Commit 1da5af93 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

d3dx9: Support setting texture through SetValue in effect.

parent 8d1131b8
...@@ -1366,6 +1366,26 @@ static HRESULT d3dx9_base_effect_set_value(struct d3dx9_base_effect *base, ...@@ -1366,6 +1366,26 @@ static HRESULT d3dx9_base_effect_set_value(struct d3dx9_base_effect *base,
{ {
switch (param->type) switch (param->type)
{ {
case D3DXPT_TEXTURE:
case D3DXPT_TEXTURE1D:
case D3DXPT_TEXTURE2D:
case D3DXPT_TEXTURE3D:
case D3DXPT_TEXTURECUBE:
{
unsigned int i;
for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
{
IUnknown *unk = ((IUnknown **)data)[i];
if (unk)
IUnknown_AddRef(unk);
unk = ((IUnknown **)param->data)[i];
if (unk)
IUnknown_Release(unk);
}
}
/* fallthrough */
case D3DXPT_VOID: case D3DXPT_VOID:
case D3DXPT_BOOL: case D3DXPT_BOOL:
case D3DXPT_INT: case D3DXPT_INT:
......
...@@ -2389,6 +2389,43 @@ static void test_effect_parameter_value(IDirect3DDevice9 *device) ...@@ -2389,6 +2389,43 @@ static void test_effect_parameter_value(IDirect3DDevice9 *device)
} }
} }
static void test_effect_setvalue_object(IDirect3DDevice9 *device)
{
ID3DXEffect *effect;
D3DXHANDLE parameter;
IDirect3DTexture9 *texture;
IDirect3DTexture9 *texture_set;
HRESULT hr;
ULONG count;
hr = D3DXCreateEffect(device, test_effect_parameter_value_blob_object,
sizeof(test_effect_parameter_value_blob_object), NULL, NULL, 0, NULL, &effect, NULL);
ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr);
parameter = effect->lpVtbl->GetParameterByName(effect, NULL, "tex");
ok(parameter != NULL, "GetParameterByName failed, got %p\n", parameter);
texture = NULL;
hr = D3DXCreateTexture(device, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, 0, D3DPOOL_DEFAULT, &texture);
ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr);
hr = effect->lpVtbl->SetValue(effect, parameter, &texture, sizeof(texture));
ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr);
texture_set = NULL;
hr = effect->lpVtbl->GetValue(effect, parameter, &texture_set, sizeof(texture_set));
ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr);
ok(texture == texture_set, "Texture does not match.\n");
count = IDirect3DTexture9_Release(texture_set);
ok(count == 2, "Got reference count %u, expected 2.\n", count);
texture_set = NULL;
hr = effect->lpVtbl->SetValue(effect, parameter, &texture_set, sizeof(texture_set));
ok(hr == D3D_OK, "Got result %#x, expected 0 (D3D_OK).\n", hr);
count = IDirect3DTexture9_Release(texture);
ok(!count, "Got reference count %u, expected 0.\n", count);
effect->lpVtbl->Release(effect);
}
/* /*
* fxc.exe /Tfx_2_0 * fxc.exe /Tfx_2_0
*/ */
...@@ -3008,6 +3045,7 @@ START_TEST(effect) ...@@ -3008,6 +3045,7 @@ START_TEST(effect)
test_create_effect_and_pool(device); test_create_effect_and_pool(device);
test_create_effect_compiler(); test_create_effect_compiler();
test_effect_parameter_value(device); test_effect_parameter_value(device);
test_effect_setvalue_object(device);
test_effect_variable_names(device); test_effect_variable_names(device);
test_effect_compilation_errors(device); test_effect_compilation_errors(device);
test_effect_states(device); test_effect_states(device);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment