[PATCH 3/6] wined3d: Move the scissor test state to wined3d_rasterizer_state.

Zebediah Figura z.figura12 at gmail.com
Fri Mar 6 22:18:35 CST 2020


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/d3d11/device.c    |  2 --
 dlls/d3d11/state.c     |  1 +
 dlls/wined3d/context.c |  5 ++---
 dlls/wined3d/cs.c      |  2 +-
 dlls/wined3d/device.c  |  2 ++
 dlls/wined3d/state.c   | 11 +++++------
 dlls/wined3d/surface.c |  4 ++--
 include/wine/wined3d.h |  1 +
 8 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 59e3ab25af..82292662e4 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -936,7 +936,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
     if (!(rasterizer_state_impl = unsafe_impl_from_ID3D11RasterizerState(rasterizer_state)))
     {
         wined3d_device_set_rasterizer_state(device->wined3d_device, NULL);
-        wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, FALSE);
         wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, FALSE);
         wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ANTIALIASEDLINEENABLE, FALSE);
         wined3d_mutex_unlock();
@@ -946,7 +945,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon
     wined3d_device_set_rasterizer_state(device->wined3d_device, rasterizer_state_impl->wined3d_state);
 
     desc = &rasterizer_state_impl->desc;
-    wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable);
     wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable);
     wined3d_device_set_render_state(device->wined3d_device,
             WINED3D_RS_ANTIALIASEDLINEENABLE, desc->AntialiasedLineEnable);
diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c
index c1aaa094e0..7402ff8ce8 100644
--- a/dlls/d3d11/state.c
+++ b/dlls/d3d11/state.c
@@ -1083,6 +1083,7 @@ static HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, str
     wined3d_desc.depth_bias_clamp = desc->DepthBiasClamp;
     wined3d_desc.scale_bias = desc->SlopeScaledDepthBias;
     wined3d_desc.depth_clip = desc->DepthClipEnable;
+    wined3d_desc.scissor = desc->ScissorEnable;
 
     /* We cannot fail after creating a wined3d_rasterizer_state object. It
      * would lead to double free. */
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 28e0d262a5..f4a5189ba1 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -3150,11 +3150,10 @@ void wined3d_context_gl_apply_blit_state(struct wined3d_context_gl *context_gl,
     gl_info->gl_ops.gl.p_glDisable(GL_BLEND);
     context_invalidate_state(context, STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE));
     gl_info->gl_ops.gl.p_glDisable(GL_CULL_FACE);
+    gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST);
     context_invalidate_state(context, STATE_RASTERIZER);
     gl_info->gl_ops.gl.p_glDisable(GL_STENCIL_TEST);
     context_invalidate_state(context, STATE_RENDER(WINED3D_RS_STENCILENABLE));
