spirv-reflect: Update to latest commit

This commit is contained in:
Pedro J. Estébanez
2022-07-08 22:18:51 +02:00
parent 99df193bea
commit 02e102911f
5 changed files with 147 additions and 23 deletions

View File

@ -597,7 +597,7 @@ Godot. See the patch in the `patches` folder for details.
## spirv-reflect ## spirv-reflect
- Upstream: https://github.com/KhronosGroup/SPIRV-Reflect - Upstream: https://github.com/KhronosGroup/SPIRV-Reflect
- Version: git (1aceb6af56e74b92a00378842dda5c5a73f49a4b, 2022) - Version: git (1ef99b09fa7ce5aee2c5cf70c61a4f7458d27e09, 2022)
- License: Apache 2.0 - License: Apache 2.0
Does not track Vulkan SDK releases closely, but try to package a commit newer Does not track Vulkan SDK releases closely, but try to package a commit newer

View File

@ -70,6 +70,7 @@ typedef enum SpvSourceLanguage_ {
SpvSourceLanguageOpenCL_CPP = 4, SpvSourceLanguageOpenCL_CPP = 4,
SpvSourceLanguageHLSL = 5, SpvSourceLanguageHLSL = 5,
SpvSourceLanguageCPP_for_OpenCL = 6, SpvSourceLanguageCPP_for_OpenCL = 6,
SpvSourceLanguageSYCL = 7,
SpvSourceLanguageMax = 0x7fffffff, SpvSourceLanguageMax = 0x7fffffff,
} SpvSourceLanguage; } SpvSourceLanguage;
@ -184,6 +185,7 @@ typedef enum SpvExecutionMode_ {
SpvExecutionModeNoGlobalOffsetINTEL = 5895, SpvExecutionModeNoGlobalOffsetINTEL = 5895,
SpvExecutionModeNumSIMDWorkitemsINTEL = 5896, SpvExecutionModeNumSIMDWorkitemsINTEL = 5896,
SpvExecutionModeSchedulerTargetFmaxMhzINTEL = 5903, SpvExecutionModeSchedulerTargetFmaxMhzINTEL = 5903,
SpvExecutionModeNamedBarrierCountINTEL = 6417,
SpvExecutionModeMax = 0x7fffffff, SpvExecutionModeMax = 0x7fffffff,
} SpvExecutionMode; } SpvExecutionMode;
@ -546,6 +548,8 @@ typedef enum SpvDecoration_ {
SpvDecorationPrefetchINTEL = 5902, SpvDecorationPrefetchINTEL = 5902,
SpvDecorationStallEnableINTEL = 5905, SpvDecorationStallEnableINTEL = 5905,
SpvDecorationFuseLoopsInFunctionINTEL = 5907, SpvDecorationFuseLoopsInFunctionINTEL = 5907,
SpvDecorationAliasScopeINTEL = 5914,
SpvDecorationNoAliasINTEL = 5915,
SpvDecorationBufferLocationINTEL = 5921, SpvDecorationBufferLocationINTEL = 5921,
SpvDecorationIOPipeStorageINTEL = 5944, SpvDecorationIOPipeStorageINTEL = 5944,
SpvDecorationFunctionFloatingPointModeINTEL = 6080, SpvDecorationFunctionFloatingPointModeINTEL = 6080,
@ -677,6 +681,7 @@ typedef enum SpvBuiltIn_ {
SpvBuiltInSMCountNV = 5375, SpvBuiltInSMCountNV = 5375,
SpvBuiltInWarpIDNV = 5376, SpvBuiltInWarpIDNV = 5376,
SpvBuiltInSMIDNV = 5377, SpvBuiltInSMIDNV = 5377,
SpvBuiltInCullMaskKHR = 6021,
SpvBuiltInMax = 0x7fffffff, SpvBuiltInMax = 0x7fffffff,
} SpvBuiltIn; } SpvBuiltIn;
@ -804,6 +809,8 @@ typedef enum SpvMemoryAccessShift_ {
SpvMemoryAccessMakePointerVisibleKHRShift = 4, SpvMemoryAccessMakePointerVisibleKHRShift = 4,
SpvMemoryAccessNonPrivatePointerShift = 5, SpvMemoryAccessNonPrivatePointerShift = 5,
SpvMemoryAccessNonPrivatePointerKHRShift = 5, SpvMemoryAccessNonPrivatePointerKHRShift = 5,
SpvMemoryAccessAliasScopeINTELMaskShift = 16,
SpvMemoryAccessNoAliasINTELMaskShift = 17,
SpvMemoryAccessMax = 0x7fffffff, SpvMemoryAccessMax = 0x7fffffff,
} SpvMemoryAccessShift; } SpvMemoryAccessShift;
@ -818,6 +825,8 @@ typedef enum SpvMemoryAccessMask_ {
SpvMemoryAccessMakePointerVisibleKHRMask = 0x00000010, SpvMemoryAccessMakePointerVisibleKHRMask = 0x00000010,
SpvMemoryAccessNonPrivatePointerMask = 0x00000020, SpvMemoryAccessNonPrivatePointerMask = 0x00000020,
SpvMemoryAccessNonPrivatePointerKHRMask = 0x00000020, SpvMemoryAccessNonPrivatePointerKHRMask = 0x00000020,
SpvMemoryAccessAliasScopeINTELMaskMask = 0x00010000,
SpvMemoryAccessNoAliasINTELMaskMask = 0x00020000,
} SpvMemoryAccessMask; } SpvMemoryAccessMask;
typedef enum SpvScope_ { typedef enum SpvScope_ {
@ -1059,6 +1068,7 @@ typedef enum SpvCapability_ {
SpvCapabilityFPGAMemoryAccessesINTEL = 5898, SpvCapabilityFPGAMemoryAccessesINTEL = 5898,
SpvCapabilityFPGAClusterAttributesINTEL = 5904, SpvCapabilityFPGAClusterAttributesINTEL = 5904,
SpvCapabilityLoopFuseINTEL = 5906, SpvCapabilityLoopFuseINTEL = 5906,
SpvCapabilityMemoryAccessAliasingINTEL = 5910,
SpvCapabilityFPGABufferLocationINTEL = 5920, SpvCapabilityFPGABufferLocationINTEL = 5920,
SpvCapabilityArbitraryPrecisionFixedPointINTEL = 5922, SpvCapabilityArbitraryPrecisionFixedPointINTEL = 5922,
SpvCapabilityUSMStorageClassesINTEL = 5935, SpvCapabilityUSMStorageClassesINTEL = 5935,
@ -1073,13 +1083,17 @@ typedef enum SpvCapability_ {
SpvCapabilityDotProductInput4x8BitPackedKHR = 6018, SpvCapabilityDotProductInput4x8BitPackedKHR = 6018,
SpvCapabilityDotProduct = 6019, SpvCapabilityDotProduct = 6019,
SpvCapabilityDotProductKHR = 6019, SpvCapabilityDotProductKHR = 6019,
SpvCapabilityRayCullMaskKHR = 6020,
SpvCapabilityBitInstructions = 6025, SpvCapabilityBitInstructions = 6025,
SpvCapabilityGroupNonUniformRotateKHR = 6026,
SpvCapabilityAtomicFloat32AddEXT = 6033, SpvCapabilityAtomicFloat32AddEXT = 6033,
SpvCapabilityAtomicFloat64AddEXT = 6034, SpvCapabilityAtomicFloat64AddEXT = 6034,
SpvCapabilityLongConstantCompositeINTEL = 6089, SpvCapabilityLongConstantCompositeINTEL = 6089,
SpvCapabilityOptNoneINTEL = 6094, SpvCapabilityOptNoneINTEL = 6094,
SpvCapabilityAtomicFloat16AddEXT = 6095, SpvCapabilityAtomicFloat16AddEXT = 6095,
SpvCapabilityDebugInfoModuleINTEL = 6114, SpvCapabilityDebugInfoModuleINTEL = 6114,
SpvCapabilitySplitBarrierINTEL = 6141,
SpvCapabilityGroupUniformArithmeticKHR = 6400,
SpvCapabilityMax = 0x7fffffff, SpvCapabilityMax = 0x7fffffff,
} SpvCapability; } SpvCapability;
@ -1535,6 +1549,7 @@ typedef enum SpvOp_ {
SpvOpSubgroupAllKHR = 4428, SpvOpSubgroupAllKHR = 4428,
SpvOpSubgroupAnyKHR = 4429, SpvOpSubgroupAnyKHR = 4429,
SpvOpSubgroupAllEqualKHR = 4430, SpvOpSubgroupAllEqualKHR = 4430,
SpvOpGroupNonUniformRotateKHR = 4431,
SpvOpSubgroupReadInvocationKHR = 4432, SpvOpSubgroupReadInvocationKHR = 4432,
SpvOpTraceRayKHR = 4445, SpvOpTraceRayKHR = 4445,
SpvOpExecuteCallableKHR = 4446, SpvOpExecuteCallableKHR = 4446,
@ -1801,6 +1816,9 @@ typedef enum SpvOp_ {
SpvOpArbitraryFloatPowRINTEL = 5881, SpvOpArbitraryFloatPowRINTEL = 5881,
SpvOpArbitraryFloatPowNINTEL = 5882, SpvOpArbitraryFloatPowNINTEL = 5882,
SpvOpLoopControlINTEL = 5887, SpvOpLoopControlINTEL = 5887,
SpvOpAliasDomainDeclINTEL = 5911,
SpvOpAliasScopeDeclINTEL = 5912,
SpvOpAliasScopeListDeclINTEL = 5913,
SpvOpFixedSqrtINTEL = 5923, SpvOpFixedSqrtINTEL = 5923,
SpvOpFixedRecipINTEL = 5924, SpvOpFixedRecipINTEL = 5924,
SpvOpFixedRsqrtINTEL = 5925, SpvOpFixedRsqrtINTEL = 5925,
@ -1839,10 +1857,23 @@ typedef enum SpvOp_ {
SpvOpTypeStructContinuedINTEL = 6090, SpvOpTypeStructContinuedINTEL = 6090,
SpvOpConstantCompositeContinuedINTEL = 6091, SpvOpConstantCompositeContinuedINTEL = 6091,
SpvOpSpecConstantCompositeContinuedINTEL = 6092, SpvOpSpecConstantCompositeContinuedINTEL = 6092,
SpvOpControlBarrierArriveINTEL = 6142,
SpvOpControlBarrierWaitINTEL = 6143,
SpvOpGroupIMulKHR = 6401,
SpvOpGroupFMulKHR = 6402,
SpvOpGroupBitwiseAndKHR = 6403,
SpvOpGroupBitwiseOrKHR = 6404,
SpvOpGroupBitwiseXorKHR = 6405,
SpvOpGroupLogicalAndKHR = 6406,
SpvOpGroupLogicalOrKHR = 6407,
SpvOpGroupLogicalXorKHR = 6408,
SpvOpMax = 0x7fffffff, SpvOpMax = 0x7fffffff,
} SpvOp; } SpvOp;
#ifdef SPV_ENABLE_UTILITY_CODE #ifdef SPV_ENABLE_UTILITY_CODE
#ifndef __cplusplus
#include <stdbool.h>
#endif
inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultType) { inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultType) {
*hasResult = *hasResultType = false; *hasResult = *hasResultType = false;
switch (opcode) { switch (opcode) {
@ -2197,6 +2228,7 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy
case SpvOpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupAllKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpSubgroupAnyKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupAnyKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpSubgroupAllEqualKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupAllEqualKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupNonUniformRotateKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpSubgroupReadInvocationKHR: *hasResult = true; *hasResultType = true; break; case SpvOpSubgroupReadInvocationKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpTraceRayKHR: *hasResult = false; *hasResultType = false; break; case SpvOpTraceRayKHR: *hasResult = false; *hasResultType = false; break;
case SpvOpExecuteCallableKHR: *hasResult = false; *hasResultType = false; break; case SpvOpExecuteCallableKHR: *hasResult = false; *hasResultType = false; break;
@ -2452,6 +2484,9 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy
case SpvOpArbitraryFloatPowRINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpArbitraryFloatPowRINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpArbitraryFloatPowNINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpArbitraryFloatPowNINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpLoopControlINTEL: *hasResult = false; *hasResultType = false; break; case SpvOpLoopControlINTEL: *hasResult = false; *hasResultType = false; break;
case SpvOpAliasDomainDeclINTEL: *hasResult = true; *hasResultType = false; break;
case SpvOpAliasScopeDeclINTEL: *hasResult = true; *hasResultType = false; break;
case SpvOpAliasScopeListDeclINTEL: *hasResult = true; *hasResultType = false; break;
case SpvOpFixedSqrtINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpFixedSqrtINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpFixedRecipINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpFixedRecipINTEL: *hasResult = true; *hasResultType = true; break;
case SpvOpFixedRsqrtINTEL: *hasResult = true; *hasResultType = true; break; case SpvOpFixedRsqrtINTEL: *hasResult = true; *hasResultType = true; break;
@ -2490,9 +2525,18 @@ inline void SpvHasResultAndType(SpvOp opcode, bool *hasResult, bool *hasResultTy
case SpvOpTypeStructContinuedINTEL: *hasResult = false; *hasResultType = false; break; case SpvOpTypeStructContinuedINTEL: *hasResult = false; *hasResultType = false; break;
case SpvOpConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; case SpvOpConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break;
case SpvOpSpecConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break; case SpvOpSpecConstantCompositeContinuedINTEL: *hasResult = false; *hasResultType = false; break;
case SpvOpControlBarrierArriveINTEL: *hasResult = false; *hasResultType = false; break;
case SpvOpControlBarrierWaitINTEL: *hasResult = false; *hasResultType = false; break;
case SpvOpGroupIMulKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupFMulKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupBitwiseAndKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupBitwiseOrKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupBitwiseXorKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupLogicalAndKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupLogicalOrKHR: *hasResult = true; *hasResultType = true; break;
case SpvOpGroupLogicalXorKHR: *hasResult = true; *hasResultType = true; break;
} }
} }
#endif /* SPV_ENABLE_UTILITY_CODE */ #endif /* SPV_ENABLE_UTILITY_CODE */
#endif #endif

View File

@ -1,8 +1,8 @@
diff --git a/thirdparty/spirv-reflect/spirv_reflect.c b/thirdparty/spirv-reflect/spirv_reflect.c diff --git a/thirdparty/spirv-reflect/spirv_reflect.c b/thirdparty/spirv-reflect/spirv_reflect.c
index e9b11bf495..f181df5fa2 100644 index cdcf3ca663..c174ae1900 100644
--- a/thirdparty/spirv-reflect/spirv_reflect.c --- a/thirdparty/spirv-reflect/spirv_reflect.c
+++ b/thirdparty/spirv-reflect/spirv_reflect.c +++ b/thirdparty/spirv-reflect/spirv_reflect.c
@@ -125,6 +125,9 @@ typedef struct SpvReflectPrvDecorations { @@ -126,6 +126,9 @@ typedef struct SpvReflectPrvDecorations {
SpvReflectPrvNumberDecoration location; SpvReflectPrvNumberDecoration location;
SpvReflectPrvNumberDecoration offset; SpvReflectPrvNumberDecoration offset;
SpvReflectPrvNumberDecoration uav_counter_buffer; SpvReflectPrvNumberDecoration uav_counter_buffer;
@ -12,7 +12,7 @@ index e9b11bf495..f181df5fa2 100644
SpvReflectPrvStringDecoration semantic; SpvReflectPrvStringDecoration semantic;
uint32_t array_stride; uint32_t array_stride;
uint32_t matrix_stride; uint32_t matrix_stride;
@@ -631,6 +634,9 @@ static SpvReflectResult ParseNodes(SpvReflectPrvParser* p_parser) @@ -639,6 +642,9 @@ static SpvReflectResult ParseNodes(SpvReflectPrvParser* p_parser)
p_parser->nodes[i].decorations.offset.value = (uint32_t)INVALID_VALUE; p_parser->nodes[i].decorations.offset.value = (uint32_t)INVALID_VALUE;
p_parser->nodes[i].decorations.uav_counter_buffer.value = (uint32_t)INVALID_VALUE; p_parser->nodes[i].decorations.uav_counter_buffer.value = (uint32_t)INVALID_VALUE;
p_parser->nodes[i].decorations.built_in = (SpvBuiltIn)INVALID_VALUE; p_parser->nodes[i].decorations.built_in = (SpvBuiltIn)INVALID_VALUE;
@ -22,7 +22,7 @@ index e9b11bf495..f181df5fa2 100644
} }
// Mark source file id node // Mark source file id node
p_parser->source_file_id = (uint32_t)INVALID_VALUE; p_parser->source_file_id = (uint32_t)INVALID_VALUE;
@@ -821,10 +827,16 @@ static SpvReflectResult ParseNodes(SpvReflectPrvParser* p_parser) @@ -829,10 +835,16 @@ static SpvReflectResult ParseNodes(SpvReflectPrvParser* p_parser)
CHECKED_READU32(p_parser, p_node->word_offset + 2, p_node->result_id); CHECKED_READU32(p_parser, p_node->word_offset + 2, p_node->result_id);
} }
break; break;
@ -41,7 +41,7 @@ index e9b11bf495..f181df5fa2 100644
case SpvOpSpecConstantComposite: case SpvOpSpecConstantComposite:
case SpvOpSpecConstantOp: { case SpvOpSpecConstantOp: {
CHECKED_READU32(p_parser, p_node->word_offset + 1, p_node->result_type_id); CHECKED_READU32(p_parser, p_node->word_offset + 1, p_node->result_type_id);
@@ -856,7 +868,7 @@ static SpvReflectResult ParseNodes(SpvReflectPrvParser* p_parser) @@ -864,7 +876,7 @@ static SpvReflectResult ParseNodes(SpvReflectPrvParser* p_parser)
CHECKED_READU32(p_parser, p_node->word_offset + 3, p_access_chain->base_id); CHECKED_READU32(p_parser, p_node->word_offset + 3, p_access_chain->base_id);
// //
// SPIRV_ACCESS_CHAIN_INDEX_OFFSET (4) is the number of words up until the first index: // SPIRV_ACCESS_CHAIN_INDEX_OFFSET (4) is the number of words up until the first index:
@ -50,7 +50,7 @@ index e9b11bf495..f181df5fa2 100644
// //
p_access_chain->index_count = (node_word_count - SPIRV_ACCESS_CHAIN_INDEX_OFFSET); p_access_chain->index_count = (node_word_count - SPIRV_ACCESS_CHAIN_INDEX_OFFSET);
if (p_access_chain->index_count > 0) { if (p_access_chain->index_count > 0) {
@@ -1338,6 +1350,9 @@ static SpvReflectResult ParseDecorations(SpvReflectPrvParser* p_parser) @@ -1346,6 +1358,9 @@ static SpvReflectResult ParseDecorations(SpvReflectPrvParser* p_parser)
skip = true; skip = true;
} }
break; break;
@ -60,7 +60,7 @@ index e9b11bf495..f181df5fa2 100644
case SpvDecorationRelaxedPrecision: case SpvDecorationRelaxedPrecision:
case SpvDecorationBlock: case SpvDecorationBlock:
case SpvDecorationBufferBlock: case SpvDecorationBufferBlock:
@@ -1481,7 +1496,14 @@ static SpvReflectResult ParseDecorations(SpvReflectPrvParser* p_parser) @@ -1495,7 +1510,14 @@ static SpvReflectResult ParseDecorations(SpvReflectPrvParser* p_parser)
p_target_decorations->input_attachment_index.word_offset = word_offset; p_target_decorations->input_attachment_index.word_offset = word_offset;
} }
break; break;
@ -76,7 +76,7 @@ index e9b11bf495..f181df5fa2 100644
case SpvReflectDecorationHlslCounterBufferGOOGLE: { case SpvReflectDecorationHlslCounterBufferGOOGLE: {
uint32_t word_offset = p_node->word_offset + member_offset+ 3; uint32_t word_offset = p_node->word_offset + member_offset+ 3;
CHECKED_READU32(p_parser, word_offset, p_target_decorations->uav_counter_buffer.value); CHECKED_READU32(p_parser, word_offset, p_target_decorations->uav_counter_buffer.value);
@@ -1789,6 +1811,13 @@ static SpvReflectResult ParseType( @@ -1803,6 +1825,13 @@ static SpvReflectResult ParseType(
p_type->type_flags |= SPV_REFLECT_TYPE_FLAG_EXTERNAL_ACCELERATION_STRUCTURE; p_type->type_flags |= SPV_REFLECT_TYPE_FLAG_EXTERNAL_ACCELERATION_STRUCTURE;
} }
break; break;
@ -90,7 +90,7 @@ index e9b11bf495..f181df5fa2 100644
} }
if (result == SPV_REFLECT_RESULT_SUCCESS) { if (result == SPV_REFLECT_RESULT_SUCCESS) {
@@ -3269,6 +3298,69 @@ static SpvReflectResult ParseExecutionModes( @@ -3332,6 +3361,69 @@ static SpvReflectResult ParseExecutionModes(
return SPV_REFLECT_RESULT_SUCCESS; return SPV_REFLECT_RESULT_SUCCESS;
} }
@ -160,7 +160,7 @@ index e9b11bf495..f181df5fa2 100644
static SpvReflectResult ParsePushConstantBlocks( static SpvReflectResult ParsePushConstantBlocks(
SpvReflectPrvParser* p_parser, SpvReflectPrvParser* p_parser,
SpvReflectShaderModule* p_module) SpvReflectShaderModule* p_module)
@@ -3650,6 +3742,12 @@ static SpvReflectResult CreateShaderModule( @@ -3717,6 +3809,12 @@ static SpvReflectResult CreateShaderModule(
result = ParsePushConstantBlocks(&parser, p_module); result = ParsePushConstantBlocks(&parser, p_module);
SPV_REFLECT_ASSERT(result == SPV_REFLECT_RESULT_SUCCESS); SPV_REFLECT_ASSERT(result == SPV_REFLECT_RESULT_SUCCESS);
} }
@ -173,8 +173,8 @@ index e9b11bf495..f181df5fa2 100644
if (result == SPV_REFLECT_RESULT_SUCCESS) { if (result == SPV_REFLECT_RESULT_SUCCESS) {
result = ParseEntryPoints(&parser, p_module); result = ParseEntryPoints(&parser, p_module);
SPV_REFLECT_ASSERT(result == SPV_REFLECT_RESULT_SUCCESS); SPV_REFLECT_ASSERT(result == SPV_REFLECT_RESULT_SUCCESS);
@@ -3807,6 +3905,9 @@ void spvReflectDestroyShaderModule(SpvReflectShaderModule* p_module) @@ -3875,6 +3973,9 @@ void spvReflectDestroyShaderModule(SpvReflectShaderModule* p_module)
SafeFree(p_entry->used_push_constants); SafeFree(p_entry->execution_modes);
} }
SafeFree(p_module->entry_points); SafeFree(p_module->entry_points);
+// -- GODOT begin -- +// -- GODOT begin --
@ -183,7 +183,7 @@ index e9b11bf495..f181df5fa2 100644
// Push constants // Push constants
for (size_t i = 0; i < p_module->push_constant_block_count; ++i) { for (size_t i = 0; i < p_module->push_constant_block_count; ++i) {
@@ -4077,6 +4178,38 @@ SpvReflectResult spvReflectEnumerateEntryPointInterfaceVariables( @@ -4145,6 +4246,38 @@ SpvReflectResult spvReflectEnumerateEntryPointInterfaceVariables(
return SPV_REFLECT_RESULT_SUCCESS; return SPV_REFLECT_RESULT_SUCCESS;
} }
@ -223,10 +223,10 @@ index e9b11bf495..f181df5fa2 100644
const SpvReflectShaderModule* p_module, const SpvReflectShaderModule* p_module,
uint32_t* p_count, uint32_t* p_count,
diff --git a/thirdparty/spirv-reflect/spirv_reflect.h b/thirdparty/spirv-reflect/spirv_reflect.h diff --git a/thirdparty/spirv-reflect/spirv_reflect.h b/thirdparty/spirv-reflect/spirv_reflect.h
index e9e4c40755..948533d3c0 100644 index 02b81613a1..02850f8811 100644
--- a/thirdparty/spirv-reflect/spirv_reflect.h --- a/thirdparty/spirv-reflect/spirv_reflect.h
+++ b/thirdparty/spirv-reflect/spirv_reflect.h +++ b/thirdparty/spirv-reflect/spirv_reflect.h
@@ -323,6 +323,28 @@ typedef struct SpvReflectTypeDescription { @@ -329,6 +329,28 @@ typedef struct SpvReflectTypeDescription {
struct SpvReflectTypeDescription* members; struct SpvReflectTypeDescription* members;
} SpvReflectTypeDescription; } SpvReflectTypeDescription;
@ -255,7 +255,7 @@ index e9e4c40755..948533d3c0 100644
/*! @struct SpvReflectInterfaceVariable /*! @struct SpvReflectInterfaceVariable
@@ -472,6 +494,10 @@ typedef struct SpvReflectShaderModule { @@ -483,6 +505,10 @@ typedef struct SpvReflectShaderModule {
SpvReflectInterfaceVariable* interface_variables; // Uses value(s) from first entry point SpvReflectInterfaceVariable* interface_variables; // Uses value(s) from first entry point
uint32_t push_constant_block_count; // Uses value(s) from first entry point uint32_t push_constant_block_count; // Uses value(s) from first entry point
SpvReflectBlockVariable* push_constant_blocks; // Uses value(s) from first entry point SpvReflectBlockVariable* push_constant_blocks; // Uses value(s) from first entry point
@ -266,7 +266,7 @@ index e9e4c40755..948533d3c0 100644
struct Internal { struct Internal {
SpvReflectModuleFlags module_flags; SpvReflectModuleFlags module_flags;
@@ -744,6 +770,33 @@ SpvReflectResult spvReflectEnumerateInputVariables( @@ -755,6 +781,33 @@ SpvReflectResult spvReflectEnumerateInputVariables(
SpvReflectInterfaceVariable** pp_variables SpvReflectInterfaceVariable** pp_variables
); );

View File

@ -119,6 +119,7 @@ typedef struct SpvReflectPrvDecorations {
bool is_noperspective; bool is_noperspective;
bool is_flat; bool is_flat;
bool is_non_writable; bool is_non_writable;
bool is_non_readable;
SpvReflectPrvNumberDecoration set; SpvReflectPrvNumberDecoration set;
SpvReflectPrvNumberDecoration binding; SpvReflectPrvNumberDecoration binding;
SpvReflectPrvNumberDecoration input_attachment_index; SpvReflectPrvNumberDecoration input_attachment_index;
@ -306,7 +307,12 @@ static SpvReflectResult IntersectSortedUint32(
size_t* res_size size_t* res_size
) )
{ {
*pp_res = NULL;
*res_size = 0; *res_size = 0;
if (IsNull(p_arr0) || IsNull(p_arr1)) {
return SPV_REFLECT_RESULT_SUCCESS;
}
const uint32_t* arr0_end = p_arr0 + arr0_size; const uint32_t* arr0_end = p_arr0 + arr0_size;
const uint32_t* arr1_end = p_arr1 + arr1_size; const uint32_t* arr1_end = p_arr1 + arr1_size;
@ -324,7 +330,6 @@ static SpvReflectResult IntersectSortedUint32(
} }
} }
*pp_res = NULL;
if (*res_size > 0) { if (*res_size > 0) {
*pp_res = (uint32_t*)calloc(*res_size, sizeof(**pp_res)); *pp_res = (uint32_t*)calloc(*res_size, sizeof(**pp_res));
if (IsNull(*pp_res)) { if (IsNull(*pp_res)) {
@ -488,6 +493,9 @@ static SpvReflectDecorationFlags ApplyDecorations(const SpvReflectPrvDecorations
if (p_decoration_fields->is_non_writable) { if (p_decoration_fields->is_non_writable) {
decorations |= SPV_REFLECT_DECORATION_NON_WRITABLE; decorations |= SPV_REFLECT_DECORATION_NON_WRITABLE;
} }
if (p_decoration_fields->is_non_readable) {
decorations |= SPV_REFLECT_DECORATION_NON_READABLE;
}
return decorations; return decorations;
} }
@ -1364,6 +1372,7 @@ static SpvReflectResult ParseDecorations(SpvReflectPrvParser* p_parser)
case SpvDecorationNoPerspective: case SpvDecorationNoPerspective:
case SpvDecorationFlat: case SpvDecorationFlat:
case SpvDecorationNonWritable: case SpvDecorationNonWritable:
case SpvDecorationNonReadable:
case SpvDecorationLocation: case SpvDecorationLocation:
case SpvDecorationBinding: case SpvDecorationBinding:
case SpvDecorationDescriptorSet: case SpvDecorationDescriptorSet:
@ -1462,6 +1471,11 @@ static SpvReflectResult ParseDecorations(SpvReflectPrvParser* p_parser)
} }
break; break;
case SpvDecorationNonReadable: {
p_target_decorations->is_non_readable = true;
}
break;
case SpvDecorationLocation: { case SpvDecorationLocation: {
uint32_t word_offset = p_node->word_offset + member_offset + 3; uint32_t word_offset = p_node->word_offset + member_offset + 3;
CHECKED_READU32(p_parser, word_offset, p_target_decorations->location.value); CHECKED_READU32(p_parser, word_offset, p_target_decorations->location.value);
@ -1970,6 +1984,7 @@ static SpvReflectResult ParseDescriptorBindings(
p_descriptor->count = 1; p_descriptor->count = 1;
p_descriptor->uav_counter_id = p_node->decorations.uav_counter_buffer.value; p_descriptor->uav_counter_id = p_node->decorations.uav_counter_buffer.value;
p_descriptor->type_description = p_type; p_descriptor->type_description = p_type;
p_descriptor->decoration_flags = ApplyDecorations(&p_node->decorations);
// If this is in the StorageBuffer storage class, it's for sure a storage // If this is in the StorageBuffer storage class, it's for sure a storage
// buffer descriptor. We need to handle this case earlier because in SPIR-V // buffer descriptor. We need to handle this case earlier because in SPIR-V
@ -3288,12 +3303,60 @@ static SpvReflectResult ParseExecutionModes(
case SpvExecutionModeLocalSizeId: case SpvExecutionModeLocalSizeId:
case SpvExecutionModeLocalSizeHintId: case SpvExecutionModeLocalSizeHintId:
case SpvExecutionModePostDepthCoverage: case SpvExecutionModePostDepthCoverage:
case SpvExecutionModeDenormPreserve:
case SpvExecutionModeDenormFlushToZero:
case SpvExecutionModeSignedZeroInfNanPreserve:
case SpvExecutionModeRoundingModeRTE:
case SpvExecutionModeRoundingModeRTZ:
case SpvExecutionModeStencilRefReplacingEXT: case SpvExecutionModeStencilRefReplacingEXT:
case SpvExecutionModeOutputLinesNV:
case SpvExecutionModeOutputPrimitivesNV: case SpvExecutionModeOutputPrimitivesNV:
case SpvExecutionModeOutputTrianglesNV: case SpvExecutionModeOutputTrianglesNV:
break; break;
} }
p_entry_point->execution_mode_count++;
} }
uint32_t* indices = (uint32_t*)calloc(p_module->entry_point_count, sizeof(indices));
if (IsNull(indices)) {
return SPV_REFLECT_RESULT_ERROR_ALLOC_FAILED;
}
for (size_t entry_point_idx = 0; entry_point_idx < p_module->entry_point_count; ++entry_point_idx) {
SpvReflectEntryPoint* p_entry_point = &p_module->entry_points[entry_point_idx];
p_entry_point->execution_modes =
(SpvExecutionMode*)calloc(p_entry_point->execution_mode_count, sizeof(*p_entry_point->execution_modes));
if (IsNull(p_entry_point->execution_modes)) {
SafeFree(indices);
return SPV_REFLECT_RESULT_ERROR_ALLOC_FAILED;
}
}
for (size_t node_idx = 0; node_idx < p_parser->node_count; ++node_idx) {
SpvReflectPrvNode* p_node = &(p_parser->nodes[node_idx]);
if (p_node->op != SpvOpExecutionMode) {
continue;
}
// Read entry point id
uint32_t entry_point_id = 0;
CHECKED_READU32(p_parser, p_node->word_offset + 1, entry_point_id);
// Find entry point
SpvReflectEntryPoint* p_entry_point = NULL;
uint32_t* idx = NULL;
for (size_t entry_point_idx = 0; entry_point_idx < p_module->entry_point_count; ++entry_point_idx) {
if (p_module->entry_points[entry_point_idx].id == entry_point_id) {
p_entry_point = &p_module->entry_points[entry_point_idx];
idx = &indices[entry_point_idx];
break;
}
}
// Read execution mode
uint32_t execution_mode = (uint32_t)INVALID_VALUE;
CHECKED_READU32(p_parser, p_node->word_offset + 2, execution_mode);
p_entry_point->execution_modes[(*idx)++] = (SpvExecutionMode)execution_mode;
}
SafeFree(indices);
} }
return SPV_REFLECT_RESULT_SUCCESS; return SPV_REFLECT_RESULT_SUCCESS;
} }
@ -3649,7 +3712,11 @@ static SpvReflectResult CreateShaderModule(
if (flags & SPV_REFLECT_MODULE_FLAG_NO_COPY) { if (flags & SPV_REFLECT_MODULE_FLAG_NO_COPY) {
// Set internal size and pointer to args passed in // Set internal size and pointer to args passed in
p_module->_internal->spirv_size = size; p_module->_internal->spirv_size = size;
#if defined(__cplusplus)
p_module->_internal->spirv_code = const_cast<uint32_t*>(static_cast<const uint32_t*>(p_code)); // cast that const away
#else
p_module->_internal->spirv_code = (void*)p_code; // cast that const away p_module->_internal->spirv_code = (void*)p_code; // cast that const away
#endif
p_module->_internal->spirv_word_count = (uint32_t)(size / SPIRV_WORD_SIZE); p_module->_internal->spirv_word_count = (uint32_t)(size / SPIRV_WORD_SIZE);
} }
else { else {
@ -3903,6 +3970,7 @@ void spvReflectDestroyShaderModule(SpvReflectShaderModule* p_module)
SafeFree(p_entry->interface_variables); SafeFree(p_entry->interface_variables);
SafeFree(p_entry->used_uniforms); SafeFree(p_entry->used_uniforms);
SafeFree(p_entry->used_push_constants); SafeFree(p_entry->used_push_constants);
SafeFree(p_entry->execution_modes);
} }
SafeFree(p_module->entry_points); SafeFree(p_module->entry_points);
// -- GODOT begin -- // -- GODOT begin --
@ -5093,6 +5161,7 @@ const char* spvReflectSourceLanguage(SpvSourceLanguage source_lang)
case SpvSourceLanguageOpenCL_CPP : return "OpenCL_CPP"; case SpvSourceLanguageOpenCL_CPP : return "OpenCL_CPP";
case SpvSourceLanguageHLSL : return "HLSL"; case SpvSourceLanguageHLSL : return "HLSL";
case SpvSourceLanguageCPP_for_OpenCL : return "CPP_for_OpenCL"; case SpvSourceLanguageCPP_for_OpenCL : return "CPP_for_OpenCL";
case SpvSourceLanguageSYCL : return "SYCL";
case SpvSourceLanguageMax: case SpvSourceLanguageMax:
break; break;
} }

View File

@ -30,7 +30,12 @@ VERSION HISTORY
#ifndef SPIRV_REFLECT_H #ifndef SPIRV_REFLECT_H
#define SPIRV_REFLECT_H #define SPIRV_REFLECT_H
#if defined(SPIRV_REFLECT_USE_SYSTEM_SPIRV_H)
#include <spirv/unified1/spirv.h>
#else
#include "./include/spirv/unified1/spirv.h" #include "./include/spirv/unified1/spirv.h"
#endif
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
@ -139,6 +144,7 @@ typedef enum SpvReflectDecorationFlagBits {
SPV_REFLECT_DECORATION_FLAT = 0x00000040, SPV_REFLECT_DECORATION_FLAT = 0x00000040,
SPV_REFLECT_DECORATION_NON_WRITABLE = 0x00000080, SPV_REFLECT_DECORATION_NON_WRITABLE = 0x00000080,
SPV_REFLECT_DECORATION_RELAXED_PRECISION = 0x00000100, SPV_REFLECT_DECORATION_RELAXED_PRECISION = 0x00000100,
SPV_REFLECT_DECORATION_NON_READABLE = 0x00000200,
} SpvReflectDecorationFlagBits; } SpvReflectDecorationFlagBits;
typedef uint32_t SpvReflectDecorationFlags; typedef uint32_t SpvReflectDecorationFlags;
@ -422,6 +428,8 @@ typedef struct SpvReflectDescriptorBinding {
uint32_t binding; uint32_t binding;
uint32_t set; uint32_t set;
} word_offset; } word_offset;
SpvReflectDecorationFlags decoration_flags;
} SpvReflectDescriptorBinding; } SpvReflectDescriptorBinding;
/*! @struct SpvReflectDescriptorSet /*! @struct SpvReflectDescriptorSet
@ -458,6 +466,9 @@ typedef struct SpvReflectEntryPoint {
uint32_t used_push_constant_count; uint32_t used_push_constant_count;
uint32_t* used_push_constants; uint32_t* used_push_constants;
uint32_t execution_mode_count;
SpvExecutionMode* execution_modes;
struct LocalSize { struct LocalSize {
uint32_t x; uint32_t x;
uint32_t y; uint32_t y;