Mesa (main): crocus: add GL_CLAMP emulation in driver again.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 12 06:19:30 UTC 2021


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

Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Jul 12 15:12:02 2021 +1000

crocus: add GL_CLAMP emulation in driver again.

I removed this because I thought the state tracker could handle it,
and it really should handle it, but it has some minecraft side effects
I'm unsure about. This fixes the problem for now, we can revisit it later.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11822>

---

 src/gallium/drivers/crocus/crocus_program.c |  3 +++
 src/gallium/drivers/crocus/crocus_screen.c  |  3 +--
 src/gallium/drivers/crocus/crocus_screen.h  |  3 +++
 src/gallium/drivers/crocus/crocus_state.c   | 18 ++++++++++++++++++
 4 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/crocus/crocus_program.c b/src/gallium/drivers/crocus/crocus_program.c
index 13b80fe31a5..f14c73ff736 100644
--- a/src/gallium/drivers/crocus/crocus_program.c
+++ b/src/gallium/drivers/crocus/crocus_program.c
@@ -150,6 +150,7 @@ crocus_populate_sampler_prog_key_data(struct crocus_context *ice,
                                       bool uses_texture_gather,
                                       struct brw_sampler_prog_key_data *key)
 {
+   struct crocus_screen *screen = (struct crocus_screen *)ice->ctx.screen;
    uint32_t mask = ish->nir->info.textures_used[0];
 
    while (mask) {
@@ -167,6 +168,8 @@ crocus_populate_sampler_prog_key_data(struct crocus_context *ice,
          key->swizzles[s] = crocus_get_texture_swizzle(ice, texture);
       }
 
+      screen->vtbl.fill_clamp_mask(ice->state.shaders[stage].samplers[s], s, key->gl_clamp_mask);
+
       /* gather4 for RG32* is broken in multiple ways on Gen7. */
       if (devinfo->ver == 7 && uses_texture_gather) {
          switch (texture->base.format) {
diff --git a/src/gallium/drivers/crocus/crocus_screen.c b/src/gallium/drivers/crocus/crocus_screen.c
index b9853e6a231..3e85b7d6c50 100644
--- a/src/gallium/drivers/crocus/crocus_screen.c
+++ b/src/gallium/drivers/crocus/crocus_screen.c
@@ -210,14 +210,13 @@ crocus_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_CS_DERIVED_SYSTEM_VALUES_SUPPORTED:
    case PIPE_CAP_FENCE_SIGNAL:
    case PIPE_CAP_DEMOTE_TO_HELPER_INVOCATION:
+   case PIPE_CAP_GL_CLAMP:
       return true;
    case PIPE_CAP_INT64:
    case PIPE_CAP_INT64_DIVMOD:
    case PIPE_CAP_TGSI_BALLOT:
    case PIPE_CAP_PACKED_UNIFORMS:
       return devinfo->ver == 8;
-   case PIPE_CAP_GL_CLAMP:
-      return false;
    case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION:
       return devinfo->ver <= 5;
    case PIPE_CAP_TEXTURE_QUERY_LOD:
diff --git a/src/gallium/drivers/crocus/crocus_screen.h b/src/gallium/drivers/crocus/crocus_screen.h
index 4d942eb8415..652f81388b8 100644
--- a/src/gallium/drivers/crocus/crocus_screen.h
+++ b/src/gallium/drivers/crocus/crocus_screen.h
@@ -136,6 +136,9 @@ struct crocus_vtable {
                            struct brw_wm_prog_key *key);
    void (*populate_cs_key)(const struct crocus_context *ice,
                            struct brw_cs_prog_key *key);
+   void (*fill_clamp_mask)(const struct crocus_sampler_state *state,
+                           int s,
+                           uint32_t *clamp_mask);
    void (*lost_genx_state)(struct crocus_context *ice, struct crocus_batch *batch);
 
    void (*finish_batch)(struct crocus_batch *batch); /* haswell only */
diff --git a/src/gallium/drivers/crocus/crocus_state.c b/src/gallium/drivers/crocus/crocus_state.c
index 59fa57d0646..07f72c3609e 100644
--- a/src/gallium/drivers/crocus/crocus_state.c
+++ b/src/gallium/drivers/crocus/crocus_state.c
@@ -9079,6 +9079,23 @@ static void update_so_strides(struct crocus_context *ice,
 }
 #endif
 
+static void crocus_fill_clamp_mask(const struct crocus_sampler_state *samp,
+                                   int s,
+                                   uint32_t *clamp_mask)
+{
+#if GFX_VER < 8
+   if (samp->pstate.min_img_filter != PIPE_TEX_FILTER_NEAREST &&
+       samp->pstate.mag_img_filter != PIPE_TEX_FILTER_NEAREST) {
+      if (samp->pstate.wrap_s == PIPE_TEX_WRAP_CLAMP)
+         clamp_mask[0] |= (1 << s);
+      if (samp->pstate.wrap_t == PIPE_TEX_WRAP_CLAMP)
+         clamp_mask[1] |= (1 << s);
+      if (samp->pstate.wrap_r == PIPE_TEX_WRAP_CLAMP)
+         clamp_mask[2] |= (1 << s);
+   }
+#endif
+}
+
 static void
 crocus_set_frontend_noop(struct pipe_context *ctx, bool enable)
 {
@@ -9145,6 +9162,7 @@ genX(crocus_init_screen_state)(struct crocus_screen *screen)
    screen->vtbl.upload_urb_fence = crocus_upload_urb_fence;
    screen->vtbl.calculate_urb_fence = crocus_calculate_urb_fence;
 #endif
+   screen->vtbl.fill_clamp_mask = crocus_fill_clamp_mask;
    screen->vtbl.batch_reset_dirty = crocus_batch_reset_dirty;
    screen->vtbl.translate_prim_type = translate_prim_type;
 #if GFX_VER >= 6



More information about the mesa-commit mailing list