Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/d2d1_private.h | 10 ++++++++++ dlls/d2d1/effect.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index de3519c76d7..1f04e797947 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -568,6 +568,12 @@ struct d2d_device
void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *factory, IDXGIDevice *dxgi_device) DECLSPEC_HIDDEN;
+struct d2d_shader +{ + const GUID *id; + void *shader; +}; + struct d2d_effect_context { ID2D1EffectContext ID2D1EffectContext_iface; @@ -576,6 +582,10 @@ struct d2d_effect_context ID2D1DeviceContext *device_context; ID3D11Device1 *d3d_device; ID2D1Factory *factory; + + 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/effect.c b/dlls/d2d1/effect.c index 009ffd8e4df..5f2ccb4ce8f 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -37,6 +37,14 @@ static inline struct d2d_effect_context *impl_from_ID2D1EffectContext(ID2D1Effec
static void d2d_effect_context_cleanup(struct d2d_effect_context *effect_context) { + unsigned int i; + + for (i = 0; i < effect_context->shader_count; ++i) + { + if (effect_context->shaders[i].shader) + IUnknown_Release((IUnknown *)effect_context->shaders[i].shader); + } + heap_free(effect_context->shaders); ID2D1Factory_Release(effect_context->factory); ID2D1DeviceContext_Release(effect_context->device_context); } @@ -180,10 +188,38 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadPixelShader(ID2D1EffectC static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadVertexShader(ID2D1EffectContext *iface, REFGUID shader_id, const BYTE *buffer, UINT32 buffer_size) { - FIXME("iface %p, shader_id %s, buffer %p, buffer_size %u stub!\n", + struct d2d_effect_context *effect_context = impl_from_ID2D1EffectContext(iface); + ID3D11VertexShader *vertex_shader; + struct d2d_shader *shader; + HRESULT hr; + + TRACE("iface %p, shader_id %s, buffer %p, buffer_size %u.\n", iface, debugstr_guid(shader_id), buffer, buffer_size);
- return E_NOTIMPL; + if (FAILED(hr = ID3D11Device1_CreateVertexShader(effect_context->d3d_device, + buffer, buffer_size, NULL, &vertex_shader))) + { + WARN("Failed to create vertex shader, hr %#lx.\n", hr); + return hr; + } + + effect_context->shader_count++; + if (effect_context->shaders_size < effect_context->shader_count) + { + if (!d2d_array_reserve((void **)&effect_context->shaders, &effect_context->shaders_size, + effect_context->shader_count, sizeof(*effect_context->shaders))) + { + ERR("Failed to resize shaders array.\n"); + ID3D11VertexShader_Release(vertex_shader); + return E_OUTOFMEMORY; + } + } + + shader = &effect_context->shaders[effect_context->shader_count - 1]; + shader->id = shader_id; + shader->shader = vertex_shader; + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d2d_effect_context_LoadComputeShader(ID2D1EffectContext *iface,