v2: When available, include the opcode name too. (Karol)
v3: Use more to_string helpers. (Karol)
Include the wrong bit_size in those failures.
Include the capability number in spv_check_supported.
Provide vtn_fail_with_* macros to avoid noise in the call sites.
v4: Provide macros only for opcode and decoration, which have enough
usages to justify them. (Jason)
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
- vtn_fail("Unhandled opcode");
+ vtn_fail_with_opcode("Unhandled opcode", opcode);
- vtn_fail("Unhandled decoration");
+ vtn_fail_with_decoration("Unhandled decoration", dec->decoration);
- vtn_fail("Unhandled decoration");
+ vtn_fail_with_decoration("Unhandled decoration", dec->decoration);
case SpvImageFormatR16ui: return 0x8234; /* GL_R16UI */
case SpvImageFormatR8ui: return 0x8232; /* GL_R8UI */
default:
case SpvImageFormatR16ui: return 0x8234; /* GL_R16UI */
case SpvImageFormatR8ui: return 0x8232; /* GL_R8UI */
default:
- vtn_fail("Invalid image format");
+ vtn_fail("Invalid image format: %s (%u)",
+ spirv_imageformat_to_string(format), format);
val->type->type = (signedness ? glsl_int8_t_type() : glsl_uint8_t_type());
break;
default:
val->type->type = (signedness ? glsl_int8_t_type() : glsl_uint8_t_type());
break;
default:
- vtn_fail("Invalid int bit size");
+ vtn_fail("Invalid int bit size: %u", bit_size);
}
val->type->length = 1;
break;
}
val->type->length = 1;
break;
val->type->type = glsl_double_type();
break;
default:
val->type->type = glsl_double_type();
break;
default:
- vtn_fail("Invalid float bit size");
+ vtn_fail("Invalid float bit size: %u", bit_size);
}
val->type->length = 1;
break;
}
val->type->length = 1;
break;
case SpvDimBuffer: dim = GLSL_SAMPLER_DIM_BUF; break;
case SpvDimSubpassData: dim = GLSL_SAMPLER_DIM_SUBPASS; break;
default:
case SpvDimBuffer: dim = GLSL_SAMPLER_DIM_BUF; break;
case SpvDimSubpassData: dim = GLSL_SAMPLER_DIM_SUBPASS; break;
default:
- vtn_fail("Invalid SPIR-V image dimensionality");
+ vtn_fail("Invalid SPIR-V image dimensionality: %s (%u)",
+ spirv_dim_to_string((SpvDim)w[3]), w[3]);
}
/* w[4]: as per Vulkan spec "Validation Rules within a Module",
}
/* w[4]: as per Vulkan spec "Validation Rules within a Module",
case SpvOpTypeQueue:
case SpvOpTypePipe:
default:
case SpvOpTypeQueue:
case SpvOpTypePipe:
default:
- vtn_fail("Unhandled opcode");
+ vtn_fail_with_opcode("Unhandled opcode", opcode);
}
vtn_foreach_decoration(b, val, type_decoration_cb, NULL);
}
vtn_foreach_decoration(b, val, type_decoration_cb, NULL);
val->constant->values[0][0].u8 = w[3];
break;
default:
val->constant->values[0][0].u8 = w[3];
break;
default:
- vtn_fail("Unsupported SpvOpConstant bit size");
+ vtn_fail("Unsupported SpvOpConstant bit size: %u", bit_size);
- vtn_fail("Unhandled opcode");
+ vtn_fail_with_opcode("Unhandled opcode", opcode);
}
/* Now that we have the value, update the workgroup size if needed */
}
/* Now that we have the value, update the workgroup size if needed */
- vtn_fail("Unhandled opcode");
+ vtn_fail_with_opcode("Unhandled opcode", opcode);
}
nir_tex_src srcs[10]; /* 10 should be enough */
}
nir_tex_src srcs[10]; /* 10 should be enough */
case 32: instr->tg4_offsets[i][j] = cvec[j].i32; break;
case 64: instr->tg4_offsets[i][j] = cvec[j].i64; break;
default:
case 32: instr->tg4_offsets[i][j] = cvec[j].i32; break;
case 64: instr->tg4_offsets[i][j] = cvec[j].i64; break;
default:
- vtn_fail("Unsupported bit size");
+ vtn_fail("Unsupported bit size: %u", bit_size);
- vtn_fail("Invalid SPIR-V atomic");
+ vtn_fail_with_opcode("Invalid SPIR-V atomic", opcode);
- vtn_fail("Invalid image opcode");
+ vtn_fail_with_opcode("Invalid image opcode", opcode);
OP(AtomicXor, atomic_xor)
#undef OP
default:
OP(AtomicXor, atomic_xor)
#undef OP
default:
- vtn_fail("Invalid image opcode");
+ vtn_fail_with_opcode("Invalid image opcode", opcode);
}
nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b->shader, op);
}
nir_intrinsic_instr *intrin = nir_intrinsic_instr_create(b->shader, op);
- vtn_fail("Invalid image opcode");
+ vtn_fail_with_opcode("Invalid image opcode", opcode);
}
if (opcode != SpvOpImageWrite && opcode != SpvOpAtomicStore) {
}
if (opcode != SpvOpImageWrite && opcode != SpvOpAtomicStore) {
OP(AtomicXor, atomic_xor)
#undef OP
default:
OP(AtomicXor, atomic_xor)
#undef OP
default:
- vtn_fail("Invalid SSBO atomic");
+ vtn_fail_with_opcode("Invalid SSBO atomic", opcode);
OP(AtomicXor, atomic_xor)
#undef OP
default:
OP(AtomicXor, atomic_xor)
#undef OP
default:
- vtn_fail("Invalid shared atomic");
+ vtn_fail_with_opcode("Invalid shared atomic", opcode);
OP(AtomicXor, atomic_xor)
#undef OP
default:
OP(AtomicXor, atomic_xor)
#undef OP
default:
- vtn_fail("Invalid shared atomic");
+ vtn_fail_with_opcode("Invalid shared atomic", opcode);
- vtn_fail("Invalid SPIR-V atomic");
+ vtn_fail_with_opcode("Invalid SPIR-V atomic", opcode);
- vtn_fail("Invalid SPIR-V atomic");
+ vtn_fail_with_opcode("Invalid SPIR-V atomic", opcode);
}
} else {
nir_deref_instr *deref = vtn_pointer_to_deref(b, ptr);
}
} else {
nir_deref_instr *deref = vtn_pointer_to_deref(b, ptr);
- vtn_fail("Invalid SPIR-V atomic");
+ vtn_fail_with_opcode("Invalid SPIR-V atomic", opcode);
case 2: op = nir_op_vec2; break;
case 3: op = nir_op_vec3; break;
case 4: op = nir_op_vec4; break;
case 2: op = nir_op_vec2; break;
case 3: op = nir_op_vec3; break;
case 4: op = nir_op_vec4; break;
- default: vtn_fail("bad vector size");
+ default: vtn_fail("bad vector size: %u", num_components);
}
nir_alu_instr *vec = nir_alu_instr_create(b->shader, op);
}
nir_alu_instr *vec = nir_alu_instr_create(b->shader, op);
- vtn_fail("unknown composite operation");
+ vtn_fail_with_opcode("unknown composite operation", opcode);
case SpvExecutionModeOutputTriangleStrip:
return 5; /* GL_TRIANGLE_STRIP */
default:
case SpvExecutionModeOutputTriangleStrip:
return 5; /* GL_TRIANGLE_STRIP */
default:
- vtn_fail("Invalid primitive type");
+ vtn_fail("Invalid primitive type: %s (%u)",
+ spirv_executionmode_to_string(mode), mode);
case SpvExecutionModeInputTrianglesAdjacency:
return 6;
default:
case SpvExecutionModeInputTrianglesAdjacency:
return 6;
default:
- vtn_fail("Invalid GS input mode");
+ vtn_fail("Invalid GS input mode: %s (%u)",
+ spirv_executionmode_to_string(mode), mode);
case SpvExecutionModelKernel:
return MESA_SHADER_KERNEL;
default:
case SpvExecutionModelKernel:
return MESA_SHADER_KERNEL;
default:
- vtn_fail("Unsupported execution model");
+ vtn_fail("Unsupported execution model: %s (%u)",
+ spirv_executionmodel_to_string(model), model);
-#define spv_check_supported(name, cap) do { \
- if (!(b->options && b->options->caps.name)) \
- vtn_warn("Unsupported SPIR-V capability: %s", \
- spirv_capability_to_string(cap)); \
+#define spv_check_supported(name, cap) do { \
+ if (!(b->options && b->options->caps.name)) \
+ vtn_warn("Unsupported SPIR-V capability: %s (%u)", \
+ spirv_capability_to_string(cap), cap); \
- vtn_fail("Unhandled capability");
+ vtn_fail("Unhandled capability: %s (%u)",
+ spirv_capability_to_string(cap), cap);
"AddressingModelPhysicalStorageBuffer64EXT not supported");
break;
default:
"AddressingModelPhysicalStorageBuffer64EXT not supported");
break;
default:
- vtn_fail("Unknown addressing model");
+ vtn_fail("Unknown addressing model: %s (%u)",
+ spirv_addressingmodel_to_string(w[1]), w[1]);
- vtn_fail("Unhandled execution mode");
+ vtn_fail("Unhandled execution mode: %s (%u)",
+ spirv_executionmode_to_string(mode->exec_mode),
+ mode->exec_mode);
- vtn_fail("Unhandled opcode");
+ vtn_fail_with_opcode("Unhandled opcode", opcode);
#include <math.h>
#include "vtn_private.h"
#include <math.h>
#include "vtn_private.h"
/*
* Normally, column vectors in SPIR-V correspond to a single NIR SSA
/*
* Normally, column vectors in SPIR-V correspond to a single NIR SSA
- default: vtn_fail("unknown matrix opcode");
+ default: vtn_fail_with_opcode("unknown matrix opcode", opcode);
vtn_fail(__VA_ARGS__); \
} while (0)
vtn_fail(__VA_ARGS__); \
} while (0)
+#define _vtn_fail_with(t, msg, v) \
+ vtn_fail("%s: %s (%u)\n", msg, spirv_ ## t ## _to_string(v), v)
+
+#define vtn_fail_with_decoration(msg, v) _vtn_fail_with(decoration, msg, v)
+#define vtn_fail_with_opcode(msg, v) _vtn_fail_with(op, msg, v)
+
/** Assert that a condition is true and, if it isn't, vtn_fail
*
* This macro is transitional only and should not be used in new code. Use
/** Assert that a condition is true and, if it isn't, vtn_fail
*
* This macro is transitional only and should not be used in new code. Use
set_mode_system_value(b, mode);
break;
default:
set_mode_system_value(b, mode);
break;
default:
- vtn_fail("unsupported builtin: %u", builtin);
+ vtn_fail("Unsupported builtin: %s (%u)",
+ spirv_builtin_to_string(builtin), builtin);
- vtn_fail("Unhandled decoration");
+ vtn_fail_with_decoration("Unhandled decoration", dec->decoration);
break;
case SpvStorageClassGeneric:
default:
break;
case SpvStorageClassGeneric:
default:
- vtn_fail("Unhandled variable storage class");
+ vtn_fail("Unhandled variable storage class: %s (%u)",
+ spirv_storageclass_to_string(class), class);
struct vtn_value *link_val = vtn_untyped_value(b, w[i]);
if (link_val->value_type == vtn_value_type_constant) {
chain->link[idx].mode = vtn_access_mode_literal;
struct vtn_value *link_val = vtn_untyped_value(b, w[i]);
if (link_val->value_type == vtn_value_type_constant) {
chain->link[idx].mode = vtn_access_mode_literal;
- switch (glsl_get_bit_size(link_val->type->type)) {
+ const unsigned bit_size = glsl_get_bit_size(link_val->type->type);
+ switch (bit_size) {
case 8:
chain->link[idx].id = link_val->constant->values[0][0].i8;
break;
case 8:
chain->link[idx].id = link_val->constant->values[0][0].i8;
break;
chain->link[idx].id = link_val->constant->values[0][0].i64;
break;
default:
chain->link[idx].id = link_val->constant->values[0][0].i64;
break;
default:
- vtn_fail("Invalid bit size");
+ vtn_fail("Invalid bit size: %u", bit_size);
}
} else {
chain->link[idx].mode = vtn_access_mode_id;
}
} else {
chain->link[idx].mode = vtn_access_mode_id;
case SpvOpCopyMemorySized:
default:
case SpvOpCopyMemorySized:
default:
- vtn_fail("Unhandled opcode");
+ vtn_fail_with_opcode("Unhandled opcode", opcode);