[PATCH 3/8] wined3d: Pass wined3d_vec4 structures to wined3d_device_set_vs_consts_f().

Henri Verbeet hverbeet at codeweavers.com
Tue Apr 26 10:55:58 CDT 2016


Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
 dlls/d3d8/device.c        |  2 +-
 dlls/d3d9/device.c        |  3 ++-
 dlls/wined3d/device.c     | 31 ++++++++++++-------------------
 dlls/wined3d/stateblock.c |  2 +-
 dlls/wined3d/wined3d.spec |  2 +-
 include/wine/wined3d.h    |  2 +-
 6 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 4590d0f..847adad 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -2434,7 +2434,7 @@ static HRESULT WINAPI d3d8_device_SetVertexShaderConstant(IDirect3DDevice8 *ifac
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_vs_consts_f(device->wined3d_device, start_register, data, count);
+    hr = wined3d_device_set_vs_consts_f(device->wined3d_device, start_register, count, data);
     wined3d_mutex_unlock();
 
     return hr;
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 57258c4..53486bc 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -2813,7 +2813,8 @@ static HRESULT WINAPI d3d9_device_SetVertexShaderConstantF(IDirect3DDevice9Ex *i
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_set_vs_consts_f(device->wined3d_device, reg_idx, data, count);
+    hr = wined3d_device_set_vs_consts_f(device->wined3d_device,
+            reg_idx, count, (const struct wined3d_vec4 *)data);
     wined3d_mutex_unlock();
 
     return hr;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 6342ee3..7afdff8 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2465,37 +2465,30 @@ HRESULT CDECL wined3d_device_get_vs_consts_i(const struct wined3d_device *device
 }
 
 HRESULT CDECL wined3d_device_set_vs_consts_f(struct wined3d_device *device,
-        UINT start_register, const float *constants, UINT vector4f_count)
+        unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants)
 {
-    UINT i;
     const struct wined3d_d3d_info *d3d_info = &device->adapter->d3d_info;
+    unsigned int i;
 
-    TRACE("device %p, start_register %u, constants %p, vector4f_count %u.\n",
-            device, start_register, constants, vector4f_count);
+    TRACE("device %p, start_idx %u, count %u, constants %p.\n",
+            device, start_idx, count, constants);
 
-    /* Specifically test start_register > limit to catch MAX_UINT overflows
-     * when adding start_register + vector4f_count. */
-    if (!constants
-            || start_register + vector4f_count > d3d_info->limits.vs_uniform_count
-            || start_register > d3d_info->limits.vs_uniform_count)
+    if (!constants || start_idx >= d3d_info->limits.vs_uniform_count
+            || count > d3d_info->limits.vs_uniform_count - start_idx)
         return WINED3DERR_INVALIDCALL;
 
-    memcpy(&device->update_state->vs_consts_f[start_register],
-            constants, vector4f_count * sizeof(float) * 4);
+    memcpy(&device->update_state->vs_consts_f[start_idx], constants, count * sizeof(*constants));
     if (TRACE_ON(d3d))
     {
-        for (i = 0; i < vector4f_count; ++i)
-            TRACE("Set FLOAT constant %u to {%.8e, %.8e, %.8e, %.8e}.\n", start_register + i,
-                    constants[i * 4], constants[i * 4 + 1],
-                    constants[i * 4 + 2], constants[i * 4 + 3]);
+        for (i = 0; i < count; ++i)
+            TRACE("Set vec4 constant %u to %s.\n", start_idx + i, debug_vec4(&constants[i]));
     }
 
     if (device->recording)
-        memset(device->recording->changed.vertexShaderConstantsF + start_register, 1,
-                sizeof(*device->recording->changed.vertexShaderConstantsF) * vector4f_count);
+        memset(&device->recording->changed.vertexShaderConstantsF[start_idx], 1,
+                count * sizeof(*device->recording->changed.vertexShaderConstantsF));
     else
-        device->shader_backend->shader_update_float_vertex_constants(device, start_register, vector4f_count);
-
+        device->shader_backend->shader_update_float_vertex_constants(device, start_idx, count);
 
     return WINED3D_OK;
 }
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 3f9cb34..2672377 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -956,7 +956,7 @@ void CDECL wined3d_stateblock_apply(const struct wined3d_stateblock *stateblock)
     for (i = 0; i < stateblock->num_contained_vs_consts_f; ++i)
     {
         wined3d_device_set_vs_consts_f(device, stateblock->contained_vs_consts_f[i],
-                &stateblock->state.vs_consts_f[stateblock->contained_vs_consts_f[i]].x, 1);
+                1, &stateblock->state.vs_consts_f[stateblock->contained_vs_consts_f[i]]);
     }
     for (i = 0; i < stateblock->num_contained_vs_consts_i; ++i)
     {
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec
index 8bf6726..26a0c07 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -150,7 +150,7 @@
 @ cdecl wined3d_device_set_viewport(ptr ptr)
 @ cdecl wined3d_device_set_vs_cb(ptr long ptr)
 @ cdecl wined3d_device_set_vs_consts_b(ptr long ptr long)
-@ cdecl wined3d_device_set_vs_consts_f(ptr long ptr long)
+@ cdecl wined3d_device_set_vs_consts_f(ptr long long ptr)
 @ cdecl wined3d_device_set_vs_consts_i(ptr long ptr long)
 @ cdecl wined3d_device_set_vs_resource_view(ptr long ptr)
 @ cdecl wined3d_device_set_vs_sampler(ptr long ptr)
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 90b84d5..d789470 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2241,7 +2241,7 @@ void __cdecl wined3d_device_set_vs_cb(struct wined3d_device *device, UINT idx, s
 HRESULT __cdecl wined3d_device_set_vs_consts_b(struct wined3d_device *device,
         UINT start_register, const BOOL *constants, UINT bool_count);
 HRESULT __cdecl wined3d_device_set_vs_consts_f(struct wined3d_device *device,
-        UINT start_register, const float *constants, UINT vector4f_count);
+        unsigned int start_idx, unsigned int count, const struct wined3d_vec4 *constants);
 HRESULT __cdecl wined3d_device_set_vs_consts_i(struct wined3d_device *device,
         UINT start_register, const int *constants, UINT vector4i_count);
 void __cdecl wined3d_device_set_vs_resource_view(struct wined3d_device *device,
-- 
2.1.4




More information about the wine-patches mailing list