Module: Mesa
Branch: staging/22.2
Commit: cbcf1bb4d815314290c56d0b27a7afe8a30cf15c
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=cbcf1bb4d815314290c56d0b27a7afe8a30cf15c

Author: Erik Faye-Lund <[email protected]>
Date:   Mon Aug 29 15:50:54 2022 +0200

zink: clamp miplodbias when creating sampler

The Vulkan spec states that it's illegal to pass a mipLodBias larger
than maxSamplerLodBias, but the gallium value here hasn't been clamped.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7140
Cc: mesa-stable
Reviewed-by: Mike Blumenkrantz <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18295>
(cherry picked from commit c551bb32d16c7abe27a5c2ee65c441c27fac9821)

---

 .pick_status.json                                  | 2 +-
 src/gallium/drivers/zink/ci/zink-tu-a630-fails.txt | 1 -
 src/gallium/drivers/zink/zink_context.c            | 5 ++++-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index b0fcc474973..6d2e97852a6 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -4252,7 +4252,7 @@
         "description": "zink: clamp miplodbias when creating sampler",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/drivers/zink/ci/zink-tu-a630-fails.txt 
b/src/gallium/drivers/zink/ci/zink-tu-a630-fails.txt
index 70654ce212d..7e0d984e138 100644
--- a/src/gallium/drivers/zink/ci/zink-tu-a630-fails.txt
+++ b/src/gallium/drivers/zink/ci/zink-tu-a630-fails.txt
@@ -1,4 +1,3 @@
-GTF-GL46.gtf21.GL3Tests.texture_lod_bias.texture_lod_bias_all,Fail
 
GTF-GL46.gtf30.GL3Tests.framebuffer_blit.framebuffer_blit_functionality_multisampled_to_singlesampled_blit,Fail
 
GTF-GL46.gtf30.GL3Tests.sgis_texture_lod.sgis_texture_lod_basic_lod_selection,Fail
 
GTF-GL46.gtf32.GL3Tests.draw_elements_base_vertex.draw_elements_base_vertex_invalid_mode,Fail
diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index 7ebfbaa2d26..1bb8a4dd6b7 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -384,7 +384,10 @@ zink_create_sampler_state(struct pipe_context *pctx,
    } else {
       sci.addressModeU = sci.addressModeV = sci.addressModeW = 
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
    }
-   sci.mipLodBias = state->lod_bias;
+
+   sci.mipLodBias = CLAMP(state->lod_bias,
+                          -screen->info.props.limits.maxSamplerLodBias,
+                          screen->info.props.limits.maxSamplerLodBias);
 
    need_custom |= wrap_needs_border_color(state->wrap_s);
    need_custom |= wrap_needs_border_color(state->wrap_t);

Reply via email to