https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a64947697d62c2fd43ada…
commit a64947697d62c2fd43ada1f2aa55d01dab9446ad
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Mon Sep 21 22:40:28 2020 +0200
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Thu Feb 4 16:37:02 2021 +0100
[WINESYNC] d3dx9: Merge the d3dx_effect_SetValue() helper.
Signed-off-by: Michael Stefaniuc <mstefani(a)winehq.org>
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id bd731f6dd12d1e61daf3d6abefb3e01be35f5104 by Michael Stefaniuc
<mstefani(a)winehq.org>
---
dll/directx/wine/d3dx9_36/effect.c | 145 +++++++++++++++++--------------------
sdk/tools/winesync/d3dx9.cfg | 2 +-
2 files changed, 68 insertions(+), 79 deletions(-)
diff --git a/dll/directx/wine/d3dx9_36/effect.c b/dll/directx/wine/d3dx9_36/effect.c
index 2bae2567624..0ed8a066bef 100644
--- a/dll/directx/wine/d3dx9_36/effect.c
+++ b/dll/directx/wine/d3dx9_36/effect.c
@@ -1181,83 +1181,6 @@ static HRESULT set_string(char **param_data, const char *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)
- {
- 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)
- {
- switch (param->type)
- {
- case D3DXPT_TEXTURE:
- case D3DXPT_TEXTURE1D:
- case D3DXPT_TEXTURE2D:
- case D3DXPT_TEXTURE3D:
- case D3DXPT_TEXTURECUBE:
- for (i = 0; i < (param->element_count ? param->element_count :
1); ++i)
- {
- IUnknown *old_texture = ((IUnknown **)param->data)[i];
- IUnknown *new_texture = ((IUnknown **)data)[i];
-
- if (new_texture == old_texture)
- continue;
-
- if (new_texture)
- IUnknown_AddRef(new_texture);
- if (old_texture)
- IUnknown_Release(old_texture);
- }
- /* fallthrough */
- case D3DXPT_VOID:
- case D3DXPT_BOOL:
- case D3DXPT_INT:
- case D3DXPT_FLOAT:
- 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));
- break;
- }
-
- return D3D_OK;
- }
-
- WARN("Invalid argument specified\n");
-
- return D3DERR_INVALIDCALL;
-}
-
static HRESULT d3dx9_base_effect_set_vector(struct d3dx9_base_effect *base,
D3DXHANDLE parameter, const D3DXVECTOR4 *vector)
{
@@ -2546,10 +2469,76 @@ static HRESULT WINAPI d3dx_effect_SetValue(ID3DXEffect *iface,
D3DXHANDLE parame
const void *data, UINT bytes)
{
struct d3dx_effect *effect = impl_from_ID3DXEffect(iface);
+ struct d3dx_parameter *param = get_valid_parameter(&effect->base_effect,
parameter);
+ unsigned int i;
TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface, parameter,
data, bytes);
- return d3dx9_base_effect_set_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)
+ {
+ switch (param->type)
+ {
+ case D3DXPT_TEXTURE:
+ case D3DXPT_TEXTURE1D:
+ case D3DXPT_TEXTURE2D:
+ case D3DXPT_TEXTURE3D:
+ case D3DXPT_TEXTURECUBE:
+ for (i = 0; i < (param->element_count ? param->element_count :
1); ++i)
+ {
+ IUnknown *old_texture = ((IUnknown **)param->data)[i];
+ IUnknown *new_texture = ((IUnknown **)data)[i];
+
+ if (new_texture == old_texture)
+ continue;
+
+ if (new_texture)
+ IUnknown_AddRef(new_texture);
+ if (old_texture)
+ IUnknown_Release(old_texture);
+ }
+ /* fallthrough */
+ case D3DXPT_VOID:
+ case D3DXPT_BOOL:
+ case D3DXPT_INT:
+ case D3DXPT_FLOAT:
+ 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));
+ break;
+ }
+
+ return D3D_OK;
+ }
+
+ WARN("Invalid argument specified.\n");
+
+ return D3DERR_INVALIDCALL;
}
static HRESULT WINAPI d3dx_effect_GetValue(ID3DXEffect *iface, D3DXHANDLE parameter, void
*data, UINT bytes)
diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg
index a0dd3358da4..aa8a2c36cbd 100644
--- a/sdk/tools/winesync/d3dx9.cfg
+++ b/sdk/tools/winesync/d3dx9.cfg
@@ -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: d4e39ee1d8a263d91bc291cacfe8938f81d447fc}
+tags: {wine: bd731f6dd12d1e61daf3d6abefb3e01be35f5104}