Zebediah Figura : d3d8: Retrieve vertex shader constants from the primary stateblock.

Alexandre Julliard julliard at winehq.org
Fri Feb 21 15:27:05 CST 2020


Module: wine
Branch: master
Commit: ffb8cc3623bde69ac80bfbcd5347581c0779a726
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=ffb8cc3623bde69ac80bfbcd5347581c0779a726

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Thu Feb 20 20:21:30 2020 -0600

d3d8: Retrieve vertex shader constants from the primary stateblock.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/d3d8/d3d8_private.h |  2 ++
 dlls/d3d8/device.c       | 25 ++++++++++++++++---------
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h
index 26451255c0..0fcc8bd7a0 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -131,6 +131,8 @@ struct d3d8_device
     DWORD in_destruction : 1;
     DWORD padding : 14;
 
+    unsigned int vs_uniform_count;
+
     /* The d3d8 API supports only one implicit swapchain (no D3DCREATE_ADAPTERGROUP_DEVICE,
      * no GetSwapchain, GetBackBuffer doesn't accept a swapchain number). */
     struct wined3d_swapchain *implicit_swapchain;
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index ef1b3afde9..90dec4aaa7 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -2991,26 +2991,29 @@ static HRESULT WINAPI d3d8_device_SetVertexShaderConstant(IDirect3DDevice8 *ifac
 }
 
 static HRESULT WINAPI d3d8_device_GetVertexShaderConstant(IDirect3DDevice8 *iface,
-        DWORD start_register, void *data, DWORD count)
+        DWORD start_idx, void *constants, DWORD count)
 {
     struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
-    HRESULT hr;
+    const struct wined3d_vec4 *src;
 
-    TRACE("iface %p, start_register %u, data %p, count %u.\n",
-            iface, start_register, data, count);
+    TRACE("iface %p, start_idx %u, constants %p, count %u.\n", iface, start_idx, constants, count);
 
-    if (start_register + count > D3D8_MAX_VERTEX_SHADER_CONSTANTF)
+    if (!constants)
+        return D3DERR_INVALIDCALL;
+
+    if (start_idx >= device->vs_uniform_count || count > device->vs_uniform_count - start_idx)
     {
-        WARN("Trying to access %u constants, but d3d8 only supports %u\n",
-             start_register + count, D3D8_MAX_VERTEX_SHADER_CONSTANTF);
+        WARN("Trying to access %u constants, but d3d8 only supports %u.\n",
+             start_idx + count, device->vs_uniform_count);
         return D3DERR_INVALIDCALL;
     }
 
     wined3d_mutex_lock();
-    hr = wined3d_device_get_vs_consts_f(device->wined3d_device, start_register, count, data);
+    src = wined3d_stateblock_get_state(device->state)->vs_consts_f;
+    memcpy(constants, &src[start_idx], count * sizeof(*src));
     wined3d_mutex_unlock();
 
-    return hr;
+    return D3D_OK;
 }
 
 static HRESULT WINAPI d3d8_device_GetVertexShaderDeclaration(IDirect3DDevice8 *iface,
@@ -3668,6 +3671,7 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
     struct wined3d_swapchain_desc swapchain_desc;
     struct wined3d_swapchain *wined3d_swapchain;
     struct d3d8_swapchain *d3d_swapchain;
+    struct wined3d_caps caps;
     HRESULT hr;
 
     static const enum wined3d_feature_level feature_levels[] =
@@ -3702,6 +3706,9 @@ HRESULT device_init(struct d3d8_device *device, struct d3d8 *parent, struct wine
         return hr;
     }
 
+    wined3d_get_device_caps(wined3d, adapter, device_type, &caps);
+    device->vs_uniform_count = caps.MaxVertexShaderConst;
+
     if (FAILED(hr = wined3d_stateblock_create(device->wined3d_device, NULL, WINED3D_SBT_PRIMARY, &device->state)))
     {
         ERR("Failed to create primary stateblock, hr %#x.\n", hr);




More information about the wine-cvs mailing list