[WINESYNC] d3dx9: Merge the d3dx_effect_GetValue() helper.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id d4e39ee1d8a263d91bc291cacfe8938f81d447fc by Michael Stefaniuc <mstefani@winehq.org>
This commit is contained in:
winesync 2020-09-21 22:40:28 +02:00 committed by Jérôme Gardou
parent e8b87e3799
commit fce46567f7
2 changed files with 58 additions and 66 deletions

View File

@ -1258,70 +1258,6 @@ static HRESULT d3dx9_base_effect_set_value(struct d3dx9_base_effect *base,
return D3DERR_INVALIDCALL;
}
static HRESULT d3dx9_base_effect_get_value(struct d3dx9_base_effect *base,
D3DXHANDLE parameter, void *data, UINT bytes)
{
struct d3dx_parameter *param = get_valid_parameter(base, parameter);
if (!param)
{
WARN("Invalid parameter %p specified\n", parameter);
return D3DERR_INVALIDCALL;
}
/* samplers don't touch data */
if (param->class == D3DXPC_OBJECT && is_param_type_sampler(param->type))
{
TRACE("Sampler: returning E_FAIL\n");
return E_FAIL;
}
if (data && param->bytes <= bytes)
{
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:
{
UINT 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);
return D3D_OK;
}
WARN("Parameter not found.\n");
return D3DERR_INVALIDCALL;
}
static HRESULT d3dx9_base_effect_set_vector(struct d3dx9_base_effect *base,
D3DXHANDLE parameter, const D3DXVECTOR4 *vector)
{
@ -2619,10 +2555,66 @@ static HRESULT WINAPI d3dx_effect_SetValue(ID3DXEffect *iface, D3DXHANDLE parame
static HRESULT WINAPI d3dx_effect_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, void *data, UINT bytes)
{
struct d3dx_effect *effect = impl_from_ID3DXEffect(iface);
struct d3dx_parameter *param = get_valid_parameter(&effect->base_effect, parameter);
TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface, parameter, data, bytes);
return d3dx9_base_effect_get_value(&effect->base_effect, parameter, data, bytes);
if (!param)
{
WARN("Invalid parameter %p specified.\n", parameter);
return D3DERR_INVALIDCALL;
}
if (param->class == D3DXPC_OBJECT && is_param_type_sampler(param->type))
{
WARN("Parameter is a sampler, returning E_FAIL.\n");
return E_FAIL;
}
if (data && param->bytes <= bytes)
{
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);
return D3D_OK;
}
WARN("Parameter not found.\n");
return D3DERR_INVALIDCALL;
}
static HRESULT WINAPI d3dx_effect_SetBool(ID3DXEffect *iface, D3DXHANDLE parameter, BOOL b)

View File

@ -15,4 +15,4 @@ files: {include/d3dx9.h: sdk/include/dxsdk/d3dx9.h, include/d3dx9anim.h: sdk/inc
include/d3dx9mesh.h: sdk/include/dxsdk/d3dx9mesh.h, include/d3dx9of.h: sdk/include/dxsdk/d3dx9of.h,
include/d3dx9shader.h: sdk/include/dxsdk/d3dx9shader.h, include/d3dx9shape.h: sdk/include/dxsdk/d3dx9shape.h,
include/d3dx9tex.h: sdk/include/dxsdk/d3dx9tex.h, include/d3dx9xof.h: sdk/include/dxsdk/d3dx9xof.h}
tags: {wine: 918c13f48cab2fe9391148ae4281015c0e169378}
tags: {wine: d4e39ee1d8a263d91bc291cacfe8938f81d447fc}