@@ -126,32 +126,28 @@ std::string CGLSLCompiler::preprocessShader(std::string&& code, IShader::E_SHADE
126
126
{
127
127
insertExtraDefines (code, preprocessOptions.extraDefines );
128
128
}
129
+ IShaderCompiler::disableAllDirectivesExceptIncludes (code);
130
+ disableGlDirectives (code);
131
+ shaderc::Compiler comp;
132
+ shaderc::CompileOptions options;
133
+ options.SetTargetSpirv (shaderc_spirv_version_1_6);
134
+
129
135
if (preprocessOptions.includeFinder != nullptr )
130
136
{
131
- IShaderCompiler::disableAllDirectivesExceptIncludes (code);
132
- disableGlDirectives (code);
133
- shaderc::Compiler comp;
134
- shaderc::CompileOptions options;
135
- options.SetTargetSpirv (shaderc_spirv_version_1_6);
136
-
137
137
options.SetIncluder (std::make_unique<impl::Includer>(preprocessOptions.includeFinder , m_system.get (), preprocessOptions.maxSelfInclusionCount + 1u ));// custom #include handler
138
- const shaderc_shader_kind scstage = stage == IShader::ESS_UNKNOWN ? shaderc_glsl_infer_from_source : ESStoShadercEnum (stage);
139
- auto res = comp.PreprocessGlsl (code, scstage, preprocessOptions.sourceIdentifier .data (), options);
140
-
141
- if (res.GetCompilationStatus () != shaderc_compilation_status_success) {
142
- preprocessOptions.logger .log (res.GetErrorMessage (), system::ILogger::ELL_ERROR);
143
- return nullptr ;
144
- }
145
-
146
- auto resolvedString = std::string (res.cbegin (), std::distance (res.cbegin (), res.cend ()));
147
- IShaderCompiler::reenableDirectives (resolvedString);
148
- reenableGlDirectives (resolvedString);
149
- return resolvedString;
150
138
}
151
- else
152
- {
153
- return code;
139
+ const shaderc_shader_kind scstage = stage == IShader::ESS_UNKNOWN ? shaderc_glsl_infer_from_source : ESStoShadercEnum (stage);
140
+ auto res = comp.PreprocessGlsl (code, scstage, preprocessOptions.sourceIdentifier .data (), options);
141
+
142
+ if (res.GetCompilationStatus () != shaderc_compilation_status_success) {
143
+ preprocessOptions.logger .log (res.GetErrorMessage (), system::ILogger::ELL_ERROR);
144
+ return nullptr ;
154
145
}
146
+
147
+ auto resolvedString = std::string (res.cbegin (), std::distance (res.cbegin (), res.cend ()));
148
+ IShaderCompiler::reenableDirectives (resolvedString);
149
+ reenableGlDirectives (resolvedString);
150
+ return resolvedString;
155
151
}
156
152
157
153
core::smart_refctd_ptr<ICPUShader> CGLSLCompiler::compileToSPIRV (const char * code, const IShaderCompiler::SCompilerOptions& options) const
0 commit comments