Mesa (main): softpipe: Use the draw module's poly stipple handling, like llvmpipe.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Dec 27 18:31:43 UTC 2021


Module: Mesa
Branch: main
Commit: 0b7a0d1a495578ed7d7457dc0fa7186678896c25
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b7a0d1a495578ed7d7457dc0fa7186678896c25

Author: Emma Anholt <emma at anholt.net>
Date:   Tue Dec 21 15:31:36 2021 -0800

softpipe: Use the draw module's poly stipple handling, like llvmpipe.

softpipe was using the draw helper module as a testbed for the draw helper
module long ago, but we can just use the finished product.

Reviewed-by: Zoltán Böszőrményi <zboszor at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13731>

---

 src/gallium/drivers/softpipe/sp_compute.c       |  1 -
 src/gallium/drivers/softpipe/sp_context.c       | 18 +------
 src/gallium/drivers/softpipe/sp_context.h       | 15 ------
 src/gallium/drivers/softpipe/sp_state.h         |  5 +-
 src/gallium/drivers/softpipe/sp_state_clip.c    |  4 +-
 src/gallium/drivers/softpipe/sp_state_derived.c | 67 -------------------------
 src/gallium/drivers/softpipe/sp_state_shader.c  | 16 +-----
 7 files changed, 4 insertions(+), 122 deletions(-)

diff --git a/src/gallium/drivers/softpipe/sp_compute.c b/src/gallium/drivers/softpipe/sp_compute.c
index ac8d51196a4..9956c6961cd 100644
--- a/src/gallium/drivers/softpipe/sp_compute.c
+++ b/src/gallium/drivers/softpipe/sp_compute.c
@@ -23,7 +23,6 @@
 #include "util/u_inlines.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
-#include "util/u_pstipple.h"
 #include "pipe/p_shader_tokens.h"
 #include "draw/draw_context.h"
 #include "draw/draw_vertex.h"
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 0f5a882eaf4..1f6e11819df 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -35,7 +35,6 @@
 #include "pipe/p_defines.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
-#include "util/u_pstipple.h"
 #include "util/u_inlines.h"
 #include "util/u_upload_mgr.h"
 #include "tgsi/tgsi_exec.h"
@@ -60,14 +59,6 @@ softpipe_destroy( struct pipe_context *pipe )
    struct softpipe_context *softpipe = softpipe_context( pipe );
    uint i, sh;
 
-#if DO_PSTIPPLE_IN_HELPER_MODULE
-   if (softpipe->pstipple.sampler)
-      pipe->delete_sampler_state(pipe, softpipe->pstipple.sampler);
-
-   pipe_resource_reference(&softpipe->pstipple.texture, NULL);
-   pipe_sampler_view_reference(&softpipe->pstipple.sampler_view, NULL);
-#endif
-
    if (softpipe->blitter) {
       util_blitter_destroy(softpipe->blitter);
    }
