Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49395 Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
This is the first part of the D2D1 on D3D11 series, split into smaller patches.
dlls/d2d1/d2d1_private.h | 3 ++- dlls/d2d1/device.c | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 199439b4616..3f3d5af6b0b 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -27,7 +27,7 @@ #include <math.h> #define COBJMACROS #include "d2d1_2.h" -#include "d3d11.h" +#include "d3d11_1.h" #ifdef D2D1_INIT_GUID #include "initguid.h" #endif @@ -140,6 +140,7 @@ struct d2d_device_context ID2D1Factory *factory; ID2D1Device *device; ID3D10Device *d3d_device; + ID3D11Device1 *d3d11_device; struct d2d_bitmap *target; ID3D10StateBlock *stateblock; struct d2d_shape_resources shape_resources[D2D_SHAPE_TYPE_COUNT]; diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 23ce03dce5e..4f939607be4 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -274,6 +274,7 @@ static ULONG STDMETHODCALLTYPE d2d_device_context_inner_Release(IUnknown *iface) context->stateblock->lpVtbl->Release(context->stateblock); if (context->target) ID2D1Bitmap1_Release(&context->target->ID2D1Bitmap1_iface); + ID3D11Device1_Release(context->d3d11_device); ID3D10Device_Release(context->d3d_device); ID2D1Factory_Release(context->factory); ID2D1Device_Release(context->device); @@ -3886,6 +3887,13 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, return hr; }
+ if (FAILED(hr = IDXGIDevice_QueryInterface(device_impl->dxgi_device, + &IID_ID3D11Device1, (void **)&render_target->d3d11_device))) + { + WARN("Failed to query ID3D11Device1 interface, hr %#x.\n", hr); + goto err; + } + if (FAILED(hr = D3D10StateBlockMaskEnableAll(&state_mask))) { WARN("Failed to create stateblock mask, hr %#x.\n", hr); @@ -4019,6 +4027,8 @@ err: } if (render_target->stateblock) render_target->stateblock->lpVtbl->Release(render_target->stateblock); + if (render_target->d3d11_device) + ID3D11Device1_Release(render_target->d3d11_device); if (render_target->d3d_device) ID3D10Device_Release(render_target->d3d_device); ID2D1Device_Release(render_target->device);
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49395 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d2d1/bitmap.c | 7 +++++++ dlls/d2d1/d2d1_private.h | 1 + 2 files changed, 8 insertions(+)
diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c index 7ed57052b98..d91b9740f2c 100644 --- a/dlls/d2d1/bitmap.c +++ b/dlls/d2d1/bitmap.c @@ -72,6 +72,8 @@ static ULONG STDMETHODCALLTYPE d2d_bitmap_Release(ID2D1Bitmap1 *iface) ID3D10RenderTargetView_Release(bitmap->rtv); if (bitmap->surface) IDXGISurface_Release(bitmap->surface); + if (bitmap->d3d11_resource) + ID3D11Resource_Release(bitmap->d3d11_resource); ID3D10Resource_Release(bitmap->resource); ID2D1Factory_Release(bitmap->factory); heap_free(bitmap); @@ -272,13 +274,18 @@ static BOOL format_supported(const D2D1_PIXEL_FORMAT *format) static void d2d_bitmap_init(struct d2d_bitmap *bitmap, struct d2d_device_context *context, ID3D10Resource *resource, D2D1_SIZE_U size, const D2D1_BITMAP_PROPERTIES1 *desc) { + ID3D11Resource *d3d11_resource; ID3D10Device *d3d_device; HRESULT hr;
+ if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource))) + WARN("Failed to query ID3D11Resource 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 = resource); + bitmap->d3d11_resource = d3d11_resource; bitmap->pixel_size = size; bitmap->format = desc->pixelFormat; bitmap->dpi_x = desc->dpiX; diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 3f3d5af6b0b..5dc62b5205d 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -354,6 +354,7 @@ struct d2d_bitmap ID3D10RenderTargetView *rtv; IDXGISurface *surface; ID3D10Resource *resource; + ID3D11Resource *d3d11_resource; D2D1_SIZE_U pixel_size; D2D1_PIXEL_FORMAT format; float dpi_x;
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49395 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d2d1/bitmap.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c index d91b9740f2c..4ace617ece1 100644 --- a/dlls/d2d1/bitmap.c +++ b/dlls/d2d1/bitmap.c @@ -152,8 +152,9 @@ static HRESULT STDMETHODCALLTYPE d2d_bitmap_CopyFromMemory(ID2D1Bitmap1 *iface, const D2D1_RECT_U *dst_rect, const void *src_data, UINT32 pitch) { struct d2d_bitmap *bitmap = impl_from_ID2D1Bitmap1(iface); - ID3D10Device *device; - D3D10_BOX box; + ID3D11DeviceContext *context; + ID3D11Device *device; + D3D11_BOX box;
TRACE("iface %p, dst_rect %p, src_data %p, pitch %u.\n", iface, dst_rect, src_data, pitch);
@@ -167,9 +168,11 @@ static HRESULT STDMETHODCALLTYPE d2d_bitmap_CopyFromMemory(ID2D1Bitmap1 *iface, box.back = 1; }
- ID3D10Resource_GetDevice(bitmap->resource, &device); - ID3D10Device_UpdateSubresource(device, bitmap->resource, 0, dst_rect ? &box : NULL, src_data, pitch, 0); - ID3D10Device_Release(device); + ID3D11Resource_GetDevice(bitmap->d3d11_resource, &device); + ID3D11Device_GetImmediateContext(device, &context); + ID3D11DeviceContext_UpdateSubresource(context, bitmap->d3d11_resource, 0, dst_rect ? &box : NULL, src_data, pitch, 0); + ID3D11DeviceContext_Release(context); + ID3D11Device_Release(device);
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 | 32 +++++++++++++++++++++----------- dlls/d2d1/d2d1_private.h | 2 ++ 2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c index 4ace617ece1..495db8ddb68 100644 --- a/dlls/d2d1/bitmap.c +++ b/dlls/d2d1/bitmap.c @@ -68,8 +68,12 @@ static ULONG STDMETHODCALLTYPE d2d_bitmap_Release(ID2D1Bitmap1 *iface) { if (bitmap->srv) ID3D10ShaderResourceView_Release(bitmap->srv); + if (bitmap->d3d11_srv) + ID3D11ShaderResourceView_Release(bitmap->d3d11_srv); if (bitmap->rtv) ID3D10RenderTargetView_Release(bitmap->rtv); + if (bitmap->d3d11_rtv) + ID3D11RenderTargetView_Release(bitmap->d3d11_rtv); if (bitmap->surface) IDXGISurface_Release(bitmap->surface); if (bitmap->d3d11_resource) @@ -275,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 *resource, D2D1_SIZE_U size, const D2D1_BITMAP_PROPERTIES1 *desc) + ID3D10Resource *d3d10_resource, D2D1_SIZE_U size, const D2D1_BITMAP_PROPERTIES1 *desc) { - ID3D11Resource *d3d11_resource; - ID3D10Device *d3d_device; + ID3D11Resource *resource; + ID3D11Device *d3d_device; HRESULT hr;
- if (FAILED(hr = ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource))) + if (FAILED(hr = ID3D10Resource_QueryInterface(d3d10_resource, &IID_ID3D11Resource, (void **)&resource))) WARN("Failed to query ID3D11Resource 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 = resource); - bitmap->d3d11_resource = d3d11_resource; + ID3D10Resource_AddRef(bitmap->resource = d3d10_resource); + bitmap->d3d11_resource = resource; bitmap->pixel_size = size; bitmap->format = desc->pixelFormat; bitmap->dpi_x = desc->dpiX; @@ -296,21 +300,27 @@ static void d2d_bitmap_init(struct d2d_bitmap *bitmap, struct d2d_device_context bitmap->options = desc->bitmapOptions;
if (d2d_device_context_is_dxgi_target(context)) - ID3D10Resource_QueryInterface(resource, &IID_IDXGISurface, (void **)&bitmap->surface); + ID3D11Resource_QueryInterface(resource, &IID_IDXGISurface, (void **)&bitmap->surface);
- ID3D10Resource_GetDevice(resource, &d3d_device); + ID3D11Resource_GetDevice(resource, &d3d_device); if (bitmap->options & D2D1_BITMAP_OPTIONS_TARGET) { - if (FAILED(hr = ID3D10Device_CreateRenderTargetView(d3d_device, resource, NULL, &bitmap->rtv))) + if (FAILED(hr = ID3D11Device_CreateRenderTargetView(d3d_device, resource, NULL, &bitmap->d3d11_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 = ID3D10Device_CreateShaderResourceView(d3d_device, resource, NULL, &bitmap->srv))) + if (FAILED(hr = ID3D11Device_CreateShaderResourceView(d3d_device, resource, NULL, &bitmap->d3d11_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); } - ID3D10Device_Release(d3d_device); + ID3D11Device_Release(d3d_device);
if (bitmap->dpi_x == 0.0f && bitmap->dpi_y == 0.0f) { diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 5dc62b5205d..9ae637037ae 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -351,7 +351,9 @@ struct d2d_bitmap
ID2D1Factory *factory; ID3D10ShaderResourceView *srv; + ID3D11ShaderResourceView *d3d11_srv; ID3D10RenderTargetView *rtv; + ID3D11RenderTargetView *d3d11_rtv; IDXGISurface *surface; ID3D10Resource *resource; ID3D11Resource *d3d11_resource;
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49395 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/d2d1/device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 4f939607be4..42ccecc259a 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -2743,12 +2743,12 @@ static ULONG STDMETHODCALLTYPE d2d_gdi_interop_render_target_Release(ID2D1GdiInt
static HRESULT d2d_device_context_get_surface(struct d2d_device_context *render_target, IDXGISurface1 **surface) { - ID3D10Resource *resource; + ID3D11Resource *resource; HRESULT hr;
- ID3D10RenderTargetView_GetResource(render_target->target->rtv, &resource); - hr = ID3D10Resource_QueryInterface(resource, &IID_IDXGISurface1, (void **)surface); - ID3D10Resource_Release(resource); + ID3D11RenderTargetView_GetResource(render_target->target->d3d11_rtv, &resource); + hr = ID3D11Resource_QueryInterface(resource, &IID_IDXGISurface1, (void **)surface); + ID3D11Resource_Release(resource); if (FAILED(hr)) { *surface = NULL;