Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49395 Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
Resending this series as there's been conflicting d2d1 changes. This is only the first part of it.
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 81a46c8a7ce..b236bf57b6f 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 @@ -162,6 +162,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 2a0c094fb74..a03b1f56836 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -287,6 +287,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); @@ -3850,6 +3851,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); @@ -4013,6 +4021,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 b236bf57b6f..c8b9db67f27 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -381,6 +381,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;
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 | 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; }
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 | 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 c8b9db67f27..573899ba91a 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -378,7 +378,9 @@ struct d2d_bitmap
ID2D1Factory *factory; ID3D10ShaderResourceView *srv; + ID3D11ShaderResourceView *d3d11_srv; ID3D10RenderTargetView *rtv; + ID3D11RenderTargetView *d3d11_rtv; IDXGISurface *surface; ID3D10Resource *resource; ID3D11Resource *d3d11_resource;
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/device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index a03b1f56836..5767a83f39b 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -2707,12 +2707,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;
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 | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c index 495db8ddb68..0b5f3e6dc5a 100644 --- a/dlls/d2d1/bitmap.c +++ b/dlls/d2d1/bitmap.c @@ -332,10 +332,11 @@ static void d2d_bitmap_init(struct d2d_bitmap *bitmap, struct d2d_device_context HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size, const void *src_data, UINT32 pitch, const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap) { - D3D10_SUBRESOURCE_DATA resource_data; + D3D11_SUBRESOURCE_DATA resource_data; D2D1_BITMAP_PROPERTIES1 bitmap_desc; - D3D10_TEXTURE2D_DESC texture_desc; - ID3D10Texture2D *texture; + D3D11_TEXTURE2D_DESC texture_desc; + ID3D11Texture2D *texture; + ID3D10Resource *resource; HRESULT hr;
if (!format_supported(&desc->pixelFormat)) @@ -366,33 +367,41 @@ HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size, texture_desc.Format = desc->pixelFormat.format; texture_desc.SampleDesc.Count = 1; texture_desc.SampleDesc.Quality = 0; - texture_desc.Usage = D3D10_USAGE_DEFAULT; + texture_desc.Usage = D3D11_USAGE_DEFAULT; texture_desc.BindFlags = 0; if (desc->bitmapOptions & D2D1_BITMAP_OPTIONS_TARGET) - texture_desc.BindFlags |= D3D10_BIND_RENDER_TARGET; + texture_desc.BindFlags |= D3D11_BIND_RENDER_TARGET; if (!(desc->bitmapOptions & D2D1_BITMAP_OPTIONS_CANNOT_DRAW)) - texture_desc.BindFlags |= D3D10_BIND_SHADER_RESOURCE; + texture_desc.BindFlags |= D3D11_BIND_SHADER_RESOURCE; texture_desc.CPUAccessFlags = 0; texture_desc.MiscFlags = 0; if (desc->bitmapOptions & D2D1_BITMAP_OPTIONS_GDI_COMPATIBLE) - texture_desc.MiscFlags |= D3D10_RESOURCE_MISC_GDI_COMPATIBLE; + texture_desc.MiscFlags |= D3D11_RESOURCE_MISC_GDI_COMPATIBLE;
resource_data.pSysMem = src_data; resource_data.SysMemPitch = pitch;
- if (FAILED(hr = ID3D10Device_CreateTexture2D(context->d3d_device, &texture_desc, + if (FAILED(hr = ID3D11Device1_CreateTexture2D(context->d3d11_device, &texture_desc, src_data ? &resource_data : NULL, &texture))) { ERR("Failed to create texture, hr %#x.\n", hr); 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, (ID3D10Resource *)texture, size, desc); + d2d_bitmap_init(*bitmap, context, resource, size, desc); TRACE("Created bitmap %p.\n", *bitmap); } - ID3D10Texture2D_Release(texture); + ID3D11Texture2D_Release(texture); + ID3D10Resource_Release(resource);
return *bitmap ? S_OK : E_OUTOFMEMORY; }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com