Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
-- v2: d2d1: Keep effect shader objects at device level. d2d1: Use device instance pointer in device context structure.
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 70 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 6 deletions(-)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 6e2b3bb622a..2f4ded1d0cc 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -11405,11 +11405,14 @@ static void test_effect_register(BOOL d3d11)
static void test_effect_context(BOOL d3d11) { - ID2D1EffectContext *effect_context; + ID2D1EffectContext *effect_context, *effect_context2; + ID2D1Effect *effect = NULL, *effect2 = NULL; + ID2D1DeviceContext *device_context; D2D1_PROPERTY_BINDING binding; struct d2d1_test_context ctx; - ID2D1Effect *effect = NULL; ID2D1Factory1 *factory; + ID2D1Device *device; + ULONG refcount; BOOL loaded; HRESULT hr;
@@ -11441,9 +11444,9 @@ static void test_effect_context(BOOL d3d11)
/* Test shader loading */ loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestVertexShader); - ok(!loaded, "Shader is loaded.\n"); + ok(!loaded, "Unexpected shader loaded state.\n"); loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestPixelShader); - ok(!loaded, "Shader is loaded.\n"); + ok(!loaded, "Unexpected shader loaded state.\n");
hr = ID2D1EffectContext_LoadVertexShader(effect_context, &GUID_TestVertexShader, (const BYTE *)test_ps, sizeof(test_ps)); @@ -11452,7 +11455,7 @@ static void test_effect_context(BOOL d3d11) &GUID_TestVertexShader, (const BYTE *)test_vs, sizeof(test_vs)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestVertexShader); - ok(loaded, "Shader is not loaded.\n"); + ok(loaded, "Unexpected shader loaded state.\n");
hr = ID2D1EffectContext_LoadVertexShader(effect_context, &GUID_TestVertexShader, (const BYTE *)test_ps, sizeof(test_ps)); @@ -11468,9 +11471,64 @@ static void test_effect_context(BOOL d3d11) &GUID_TestPixelShader, (const BYTE *)test_ps, sizeof(test_ps)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestPixelShader); - ok(loaded, "Shader is not loaded.\n"); + ok(loaded, "Unexpected shader loaded state.\n"); + + /* Same shader id, using different context. */ + hr = ID2D1DeviceContext_CreateEffect(ctx.context, &CLSID_TestEffect, &effect2); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + effect_context2 = NULL; + hr = ID2D1Effect_GetValueByName(effect2, L"Context", + D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context2, sizeof(effect_context2)); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + loaded = ID2D1EffectContext_IsShaderLoaded(effect_context2, &GUID_TestPixelShader); + todo_wine + ok(loaded, "Unexpected shader loaded state.\n"); + + ID2D1Effect_Release(effect2); + + /* Same shader id, using different device. */ + hr = ID2D1Factory1_CreateDevice(factory, ctx.device, &device); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = ID2D1Device_CreateDeviceContext(device, D2D1_DEVICE_CONTEXT_OPTIONS_NONE, &device_context); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + hr = ID2D1DeviceContext_CreateEffect(device_context, &CLSID_TestEffect, &effect2); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + effect_context = NULL; + hr = ID2D1Effect_GetValueByName(effect2, L"Context", + D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestPixelShader); + ok(!loaded, "Unexpected shader loaded state.\n"); + + ID2D1Effect_Release(effect2); + + ID2D1DeviceContext_Release(device_context); + ID2D1Device_Release(device); + + /* Release all created effects, check shader map. */ + refcount = ID2D1Effect_Release(effect); + ok(!refcount, "Unexpected refcount %lu.\n", refcount); + + hr = ID2D1DeviceContext_CreateEffect(ctx.context, &CLSID_TestEffect, &effect); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + effect_context = NULL; + hr = ID2D1Effect_GetValueByName(effect, L"Context", + D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestPixelShader); + todo_wine + ok(loaded, "Unexpected shader loaded state.\n");
ID2D1Effect_Release(effect); + hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); release_test_context(&ctx);
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/d2d1_private.h | 5 +++-- dlls/d2d1/dc_render_target.c | 5 +++-- dlls/d2d1/device.c | 35 ++++++++++++++++++---------------- dlls/d2d1/factory.c | 3 ++- dlls/d2d1/hwnd_render_target.c | 2 +- dlls/d2d1/wic_render_target.c | 3 ++- 6 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index dfd4e130f58..8762a7a5503 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -171,7 +171,7 @@ struct d2d_device_context const struct d2d_device_context_ops *ops;
ID2D1Factory *factory; - ID2D1Device *device; + struct d2d_device *device; ID3D11Device1 *d3d_device; ID3DDeviceContextState *d3d_state; struct @@ -209,7 +209,7 @@ struct d2d_device_context struct d2d_clip_stack clip_stack; };
-HRESULT d2d_d3d_create_render_target(ID2D1Device *device, IDXGISurface *surface, IUnknown *outer_unknown, +HRESULT d2d_d3d_create_render_target(struct d2d_device *device, IDXGISurface *surface, IUnknown *outer_unknown, const struct d2d_device_context_ops *ops, const D2D1_RENDER_TARGET_PROPERTIES *desc, void **render_target);
@@ -601,6 +601,7 @@ struct d2d_device };
void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *factory, IDXGIDevice *dxgi_device); +struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device1 *iface);
struct d2d_shader { diff --git a/dlls/d2d1/dc_render_target.c b/dlls/d2d1/dc_render_target.c index 99b2a1d4da9..aa0c715baa5 100644 --- a/dlls/d2d1/dc_render_target.c +++ b/dlls/d2d1/dc_render_target.c @@ -864,8 +864,9 @@ HRESULT d2d_dc_render_target_init(struct d2d_dc_render_target *render_target, ID return hr; }
- hr = d2d_d3d_create_render_target(device, NULL, (IUnknown *)&render_target->ID2D1DCRenderTarget_iface, - &d2d_dc_render_target_ops, desc, (void **)&render_target->dxgi_inner); + hr = d2d_d3d_create_render_target(unsafe_impl_from_ID2D1Device((ID2D1Device1* )device), NULL, + (IUnknown *)&render_target->ID2D1DCRenderTarget_iface, &d2d_dc_render_target_ops, + desc, (void **)&render_target->dxgi_inner); ID2D1Device_Release(device); if (FAILED(hr)) { diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 25cbb609b26..954ce7f8c28 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -40,8 +40,6 @@ static inline struct d2d_device *impl_from_ID2D1Device(ID2D1Device1 *iface) return CONTAINING_RECORD(iface, struct d2d_device, ID2D1Device1_iface); }
-static struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device1 *iface); - static ID2D1Brush *d2d_draw_get_text_brush(struct d2d_draw_text_layout_ctx *context, IUnknown *effect) { ID2D1Brush *brush = NULL; @@ -293,7 +291,7 @@ static ULONG STDMETHODCALLTYPE d2d_device_context_inner_Release(IUnknown *iface) IUnknown_Release(context->target.object); ID3D11Device1_Release(context->d3d_device); ID2D1Factory_Release(context->factory); - ID2D1Device_Release(context->device); + ID2D1Device1_Release(&context->device->ID2D1Device1_iface); free(context); }
@@ -2338,7 +2336,7 @@ static void STDMETHODCALLTYPE d2d_device_context_GetDevice(ID2D1DeviceContext1 *
TRACE("iface %p, device %p.\n", iface, device);
- *device = context->device; + *device = (ID2D1Device *)&context->device->ID2D1Device1_iface; ID2D1Device_AddRef(*device); }
@@ -3184,8 +3182,8 @@ static const struct ID2D1GdiInteropRenderTargetVtbl d2d_gdi_interop_render_targe d2d_gdi_interop_render_target_ReleaseDC, };
-static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, ID2D1Device *device, - IUnknown *outer_unknown, const struct d2d_device_context_ops *ops) +static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, + struct d2d_device *device, IUnknown *outer_unknown, const struct d2d_device_context_ops *ops) { D3D11_SUBRESOURCE_DATA buffer_data; struct d2d_device *device_impl; @@ -4248,9 +4246,9 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, render_target->IDWriteTextRenderer_iface.lpVtbl = &d2d_text_renderer_vtbl; render_target->IUnknown_iface.lpVtbl = &d2d_device_context_inner_unknown_vtbl; render_target->refcount = 1; - ID2D1Device_GetFactory(device, &render_target->factory); + ID2D1Device1_GetFactory(&device->ID2D1Device1_iface, &render_target->factory); render_target->device = device; - ID2D1Device_AddRef(render_target->device); + ID2D1Device1_AddRef(&render_target->device->ID2D1Device1_iface);
render_target->outer_unknown = outer_unknown ? outer_unknown : &render_target->IUnknown_iface; render_target->ops = ops; @@ -4424,12 +4422,12 @@ err: ID3DDeviceContextState_Release(render_target->d3d_state); if (render_target->d3d_device) ID3D11Device1_Release(render_target->d3d_device); - ID2D1Device_Release(render_target->device); + ID2D1Device1_Release(&render_target->device->ID2D1Device1_iface); ID2D1Factory_Release(render_target->factory); return hr; }
-HRESULT d2d_d3d_create_render_target(ID2D1Device *device, IDXGISurface *surface, IUnknown *outer_unknown, +HRESULT d2d_d3d_create_render_target(struct d2d_device *device, IDXGISurface *surface, IUnknown *outer_unknown, const struct d2d_device_context_ops *ops, const D2D1_RENDER_TARGET_PROPERTIES *desc, void **render_target) { D2D1_BITMAP_PROPERTIES1 bitmap_desc; @@ -4553,8 +4551,9 @@ static void WINAPI d2d_device_GetFactory(ID2D1Device1 *iface, ID2D1Factory **fac ID2D1Factory1_AddRef(device->factory); }
-static HRESULT d2d_device_create_device_context(ID2D1Device1 *iface, D2D1_DEVICE_CONTEXT_OPTIONS options, - ID2D1DeviceContext1 **context) { +static HRESULT d2d_device_create_device_context(struct d2d_device *device, + D2D1_DEVICE_CONTEXT_OPTIONS options, ID2D1DeviceContext1 **context) +{ struct d2d_device_context *object; HRESULT hr;
@@ -4564,7 +4563,7 @@ static HRESULT d2d_device_create_device_context(ID2D1Device1 *iface, D2D1_DEVICE if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
- if (FAILED(hr = d2d_device_context_init(object, (ID2D1Device *)iface, NULL, NULL))) + if (FAILED(hr = d2d_device_context_init(object, device, NULL, NULL))) { WARN("Failed to initialise device context, hr %#lx.\n", hr); free(object); @@ -4580,9 +4579,11 @@ static HRESULT d2d_device_create_device_context(ID2D1Device1 *iface, D2D1_DEVICE static HRESULT WINAPI d2d_device_CreateDeviceContext(ID2D1Device1 *iface, D2D1_DEVICE_CONTEXT_OPTIONS options, ID2D1DeviceContext **context) { + struct d2d_device *device = impl_from_ID2D1Device(iface); + TRACE("iface %p, options %#x, context %p.\n", iface, options, context);
- return d2d_device_create_device_context(iface, options, (ID2D1DeviceContext1 **)context); + return d2d_device_create_device_context(device, options, (ID2D1DeviceContext1 **)context); }
static HRESULT WINAPI d2d_device_CreatePrintControl(ID2D1Device1 *iface, IWICImagingFactory *wic_factory, @@ -4629,9 +4630,11 @@ static void WINAPI d2d_device_SetRenderingPriority(ID2D1Device1 *iface, D2D1_REN static HRESULT WINAPI d2d_device_CreateDeviceContext1(ID2D1Device1 *iface, D2D1_DEVICE_CONTEXT_OPTIONS options, ID2D1DeviceContext1 **context) { + struct d2d_device *device = impl_from_ID2D1Device(iface); + TRACE("iface %p, options %#x, context %p.\n", iface, options, context);
- return d2d_device_create_device_context(iface, options, context); + return d2d_device_create_device_context(device, options, context); }
static const struct ID2D1Device1Vtbl d2d_device_vtbl = @@ -4650,7 +4653,7 @@ static const struct ID2D1Device1Vtbl d2d_device_vtbl = d2d_device_CreateDeviceContext1, };
-static struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device1 *iface) +struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device1 *iface) { if (!iface) return NULL; diff --git a/dlls/d2d1/factory.c b/dlls/d2d1/factory.c index bf905bcd581..fff9895e930 100644 --- a/dlls/d2d1/factory.c +++ b/dlls/d2d1/factory.c @@ -495,7 +495,8 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDxgiSurfaceRenderTarget(ID2D1 return hr; }
- hr = d2d_d3d_create_render_target(device, surface, NULL, NULL, desc, (void **)render_target); + hr = d2d_d3d_create_render_target(unsafe_impl_from_ID2D1Device((ID2D1Device1 *)device), surface, + NULL, NULL, desc, (void **)render_target); ID2D1Device_Release(device); return hr; } diff --git a/dlls/d2d1/hwnd_render_target.c b/dlls/d2d1/hwnd_render_target.c index f176a25e956..7f16ff00d4e 100644 --- a/dlls/d2d1/hwnd_render_target.c +++ b/dlls/d2d1/hwnd_render_target.c @@ -928,7 +928,7 @@ HRESULT d2d_hwnd_render_target_init(struct d2d_hwnd_render_target *render_target return hr; }
- hr = d2d_d3d_create_render_target(device, dxgi_surface, + hr = d2d_d3d_create_render_target(unsafe_impl_from_ID2D1Device((ID2D1Device1 *)device), dxgi_surface, (IUnknown *)&render_target->ID2D1HwndRenderTarget_iface, &d2d_hwnd_render_target_ops, &dxgi_rt_desc, (void **)&render_target->dxgi_inner); IDXGISurface_Release(dxgi_surface); diff --git a/dlls/d2d1/wic_render_target.c b/dlls/d2d1/wic_render_target.c index f6e7b14ed3f..858c187e3bc 100644 --- a/dlls/d2d1/wic_render_target.c +++ b/dlls/d2d1/wic_render_target.c @@ -255,7 +255,8 @@ HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target, return hr; }
- hr = d2d_d3d_create_render_target(device, render_target->dxgi_surface, &render_target->IUnknown_iface, + hr = d2d_d3d_create_render_target(unsafe_impl_from_ID2D1Device((ID2D1Device1 *)device), + render_target->dxgi_surface, &render_target->IUnknown_iface, &d2d_wic_render_target_ops, desc, (void **)&render_target->dxgi_inner); ID2D1Device_Release(device); if (FAILED(hr))
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/d2d1_private.h | 25 +++++++++++-------- dlls/d2d1/device.c | 36 +++++++++++++++++++++++++++ dlls/d2d1/effect.c | 54 ++++++---------------------------------- dlls/d2d1/tests/d2d1.c | 2 -- 4 files changed, 59 insertions(+), 58 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 8762a7a5503..f3029bab0f2 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -592,22 +592,31 @@ HRESULT d2d_geometry_group_init(struct d2d_geometry *geometry, ID2D1Factory *fac D2D1_FILL_MODE fill_mode, ID2D1Geometry **src_geometries, unsigned int geometry_count); struct d2d_geometry *unsafe_impl_from_ID2D1Geometry(ID2D1Geometry *iface);
+struct d2d_shader +{ + GUID id; + IUnknown *shader; +}; + struct d2d_device { ID2D1Device1 ID2D1Device1_iface; LONG refcount; ID2D1Factory1 *factory; IDXGIDevice *dxgi_device; + + struct + { + struct d2d_shader *objects; + size_t size; + size_t count; + } shaders; };
void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *factory, IDXGIDevice *dxgi_device); struct d2d_device *unsafe_impl_from_ID2D1Device(ID2D1Device1 *iface); - -struct d2d_shader -{ - GUID id; - IUnknown *shader; -}; +HRESULT d2d_device_add_shader(struct d2d_device *device, REFGUID shader_id, IUnknown *shader); +BOOL d2d_device_is_shader_loaded(struct d2d_device *device, REFGUID shader_id);
struct d2d_effect_context { @@ -615,10 +624,6 @@ struct d2d_effect_context LONG refcount;
struct d2d_device_context *device_context; - - struct d2d_shader *shaders; - size_t shaders_size; - size_t shader_count; };
void d2d_effect_context_init(struct d2d_effect_context *effect_context, diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 954ce7f8c28..33cf943010c 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -4528,6 +4528,7 @@ static ULONG WINAPI d2d_device_Release(ID2D1Device1 *iface) { struct d2d_device *device = impl_from_ID2D1Device(iface); ULONG refcount = InterlockedDecrement(&device->refcount); + size_t i;
TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
@@ -4535,6 +4536,9 @@ static ULONG WINAPI d2d_device_Release(ID2D1Device1 *iface) { IDXGIDevice_Release(device->dxgi_device); ID2D1Factory1_Release(device->factory); + for (i = 0; i < device->shaders.count; ++i) + IUnknown_Release(device->shaders.objects[i].shader); + free(device->shaders.objects); free(device); }
@@ -4670,3 +4674,35 @@ void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *iface, IDXGIDevic device->dxgi_device = dxgi_device; IDXGIDevice_AddRef(device->dxgi_device); } + +HRESULT d2d_device_add_shader(struct d2d_device *device, REFGUID shader_id, IUnknown *shader) +{ + struct d2d_shader *entry; + + if (!d2d_array_reserve((void **)&device->shaders.objects, &device->shaders.size, + device->shaders.count + 1, sizeof(*device->shaders.objects))) + { + WARN("Failed to resize shaders array.\n"); + return E_OUTOFMEMORY; + } + + entry = &device->shaders.objects[device->shaders.count++]; + entry->id = *shader_id; + entry->shader = shader; + IUnknown_AddRef(entry->shader); + + return S_OK; +} + +BOOL d2d_device_is_shader_loaded(struct d2d_device *device, REFGUID shader_id) +{ + size_t i; + + for (i = 0; i < device->shaders.count; ++i) + { + if (IsEqualGUID(shader_id, &device->shaders.objects[i].id)) + return TRUE; + } + + return FALSE; +} diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index 7b086e20b9b..ddc9eee9236 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -624,37 +624,6 @@ static inline struct d2d_effect_context *impl_from_ID2D1EffectContext(ID2D1Effec return CONTAINING_RECORD(iface, struct d2d_effect_context, ID2D1EffectContext_iface); }
-static void d2d_effect_context_cleanup(struct d2d_effect_context *effect_context) -{ - size_t i; - - for (i = 0; i < effect_context->shader_count; ++i) - IUnknown_Release(effect_context->shaders[i].shader); - free(effect_context->shaders); - - ID2D1DeviceContext1_Release(&effect_context->device_context->ID2D1DeviceContext1_iface); -} - -static HRESULT d2d_effect_context_add_shader(struct d2d_effect_context *effect_context, - REFGUID shader_id, void *shader) -{ - struct d2d_shader *entry; - - if (!d2d_array_reserve((void **)&effect_context->shaders, &effect_context->shaders_size, - effect_context->shader_count + 1, sizeof(*effect_context->shaders))) - { - WARN("Failed to resize shaders array.\n"); - return E_OUTOFMEMORY; - } - - entry = &effect_context->shaders[effect_context->shader_count++]; - entry->id = *shader_id; - entry->shader = shader; - IUnknown_AddRef(entry->shader); - - return S_OK; -} - static HRESULT STDMETHODCALLTYPE d2d_effect_context_QueryInterface(ID2D1EffectContext *iface, REFIID iid, void **out) { TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); @@ -692,7 +661,7 @@ static ULONG STDMETHODCALLTYPE d2d_effect_context_Release(ID2D1EffectContext *if
if (!refcount) { - d2d_effect_context_cleanup(effect_context); + ID2D1DeviceContext1_Release(&effect_context->device_context->ID2D1DeviceContext1_iface); free(effect_context); }
@@ -787,7 +756,7 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadPixelShader(ID2D1EffectC return hr; }
- hr = d2d_effect_context_add_shader(effect_context, shader_id, shader); + hr = d2d_device_add_shader(effect_context->device_context->device, shader_id, (IUnknown *)shader); ID3D11PixelShader_Release(shader);
return hr; @@ -797,7 +766,7 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadVertexShader(ID2D1Effect REFGUID shader_id, const BYTE *buffer, UINT32 buffer_size) { struct d2d_effect_context *effect_context = impl_from_ID2D1EffectContext(iface); - ID3D11VertexShader *vertex_shader; + ID3D11VertexShader *shader; HRESULT hr;
TRACE("iface %p, shader_id %s, buffer %p, buffer_size %u.\n", @@ -807,14 +776,14 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadVertexShader(ID2D1Effect return S_OK;
if (FAILED(hr = ID3D11Device1_CreateVertexShader(effect_context->device_context->d3d_device, - buffer, buffer_size, NULL, &vertex_shader))) + buffer, buffer_size, NULL, &shader))) { WARN("Failed to create vertex shader, hr %#lx.\n", hr); return hr; }
- hr = d2d_effect_context_add_shader(effect_context, shader_id, vertex_shader); - ID3D11VertexShader_Release(vertex_shader); + hr = d2d_device_add_shader(effect_context->device_context->device, shader_id, (IUnknown *)shader); + ID3D11VertexShader_Release(shader);
return hr; } @@ -839,7 +808,7 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadComputeShader(ID2D1Effec return hr; }
- hr = d2d_effect_context_add_shader(effect_context, shader_id, shader); + hr = d2d_device_add_shader(effect_context->device_context->device, shader_id, (IUnknown *)shader); ID3D11ComputeShader_Release(shader);
return hr; @@ -848,17 +817,10 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadComputeShader(ID2D1Effec static BOOL STDMETHODCALLTYPE d2d_effect_context_IsShaderLoaded(ID2D1EffectContext *iface, REFGUID shader_id) { struct d2d_effect_context *effect_context = impl_from_ID2D1EffectContext(iface); - size_t i;
TRACE("iface %p, shader_id %s.\n", iface, debugstr_guid(shader_id));
- for (i = 0; i < effect_context->shader_count; ++i) - { - if (IsEqualGUID(shader_id, &effect_context->shaders[i].id)) - return TRUE; - } - - return FALSE; + return d2d_device_is_shader_loaded(effect_context->device_context->device, shader_id); }
static HRESULT STDMETHODCALLTYPE d2d_effect_context_CreateResourceTexture(ID2D1EffectContext *iface, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 2f4ded1d0cc..4f53b4b7142 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -11483,7 +11483,6 @@ static void test_effect_context(BOOL d3d11) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
loaded = ID2D1EffectContext_IsShaderLoaded(effect_context2, &GUID_TestPixelShader); - todo_wine ok(loaded, "Unexpected shader loaded state.\n");
ID2D1Effect_Release(effect2); @@ -11524,7 +11523,6 @@ static void test_effect_context(BOOL d3d11) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
loaded = ID2D1EffectContext_IsShaderLoaded(effect_context, &GUID_TestPixelShader); - todo_wine ok(loaded, "Unexpected shader loaded state.\n");
ID2D1Effect_Release(effect);
On Wed Aug 2 17:12:33 2023 +0000, Nikolay Sivov wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/3483/diffs?diff_id=60702&start_sha=6b569a3f8b09242fbf3069cda6ee519a577b07de#7bd8161ba70cc38a0182d56400f361d22514b82f_43_43)
Thanks.