@@ -81,9 +81,13 @@ class ShaderCompiler final : public system::IApplicationFramework
81
81
}
82
82
#endif
83
83
84
- // TODO unfuck this
85
- const ICPUShader* shader_code = open_shader_file (file_to_compile);
86
- auto compilation_result = compile_shader (shader_code, file_to_compile);
84
+ const ICPUShader* shader = open_shader_file (file_to_compile);
85
+ if (shader->getContentType () != IShader::E_CONTENT_TYPE::ECT_HLSL)
86
+ {
87
+ m_logger->log (" Error. Loaded shader file content is not HLSL." , ILogger::ELL_ERROR);
88
+ return false ;
89
+ }
90
+ auto compilation_result = compile_shader (shader, file_to_compile);
87
91
88
92
// writie compiled shader to file as bytes
89
93
if (compilation_result && !output_filepath.empty ()) {
@@ -105,23 +109,23 @@ class ShaderCompiler final : public system::IApplicationFramework
105
109
106
110
private:
107
111
108
- core::smart_refctd_ptr<ICPUShader> compile_shader (const ICPUShader* shader_code , std::string_view sourceIdentifier) {
112
+ core::smart_refctd_ptr<ICPUShader> compile_shader (const ICPUShader* shader , std::string_view sourceIdentifier) {
109
113
constexpr uint32_t WorkgroupSize = 256 ;
110
114
constexpr uint32_t WorkgroupCount = 2048 ;
111
115
const string WorkgroupSizeAsStr = std::to_string (WorkgroupSize);
112
116
113
117
smart_refctd_ptr<CHLSLCompiler> hlslcompiler = make_smart_refctd_ptr<CHLSLCompiler>(smart_refctd_ptr (m_system));
114
118
115
119
CHLSLCompiler::SOptions options = {};
116
- options.stage = shader_code ->getStage ();
120
+ options.stage = shader ->getStage ();
117
121
// options.debugInfoFlags = IShaderCompiler::E_DEBUG_INFO_FLAGS::EDIF_LINE_BIT;
118
122
options.preprocessorOptions .sourceIdentifier = sourceIdentifier;
119
123
options.preprocessorOptions .logger = m_logger.get ();
120
124
options.dxcOptions = std::span<std::string>(m_arguments);
121
125
auto includeFinder = make_smart_refctd_ptr<IShaderCompiler::CIncludeFinder>(smart_refctd_ptr (m_system));
122
126
options.preprocessorOptions .includeFinder = includeFinder.get ();
123
127
124
- return hlslcompiler->compileToSPIRV ((const char *)shader_code ->getContent ()->getPointer (), options);
128
+ return hlslcompiler->compileToSPIRV ((const char *)shader ->getContent ()->getPointer (), options);
125
129
}
126
130
127
131
0 commit comments