diff --git a/dlls/d3dx9_36/effect.c b/dlls/d3dx9_36/effect.c index 88c6a16ef5e..ea24d4b55bf 100644 --- a/dlls/d3dx9_36/effect.c +++ b/dlls/d3dx9_36/effect.c @@ -559,6 +559,15 @@ static struct d3dx_parameter *is_valid_parameter(struct ID3DXBaseEffectImpl *bas return NULL; } +static inline struct d3dx_parameter *get_valid_parameter(struct ID3DXBaseEffectImpl *base, D3DXHANDLE parameter) +{ + struct d3dx_parameter *param = is_valid_parameter(base, parameter); + + if (!param) param = get_parameter_by_name(base, NULL, parameter); + + return param; +} + static void free_state(struct d3dx_state *state) { free_parameter_state(state->parameter, FALSE, FALSE, state->type); @@ -1092,12 +1101,10 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_GetDesc(ID3DXBaseEffect *iface, D3DXEF static HRESULT WINAPI ID3DXBaseEffectImpl_GetParameterDesc(ID3DXBaseEffect *iface, D3DXHANDLE parameter, D3DXPARAMETER_DESC *desc) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, desc %p\n", This, parameter, desc); - if (!param) param = get_parameter_struct(iface->lpVtbl->GetParameterByName(iface, NULL, parameter)); - if (!desc || !param) { WARN("Invalid argument specified.\n"); @@ -1174,12 +1181,10 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_GetFunctionDesc(ID3DXBaseEffect *iface static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, index %u\n", This, parameter, index); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (!parameter) { if (index < This->parameter_count) @@ -1205,13 +1210,11 @@ static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameter(ID3DXBaseEffect *iface static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR name) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); D3DXHANDLE handle; TRACE("iface %p, parameter %p, name %s\n", This, parameter, debugstr_a(name)); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (!name) { handle = get_parameter_handle(param); @@ -1228,14 +1231,12 @@ static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterByName(ID3DXBaseEffect static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR semantic) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); struct d3dx_parameter *temp_param; UINT i; TRACE("iface %p, parameter %p, semantic %s\n", This, parameter, debugstr_a(semantic)); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (!parameter) { for (i = 0; i < This->parameter_count; ++i) @@ -1291,12 +1292,10 @@ static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterBySemantic(ID3DXBaseEff static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetParameterElement(ID3DXBaseEffect *iface, D3DXHANDLE parameter, UINT index) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, index %u\n", This, parameter, index); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (!param) { if (index < This->parameter_count) @@ -1436,7 +1435,7 @@ static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetFunctionByName(ID3DXBaseEffect * static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *iface, D3DXHANDLE object, UINT index) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, object); + struct d3dx_parameter *param = get_valid_parameter(This, object); struct d3dx_pass *pass = is_valid_pass(This, object); struct d3dx_technique *technique = is_valid_technique(This, object); UINT annotation_count = 0; @@ -1454,15 +1453,10 @@ static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *ifac annotation_count = technique->annotation_count; annotation_handles = technique->annotation_handles; } - else + else if (param) { - if (!param) param = get_parameter_by_name(This, NULL, object); - - if (param) - { - annotation_count = param->annotation_count; - annotation_handles = param->annotation_handles; - } + annotation_count = param->annotation_count; + annotation_handles = param->annotation_handles; } /* Todo: add funcs */ @@ -1480,7 +1474,7 @@ static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotation(ID3DXBaseEffect *ifac static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect *iface, D3DXHANDLE object, LPCSTR name) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, object); + struct d3dx_parameter *param = get_valid_parameter(This, object); struct d3dx_pass *pass = is_valid_pass(This, object); struct d3dx_technique *technique = is_valid_technique(This, object); UINT annotation_count = 0, i; @@ -1504,15 +1498,10 @@ static D3DXHANDLE WINAPI ID3DXBaseEffectImpl_GetAnnotationByName(ID3DXBaseEffect annotation_count = technique->annotation_count; annotation_handles = technique->annotation_handles; } - else + else if (param) { - if (!param) param = get_parameter_by_name(This, NULL, object); - - if (param) - { - annotation_count = param->annotation_count; - annotation_handles = param->annotation_handles; - } + annotation_count = param->annotation_count; + annotation_handles = param->annotation_handles; } /* Todo: add funcs */ @@ -1544,11 +1533,10 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_SetValue(ID3DXBaseEffect *iface, D3DXH static HRESULT WINAPI ID3DXBaseEffectImpl_GetValue(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPVOID data, UINT bytes) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, data %p, bytes %u\n", This, parameter, data, bytes); - if (!param) param = get_parameter_by_name(This, NULL, parameter); if (!param) { WARN("Invalid parameter %p specified\n", parameter); @@ -1622,12 +1610,10 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_SetBool(ID3DXBaseEffect *iface, D3DXHA static HRESULT WINAPI ID3DXBaseEffectImpl_GetBool(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, b %p\n", This, parameter, b); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (b && param && !param->element_count && param->class == D3DXPC_SCALAR) { *b = get_bool(param->data); @@ -1652,12 +1638,10 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_SetBoolArray(ID3DXBaseEffect *iface, D static HRESULT WINAPI ID3DXBaseEffectImpl_GetBoolArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, BOOL *b, UINT count) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, b %p, count %u\n", This, parameter, b, count); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (b && param && (param->class == D3DXPC_SCALAR || param->class == D3DXPC_VECTOR || param->class == D3DXPC_MATRIX_ROWS @@ -1689,12 +1673,10 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_SetInt(ID3DXBaseEffect *iface, D3DXHAN static HRESULT WINAPI ID3DXBaseEffectImpl_GetInt(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, n %p\n", This, parameter, n); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (n && param && !param->element_count && param->class == D3DXPC_SCALAR) { *n = get_int(param->type, param->data); @@ -1719,12 +1701,10 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_SetIntArray(ID3DXBaseEffect *iface, D3 static HRESULT WINAPI ID3DXBaseEffectImpl_GetIntArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, INT *n, UINT count) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, n %p, count %u\n", This, parameter, n, count); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (n && param && (param->class == D3DXPC_SCALAR || param->class == D3DXPC_VECTOR || param->class == D3DXPC_MATRIX_ROWS @@ -1756,12 +1736,10 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloat(ID3DXBaseEffect *iface, D3DXH static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloat(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, f %p\n", This, parameter, f); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (f && param && !param->element_count && param->class == D3DXPC_SCALAR) { f = param->data; @@ -1786,12 +1764,10 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_SetFloatArray(ID3DXBaseEffect *iface, static HRESULT WINAPI ID3DXBaseEffectImpl_GetFloatArray(ID3DXBaseEffect *iface, D3DXHANDLE parameter, FLOAT *f, UINT count) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, f %p, count %u\n", This, parameter, f, count); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (f && param && (param->class == D3DXPC_SCALAR || param->class == D3DXPC_VECTOR || param->class == D3DXPC_MATRIX_ROWS @@ -1967,12 +1943,10 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_SetString(ID3DXBaseEffect *iface, D3DX static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPCSTR *string) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, string %p\n", This, parameter, string); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (string && param && !param->element_count && param->type == D3DXPT_STRING) { *string = *(LPCSTR *)param->data; @@ -1988,12 +1962,10 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_GetString(ID3DXBaseEffect *iface, D3DX static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 texture) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (texture && param && !param->element_count && (param->type == D3DXPT_TEXTURE || param->type == D3DXPT_TEXTURE1D || param->type == D3DXPT_TEXTURE2D || param->type == D3DXPT_TEXTURE3D @@ -2017,7 +1989,7 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_SetTexture(ID3DXBaseEffect *iface, D3D static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DBASETEXTURE9 *texture) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, texture %p\n", This, parameter, texture); @@ -2040,12 +2012,10 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_GetTexture(ID3DXBaseEffect *iface, D3D static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DPIXELSHADER9 *pshader) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, pshader %p\n", This, parameter, pshader); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (pshader && param && !param->element_count && param->type == D3DXPT_PIXELSHADER) { *pshader = *(LPDIRECT3DPIXELSHADER9 *)param->data; @@ -2062,12 +2032,10 @@ static HRESULT WINAPI ID3DXBaseEffectImpl_GetPixelShader(ID3DXBaseEffect *iface, static HRESULT WINAPI ID3DXBaseEffectImpl_GetVertexShader(ID3DXBaseEffect *iface, D3DXHANDLE parameter, LPDIRECT3DVERTEXSHADER9 *vshader) { struct ID3DXBaseEffectImpl *This = impl_from_ID3DXBaseEffect(iface); - struct d3dx_parameter *param = is_valid_parameter(This, parameter); + struct d3dx_parameter *param = get_valid_parameter(This, parameter); TRACE("iface %p, parameter %p, vshader %p\n", This, parameter, vshader); - if (!param) param = get_parameter_by_name(This, NULL, parameter); - if (vshader && param && !param->element_count && param->type == D3DXPT_VERTEXSHADER) { *vshader = *(LPDIRECT3DVERTEXSHADER9 *)param->data;