29 static constexpr u32 PARAMETER_COUNT_MAX = 64;
30 static constexpr u32 FUNCTIONS_COUNT_MAX = 64;
31 static constexpr u32 PASS_COUNT_MAX = 64;
85 GX_CHAR _name[GxShaderCompiler::GxConstantRegisterElement::PARAMETER_NAME_MAX];
86 GX_CHAR _virtualName[GxShaderCompiler::GxConstantRegisterElement::PARAMETER_NAME_MAX];
93 GX_CHAR _name[GxShaderCompiler::GxConstantRegisterElement::PARAMETER_NAME_MAX];
94 GX_CHAR _virtualName[GxShaderCompiler::GxConstantRegisterElement::PARAMETER_NAME_MAX];
100 GX_CHAR _name[GxShaderCompiler::GxConstantRegisterElement::PARAMETER_NAME_MAX];
101 GX_CHAR _virtualName[GxShaderCompiler::GxConstantRegisterElement::PARAMETER_NAME_MAX];
104 GX_ENUM _gxEnum[FUNCTIONS_COUNT_MAX];
108 struct GxParameterAnnotation
115 struct GxSemanticsInfo
117 GX_CHAR _name[GxShaderCompiler::GxConstantRegisterElement::PARAMETER_NAME_MAX];
118 PARAMETER_TYPE _type;
124 GX_CHAR _name[GxShaderCompiler::GxConstantRegisterElement::PARAMETER_NAME_MAX];
126 GX_CHAR _entryPoint[
static_cast<u32
>(
RENDER_SHADER::MAX)][GxShaderCompiler::GxConstantRegisterElement::PARAMETER_NAME_MAX];
148 b32 initialize(GX_CSTR shaderSource);
161 GX_HANDLE getProgramFunctionsHandleByName(GX_CSTR name)
const;
163 GX_HANDLE getMaterialFunctionsHandleByName(GX_CSTR name)
const;
166 GX_HANDLE getProgramFunctionsHandleByVirtualName(GX_CSTR name)
const;
168 GX_HANDLE getMaterialFunctionsHandleByVirtualName(GX_CSTR name)
const;
171 GX_CSTR getProgramFunctionsName(
GX_HANDLE handle)
const;
173 GX_CSTR getMaterialFunctionsName(
GX_HANDLE handle)
const;
176 GX_CSTR getProgramFunctionsVirtualName(
GX_HANDLE handle)
const;
178 GX_CSTR getMaterialFunctionsVirtualName(
GX_HANDLE handle)
const;
181 GX_CSTR getProgramFunctionsValueName(
GX_HANDLE handle, u32 value)
const;
183 GX_CSTR getMaterialFunctionsValueName(
GX_HANDLE handle, u32 value)
const;
186 GX_CSTR getProgramFunctionsValueVirtualName(
GX_HANDLE handle, u32 value)
const;
188 GX_CSTR getMaterialFunctionsValueVirtualName(
GX_HANDLE handle, u32 value)
const;
191 u32 getProgramFunctionsValueByName(
GX_HANDLE handle, GX_CSTR name)
const;
193 u32 getMaterialFunctionsValueByName(
GX_HANDLE handle, GX_CSTR name)
const;
196 u32 getProgramFunctionsValueByVirtualName(
GX_HANDLE handle, GX_CSTR name)
const;
198 u32 getMaterialFunctionsValueByVirtualName(
GX_HANDLE handle, GX_CSTR name)
const;
206 void setProgramFunctions(
GX_HANDLE handle, u32 value);
208 void setMaterialFunctions(
GX_HANDLE handle, u32 value);
211 constexpr u32 getProgramFunctionsCount(
void)
const {
return _programFunctionsCount; }
213 constexpr u32 getMaterialFunctionsCount(
void)
const {
return _materialFunctionsCount; }
216 u32 getProgramFunctionsValueCount(
GX_HANDLE handle)
const;
218 u32 getMaterialFunctionsValueCount(
GX_HANDLE handle)
const;
221 GX_HANDLE getProgramParameterHandleByName(GX_CSTR name)
const;
223 GX_HANDLE getMaterialParameterHandleByName(GX_CSTR name)
const;
226 GX_HANDLE getProgramParameterHandleByVirtualName(GX_CSTR name)
const;
228 GX_HANDLE getMaterialParameterHandleByVirtualName(GX_CSTR name)
const;
231 GX_CSTR getProgramParameterName(
GX_HANDLE handle)
const;
233 GX_CSTR getMaterialParameterName(
GX_HANDLE handle)
const;
236 GX_CSTR getProgramParameterVirtualName(
GX_HANDLE handle)
const;
238 GX_CSTR getMaterialParameterVirtualName(
GX_HANDLE handle)
const;
241 PARAMETER_TYPE getProgramParameterType(
GX_HANDLE handle)
const;
243 PARAMETER_TYPE getMaterialParameterType(
GX_HANDLE handle)
const;
246 GxParameterAnnotation getMaterialParameterAnnotation(
GX_HANDLE handle)
const;
248 const GxParameterDefaultValue& getMaterialParameterDefaultValue(
GX_HANDLE handle)
const;
251 constexpr u32 getProgramParameterCount(
void)
const {
return _programParameterCount; }
253 constexpr u32 getMaterialParameterCount(
void)
const {
return _materialParameterCount; }
256 void setPass(u32 value);
258 constexpr u32 getPassCount(
void)
const {
return _passCount; }
260 u32 getPassByName(GX_CSTR name)
const;
262 GX_CSTR getPassName(u32 pass)
const;
264 constexpr GxShaderCompiler::COMPILE_SHADER getShaderType(
RENDER_SHADER renderShader, u32 pass)
const {
return _passInfo[pass]._shaderType[
static_cast<u32
>(renderShader)]; }
267 constexpr GX_CSTR getShaderPath(
void)
const {
return _shaderPath; }
277 void setupCompile(
void);
280 b32 compileVertexShader(GxShaderCompiler& shaderCompiler);
283 b32 compilePixelShader(GxShaderCompiler& shaderCompiler);
284#if GX_ENABLE_TESSELLATION
286 b32 compileHullShader(GxShaderCompiler& shaderCompiler);
289 b32 compileDomainShader(GxShaderCompiler& shaderCompiler);
291#if GX_ENABLE_COMPUTE_SHADER
293 b32 compileComputeShader(GxShaderCompiler& shaderCompiler);
298 void executeInclude(
void);
300 void replaceDefineConstant(
void);
302 void executeProgramDefine(
void);
304 void executeMaterialDefine(
void);
306 void executeDefine(GX_CSTR defineString, GxParameter* pParameter, GxFunctions* pFunctions, u32& parameterCount, u32& functionsCount);
308 void parseVertexInput(
void);
310 void parseInterpolator(
void);
312 void parseTechnique(
void);
314 void parseAnnotationAndDefaultValue(
void);
316 void proxyVertexShader(
GxString& outputString, u32 outputSemantics);
319 void replaceFunction(
GxString& program,
const GxFunctions* pFunctions,
const u8* pFunctionsValue, u32 functionsCount);
322 void removeUnusedFunctions(
GxString& program, GX_CSTR entryPoint, GX_CSTR escapeFunction =
nullptr);
324 b32 removeUnusedFunction(
GxString& program, GX_CSTR functionName,
b32 isForce =
false);
326 void removeUnusedConstValues(
GxString& program);
329 static void* allocateCompilerMemory(
size_t size);
331 static void freeCompilerMemory(
void* pAddress);
334 s32 defaultIncludeCallback(
void* pSource,
void* pArgument);
339#if GX_ENABLE_TESSELLATION
350 static void replaceSemanticsGLSL(
GxString& buffer);
353 void removeFunction(
GxString& src, GX_CSTR entryPoint);
357 void warningShaderInfo(
void);
359 static void eraseComment(
GxString& buffer);
361 static void replaceSpace(
GxString& buffer);
364 void getFunctionInfoStr(
const GxFunctions* pFunctions,
const u8* pFunctionsValue, u32 functionsCount,
GxString& outString);
366 void writeFunctionInfo(
const GxFunctions* pFunctions,
const u8* pFunctionsValue, u32 functionsCount, GxResCellSheetCsv* pResource, u32& positionRow);
368 void saveShaderInfo(GxResCellSheetCsv* pResource,
const GxString& path);
370 b32 askContinueCompile(GX_CSTR message);
379 GxParameter _programParameter[PARAMETER_COUNT_MAX];
380 GxParameter _materialParameter[PARAMETER_COUNT_MAX];
381 GxFunctions _programFunctions[FUNCTIONS_COUNT_MAX];
382 GxFunctions _materialFunctions[FUNCTIONS_COUNT_MAX];
383 u8 _programFunctionsValue[FUNCTIONS_COUNT_MAX];
384 u8 _materialFunctionsValue[FUNCTIONS_COUNT_MAX];
385 GxParameterAnnotation _materialParameterAnnotation[PARAMETER_COUNT_MAX];
386 GxParameterDefaultValue _materialParameterDefaultValue[PARAMETER_COUNT_MAX];
387 u32 _programParameterCount;
388 u32 _materialParameterCount;
389 u32 _programFunctionsCount;
390 u32 _materialFunctionsCount;
395 GxPassInfo _passInfo[PASS_COUNT_MAX];
398 b32 _findVertexInput;