mirror of https://github.com/AxioDL/metaforce.git
Update GLSL backend for proper block bindings
This commit is contained in:
parent
9681a26988
commit
80284ad816
|
@ -1 +1 @@
|
|||
Subproject commit af188afc819a388e34b7b00b8e4e524ff83c94e9
|
||||
Subproject commit 54ae8c2b1a2ce58cabbebacd0ec4c0b16d92cd8c
|
|
@ -8,6 +8,9 @@ namespace hecl
|
|||
namespace Backend
|
||||
{
|
||||
|
||||
#define HECL_GLSL_VERT_UNIFORM_BLOCK_NAME "HECLVertUniform"
|
||||
#define HECL_GLSL_TEXMTX_UNIFORM_BLOCK_NAME "HECLTexMtxUniform"
|
||||
|
||||
struct GLSL : ProgrammableCommon
|
||||
{
|
||||
void reset(const IR& ir, Diagnostics& diag);
|
||||
|
|
|
@ -128,6 +128,8 @@ public:
|
|||
{
|
||||
Function lighting;
|
||||
Function post;
|
||||
size_t blockCount = 0;
|
||||
const char** blockNames = nullptr;
|
||||
};
|
||||
std::vector<ExtensionSlot> m_extensionSlots;
|
||||
|
||||
|
@ -139,12 +141,14 @@ public:
|
|||
operator bool() const {return m_plat != boo::IGraphicsDataFactory::Platform::Null;}
|
||||
|
||||
/* Strings must remain resident!! (intended to be stored static const) */
|
||||
unsigned registerExtensionSlot(Function lighting, Function post)
|
||||
unsigned registerExtensionSlot(Function lighting, Function post, size_t blockCount, const char** blockNames)
|
||||
{
|
||||
m_extensionSlots.emplace_back();
|
||||
ExtensionSlot& slot = m_extensionSlots.back();
|
||||
slot.lighting = lighting;
|
||||
slot.post = post;
|
||||
slot.blockCount = blockCount;
|
||||
slot.blockNames = blockNames;
|
||||
return m_extensionSlots.size() - 1;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -253,7 +253,8 @@ std::string GLSL::makeFrag(const char* glslVer,
|
|||
namespace Runtime
|
||||
{
|
||||
|
||||
static const char* STD_BLOCKNAMES[] = {"HECLVertUniform"};
|
||||
static const char* STD_BLOCKNAMES[] = {HECL_GLSL_VERT_UNIFORM_BLOCK_NAME,
|
||||
HECL_GLSL_TEXMTX_UNIFORM_BLOCK_NAME};
|
||||
|
||||
struct GLSLBackendFactory : IShaderBackendFactory
|
||||
{
|
||||
|
@ -280,7 +281,7 @@ struct GLSLBackendFactory : IShaderBackendFactory
|
|||
static_cast<boo::GLDataFactory::Context&>(ctx).
|
||||
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
||||
m_backend.m_texMapEnd, "texs",
|
||||
1, STD_BLOCKNAMES,
|
||||
2, STD_BLOCKNAMES,
|
||||
m_backend.m_blendSrc, m_backend.m_blendDst, tag.getPrimType(),
|
||||
tag.getDepthTest(), tag.getDepthWrite(),
|
||||
tag.getBackfaceCulling());
|
||||
|
@ -312,7 +313,7 @@ struct GLSLBackendFactory : IShaderBackendFactory
|
|||
static_cast<boo::GLDataFactory::Context&>(ctx).
|
||||
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
||||
texMapEnd, "texs",
|
||||
1, STD_BLOCKNAMES,
|
||||
2, STD_BLOCKNAMES,
|
||||
blendSrc, blendDst, tag.getPrimType(),
|
||||
tag.getDepthTest(), tag.getDepthWrite(),
|
||||
tag.getBackfaceCulling());
|
||||
|
@ -341,13 +342,20 @@ struct GLSLBackendFactory : IShaderBackendFactory
|
|||
fragSources.reserve(extensionSlots.size());
|
||||
for (const ShaderCacheExtensions::ExtensionSlot& slot : extensionSlots)
|
||||
{
|
||||
size_t bc = 2;
|
||||
const char** bn = STD_BLOCKNAMES;
|
||||
if (slot.blockCount)
|
||||
{
|
||||
bc = slot.blockCount;
|
||||
bn = slot.blockNames;
|
||||
}
|
||||
|
||||
fragSources.push_back(m_backend.makeFrag("#version 330", slot.lighting, slot.post));
|
||||
cachedSz += fragSources.back().size() + 1;
|
||||
boo::IShaderPipeline* ret =
|
||||
static_cast<boo::GLDataFactory::Context&>(ctx).
|
||||
newShaderPipeline(vertSource.c_str(), fragSources.back().c_str(),
|
||||
m_backend.m_texMapEnd, "texs",
|
||||
1, STD_BLOCKNAMES,
|
||||
m_backend.m_texMapEnd, "texs", bc, bn,
|
||||
m_backend.m_blendSrc, m_backend.m_blendDst, tag.getPrimType(),
|
||||
tag.getDepthTest(), tag.getDepthWrite(),
|
||||
tag.getBackfaceCulling());
|
||||
|
@ -381,12 +389,19 @@ struct GLSLBackendFactory : IShaderBackendFactory
|
|||
std::string vertSource = r.readString();
|
||||
for (const ShaderCacheExtensions::ExtensionSlot& slot : extensionSlots)
|
||||
{
|
||||
size_t bc = 2;
|
||||
const char** bn = STD_BLOCKNAMES;
|
||||
if (slot.blockCount)
|
||||
{
|
||||
bc = slot.blockCount;
|
||||
bn = slot.blockNames;
|
||||
}
|
||||
|
||||
std::string fragSource = r.readString();
|
||||
boo::IShaderPipeline* ret =
|
||||
static_cast<boo::GLDataFactory::Context&>(ctx).
|
||||
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
|
||||
texMapEnd, "texs",
|
||||
1, STD_BLOCKNAMES,
|
||||
texMapEnd, "texs", bc, bn,
|
||||
blendSrc, blendDst, tag.getPrimType(),
|
||||
tag.getDepthTest(), tag.getDepthWrite(),
|
||||
tag.getBackfaceCulling());
|
||||
|
|
Loading…
Reference in New Issue