2021-05-02 00:52:13 +00:00
|
|
|
#ifndef ENGINE_CLIENT_BACKEND_GLSL_SHADER_COMPILER_H
|
|
|
|
#define ENGINE_CLIENT_BACKEND_GLSL_SHADER_COMPILER_H
|
2021-04-30 22:42:37 +00:00
|
|
|
|
2020-08-29 10:10:38 +00:00
|
|
|
#include <string>
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <vector>
|
2020-08-29 10:10:38 +00:00
|
|
|
|
2021-05-02 00:52:13 +00:00
|
|
|
enum EGLSLShaderCompilerType
|
2020-09-26 19:41:58 +00:00
|
|
|
{
|
2021-05-02 00:52:13 +00:00
|
|
|
GLSL_SHADER_COMPILER_TYPE_VERTEX = 0,
|
|
|
|
GLSL_SHADER_COMPILER_TYPE_FRAGMENT,
|
2017-10-20 07:08:49 +00:00
|
|
|
};
|
2018-02-12 22:14:14 +00:00
|
|
|
|
2020-08-29 10:10:38 +00:00
|
|
|
class CGLSLCompiler
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend class CGLSL;
|
|
|
|
|
|
|
|
struct SGLSLCompilerDefine
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
SGLSLCompilerDefine(const std::string &DefineName, const std::string &DefineValue)
|
2020-08-29 10:10:38 +00:00
|
|
|
{
|
|
|
|
m_DefineName = DefineName;
|
|
|
|
m_DefineValue = DefineValue;
|
|
|
|
}
|
|
|
|
std::string m_DefineName;
|
|
|
|
std::string m_DefineValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<SGLSLCompilerDefine> m_Defines;
|
|
|
|
|
|
|
|
int m_OpenGLVersionMajor;
|
|
|
|
int m_OpenGLVersionMinor;
|
|
|
|
int m_OpenGLVersionPatch;
|
|
|
|
|
2021-04-30 22:42:37 +00:00
|
|
|
bool m_IsOpenGLES;
|
|
|
|
|
|
|
|
float m_TextureLODBias;
|
|
|
|
|
2020-08-29 10:10:38 +00:00
|
|
|
bool m_HasTextureArray;
|
|
|
|
int m_TextureReplaceType; // @see EGLSLCompilerTextureReplaceType
|
|
|
|
public:
|
2021-04-30 22:42:37 +00:00
|
|
|
CGLSLCompiler(int OpenGLVersionMajor, int OpenGLVersionMinor, int OpenGLVersionPatch, bool IsOpenGLES, float TextureLODBias);
|
2020-08-29 10:10:38 +00:00
|
|
|
void SetHasTextureArray(bool TextureArray) { m_HasTextureArray = TextureArray; }
|
|
|
|
void SetTextureReplaceType(int TextureReplaceType) { m_TextureReplaceType = TextureReplaceType; }
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
void AddDefine(const std::string &DefineName, const std::string &DefineValue);
|
|
|
|
void AddDefine(const char *pDefineName, const char *pDefineValue);
|
2020-08-29 10:10:38 +00:00
|
|
|
void ClearDefines();
|
|
|
|
|
2021-05-02 00:52:13 +00:00
|
|
|
void ParseLine(std::string &Line, const char *pReadLine, EGLSLShaderCompilerType Type);
|
2020-08-29 10:10:38 +00:00
|
|
|
|
|
|
|
enum EGLSLCompilerTextureReplaceType
|
|
|
|
{
|
|
|
|
GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D = 0,
|
|
|
|
GLSL_COMPILER_TEXTURE_REPLACE_TYPE_3D,
|
|
|
|
GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D_ARRAY,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-05-02 00:52:13 +00:00
|
|
|
#endif
|