Matteo Bruni : ddraw: Store primary stateblock state pointer in the device.

Alexandre Julliard julliard at winehq.org
Wed Mar 18 15:42:02 CDT 2020


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

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Wed Mar 18 14:01:23 2020 +0100

ddraw: Store primary stateblock state pointer in the device.

Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ddraw/ddraw.c         |  1 +
 dlls/ddraw/ddraw_private.h |  2 ++
 dlls/ddraw/device.c        | 23 ++++++++++++-----------
 dlls/ddraw/vertexbuffer.c  |  4 ++--
 dlls/ddraw/viewport.c      |  2 +-
 5 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index de45751159..050f625f71 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -5048,6 +5048,7 @@ HRESULT ddraw_init(struct ddraw *ddraw, DWORD flags, enum wined3d_device_type de
         wined3d_decref(ddraw->wined3d);
         return hr;
     }
+    ddraw->stateblock_state = wined3d_stateblock_get_state(ddraw->state);
 
     return DD_OK;
 }
diff --git a/dlls/ddraw/ddraw_private.h b/dlls/ddraw/ddraw_private.h
index 515a622e37..f4fe970a61 100644
--- a/dlls/ddraw/ddraw_private.h
+++ b/dlls/ddraw/ddraw_private.h
@@ -132,6 +132,7 @@ struct ddraw
     UINT                    numConvertedDecls, declArraySize;
 
     struct wined3d_stateblock *state;
+    const struct wined3d_stateblock_state *stateblock_state;
 };
 
 #define DDRAW_WINDOW_CLASS_NAME "DirectDrawDeviceWnd"
@@ -356,6 +357,7 @@ struct d3d_device
     struct wined3d_vec4 user_clip_planes[D3DMAXUSERCLIPPLANES];
 
     struct wined3d_stateblock *recording, *state, *update_state;
