Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49395 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d2d1/bitmap.c | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c index 0b5f3e6dc5a..03982924efa 100644 --- a/dlls/d2d1/bitmap.c +++ b/dlls/d2d1/bitmap.c @@ -414,7 +414,7 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, if (IsEqualGUID(iid, &IID_ID2D1Bitmap)) { struct d2d_bitmap *src_impl = unsafe_impl_from_ID2D1Bitmap(data); - ID3D10Device *device; + ID3D11Device *device; HRESULT hr = S_OK;
if (src_impl->factory != context->factory) @@ -423,9 +423,9 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, goto failed; }
- ID3D10Resource_GetDevice(src_impl->resource, &device); - ID3D10Device_Release(device); - if (device != context->d3d_device) + ID3D11Resource_GetDevice(src_impl->d3d11_resource, &device); + ID3D11Device_Release(device); + if (device != (ID3D11Device *)context->d3d11_device) { hr = D2DERR_UNSUPPORTED_OPERATION; goto failed; @@ -466,28 +466,37 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, { DXGI_SURFACE_DESC surface_desc; IDXGISurface *surface = data; - ID3D10Resource *resource; + ID3D11Resource *resource; + ID3D10Resource *d3d10_resource; D2D1_SIZE_U pixel_size; - ID3D10Device *device; + ID3D11Device *device; HRESULT hr;
- if (FAILED(IDXGISurface_QueryInterface(surface, &IID_ID3D10Resource, (void **)&resource))) + if (FAILED(IDXGISurface_QueryInterface(surface, &IID_ID3D11Resource, (void **)&resource))) { WARN("Failed to get d3d resource from dxgi surface.\n"); return E_FAIL; }
- ID3D10Resource_GetDevice(resource, &device); - ID3D10Device_Release(device); - if (device != context->d3d_device) + if (FAILED(hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D10Resource, (void **)&d3d10_resource))) { - ID3D10Resource_Release(resource); + ERR("Failed to query ID3D10Resource interface, hr %#x.\n", hr); + ID3D11Resource_Release(resource); + return hr; + } + + ID3D11Resource_GetDevice(resource, &device); + ID3D11Resource_Release(resource); + ID3D11Device_Release(device); + if (device != (ID3D11Device *)context->d3d11_device) + { + ID3D10Resource_Release(d3d10_resource); return D2DERR_UNSUPPORTED_OPERATION; }
if (!(*bitmap = heap_alloc_zero(sizeof(**bitmap)))) { - ID3D10Resource_Release(resource); + ID3D10Resource_Release(d3d10_resource); return E_OUTOFMEMORY; }
@@ -495,7 +504,7 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, if (FAILED(hr = IDXGISurface_GetDesc(surface, &surface_desc))) { WARN("Failed to get surface desc, hr %#x.\n", hr); - ID3D10Resource_Release(resource); + ID3D10Resource_Release(d3d10_resource); return hr; }
@@ -522,8 +531,8 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, pixel_size.width = surface_desc.Width; pixel_size.height = surface_desc.Height;
- d2d_bitmap_init(*bitmap, context, resource, pixel_size, &d); - ID3D10Resource_Release(resource); + d2d_bitmap_init(*bitmap, context, d3d10_resource, pixel_size, &d); + ID3D10Resource_Release(d3d10_resource); TRACE("Created bitmap %p.\n", *bitmap);
return S_OK;
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49395 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d2d1/bitmap.c | 44 +++++++++++++------------------------------- 1 file changed, 13 insertions(+), 31 deletions(-)
diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c index 03982924efa..43c1b6f8d44 100644 --- a/dlls/d2d1/bitmap.c +++ b/dlls/d2d1/bitmap.c @@ -279,20 +279,20 @@ static BOOL format_supported(const D2D1_PIXEL_FORMAT *format) }
static void d2d_bitmap_init(struct d2d_bitmap *bitmap, struct d2d_device_context *context, - ID3D10Resource *d3d10_resource, D2D1_SIZE_U size, const D2D1_BITMAP_PROPERTIES1 *desc) + ID3D11Resource *resource, D2D1_SIZE_U size, const D2D1_BITMAP_PROPERTIES1 *desc) { - ID3D11Resource *resource; + ID3D10Resource *d3d10_resource; ID3D11Device *d3d_device; HRESULT hr;
- if (FAILED(hr = ID3D10Resource_QueryInterface(d3d10_resource, &IID_ID3D11Resource, (void **)&resource))) - WARN("Failed to query ID3D11Resource interface, hr %#x.\n", hr); + if (FAILED(hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D10Resource, (void **)&d3d10_resource))) + WARN("Failed to query ID3D10Resource interface, hr %#x.\n", hr);
bitmap->ID2D1Bitmap1_iface.lpVtbl = &d2d_bitmap_vtbl; bitmap->refcount = 1; ID2D1Factory_AddRef(bitmap->factory = context->factory); - ID3D10Resource_AddRef(bitmap->resource = d3d10_resource); - bitmap->d3d11_resource = resource; + ID3D11Resource_AddRef(bitmap->d3d11_resource = resource); + bitmap->resource = d3d10_resource; bitmap->pixel_size = size; bitmap->format = desc->pixelFormat; bitmap->dpi_x = desc->dpiX; @@ -336,7 +336,6 @@ HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size, D2D1_BITMAP_PROPERTIES1 bitmap_desc; D3D11_TEXTURE2D_DESC texture_desc; ID3D11Texture2D *texture; - ID3D10Resource *resource; HRESULT hr;
if (!format_supported(&desc->pixelFormat)) @@ -388,20 +387,12 @@ HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size, return hr; }
- if (FAILED(hr = ID3D11Texture2D_QueryInterface(texture, &IID_ID3D10Resource, (void **)&resource))) - { - ERR("Failed to query ID3D10Resource interface, hr %#x.\n", hr); - ID3D11Texture2D_Release(texture); - return hr; - } - if ((*bitmap = heap_alloc_zero(sizeof(**bitmap)))) { - d2d_bitmap_init(*bitmap, context, resource, size, desc); + d2d_bitmap_init(*bitmap, context, (ID3D11Resource *)texture, size, desc); TRACE("Created bitmap %p.\n", *bitmap); } ID3D11Texture2D_Release(texture); - ID3D10Resource_Release(resource);
return *bitmap ? S_OK : E_OUTOFMEMORY; } @@ -455,7 +446,7 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, goto failed; }
- d2d_bitmap_init(*bitmap, context, src_impl->resource, src_impl->pixel_size, desc); + d2d_bitmap_init(*bitmap, context, src_impl->d3d11_resource, src_impl->pixel_size, desc); TRACE("Created bitmap %p.\n", *bitmap);
failed: @@ -467,7 +458,6 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, DXGI_SURFACE_DESC surface_desc; IDXGISurface *surface = data; ID3D11Resource *resource; - ID3D10Resource *d3d10_resource; D2D1_SIZE_U pixel_size; ID3D11Device *device; HRESULT hr; @@ -478,25 +468,17 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, return E_FAIL; }
- if (FAILED(hr = ID3D11Resource_QueryInterface(resource, &IID_ID3D10Resource, (void **)&d3d10_resource))) - { - ERR("Failed to query ID3D10Resource interface, hr %#x.\n", hr); - ID3D11Resource_Release(resource); - return hr; - } - ID3D11Resource_GetDevice(resource, &device); - ID3D11Resource_Release(resource); ID3D11Device_Release(device); if (device != (ID3D11Device *)context->d3d11_device) { - ID3D10Resource_Release(d3d10_resource); + ID3D11Resource_Release(resource); return D2DERR_UNSUPPORTED_OPERATION; }
if (!(*bitmap = heap_alloc_zero(sizeof(**bitmap)))) { - ID3D10Resource_Release(d3d10_resource); + ID3D11Resource_Release(resource); return E_OUTOFMEMORY; }
@@ -504,7 +486,7 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, if (FAILED(hr = IDXGISurface_GetDesc(surface, &surface_desc))) { WARN("Failed to get surface desc, hr %#x.\n", hr); - ID3D10Resource_Release(d3d10_resource); + ID3D11Resource_Release(resource); return hr; }
@@ -531,8 +513,8 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, pixel_size.width = surface_desc.Width; pixel_size.height = surface_desc.Height;
- d2d_bitmap_init(*bitmap, context, d3d10_resource, pixel_size, &d); - ID3D10Resource_Release(d3d10_resource); + d2d_bitmap_init(*bitmap, context, resource, pixel_size, &d); + ID3D11Resource_Release(resource); TRACE("Created bitmap %p.\n", *bitmap);
return S_OK;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49395 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d2d1/brush.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c index 1fe9b5e8f70..67c7d701b82 100644 --- a/dlls/d2d1/brush.c +++ b/dlls/d2d1/brush.c @@ -128,17 +128,19 @@ static const struct ID2D1GradientStopCollectionVtbl d2d_gradient_vtbl = };
HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D10Device *device, const D2D1_GRADIENT_STOP *stops, - UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode, struct d2d_gradient **gradient) + UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode, struct d2d_gradient **out) { D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc; D3D10_SUBRESOURCE_DATA buffer_data; ID3D10ShaderResourceView *view; + struct d2d_gradient *gradient; D3D10_BUFFER_DESC buffer_desc; struct d2d_vec4 *data; ID3D10Buffer *buffer; unsigned int i; HRESULT hr;
+ *out = NULL; if (!(data = heap_calloc(stop_count, 2 * sizeof(*data)))) { ERR("Failed to allocate data.\n"); @@ -185,7 +187,7 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D10Device *device, const D return hr; }
- if (!(*gradient = heap_alloc_zero(sizeof(**gradient)))) + if (!(gradient = heap_alloc_zero(sizeof(*gradient)))) { ID3D10ShaderResourceView_Release(view); return E_OUTOFMEMORY; @@ -196,21 +198,22 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D10Device *device, const D if (extend_mode != D2D1_EXTEND_MODE_CLAMP) FIXME("Ignoring extend mode %#x.\n", extend_mode);
- (*gradient)->ID2D1GradientStopCollection_iface.lpVtbl = &d2d_gradient_vtbl; - (*gradient)->refcount = 1; - ID2D1Factory_AddRef((*gradient)->factory = factory); - (*gradient)->view = view; + gradient->ID2D1GradientStopCollection_iface.lpVtbl = &d2d_gradient_vtbl; + gradient->refcount = 1; + ID2D1Factory_AddRef(gradient->factory = factory); + gradient->view = view;
- (*gradient)->stop_count = stop_count; - if (!((*gradient)->stops = heap_calloc(stop_count, sizeof(*stops)))) + gradient->stop_count = stop_count; + if (!(gradient->stops = heap_calloc(stop_count, sizeof(*stops)))) { ID3D10ShaderResourceView_Release(view); - heap_free(*gradient); + heap_free(gradient); return E_OUTOFMEMORY; } - memcpy((*gradient)->stops, stops, stop_count * sizeof(*stops)); + memcpy(gradient->stops, stops, stop_count * sizeof(*stops));
- TRACE("Created gradient %p.\n", *gradient); + TRACE("Created gradient %p.\n", gradient); + *out = gradient; return S_OK; }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49395 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d2d1/brush.c | 34 +++++++++++++++++++++++----------- dlls/d2d1/d2d1_private.h | 3 ++- dlls/d2d1/device.c | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c index 67c7d701b82..5932a5fa113 100644 --- a/dlls/d2d1/brush.c +++ b/dlls/d2d1/brush.c @@ -65,6 +65,7 @@ static ULONG STDMETHODCALLTYPE d2d_gradient_Release(ID2D1GradientStopCollection if (!refcount) { heap_free(gradient->stops); + ID3D11ShaderResourceView_Release(gradient->d3d11_view); ID3D10ShaderResourceView_Release(gradient->view); ID2D1Factory_Release(gradient->factory); heap_free(gradient); @@ -127,16 +128,17 @@ static const struct ID2D1GradientStopCollectionVtbl d2d_gradient_vtbl = d2d_gradient_GetExtendMode, };
-HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D10Device *device, const D2D1_GRADIENT_STOP *stops, +HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const D2D1_GRADIENT_STOP *stops, UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode, struct d2d_gradient **out) { - D3D10_SHADER_RESOURCE_VIEW_DESC srv_desc; - D3D10_SUBRESOURCE_DATA buffer_data; + D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc; + ID3D11ShaderResourceView *d3d11_view; + D3D11_SUBRESOURCE_DATA buffer_data; ID3D10ShaderResourceView *view; struct d2d_gradient *gradient; - D3D10_BUFFER_DESC buffer_desc; + D3D11_BUFFER_DESC buffer_desc; struct d2d_vec4 *data; - ID3D10Buffer *buffer; + ID3D11Buffer *buffer; unsigned int i; HRESULT hr;
@@ -157,8 +159,8 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D10Device *device, const D }
buffer_desc.ByteWidth = 2 * stop_count * sizeof(*data); - buffer_desc.Usage = D3D10_USAGE_DEFAULT; - buffer_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE; + buffer_desc.Usage = D3D11_USAGE_DEFAULT; + buffer_desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; buffer_desc.CPUAccessFlags = 0; buffer_desc.MiscFlags = 0;
@@ -166,7 +168,7 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D10Device *device, const D buffer_data.SysMemPitch = 0; buffer_data.SysMemSlicePitch = 0;
- hr = ID3D10Device_CreateBuffer(device, &buffer_desc, &buffer_data, &buffer); + hr = ID3D11Device1_CreateBuffer(device, &buffer_desc, &buffer_data, &buffer); heap_free(data); if (FAILED(hr)) { @@ -175,21 +177,29 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D10Device *device, const D }
srv_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; - srv_desc.ViewDimension = D3D10_SRV_DIMENSION_BUFFER; + srv_desc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; srv_desc.Buffer.ElementOffset = 0; srv_desc.Buffer.ElementWidth = 2 * stop_count;
- hr = ID3D10Device_CreateShaderResourceView(device, (ID3D10Resource *)buffer, &srv_desc, &view); - ID3D10Buffer_Release(buffer); + hr = ID3D11Device1_CreateShaderResourceView(device, (ID3D11Resource *)buffer, &srv_desc, &d3d11_view); + ID3D11Buffer_Release(buffer); if (FAILED(hr)) { ERR("Failed to create view, hr %#x.\n", hr); return hr; }
+ if (FAILED(hr = ID3D11ShaderResourceView_QueryInterface(d3d11_view, &IID_ID3D10ShaderResourceView, (void **)&view))) + { + ERR("Failed to query D3D10 view, hr %#x.\n", hr); + ID3D11ShaderResourceView_Release(d3d11_view); + return hr; + } + if (!(gradient = heap_alloc_zero(sizeof(*gradient)))) { ID3D10ShaderResourceView_Release(view); + ID3D11ShaderResourceView_Release(d3d11_view); return E_OUTOFMEMORY; }
@@ -202,11 +212,13 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D10Device *device, const D gradient->refcount = 1; ID2D1Factory_AddRef(gradient->factory = factory); gradient->view = view; + gradient->d3d11_view = d3d11_view;
gradient->stop_count = stop_count; if (!(gradient->stops = heap_calloc(stop_count, sizeof(*stops)))) { ID3D10ShaderResourceView_Release(view); + ID3D11ShaderResourceView_Release(d3d11_view); heap_free(gradient); return E_OUTOFMEMORY; } diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 573899ba91a..e2510568e3c 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -273,11 +273,12 @@ struct d2d_gradient
ID2D1Factory *factory; ID3D10ShaderResourceView *view; + ID3D11ShaderResourceView *d3d11_view; D2D1_GRADIENT_STOP *stops; UINT32 stop_count; };
-HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D10Device *device, const D2D1_GRADIENT_STOP *stops, +HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const D2D1_GRADIENT_STOP *stops, UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode, struct d2d_gradient **gradient) DECLSPEC_HIDDEN;
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 5767a83f39b..6390037bce3 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -457,7 +457,7 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateGradientStopCollection TRACE("iface %p, stops %p, stop_count %u, gamma %#x, extend_mode %#x, gradient %p.\n", iface, stops, stop_count, gamma, extend_mode, gradient);
- if (SUCCEEDED(hr = d2d_gradient_create(render_target->factory, render_target->d3d_device, + if (SUCCEEDED(hr = d2d_gradient_create(render_target->factory, render_target->d3d11_device, stops, stop_count, gamma, extend_mode, &object))) *gradient = &object->ID2D1GradientStopCollection_iface;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49395 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d2d1/d2d1_private.h | 8 +- dlls/d2d1/device.c | 209 ++++++++++++++++++++++++--------------- 2 files changed, 135 insertions(+), 82 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index e2510568e3c..e85c93ec277 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -166,12 +166,12 @@ struct d2d_device_context struct d2d_bitmap *target; ID3D10StateBlock *stateblock; struct d2d_shape_resources shape_resources[D2D_SHAPE_TYPE_COUNT]; - ID3D10Buffer *vs_cb; + ID3D11Buffer *vs_cb; ID3D10PixelShader *ps; - ID3D10Buffer *ps_cb; - ID3D10Buffer *ib; + ID3D11Buffer *ps_cb; + ID3D11Buffer *ib; unsigned int vb_stride; - ID3D10Buffer *vb; + ID3D11Buffer *vb; ID3D10RasterizerState *rs; ID3D10BlendState *bs; ID3D10SamplerState *sampler_states diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 6390037bce3..c5bfa125566 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -118,11 +118,13 @@ static void d2d_clip_stack_pop(struct d2d_clip_stack *stack) }
static void d2d_device_context_draw(struct d2d_device_context *render_target, enum d2d_shape_type shape_type, - ID3D10Buffer *ib, unsigned int index_count, ID3D10Buffer *vb, unsigned int vb_stride, + ID3D11Buffer *ib, unsigned int index_count, ID3D11Buffer *vb, unsigned int vb_stride, struct d2d_brush *brush, struct d2d_brush *opacity_brush) { struct d2d_shape_resources *shape_resources = &render_target->shape_resources[shape_type]; ID3D10Device *device = render_target->d3d_device; + ID3D10Buffer *d3d10_ib = NULL, *d3d10_vb = NULL, *d3d10_vs_cb = NULL, *d3d10_ps_cb = NULL; + ID3D11Buffer *vs_cb = render_target->vs_cb, *ps_cb = render_target->ps_cb; D3D10_RECT scissor_rect; unsigned int offset; D3D10_VIEWPORT vp; @@ -135,22 +137,46 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f;
+ if (ib && FAILED(hr = ID3D11Buffer_QueryInterface(ib, &IID_ID3D10Buffer, (void **)&d3d10_ib))) + { + ERR("Failed to query D3D10 index buffer, hr %#x.\n", hr); + goto error; + } + + if (vb && FAILED(hr = ID3D11Buffer_QueryInterface(vb, &IID_ID3D10Buffer, (void **)&d3d10_vb))) + { + ERR("Failed to query D3D10 vertex buffer, hr %#x.\n", hr); + goto error; + } + + if (vs_cb && FAILED(hr = ID3D11Buffer_QueryInterface(vs_cb, &IID_ID3D10Buffer, (void **)&d3d10_vs_cb))) + { + ERR("Failed to query D3D10 VS constant buffer, hr %#x.\n", hr); + goto error; + } + + if (ps_cb && FAILED(hr = ID3D11Buffer_QueryInterface(ps_cb, &IID_ID3D10Buffer, (void **)&d3d10_ps_cb))) + { + ERR("Failed to query D3D10 PS constant buffer, hr %#x.\n", hr); + goto error; + } + if (FAILED(hr = render_target->stateblock->lpVtbl->Capture(render_target->stateblock))) { WARN("Failed to capture stateblock, hr %#x.\n", hr); - return; + goto error; }
ID3D10Device_ClearState(device);
ID3D10Device_IASetInputLayout(device, shape_resources->il); ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - ID3D10Device_IASetIndexBuffer(device, ib, DXGI_FORMAT_R16_UINT, 0); + ID3D10Device_IASetIndexBuffer(device, d3d10_ib, DXGI_FORMAT_R16_UINT, 0); offset = 0; - ID3D10Device_IASetVertexBuffers(device, 0, 1, &vb, &vb_stride, &offset); - ID3D10Device_VSSetConstantBuffers(device, 0, 1, &render_target->vs_cb); + ID3D10Device_IASetVertexBuffers(device, 0, 1, &d3d10_vb, &vb_stride, &offset); + ID3D10Device_VSSetConstantBuffers(device, 0, 1, &d3d10_vs_cb); ID3D10Device_VSSetShader(device, shape_resources->vs); - ID3D10Device_PSSetConstantBuffers(device, 0, 1, &render_target->ps_cb); + ID3D10Device_PSSetConstantBuffers(device, 0, 1, &d3d10_ps_cb); ID3D10Device_PSSetShader(device, render_target->ps); ID3D10Device_RSSetViewports(device, 1, &vp); if (render_target->clip_stack.count) @@ -188,6 +214,12 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en
if (FAILED(hr = render_target->stateblock->lpVtbl->Apply(render_target->stateblock))) WARN("Failed to apply stateblock, hr %#x.\n", hr); + +error: + if (d3d10_ib) ID3D10Buffer_Release(d3d10_ib); + if (d3d10_vb) ID3D10Buffer_Release(d3d10_vb); + if (d3d10_vs_cb) ID3D10Buffer_Release(d3d10_vs_cb); + if (d3d10_ps_cb) ID3D10Buffer_Release(d3d10_ps_cb); }
static void d2d_device_context_set_error(struct d2d_device_context *context, HRESULT code) @@ -263,11 +295,11 @@ static ULONG STDMETHODCALLTYPE d2d_device_context_inner_Release(IUnknown *iface) if (context->bs) ID3D10BlendState_Release(context->bs); ID3D10RasterizerState_Release(context->rs); - ID3D10Buffer_Release(context->vb); - ID3D10Buffer_Release(context->ib); - ID3D10Buffer_Release(context->ps_cb); + ID3D11Buffer_Release(context->vb); + ID3D11Buffer_Release(context->ib); + ID3D11Buffer_Release(context->ps_cb); ID3D10PixelShader_Release(context->ps); - ID3D10Buffer_Release(context->vs_cb); + ID3D11Buffer_Release(context->vs_cb); for (i = 0; i < D2D_SHAPE_TYPE_COUNT; ++i) { ID3D10VertexShader_Release(context->shape_resources[i].vs); @@ -712,15 +744,21 @@ static void STDMETHODCALLTYPE d2d_device_context_FillEllipse(ID2D1DeviceContext static HRESULT d2d_device_context_update_ps_cb(struct d2d_device_context *context, struct d2d_brush *brush, struct d2d_brush *opacity_brush, BOOL outline, BOOL is_arc) { + D3D11_MAPPED_SUBRESOURCE map_desc; + ID3D11DeviceContext *d3d_context; struct d2d_ps_cb *cb_data; HRESULT hr;
- if (FAILED(hr = ID3D10Buffer_Map(context->ps_cb, D3D10_MAP_WRITE_DISCARD, 0, (void **)&cb_data))) + ID3D11Device1_GetImmediateContext(context->d3d11_device, &d3d_context); + + if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)context->ps_cb, 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc))) { WARN("Failed to map constant buffer, hr %#x.\n", hr); + ID3D11DeviceContext_Release(d3d_context); return hr; }
+ cb_data = map_desc.pData; cb_data->outline = outline; cb_data->is_arc = is_arc; cb_data->pad[0] = 0; @@ -730,7 +768,8 @@ static HRESULT d2d_device_context_update_ps_cb(struct d2d_device_context *contex if (!d2d_brush_fill_cb(opacity_brush, &cb_data->opacity_brush)) WARN("Failed to initialize opacity brush buffer.\n");
- ID3D10Buffer_Unmap(context->ps_cb); + ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)context->ps_cb, 0); + ID3D11DeviceContext_Release(d3d_context);
return hr; } @@ -738,17 +777,23 @@ static HRESULT d2d_device_context_update_ps_cb(struct d2d_device_context *contex static HRESULT d2d_device_context_update_vs_cb(struct d2d_device_context *context, const D2D_MATRIX_3X2_F *geometry_transform, float stroke_width) { + D3D11_MAPPED_SUBRESOURCE map_desc; + ID3D11DeviceContext *d3d_context; const D2D1_MATRIX_3X2_F *w; struct d2d_vs_cb *cb_data; float tmp_x, tmp_y; HRESULT hr;
- if (FAILED(hr = ID3D10Buffer_Map(context->vs_cb, D3D10_MAP_WRITE_DISCARD, 0, (void **)&cb_data))) + ID3D11Device1_GetImmediateContext(context->d3d11_device, &d3d_context); + + if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)context->vs_cb, 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc))) { WARN("Failed to map constant buffer, hr %#x.\n", hr); + ID3D11DeviceContext_Release(d3d_context); return hr; }
+ cb_data = map_desc.pData; cb_data->transform_geometry._11 = geometry_transform->_11; cb_data->transform_geometry._21 = geometry_transform->_21; cb_data->transform_geometry._31 = geometry_transform->_31; @@ -772,7 +817,8 @@ static HRESULT d2d_device_context_update_vs_cb(struct d2d_device_context *contex cb_data->transform_rty.z = w->_32 * tmp_y; cb_data->transform_rty.w = -2.0f / context->pixel_size.height;
- ID3D10Buffer_Unmap(context->vs_cb); + ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)context->vs_cb, 0); + ID3D11DeviceContext_Release(d3d_context);
return S_OK; } @@ -780,9 +826,9 @@ static HRESULT d2d_device_context_update_vs_cb(struct d2d_device_context *contex static void d2d_device_context_draw_geometry(struct d2d_device_context *render_target, const struct d2d_geometry *geometry, struct d2d_brush *brush, float stroke_width) { - D3D10_SUBRESOURCE_DATA buffer_data; - D3D10_BUFFER_DESC buffer_desc; - ID3D10Buffer *ib, *vb; + D3D11_SUBRESOURCE_DATA buffer_data; + D3D11_BUFFER_DESC buffer_desc; + ID3D11Buffer *ib, *vb; HRESULT hr;
if (FAILED(hr = d2d_device_context_update_vs_cb(render_target, &geometry->transform, stroke_width))) @@ -797,7 +843,7 @@ static void d2d_device_context_draw_geometry(struct d2d_device_context *render_t return; }
- buffer_desc.Usage = D3D10_USAGE_DEFAULT; + buffer_desc.Usage = D3D11_USAGE_DEFAULT; buffer_desc.CPUAccessFlags = 0; buffer_desc.MiscFlags = 0;
@@ -807,53 +853,53 @@ static void d2d_device_context_draw_geometry(struct d2d_device_context *render_t if (geometry->outline.face_count) { buffer_desc.ByteWidth = geometry->outline.face_count * sizeof(*geometry->outline.faces); - buffer_desc.BindFlags = D3D10_BIND_INDEX_BUFFER; + buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER; buffer_data.pSysMem = geometry->outline.faces;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &ib))) { WARN("Failed to create index buffer, hr %#x.\n", hr); return; }
buffer_desc.ByteWidth = geometry->outline.vertex_count * sizeof(*geometry->outline.vertices); - buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER; + buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; buffer_data.pSysMem = geometry->outline.vertices;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &vb))) { ERR("Failed to create vertex buffer, hr %#x.\n", hr); - ID3D10Buffer_Release(ib); + ID3D11Buffer_Release(ib); return; }
d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_OUTLINE, ib, 3 * geometry->outline.face_count, vb, sizeof(*geometry->outline.vertices), brush, NULL);
- ID3D10Buffer_Release(vb); - ID3D10Buffer_Release(ib); + ID3D11Buffer_Release(vb); + ID3D11Buffer_Release(ib); }
if (geometry->outline.bezier_face_count) { buffer_desc.ByteWidth = geometry->outline.bezier_face_count * sizeof(*geometry->outline.bezier_faces); - buffer_desc.BindFlags = D3D10_BIND_INDEX_BUFFER; + buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER; buffer_data.pSysMem = geometry->outline.bezier_faces;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &ib))) { WARN("Failed to create beziers index buffer, hr %#x.\n", hr); return; }
buffer_desc.ByteWidth = geometry->outline.bezier_count * sizeof(*geometry->outline.beziers); - buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER; + buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; buffer_data.pSysMem = geometry->outline.beziers;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &vb))) { ERR("Failed to create beziers vertex buffer, hr %#x.\n", hr); - ID3D10Buffer_Release(ib); + ID3D11Buffer_Release(ib); return; }
@@ -861,30 +907,30 @@ static void d2d_device_context_draw_geometry(struct d2d_device_context *render_t 3 * geometry->outline.bezier_face_count, vb, sizeof(*geometry->outline.beziers), brush, NULL);
- ID3D10Buffer_Release(vb); - ID3D10Buffer_Release(ib); + ID3D11Buffer_Release(vb); + ID3D11Buffer_Release(ib); }
if (geometry->outline.arc_face_count) { buffer_desc.ByteWidth = geometry->outline.arc_face_count * sizeof(*geometry->outline.arc_faces); - buffer_desc.BindFlags = D3D10_BIND_INDEX_BUFFER; + buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER; buffer_data.pSysMem = geometry->outline.arc_faces;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &ib))) { WARN("Failed to create arcs index buffer, hr %#x.\n", hr); return; }
buffer_desc.ByteWidth = geometry->outline.arc_count * sizeof(*geometry->outline.arcs); - buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER; + buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; buffer_data.pSysMem = geometry->outline.arcs;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &vb))) { ERR("Failed to create arcs vertex buffer, hr %#x.\n", hr); - ID3D10Buffer_Release(ib); + ID3D11Buffer_Release(ib); return; }
@@ -893,8 +939,8 @@ static void d2d_device_context_draw_geometry(struct d2d_device_context *render_t 3 * geometry->outline.arc_face_count, vb, sizeof(*geometry->outline.arcs), brush, NULL);
- ID3D10Buffer_Release(vb); - ID3D10Buffer_Release(ib); + ID3D11Buffer_Release(vb); + ID3D11Buffer_Release(ib); } }
@@ -917,12 +963,12 @@ static void STDMETHODCALLTYPE d2d_device_context_DrawGeometry(ID2D1DeviceContext static void d2d_device_context_fill_geometry(struct d2d_device_context *render_target, const struct d2d_geometry *geometry, struct d2d_brush *brush, struct d2d_brush *opacity_brush) { - D3D10_SUBRESOURCE_DATA buffer_data; - D3D10_BUFFER_DESC buffer_desc; - ID3D10Buffer *ib, *vb; + D3D11_SUBRESOURCE_DATA buffer_data; + D3D11_BUFFER_DESC buffer_desc; + ID3D11Buffer *ib, *vb; HRESULT hr;
- buffer_desc.Usage = D3D10_USAGE_DEFAULT; + buffer_desc.Usage = D3D11_USAGE_DEFAULT; buffer_desc.CPUAccessFlags = 0; buffer_desc.MiscFlags = 0;
@@ -944,40 +990,40 @@ static void d2d_device_context_fill_geometry(struct d2d_device_context *render_t if (geometry->fill.face_count) { buffer_desc.ByteWidth = geometry->fill.face_count * sizeof(*geometry->fill.faces); - buffer_desc.BindFlags = D3D10_BIND_INDEX_BUFFER; + buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER; buffer_data.pSysMem = geometry->fill.faces;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &ib))) { WARN("Failed to create index buffer, hr %#x.\n", hr); return; }
buffer_desc.ByteWidth = geometry->fill.vertex_count * sizeof(*geometry->fill.vertices); - buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER; + buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; buffer_data.pSysMem = geometry->fill.vertices;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &vb))) { ERR("Failed to create vertex buffer, hr %#x.\n", hr); - ID3D10Buffer_Release(ib); + ID3D11Buffer_Release(ib); return; }
d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_TRIANGLE, ib, 3 * geometry->fill.face_count, vb, sizeof(*geometry->fill.vertices), brush, opacity_brush);
- ID3D10Buffer_Release(vb); - ID3D10Buffer_Release(ib); + ID3D11Buffer_Release(vb); + ID3D11Buffer_Release(ib); }
if (geometry->fill.bezier_vertex_count) { buffer_desc.ByteWidth = geometry->fill.bezier_vertex_count * sizeof(*geometry->fill.bezier_vertices); - buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER; + buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; buffer_data.pSysMem = geometry->fill.bezier_vertices;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &vb))) { ERR("Failed to create beziers vertex buffer, hr %#x.\n", hr); return; @@ -986,16 +1032,16 @@ static void d2d_device_context_fill_geometry(struct d2d_device_context *render_t d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_CURVE, NULL, geometry->fill.bezier_vertex_count, vb, sizeof(*geometry->fill.bezier_vertices), brush, opacity_brush);
- ID3D10Buffer_Release(vb); + ID3D11Buffer_Release(vb); }
if (geometry->fill.arc_vertex_count) { buffer_desc.ByteWidth = geometry->fill.arc_vertex_count * sizeof(*geometry->fill.arc_vertices); - buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER; + buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; buffer_data.pSysMem = geometry->fill.arc_vertices;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &vb))) { ERR("Failed to create arc vertex buffer, hr %#x.\n", hr); return; @@ -1005,7 +1051,7 @@ static void d2d_device_context_fill_geometry(struct d2d_device_context *render_t d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_CURVE, NULL, geometry->fill.arc_vertex_count, vb, sizeof(*geometry->fill.arc_vertices), brush, opacity_brush);
- ID3D10Buffer_Release(vb); + ID3D11Buffer_Release(vb); } }
@@ -1602,6 +1648,8 @@ static void STDMETHODCALLTYPE d2d_device_context_PopAxisAlignedClip(ID2D1DeviceC static void STDMETHODCALLTYPE d2d_device_context_Clear(ID2D1DeviceContext *iface, const D2D1_COLOR_F *colour) { struct d2d_device_context *render_target = impl_from_ID2D1DeviceContext(iface); + D3D11_MAPPED_SUBRESOURCE map_desc; + ID3D11DeviceContext *d3d_context; struct d2d_ps_cb *ps_cb_data; struct d2d_vs_cb *vs_cb_data; D2D1_COLOR_F *c; @@ -1609,13 +1657,16 @@ static void STDMETHODCALLTYPE d2d_device_context_Clear(ID2D1DeviceContext *iface
TRACE("iface %p, colour %p.\n", iface, colour);
- if (FAILED(hr = ID3D10Buffer_Map(render_target->vs_cb, D3D10_MAP_WRITE_DISCARD, - 0, (void **)&vs_cb_data))) + ID3D11Device1_GetImmediateContext(render_target->d3d11_device, &d3d_context); + + if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)render_target->vs_cb, 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc))) { WARN("Failed to map vs constant buffer, hr %#x.\n", hr); + ID3D11DeviceContext_Release(d3d_context); return; }
+ vs_cb_data = map_desc.pData; vs_cb_data->transform_geometry._11 = 1.0f; vs_cb_data->transform_geometry._21 = 0.0f; vs_cb_data->transform_geometry._31 = 0.0f; @@ -1633,15 +1684,16 @@ static void STDMETHODCALLTYPE d2d_device_context_Clear(ID2D1DeviceContext *iface vs_cb_data->transform_rty.z = 1.0f; vs_cb_data->transform_rty.w = -1.0f;
- ID3D10Buffer_Unmap(render_target->vs_cb); + ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)render_target->vs_cb, 0);
- if (FAILED(hr = ID3D10Buffer_Map(render_target->ps_cb, D3D10_MAP_WRITE_DISCARD, - 0, (void **)&ps_cb_data))) + if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)render_target->ps_cb, 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc))) { - WARN("Failed to map ps constant buffer, hr %#x.\n", hr); + WARN("Failed to map vs constant buffer, hr %#x.\n", hr); + ID3D11DeviceContext_Release(d3d_context); return; }
+ ps_cb_data = map_desc.pData; memset(ps_cb_data, 0, sizeof(*ps_cb_data)); ps_cb_data->colour_brush.type = D2D_BRUSH_TYPE_SOLID; ps_cb_data->colour_brush.opacity = 1.0f; @@ -1655,7 +1707,8 @@ static void STDMETHODCALLTYPE d2d_device_context_Clear(ID2D1DeviceContext *iface c->g *= c->a; c->b *= c->a;
- ID3D10Buffer_Unmap(render_target->ps_cb); + ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)render_target->ps_cb, 0); + ID3D11DeviceContext_Release(d3d_context);
d2d_device_context_draw(render_target, D2D_SHAPE_TYPE_TRIANGLE, render_target->ib, 6, render_target->vb, render_target->vb_stride, NULL, NULL); @@ -2774,12 +2827,12 @@ static const struct ID2D1GdiInteropRenderTargetVtbl d2d_gdi_interop_render_targe static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, ID2D1Device *device, IUnknown *outer_unknown, const struct d2d_device_context_ops *ops) { - D3D10_SUBRESOURCE_DATA buffer_data; + D3D11_SUBRESOURCE_DATA buffer_data; D3D10_STATE_BLOCK_MASK state_mask; struct d2d_device *device_impl; IDWriteFactory *dwrite_factory; D3D10_RASTERIZER_DESC rs_desc; - D3D10_BUFFER_DESC buffer_desc; + D3D11_BUFFER_DESC buffer_desc; unsigned int i; HRESULT hr;
@@ -3891,12 +3944,12 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, }
buffer_desc.ByteWidth = sizeof(struct d2d_vs_cb); - buffer_desc.Usage = D3D10_USAGE_DYNAMIC; + buffer_desc.Usage = D3D11_USAGE_DYNAMIC; buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER; buffer_desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; buffer_desc.MiscFlags = 0;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, &buffer_desc, NULL, + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, NULL, &render_target->vs_cb))) { WARN("Failed to create constant buffer, hr %#x.\n", hr); @@ -3911,12 +3964,12 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, }
buffer_desc.ByteWidth = sizeof(struct d2d_ps_cb); - buffer_desc.Usage = D3D10_USAGE_DYNAMIC; + buffer_desc.Usage = D3D11_USAGE_DYNAMIC; buffer_desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER; buffer_desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; buffer_desc.MiscFlags = 0;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, &buffer_desc, NULL, + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, NULL, &render_target->ps_cb))) { WARN("Failed to create constant buffer, hr %#x.\n", hr); @@ -3924,8 +3977,8 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, }
buffer_desc.ByteWidth = sizeof(indices); - buffer_desc.Usage = D3D10_USAGE_DEFAULT; - buffer_desc.BindFlags = D3D10_BIND_INDEX_BUFFER; + buffer_desc.Usage = D3D11_USAGE_DEFAULT; + buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER; buffer_desc.CPUAccessFlags = 0; buffer_desc.MiscFlags = 0;
@@ -3933,7 +3986,7 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, buffer_data.SysMemPitch = 0; buffer_data.SysMemSlicePitch = 0;
- if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &render_target->ib))) { WARN("Failed to create clear index buffer, hr %#x.\n", hr); @@ -3941,11 +3994,11 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, }
buffer_desc.ByteWidth = sizeof(quad); - buffer_desc.BindFlags = D3D10_BIND_VERTEX_BUFFER; + buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; buffer_data.pSysMem = quad;
render_target->vb_stride = sizeof(*quad); - if (FAILED(hr = ID3D10Device_CreateBuffer(render_target->d3d_device, + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &render_target->vb))) { WARN("Failed to create clear vertex buffer, hr %#x.\n", hr); @@ -4003,15 +4056,15 @@ err: if (render_target->rs) ID3D10RasterizerState_Release(render_target->rs); if (render_target->vb) - ID3D10Buffer_Release(render_target->vb); + ID3D11Buffer_Release(render_target->vb); if (render_target->ib) - ID3D10Buffer_Release(render_target->ib); + ID3D11Buffer_Release(render_target->ib); if (render_target->ps_cb) - ID3D10Buffer_Release(render_target->ps_cb); + ID3D11Buffer_Release(render_target->ps_cb); if (render_target->ps) ID3D10PixelShader_Release(render_target->ps); if (render_target->vs_cb) - ID3D10Buffer_Release(render_target->vs_cb); + ID3D11Buffer_Release(render_target->vs_cb); for (i = 0; i < D2D_SHAPE_TYPE_COUNT; ++i) { if (render_target->shape_resources[i].vs)
On Thu, 24 Jun 2021 at 09:36, Rémi Bernon rbernon@codeweavers.com wrote:
@@ -1633,15 +1684,16 @@ static void STDMETHODCALLTYPE d2d_device_context_Clear(ID2D1DeviceContext *iface vs_cb_data->transform_rty.z = 1.0f; vs_cb_data->transform_rty.w = -1.0f;
- ID3D10Buffer_Unmap(render_target->vs_cb);
- ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)render_target->vs_cb, 0);
- if (FAILED(hr = ID3D10Buffer_Map(render_target->ps_cb, D3D10_MAP_WRITE_DISCARD,
0, (void **)&ps_cb_data)))
- if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)render_target->ps_cb, 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc))) {
WARN("Failed to map ps constant buffer, hr %#x.\n", hr);
WARN("Failed to map vs constant buffer, hr %#x.\n", hr);
}ID3D11DeviceContext_Release(d3d_context); return;
That change to that WARN doesn't seem quite right.
On 6/24/21 5:02 PM, Henri Verbeet wrote:
On Thu, 24 Jun 2021 at 09:36, Rémi Bernon rbernon@codeweavers.com wrote:
@@ -1633,15 +1684,16 @@ static void STDMETHODCALLTYPE d2d_device_context_Clear(ID2D1DeviceContext *iface vs_cb_data->transform_rty.z = 1.0f; vs_cb_data->transform_rty.w = -1.0f;
- ID3D10Buffer_Unmap(render_target->vs_cb);
- ID3D11DeviceContext_Unmap(d3d_context, (ID3D11Resource *)render_target->vs_cb, 0);
- if (FAILED(hr = ID3D10Buffer_Map(render_target->ps_cb, D3D10_MAP_WRITE_DISCARD,
0, (void **)&ps_cb_data)))
- if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)render_target->ps_cb, 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc))) {
WARN("Failed to map ps constant buffer, hr %#x.\n", hr);
WARN("Failed to map vs constant buffer, hr %#x.\n", hr);
ID3D11DeviceContext_Release(d3d_context); return; }
That change to that WARN doesn't seem quite right.
Indeed, thanks.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49395 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d2d1/d2d1_private.h | 2 +- dlls/d2d1/device.c | 50 +++++++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index e85c93ec277..0f4b52f4c3e 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -73,7 +73,7 @@ struct d2d_error_state
struct d2d_shape_resources { - ID3D10InputLayout *il; + ID3D11InputLayout *il; ID3D10VertexShader *vs; };
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index c5bfa125566..e378374f7cf 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -125,6 +125,7 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en ID3D10Device *device = render_target->d3d_device; ID3D10Buffer *d3d10_ib = NULL, *d3d10_vb = NULL, *d3d10_vs_cb = NULL, *d3d10_ps_cb = NULL; ID3D11Buffer *vs_cb = render_target->vs_cb, *ps_cb = render_target->ps_cb; + ID3D10InputLayout *d3d10_il = NULL; D3D10_RECT scissor_rect; unsigned int offset; D3D10_VIEWPORT vp; @@ -161,6 +162,12 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en goto error; }
+ if (shape_resources->il && FAILED(hr = ID3D11InputLayout_QueryInterface(shape_resources->il, &IID_ID3D10InputLayout, (void **)&d3d10_il))) + { + ERR("Failed to query D3D10 input layout, hr %#x.\n", hr); + goto error; + } + if (FAILED(hr = render_target->stateblock->lpVtbl->Capture(render_target->stateblock))) { WARN("Failed to capture stateblock, hr %#x.\n", hr); @@ -169,7 +176,7 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en
ID3D10Device_ClearState(device);
- ID3D10Device_IASetInputLayout(device, shape_resources->il); + ID3D10Device_IASetInputLayout(device, d3d10_il); ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST); ID3D10Device_IASetIndexBuffer(device, d3d10_ib, DXGI_FORMAT_R16_UINT, 0); offset = 0; @@ -216,6 +223,7 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en WARN("Failed to apply stateblock, hr %#x.\n", hr);
error: + if (d3d10_il) ID3D10InputLayout_Release(d3d10_il); if (d3d10_ib) ID3D10Buffer_Release(d3d10_ib); if (d3d10_vb) ID3D10Buffer_Release(d3d10_vb); if (d3d10_vs_cb) ID3D10Buffer_Release(d3d10_vs_cb); @@ -303,7 +311,7 @@ static ULONG STDMETHODCALLTYPE d2d_device_context_inner_Release(IUnknown *iface) for (i = 0; i < D2D_SHAPE_TYPE_COUNT; ++i) { ID3D10VertexShader_Release(context->shape_resources[i].vs); - ID3D10InputLayout_Release(context->shape_resources[i].il); + ID3D11InputLayout_Release(context->shape_resources[i].il); } for (i = 0; i < D2D_SAMPLER_INTERPOLATION_MODE_COUNT; ++i) { @@ -2836,29 +2844,29 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, unsigned int i; HRESULT hr;
- static const D3D10_INPUT_ELEMENT_DESC il_desc_outline[] = + static const D3D11_INPUT_ELEMENT_DESC il_desc_outline[] = { - {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}, - {"PREV", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D10_INPUT_PER_VERTEX_DATA, 0}, - {"NEXT", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D10_INPUT_PER_VERTEX_DATA, 0}, + {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"PREV", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"NEXT", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0}, }; - static const D3D10_INPUT_ELEMENT_DESC il_desc_curve_outline[] = + static const D3D11_INPUT_ELEMENT_DESC il_desc_curve_outline[] = { - {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}, - {"P", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D10_INPUT_PER_VERTEX_DATA, 0}, - {"P", 1, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D10_INPUT_PER_VERTEX_DATA, 0}, - {"P", 2, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D10_INPUT_PER_VERTEX_DATA, 0}, - {"PREV", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 32, D3D10_INPUT_PER_VERTEX_DATA, 0}, - {"NEXT", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 40, D3D10_INPUT_PER_VERTEX_DATA, 0}, + {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"P", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"P", 1, DXGI_FORMAT_R32G32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"P", 2, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"PREV", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"NEXT", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 40, D3D11_INPUT_PER_VERTEX_DATA, 0}, }; - static const D3D10_INPUT_ELEMENT_DESC il_desc_triangle[] = + static const D3D11_INPUT_ELEMENT_DESC il_desc_triangle[] = { - {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}, + {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, }; - static const D3D10_INPUT_ELEMENT_DESC il_desc_curve[] = + static const D3D11_INPUT_ELEMENT_DESC il_desc_curve[] = { - {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0}, - {"TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 8, D3D10_INPUT_PER_VERTEX_DATA, 0}, + {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0}, }; static const DWORD vs_code_outline[] = { @@ -3852,7 +3860,7 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, static const struct shape_info { enum d2d_shape_type shape_type; - const D3D10_INPUT_ELEMENT_DESC *il_desc; + const D3D11_INPUT_ELEMENT_DESC *il_desc; unsigned int il_element_count; const void *vs_code; size_t vs_code_size; @@ -3927,7 +3935,7 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, { const struct shape_info *si = &shape_info[i];
- if (FAILED(hr = ID3D10Device_CreateInputLayout(render_target->d3d_device, si->il_desc, si->il_element_count, + if (FAILED(hr = ID3D11Device1_CreateInputLayout(render_target->d3d11_device, si->il_desc, si->il_element_count, si->vs_code, si->vs_code_size, &render_target->shape_resources[si->shape_type].il))) { WARN("Failed to create input layout for shape type %#x, hr %#x.\n", si->shape_type, hr); @@ -4070,7 +4078,7 @@ err: if (render_target->shape_resources[i].vs) ID3D10VertexShader_Release(render_target->shape_resources[i].vs); if (render_target->shape_resources[i].il) - ID3D10InputLayout_Release(render_target->shape_resources[i].il); + ID3D11InputLayout_Release(render_target->shape_resources[i].il); } if (render_target->stateblock) render_target->stateblock->lpVtbl->Release(render_target->stateblock);