From: Jason Ekstrand Date: Thu, 31 Dec 2015 00:35:34 +0000 (-0800) Subject: nir/spirv: Separate handling of preamble from type/var/const instructions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2b6bcaf91ab4f3dd7b9a31013725078a38db966d;p=mesa.git nir/spirv: Separate handling of preamble from type/var/const instructions --- diff --git a/src/glsl/nir/spirv/spirv_to_nir.c b/src/glsl/nir/spirv/spirv_to_nir.c index b6f5dd761bb..fd7e9e8dbc1 100644 --- a/src/glsl/nir/spirv/spirv_to_nir.c +++ b/src/glsl/nir/spirv/spirv_to_nir.c @@ -3319,6 +3319,38 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode, vtn_handle_decoration(b, opcode, w, count); break; + default: + return false; /* End of preamble */ + } + + return true; +} + +static bool +vtn_handle_variable_or_type_instruction(struct vtn_builder *b, SpvOp opcode, + const uint32_t *w, unsigned count) +{ + switch (opcode) { + case SpvOpSource: + case SpvOpSourceExtension: + case SpvOpExtension: + case SpvOpCapability: + case SpvOpExtInstImport: + case SpvOpMemoryModel: + case SpvOpEntryPoint: + case SpvOpExecutionMode: + case SpvOpString: + case SpvOpName: + case SpvOpMemberName: + case SpvOpLine: + case SpvOpDecorationGroup: + case SpvOpDecorate: + case SpvOpMemberDecorate: + case SpvOpGroupDecorate: + case SpvOpGroupMemberDecorate: + assert(!"Invalid opcode types and variables section"); + break; + case SpvOpTypeVoid: case SpvOpTypeBool: case SpvOpTypeInt: @@ -3617,6 +3649,10 @@ spirv_to_nir(const uint32_t *words, size_t word_count, words = vtn_foreach_instruction(b, words, word_end, vtn_handle_preamble_instruction); + /* Handle all variable, type, and constant instructions */ + words = vtn_foreach_instruction(b, words, word_end, + vtn_handle_variable_or_type_instruction); + vtn_build_cfg(b, words, word_end); foreach_list_typed(struct vtn_function, func, node, &b->functions) {