-    gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST);
-    context_invalidate_state(context, STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE));
     if (gl_info->supported[ARB_POINT_SPRITE])
     {
         gl_info->gl_ops.gl.p_glDisable(GL_POINT_SPRITE_ARB);
@@ -3428,7 +3427,7 @@ BOOL wined3d_context_gl_apply_clear_state(struct wined3d_context_gl *context_gl,
     checkGLcall("setting up state for clear");
 
     context_invalidate_state(&context_gl->c, STATE_RENDER(WINED3D_RS_ALPHABLENDENABLE));
-    context_invalidate_state(&context_gl->c, STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE));
+    context_invalidate_state(&context_gl->c, STATE_RASTERIZER);
     context_invalidate_state(&context_gl->c, STATE_SCISSORRECT);
 
     return TRUE;
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index ac518cae04..dbdf5f2ec2 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -614,7 +614,7 @@ void wined3d_cs_emit_clear(struct wined3d_cs *cs, DWORD rect_count, const RECT *
     op->rt_count = rt_count;
     op->fb = &cs->fb;
     SetRect(&op->draw_rect, vp->x, vp->y, vp->x + vp->width, vp->y + vp->height);
-    if (state->render_states[WINED3D_RS_SCISSORTESTENABLE])
+    if (state->rasterizer_state && state->rasterizer_state->desc.scissor)
         IntersectRect(&op->draw_rect, &op->draw_rect, &state->scissor_rects[0]);
     op->color = *color;
     op->depth = depth;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 50a0a740bf..13b3348c04 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3602,6 +3602,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
                 case WINED3D_RS_CULLMODE:
                 case WINED3D_RS_SLOPESCALEDEPTHBIAS:
                 case WINED3D_RS_DEPTHBIAS:
+                case WINED3D_RS_SCISSORTESTENABLE:
                     set_rasterizer_state = TRUE;
                     break;
 
@@ -3631,6 +3632,7 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device,
         bias.d = state->rs[WINED3D_RS_SLOPESCALEDEPTHBIAS];
         desc.scale_bias = bias.f;
         desc.depth_clip = TRUE;
+        desc.scissor = state->rs[WINED3D_RS_SCISSORTESTENABLE];
 
         if ((entry = wine_rb_get(&device->rasterizer_states, &desc)))
         {
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 4d5455e19b..53daca8d52 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -1721,11 +1721,9 @@ static void state_line_antialias(struct wined3d_context *context, const struct w
     }
 }
 
-static void state_scissor(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
+static void scissor(const struct wined3d_rasterizer_state *r, const struct wined3d_gl_info *gl_info)
 {
-    const struct wined3d_gl_info *gl_info = wined3d_context_gl(context)->gl_info;
-
-    if (state->render_states[WINED3D_RS_SCISSORTESTENABLE])
+    if (r && r->desc.scissor)
     {
         gl_info->gl_ops.gl.p_glEnable(GL_SCISSOR_TEST);
         checkGLcall("glEnable(GL_SCISSOR_TEST)");
@@ -4335,6 +4333,7 @@ static void rasterizer(struct wined3d_context *context, const struct wined3d_sta
     fillmode(r, gl_info);
     cullmode(r, gl_info);
     depth_clip(r, gl_info);
+    scissor(r, gl_info);
 }
 
 static void rasterizer_cc(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
@@ -4351,6 +4350,7 @@ static void rasterizer_cc(struct wined3d_context *context, const struct wined3d_
     fillmode(r, gl_info);
     cullmode(r, gl_info);
     depth_clip(r, gl_info);
+    scissor(r, gl_info);
 }
 
 static void psorigin_w(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
@@ -4660,7 +4660,6 @@ const struct wined3d_state_entry_template misc_state_template[] =
     { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE),          { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE),          state_colorwrite    }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3D_RS_BLENDOP),                   { STATE_RENDER(WINED3D_RS_BLENDOP),                   state_blendop       }, WINED3D_GL_BLEND_EQUATION       },
     { STATE_RENDER(WINED3D_RS_BLENDOP),                   { STATE_RENDER(WINED3D_RS_BLENDOP),                   state_blendop_w     }, WINED3D_GL_EXT_NONE             },
-    { STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE),         { STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE),         state_scissor       }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1),         { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1),         state_colorwrite1   }, EXT_DRAW_BUFFERS2               },
     { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE1),         { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE),          NULL                }, WINED3D_GL_EXT_NONE             },
     { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2),         { STATE_RENDER(WINED3D_RS_COLORWRITEENABLE2),         state_colorwrite2   }, EXT_DRAW_BUFFERS2               },
@@ -5432,7 +5431,7 @@ static void validate_state_table(struct wined3d_state_entry *state_table)
         { 61, 127},
         {149, 150},
         {169, 169},
-        {175, 175},
+        {174, 175},
         {177, 177},
         {193, 193},
         {195, 197},
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index c0f28099cf..d8dc379c1a 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -131,7 +131,7 @@ static void texture2d_depth_blt_fbo(const struct wined3d_device *device, struct
     }
 
     gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST);
-    context_invalidate_state(context, STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE));
+    context_invalidate_state(context, STATE_RASTERIZER);
 
     gl_info->fbo_ops.glBlitFramebuffer(src_rect->left, src_rect->top, src_rect->right, src_rect->bottom,
             dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom, gl_mask, GL_NEAREST);
@@ -267,7 +267,7 @@ void texture2d_blt_fbo(struct wined3d_device *device, struct wined3d_context *co
     context_invalidate_state(context, STATE_RENDER(WINED3D_RS_COLORWRITEENABLE3));
 
     gl_info->gl_ops.gl.p_glDisable(GL_SCISSOR_TEST);
-    context_invalidate_state(context, STATE_RENDER(WINED3D_RS_SCISSORTESTENABLE));
+    context_invalidate_state(context, STATE_RASTERIZER);
 
     gl_info->fbo_ops.glBlitFramebuffer(src_rect->left, src_rect->top, src_rect->right, src_rect->bottom,
             dst_rect->left, dst_rect->top, dst_rect->right, dst_rect->bottom, GL_COLOR_BUFFER_BIT, gl_filter);
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 85d7885f49..211e9d37d0 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2040,6 +2040,7 @@ struct wined3d_rasterizer_state_desc
     float depth_bias_clamp;
     float scale_bias;
     BOOL depth_clip;
+    BOOL scissor;
 };
 
 struct wined3d_sampler_desc
-- 
2.25.1




More information about the wine-devel mailing list