@@ -34,78 +34,78 @@ namespace Diligent
3434
3535namespace SPIRVToolsInternal
3636{
37-
38- void SpvOptimizerMessageConsumer (
39- spv_message_level_t level,
40- const char * /* source */ ,
41- const spv_position_t & /* position */ ,
42- const char * message)
37+
38+ void SpvOptimizerMessageConsumer (
39+ spv_message_level_t level,
40+ const char * /* source */ ,
41+ const spv_position_t & /* position */ ,
42+ const char * message)
43+ {
44+ const char * LevelText = " message" ;
45+ DEBUG_MESSAGE_SEVERITY MsgSeverity = DEBUG_MESSAGE_SEVERITY_INFO;
46+ switch (level)
4347 {
44- const char * LevelText = " message" ;
45- DEBUG_MESSAGE_SEVERITY MsgSeverity = DEBUG_MESSAGE_SEVERITY_INFO;
46- switch (level)
47- {
48- case SPV_MSG_FATAL:
49- // Unrecoverable error due to environment (e.g. out of memory)
50- LevelText = " fatal error" ;
51- MsgSeverity = DEBUG_MESSAGE_SEVERITY_FATAL_ERROR;
52- break ;
53-
54- case SPV_MSG_INTERNAL_ERROR:
55- // Unrecoverable error due to SPIRV-Tools internals (e.g. unimplemented feature)
56- LevelText = " internal error" ;
57- MsgSeverity = DEBUG_MESSAGE_SEVERITY_ERROR;
58- break ;
59-
60- case SPV_MSG_ERROR:
61- // Normal error due to user input.
62- LevelText = " error" ;
63- MsgSeverity = DEBUG_MESSAGE_SEVERITY_ERROR;
64- break ;
65-
66- case SPV_MSG_WARNING:
67- LevelText = " warning" ;
68- MsgSeverity = DEBUG_MESSAGE_SEVERITY_WARNING;
69- break ;
70-
71- case SPV_MSG_INFO:
72- LevelText = " info" ;
73- MsgSeverity = DEBUG_MESSAGE_SEVERITY_INFO;
74- break ;
75-
76- case SPV_MSG_DEBUG:
77- LevelText = " debug" ;
78- MsgSeverity = DEBUG_MESSAGE_SEVERITY_INFO;
79- break ;
80- }
81-
82- if (level == SPV_MSG_FATAL || level == SPV_MSG_INTERNAL_ERROR || level == SPV_MSG_ERROR || level == SPV_MSG_WARNING)
83- LOG_DEBUG_MESSAGE (MsgSeverity, " Spirv optimizer " , LevelText, " : " , message);
48+ case SPV_MSG_FATAL:
49+ // Unrecoverable error due to environment (e.g. out of memory)
50+ LevelText = " fatal error" ;
51+ MsgSeverity = DEBUG_MESSAGE_SEVERITY_FATAL_ERROR;
52+ break ;
53+
54+ case SPV_MSG_INTERNAL_ERROR:
55+ // Unrecoverable error due to SPIRV-Tools internals (e.g. unimplemented feature)
56+ LevelText = " internal error" ;
57+ MsgSeverity = DEBUG_MESSAGE_SEVERITY_ERROR;
58+ break ;
59+
60+ case SPV_MSG_ERROR:
61+ // Normal error due to user input.
62+ LevelText = " error" ;
63+ MsgSeverity = DEBUG_MESSAGE_SEVERITY_ERROR;
64+ break ;
65+
66+ case SPV_MSG_WARNING:
67+ LevelText = " warning" ;
68+ MsgSeverity = DEBUG_MESSAGE_SEVERITY_WARNING;
69+ break ;
70+
71+ case SPV_MSG_INFO:
72+ LevelText = " info" ;
73+ MsgSeverity = DEBUG_MESSAGE_SEVERITY_INFO;
74+ break ;
75+
76+ case SPV_MSG_DEBUG:
77+ LevelText = " debug" ;
78+ MsgSeverity = DEBUG_MESSAGE_SEVERITY_INFO;
79+ break ;
8480 }
85-
86- spv_target_env SpvTargetEnvFromSPIRV (const std::vector<uint32_t >& SPIRV)
81+
82+ if (level == SPV_MSG_FATAL || level == SPV_MSG_INTERNAL_ERROR || level == SPV_MSG_ERROR || level == SPV_MSG_WARNING)
83+ LOG_DEBUG_MESSAGE (MsgSeverity, " Spirv optimizer " , LevelText, " : " , message);
84+ }
85+
86+ spv_target_env SpvTargetEnvFromSPIRV (const std::vector<uint32_t >& SPIRV)
87+ {
88+ if (SPIRV.size () < 2 )
8789 {
88- if (SPIRV.size () < 2 )
89- {
90- // Invalid SPIRV
91- return SPV_ENV_VULKAN_1_0;
92- }
93-
94- #define SPV_SPIRV_VERSION_WORD (MAJOR, MINOR ) ((uint32_t (uint8_t (MAJOR)) << 16 ) | (uint32_t (uint8_t (MINOR)) << 8 ))
95- switch (SPIRV[1 ])
96- {
97- case SPV_SPIRV_VERSION_WORD (1 , 0 ): return SPV_ENV_VULKAN_1_0;
98- case SPV_SPIRV_VERSION_WORD (1 , 1 ): return SPV_ENV_VULKAN_1_0;
99- case SPV_SPIRV_VERSION_WORD (1 , 2 ): return SPV_ENV_VULKAN_1_0;
100- case SPV_SPIRV_VERSION_WORD (1 , 3 ): return SPV_ENV_VULKAN_1_1;
101- case SPV_SPIRV_VERSION_WORD (1 , 4 ): return SPV_ENV_VULKAN_1_1_SPIRV_1_4;
102- case SPV_SPIRV_VERSION_WORD (1 , 5 ): return SPV_ENV_VULKAN_1_2;
103- case SPV_SPIRV_VERSION_WORD (1 , 6 ): return SPV_ENV_VULKAN_1_3;
104- default : return SPV_ENV_VULKAN_1_3;
105- }
106- #undef SPV_SPIRV_VERSION_WORD
90+ // Invalid SPIRV
91+ return SPV_ENV_VULKAN_1_0;
10792 }
108-
93+
94+ #define SPV_SPIRV_VERSION_WORD (MAJOR, MINOR ) ((uint32_t (uint8_t (MAJOR)) << 16 ) | (uint32_t (uint8_t (MINOR)) << 8 ))
95+ switch (SPIRV[1 ])
96+ {
97+ case SPV_SPIRV_VERSION_WORD (1 , 0 ): return SPV_ENV_VULKAN_1_0;
98+ case SPV_SPIRV_VERSION_WORD (1 , 1 ): return SPV_ENV_VULKAN_1_0;
99+ case SPV_SPIRV_VERSION_WORD (1 , 2 ): return SPV_ENV_VULKAN_1_0;
100+ case SPV_SPIRV_VERSION_WORD (1 , 3 ): return SPV_ENV_VULKAN_1_1;
101+ case SPV_SPIRV_VERSION_WORD (1 , 4 ): return SPV_ENV_VULKAN_1_1_SPIRV_1_4;
102+ case SPV_SPIRV_VERSION_WORD (1 , 5 ): return SPV_ENV_VULKAN_1_2;
103+ case SPV_SPIRV_VERSION_WORD (1 , 6 ): return SPV_ENV_VULKAN_1_3;
104+ default : return SPV_ENV_VULKAN_1_3;
105+ }
106+ #undef SPV_SPIRV_VERSION_WORD
107+ }
108+
109109} // namespace SPIRVToolsInternal
110110
111111std::vector<uint32_t > OptimizeSPIRV (const std::vector<uint32_t >& SrcSPIRV, spv_target_env TargetEnv, SPIRV_OPTIMIZATION_FLAGS Passes)
0 commit comments