spirv: Fix gl_spirv_validation when OpLine with strings is present
authorCaio Oliveira <caio.oliveira@intel.com>
Thu, 11 May 2023 21:33:46 +0000 (14:33 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 17 May 2023 18:27:41 +0000 (18:27 +0000)
Fix issue by handling the OpString instructions when walking through
the preamble for validation.

The gl_spirv_validation() creates a vtn_builder() and walks the
instructions looking for a subset of the information.  However
our current way to walk the instructions will also perform tracking
of OpLine/OpNoLine, that may make references to OpString instructions
that were being previously ignored by gl_spirv_validation().
This would cause the parsing to fail.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9004
Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22973>

src/compiler/spirv/gl_spirv.c

index 5ef3892..9b5e351 100644 (file)
@@ -33,14 +33,22 @@ vtn_validate_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
                                   const uint32_t *w, unsigned count)
 {
    switch (opcode) {
+   case SpvOpString:
    case SpvOpSource:
    case SpvOpSourceExtension:
    case SpvOpSourceContinued:
+   case SpvOpModuleProcessed:
+      /* We need this since vtn_foreach_instruction automatically handles
+       * OpLine / OpNoLine and relies on the SpvOpString from preamble being
+       * handled.
+       */
+      vtn_handle_debug_text(b, opcode, w, count);
+      break;
+
    case SpvOpExtension:
    case SpvOpCapability:
    case SpvOpExtInstImport:
    case SpvOpMemoryModel:
-   case SpvOpString:
    case SpvOpName:
    case SpvOpMemberName:
    case SpvOpExecutionMode: