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