@@ -101,24 +101,29 @@ const CIntrospectionData* CShaderIntrospector::introspect(const ICPUShader* _sha
101
101
return m_introspectionCache[std::move (key)].insert ({core::smart_refctd_ptr<const ICPUShader>(_shader),std::move (introspection)}).first ->second .get ();
102
102
};
103
103
104
- // TODO: Use the compilerSet here to also take care of HLSL
105
- if (_shader->getContentType () == ICPUShader::E_CONTENT_TYPE::ECT_GLSL)
104
+ auto begin = reinterpret_cast <const char *>(_shader->getContent ()->getPointer ());
105
+ auto end = begin + _shader->getContent ()->getSize ();
106
+ std::string code (begin, end);
107
+ if (_shader->getContentType () != ICPUShader::E_CONTENT_TYPE::ECT_SPIRV)
108
+ ICPUShader::insertDefines (code, _params.extraDefines );
109
+
110
+ // TODO:
111
+ core::smart_refctd_ptr<asset::CCompilerSet> compilerSet;
112
+
113
+ auto compiler = compilerSet->getShaderCompiler (_shader->getContentType ());
114
+ asset::IShaderCompiler::SOptions commonCompileOptions = {};
115
+ commonCompileOptions.logger = nullptr ;
116
+ commonCompileOptions.includeFinder = compiler->getDefaultIncludeFinder (); // to resolve includes before compilation
117
+ commonCompileOptions.stage = _shader->getStage ();
118
+ commonCompileOptions.sourceIdentifier = _shader->getFilepathHint ().c_str ();
119
+ commonCompileOptions.entryPoint = _params.entryPoint ;
120
+ commonCompileOptions.genDebugInfo = true ;
121
+ commonCompileOptions.spirvOptimizer = nullptr ; // No need of optimizing for introspection
122
+
123
+ if (_shader->getContentType () == ICPUShader::E_CONTENT_TYPE::ECT_GLSL || _shader->getContentType () == ICPUShader::E_CONTENT_TYPE::ECT_HLSL)
106
124
{
107
- auto begin = reinterpret_cast <const char *>(_shader->getContent ()->getPointer ());
108
- auto end = begin+_shader->getContent ()->getSize ();
109
- std::string glsl (begin,end);
110
- ICPUShader::insertDefines (glsl,_params.extraDefines );
111
- auto glslShader_woIncludes = m_glslCompiler->resolveIncludeDirectives (glsl.c_str (), _shader->getStage (), _shader->getFilepathHint ().c_str ());
112
- auto spvShader = m_glslCompiler->createSPIRVFromGLSL (
113
- reinterpret_cast <const char *>(glslShader_woIncludes->getContent ()->getPointer ()),
114
- glslShader_woIncludes->getStage (),
115
- _params.entryPoint ,
116
- glslShader_woIncludes->getFilepathHint ().c_str ()
117
- );
118
- if (!spvShader)
119
- return nullptr ;
120
-
121
- return introspectSPV (spvShader.get ());
125
+ // TODO: actually use code to create a ICPUShader or change the function signature for "compilerSet"
126
+ compilerSet->compileToSPIRV (_shader, commonCompileOptions);
122
127
}
123
128
else if (_shader->getContentType () == ICPUShader::E_CONTENT_TYPE::ECT_SPIRV)
124
129
return introspectSPV (_shader);
0 commit comments