+    const struct wined3d_stateblock_state *stateblock_state;
 };
 
 HRESULT d3d_device_create(struct ddraw *ddraw, struct ddraw_surface *target, IUnknown *rt_iface,
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 3c0ae71196..048ba7fba6 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -2302,7 +2302,7 @@ static HRESULT d3d_device7_GetRenderState(IDirect3DDevice7 *iface,
         return DDERR_INVALIDPARAMS;
 
     wined3d_mutex_lock();
-    device_state = wined3d_stateblock_get_state(device->state);
+    device_state = device->stateblock_state;
     switch (state)
     {
         case D3DRENDERSTATE_TEXTUREMAG:
@@ -2451,7 +2451,7 @@ static HRESULT WINAPI d3d_device3_GetRenderState(IDirect3DDevice3 *iface,
             *value = 0;
 
             wined3d_mutex_lock();
-            if ((tex = wined3d_stateblock_get_state(device->state)->textures[0]))
+            if ((tex = device->stateblock_state->textures[0]))
             {
                 /* The parent of the texture is the IDirectDrawSurface7
                  * interface of the ddraw surface. */
@@ -2673,7 +2673,7 @@ static void fixup_texture_alpha_op(struct d3d_device *device)
     if (!(device->legacyTextureBlending && device->texture_map_blend == D3DTBLEND_MODULATE))
         return;
 
-    if ((tex = wined3d_stateblock_get_state(device->state)->textures[0]))
+    if ((tex = device->stateblock_state->textures[0]))
     {
         struct wined3d_resource_desc desc;
 
@@ -3233,7 +3233,7 @@ static HRESULT d3d_device7_GetTransform(IDirect3DDevice7 *iface,
 
     /* Note: D3DMATRIX is compatible with struct wined3d_matrix. */
     wined3d_mutex_lock();
-    memcpy(matrix, &wined3d_stateblock_get_state(device->state)->transforms[wined3d_state], sizeof(*matrix));
+    memcpy(matrix, &device->stateblock_state->transforms[wined3d_state], sizeof(*matrix));
     wined3d_mutex_unlock();
 
     return D3D_OK;
@@ -3886,7 +3886,7 @@ static HRESULT WINAPI d3d_device7_GetClipStatus(IDirect3DDevice7 *iface, D3DCLIP
 
     FIXME("iface %p, clip_status %p stub.\n", iface, clip_status);
 
-    vp = wined3d_stateblock_get_state(device->state)->viewport;
+    vp = device->stateblock_state->viewport;
     clip_status->minx = vp.x;
     clip_status->maxx = vp.x + vp.width;
     clip_status->miny = vp.y;
@@ -4566,7 +4566,7 @@ static void prepare_clip_space_planes(struct d3d_device *device, struct wined3d_
     /* We want the wined3d matrices since those include the legacy viewport
      * transformation. */
     wined3d_mutex_lock();
-    state = wined3d_stateblock_get_state(device->state);
+    state = device->stateblock_state;
     multiply_matrix(&m, &state->transforms[WINED3D_TS_VIEW], &state->transforms[WINED3D_TS_WORLD]);
     multiply_matrix(&m, &state->transforms[WINED3D_TS_PROJECTION], &m);
     wined3d_mutex_unlock();
@@ -4725,7 +4725,7 @@ static HRESULT d3d_device7_GetTexture(IDirect3DDevice7 *iface,
     }
 
     wined3d_mutex_lock();
-    if (!(wined3d_texture = wined3d_stateblock_get_state(device->state)->textures[stage]))
+    if (!(wined3d_texture = device->stateblock_state->textures[stage]))
     {
         *texture = NULL;
         wined3d_mutex_unlock();
@@ -4936,7 +4936,7 @@ static HRESULT d3d_device7_GetTextureStageState(IDirect3DDevice7 *iface,
 
     wined3d_mutex_lock();
 
-    device_state = wined3d_stateblock_get_state(device->state);
+    device_state = device->stateblock_state;
 
     if (l->sampler_state)
     {
@@ -5391,7 +5391,7 @@ static HRESULT d3d_device7_GetViewport(IDirect3DDevice7 *iface, D3DVIEWPORT7 *vi
         return DDERR_INVALIDPARAMS;
 
     wined3d_mutex_lock();
-    wined3d_viewport = wined3d_stateblock_get_state(device->state)->viewport;
+    wined3d_viewport = device->stateblock_state->viewport;
     wined3d_mutex_unlock();
 
     viewport->dwX = wined3d_viewport.x;
@@ -5493,7 +5493,7 @@ static HRESULT d3d_device7_GetMaterial(IDirect3DDevice7 *iface, D3DMATERIAL7 *ma
 
     wined3d_mutex_lock();
     /* Note: D3DMATERIAL7 is compatible with struct wined3d_material. */
-    memcpy(material, &wined3d_stateblock_get_state(device->state)->material, sizeof(*material));
+    memcpy(material, &device->stateblock_state->material, sizeof(*material));
     wined3d_mutex_unlock();
 
     return D3D_OK;
@@ -6577,7 +6577,7 @@ static HRESULT d3d_device7_GetClipPlane(IDirect3DDevice7 *iface, DWORD idx, D3DV
 
     wined3d_mutex_lock();
     if (idx < WINED3D_MAX_CLIP_DISTANCES)
-        memcpy(plane, &wined3d_stateblock_get_state(device->state)->clip_planes[idx], sizeof(struct wined3d_vec4));
+        memcpy(plane, &device->stateblock_state->clip_planes[idx], sizeof(struct wined3d_vec4));
     else
     {
         WARN("Clip plane %u is not supported.\n", idx);
@@ -6997,6 +6997,7 @@ static HRESULT d3d_device_init(struct d3d_device *device, struct ddraw *ddraw,
     device->wined3d_device = ddraw->wined3d_device;
     wined3d_device_incref(ddraw->wined3d_device);
     device->update_state = device->state = ddraw->state;
+    device->stateblock_state = ddraw->stateblock_state;
     wined3d_stateblock_incref(ddraw->state);
 
     /* Render to the back buffer */
diff --git a/dlls/ddraw/vertexbuffer.c b/dlls/ddraw/vertexbuffer.c
index afd798cb9f..584d9d162b 100644
--- a/dlls/ddraw/vertexbuffer.c
+++ b/dlls/ddraw/vertexbuffer.c
@@ -85,7 +85,7 @@ static ULONG WINAPI d3d_vertex_buffer7_Release(IDirect3DVertexBuffer7 *iface)
          * stream source in wined3d and they should get unset there before
          * they are destroyed. */
         wined3d_mutex_lock();
-        if (wined3d_stateblock_get_state(buffer->ddraw->state)->streams[0].buffer == buffer->wined3d_buffer)
+        if (buffer->ddraw->stateblock_state->streams[0].buffer == buffer->wined3d_buffer)
             wined3d_stateblock_set_stream_source(buffer->ddraw->state, 0, NULL, 0, 0);
 
         wined3d_vertex_declaration_decref(buffer->wined3d_declaration);
@@ -275,7 +275,7 @@ static HRESULT WINAPI d3d_vertex_buffer7_ProcessVertices(IDirect3DVertexBuffer7
 
     wined3d_mutex_lock();
 
-    state = wined3d_stateblock_get_state(device_impl->state);
+    state = device_impl->stateblock_state;
 
     /* WineD3D doesn't know d3d7 vertex operation, it uses
      * render states instead. Set the render states according to
diff --git a/dlls/ddraw/viewport.c b/dlls/ddraw/viewport.c
index ac56928e4f..4a415c4daf 100644
--- a/dlls/ddraw/viewport.c
+++ b/dlls/ddraw/viewport.c
@@ -520,7 +520,7 @@ static HRESULT WINAPI d3d_viewport_TransformVertices(IDirect3DViewport3 *iface,
     if (activate)
         viewport_activate(viewport, TRUE);
 
-    state = wined3d_stateblock_get_state(device->state);
+    state = device->stateblock_state;
     multiply_matrix(&mat, &state->transforms[WINED3D_TS_VIEW], &state->transforms[WINED3D_TS_WORLD_MATRIX(0)]);
     multiply_matrix(&mat, &state->transforms[WINED3D_TS_PROJECTION], &mat);
 




More information about the wine-cvs mailing list