mirror of https://github.com/AxioDL/metaforce.git
Integrate glslang AST compilation
This commit is contained in:
parent
fa1937872d
commit
99ea94de39
|
@ -20,7 +20,7 @@ set(ATHENA_INCLUDE_DIR ${ATHENA_INCLUDE_DIR} PARENT_SCOPE)
|
|||
set(SQUISH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/extern/libSquish)
|
||||
set(SQUISH_INCLUDE_DIR ${SQUISH_INCLUDE_DIR} PARENT_SCOPE)
|
||||
|
||||
set(BOO_INCLUDE_DIR extern/libBoo/include)
|
||||
set(BOO_INCLUDE_DIR extern/libBoo/include extern/libBoo/glslang)
|
||||
|
||||
add_subdirectory(bintoc)
|
||||
add_subdirectory(extern)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 9b416c6549d49ad6302c1f7a1612d051f68ad7fa
|
||||
Subproject commit a79f55c5c19f98a8699e276c191ef047c1be3afa
|
|
@ -2,6 +2,7 @@
|
|||
#define HECLBACKEND_GLSL_HPP
|
||||
|
||||
#include "ProgrammableCommon.hpp"
|
||||
#include <glslang/Public/ShaderLang.h>
|
||||
|
||||
namespace HECL
|
||||
{
|
||||
|
@ -19,6 +20,14 @@ struct GLSL : ProgrammableCommon
|
|||
const ShaderFunction& lighting,
|
||||
const ShaderFunction& post) const;
|
||||
|
||||
glslang::TShader makeVertAST(const char* glslVer, unsigned col, unsigned uv, unsigned w,
|
||||
unsigned skinSlots, unsigned texMtxs) const;
|
||||
glslang::TShader makeFragAST(const char* glslVer,
|
||||
const ShaderFunction& lighting=ShaderFunction()) const;
|
||||
glslang::TShader makeFragAST(const char* glslVer,
|
||||
const ShaderFunction& lighting,
|
||||
const ShaderFunction& post) const;
|
||||
|
||||
private:
|
||||
std::string GenerateVertInStruct(unsigned col, unsigned uv, unsigned w) const;
|
||||
std::string GenerateVertToFragStruct() const;
|
||||
|
|
|
@ -140,8 +140,9 @@ public:
|
|||
unsigned registerExtensionSlot(Function lighting, Function post)
|
||||
{
|
||||
m_extensionSlots.emplace_back();
|
||||
m_extensionSlots.back().lighting = lighting;
|
||||
m_extensionSlots.back().post = post;
|
||||
ExtensionSlot& slot = m_extensionSlots.back();
|
||||
slot.lighting = lighting;
|
||||
slot.post = post;
|
||||
return m_extensionSlots.size() - 1;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -6,6 +6,105 @@
|
|||
|
||||
static LogVisor::LogModule Log("HECL::Backend::GLSL");
|
||||
|
||||
static const TBuiltInResource DefaultBuiltInResource =
|
||||
{
|
||||
32,
|
||||
6,
|
||||
32,
|
||||
32,
|
||||
64,
|
||||
4096,
|
||||
64,
|
||||
32,
|
||||
80,
|
||||
32,
|
||||
4096,
|
||||
32,
|
||||
128,
|
||||
8,
|
||||
16,
|
||||
16,
|
||||
15,
|
||||
-8,
|
||||
7,
|
||||
8,
|
||||
65535,
|
||||
65535,
|
||||
65535,
|
||||
1024,
|
||||
1024,
|
||||
64,
|
||||
1024,
|
||||
16,
|
||||
8,
|
||||
8,
|
||||
1,
|
||||
60,
|
||||
64,
|
||||
64,
|
||||
128,
|
||||
128,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
8,
|
||||
8,
|
||||
16,
|
||||
256,
|
||||
1024,
|
||||
1024,
|
||||
64,
|
||||
128,
|
||||
128,
|
||||
16,
|
||||
1024,
|
||||
4096,
|
||||
128,
|
||||
128,
|
||||
16,
|
||||
1024,
|
||||
120,
|
||||
32,
|
||||
64,
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
8,
|
||||
8,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
16384,
|
||||
4,
|
||||
64,
|
||||
8,
|
||||
8,
|
||||
4,
|
||||
|
||||
{
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
}
|
||||
};
|
||||
|
||||
namespace HECL
|
||||
{
|
||||
namespace Backend
|
||||
|
@ -150,6 +249,20 @@ std::string GLSL::makeVert(const char* glslVer, unsigned col, unsigned uv, unsig
|
|||
return retval + "}\n";
|
||||
}
|
||||
|
||||
glslang::TShader GLSL::makeVertAST(const char* glslVer, unsigned col, unsigned uv, unsigned w,
|
||||
unsigned s, unsigned tm) const
|
||||
{
|
||||
std::string src = makeVert(glslVer, col, uv, w, s, tm);
|
||||
const char* strs[] = {src.data()};
|
||||
int lens[] = {int(src.size())};
|
||||
|
||||
glslang::TShader ret(EShLangVertex);
|
||||
ret.setStringsWithLengths(strs, lens, 1);
|
||||
ret.parse(&DefaultBuiltInResource, 110, true, EShMsgDefault);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string GLSL::makeFrag(const char* glslVer,
|
||||
const ShaderFunction& lighting) const
|
||||
{
|
||||
|
@ -191,6 +304,20 @@ std::string GLSL::makeFrag(const char* glslVer,
|
|||
return retval + "}\n";
|
||||
}
|
||||
|
||||
glslang::TShader GLSL::makeFragAST(const char* glslVer,
|
||||
const ShaderFunction& lighting) const
|
||||
{
|
||||
std::string src = makeFrag(glslVer, lighting);
|
||||
const char* strs[] = {src.data()};
|
||||
int lens[] = {int(src.size())};
|
||||
|
||||
glslang::TShader ret(EShLangFragment);
|
||||
ret.setStringsWithLengths(strs, lens, 1);
|
||||
ret.parse(&DefaultBuiltInResource, 110, true, EShMsgDefault);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string GLSL::makeFrag(const char* glslVer,
|
||||
const ShaderFunction& lighting,
|
||||
const ShaderFunction& post) const
|
||||
|
@ -241,6 +368,21 @@ std::string GLSL::makeFrag(const char* glslVer,
|
|||
return retval + "}\n";
|
||||
}
|
||||
|
||||
glslang::TShader GLSL::makeFragAST(const char* glslVer,
|
||||
const ShaderFunction& lighting,
|
||||
const ShaderFunction& post) const
|
||||
{
|
||||
std::string src = makeFrag(glslVer, lighting, post);
|
||||
const char* strs[] = {src.data()};
|
||||
int lens[] = {int(src.size())};
|
||||
|
||||
glslang::TShader ret(EShLangFragment);
|
||||
ret.setStringsWithLengths(strs, lens, 1);
|
||||
ret.parse(&DefaultBuiltInResource, 110, true, EShMsgDefault);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
namespace Runtime
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue