Mesa (main): zink: clean up const-value handling for get_ssbo_size
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Aug 27 18:54:28 UTC 2021
Module: Mesa
Branch: main
Commit: 2b82f2b78b151b90e1e713b29693e845325493ae
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2b82f2b78b151b90e1e713b29693e845325493ae
Author: Erik Faye-Lund <erik.faye-lund at collabora.com>
Date: Thu Aug 26 11:12:23 2021 +0200
zink: clean up const-value handling for get_ssbo_size
nir_src_as_const_value can return null pointers, and in other places we
at least assert for this. So let's do that here as well, which makes
Coverity a bit less paranoid.
While we're at it, avoid duplicating the nir_src_as_const_value call to
the same source.
CID: 1444291
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12594>
---
src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
index 7ff183ffe14..3ac7fec06f2 100644
--- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
+++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
@@ -2454,9 +2454,11 @@ static void
emit_get_ssbo_size(struct ntv_context *ctx, nir_intrinsic_instr *intr)
{
SpvId uint_type = get_uvec_type(ctx, 32, 1);
- nir_variable *var = ctx->ssbo_vars[nir_src_as_const_value(intr->src[0])->u32];
+ nir_const_value *const_block_index = nir_src_as_const_value(intr->src[0]);
+ assert(const_block_index); // no dynamic indexing for now
+ nir_variable *var = ctx->ssbo_vars[const_block_index->u32];
SpvId result = spirv_builder_emit_binop(&ctx->builder, SpvOpArrayLength, uint_type,
- ctx->ssbos[nir_src_as_const_value(intr->src[0])->u32], 1);
+ ctx->ssbos[const_block_index->u32], 1);
/* this is going to be converted by nir to:
length = (buffer_size - offset) / stride
More information about the mesa-commit
mailing list