Commit d1ac3b8e authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

d3dx9: Support setting strings in effect.

parent 97dcf42f
......@@ -1497,10 +1497,24 @@ static void clear_dirty_params(struct d3dx9_base_effect *base)
base->parameters[i].runtime_flags &= ~PARAMETER_FLAG_DIRTY;
}
static HRESULT set_string(char **param_data, const char *string)
{
HeapFree(GetProcessHeap(), 0, *param_data);
*param_data = HeapAlloc(GetProcessHeap(), 0, strlen(string) + 1);
if (!*param_data)
{
ERR("Out of memory.\n");
return E_OUTOFMEMORY;
}
strcpy(*param_data, string);
return D3D_OK;
}
static HRESULT d3dx9_base_effect_set_value(struct d3dx9_base_effect *base,
D3DXHANDLE parameter, const void *data, UINT bytes)
{
struct d3dx_parameter *param = get_valid_parameter(base, parameter);
unsigned int i;
if (!param)
{
......@@ -1524,9 +1538,6 @@ static HRESULT d3dx9_base_effect_set_value(struct d3dx9_base_effect *base,
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];
......@@ -1537,19 +1548,31 @@ static HRESULT d3dx9_base_effect_set_value(struct d3dx9_base_effect *base,
if (unk)
IUnknown_Release(unk);
}
}
/* fallthrough */
case D3DXPT_VOID:
case D3DXPT_BOOL:
case D3DXPT_INT:
case D3DXPT_FLOAT:
TRACE("Copy %u bytes\n", param->bytes);
TRACE("Copy %u bytes.\n", param->bytes);
memcpy(param->data, data, param->bytes);
set_dirty(param);
break;
case D3DXPT_STRING:
{
HRESULT hr;
set_dirty(param);
for (i = 0; i < (param->element_count ? param->element_count : 1); ++i)
{
if (FAILED(hr = set_string(&((char **)param->data)[i], ((const char **)data)[i])))
return hr;
}
break;
}
default:
FIXME("Unhandled type %s\n", debug_d3dxparameter_type(param->type));
FIXME("Unhandled type %s.\n", debug_d3dxparameter_type(param->type));
break;
}
......@@ -2578,9 +2601,17 @@ static HRESULT d3dx9_base_effect_get_matrix_transpose_pointer_array(struct d3dx9
static HRESULT d3dx9_base_effect_set_string(struct d3dx9_base_effect *base,
D3DXHANDLE parameter, const char *string)
{
FIXME("stub!\n");
struct d3dx_parameter *param = get_valid_parameter(base, parameter);
return E_NOTIMPL;
if (param && param->type == D3DXPT_STRING)
{
set_dirty(param);
return set_string(param->data, string);
}
WARN("Parameter not found.\n");
return D3DERR_INVALIDCALL;
}
static HRESULT d3dx9_base_effect_get_string(struct d3dx9_base_effect *base,
......
......@@ -2441,7 +2441,6 @@ static void test_effect_setvalue_object(IDirect3DDevice9 *device)
ok(!count, "Got reference count %u, expected 0.\n", count);
hr = effect->lpVtbl->SetString(effect, "s", expected_string);
todo_wine
ok(hr == D3D_OK, "Got result %#x.\n", hr);
string = NULL;
hr = effect->lpVtbl->GetString(effect, "s", &string);
......@@ -2451,7 +2450,6 @@ static void test_effect_setvalue_object(IDirect3DDevice9 *device)
ok(string != expected_string, "String pointers are the same.\n");
ok(string == string2, "String pointers differ.\n");
todo_wine
ok(!strcmp(string, expected_string), "Unexpected string '%s'.\n", string);
string = expected_string2;
......@@ -2466,7 +2464,6 @@ static void test_effect_setvalue_object(IDirect3DDevice9 *device)
ok(hr == D3D_OK, "Got result %#x.\n", hr);
ok(string != expected_string2, "String pointers are the same.\n");
todo_wine
ok(!strcmp(string, expected_string2), "Unexpected string '%s'.\n", string);
hr = effect->lpVtbl->SetValue(effect, "s_2", expected_string_array,
......@@ -2477,7 +2474,6 @@ static void test_effect_setvalue_object(IDirect3DDevice9 *device)
ok(hr == D3D_OK, "Got result %#x.\n", hr);
for (i = 0; i < ARRAY_SIZE(expected_string_array); ++i)
{
todo_wine
ok(!strcmp(string_array[i], expected_string_array[i]), "Unexpected string '%s', i %u.\n",
string_array[i], i);
}
......
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