@@ -344,20 +335,13 @@ softpipe_create_context(struct pipe_screen *screen,
    draw_install_aaline_stage(softpipe->draw, &softpipe->pipe);
    draw_install_aapoint_stage(softpipe->draw, &softpipe->pipe);
 
-   /* Do polygon stipple w/ texture map + frag prog? */
-#if DO_PSTIPPLE_IN_DRAW_MODULE
+   /* Do polygon stipple w/ texture map + frag prog. */
    draw_install_pstipple_stage(softpipe->draw, &softpipe->pipe);
-#endif
 
    draw_wide_point_sprites(softpipe->draw, TRUE);
 
    sp_init_surface_functions(softpipe);
 
-#if DO_PSTIPPLE_IN_HELPER_MODULE
-   /* create the polygon stipple sampler */
-   softpipe->pstipple.sampler = util_pstipple_create_sampler(&softpipe->pipe);
-#endif
-
    return &softpipe->pipe;
 
  fail:
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index 70aac737960..7a820fb1d47 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -40,13 +40,6 @@
 #include "sp_setup.h"
 
 
-/** Do polygon stipple in the draw module? */
-#define DO_PSTIPPLE_IN_DRAW_MODULE 0
-
-/** Do polygon stipple with the util module? */
-#define DO_PSTIPPLE_IN_HELPER_MODULE 1
-
-
 struct softpipe_vbuf_render;
 struct draw_context;
 struct draw_stage;
@@ -80,7 +73,6 @@ struct softpipe_context {
    struct pipe_clip_state clip;
    struct pipe_resource *constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
    struct pipe_framebuffer_state framebuffer;
-   struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissors[PIPE_MAX_VIEWPORTS];
    struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
 
@@ -153,13 +145,6 @@ struct softpipe_context {
    enum pipe_render_cond_flag render_cond_mode;
    bool render_cond_cond;
 
-   /** Polygon stipple items */
-   struct {
-      struct pipe_resource *texture;
-      struct pipe_sampler_state *sampler;
-      struct pipe_sampler_view *sampler_view;
-   } pstipple;
-
    /** Software quad rendering pipeline */
    struct {
       struct quad_stage *shade;
diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h
index dcb89ef252e..30501ba01fe 100644
--- a/src/gallium/drivers/softpipe/sp_state.h
+++ b/src/gallium/drivers/softpipe/sp_state.h
@@ -41,7 +41,7 @@
 #define SP_NEW_BLEND         0x8
 #define SP_NEW_CLIP          0x10
 #define SP_NEW_SCISSOR       0x20
-#define SP_NEW_STIPPLE       0x40
+
 #define SP_NEW_FRAMEBUFFER   0x80
 #define SP_NEW_DEPTH_STENCIL_ALPHA 0x100
 #define SP_NEW_CONSTANTS     0x200
@@ -64,7 +64,6 @@ struct vertex_info;
 
 struct sp_fragment_shader_variant_key
 {
-   boolean polygon_stipple;
 };
 
 
@@ -74,8 +73,6 @@ struct sp_fragment_shader_variant
    struct sp_fragment_shader_variant_key key;
    struct tgsi_shader_info info;
 
-   unsigned stipple_sampler_unit;
-
    /* See comments about this elsewhere */
 #if 0
    struct draw_fragment_shader *draw_shader;
diff --git a/src/gallium/drivers/softpipe/sp_state_clip.c b/src/gallium/drivers/softpipe/sp_state_clip.c
index 4de6296fce5..7f1079b59b3 100644
--- a/src/gallium/drivers/softpipe/sp_state_clip.c
+++ b/src/gallium/drivers/softpipe/sp_state_clip.c
@@ -84,12 +84,10 @@ static void
 softpipe_set_polygon_stipple(struct pipe_context *pipe,
                              const struct pipe_poly_stipple *stipple)
 {
+   /* Actual stippling handled by draw module. */
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
    draw_flush(softpipe->draw);
-
-   softpipe->poly_stipple = *stipple; /* struct copy */
-   softpipe->dirty |= SP_NEW_STIPPLE;
 }
 
 
diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c
index e7ee921c719..8436b320b95 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -28,7 +28,6 @@
 #include "util/u_inlines.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
-#include "util/u_pstipple.h"
 #include "pipe/p_shader_tokens.h"
 #include "draw/draw_context.h"
 #include "draw/draw_vertex.h"
@@ -338,9 +337,6 @@ update_fragment_shader(struct softpipe_context *softpipe, unsigned prim)
 
    memset(&key, 0, sizeof(key));
 
-   if (prim == PIPE_PRIM_TRIANGLES)
-      key.polygon_stipple = softpipe->rasterizer->poly_stipple_enable;
-
    if (softpipe->fs) {
       softpipe->fs_variant = softpipe_find_fs_variant(softpipe,
                                                       softpipe->fs, &key);
@@ -377,56 +373,6 @@ update_fragment_shader(struct softpipe_context *softpipe, unsigned prim)
 }
 
 
-/**
- * This should be called when the polygon stipple pattern changes.
- * We create a new texture from the stipple pattern and create a new
- * sampler view.
- */
-static void
-update_polygon_stipple_pattern(struct softpipe_context *softpipe)
-{
-   struct pipe_resource *tex;
-   struct pipe_sampler_view *view;
-
-   tex = util_pstipple_create_stipple_texture(&softpipe->pipe,
-                                              softpipe->poly_stipple.stipple);
-   pipe_resource_reference(&softpipe->pstipple.texture, tex);
-   pipe_resource_reference(&tex, NULL);
-
-   view = util_pstipple_create_sampler_view(&softpipe->pipe,
-                                            softpipe->pstipple.texture);
-   pipe_sampler_view_reference(&softpipe->pstipple.sampler_view, view);
-   pipe_sampler_view_reference(&view, NULL);
-}
-
-
-/**
- * Should be called when polygon stipple is enabled/disabled or when
- * the fragment shader changes.
- * We add/update the fragment sampler and sampler views to sample from
- * the polygon stipple texture.  The texture unit that we use depends on
- * the fragment shader (we need to use a unit not otherwise used by the
- * shader).
- */
-static void
-update_polygon_stipple_enable(struct softpipe_context *softpipe, unsigned prim)
-{
-   if (prim == PIPE_PRIM_TRIANGLES &&
-       softpipe->fs_variant->key.polygon_stipple) {
-      const unsigned unit = softpipe->fs_variant->stipple_sampler_unit;
-
-      /* sampler state */
-      softpipe->samplers[PIPE_SHADER_FRAGMENT][unit] = softpipe->pstipple.sampler;
-
-      /* sampler view state */
-      softpipe_set_sampler_views(&softpipe->pipe, PIPE_SHADER_FRAGMENT,
-                                 unit, 1, 0, false, &softpipe->pstipple.sampler_view);
-
-      softpipe->dirty |= SP_NEW_SAMPLER;
-   }
-}
-
-
 /* Hopefully this will remain quite simple, otherwise need to pull in
  * something like the gallium frontend mechanism.
  */
@@ -442,23 +388,10 @@ softpipe_update_derived(struct softpipe_context *softpipe, unsigned prim)
       softpipe->dirty |= SP_NEW_TEXTURE;
    }
 
-#if DO_PSTIPPLE_IN_HELPER_MODULE
-   if (softpipe->dirty & SP_NEW_STIPPLE)
-      /* before updating samplers! */
-      update_polygon_stipple_pattern(softpipe);
-#endif
-
    if (softpipe->dirty & (SP_NEW_RASTERIZER |
                           SP_NEW_FS))
       update_fragment_shader(softpipe, prim);
 
-#if DO_PSTIPPLE_IN_HELPER_MODULE
-   if (softpipe->dirty & (SP_NEW_RASTERIZER |
-                          SP_NEW_STIPPLE |
-                          SP_NEW_FS))
-      update_polygon_stipple_enable(softpipe, prim);
-#endif
-
    /* TODO: this looks suboptimal */
    if (softpipe->dirty & (SP_NEW_SAMPLER |
                           SP_NEW_TEXTURE |
diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c b/src/gallium/drivers/softpipe/sp_state_shader.c
index 0f25786c6e6..37506ee88da 100644
--- a/src/gallium/drivers/softpipe/sp_state_shader.c
+++ b/src/gallium/drivers/softpipe/sp_state_shader.c
@@ -37,7 +37,6 @@
 #include "util/ralloc.h"
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
-#include "util/u_pstipple.h"
 #include "draw/draw_context.h"
 #include "draw/draw_vs.h"
 #include "draw/draw_gs.h"
@@ -65,20 +64,7 @@ create_fs_variant(struct softpipe_context *softpipe,
    if (var) {
       var->key = *key;
 
-#if DO_PSTIPPLE_IN_HELPER_MODULE
-      if (key->polygon_stipple) {
-         /* get new shader that implements polygon stippling */
-         var->tokens = 
-            util_pstipple_create_fragment_shader(curfs->tokens,
-                                                 &var->stipple_sampler_unit, 0,
-                                                 TGSI_FILE_INPUT);
-      }
-      else
-#endif
-      {
-         var->tokens = tgsi_dup_tokens(curfs->tokens);
-         var->stipple_sampler_unit = 0;
-      }
+      var->tokens = tgsi_dup_tokens(curfs->tokens);
 
       tgsi_scan_shader(var->tokens, &var->info);
 



More information about the mesa-commit mailing list