90679f1dcf
This effectively disables validation of the size of the data provided.
110 lines
4.5 KiB
Diff
110 lines
4.5 KiB
Diff
diff --git a/thirdparty/spirv-reflect/spirv_reflect.c b/thirdparty/spirv-reflect/spirv_reflect.c
|
|
index b4f6bc17c2..c96dd85439 100644
|
|
--- a/thirdparty/spirv-reflect/spirv_reflect.c
|
|
+++ b/thirdparty/spirv-reflect/spirv_reflect.c
|
|
@@ -1571,6 +1571,10 @@ static SpvReflectResult ParseDecorations(SpvReflectPrvParser* p_parser, SpvRefle
|
|
} break;
|
|
|
|
case SpvDecorationSpecId: {
|
|
+// -- GODOT begin --
|
|
+ uint32_t word_offset = p_node->word_offset + member_offset+ 3;
|
|
+ CHECKED_READU32(p_parser, word_offset, p_target_decorations->spec_id);
|
|
+// -- GODOT end --
|
|
spec_constant_count++;
|
|
} break;
|
|
|
|
@@ -1692,21 +1696,45 @@ static SpvReflectResult ParseDecorations(SpvReflectPrvParser* p_parser, SpvRefle
|
|
}
|
|
for (uint32_t i = 0; i < p_parser->node_count; ++i) {
|
|
SpvReflectPrvNode* p_node = &(p_parser->nodes[i]);
|
|
- if (p_node->op == SpvOpDecorate) {
|
|
- uint32_t decoration = (uint32_t)INVALID_VALUE;
|
|
- CHECKED_READU32(p_parser, p_node->word_offset + 2, decoration);
|
|
- if (decoration == SpvDecorationSpecId) {
|
|
- const uint32_t count = p_module->spec_constant_count;
|
|
- CHECKED_READU32(p_parser, p_node->word_offset + 1, p_module->spec_constants[count].spirv_id);
|
|
- CHECKED_READU32(p_parser, p_node->word_offset + 3, p_module->spec_constants[count].constant_id);
|
|
- // If being used for a OpSpecConstantComposite (ex. LocalSizeId), there won't be a name
|
|
- SpvReflectPrvNode* target_node = FindNode(p_parser, p_module->spec_constants[count].spirv_id);
|
|
- if (IsNotNull(target_node)) {
|
|
- p_module->spec_constants[count].name = target_node->name;
|
|
+// -- GODOT begin --
|
|
+ const uint32_t count = p_module->spec_constant_count;
|
|
+ switch(p_node->op) {
|
|
+ default: continue;
|
|
+ case SpvOpSpecConstantTrue: {
|
|
+ p_module->spec_constants[count].constant_type = SPV_REFLECT_SPECIALIZATION_CONSTANT_BOOL;
|
|
+ p_module->spec_constants[count].default_value.int_bool_value = 1;
|
|
+ } break;
|
|
+ case SpvOpSpecConstantFalse: {
|
|
+ p_module->spec_constants[count].constant_type = SPV_REFLECT_SPECIALIZATION_CONSTANT_BOOL;
|
|
+ p_module->spec_constants[count].default_value.int_bool_value = 0;
|
|
+ } break;
|
|
+ case SpvOpSpecConstant: {
|
|
+ SpvReflectResult result = SPV_REFLECT_RESULT_SUCCESS;
|
|
+ uint32_t element_type_id = (uint32_t)INVALID_VALUE;
|
|
+ uint32_t default_value = 0;
|
|
+ CHECKED_READU32(p_parser, p_node->word_offset + 1, element_type_id);
|
|
+ CHECKED_READU32(p_parser, p_node->word_offset + 3, default_value);
|
|
+
|
|
+ SpvReflectPrvNode* p_next_node = FindNode(p_parser, element_type_id);
|
|
+
|
|
+ if (p_next_node->op == SpvOpTypeInt) {
|
|
+ p_module->spec_constants[count].constant_type = SPV_REFLECT_SPECIALIZATION_CONSTANT_INT;
|
|
+ } else if (p_next_node->op == SpvOpTypeFloat) {
|
|
+ p_module->spec_constants[count].constant_type = SPV_REFLECT_SPECIALIZATION_CONSTANT_FLOAT;
|
|
+ } else {
|
|
+ return SPV_REFLECT_RESULT_ERROR_PARSE_FAILED;
|
|
}
|
|
- p_module->spec_constant_count++;
|
|
- }
|
|
+
|
|
+ p_module->spec_constants[count].default_value.int_bool_value = default_value; //bits are the same for int and float
|
|
+ } break;
|
|
}
|
|
+
|
|
+ p_module->spec_constants[count].name = p_node->name;
|
|
+ p_module->spec_constants[count].constant_id = p_node->decorations.spec_id;
|
|
+ p_module->spec_constants[count].spirv_id = p_node->result_id;
|
|
+
|
|
+ p_module->spec_constant_count++;
|
|
+// -- GODOT end --
|
|
}
|
|
|
|
return SPV_REFLECT_RESULT_SUCCESS;
|
|
diff --git a/thirdparty/spirv-reflect/spirv_reflect.h b/thirdparty/spirv-reflect/spirv_reflect.h
|
|
index 9a42f14eed..4ea0319c5e 100644
|
|
--- a/thirdparty/spirv-reflect/spirv_reflect.h
|
|
+++ b/thirdparty/spirv-reflect/spirv_reflect.h
|
|
@@ -568,6 +568,17 @@ typedef struct SpvReflectCapability {
|
|
} SpvReflectCapability;
|
|
|
|
|
|
+// -- GODOT begin --
|
|
+/*! @enum SpvReflectSpecializationConstantType
|
|
+
|
|
+*/
|
|
+typedef enum SpvReflectSpecializationConstantType {
|
|
+ SPV_REFLECT_SPECIALIZATION_CONSTANT_BOOL = 0,
|
|
+ SPV_REFLECT_SPECIALIZATION_CONSTANT_INT = 1,
|
|
+ SPV_REFLECT_SPECIALIZATION_CONSTANT_FLOAT = 2,
|
|
+} SpvReflectSpecializationConstantType;
|
|
+// -- GODOT end --
|
|
+
|
|
/*! @struct SpvReflectSpecId
|
|
|
|
*/
|
|
@@ -575,6 +586,13 @@ typedef struct SpvReflectSpecializationConstant {
|
|
uint32_t spirv_id;
|
|
uint32_t constant_id;
|
|
const char* name;
|
|
+// -- GODOT begin --
|
|
+ SpvReflectSpecializationConstantType constant_type;
|
|
+ union {
|
|
+ float float_value;
|
|
+ uint32_t int_bool_value;
|
|
+ } default_value;
|
|
+// -- GODOT end --
|
|
} SpvReflectSpecializationConstant;
|
|
|
|
/*! @struct SpvReflectShaderModule
|