Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/d3d10_main.c | 53 ----------------------------------------- dlls/d3d10/effect.c | 53 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 53 deletions(-)
diff --git a/dlls/d3d10/d3d10_main.c b/dlls/d3d10/d3d10_main.c index 2d08c82a3c4..6961589ca31 100644 --- a/dlls/d3d10/d3d10_main.c +++ b/dlls/d3d10/d3d10_main.c @@ -230,50 +230,6 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER return S_OK; }
-static int d3d10_effect_type_compare(const void *key, const struct wine_rb_entry *entry) -{ - const struct d3d10_effect_type *t = WINE_RB_ENTRY_VALUE(entry, const struct d3d10_effect_type, entry); - const DWORD *id = key; - - return *id - t->id; -} - -HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT flags, - ID3D10Device *device, ID3D10EffectPool *effect_pool, ID3D10Effect **effect) -{ - struct d3d10_effect *object; - HRESULT hr; - - FIXME("data %p, data_size %lu, flags %#x, device %p, effect_pool %p, effect %p stub!\n", - data, data_size, flags, device, effect_pool, effect); - - if (!(object = heap_alloc_zero(sizeof(*object)))) - { - ERR("Failed to allocate D3D10 effect object memory\n"); - return E_OUTOFMEMORY; - } - - wine_rb_init(&object->types, d3d10_effect_type_compare); - object->ID3D10Effect_iface.lpVtbl = &d3d10_effect_vtbl; - object->refcount = 1; - ID3D10Device_AddRef(device); - object->device = device; - - hr = d3d10_effect_parse(object, data, data_size); - if (FAILED(hr)) - { - ERR("Failed to parse effect\n"); - IUnknown_Release(&object->ID3D10Effect_iface); - return hr; - } - - *effect = &object->ID3D10Effect_iface; - - TRACE("Created ID3D10Effect %p\n", object); - - return S_OK; -} - HRESULT WINAPI D3D10CompileEffectFromMemory(void *data, SIZE_T data_size, const char *filename, const D3D10_SHADER_MACRO *defines, ID3D10Include *include, UINT hlsl_flags, UINT fx_flags, ID3D10Blob **effect, ID3D10Blob **errors) @@ -287,15 +243,6 @@ HRESULT WINAPI D3D10CompileEffectFromMemory(void *data, SIZE_T data_size, const NULL, "fx_4_0", hlsl_flags, fx_flags, effect, errors); }
-HRESULT WINAPI D3D10CreateEffectPoolFromMemory(void *data, SIZE_T data_size, UINT fx_flags, - ID3D10Device *device, ID3D10EffectPool **effect_pool) -{ - FIXME("data %p, data_size %lu, fx_flags %#x, device %p, effect_pool %p stub.\n", - data, data_size, fx_flags, device, effect_pool); - - return E_NOTIMPL; -} - const char * WINAPI D3D10GetVertexShaderProfile(ID3D10Device *device) { FIXME("device %p stub!\n", device); diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index e77d0691fcf..7342c2dbe23 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -8360,3 +8360,56 @@ static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl = d3d10_effect_type_GetMemberName, d3d10_effect_type_GetMemberSemantic, }; + +static int d3d10_effect_type_compare(const void *key, const struct wine_rb_entry *entry) +{ + const struct d3d10_effect_type *t = WINE_RB_ENTRY_VALUE(entry, const struct d3d10_effect_type, entry); + const DWORD *id = key; + + return *id - t->id; +} + +HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT flags, + ID3D10Device *device, ID3D10EffectPool *effect_pool, ID3D10Effect **effect) +{ + struct d3d10_effect *object; + HRESULT hr; + + FIXME("data %p, data_size %lu, flags %#x, device %p, effect_pool %p, effect %p stub!\n", + data, data_size, flags, device, effect_pool, effect); + + if (!(object = heap_alloc_zero(sizeof(*object)))) + { + ERR("Failed to allocate D3D10 effect object memory\n"); + return E_OUTOFMEMORY; + } + + wine_rb_init(&object->types, d3d10_effect_type_compare); + object->ID3D10Effect_iface.lpVtbl = &d3d10_effect_vtbl; + object->refcount = 1; + ID3D10Device_AddRef(device); + object->device = device; + + hr = d3d10_effect_parse(object, data, data_size); + if (FAILED(hr)) + { + ERR("Failed to parse effect\n"); + IUnknown_Release(&object->ID3D10Effect_iface); + return hr; + } + + *effect = &object->ID3D10Effect_iface; + + TRACE("Created effect %p\n", object); + + return S_OK; +} + +HRESULT WINAPI D3D10CreateEffectPoolFromMemory(void *data, SIZE_T data_size, UINT fx_flags, + ID3D10Device *device, ID3D10EffectPool **effect_pool) +{ + FIXME("data %p, data_size %lu, fx_flags %#x, device %p, effect_pool %p stub.\n", + data, data_size, fx_flags, device, effect_pool); + + return E_NOTIMPL; +}
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/d3d10_private.h | 2 +- dlls/d3d10/effect.c | 148 +++++++++++++++++++++++++++++++++---- dlls/d3d10/tests/effect.c | 122 ++++++++++++++++++++++++------ 3 files changed, 235 insertions(+), 37 deletions(-)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index 4d73121d6ca..a230d0bcbe6 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -257,10 +257,10 @@ struct d3d10_effect_anonymous_shader };
/* ID3D10Effect */ -extern const struct ID3D10EffectVtbl d3d10_effect_vtbl DECLSPEC_HIDDEN; struct d3d10_effect { ID3D10Effect ID3D10Effect_iface; + ID3D10EffectPool ID3D10EffectPool_iface; LONG refcount;
ID3D10Device *device; diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 7342c2dbe23..10b8565c8d7 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -44,6 +44,13 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
#define D3D10_FX10_TYPE_MATRIX_COLUMN_MAJOR_MASK 0x4000
+static inline struct d3d10_effect *impl_from_ID3D10EffectPool(ID3D10EffectPool *iface) +{ + return CONTAINING_RECORD(iface, struct d3d10_effect, ID3D10EffectPool_iface); +} + +static const struct ID3D10EffectVtbl d3d10_effect_pool_effect_vtbl; + static const struct ID3D10EffectTechniqueVtbl d3d10_effect_technique_vtbl; static const struct ID3D10EffectPassVtbl d3d10_effect_pass_vtbl; static const struct ID3D10EffectVariableVtbl d3d10_effect_variable_vtbl; @@ -3139,9 +3146,11 @@ static BOOL STDMETHODCALLTYPE d3d10_effect_IsValid(ID3D10Effect *iface)
static BOOL STDMETHODCALLTYPE d3d10_effect_IsPool(ID3D10Effect *iface) { - FIXME("iface %p stub!\n", iface); + struct d3d10_effect *effect = impl_from_ID3D10Effect(iface);
- return FALSE; + TRACE("iface %p.\n", iface); + + return effect->ID3D10Effect_iface.lpVtbl == &d3d10_effect_pool_effect_vtbl; }
static HRESULT STDMETHODCALLTYPE d3d10_effect_GetDevice(ID3D10Effect *iface, ID3D10Device **device) @@ -8361,6 +8370,57 @@ static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl = d3d10_effect_type_GetMemberSemantic, };
+static HRESULT STDMETHODCALLTYPE d3d10_effect_pool_QueryInterface(ID3D10EffectPool *iface, + REFIID riid, void **object) +{ + TRACE("iface %p, riid %s, object %p.\n", iface, debugstr_guid(riid), object); + + if (IsEqualGUID(riid, &IID_ID3D10EffectPool) || + IsEqualGUID(riid, &IID_IUnknown)) + { + IUnknown_AddRef(iface); + *object = iface; + return S_OK; + } + + WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid)); + + *object = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d3d10_effect_pool_AddRef(ID3D10EffectPool *iface) +{ + struct d3d10_effect *effect = impl_from_ID3D10EffectPool(iface); + return d3d10_effect_AddRef(&effect->ID3D10Effect_iface); +} + +static ULONG STDMETHODCALLTYPE d3d10_effect_pool_Release(ID3D10EffectPool *iface) +{ + struct d3d10_effect *effect = impl_from_ID3D10EffectPool(iface); + return d3d10_effect_Release(&effect->ID3D10Effect_iface); +} + +static ID3D10Effect * STDMETHODCALLTYPE d3d10_effect_pool_AsEffect(ID3D10EffectPool *iface) +{ + struct d3d10_effect *effect = impl_from_ID3D10EffectPool(iface); + + TRACE("%p.\n", iface); + + return &effect->ID3D10Effect_iface; +} + +const struct ID3D10EffectPoolVtbl d3d10_effect_pool_vtbl = +{ + /* IUnknown methods */ + d3d10_effect_pool_QueryInterface, + d3d10_effect_pool_AddRef, + d3d10_effect_pool_Release, + /* ID3D10EffectPool methods */ + d3d10_effect_pool_AsEffect, +}; + + static int d3d10_effect_type_compare(const void *key, const struct wine_rb_entry *entry) { const struct d3d10_effect_type *t = WINE_RB_ENTRY_VALUE(entry, const struct d3d10_effect_type, entry); @@ -8369,23 +8429,18 @@ static int d3d10_effect_type_compare(const void *key, const struct wine_rb_entry return *id - t->id; }
-HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT flags, - ID3D10Device *device, ID3D10EffectPool *effect_pool, ID3D10Effect **effect) +static HRESULT d3d10_create_effect(void *data, SIZE_T data_size, ID3D10Device *device, + const ID3D10EffectVtbl *vtbl, struct d3d10_effect **effect) { struct d3d10_effect *object; HRESULT hr;
- FIXME("data %p, data_size %lu, flags %#x, device %p, effect_pool %p, effect %p stub!\n", - data, data_size, flags, device, effect_pool, effect); - if (!(object = heap_alloc_zero(sizeof(*object)))) - { - ERR("Failed to allocate D3D10 effect object memory\n"); return E_OUTOFMEMORY; - }
wine_rb_init(&object->types, d3d10_effect_type_compare); - object->ID3D10Effect_iface.lpVtbl = &d3d10_effect_vtbl; + object->ID3D10Effect_iface.lpVtbl = vtbl; + object->ID3D10EffectPool_iface.lpVtbl = &d3d10_effect_pool_vtbl; object->refcount = 1; ID3D10Device_AddRef(device); object->device = device; @@ -8398,18 +8453,83 @@ HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT fl return hr; }
+ *effect = object; + + return S_OK; +} + +HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT flags, + ID3D10Device *device, ID3D10EffectPool *effect_pool, ID3D10Effect **effect) +{ + struct d3d10_effect *object; + HRESULT hr; + + FIXME("data %p, data_size %lu, flags %#x, device %p, effect_pool %p, effect %p stub!\n", + data, data_size, flags, device, effect_pool, effect); + + if (FAILED(hr = d3d10_create_effect(data, data_size, device, &d3d10_effect_vtbl, &object))) + { + WARN("Failed to create an effect, hr %#x.\n", hr); + } + *effect = &object->ID3D10Effect_iface;
TRACE("Created effect %p\n", object);
- return S_OK; + return hr; }
+static HRESULT STDMETHODCALLTYPE d3d10_effect_pool_effect_QueryInterface(ID3D10Effect *iface, + REFIID riid, void **object) +{ + struct d3d10_effect *effect = impl_from_ID3D10Effect(iface); + + TRACE("iface %p, riid %s, obj %p.\n", iface, debugstr_guid(riid), object); + + return IUnknown_QueryInterface(&effect->ID3D10EffectPool_iface, riid, object); +} + +static const struct ID3D10EffectVtbl d3d10_effect_pool_effect_vtbl = +{ + /* IUnknown methods */ + d3d10_effect_pool_effect_QueryInterface, + d3d10_effect_AddRef, + d3d10_effect_Release, + /* ID3D10Effect methods */ + d3d10_effect_IsValid, + d3d10_effect_IsPool, + d3d10_effect_GetDevice, + d3d10_effect_GetDesc, + d3d10_effect_GetConstantBufferByIndex, + d3d10_effect_GetConstantBufferByName, + d3d10_effect_GetVariableByIndex, + d3d10_effect_GetVariableByName, + d3d10_effect_GetVariableBySemantic, + d3d10_effect_GetTechniqueByIndex, + d3d10_effect_GetTechniqueByName, + d3d10_effect_Optimize, + d3d10_effect_IsOptimized, +}; + HRESULT WINAPI D3D10CreateEffectPoolFromMemory(void *data, SIZE_T data_size, UINT fx_flags, ID3D10Device *device, ID3D10EffectPool **effect_pool) { - FIXME("data %p, data_size %lu, fx_flags %#x, device %p, effect_pool %p stub.\n", + struct d3d10_effect *object; + HRESULT hr; + + TRACE("data %p, data_size %lu, fx_flags %#x, device %p, effect_pool %p.\n", data, data_size, fx_flags, device, effect_pool);
- return E_NOTIMPL; + if (FAILED(hr = d3d10_create_effect(data, data_size, device, &d3d10_effect_pool_effect_vtbl, + &object))) + { + WARN("Failed to create an effect, hr %#x.\n", hr); + return hr; + } + + *effect_pool = &object->ID3D10EffectPool_iface; + + TRACE("Created effect pool %p.\n", object); + + return hr; } diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 9223fdf51ef..97331c2135e 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -6377,6 +6377,7 @@ static void test_effect_pool(void) D3D10_EFFECT_DESC desc; ID3D10Buffer *buffer; ULONG refcount; + IUnknown *unk; HRESULT hr; BOOL ret;
@@ -6394,13 +6395,7 @@ todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = create_effect_pool(fx_test_pool, device, &pool); -todo_wine ok(hr == S_OK, "Failed to create effect pool, hr %#x.\n", hr); - if (FAILED(hr)) - { - ID3D10Device_Release(device); - return; - }
refcount = get_refcount(pool); ok(refcount == 1, "Unexpected refcount %u.\n", refcount); @@ -6412,6 +6407,27 @@ todo_wine ok(refcount == 2, "Unexpected refcount %u.\n", refcount); effect->lpVtbl->Release(effect);
+ hr = pool->lpVtbl->QueryInterface(pool, &IID_IUnknown, (void **)&unk); +todo_wine + ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) IUnknown_Release(unk); + + hr = pool->lpVtbl->QueryInterface(pool, &IID_ID3D10Effect, (void **)&unk); + ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr); + + hr = pool->lpVtbl->QueryInterface(pool, &IID_ID3D10EffectPool, (void **)&unk); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(unk == (IUnknown *)pool, "Unexpected pointer.\n"); + IUnknown_Release(unk); + + hr = effect->lpVtbl->QueryInterface(effect, &IID_IUnknown, (void **)&unk); +todo_wine + ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) IUnknown_Release(unk); + + hr = effect->lpVtbl->QueryInterface(effect, &IID_ID3D10Effect, (void **)&unk); + ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr); + hr = effect->lpVtbl->QueryInterface(effect, &IID_ID3D10EffectPool, (void **)&pool2); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(pool2 == pool, "Unexpected pool pointer.\n"); @@ -6434,24 +6450,28 @@ todo_wine hr = cb->lpVtbl->GetDesc(cb, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_cb"), "Unexpected name %s.\n", var_desc.Name); +todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = effect->lpVtbl->GetVariableByName(effect, "s_blendstate"); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_blendstate"), "Unexpected name %s.\n", var_desc.Name); +todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = effect->lpVtbl->GetVariableByName(effect, "s_texture"); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_texture"), "Unexpected name %s.\n", var_desc.Name); +todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = effect->lpVtbl->GetVariableByName(effect, "ps"); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "ps"), "Unexpected name %s.\n", var_desc.Name); +todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
t = effect->lpVtbl->GetTechniqueByIndex(effect, 0); @@ -6466,11 +6486,31 @@ todo_wine
/* Create standalone effect from the same blob used for pool, */ hr = create_effect(fx_test_pool, D3D10_EFFECT_COMPILE_CHILD_EFFECT, device, NULL, &child_effect); +todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) child_effect->lpVtbl->Release(child_effect);
hr = create_effect(fx_test_pool, 0, device, NULL, &effect2); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+ hr = effect2->lpVtbl->QueryInterface(effect2, &IID_IUnknown, (void **)&unk); +todo_wine + ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) IUnknown_Release(unk); + + hr = effect2->lpVtbl->QueryInterface(effect2, &IID_ID3D10Effect, (void **)&unk); +todo_wine + ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) IUnknown_Release(unk); + + /* For regular effects querying for ID3D10EffectPool is broken */ + hr = effect2->lpVtbl->QueryInterface(effect2, &IID_ID3D10EffectPool, (void **)&unk); +todo_wine { + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(unk == (IUnknown *)effect2, "Unexpected pointer.\n"); +} + if (SUCCEEDED(hr)) IUnknown_Release(unk); + ret = effect2->lpVtbl->IsPool(effect2); ok(!ret, "Unexpected pool.\n");
@@ -6505,24 +6545,33 @@ todo_wine ID3D10Device_Release(device3);
cb = child_effect->lpVtbl->GetConstantBufferByName(child_effect, "s_cb"); +todo_wine ok(cb->lpVtbl->IsValid(cb), "Expected valid constant buffer.\n");
hr = cb->lpVtbl->GetConstantBuffer(cb, &buffer); +todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - ID3D10Buffer_GetDevice(buffer, &device3); - ok(device3 == device2, "Unexpected device.\n"); - ID3D10Device_Release(device3); - ID3D10Buffer_Release(buffer); + if (SUCCEEDED(hr)) + { + ID3D10Buffer_GetDevice(buffer, &device3); + ok(device3 == device2, "Unexpected device.\n"); + ID3D10Device_Release(device3); + ID3D10Buffer_Release(buffer); + }
child_effect->lpVtbl->Release(child_effect); pool2->lpVtbl->Release(pool2);
/* When pool is specified, corresponding flag has to be set. */ hr = create_effect(fx_test_pool_child, 0, device, pool, &child_effect); +todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) child_effect->lpVtbl->Release(child_effect);
hr = create_effect(fx_test_pool_child, D3D10_EFFECT_COMPILE_CHILD_EFFECT, device, NULL, &child_effect); +todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) child_effect->lpVtbl->Release(child_effect);
refcount = get_refcount(pool); ok(refcount == 1, "Unexpected refcount %u.\n", refcount); @@ -6531,15 +6580,19 @@ todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
refcount = get_refcount(pool); +todo_wine ok(refcount == 2, "Unexpected refcount %u.\n", refcount);
hr = child_effect->lpVtbl->GetDesc(child_effect, &desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); +todo_wine ok(desc.IsChildEffect, "Unexpected child flag.\n"); ok(desc.ConstantBuffers == 2, "Unexpected buffer count %u.\n", desc.ConstantBuffers); +todo_wine ok(desc.SharedConstantBuffers == 1, "Unexpected shared buffer count %u.\n", desc.SharedConstantBuffers); ok(desc.GlobalVariables == 2, "Unexpected variables count %u.\n", desc.GlobalVariables); +todo_wine ok(desc.SharedGlobalVariables == 5, "Unexpected shared variables count %u.\n", desc.SharedGlobalVariables);
@@ -6564,12 +6617,17 @@ todo_wine
cb = child_effect->lpVtbl->GetConstantBufferByIndex(child_effect, 2); ret = cb->lpVtbl->IsValid(cb); +todo_wine ok(ret, "Unexpected invalid variable.\n");
hr = cb->lpVtbl->GetDesc(cb, &var_desc); +todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - ok(!strcmp(var_desc.Name, "s_cb"), "Unexpected name %s.\n", var_desc.Name); - ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + if (SUCCEEDED(hr)) + { + ok(!strcmp(var_desc.Name, "s_cb"), "Unexpected name %s.\n", var_desc.Name); + ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + }
/* Pool techniques are not accessible */ t = effect->lpVtbl->GetTechniqueByIndex(effect, 0); @@ -6593,27 +6651,43 @@ todo_wine
v = child_effect->lpVtbl->GetVariableByIndex(child_effect, 2); hr = v->lpVtbl->GetDesc(v, &var_desc); +todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - ok(!strcmp(var_desc.Name, "f1"), "Unexpected name %s.\n", var_desc.Name); - ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + if (SUCCEEDED(hr)) + { + ok(!strcmp(var_desc.Name, "f1"), "Unexpected name %s.\n", var_desc.Name); + ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + }
v = child_effect->lpVtbl->GetVariableByIndex(child_effect, 3); hr = v->lpVtbl->GetDesc(v, &var_desc); +todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - ok(!strcmp(var_desc.Name, "f2"), "Unexpected name %s.\n", var_desc.Name); - ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + if (SUCCEEDED(hr)) + { + ok(!strcmp(var_desc.Name, "f2"), "Unexpected name %s.\n", var_desc.Name); + ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + }
v = child_effect->lpVtbl->GetVariableByIndex(child_effect, 4); hr = v->lpVtbl->GetDesc(v, &var_desc); +todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - ok(!strcmp(var_desc.Name, "s_blendstate"), "Unexpected name %s.\n", var_desc.Name); - ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + if (SUCCEEDED(hr)) + { + ok(!strcmp(var_desc.Name, "s_blendstate"), "Unexpected name %s.\n", var_desc.Name); + ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + }
v = child_effect->lpVtbl->GetVariableByName(child_effect, "s_texture"); hr = v->lpVtbl->GetDesc(v, &var_desc); +todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - ok(!strcmp(var_desc.Name, "s_texture"), "Unexpected name %s.\n", var_desc.Name); - ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + if (SUCCEEDED(hr)) + { + ok(!strcmp(var_desc.Name, "s_texture"), "Unexpected name %s.\n", var_desc.Name); + ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + }
v = child_effect->lpVtbl->GetVariableBySemantic(child_effect, "COLOR0"); hr = v->lpVtbl->GetDesc(v, &var_desc); @@ -6623,9 +6697,13 @@ todo_wine
v = child_effect->lpVtbl->GetVariableBySemantic(child_effect, "COLOR1"); hr = v->lpVtbl->GetDesc(v, &var_desc); +todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr); - ok(!strcmp(var_desc.Name, "f2"), "Unexpected name %s.\n", var_desc.Name); - ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + if (SUCCEEDED(hr)) + { + ok(!strcmp(var_desc.Name, "f2"), "Unexpected name %s.\n", var_desc.Name); + ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags); + }
child_effect->lpVtbl->Release(child_effect);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
On Thu, Sep 16, 2021 at 8:48 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3d10/d3d10_private.h | 2 +- dlls/d3d10/effect.c | 148 +++++++++++++++++++++++++++++++++---- dlls/d3d10/tests/effect.c | 122 ++++++++++++++++++++++++------ 3 files changed, 235 insertions(+), 37 deletions(-)
diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 9223fdf51ef..97331c2135e 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -6377,6 +6377,7 @@ static void test_effect_pool(void) D3D10_EFFECT_DESC desc; ID3D10Buffer *buffer; ULONG refcount;
- IUnknown *unk; HRESULT hr; BOOL ret;
@@ -6394,13 +6395,7 @@ todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = create_effect_pool(fx_test_pool, device, &pool);
-todo_wine ok(hr == S_OK, "Failed to create effect pool, hr %#x.\n", hr);
if (FAILED(hr))
{
ID3D10Device_Release(device);
return;
}
refcount = get_refcount(pool); ok(refcount == 1, "Unexpected refcount %u.\n", refcount);
@@ -6412,6 +6407,27 @@ todo_wine ok(refcount == 2, "Unexpected refcount %u.\n", refcount); effect->lpVtbl->Release(effect);
- hr = pool->lpVtbl->QueryInterface(pool, &IID_IUnknown, (void **)&unk);
+todo_wine
- ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
- if (SUCCEEDED(hr)) IUnknown_Release(unk);
- hr = pool->lpVtbl->QueryInterface(pool, &IID_ID3D10Effect, (void **)&unk);
- ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
- hr = pool->lpVtbl->QueryInterface(pool, &IID_ID3D10EffectPool, (void **)&unk);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- ok(unk == (IUnknown *)pool, "Unexpected pointer.\n");
- IUnknown_Release(unk);
- hr = effect->lpVtbl->QueryInterface(effect, &IID_IUnknown, (void **)&unk);
+todo_wine
- ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
- if (SUCCEEDED(hr)) IUnknown_Release(unk);
- hr = effect->lpVtbl->QueryInterface(effect, &IID_ID3D10Effect, (void **)&unk);
- ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
I guess we could fix those two todo_wine by not accepting IID_IUnknown in d3d10_effect_pool_QueryInterface(). Any reason not to?
Especially given the last test above, this isn't standard COM by any means...
hr = effect->lpVtbl->QueryInterface(effect, &IID_ID3D10EffectPool, (void **)&pool2); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(pool2 == pool, "Unexpected pool pointer.\n");
@@ -6434,24 +6450,28 @@ todo_wine hr = cb->lpVtbl->GetDesc(cb, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_cb"), "Unexpected name %s.\n", var_desc.Name); +todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = effect->lpVtbl->GetVariableByName(effect, "s_blendstate"); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_blendstate"), "Unexpected name %s.\n", var_desc.Name);
+todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = effect->lpVtbl->GetVariableByName(effect, "s_texture"); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_texture"), "Unexpected name %s.\n", var_desc.Name);
+todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = effect->lpVtbl->GetVariableByName(effect, "ps"); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "ps"), "Unexpected name %s.\n", var_desc.Name);
+todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
t = effect->lpVtbl->GetTechniqueByIndex(effect, 0);
@@ -6466,11 +6486,31 @@ todo_wine
/* Create standalone effect from the same blob used for pool, */ hr = create_effect(fx_test_pool, D3D10_EFFECT_COMPILE_CHILD_EFFECT, device, NULL, &child_effect);
+todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr)) child_effect->lpVtbl->Release(child_effect);
hr = create_effect(fx_test_pool, 0, device, NULL, &effect2); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = effect2->lpVtbl->QueryInterface(effect2, &IID_IUnknown, (void **)&unk);
+todo_wine
- ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
- if (SUCCEEDED(hr)) IUnknown_Release(unk);
- hr = effect2->lpVtbl->QueryInterface(effect2, &IID_ID3D10Effect, (void **)&unk);
+todo_wine
- ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
- if (SUCCEEDED(hr)) IUnknown_Release(unk);
- /* For regular effects querying for ID3D10EffectPool is broken */
- hr = effect2->lpVtbl->QueryInterface(effect2, &IID_ID3D10EffectPool, (void **)&unk);
+todo_wine {
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- ok(unk == (IUnknown *)effect2, "Unexpected pointer.\n");
+}
- if (SUCCEEDED(hr)) IUnknown_Release(unk);
I guess this one can remain todo_wine. Not that I see any trouble in just making d3d10_effect_QueryInterface() match this behavior. Somewhat relatedly, we should probably implement IsValid(), IsPool(), IsOptimized() sooner rather than later.
On 9/19/21 9:03 PM, Matteo Bruni wrote:
On Thu, Sep 16, 2021 at 8:48 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3d10/d3d10_private.h | 2 +- dlls/d3d10/effect.c | 148 +++++++++++++++++++++++++++++++++---- dlls/d3d10/tests/effect.c | 122 ++++++++++++++++++++++++------ 3 files changed, 235 insertions(+), 37 deletions(-) diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 9223fdf51ef..97331c2135e 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -6377,6 +6377,7 @@ static void test_effect_pool(void) D3D10_EFFECT_DESC desc; ID3D10Buffer *buffer; ULONG refcount;
- IUnknown *unk; HRESULT hr; BOOL ret;
@@ -6394,13 +6395,7 @@ todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = create_effect_pool(fx_test_pool, device, &pool);
-todo_wine ok(hr == S_OK, "Failed to create effect pool, hr %#x.\n", hr);
if (FAILED(hr))
{
ID3D10Device_Release(device);
return;
}
refcount = get_refcount(pool); ok(refcount == 1, "Unexpected refcount %u.\n", refcount);
@@ -6412,6 +6407,27 @@ todo_wine ok(refcount == 2, "Unexpected refcount %u.\n", refcount); effect->lpVtbl->Release(effect);
- hr = pool->lpVtbl->QueryInterface(pool, &IID_IUnknown, (void **)&unk);
+todo_wine
- ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
- if (SUCCEEDED(hr)) IUnknown_Release(unk);
- hr = pool->lpVtbl->QueryInterface(pool, &IID_ID3D10Effect, (void **)&unk);
- ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
- hr = pool->lpVtbl->QueryInterface(pool, &IID_ID3D10EffectPool, (void **)&unk);
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- ok(unk == (IUnknown *)pool, "Unexpected pointer.\n");
- IUnknown_Release(unk);
- hr = effect->lpVtbl->QueryInterface(effect, &IID_IUnknown, (void **)&unk);
+todo_wine
- ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
- if (SUCCEEDED(hr)) IUnknown_Release(unk);
- hr = effect->lpVtbl->QueryInterface(effect, &IID_ID3D10Effect, (void **)&unk);
- ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
I guess we could fix those two todo_wine by not accepting IID_IUnknown in d3d10_effect_pool_QueryInterface(). Any reason not to?
Especially given the last test above, this isn't standard COM by any means...
Yes, it is entirely broken. I wasn't planning to break ours too, it's just something that I found while testing.
hr = effect->lpVtbl->QueryInterface(effect, &IID_ID3D10EffectPool, (void **)&pool2); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(pool2 == pool, "Unexpected pool pointer.\n");
@@ -6434,24 +6450,28 @@ todo_wine hr = cb->lpVtbl->GetDesc(cb, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_cb"), "Unexpected name %s.\n", var_desc.Name); +todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = effect->lpVtbl->GetVariableByName(effect, "s_blendstate"); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_blendstate"), "Unexpected name %s.\n", var_desc.Name);
+todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = effect->lpVtbl->GetVariableByName(effect, "s_texture"); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "s_texture"), "Unexpected name %s.\n", var_desc.Name);
+todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
v = effect->lpVtbl->GetVariableByName(effect, "ps"); hr = v->lpVtbl->GetDesc(v, &var_desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!strcmp(var_desc.Name, "ps"), "Unexpected name %s.\n", var_desc.Name);
+todo_wine ok(var_desc.Flags == D3D10_EFFECT_VARIABLE_POOLED, "Unexpected flags %#x.\n", var_desc.Flags);
t = effect->lpVtbl->GetTechniqueByIndex(effect, 0);
@@ -6466,11 +6486,31 @@ todo_wine
/* Create standalone effect from the same blob used for pool, */ hr = create_effect(fx_test_pool, D3D10_EFFECT_COMPILE_CHILD_EFFECT, device, NULL, &child_effect);
+todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
if (SUCCEEDED(hr)) child_effect->lpVtbl->Release(child_effect);
hr = create_effect(fx_test_pool, 0, device, NULL, &effect2); ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
hr = effect2->lpVtbl->QueryInterface(effect2, &IID_IUnknown, (void **)&unk);
+todo_wine
- ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
- if (SUCCEEDED(hr)) IUnknown_Release(unk);
- hr = effect2->lpVtbl->QueryInterface(effect2, &IID_ID3D10Effect, (void **)&unk);
+todo_wine
- ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
- if (SUCCEEDED(hr)) IUnknown_Release(unk);
- /* For regular effects querying for ID3D10EffectPool is broken */
- hr = effect2->lpVtbl->QueryInterface(effect2, &IID_ID3D10EffectPool, (void **)&unk);
+todo_wine {
- ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- ok(unk == (IUnknown *)effect2, "Unexpected pointer.\n");
+}
- if (SUCCEEDED(hr)) IUnknown_Release(unk);
I guess this one can remain todo_wine. Not that I see any trouble in just making d3d10_effect_QueryInterface() match this behavior. Somewhat relatedly, we should probably implement IsValid(), IsPool(), IsOptimized() sooner rather than later.
I agree about keeping it as todo, I was thinking doing the same for broken QI cases above too, but if you want that in, sure.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 118 ++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 71 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index 10b8565c8d7..a2595aac136 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -1375,6 +1375,33 @@ static HRESULT parse_fx10_annotation(const char *data, size_t data_size, return S_OK; }
+static HRESULT parse_fx10_annotations(const char *data, size_t data_size, const char **ptr, + struct d3d10_effect *effect, unsigned int annotation_count, + struct d3d10_effect_variable **annotations) +{ + unsigned int i; + HRESULT hr; + + if (!(*annotations = heap_calloc(annotation_count, sizeof(**annotations)))) + { + ERR("Failed to allocate annotations memory.\n"); + return E_OUTOFMEMORY; + } + + for (i = 0; i < annotation_count; ++i) + { + struct d3d10_effect_variable *a = &(*annotations)[i]; + + a->effect = effect; + a->buffer = &null_local_buffer; + + if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a))) + return hr; + } + + return hr; +} + static HRESULT parse_fx10_anonymous_shader(struct d3d10_effect *e, struct d3d10_effect_anonymous_shader *s, enum d3d10_effect_object_type otype) { @@ -1904,21 +1931,11 @@ static HRESULT parse_fx10_pass(const char *data, size_t data_size, read_dword(ptr, &p->annotation_count); TRACE("Pass has %u annotations.\n", p->annotation_count);
- if (!(p->annotations = heap_calloc(p->annotation_count, sizeof(*p->annotations)))) - { - ERR("Failed to allocate pass annotations memory.\n"); - return E_OUTOFMEMORY; - } - - for (i = 0; i < p->annotation_count; ++i) + if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, p->technique->effect, + p->annotation_count, &p->annotations))) { - struct d3d10_effect_variable *a = &p->annotations[i]; - - a->effect = p->technique->effect; - a->buffer = &null_local_buffer; - - if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a))) - return hr; + ERR("Failed to parse pass annotations, hr %#x.\n", hr); + return hr; }
if (!(p->objects = heap_calloc(p->object_count, sizeof(*p->objects)))) @@ -1967,21 +1984,11 @@ static HRESULT parse_fx10_technique(const char *data, size_t data_size, read_dword(ptr, &t->annotation_count); TRACE("Technique has %u annotations.\n", t->annotation_count);
- if (!(t->annotations = heap_calloc(t->annotation_count, sizeof(*t->annotations)))) - { - ERR("Failed to allocate technique annotations memory.\n"); - return E_OUTOFMEMORY; - } - - for (i = 0; i < t->annotation_count; ++i) + if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, t->effect, + t->annotation_count, &t->annotations))) { - struct d3d10_effect_variable *a = &t->annotations[i]; - - a->effect = t->effect; - a->buffer = &null_local_buffer; - - if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a))) - return hr; + ERR("Failed to parse technique annotations, hr %#x.\n", hr); + return hr; }
if (!(t->passes = heap_calloc(t->pass_count, sizeof(*t->passes)))) @@ -2008,7 +2015,6 @@ static HRESULT parse_fx10_numeric_variable(const char *data, size_t data_size, const char **ptr, struct d3d10_effect_variable *v) { DWORD offset, default_value_offset; - unsigned int i; HRESULT hr;
if (FAILED(hr = parse_fx10_variable_head(data, data_size, ptr, v))) @@ -2038,21 +2044,11 @@ static HRESULT parse_fx10_numeric_variable(const char *data, size_t data_size, read_dword(ptr, &v->annotation_count); TRACE("Variable has %u annotations.\n", v->annotation_count);
- if (!(v->annotations = heap_calloc(v->annotation_count, sizeof(*v->annotations)))) - { - ERR("Failed to allocate variable annotations memory.\n"); - return E_OUTOFMEMORY; - } - - for (i = 0; i < v->annotation_count; ++i) + if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, v->effect, + v->annotation_count, &v->annotations))) { - struct d3d10_effect_variable *a = &v->annotations[i]; - - a->effect = v->effect; - a->buffer = &null_local_buffer; - - if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a))) - return hr; + ERR("Failed to parse variable annotations, hr %#x.\n", hr); + return hr; }
if (v->flag & D3D10_EFFECT_VARIABLE_EXPLICIT_BIND_POINT) @@ -2254,21 +2250,11 @@ static HRESULT parse_fx10_local_variable(const char *data, size_t data_size, read_dword(ptr, &v->annotation_count); TRACE("Variable has %u annotations.\n", v->annotation_count);
- if (!(v->annotations = heap_calloc(v->annotation_count, sizeof(*v->annotations)))) + if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, v->effect, + v->annotation_count, &v->annotations))) { - ERR("Failed to allocate variable annotations memory.\n"); - return E_OUTOFMEMORY; - } - - for (i = 0; i < v->annotation_count; ++i) - { - struct d3d10_effect_variable *a = &v->annotations[i]; - - a->effect = v->effect; - a->buffer = &null_local_buffer; - - if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a))) - return hr; + ERR("Failed to parse variable annotations, hr %#x.\n", hr); + return hr; }
return S_OK; @@ -2392,21 +2378,11 @@ static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size, read_dword(ptr, &l->annotation_count); TRACE("Local buffer has %u annotations.\n", l->annotation_count);
- if (!(l->annotations = heap_calloc(l->annotation_count, sizeof(*l->annotations)))) + if (FAILED(hr = parse_fx10_annotations(data, data_size, ptr, l->effect, + l->annotation_count, &l->annotations))) { - ERR("Failed to allocate local buffer annotations memory.\n"); - return E_OUTOFMEMORY; - } - - for (i = 0; i < l->annotation_count; ++i) - { - struct d3d10_effect_variable *a = &l->annotations[i]; - - a->effect = l->effect; - a->buffer = &null_local_buffer; - - if (FAILED(hr = parse_fx10_annotation(data, data_size, ptr, a))) - return hr; + ERR("Failed to parse buffer annotations, hr %#x.\n", hr); + return hr; }
if (!(l->members = heap_calloc(l->type->member_count, sizeof(*l->members))))
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/effect.c | 3 +++ dlls/d3d10/tests/effect.c | 6 ------ 2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index a2595aac136..c757b82a529 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -8443,6 +8443,9 @@ HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT fl FIXME("data %p, data_size %lu, flags %#x, device %p, effect_pool %p, effect %p stub!\n", data, data_size, flags, device, effect_pool, effect);
+ if (!(flags & D3D10_EFFECT_COMPILE_CHILD_EFFECT) != !effect_pool) + return E_INVALIDARG; + if (FAILED(hr = d3d10_create_effect(data, data_size, device, &d3d10_effect_vtbl, &object))) { WARN("Failed to create an effect, hr %#x.\n", hr); diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 97331c2135e..2ca78194d6a 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -6486,9 +6486,7 @@ todo_wine
/* Create standalone effect from the same blob used for pool, */ hr = create_effect(fx_test_pool, D3D10_EFFECT_COMPILE_CHILD_EFFECT, device, NULL, &child_effect); -todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); - if (SUCCEEDED(hr)) child_effect->lpVtbl->Release(child_effect);
hr = create_effect(fx_test_pool, 0, device, NULL, &effect2); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); @@ -6564,14 +6562,10 @@ todo_wine
/* When pool is specified, corresponding flag has to be set. */ hr = create_effect(fx_test_pool_child, 0, device, pool, &child_effect); -todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); - if (SUCCEEDED(hr)) child_effect->lpVtbl->Release(child_effect);
hr = create_effect(fx_test_pool_child, D3D10_EFFECT_COMPILE_CHILD_EFFECT, device, NULL, &child_effect); -todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); - if (SUCCEEDED(hr)) child_effect->lpVtbl->Release(child_effect);
refcount = get_refcount(pool); ok(refcount == 1, "Unexpected refcount %u.\n", refcount);
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d3d10/d3d10_private.h | 1 + dlls/d3d10/effect.c | 41 ++++++++++++++++++++++++++++---------- dlls/d3d10/tests/effect.c | 4 ---- 3 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/dlls/d3d10/d3d10_private.h b/dlls/d3d10/d3d10_private.h index a230d0bcbe6..21530b3d30c 100644 --- a/dlls/d3d10/d3d10_private.h +++ b/dlls/d3d10/d3d10_private.h @@ -264,6 +264,7 @@ struct d3d10_effect LONG refcount;
ID3D10Device *device; + ID3D10Effect *pool; DWORD version; DWORD local_buffer_count; DWORD variable_count; diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index c757b82a529..9436d0277f2 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -3104,6 +3104,8 @@ static ULONG STDMETHODCALLTYPE d3d10_effect_Release(ID3D10Effect *iface)
wine_rb_destroy(&This->types, d3d10_effect_type_destroy, NULL);
+ if (This->pool) + This->pool->lpVtbl->Release(This->pool); ID3D10Device_Release(This->device); heap_free(This); } @@ -3144,26 +3146,32 @@ static HRESULT STDMETHODCALLTYPE d3d10_effect_GetDevice(ID3D10Effect *iface, ID3 static HRESULT STDMETHODCALLTYPE d3d10_effect_GetDesc(ID3D10Effect *iface, D3D10_EFFECT_DESC *desc) { struct d3d10_effect *effect = impl_from_ID3D10Effect(iface); + D3D10_EFFECT_DESC pool_desc = { 0 }; unsigned int i; + HRESULT hr;
- FIXME("iface %p, desc %p.\n", iface, desc); + TRACE("iface %p, desc %p.\n", iface, desc);
if (!desc) return E_INVALIDARG;
- /* FIXME */ - desc->IsChildEffect = FALSE; - desc->SharedConstantBuffers = 0; - desc->SharedGlobalVariables = 0; + if (effect->pool && FAILED(hr = effect->pool->lpVtbl->GetDesc(effect->pool, &pool_desc))) + { + WARN("Failed to get pool description, hr %#x.\n", hr); + return hr; + }
+ desc->IsChildEffect = !!effect->pool; desc->ConstantBuffers = effect->local_buffer_count; - desc->Techniques = effect->technique_count; + desc->SharedConstantBuffers = pool_desc.ConstantBuffers; desc->GlobalVariables = effect->local_variable_count; for (i = 0; i < effect->local_buffer_count; ++i) { struct d3d10_effect_variable *l = &effect->local_buffers[i]; desc->GlobalVariables += l->type->member_count; } + desc->SharedGlobalVariables = pool_desc.GlobalVariables; + desc->Techniques = effect->technique_count;
return S_OK; } @@ -8406,7 +8414,7 @@ static int d3d10_effect_type_compare(const void *key, const struct wine_rb_entry }
static HRESULT d3d10_create_effect(void *data, SIZE_T data_size, ID3D10Device *device, - const ID3D10EffectVtbl *vtbl, struct d3d10_effect **effect) + ID3D10Effect *pool, const ID3D10EffectVtbl *vtbl, struct d3d10_effect **effect) { struct d3d10_effect *object; HRESULT hr; @@ -8420,6 +8428,8 @@ static HRESULT d3d10_create_effect(void *data, SIZE_T data_size, ID3D10Device *d object->refcount = 1; ID3D10Device_AddRef(device); object->device = device; + object->pool = pool; + if (pool) pool->lpVtbl->AddRef(pool);
hr = d3d10_effect_parse(object, data, data_size); if (FAILED(hr)) @@ -8438,6 +8448,7 @@ HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT fl ID3D10Device *device, ID3D10EffectPool *effect_pool, ID3D10Effect **effect) { struct d3d10_effect *object; + ID3D10Effect *pool = NULL; HRESULT hr;
FIXME("data %p, data_size %lu, flags %#x, device %p, effect_pool %p, effect %p stub!\n", @@ -8446,7 +8457,17 @@ HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT fl if (!(flags & D3D10_EFFECT_COMPILE_CHILD_EFFECT) != !effect_pool) return E_INVALIDARG;
- if (FAILED(hr = d3d10_create_effect(data, data_size, device, &d3d10_effect_vtbl, &object))) + if (effect_pool) + { + pool = effect_pool->lpVtbl->AsEffect(effect_pool); + if (pool->lpVtbl != &d3d10_effect_pool_effect_vtbl) + { + WARN("External pool implementations are not supported.\n"); + return E_INVALIDARG; + } + } + + if (FAILED(hr = d3d10_create_effect(data, data_size, device, pool, &d3d10_effect_vtbl, &object))) { WARN("Failed to create an effect, hr %#x.\n", hr); } @@ -8499,8 +8520,8 @@ HRESULT WINAPI D3D10CreateEffectPoolFromMemory(void *data, SIZE_T data_size, UIN TRACE("data %p, data_size %lu, fx_flags %#x, device %p, effect_pool %p.\n", data, data_size, fx_flags, device, effect_pool);
- if (FAILED(hr = d3d10_create_effect(data, data_size, device, &d3d10_effect_pool_effect_vtbl, - &object))) + if (FAILED(hr = d3d10_create_effect(data, data_size, device, NULL, + &d3d10_effect_pool_effect_vtbl, &object))) { WARN("Failed to create an effect, hr %#x.\n", hr); return hr; diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c index 2ca78194d6a..3243e7b2713 100644 --- a/dlls/d3d10/tests/effect.c +++ b/dlls/d3d10/tests/effect.c @@ -6574,19 +6574,15 @@ todo_wine ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
refcount = get_refcount(pool); -todo_wine ok(refcount == 2, "Unexpected refcount %u.\n", refcount);
hr = child_effect->lpVtbl->GetDesc(child_effect, &desc); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); -todo_wine ok(desc.IsChildEffect, "Unexpected child flag.\n"); ok(desc.ConstantBuffers == 2, "Unexpected buffer count %u.\n", desc.ConstantBuffers); -todo_wine ok(desc.SharedConstantBuffers == 1, "Unexpected shared buffer count %u.\n", desc.SharedConstantBuffers); ok(desc.GlobalVariables == 2, "Unexpected variables count %u.\n", desc.GlobalVariables); -todo_wine ok(desc.SharedGlobalVariables == 5, "Unexpected shared variables count %u.\n", desc.SharedGlobalVariables);
With the subject changed to "d3d10/effect: Correctly handle GetDesc() for child effects." this is:
Signed-off-by: Matteo Bruni mbruni@codeweavers.com
On Thu, Sep 16, 2021 at 8:48 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3d10/d3d10_private.h | 1 + dlls/d3d10/effect.c | 41 ++++++++++++++++++++++++++++---------- dlls/d3d10/tests/effect.c | 4 ---- 3 files changed, 32 insertions(+), 14 deletions(-)
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index c757b82a529..9436d0277f2 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c
@@ -8446,7 +8457,17 @@ HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT fl if (!(flags & D3D10_EFFECT_COMPILE_CHILD_EFFECT) != !effect_pool) return E_INVALIDARG;
- if (FAILED(hr = d3d10_create_effect(data, data_size, device, &d3d10_effect_vtbl, &object)))
- if (effect_pool)
- {
pool = effect_pool->lpVtbl->AsEffect(effect_pool);
if (pool->lpVtbl != &d3d10_effect_pool_effect_vtbl)
{
WARN("External pool implementations are not supported.\n");
return E_INVALIDARG;
}
- }
Any idea if that's something that native allows?
On 9/19/21 9:04 PM, Matteo Bruni wrote:
On Thu, Sep 16, 2021 at 8:48 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3d10/d3d10_private.h | 1 + dlls/d3d10/effect.c | 41 ++++++++++++++++++++++++++++---------- dlls/d3d10/tests/effect.c | 4 ---- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index c757b82a529..9436d0277f2 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -8446,7 +8457,17 @@ HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT fl if (!(flags & D3D10_EFFECT_COMPILE_CHILD_EFFECT) != !effect_pool) return E_INVALIDARG;
- if (FAILED(hr = d3d10_create_effect(data, data_size, device, &d3d10_effect_vtbl, &object)))
- if (effect_pool)
- {
pool = effect_pool->lpVtbl->AsEffect(effect_pool);
if (pool->lpVtbl != &d3d10_effect_pool_effect_vtbl)
{
WARN("External pool implementations are not supported.\n");
return E_INVALIDARG;
}
- }
Any idea if that's something that native allows?
No idea. I added this only because of the way update_buffer() currently works, maybe some other places are doing impl_from_* too, I haven't checked.
On Thu, Sep 16, 2021 at 8:48 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3d10/d3d10_main.c | 53 ----------------------------------------- dlls/d3d10/effect.c | 53 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 53 deletions(-)
This patch just moves stuff around, which is great. There is the chance for some small followups though.
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index e77d0691fcf..7342c2dbe23 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -8360,3 +8360,56 @@ static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl = d3d10_effect_type_GetMemberName, d3d10_effect_type_GetMemberSemantic, };
+static int d3d10_effect_type_compare(const void *key, const struct wine_rb_entry *entry) +{
- const struct d3d10_effect_type *t = WINE_RB_ENTRY_VALUE(entry, const struct d3d10_effect_type, entry);
- const DWORD *id = key;
- return *id - t->id;
+}
+HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT flags,
ID3D10Device *device, ID3D10EffectPool *effect_pool, ID3D10Effect **effect)
+{
- struct d3d10_effect *object;
- HRESULT hr;
- FIXME("data %p, data_size %lu, flags %#x, device %p, effect_pool %p, effect %p stub!\n",
data, data_size, flags, device, effect_pool, effect);
I guess we could make it a normal TRACE at this point.
- if (!(object = heap_alloc_zero(sizeof(*object))))
- {
ERR("Failed to allocate D3D10 effect object memory\n");
return E_OUTOFMEMORY;
- }
- wine_rb_init(&object->types, d3d10_effect_type_compare);
- object->ID3D10Effect_iface.lpVtbl = &d3d10_effect_vtbl;
- object->refcount = 1;
- ID3D10Device_AddRef(device);
- object->device = device;
- hr = d3d10_effect_parse(object, data, data_size);
- if (FAILED(hr))
- {
ERR("Failed to parse effect\n");
IUnknown_Release(&object->ID3D10Effect_iface);
return hr;
- }
ERR doesn't seem right, but you're fixing these two in patch 2/5 so we're all good :)
- *effect = &object->ID3D10Effect_iface;
- TRACE("Created effect %p\n", object);
- return S_OK;
+}
While at it, we could add the period at the end of those messages.
On 9/19/21 9:01 PM, Matteo Bruni wrote:
On Thu, Sep 16, 2021 at 8:48 AM Nikolay Sivov nsivov@codeweavers.com wrote:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
dlls/d3d10/d3d10_main.c | 53 ----------------------------------------- dlls/d3d10/effect.c | 53 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 53 deletions(-)
This patch just moves stuff around, which is great. There is the chance for some small followups though.
diff --git a/dlls/d3d10/effect.c b/dlls/d3d10/effect.c index e77d0691fcf..7342c2dbe23 100644 --- a/dlls/d3d10/effect.c +++ b/dlls/d3d10/effect.c @@ -8360,3 +8360,56 @@ static const struct ID3D10EffectTypeVtbl d3d10_effect_type_vtbl = d3d10_effect_type_GetMemberName, d3d10_effect_type_GetMemberSemantic, };
+static int d3d10_effect_type_compare(const void *key, const struct wine_rb_entry *entry) +{
- const struct d3d10_effect_type *t = WINE_RB_ENTRY_VALUE(entry, const struct d3d10_effect_type, entry);
- const DWORD *id = key;
- return *id - t->id;
+}
+HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT flags,
ID3D10Device *device, ID3D10EffectPool *effect_pool, ID3D10Effect **effect)
+{
- struct d3d10_effect *object;
- HRESULT hr;
- FIXME("data %p, data_size %lu, flags %#x, device %p, effect_pool %p, effect %p stub!\n",
data, data_size, flags, device, effect_pool, effect);
I guess we could make it a normal TRACE at this point.
We could, I wanted to do that once pool stuff is integrated, more or less.
- if (!(object = heap_alloc_zero(sizeof(*object))))
- {
ERR("Failed to allocate D3D10 effect object memory\n");
return E_OUTOFMEMORY;
- }
- wine_rb_init(&object->types, d3d10_effect_type_compare);
- object->ID3D10Effect_iface.lpVtbl = &d3d10_effect_vtbl;
- object->refcount = 1;
- ID3D10Device_AddRef(device);
- object->device = device;
- hr = d3d10_effect_parse(object, data, data_size);
- if (FAILED(hr))
- {
ERR("Failed to parse effect\n");
IUnknown_Release(&object->ID3D10Effect_iface);
return hr;
- }
ERR doesn't seem right, but you're fixing these two in patch 2/5 so we're all good :)
- *effect = &object->ID3D10Effect_iface;
- TRACE("Created effect %p\n", object);
- return S_OK;
+}
While at it, we could add the period at the end of those messages.