Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/d3dx9_36/effect.c | 26 +++++++++++++++++++++++--- dlls/d3dx9_36/tests/effect.c | 10 +++++----- 2 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 19c9e552c7..d26e451958 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -24,6 +24,7 @@ #include "d3dx9_private.h" #include "d3dcompiler.h" #include "winternl.h" +#include "wine/list.h"
/* Constants for special INT/FLOAT conversation */ #define INT_FLOAT_MULTI 255.0f @@ -151,6 +152,7 @@ struct d3dx_technique struct d3dx_parameter_block { char magic_string[ARRAY_SIZE(parameter_block_magic_string)]; + struct list entry; };
struct d3dx_effect @@ -184,6 +186,7 @@ struct d3dx_effect D3DMATERIAL9 current_material; BOOL material_updated;
+ struct list parameter_block_list; struct d3dx_parameter_block *current_parameter_block; };
@@ -688,12 +691,18 @@ static void free_parameter_block(struct d3dx_parameter_block *block)
static void d3dx_effect_cleanup(struct d3dx_effect *effect) { + struct d3dx_parameter_block *block, *cursor; ID3DXEffectPool *pool; unsigned int i;
TRACE("effect %p.\n", effect);
free_parameter_block(effect->current_parameter_block); + LIST_FOR_EACH_ENTRY_SAFE(block, cursor, &effect->parameter_block_list, struct d3dx_parameter_block, entry) + { + list_remove(&block->entry); + free_parameter_block(block); + }
heap_free(effect->full_name_tmp);
@@ -4084,11 +4093,20 @@ static HRESULT WINAPI d3dx_effect_BeginParameterBlock(ID3DXEffect *iface)
static D3DXHANDLE WINAPI d3dx_effect_EndParameterBlock(ID3DXEffect *iface) { - struct d3dx_effect *This = impl_from_ID3DXEffect(iface); + struct d3dx_effect *effect = impl_from_ID3DXEffect(iface); + struct d3dx_parameter_block *ret;
- FIXME("(%p)->(): stub\n", This); + TRACE("iface %p.\n", iface);
- return NULL; + if (!effect->current_parameter_block) + { + WARN("No active parameter block.\n"); + return NULL; + } + ret = effect->current_parameter_block; + effect->current_parameter_block = NULL; + list_add_tail(&effect->parameter_block_list, &ret->entry); + return (D3DXHANDLE)ret; }
static HRESULT WINAPI d3dx_effect_ApplyParameterBlock(ID3DXEffect *iface, D3DXHANDLE parameter_block) @@ -6234,6 +6252,8 @@ static HRESULT d3dx9_effect_init(struct d3dx_effect *effect, struct IDirect3DDev
effect->flags = eflags;
+ list_init(&effect->parameter_block_list); + read_dword(&ptr, &tag); TRACE("Tag: %x\n", tag);
diff --git a/dlls/d3dx9_36/tests/effect.c b/dlls/d3dx9_36/tests/effect.c index f175d84d60..23b4d04487 100644 --- a/dlls/d3dx9_36/tests/effect.c +++ b/dlls/d3dx9_36/tests/effect.c @@ -8063,7 +8063,7 @@ static void test_effect_parameter_block(void) hr = effect->lpVtbl->BeginParameterBlock(effect); ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); block = effect->lpVtbl->EndParameterBlock(effect); - todo_wine ok(!!block, "Got unexpected block %p.\n", block); + ok(!!block, "Got unexpected block %p.\n", block); handle = effect->lpVtbl->EndParameterBlock(effect); ok(!handle, "Got unexpected handle %p.\n", handle);
@@ -8078,13 +8078,13 @@ static void test_effect_parameter_block(void) todo_wine ok(hr == D3D_OK, "Got result %#x.\n", hr);
hr = effect->lpVtbl->BeginParameterBlock(effect); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = effect->lpVtbl->SetFloat(effect, "vec3[0]", 1001.0f); ok(hr == D3DERR_INVALIDCALL, "Got unexpected hr %#x.\n", hr); hr = effect->lpVtbl->SetFloat(effect, "arr1[0]", 91.0f); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); block = effect->lpVtbl->EndParameterBlock(effect); - todo_wine ok(!!block, "Got unexpected block %p.\n", block); + ok(!!block, "Got unexpected block %p.\n", block); hr = effect->lpVtbl->ApplyParameterBlock(effect, block); todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
@@ -8100,7 +8100,7 @@ static void test_effect_parameter_block(void) ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr);
hr = effect->lpVtbl->BeginParameterBlock(effect); - todo_wine ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = effect->lpVtbl->SetTexture(effect, "tex1", (IDirect3DBaseTexture9 *)texture); ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); @@ -8137,7 +8137,7 @@ static void test_effect_parameter_block(void) ok(refcount == 2, "Got unexpected refcount %u.\n", refcount);
block = effect->lpVtbl->EndParameterBlock(effect); - todo_wine ok(!!block, "Got unexpected block %p.\n", block); + ok(!!block, "Got unexpected block %p.\n", block);
IDirect3DTexture9_AddRef(texture); refcount = IDirect3DTexture9_Release(texture);