Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- Michael, let me know if these two patches conflict badly with your pending stuff, I'm happy to defer to a later point if needed.
dlls/d3dx9_36/effect.c | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 0c28fae1ec5..d89c5d72b0a 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -677,11 +677,11 @@ static void free_technique(struct d3dx_technique *technique) technique->name = NULL; }
-static void d3dx9_base_effect_cleanup(struct d3dx_effect *effect) +static void d3dx_effect_cleanup(struct d3dx_effect *effect) { unsigned int i;
- TRACE("Effect %p.\n", effect); + TRACE("effect %p.\n", effect);
heap_free(effect->full_name_tmp);
@@ -690,7 +690,6 @@ static void d3dx9_base_effect_cleanup(struct d3dx_effect *effect) for (i = 0; i < effect->parameter_count; ++i) free_top_level_parameter(&effect->parameters[i]); heap_free(effect->parameters); - effect->parameters = NULL; }
if (effect->techniques) @@ -698,37 +697,23 @@ static void d3dx9_base_effect_cleanup(struct d3dx_effect *effect) for (i = 0; i < effect->technique_count; ++i) free_technique(&effect->techniques[i]); heap_free(effect->techniques); - effect->techniques = NULL; }
if (effect->objects) { for (i = 0; i < effect->object_count; ++i) - { free_object(&effect->objects[i]); - } heap_free(effect->objects); - effect->objects = NULL; } -} - -static void free_effect(struct d3dx_effect *effect) -{ - TRACE("Free effect %p\n", effect); - - d3dx9_base_effect_cleanup(effect);
if (effect->pool) - { effect->pool->lpVtbl->Release(effect->pool); - }
if (effect->manager) - { IUnknown_Release(effect->manager); - }
IDirect3DDevice9_Release(effect->device); + heap_free(effect); }
static void get_vector(struct d3dx_parameter *param, D3DXVECTOR4 *vector) @@ -1822,18 +1807,15 @@ static ULONG WINAPI d3dx_effect_AddRef(ID3DXEffect *iface)
static ULONG WINAPI d3dx_effect_Release(ID3DXEffect *iface) { - struct d3dx_effect *This = impl_from_ID3DXEffect(iface); - ULONG ref = InterlockedDecrement(&This->ref); + struct d3dx_effect *effect = impl_from_ID3DXEffect(iface); + ULONG refcount = InterlockedDecrement(&effect->ref);
- TRACE("(%p)->(): Release from %u\n", This, ref + 1); + TRACE("%p decreasing refcount to %u.\n", effect, refcount);
- if (!ref) - { - free_effect(This); - HeapFree(GetProcessHeap(), 0, This); - } + if (!refcount) + d3dx_effect_cleanup(effect);
- return ref; + return refcount; }
/*** ID3DXBaseEffect methods ***/ @@ -6330,7 +6312,6 @@ static HRESULT d3dx9_effect_init(struct d3dx_effect *effect, struct IDirect3DDev error_messages, pool_impl, skip_constants))) { FIXME("Failed to parse effect, hr %#x.\n", hr); - free_effect(effect); return hr; }
@@ -6378,7 +6359,7 @@ HRESULT WINAPI D3DXCreateEffectEx(struct IDirect3DDevice9 *device, const void *s if (FAILED(hr)) { WARN("Failed to create effect object.\n"); - HeapFree(GetProcessHeap(), 0, object); + d3dx_effect_cleanup(object); return hr; }
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3dx9_36/effect.c | 76 ++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 47 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index d89c5d72b0a..7635caa8786 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -6142,32 +6142,46 @@ static const char **parse_skip_constants_string(char *skip_constants_string, uns return new_alloc; }
-static HRESULT d3dx9_base_effect_init(struct d3dx_effect *effect, const char *data, SIZE_T data_size, - const D3D_SHADER_MACRO *defines, ID3DInclude *include, unsigned int eflags, ID3DBlob **errors, - struct d3dx_effect_pool *pool, const char *skip_constants_string) +static HRESULT d3dx9_effect_init(struct d3dx_effect *effect, struct IDirect3DDevice9 *device, + const char *data, SIZE_T data_size, const D3D_SHADER_MACRO *defines, ID3DInclude *include, + UINT eflags, ID3DBlob **errors, struct ID3DXEffectPool *pool, const char *skip_constants_string) { - struct d3dx9_base_effect *base = &effect->base_effect; - DWORD tag, offset; - const char *ptr = data; - HRESULT hr; - ID3DBlob *bytecode = NULL, *temp_errors = NULL; - char *skip_constants_buffer = NULL; - const char **skip_constants = NULL; - unsigned int skip_constants_count = 0; #if D3DX_SDK_VERSION <= 36 UINT compile_flags = D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY; #else UINT compile_flags = 0; #endif + struct d3dx9_base_effect *base = &effect->base_effect; + ID3DBlob *bytecode = NULL, *temp_errors = NULL; + struct d3dx_effect_pool *pool_impl = NULL; + unsigned int skip_constants_count = 0; + char *skip_constants_buffer = NULL; + const char **skip_constants = NULL; + const char *ptr = data; + DWORD tag, offset; unsigned int i, j; + HRESULT hr;
- TRACE("effect %p, data %p, data_size %lu, defines %p, include %p, eflags %#x, errors %p, " + TRACE("effect %p, device %p, data %p, data_size %lu, defines %p, include %p, eflags %#x, errors %p, " "pool %p, skip_constants %s.\n", - effect, data, data_size, defines, include, eflags, errors, pool, + effect, device, data, data_size, defines, include, eflags, errors, pool, debugstr_a(skip_constants_string));
+ effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl; + effect->ref = 1; + + if (pool) + { + pool->lpVtbl->AddRef(pool); + pool_impl = impl_from_ID3DXEffectPool(pool); + } + effect->pool = pool; + + IDirect3DDevice9_AddRef(device); + effect->device = device; + base->effect = effect; - base->pool = pool; + base->pool = pool_impl; base->flags = eflags;
read_dword(&ptr, &tag); @@ -6283,38 +6297,6 @@ static HRESULT d3dx9_base_effect_init(struct d3dx_effect *effect, const char *da HeapFree(GetProcessHeap(), 0, skip_constants_buffer); HeapFree(GetProcessHeap(), 0, skip_constants);
- return D3D_OK; -} - -static HRESULT d3dx9_effect_init(struct d3dx_effect *effect, struct IDirect3DDevice9 *device, - const char *data, SIZE_T data_size, const D3D_SHADER_MACRO *defines, ID3DInclude *include, - UINT eflags, ID3DBlob **error_messages, struct ID3DXEffectPool *pool, const char *skip_constants) -{ - HRESULT hr; - struct d3dx_effect_pool *pool_impl = NULL; - - TRACE("effect %p, device %p, data %p, data_size %lu, pool %p\n", effect, device, data, data_size, pool); - - effect->ID3DXEffect_iface.lpVtbl = &ID3DXEffect_Vtbl; - effect->ref = 1; - - if (pool) - { - pool->lpVtbl->AddRef(pool); - pool_impl = impl_from_ID3DXEffectPool(pool); - } - effect->pool = pool; - - IDirect3DDevice9_AddRef(device); - effect->device = device; - - if (FAILED(hr = d3dx9_base_effect_init(effect, data, data_size, defines, include, eflags, - error_messages, pool_impl, skip_constants))) - { - FIXME("Failed to parse effect, hr %#x.\n", hr); - return hr; - } - /* initialize defaults - check because of unsupported ascii effects */ if (effect->techniques) { @@ -6358,7 +6340,7 @@ HRESULT WINAPI D3DXCreateEffectEx(struct IDirect3DDevice9 *device, const void *s (ID3DInclude *)include, flags, (ID3DBlob **)compilation_errors, pool, skip_constants); if (FAILED(hr)) { - WARN("Failed to create effect object.\n"); + WARN("Failed to create effect object, hr %#x.\n", hr); d3dx_effect_cleanup(object); return hr; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=49705
Your paranoid android.
=== debian9 (build log) ===
error: patch failed: dlls/d3dx9_36/effect.c:677 error: patch failed: dlls/d3dx9_36/effect.c:6142 Task: Patch failed to apply
=== debian9b (build log) ===
error: patch failed: dlls/d3dx9_36/effect.c:677 error: patch failed: dlls/d3dx9_36/effect.c:6142 Task: Patch failed to apply
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=49704
Your paranoid android.
=== debian9 (build log) ===
error: patch failed: dlls/d3dx9_36/effect.c:677 Task: Patch failed to apply
=== debian9b (build log) ===
error: patch failed: dlls/d3dx9_36/effect.c:677 Task: Patch failed to apply