summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWitold Baryluk <witold.baryluk@gmail.com>2020-12-07 20:30:32 +0000
committerDylan Baker <dylan.c.baker@intel.com>2020-12-09 19:33:58 -0800
commitbd32ac29bbbe26e035c76a0d85c664be4c3ec0e4 (patch)
tree957a225933f9a3eb712b98e313921943398ccf23
parent5a468a3ca226ba0248248e83827a433185212fc3 (diff)
zink: Cap PIPE_SHADER_CAP_MAX_CONST_BUFFERS to 32
PIPE_MAX_CONSTANT_BUFFERS is 32, however many Vulkan implementations has maxPerStageDescriptorUniformBuffers that exceeds it, for example: radv 8388606, anv 64 nvidia 1048580 for RTX 2000 and up. and, together with the current zink logic, the returned value will exceed the maximum allowed value for the cap. This causes cso_destroy_context to pass big values back to zink (via zink_set_constant_buffer), resulting in access beyond end of allocated buffer for all UBOs. Cap the cap to PIPE_MAX_CONSTANT_BUFFERS (32), not INT_MAX. Add an assert to verify future drivers. Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Fixes: daaf5f1d186 ("gallium: Fix leak of currently bound UBOs at CSO context destruction.") Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7976> (cherry picked from commit e2b4247e403957ebd9767b2e8700442306c7e7c6)
-rw-r--r--.pick_status.json2
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c1
-rw-r--r--src/gallium/drivers/zink/zink_screen.c3
3 files changed, 4 insertions, 2 deletions
diff --git a/.pick_status.json b/.pick_status.json
index 755231fb9e2..c32a538a235 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -1120,7 +1120,7 @@
"description": "zink: Cap PIPE_SHADER_CAP_MAX_CONST_BUFFERS to 32",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "daaf5f1d1868bebec7931a51753236a850ebbd24"
},
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index df040ee6372..1eef6aac70c 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -405,6 +405,7 @@ void cso_destroy_context( struct cso_context *ctx )
assert(maxsam <= PIPE_MAX_SAMPLERS);
assert(maxview <= PIPE_MAX_SHADER_SAMPLER_VIEWS);
assert(maxssbo <= PIPE_MAX_SHADER_BUFFERS);
+ assert(maxcb <= PIPE_MAX_CONSTANT_BUFFERS);
if (maxsam > 0) {
ctx->pipe->bind_sampler_states(ctx->pipe, sh, 0, maxsam, zeros);
}
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 3c1c4d936d1..f85954104e7 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -415,7 +415,8 @@ zink_get_shader_param(struct pipe_screen *pscreen,
return MIN2(screen->props.limits.maxUniformBufferRange, INT_MAX);
case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
- return screen->props.limits.maxPerStageDescriptorUniformBuffers;
+ return MIN2(screen->props.limits.maxPerStageDescriptorUniformBuffers,
+ PIPE_MAX_CONSTANT_BUFFERS);
case PIPE_SHADER_CAP_MAX_TEMPS:
return INT_MAX;