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