https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0bc31de9880be200c2ed0…
commit 0bc31de9880be200c2ed04b46715db50dbe9571f
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Mon Sep 21 23:03:21 2020 +0200
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Thu Feb 4 16:37:04 2021 +0100
[WINESYNC] d3dx9: Factor out set_value() function.
Signed-off-by: Paul Gofman <gofmanp(a)gmail.com>
Signed-off-by: Matteo Bruni <mbruni(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 4020a38259774c64035e5783d595ff88097cedf8 by Paul Gofman
<gofmanp(a)gmail.com>
---
dll/directx/wine/d3dx9_36/effect.c | 130 ++++++++++++++++++++-----------------
sdk/tools/winesync/d3dx9.cfg | 2 +-
2 files changed, 70 insertions(+), 62 deletions(-)
diff --git a/dll/directx/wine/d3dx9_36/effect.c b/dll/directx/wine/d3dx9_36/effect.c
index f1ffd1a7c37..e6fc00d3777 100644
--- a/dll/directx/wine/d3dx9_36/effect.c
+++ b/dll/directx/wine/d3dx9_36/effect.c
@@ -831,6 +831,73 @@ static void set_matrix_transpose(struct d3dx_parameter *param, const
D3DXMATRIX
}
}
+static HRESULT set_string(char **param_data, const char *string)
+{
+ heap_free(*param_data);
+ *param_data = heap_alloc(strlen(string) + 1);
+ if (!*param_data)
+ {
+ ERR("Out of memory.\n");
+ return E_OUTOFMEMORY;
+ }
+ strcpy(*param_data, string);
+ return D3D_OK;
+}
+
+static HRESULT set_value(struct d3dx_parameter *param, const void *data, unsigned int
bytes)
+{
+ unsigned int i, count;
+
+ bytes = min(bytes, param->bytes);
+ count = min(param->element_count ? param->element_count : 1, bytes /
sizeof(void *));
+
+ switch (param->type)
+ {
+ case D3DXPT_TEXTURE:
+ case D3DXPT_TEXTURE1D:
+ case D3DXPT_TEXTURE2D:
+ case D3DXPT_TEXTURE3D:
+ case D3DXPT_TEXTURECUBE:
+ for (i = 0; i < count; ++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", bytes);
+ memcpy(param->data, data, bytes);
+ break;
+
+ case D3DXPT_STRING:
+ {
+ HRESULT hr;
+
+ for (i = 0; i < count; ++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;
+}
+
static struct d3dx_parameter *get_parameter_element_by_name(struct d3dx_effect *effect,
struct d3dx_parameter *parameter, const char *name)
{
@@ -1180,19 +1247,6 @@ static void set_dirty(struct d3dx_parameter *param)
top_param->update_version = new_update_version;
}
-static HRESULT set_string(char **param_data, const char *string)
-{
- HeapFree(GetProcessHeap(), 0, *param_data);
- *param_data = HeapAlloc(GetProcessHeap(), 0, strlen(string) + 1);
- if (!*param_data)
- {
- ERR("Out of memory.\n");
- return E_OUTOFMEMORY;
- }
- strcpy(*param_data, string);
- return D3D_OK;
-}
-
static void d3dx9_set_light_parameter(enum LIGHT_TYPE op, D3DLIGHT9 *light, void *value)
{
static const struct
@@ -2282,7 +2336,6 @@ static HRESULT WINAPI d3dx_effect_SetValue(ID3DXEffect *iface,
D3DXHANDLE parame
{
struct d3dx_effect *effect = impl_from_ID3DXEffect(iface);
struct d3dx_parameter *param = get_valid_parameter(effect, parameter);
- unsigned int i;
TRACE("iface %p, parameter %p, data %p, bytes %u.\n", iface, parameter,
data, bytes);
@@ -2299,53 +2352,8 @@ static HRESULT WINAPI d3dx_effect_SetValue(ID3DXEffect *iface,
D3DXHANDLE parame
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;
+ set_dirty(param);
+ return set_value(param, data, bytes);
}
WARN("Invalid argument specified.\n");
diff --git a/sdk/tools/winesync/d3dx9.cfg b/sdk/tools/winesync/d3dx9.cfg
index 023289fc2c9..5ef09b584fa 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: f65e4854e37355a946b6e017a2cd595a1ddceb38}
+tags: {wine: 4020a38259774c64035e5783d595ff88097cedf8}