Module: Mesa Branch: main Commit: 4d3703c12df0d3a2f4b660024fe434536e9fb234 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4d3703c12df0d3a2f4b660024fe434536e9fb234
Author: Caio Oliveira <[email protected]> Date: Thu Sep 28 00:05:08 2023 -0700 spirv: Expose stage enum conversion in vtn_private.h Refactor it to not fail, just return MESA_SHADER_NONE. Caller takes care of handling error. Exposed so can be used by spirv2nir program. Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25461> --- src/compiler/spirv/spirv_to_nir.c | 13 ++++++++----- src/compiler/spirv/vtn_private.h | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 5b20c5cf985..068daeabbce 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -4540,8 +4540,8 @@ vertices_in_from_spv_execution_mode(struct vtn_builder *b, } } -static gl_shader_stage -stage_for_execution_model(struct vtn_builder *b, SpvExecutionModel model) +gl_shader_stage +vtn_stage_for_execution_model(SpvExecutionModel model) { switch (model) { case SpvExecutionModelVertex: @@ -4577,8 +4577,7 @@ stage_for_execution_model(struct vtn_builder *b, SpvExecutionModel model) case SpvExecutionModelMeshEXT: return MESA_SHADER_MESH; default: - vtn_fail("Unsupported execution model: %s (%u)", - spirv_executionmodel_to_string(model), model); + return MESA_SHADER_NONE; } } @@ -4598,8 +4597,12 @@ vtn_handle_entry_point(struct vtn_builder *b, const uint32_t *w, unsigned name_words; entry_point->name = vtn_string_literal(b, &w[3], count - 3, &name_words); + gl_shader_stage stage = vtn_stage_for_execution_model(w[1]); + vtn_fail_if(stage == MESA_SHADER_NONE, + "Unsupported execution model: %s (%u)", + spirv_executionmodel_to_string(w[1]), w[1]); if (strcmp(entry_point->name, b->entry_point_name) != 0 || - stage_for_execution_model(b, w[1]) != b->entry_point_stage) + stage != b->entry_point_stage) return; vtn_assert(b->entry_point == NULL); diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h index 02fe2f26ae8..6daffa3181f 100644 --- a/src/compiler/spirv/vtn_private.h +++ b/src/compiler/spirv/vtn_private.h @@ -1071,4 +1071,6 @@ struct vtn_ssa_value *vtn_cooperative_matrix_insert(struct vtn_builder *b, struc nir_deref_instr *vtn_create_cmat_temporary(struct vtn_builder *b, const struct glsl_type *t, const char *name); +gl_shader_stage vtn_stage_for_execution_model(SpvExecutionModel model); + #endif /* _VTN_PRIVATE_H_ */
