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>
This commit is contained in:
Michael Stefaniuc 2019-03-15 19:07:06 +01:00 committed by Alexandre Julliard
parent fa26231748
commit d4e39ee1d8
1 changed files with 57 additions and 65 deletions

View File

@ -1254,70 +1254,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)
{
@ -2615,10 +2551,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)