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 | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 73259835786..0915bc55cfd 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -172,7 +172,7 @@ struct d2d_device_context ID3D11Buffer *ib; unsigned int vb_stride; ID3D11Buffer *vb; - ID3D10RasterizerState *rs; + ID3D11RasterizerState *rs; ID3D10BlendState *bs; ID3D10SamplerState *sampler_states [D2D_SAMPLER_INTERPOLATION_MODE_COUNT] diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index efeeaf6aa18..0a0e9f5bbe6 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; + ID3D10RasterizerState *d3d10_rs = NULL; ID3D10VertexShader *d3d10_vs = NULL; ID3D10PixelShader *d3d10_ps = NULL; ID3D10InputLayout *d3d10_il = NULL; @@ -182,6 +183,12 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en goto error; }
+ if (render_target->rs && FAILED(hr = ID3D11RasterizerState_QueryInterface(render_target->rs, &IID_ID3D10RasterizerState, (void **)&d3d10_rs))) + { + ERR("Failed to query D3D10 rasterizer state, 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); @@ -218,7 +225,7 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en scissor_rect.bottom = render_target->pixel_size.height; } ID3D10Device_RSSetScissorRects(device, 1, &scissor_rect); - ID3D10Device_RSSetState(device, render_target->rs); + ID3D10Device_RSSetState(device, d3d10_rs); ID3D10Device_OMSetRenderTargets(device, 1, &render_target->target->rtv, NULL); if (brush) { @@ -237,6 +244,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_rs) ID3D10RasterizerState_Release(d3d10_rs); if (d3d10_ps) ID3D10PixelShader_Release(d3d10_ps); if (d3d10_vs) ID3D10VertexShader_Release(d3d10_vs); if (d3d10_il) ID3D10InputLayout_Release(d3d10_il); @@ -318,7 +326,7 @@ static ULONG STDMETHODCALLTYPE d2d_device_context_inner_Release(IUnknown *iface) IDWriteRenderingParams_Release(context->text_rendering_params); if (context->bs) ID3D10BlendState_Release(context->bs); - ID3D10RasterizerState_Release(context->rs); + ID3D11RasterizerState_Release(context->rs); ID3D11Buffer_Release(context->vb); ID3D11Buffer_Release(context->ib); ID3D11Buffer_Release(context->ps_cb); @@ -2859,7 +2867,7 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, D3D10_STATE_BLOCK_MASK state_mask; struct d2d_device *device_impl; IDWriteFactory *dwrite_factory; - D3D10_RASTERIZER_DESC rs_desc; + D3D11_RASTERIZER_DESC rs_desc; D3D11_BUFFER_DESC buffer_desc; unsigned int i; HRESULT hr; @@ -4033,8 +4041,8 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, goto err; }
- rs_desc.FillMode = D3D10_FILL_SOLID; - rs_desc.CullMode = D3D10_CULL_NONE; + rs_desc.FillMode = D3D11_FILL_SOLID; + rs_desc.CullMode = D3D11_CULL_NONE; rs_desc.FrontCounterClockwise = FALSE; rs_desc.DepthBias = 0; rs_desc.DepthBiasClamp = 0.0f; @@ -4043,7 +4051,7 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, rs_desc.ScissorEnable = TRUE; rs_desc.MultisampleEnable = FALSE; rs_desc.AntialiasedLineEnable = FALSE; - if (FAILED(hr = ID3D10Device_CreateRasterizerState(render_target->d3d_device, &rs_desc, &render_target->rs))) + if (FAILED(hr = ID3D11Device1_CreateRasterizerState(render_target->d3d11_device, &rs_desc, &render_target->rs))) { WARN("Failed to create clear rasterizer state, hr %#x.\n", hr); goto err; @@ -4082,7 +4090,7 @@ err: if (render_target->default_text_rendering_params) IDWriteRenderingParams_Release(render_target->default_text_rendering_params); if (render_target->rs) - ID3D10RasterizerState_Release(render_target->rs); + ID3D11RasterizerState_Release(render_target->rs); if (render_target->vb) ID3D11Buffer_Release(render_target->vb); if (render_target->ib)
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 | 39 ++++++++++++++++++++++++--------------- 2 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 0915bc55cfd..f823953dd2b 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -173,7 +173,7 @@ struct d2d_device_context unsigned int vb_stride; ID3D11Buffer *vb; ID3D11RasterizerState *rs; - ID3D10BlendState *bs; + ID3D11BlendState *bs; ID3D10SamplerState *sampler_states [D2D_SAMPLER_INTERPOLATION_MODE_COUNT] [D2D_SAMPLER_EXTEND_MODE_COUNT] diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 0a0e9f5bbe6..ba9e4e13481 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -129,6 +129,7 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en ID3D10VertexShader *d3d10_vs = NULL; ID3D10PixelShader *d3d10_ps = NULL; ID3D10InputLayout *d3d10_il = NULL; + ID3D10BlendState *d3d10_bs = NULL; D3D10_RECT scissor_rect; unsigned int offset; D3D10_VIEWPORT vp; @@ -189,6 +190,12 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en goto error; }
+ if (render_target->bs && FAILED(hr = ID3D11BlendState_QueryInterface(render_target->bs, &IID_ID3D10BlendState, (void **)&d3d10_bs))) + { + ERR("Failed to query D3D10 blend state, 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); @@ -229,7 +236,7 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en ID3D10Device_OMSetRenderTargets(device, 1, &render_target->target->rtv, NULL); if (brush) { - ID3D10Device_OMSetBlendState(device, render_target->bs, NULL, D3D10_DEFAULT_SAMPLE_MASK); + ID3D10Device_OMSetBlendState(device, d3d10_bs, NULL, D3D10_DEFAULT_SAMPLE_MASK); d2d_brush_bind_resources(brush, render_target, 0); } if (opacity_brush) @@ -244,6 +251,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_bs) ID3D10BlendState_Release(d3d10_bs); if (d3d10_rs) ID3D10RasterizerState_Release(d3d10_rs); if (d3d10_ps) ID3D10PixelShader_Release(d3d10_ps); if (d3d10_vs) ID3D10VertexShader_Release(d3d10_vs); @@ -325,7 +333,7 @@ static ULONG STDMETHODCALLTYPE d2d_device_context_inner_Release(IUnknown *iface) if (context->text_rendering_params) IDWriteRenderingParams_Release(context->text_rendering_params); if (context->bs) - ID3D10BlendState_Release(context->bs); + ID3D11BlendState_Release(context->bs); ID3D11RasterizerState_Release(context->rs); ID3D11Buffer_Release(context->vb); ID3D11Buffer_Release(context->ib); @@ -2076,7 +2084,7 @@ static void d2d_device_context_reset_target(struct d2d_device_context *context) memset(&context->desc.pixelFormat, 0, sizeof(context->desc.pixelFormat)); memset(&context->pixel_size, 0, sizeof(context->pixel_size));
- ID3D10BlendState_Release(context->bs); + ID3D11BlendState_Release(context->bs); context->bs = NULL; }
@@ -2084,7 +2092,7 @@ static void STDMETHODCALLTYPE d2d_device_context_SetTarget(ID2D1DeviceContext *i { struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface); struct d2d_bitmap *bitmap_impl; - D3D10_BLEND_DESC blend_desc; + D3D11_BLEND_DESC blend_desc; ID2D1Bitmap *bitmap; HRESULT hr;
@@ -2118,23 +2126,24 @@ static void STDMETHODCALLTYPE d2d_device_context_SetTarget(ID2D1DeviceContext *i context->target = bitmap_impl;
memset(&blend_desc, 0, sizeof(blend_desc)); - blend_desc.BlendEnable[0] = TRUE; - blend_desc.SrcBlend = D3D10_BLEND_ONE; - blend_desc.DestBlend = D3D10_BLEND_INV_SRC_ALPHA; - blend_desc.BlendOp = D3D10_BLEND_OP_ADD; + blend_desc.IndependentBlendEnable = FALSE; + blend_desc.RenderTarget[0].BlendEnable = TRUE; + blend_desc.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; + blend_desc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; + blend_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; if (context->desc.pixelFormat.alphaMode == D2D1_ALPHA_MODE_IGNORE) { - blend_desc.SrcBlendAlpha = D3D10_BLEND_ZERO; - blend_desc.DestBlendAlpha = D3D10_BLEND_ONE; + blend_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO; + blend_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE; } else { - blend_desc.SrcBlendAlpha = D3D10_BLEND_ONE; - blend_desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA; + blend_desc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; + blend_desc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; } - blend_desc.BlendOpAlpha = D3D10_BLEND_OP_ADD; - blend_desc.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL; - if (FAILED(hr = ID3D10Device_CreateBlendState(context->d3d_device, &blend_desc, &context->bs))) + blend_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; + blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + if (FAILED(hr = ID3D11Device1_CreateBlendState(context->d3d11_device, &blend_desc, &context->bs))) WARN("Failed to create blend state, hr %#x.\n", hr); }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d2d1/brush.c | 32 +++++++++++++++++++------------- dlls/d2d1/d2d1_private.h | 2 +- dlls/d2d1/device.c | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c index 5932a5fa113..6384cb0ae52 100644 --- a/dlls/d2d1/brush.c +++ b/dlls/d2d1/brush.c @@ -1121,19 +1121,19 @@ struct d2d_brush *unsafe_impl_from_ID2D1Brush(ID2D1Brush *iface) return CONTAINING_RECORD(iface, struct d2d_brush, ID2D1Brush_iface); }
-static D3D10_TEXTURE_ADDRESS_MODE texture_address_mode_from_extend_mode(D2D1_EXTEND_MODE mode) +static D3D11_TEXTURE_ADDRESS_MODE texture_address_mode_from_extend_mode(D2D1_EXTEND_MODE mode) { switch (mode) { case D2D1_EXTEND_MODE_CLAMP: - return D3D10_TEXTURE_ADDRESS_CLAMP; + return D3D11_TEXTURE_ADDRESS_CLAMP; case D2D1_EXTEND_MODE_WRAP: - return D3D10_TEXTURE_ADDRESS_WRAP; + return D3D11_TEXTURE_ADDRESS_WRAP; case D2D1_EXTEND_MODE_MIRROR: - return D3D10_TEXTURE_ADDRESS_MIRROR; + return D3D11_TEXTURE_ADDRESS_MIRROR; default: FIXME("Unhandled extend mode %#x.\n", mode); - return D3D10_TEXTURE_ADDRESS_CLAMP; + return D3D11_TEXTURE_ADDRESS_CLAMP; } }
@@ -1256,7 +1256,8 @@ BOOL d2d_brush_fill_cb(const struct d2d_brush *brush, struct d2d_brush_cb *cb) static void d2d_brush_bind_bitmap(struct d2d_brush *brush, struct d2d_device_context *context, unsigned int brush_idx) { - ID3D10SamplerState **sampler_state; + ID3D10SamplerState *d3d10_sampler_state; + ID3D11SamplerState **sampler_state; HRESULT hr;
ID3D10Device_PSSetShaderResources(context->d3d_device, brush_idx, 1, &brush->u.bitmap.bitmap->srv); @@ -1268,18 +1269,18 @@ static void d2d_brush_bind_bitmap(struct d2d_brush *brush, struct d2d_device_con
if (!*sampler_state) { - D3D10_SAMPLER_DESC sampler_desc; + D3D11_SAMPLER_DESC sampler_desc;
if (brush->u.bitmap.interpolation_mode == D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR) - sampler_desc.Filter = D3D10_FILTER_MIN_MAG_MIP_POINT; + sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; else - sampler_desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR; + sampler_desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; sampler_desc.AddressU = texture_address_mode_from_extend_mode(brush->u.bitmap.extend_mode_x); sampler_desc.AddressV = texture_address_mode_from_extend_mode(brush->u.bitmap.extend_mode_y); - sampler_desc.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP; + sampler_desc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; sampler_desc.MipLODBias = 0.0f; sampler_desc.MaxAnisotropy = 0; - sampler_desc.ComparisonFunc = D3D10_COMPARISON_NEVER; + sampler_desc.ComparisonFunc = D3D11_COMPARISON_NEVER; sampler_desc.BorderColor[0] = 0.0f; sampler_desc.BorderColor[1] = 0.0f; sampler_desc.BorderColor[2] = 0.0f; @@ -1287,10 +1288,15 @@ static void d2d_brush_bind_bitmap(struct d2d_brush *brush, struct d2d_device_con sampler_desc.MinLOD = 0.0f; sampler_desc.MaxLOD = 0.0f;
- if (FAILED(hr = ID3D10Device_CreateSamplerState(context->d3d_device, &sampler_desc, sampler_state))) + if (FAILED(hr = ID3D11Device1_CreateSamplerState(context->d3d11_device, &sampler_desc, sampler_state))) ERR("Failed to create sampler state, hr %#x.\n", hr); } - ID3D10Device_PSSetSamplers(context->d3d_device, brush_idx, 1, sampler_state); + + if (FAILED(hr = ID3D11SamplerState_QueryInterface(*sampler_state, &IID_ID3D10SamplerState, (void **)&d3d10_sampler_state))) + ERR("Failed to query D3D10 sampler state, hr %#x.\n", hr); + + ID3D10Device_PSSetSamplers(context->d3d_device, brush_idx, 1, &d3d10_sampler_state); + ID3D10SamplerState_Release(d3d10_sampler_state); }
void d2d_brush_bind_resources(struct d2d_brush *brush, struct d2d_device_context *context, unsigned int brush_idx) diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index f823953dd2b..b4a489e1966 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -174,7 +174,7 @@ struct d2d_device_context ID3D11Buffer *vb; ID3D11RasterizerState *rs; ID3D11BlendState *bs; - ID3D10SamplerState *sampler_states + ID3D11SamplerState *sampler_states [D2D_SAMPLER_INTERPOLATION_MODE_COUNT] [D2D_SAMPLER_EXTEND_MODE_COUNT] [D2D_SAMPLER_EXTEND_MODE_COUNT]; diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index ba9e4e13481..a862215c130 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -352,7 +352,7 @@ static ULONG STDMETHODCALLTYPE d2d_device_context_inner_Release(IUnknown *iface) for (k = 0; k < D2D_SAMPLER_EXTEND_MODE_COUNT; ++k) { if (context->sampler_states[i][j][k]) - ID3D10SamplerState_Release(context->sampler_states[i][j][k]); + ID3D11SamplerState_Release(context->sampler_states[i][j][k]); } } }
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 | 23 +++--- dlls/d2d1/d2d1_private.h | 2 +- dlls/d2d1/device.c | 146 ++++++++++----------------------------- 3 files changed, 48 insertions(+), 123 deletions(-)
diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c index 6384cb0ae52..398ba80dd8b 100644 --- a/dlls/d2d1/brush.c +++ b/dlls/d2d1/brush.c @@ -237,9 +237,12 @@ static struct d2d_gradient *unsafe_impl_from_ID2D1GradientStopCollection(ID2D1Gr return CONTAINING_RECORD(iface, struct d2d_gradient, ID2D1GradientStopCollection_iface); }
-static void d2d_gradient_bind(struct d2d_gradient *gradient, ID3D10Device *device, unsigned int brush_idx) +static void d2d_gradient_bind(struct d2d_gradient *gradient, ID3D11Device1 *device, unsigned int brush_idx) { - ID3D10Device_PSSetShaderResources(device, 2 + brush_idx, 1, &gradient->view); + ID3D11DeviceContext *context; + ID3D11Device1_GetImmediateContext(device, &context); + ID3D11DeviceContext_PSSetShaderResources(context, 2 + brush_idx, 1, &gradient->d3d11_view); + ID3D11DeviceContext_Release(context); }
static void d2d_brush_destroy(struct d2d_brush *brush) @@ -1256,11 +1259,12 @@ BOOL d2d_brush_fill_cb(const struct d2d_brush *brush, struct d2d_brush_cb *cb) static void d2d_brush_bind_bitmap(struct d2d_brush *brush, struct d2d_device_context *context, unsigned int brush_idx) { - ID3D10SamplerState *d3d10_sampler_state; ID3D11SamplerState **sampler_state; + ID3D11DeviceContext *d3d_context; HRESULT hr;
- ID3D10Device_PSSetShaderResources(context->d3d_device, brush_idx, 1, &brush->u.bitmap.bitmap->srv); + ID3D11Device1_GetImmediateContext(context->d3d11_device, &d3d_context); + ID3D11DeviceContext_PSSetShaderResources(d3d_context, brush_idx, 1, &brush->u.bitmap.bitmap->d3d11_srv);
sampler_state = &context->sampler_states [brush->u.bitmap.interpolation_mode % D2D_SAMPLER_INTERPOLATION_MODE_COUNT] @@ -1292,11 +1296,8 @@ static void d2d_brush_bind_bitmap(struct d2d_brush *brush, struct d2d_device_con ERR("Failed to create sampler state, hr %#x.\n", hr); }
- if (FAILED(hr = ID3D11SamplerState_QueryInterface(*sampler_state, &IID_ID3D10SamplerState, (void **)&d3d10_sampler_state))) - ERR("Failed to query D3D10 sampler state, hr %#x.\n", hr); - - ID3D10Device_PSSetSamplers(context->d3d_device, brush_idx, 1, &d3d10_sampler_state); - ID3D10SamplerState_Release(d3d10_sampler_state); + ID3D11DeviceContext_PSSetSamplers(d3d_context, brush_idx, 1, sampler_state); + ID3D11DeviceContext_Release(d3d_context); }
void d2d_brush_bind_resources(struct d2d_brush *brush, struct d2d_device_context *context, unsigned int brush_idx) @@ -1307,11 +1308,11 @@ void d2d_brush_bind_resources(struct d2d_brush *brush, struct d2d_device_context break;
case D2D_BRUSH_TYPE_LINEAR: - d2d_gradient_bind(brush->u.linear.gradient, context->d3d_device, brush_idx); + d2d_gradient_bind(brush->u.linear.gradient, context->d3d11_device, brush_idx); break;
case D2D_BRUSH_TYPE_RADIAL: - d2d_gradient_bind(brush->u.radial.gradient, context->d3d_device, brush_idx); + d2d_gradient_bind(brush->u.radial.gradient, context->d3d11_device, brush_idx); break;
case D2D_BRUSH_TYPE_BITMAP: diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index b4a489e1966..50710a7ebd9 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -163,8 +163,8 @@ struct d2d_device_context ID2D1Device *device; ID3D10Device *d3d_device; ID3D11Device1 *d3d11_device; + ID3DDeviceContextState *d3d_state; struct d2d_bitmap *target; - ID3D10StateBlock *stateblock; struct d2d_shape_resources shape_resources[D2D_SHAPE_TYPE_COUNT]; ID3D11Buffer *vs_cb; ID3D11PixelShader *ps; diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index a862215c130..e102290bd0a 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -122,18 +122,13 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en 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; + ID3DDeviceContextState *prev_state; + ID3D11Device1 *device = render_target->d3d11_device; + ID3D11DeviceContext1 *context; ID3D11Buffer *vs_cb = render_target->vs_cb, *ps_cb = render_target->ps_cb; - ID3D10RasterizerState *d3d10_rs = NULL; - ID3D10VertexShader *d3d10_vs = NULL; - ID3D10PixelShader *d3d10_ps = NULL; - ID3D10InputLayout *d3d10_il = NULL; - ID3D10BlendState *d3d10_bs = NULL; - D3D10_RECT scissor_rect; + D3D11_RECT scissor_rect; unsigned int offset; - D3D10_VIEWPORT vp; - HRESULT hr; + D3D11_VIEWPORT vp;
vp.TopLeftX = 0; vp.TopLeftY = 0; @@ -142,78 +137,20 @@ 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 (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 (shape_resources->vs && FAILED(hr = ID3D11VertexShader_QueryInterface(shape_resources->vs, &IID_ID3D10VertexShader, (void **)&d3d10_vs))) - { - ERR("Failed to query D3D10 vertex shader, hr %#x.\n", hr); - goto error; - } - - if (render_target->ps && FAILED(hr = ID3D11PixelShader_QueryInterface(render_target->ps, &IID_ID3D10PixelShader, (void **)&d3d10_ps))) - { - ERR("Failed to query D3D10 pixel shader, hr %#x.\n", hr); - goto error; - } - - if (render_target->rs && FAILED(hr = ID3D11RasterizerState_QueryInterface(render_target->rs, &IID_ID3D10RasterizerState, (void **)&d3d10_rs))) - { - ERR("Failed to query D3D10 rasterizer state, hr %#x.\n", hr); - goto error; - } - - if (render_target->bs && FAILED(hr = ID3D11BlendState_QueryInterface(render_target->bs, &IID_ID3D10BlendState, (void **)&d3d10_bs))) - { - ERR("Failed to query D3D10 blend state, 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); - goto error; - } + ID3D11Device1_GetImmediateContext1(device, &context); + ID3D11DeviceContext1_SwapDeviceContextState(context, render_target->d3d_state, &prev_state); + ID3D11DeviceContext1_ClearState(context);
- ID3D10Device_ClearState(device); - - ID3D10Device_IASetInputLayout(device, d3d10_il); - ID3D10Device_IASetPrimitiveTopology(device, D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - ID3D10Device_IASetIndexBuffer(device, d3d10_ib, DXGI_FORMAT_R16_UINT, 0); + ID3D11DeviceContext1_IASetInputLayout(context, shape_resources->il); + ID3D11DeviceContext1_IASetPrimitiveTopology(context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + ID3D11DeviceContext1_IASetIndexBuffer(context, ib, DXGI_FORMAT_R16_UINT, 0); offset = 0; - ID3D10Device_IASetVertexBuffers(device, 0, 1, &d3d10_vb, &vb_stride, &offset); - ID3D10Device_VSSetConstantBuffers(device, 0, 1, &d3d10_vs_cb); - ID3D10Device_VSSetShader(device, d3d10_vs); - ID3D10Device_PSSetConstantBuffers(device, 0, 1, &d3d10_ps_cb); - ID3D10Device_PSSetShader(device, d3d10_ps); - ID3D10Device_RSSetViewports(device, 1, &vp); + ID3D11DeviceContext1_IASetVertexBuffers(context, 0, 1, &vb, &vb_stride, &offset); + ID3D11DeviceContext1_VSSetConstantBuffers(context, 0, 1, &vs_cb); + ID3D11DeviceContext1_VSSetShader(context, shape_resources->vs, NULL, 0); + ID3D11DeviceContext1_PSSetConstantBuffers(context, 0, 1, &ps_cb); + ID3D11DeviceContext1_PSSetShader(context, render_target->ps, NULL, 0); + ID3D11DeviceContext1_RSSetViewports(context, 1, &vp); if (render_target->clip_stack.count) { const D2D1_RECT_F *clip_rect; @@ -231,35 +168,25 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en scissor_rect.right = render_target->pixel_size.width; scissor_rect.bottom = render_target->pixel_size.height; } - ID3D10Device_RSSetScissorRects(device, 1, &scissor_rect); - ID3D10Device_RSSetState(device, d3d10_rs); - ID3D10Device_OMSetRenderTargets(device, 1, &render_target->target->rtv, NULL); + ID3D11DeviceContext1_RSSetScissorRects(context, 1, &scissor_rect); + ID3D11DeviceContext1_RSSetState(context, render_target->rs); + ID3D11DeviceContext1_OMSetRenderTargets(context, 1, &render_target->target->d3d11_rtv, NULL); if (brush) { - ID3D10Device_OMSetBlendState(device, d3d10_bs, NULL, D3D10_DEFAULT_SAMPLE_MASK); + ID3D11DeviceContext1_OMSetBlendState(context, render_target->bs, NULL, D3D11_DEFAULT_SAMPLE_MASK); d2d_brush_bind_resources(brush, render_target, 0); } if (opacity_brush) d2d_brush_bind_resources(opacity_brush, render_target, 1);
if (ib) - ID3D10Device_DrawIndexed(device, index_count, 0, 0); + ID3D11DeviceContext1_DrawIndexed(context, index_count, 0, 0); else - ID3D10Device_Draw(device, index_count, 0); - - if (FAILED(hr = render_target->stateblock->lpVtbl->Apply(render_target->stateblock))) - WARN("Failed to apply stateblock, hr %#x.\n", hr); + ID3D11DeviceContext1_Draw(context, index_count, 0);
-error: - if (d3d10_bs) ID3D10BlendState_Release(d3d10_bs); - if (d3d10_rs) ID3D10RasterizerState_Release(d3d10_rs); - if (d3d10_ps) ID3D10PixelShader_Release(d3d10_ps); - if (d3d10_vs) ID3D10VertexShader_Release(d3d10_vs); - 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); - if (d3d10_ps_cb) ID3D10Buffer_Release(d3d10_ps_cb); + ID3D11DeviceContext1_SwapDeviceContextState(context, prev_state, NULL); + ID3D11DeviceContext1_Release(context); + ID3DDeviceContextState_Release(prev_state); }
static void d2d_device_context_set_error(struct d2d_device_context *context, HRESULT code) @@ -356,7 +283,8 @@ static ULONG STDMETHODCALLTYPE d2d_device_context_inner_Release(IUnknown *iface) } } } - context->stateblock->lpVtbl->Release(context->stateblock); + if (context->d3d_state) + ID3DDeviceContextState_Release(context->d3d_state); if (context->target) ID2D1Bitmap1_Release(&context->target->ID2D1Bitmap1_iface); ID3D11Device1_Release(context->d3d11_device); @@ -2873,7 +2801,6 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, IUnknown *outer_unknown, const struct d2d_device_context_ops *ops) { D3D11_SUBRESOURCE_DATA buffer_data; - D3D10_STATE_BLOCK_MASK state_mask; struct d2d_device *device_impl; IDWriteFactory *dwrite_factory; D3D11_RASTERIZER_DESC rs_desc; @@ -3927,6 +3854,7 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, { 1.0f, -1.0f}, }; static const UINT16 indices[] = {0, 1, 2, 2, 1, 3}; + static const D3D_FEATURE_LEVEL feature_levels = D3D_FEATURE_LEVEL_11_0;
render_target->ID2D1DeviceContext_iface.lpVtbl = &d2d_device_context_vtbl; render_target->ID2D1GdiInteropRenderTarget_iface.lpVtbl = &d2d_gdi_interop_render_target_vtbl; @@ -3956,15 +3884,11 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, goto err; }
- if (FAILED(hr = D3D10StateBlockMaskEnableAll(&state_mask))) - { - WARN("Failed to create stateblock mask, hr %#x.\n", hr); - goto err; - } - - if (FAILED(hr = D3D10CreateStateBlock(render_target->d3d_device, &state_mask, &render_target->stateblock))) + if (FAILED(hr = ID3D11Device1_CreateDeviceContextState(render_target->d3d11_device, + 0, &feature_levels, 1, D3D11_SDK_VERSION, &IID_ID3D11Device1, NULL, + &render_target->d3d_state))) { - WARN("Failed to create stateblock, hr %#x.\n", hr); + WARN("Failed to create device context state, hr %#x.\n", hr); goto err; }
@@ -4117,8 +4041,8 @@ err: if (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); + if (render_target->d3d_state) + ID3DDeviceContextState_Release(render_target->d3d_state); if (render_target->d3d11_device) ID3D11Device1_Release(render_target->d3d11_device); if (render_target->d3d_device)
On Mon, 28 Jun 2021 at 09:18, Rémi Bernon rbernon@codeweavers.com wrote:
- ID3D11Device1_GetImmediateContext1(device, &context);
- ID3D11DeviceContext1_SwapDeviceContextState(context, render_target->d3d_state, &prev_state);
- ID3D11DeviceContext1_ClearState(context);
- ID3D10Device_ClearState(device);
This is fine because it retains the existing behaviour, but note that now that we have our own D3DDeviceContextState, clearing the device context state should be superfluous, and we could get rid of it in a subsequent patch.
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/bitmap.c | 43 +++++++-------------- dlls/d2d1/brush.c | 34 ++++++----------- dlls/d2d1/d2d1_private.h | 15 +++----- dlls/d2d1/dc_render_target.c | 2 +- dlls/d2d1/device.c | 73 +++++++++++++++--------------------- dlls/d2d1/tests/d2d1.c | 5 +-- 6 files changed, 62 insertions(+), 110 deletions(-)
diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c index 43c1b6f8d44..470724e96a9 100644 --- a/dlls/d2d1/bitmap.c +++ b/dlls/d2d1/bitmap.c @@ -67,18 +67,12 @@ static ULONG STDMETHODCALLTYPE d2d_bitmap_Release(ID2D1Bitmap1 *iface) if (!refcount) { if (bitmap->srv) - ID3D10ShaderResourceView_Release(bitmap->srv); - if (bitmap->d3d11_srv) - ID3D11ShaderResourceView_Release(bitmap->d3d11_srv); + ID3D11ShaderResourceView_Release(bitmap->srv); if (bitmap->rtv) - ID3D10RenderTargetView_Release(bitmap->rtv); - if (bitmap->d3d11_rtv) - ID3D11RenderTargetView_Release(bitmap->d3d11_rtv); + ID3D11RenderTargetView_Release(bitmap->rtv); if (bitmap->surface) IDXGISurface_Release(bitmap->surface); - if (bitmap->d3d11_resource) - ID3D11Resource_Release(bitmap->d3d11_resource); - ID3D10Resource_Release(bitmap->resource); + ID3D11Resource_Release(bitmap->resource); ID2D1Factory_Release(bitmap->factory); heap_free(bitmap); } @@ -172,9 +166,9 @@ static HRESULT STDMETHODCALLTYPE d2d_bitmap_CopyFromMemory(ID2D1Bitmap1 *iface, box.back = 1; }
- ID3D11Resource_GetDevice(bitmap->d3d11_resource, &device); + ID3D11Resource_GetDevice(bitmap->resource, &device); ID3D11Device_GetImmediateContext(device, &context); - ID3D11DeviceContext_UpdateSubresource(context, bitmap->d3d11_resource, 0, dst_rect ? &box : NULL, src_data, pitch, 0); + ID3D11DeviceContext_UpdateSubresource(context, bitmap->resource, 0, dst_rect ? &box : NULL, src_data, pitch, 0); ID3D11DeviceContext_Release(context); ID3D11Device_Release(device);
@@ -281,18 +275,13 @@ static BOOL format_supported(const D2D1_PIXEL_FORMAT *format) static void d2d_bitmap_init(struct d2d_bitmap *bitmap, struct d2d_device_context *context, ID3D11Resource *resource, D2D1_SIZE_U size, const D2D1_BITMAP_PROPERTIES1 *desc) { - ID3D10Resource *d3d10_resource; ID3D11Device *d3d_device; HRESULT 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); - ID3D11Resource_AddRef(bitmap->d3d11_resource = resource); - bitmap->resource = d3d10_resource; + ID3D11Resource_AddRef(bitmap->resource = resource); bitmap->pixel_size = size; bitmap->format = desc->pixelFormat; bitmap->dpi_x = desc->dpiX; @@ -305,20 +294,14 @@ static void d2d_bitmap_init(struct d2d_bitmap *bitmap, struct d2d_device_context ID3D11Resource_GetDevice(resource, &d3d_device); if (bitmap->options & D2D1_BITMAP_OPTIONS_TARGET) { - if (FAILED(hr = ID3D11Device_CreateRenderTargetView(d3d_device, resource, NULL, &bitmap->d3d11_rtv))) + if (FAILED(hr = ID3D11Device_CreateRenderTargetView(d3d_device, resource, NULL, &bitmap->rtv))) WARN("Failed to create RTV, hr %#x.\n", hr); - if (FAILED(hr = ID3D11RenderTargetView_QueryInterface(bitmap->d3d11_rtv, &IID_ID3D10RenderTargetView, - (void **)&bitmap->rtv))) - WARN("Failed to query D3D10 RTV interface, hr %#x.\n", hr); }
if (!(bitmap->options & D2D1_BITMAP_OPTIONS_CANNOT_DRAW)) { - if (FAILED(hr = ID3D11Device_CreateShaderResourceView(d3d_device, resource, NULL, &bitmap->d3d11_srv))) + if (FAILED(hr = ID3D11Device_CreateShaderResourceView(d3d_device, resource, NULL, &bitmap->srv))) WARN("Failed to create SRV, hr %#x.\n", hr); - if (FAILED(hr = ID3D11ShaderResourceView_QueryInterface(bitmap->d3d11_srv, &IID_ID3D10ShaderResourceView, - (void **)&bitmap->srv))) - WARN("Failed to query D3D10 SRV interface, hr %#x.\n", hr); } ID3D11Device_Release(d3d_device);
@@ -380,7 +363,7 @@ HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size, resource_data.pSysMem = src_data; resource_data.SysMemPitch = pitch;
- if (FAILED(hr = ID3D11Device1_CreateTexture2D(context->d3d11_device, &texture_desc, + if (FAILED(hr = ID3D11Device1_CreateTexture2D(context->d3d_device, &texture_desc, src_data ? &resource_data : NULL, &texture))) { ERR("Failed to create texture, hr %#x.\n", hr); @@ -414,9 +397,9 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, goto failed; }
- ID3D11Resource_GetDevice(src_impl->d3d11_resource, &device); + ID3D11Resource_GetDevice(src_impl->resource, &device); ID3D11Device_Release(device); - if (device != (ID3D11Device *)context->d3d11_device) + if (device != (ID3D11Device *)context->d3d_device) { hr = D2DERR_UNSUPPORTED_OPERATION; goto failed; @@ -446,7 +429,7 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid, goto failed; }
- d2d_bitmap_init(*bitmap, context, src_impl->d3d11_resource, src_impl->pixel_size, desc); + d2d_bitmap_init(*bitmap, context, src_impl->resource, src_impl->pixel_size, desc); TRACE("Created bitmap %p.\n", *bitmap);
failed: @@ -470,7 +453,7 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid,
ID3D11Resource_GetDevice(resource, &device); ID3D11Device_Release(device); - if (device != (ID3D11Device *)context->d3d11_device) + if (device != (ID3D11Device *)context->d3d_device) { ID3D11Resource_Release(resource); return D2DERR_UNSUPPORTED_OPERATION; diff --git a/dlls/d2d1/brush.c b/dlls/d2d1/brush.c index 398ba80dd8b..38afbe83752 100644 --- a/dlls/d2d1/brush.c +++ b/dlls/d2d1/brush.c @@ -65,8 +65,7 @@ static ULONG STDMETHODCALLTYPE d2d_gradient_Release(ID2D1GradientStopCollection if (!refcount) { heap_free(gradient->stops); - ID3D11ShaderResourceView_Release(gradient->d3d11_view); - ID3D10ShaderResourceView_Release(gradient->view); + ID3D11ShaderResourceView_Release(gradient->view); ID2D1Factory_Release(gradient->factory); heap_free(gradient); } @@ -132,9 +131,8 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const UINT32 stop_count, D2D1_GAMMA gamma, D2D1_EXTEND_MODE extend_mode, struct d2d_gradient **out) { D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc; - ID3D11ShaderResourceView *d3d11_view; D3D11_SUBRESOURCE_DATA buffer_data; - ID3D10ShaderResourceView *view; + ID3D11ShaderResourceView *view; struct d2d_gradient *gradient; D3D11_BUFFER_DESC buffer_desc; struct d2d_vec4 *data; @@ -181,7 +179,7 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const srv_desc.Buffer.ElementOffset = 0; srv_desc.Buffer.ElementWidth = 2 * stop_count;
- hr = ID3D11Device1_CreateShaderResourceView(device, (ID3D11Resource *)buffer, &srv_desc, &d3d11_view); + hr = ID3D11Device1_CreateShaderResourceView(device, (ID3D11Resource *)buffer, &srv_desc, &view); ID3D11Buffer_Release(buffer); if (FAILED(hr)) { @@ -189,17 +187,9 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const 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); + ID3D11ShaderResourceView_Release(view); return E_OUTOFMEMORY; }
@@ -212,13 +202,11 @@ HRESULT d2d_gradient_create(ID2D1Factory *factory, ID3D11Device1 *device, const 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); + ID3D11ShaderResourceView_Release(view); heap_free(gradient); return E_OUTOFMEMORY; } @@ -241,7 +229,7 @@ static void d2d_gradient_bind(struct d2d_gradient *gradient, ID3D11Device1 *devi { ID3D11DeviceContext *context; ID3D11Device1_GetImmediateContext(device, &context); - ID3D11DeviceContext_PSSetShaderResources(context, 2 + brush_idx, 1, &gradient->d3d11_view); + ID3D11DeviceContext_PSSetShaderResources(context, 2 + brush_idx, 1, &gradient->view); ID3D11DeviceContext_Release(context); }
@@ -1263,8 +1251,8 @@ static void d2d_brush_bind_bitmap(struct d2d_brush *brush, struct d2d_device_con ID3D11DeviceContext *d3d_context; HRESULT hr;
- ID3D11Device1_GetImmediateContext(context->d3d11_device, &d3d_context); - ID3D11DeviceContext_PSSetShaderResources(d3d_context, brush_idx, 1, &brush->u.bitmap.bitmap->d3d11_srv); + ID3D11Device1_GetImmediateContext(context->d3d_device, &d3d_context); + ID3D11DeviceContext_PSSetShaderResources(d3d_context, brush_idx, 1, &brush->u.bitmap.bitmap->srv);
sampler_state = &context->sampler_states [brush->u.bitmap.interpolation_mode % D2D_SAMPLER_INTERPOLATION_MODE_COUNT] @@ -1292,7 +1280,7 @@ static void d2d_brush_bind_bitmap(struct d2d_brush *brush, struct d2d_device_con sampler_desc.MinLOD = 0.0f; sampler_desc.MaxLOD = 0.0f;
- if (FAILED(hr = ID3D11Device1_CreateSamplerState(context->d3d11_device, &sampler_desc, sampler_state))) + if (FAILED(hr = ID3D11Device1_CreateSamplerState(context->d3d_device, &sampler_desc, sampler_state))) ERR("Failed to create sampler state, hr %#x.\n", hr); }
@@ -1308,11 +1296,11 @@ void d2d_brush_bind_resources(struct d2d_brush *brush, struct d2d_device_context break;
case D2D_BRUSH_TYPE_LINEAR: - d2d_gradient_bind(brush->u.linear.gradient, context->d3d11_device, brush_idx); + d2d_gradient_bind(brush->u.linear.gradient, context->d3d_device, brush_idx); break;
case D2D_BRUSH_TYPE_RADIAL: - d2d_gradient_bind(brush->u.radial.gradient, context->d3d11_device, brush_idx); + d2d_gradient_bind(brush->u.radial.gradient, context->d3d_device, brush_idx); break;
case D2D_BRUSH_TYPE_BITMAP: diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 50710a7ebd9..f25a7809b17 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -161,8 +161,7 @@ struct d2d_device_context
ID2D1Factory *factory; ID2D1Device *device; - ID3D10Device *d3d_device; - ID3D11Device1 *d3d11_device; + ID3D11Device1 *d3d_device; ID3DDeviceContextState *d3d_state; struct d2d_bitmap *target; struct d2d_shape_resources shape_resources[D2D_SHAPE_TYPE_COUNT]; @@ -272,8 +271,7 @@ struct d2d_gradient LONG refcount;
ID2D1Factory *factory; - ID3D10ShaderResourceView *view; - ID3D11ShaderResourceView *d3d11_view; + ID3D11ShaderResourceView *view; D2D1_GRADIENT_STOP *stops; UINT32 stop_count; }; @@ -378,13 +376,10 @@ struct d2d_bitmap LONG refcount;
ID2D1Factory *factory; - ID3D10ShaderResourceView *srv; - ID3D11ShaderResourceView *d3d11_srv; - ID3D10RenderTargetView *rtv; - ID3D11RenderTargetView *d3d11_rtv; + ID3D11ShaderResourceView *srv; + ID3D11RenderTargetView *rtv; IDXGISurface *surface; - ID3D10Resource *resource; - ID3D11Resource *d3d11_resource; + ID3D11Resource *resource; D2D1_SIZE_U pixel_size; D2D1_PIXEL_FORMAT format; float dpi_x; diff --git a/dlls/d2d1/dc_render_target.c b/dlls/d2d1/dc_render_target.c index 47aa99697d7..099e3b0a3a2 100644 --- a/dlls/d2d1/dc_render_target.c +++ b/dlls/d2d1/dc_render_target.c @@ -715,7 +715,7 @@ static HRESULT STDMETHODCALLTYPE d2d_dc_render_target_BindDC(ID2D1DCRenderTarget }
bitmap_impl = unsafe_impl_from_ID2D1Bitmap(bitmap); - ID3D10Resource_QueryInterface(bitmap_impl->resource, &IID_IDXGISurface1, (void **)&dxgi_surface); + ID3D11Resource_QueryInterface(bitmap_impl->resource, &IID_IDXGISurface1, (void **)&dxgi_surface);
ID2D1DeviceContext_SetTarget(context, (ID2D1Image *)bitmap); ID2D1Bitmap_Release(bitmap); diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index e102290bd0a..3b444321c87 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -123,7 +123,7 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en { struct d2d_shape_resources *shape_resources = &render_target->shape_resources[shape_type]; ID3DDeviceContextState *prev_state; - ID3D11Device1 *device = render_target->d3d11_device; + ID3D11Device1 *device = render_target->d3d_device; ID3D11DeviceContext1 *context; ID3D11Buffer *vs_cb = render_target->vs_cb, *ps_cb = render_target->ps_cb; D3D11_RECT scissor_rect; @@ -170,7 +170,7 @@ static void d2d_device_context_draw(struct d2d_device_context *render_target, en } ID3D11DeviceContext1_RSSetScissorRects(context, 1, &scissor_rect); ID3D11DeviceContext1_RSSetState(context, render_target->rs); - ID3D11DeviceContext1_OMSetRenderTargets(context, 1, &render_target->target->d3d11_rtv, NULL); + ID3D11DeviceContext1_OMSetRenderTargets(context, 1, &render_target->target->rtv, NULL); if (brush) { ID3D11DeviceContext1_OMSetBlendState(context, render_target->bs, NULL, D3D11_DEFAULT_SAMPLE_MASK); @@ -287,8 +287,7 @@ static ULONG STDMETHODCALLTYPE d2d_device_context_inner_Release(IUnknown *iface) ID3DDeviceContextState_Release(context->d3d_state); if (context->target) ID2D1Bitmap1_Release(&context->target->ID2D1Bitmap1_iface); - ID3D11Device1_Release(context->d3d11_device); - ID3D10Device_Release(context->d3d_device); + ID3D11Device1_Release(context->d3d_device); ID2D1Factory_Release(context->factory); ID2D1Device_Release(context->device); heap_free(context); @@ -457,7 +456,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->d3d11_device, + if (SUCCEEDED(hr = d2d_gradient_create(render_target->factory, render_target->d3d_device, stops, stop_count, gamma, extend_mode, &object))) *gradient = &object->ID2D1GradientStopCollection_iface;
@@ -717,7 +716,7 @@ static HRESULT d2d_device_context_update_ps_cb(struct d2d_device_context *contex struct d2d_ps_cb *cb_data; HRESULT hr;
- ID3D11Device1_GetImmediateContext(context->d3d11_device, &d3d_context); + ID3D11Device1_GetImmediateContext(context->d3d_device, &d3d_context);
if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)context->ps_cb, 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc))) @@ -753,7 +752,7 @@ static HRESULT d2d_device_context_update_vs_cb(struct d2d_device_context *contex float tmp_x, tmp_y; HRESULT hr;
- ID3D11Device1_GetImmediateContext(context->d3d11_device, &d3d_context); + ID3D11Device1_GetImmediateContext(context->d3d_device, &d3d_context);
if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)context->vs_cb, 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc))) @@ -826,7 +825,7 @@ static void d2d_device_context_draw_geometry(struct d2d_device_context *render_t buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER; buffer_data.pSysMem = geometry->outline.faces;
- if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &ib))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib))) { WARN("Failed to create index buffer, hr %#x.\n", hr); return; @@ -836,7 +835,7 @@ static void d2d_device_context_draw_geometry(struct d2d_device_context *render_t buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; buffer_data.pSysMem = geometry->outline.vertices;
- if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &vb))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb))) { ERR("Failed to create vertex buffer, hr %#x.\n", hr); ID3D11Buffer_Release(ib); @@ -856,7 +855,7 @@ static void d2d_device_context_draw_geometry(struct d2d_device_context *render_t buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER; buffer_data.pSysMem = geometry->outline.bezier_faces;
- if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &ib))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib))) { WARN("Failed to create beziers index buffer, hr %#x.\n", hr); return; @@ -866,7 +865,7 @@ static void d2d_device_context_draw_geometry(struct d2d_device_context *render_t buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; buffer_data.pSysMem = geometry->outline.beziers;
- if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &vb))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb))) { ERR("Failed to create beziers vertex buffer, hr %#x.\n", hr); ID3D11Buffer_Release(ib); @@ -887,7 +886,7 @@ static void d2d_device_context_draw_geometry(struct d2d_device_context *render_t buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER; buffer_data.pSysMem = geometry->outline.arc_faces;
- if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &ib))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib))) { WARN("Failed to create arcs index buffer, hr %#x.\n", hr); return; @@ -897,7 +896,7 @@ static void d2d_device_context_draw_geometry(struct d2d_device_context *render_t buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; buffer_data.pSysMem = geometry->outline.arcs;
- if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &vb))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb))) { ERR("Failed to create arcs vertex buffer, hr %#x.\n", hr); ID3D11Buffer_Release(ib); @@ -963,7 +962,7 @@ static void d2d_device_context_fill_geometry(struct d2d_device_context *render_t buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER; buffer_data.pSysMem = geometry->fill.faces;
- if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &ib))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &ib))) { WARN("Failed to create index buffer, hr %#x.\n", hr); return; @@ -973,7 +972,7 @@ static void d2d_device_context_fill_geometry(struct d2d_device_context *render_t buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; buffer_data.pSysMem = geometry->fill.vertices;
- if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &vb))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb))) { ERR("Failed to create vertex buffer, hr %#x.\n", hr); ID3D11Buffer_Release(ib); @@ -993,7 +992,7 @@ static void d2d_device_context_fill_geometry(struct d2d_device_context *render_t buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; buffer_data.pSysMem = geometry->fill.bezier_vertices;
- if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &vb))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb))) { ERR("Failed to create beziers vertex buffer, hr %#x.\n", hr); return; @@ -1011,7 +1010,7 @@ static void d2d_device_context_fill_geometry(struct d2d_device_context *render_t buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; buffer_data.pSysMem = geometry->fill.arc_vertices;
- if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, &buffer_data, &vb))) + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &vb))) { ERR("Failed to create arc vertex buffer, hr %#x.\n", hr); return; @@ -1627,7 +1626,7 @@ static void STDMETHODCALLTYPE d2d_device_context_Clear(ID2D1DeviceContext *iface
TRACE("iface %p, colour %p.\n", iface, colour);
- ID3D11Device1_GetImmediateContext(render_target->d3d11_device, &d3d_context); + ID3D11Device1_GetImmediateContext(render_target->d3d_device, &d3d_context);
if (FAILED(hr = ID3D11DeviceContext_Map(d3d_context, (ID3D11Resource *)render_target->vs_cb, 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc))) @@ -1782,7 +1781,7 @@ static UINT32 STDMETHODCALLTYPE d2d_device_context_GetMaximumBitmapSize(ID2D1Dev { TRACE("iface %p.\n", iface);
- return D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION; + return D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION; }
static BOOL STDMETHODCALLTYPE d2d_device_context_IsSupported(ID2D1DeviceContext *iface, @@ -2071,7 +2070,7 @@ static void STDMETHODCALLTYPE d2d_device_context_SetTarget(ID2D1DeviceContext *i } blend_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; blend_desc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; - if (FAILED(hr = ID3D11Device1_CreateBlendState(context->d3d11_device, &blend_desc, &context->bs))) + if (FAILED(hr = ID3D11Device1_CreateBlendState(context->d3d_device, &blend_desc, &context->bs))) WARN("Failed to create blend state, hr %#x.\n", hr); }
@@ -2736,7 +2735,7 @@ static HRESULT d2d_device_context_get_surface(struct d2d_device_context *render_ ID3D11Resource *resource; HRESULT hr;
- ID3D11RenderTargetView_GetResource(render_target->target->d3d11_rtv, &resource); + ID3D11RenderTargetView_GetResource(render_target->target->rtv, &resource); hr = ID3D11Resource_QueryInterface(resource, &IID_IDXGISurface1, (void **)surface); ID3D11Resource_Release(resource); if (FAILED(hr)) @@ -3870,21 +3869,13 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target,
device_impl = unsafe_impl_from_ID2D1Device(device); if (FAILED(hr = IDXGIDevice_QueryInterface(device_impl->dxgi_device, - &IID_ID3D10Device, (void **)&render_target->d3d_device))) - { - WARN("Failed to get device interface, hr %#x.\n", hr); - ID2D1Factory_Release(render_target->factory); - return hr; - } - - if (FAILED(hr = IDXGIDevice_QueryInterface(device_impl->dxgi_device, - &IID_ID3D11Device1, (void **)&render_target->d3d11_device))) + &IID_ID3D11Device1, (void **)&render_target->d3d_device))) { WARN("Failed to query ID3D11Device1 interface, hr %#x.\n", hr); goto err; }
- if (FAILED(hr = ID3D11Device1_CreateDeviceContextState(render_target->d3d11_device, + if (FAILED(hr = ID3D11Device1_CreateDeviceContextState(render_target->d3d_device, 0, &feature_levels, 1, D3D11_SDK_VERSION, &IID_ID3D11Device1, NULL, &render_target->d3d_state))) { @@ -3896,14 +3887,14 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, { const struct shape_info *si = &shape_info[i];
- if (FAILED(hr = ID3D11Device1_CreateInputLayout(render_target->d3d11_device, si->il_desc, si->il_element_count, + if (FAILED(hr = ID3D11Device1_CreateInputLayout(render_target->d3d_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); goto err; }
- if (FAILED(hr = ID3D11Device1_CreateVertexShader(render_target->d3d11_device, si->vs_code, + if (FAILED(hr = ID3D11Device1_CreateVertexShader(render_target->d3d_device, si->vs_code, si->vs_code_size, NULL, &render_target->shape_resources[si->shape_type].vs))) { WARN("Failed to create vertex shader for shape type %#x, hr %#x.\n", si->shape_type, hr); @@ -3918,14 +3909,14 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, buffer_desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; buffer_desc.MiscFlags = 0;
- if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, NULL, + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, NULL, &render_target->vs_cb))) { WARN("Failed to create constant buffer, hr %#x.\n", hr); goto err; }
- if (FAILED(hr = ID3D11Device1_CreatePixelShader(render_target->d3d11_device, + if (FAILED(hr = ID3D11Device1_CreatePixelShader(render_target->d3d_device, ps_code, sizeof(ps_code), NULL, &render_target->ps))) { WARN("Failed to create pixel shader, hr %#x.\n", hr); @@ -3938,7 +3929,7 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, buffer_desc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; buffer_desc.MiscFlags = 0;
- if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, &buffer_desc, NULL, + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, NULL, &render_target->ps_cb))) { WARN("Failed to create constant buffer, hr %#x.\n", hr); @@ -3955,7 +3946,7 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, buffer_data.SysMemPitch = 0; buffer_data.SysMemSlicePitch = 0;
- if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &render_target->ib))) { WARN("Failed to create clear index buffer, hr %#x.\n", hr); @@ -3967,7 +3958,7 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, buffer_data.pSysMem = quad;
render_target->vb_stride = sizeof(*quad); - if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d11_device, + if (FAILED(hr = ID3D11Device1_CreateBuffer(render_target->d3d_device, &buffer_desc, &buffer_data, &render_target->vb))) { WARN("Failed to create clear vertex buffer, hr %#x.\n", hr); @@ -3984,7 +3975,7 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, rs_desc.ScissorEnable = TRUE; rs_desc.MultisampleEnable = FALSE; rs_desc.AntialiasedLineEnable = FALSE; - if (FAILED(hr = ID3D11Device1_CreateRasterizerState(render_target->d3d11_device, &rs_desc, &render_target->rs))) + if (FAILED(hr = ID3D11Device1_CreateRasterizerState(render_target->d3d_device, &rs_desc, &render_target->rs))) { WARN("Failed to create clear rasterizer state, hr %#x.\n", hr); goto err; @@ -4043,10 +4034,8 @@ err: } if (render_target->d3d_state) ID3DDeviceContextState_Release(render_target->d3d_state); - if (render_target->d3d11_device) - ID3D11Device1_Release(render_target->d3d11_device); if (render_target->d3d_device) - ID3D10Device_Release(render_target->d3d_device); + ID3D11Device1_Release(render_target->d3d_device); ID2D1Device_Release(render_target->device); ID2D1Factory_Release(render_target->factory); return hr; diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 8dbad9c5ecc..e60128b38f2 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -936,12 +936,9 @@ static ID2D1RenderTarget *create_render_target_desc(IDXGISurface *surface, hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &IID_ID2D1Factory, NULL, (void **)&factory); ok(SUCCEEDED(hr), "Failed to create factory, hr %#x.\n", hr); hr = ID2D1Factory_CreateDxgiSurfaceRenderTarget(factory, surface, desc, &render_target); - todo_wine_if(d3d11) ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr); + ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr); ID2D1Factory_Release(factory);
- if (FAILED(hr)) - return NULL; - return render_target; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=93190
Your paranoid android.
=== debiant2 (32 bit Chinese:China report) ===
Report validation errors: d2d1:d2d1 is missing some skip messages
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com