Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/d3dx9_36/effect.c | 81 ++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 35 deletions(-)
diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 6e996e5fae..64106abebb 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -840,6 +840,51 @@ static HRESULT set_string(char **param_data, const char *string) return D3D_OK; }
+static void get_value(struct d3dx_parameter *param, void *data, const void *input_data, unsigned int bytes) +{ + bytes = min(bytes, param->bytes); + if (!input_data) + input_data = param->data; + + switch (param->type) + { + case D3DXPT_VOID: + case D3DXPT_BOOL: + case D3DXPT_INT: + case D3DXPT_FLOAT: + case D3DXPT_STRING: + break; + + case D3DXPT_VERTEXSHADER: + case D3DXPT_PIXELSHADER: + case D3DXPT_TEXTURE: + case D3DXPT_TEXTURE1D: + case D3DXPT_TEXTURE2D: + case D3DXPT_TEXTURE3D: + case D3DXPT_TEXTURECUBE: + { + unsigned int i, count; + + count = min(param->element_count ? param->element_count : 1, bytes / sizeof(void *)); + + for (i = 0; i < count; ++i) + { + IUnknown *unk = ((IUnknown **)input_data)[i]; + if (unk) + IUnknown_AddRef(unk); + } + break; + } + + default: + FIXME("Unhandled type %s.\n", debug_d3dxparameter_type(param->type)); + break; + } + + TRACE("Copy %u bytes.\n", bytes); + memcpy(data, input_data, bytes); +} + static HRESULT set_value(struct d3dx_parameter *param, const void *data, unsigned int bytes) { unsigned int i, count; @@ -2379,41 +2424,7 @@ static HRESULT WINAPI d3dx_effect_GetValue(ID3DXEffect *iface, D3DXHANDLE parame { TRACE("Type %s.\n", debug_d3dxparameter_type(param->type));
- switch (param->type) - { - case D3DXPT_VOID: - case D3DXPT_BOOL: - case D3DXPT_INT: - case D3DXPT_FLOAT: - case D3DXPT_STRING: - break; - - case D3DXPT_VERTEXSHADER: - case D3DXPT_PIXELSHADER: - 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 **)param->data)[i]; - if (unk) - IUnknown_AddRef(unk); - } - break; - } - - default: - FIXME("Unhandled type %s.\n", debug_d3dxparameter_type(param->type)); - break; - } - - TRACE("Copy %u bytes.\n", param->bytes); - memcpy(data, param->data, param->bytes); + get_value(param, data, NULL, bytes); return D3D_OK; }