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

Author: Erik Faye-Lund <[email protected]>
Date:   Mon Mar 29 15:24:31 2021 +0200

zink: assert that pstage is within range

This makes it clearer that these don't include the compute-stage.

Reviewed-By: Mike Blumenkrantz <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9898>

---

 src/gallium/drivers/zink/zink_compiler.c | 1 +
 src/gallium/drivers/zink/zink_program.c  | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/zink/zink_compiler.c 
b/src/gallium/drivers/zink/zink_compiler.c
index 30ea6a11d47..36887a24c99 100644
--- a/src/gallium/drivers/zink/zink_compiler.c
+++ b/src/gallium/drivers/zink/zink_compiler.c
@@ -856,6 +856,7 @@ zink_shader_free(struct zink_context *ctx, struct 
zink_shader *shader)
       } else {
          struct zink_gfx_program *prog = (void*)entry->key;
          enum pipe_shader_type pstage = 
pipe_shader_type_from_mesa(shader->nir->info.stage);
+         assert(pstage < ZINK_SHADER_COUNT);
          bool in_use = prog == ctx->curr_program;
          if (shader->nir->info.stage != MESA_SHADER_TESS_CTRL || 
!shader->is_generated)
             _mesa_hash_table_remove_key(ctx->program_cache, prog->shaders);
diff --git a/src/gallium/drivers/zink/zink_program.c 
b/src/gallium/drivers/zink/zink_program.c
index 41ad4c5dc6b..e2f55c867c5 100644
--- a/src/gallium/drivers/zink/zink_program.c
+++ b/src/gallium/drivers/zink/zink_program.c
@@ -374,6 +374,7 @@ update_shader_modules(struct zink_context *ctx, struct 
zink_shader *stages[ZINK_
 
    for (int i = 0; i < ZINK_SHADER_COUNT; ++i) {
       enum pipe_shader_type type = pipe_shader_type_from_mesa(i);
+      assert(type < ZINK_SHADER_COUNT);
       if (dirty[i]) {
          struct zink_shader_module *zm;
          zm = get_shader_module_for_stage(ctx, dirty[i], prog);
@@ -790,7 +791,7 @@ static void
 gfx_program_remove_shader(struct zink_gfx_program *prog, struct zink_shader 
*shader)
 {
    enum pipe_shader_type p_stage = 
pipe_shader_type_from_mesa(shader->nir->info.stage);
-
+   assert(p_stage < ZINK_SHADER_COUNT);
    assert(prog->shaders[p_stage] == shader);
    prog->shaders[p_stage] = NULL;
    _mesa_set_remove_key(shader->programs, prog);

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to