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

Author: Mike Blumenkrantz <[email protected]>
Date:   Fri Apr  8 13:24:32 2022 -0400

zink: clamp out partial texels when creating bufferviews

this is an illegal alignment, so clamp the range to the nearest
texel offset since the shader should be hitting the robustness
case for the partial texel

affects:
dEQP-GLES31.functional.texture.texture_buffer.modify.mapbuffer_readwrite.range_size_65537

Reviewed-by: Dave Airlie <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15827>

---

 src/gallium/drivers/zink/zink_context.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/zink/zink_context.c 
b/src/gallium/drivers/zink/zink_context.c
index 987f9bbb855..363096f1c30 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -701,7 +701,14 @@ create_bvci(struct zink_context *ctx, struct zink_resource 
*res, enum pipe_forma
    assert(bvci.format);
    bvci.offset = offset;
    bvci.range = !offset && range == res->base.b.width0 ? VK_WHOLE_SIZE : range;
-   uint32_t clamp = util_format_get_blocksize(format) * 
screen->info.props.limits.maxTexelBufferElements;
+   unsigned blocksize = util_format_get_blocksize(format);
+   if (bvci.range != VK_WHOLE_SIZE) {
+      /* clamp out partial texels */
+      bvci.range -= bvci.range % blocksize;
+      if (bvci.offset + bvci.range >= res->base.b.width0)
+         bvci.range = VK_WHOLE_SIZE;
+   }
+   uint32_t clamp = blocksize * 
screen->info.props.limits.maxTexelBufferElements;
    if (bvci.range == VK_WHOLE_SIZE && res->base.b.width0 > clamp)
       bvci.range = clamp;
    bvci.flags = 0;

Reply via email to