mirror of https://github.com/AxioDL/metaforce.git
Deep color CVar and GLSL backend bug fixes
This commit is contained in:
parent
da5ba6cdf3
commit
ac29a724ba
|
@ -1 +1 @@
|
||||||
Subproject commit 41cfb56c36d2b67e8da95106eac22a1fda1bcb9a
|
Subproject commit 3d987b6dc9e2c06072a5a09832e85bbd4279c2a4
|
|
@ -13,7 +13,7 @@ struct GLSL : ProgrammableCommon
|
||||||
{
|
{
|
||||||
void reset(const IR& ir, Diagnostics& diag);
|
void reset(const IR& ir, Diagnostics& diag);
|
||||||
std::string makeVert(const char* glslVer, unsigned col, unsigned uv, unsigned w,
|
std::string makeVert(const char* glslVer, unsigned col, unsigned uv, unsigned w,
|
||||||
unsigned skinSlots, unsigned texMtxs, size_t extTexCount,
|
unsigned skinSlots, size_t extTexCount,
|
||||||
const TextureInfo* extTexs, ReflectionType reflectionType) const;
|
const TextureInfo* extTexs, ReflectionType reflectionType) const;
|
||||||
std::string makeFrag(const char* glslVer, bool alphaTest, ReflectionType reflectionType,
|
std::string makeFrag(const char* glslVer, bool alphaTest, ReflectionType reflectionType,
|
||||||
const ShaderFunction& lighting=ShaderFunction()) const;
|
const ShaderFunction& lighting=ShaderFunction()) const;
|
||||||
|
@ -26,7 +26,7 @@ struct GLSL : ProgrammableCommon
|
||||||
private:
|
private:
|
||||||
std::string GenerateVertInStruct(unsigned col, unsigned uv, unsigned w) const;
|
std::string GenerateVertInStruct(unsigned col, unsigned uv, unsigned w) const;
|
||||||
std::string GenerateVertToFragStruct(size_t extTexCount, bool reflectionCoords) const;
|
std::string GenerateVertToFragStruct(size_t extTexCount, bool reflectionCoords) const;
|
||||||
std::string GenerateVertUniformStruct(unsigned skinSlots, unsigned texMtxs, bool reflectionCoords) const;
|
std::string GenerateVertUniformStruct(unsigned skinSlots, bool reflectionCoords) const;
|
||||||
std::string GenerateAlphaTest() const;
|
std::string GenerateAlphaTest() const;
|
||||||
std::string GenerateReflectionExpr(ReflectionType type) const;
|
std::string GenerateReflectionExpr(ReflectionType type) const;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ struct HLSL : ProgrammableCommon
|
||||||
{
|
{
|
||||||
void reset(const IR& ir, Diagnostics& diag);
|
void reset(const IR& ir, Diagnostics& diag);
|
||||||
std::string makeVert(unsigned col, unsigned uv, unsigned w,
|
std::string makeVert(unsigned col, unsigned uv, unsigned w,
|
||||||
unsigned skinSlots, unsigned texMtxs, size_t extTexCount,
|
unsigned skinSlots, size_t extTexCount,
|
||||||
const TextureInfo* extTexs, ReflectionType reflectionType) const;
|
const TextureInfo* extTexs, ReflectionType reflectionType) const;
|
||||||
std::string makeFrag(bool alphaTest, ReflectionType reflectionType,
|
std::string makeFrag(bool alphaTest, ReflectionType reflectionType,
|
||||||
const ShaderFunction& lighting=ShaderFunction()) const;
|
const ShaderFunction& lighting=ShaderFunction()) const;
|
||||||
|
@ -22,7 +22,7 @@ struct HLSL : ProgrammableCommon
|
||||||
private:
|
private:
|
||||||
std::string GenerateVertInStruct(unsigned col, unsigned uv, unsigned w) const;
|
std::string GenerateVertInStruct(unsigned col, unsigned uv, unsigned w) const;
|
||||||
std::string GenerateVertToFragStruct(size_t extTexCount, bool reflectionCoords) const;
|
std::string GenerateVertToFragStruct(size_t extTexCount, bool reflectionCoords) const;
|
||||||
std::string GenerateVertUniformStruct(unsigned skinSlots, unsigned texMtxs, bool reflectionCoords) const;
|
std::string GenerateVertUniformStruct(unsigned skinSlots, bool reflectionCoords) const;
|
||||||
std::string GenerateAlphaTest() const;
|
std::string GenerateAlphaTest() const;
|
||||||
std::string GenerateReflectionExpr(ReflectionType type) const;
|
std::string GenerateReflectionExpr(ReflectionType type) const;
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ struct Metal : ProgrammableCommon
|
||||||
{
|
{
|
||||||
void reset(const IR& ir, Diagnostics& diag);
|
void reset(const IR& ir, Diagnostics& diag);
|
||||||
std::string makeVert(unsigned col, unsigned uv, unsigned w,
|
std::string makeVert(unsigned col, unsigned uv, unsigned w,
|
||||||
unsigned skinSlots, unsigned texMtxs, size_t extTexCount,
|
unsigned skinSlots, size_t extTexCount,
|
||||||
const TextureInfo* extTexs, ReflectionType reflectionType) const;
|
const TextureInfo* extTexs, ReflectionType reflectionType) const;
|
||||||
std::string makeFrag(size_t blockCount, const char** blockNames, bool alphaTest,
|
std::string makeFrag(size_t blockCount, const char** blockNames, bool alphaTest,
|
||||||
ReflectionType reflectionType,
|
ReflectionType reflectionType,
|
||||||
|
|
|
@ -25,6 +25,7 @@ class CVarCommons
|
||||||
std::string m_graphicsApi = DEFAULT_GRAPHICS_API;
|
std::string m_graphicsApi = DEFAULT_GRAPHICS_API;
|
||||||
uint32_t m_drawSamples = 1;
|
uint32_t m_drawSamples = 1;
|
||||||
uint32_t m_texAnisotropy = 1;
|
uint32_t m_texAnisotropy = 1;
|
||||||
|
bool m_deepColor = false;
|
||||||
public:
|
public:
|
||||||
CVarCommons(CVarManager& manager) : m_mgr(manager)
|
CVarCommons(CVarManager& manager) : m_mgr(manager)
|
||||||
{
|
{
|
||||||
|
@ -37,6 +38,9 @@ public:
|
||||||
m_mgr.findOrMakeCVar("texAnisotropy"sv,
|
m_mgr.findOrMakeCVar("texAnisotropy"sv,
|
||||||
"Number of anisotropic samples to use for sampling textures"sv,
|
"Number of anisotropic samples to use for sampling textures"sv,
|
||||||
m_texAnisotropy, hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ModifyRestart);
|
m_texAnisotropy, hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ModifyRestart);
|
||||||
|
m_mgr.findOrMakeCVar("deepColor"sv,
|
||||||
|
"Allow framebuffer with color depth greater-then 24-bits"sv,
|
||||||
|
m_deepColor, hecl::CVar::EFlags::System | hecl::CVar::EFlags::Archive | hecl::CVar::EFlags::ModifyRestart);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getGraphicsApi() const
|
std::string getGraphicsApi() const
|
||||||
|
@ -69,6 +73,16 @@ public:
|
||||||
m_texAnisotropy = std::max(uint32_t(1), v);
|
m_texAnisotropy = std::max(uint32_t(1), v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getDeepColor() const
|
||||||
|
{
|
||||||
|
return m_deepColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setDeepColor(bool b)
|
||||||
|
{
|
||||||
|
m_deepColor = b;
|
||||||
|
}
|
||||||
|
|
||||||
void serialize()
|
void serialize()
|
||||||
{
|
{
|
||||||
m_mgr.serialize();
|
m_mgr.serialize();
|
||||||
|
|
|
@ -47,7 +47,6 @@ class ShaderTag : public Hash
|
||||||
uint8_t m_uvCount;
|
uint8_t m_uvCount;
|
||||||
uint8_t m_weightCount;
|
uint8_t m_weightCount;
|
||||||
uint8_t m_skinSlotCount;
|
uint8_t m_skinSlotCount;
|
||||||
uint8_t m_texMtxCount;
|
|
||||||
uint8_t m_primitiveType;
|
uint8_t m_primitiveType;
|
||||||
uint8_t m_reflectionType;
|
uint8_t m_reflectionType;
|
||||||
bool m_depthTest:1;
|
bool m_depthTest:1;
|
||||||
|
@ -57,21 +56,21 @@ class ShaderTag : public Hash
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
ShaderTag() = default;
|
ShaderTag() = default;
|
||||||
ShaderTag(std::string_view source, uint8_t c, uint8_t u, uint8_t w, uint8_t s, uint8_t t, boo::Primitive pt,
|
ShaderTag(std::string_view source, uint8_t c, uint8_t u, uint8_t w, uint8_t s, boo::Primitive pt,
|
||||||
Backend::ReflectionType reflectionType, bool depthTest, bool depthWrite, bool backfaceCulling)
|
Backend::ReflectionType reflectionType, bool depthTest, bool depthWrite, bool backfaceCulling)
|
||||||
: Hash(source), m_colorCount(c), m_uvCount(u), m_weightCount(w), m_skinSlotCount(s), m_texMtxCount(t),
|
: Hash(source), m_colorCount(c), m_uvCount(u), m_weightCount(w), m_skinSlotCount(s),
|
||||||
m_primitiveType(uint8_t(pt)), m_reflectionType(uint8_t(reflectionType)),
|
m_primitiveType(uint8_t(pt)), m_reflectionType(uint8_t(reflectionType)),
|
||||||
m_depthTest(depthTest), m_depthWrite(depthWrite), m_backfaceCulling(backfaceCulling)
|
m_depthTest(depthTest), m_depthWrite(depthWrite), m_backfaceCulling(backfaceCulling)
|
||||||
{hash ^= m_meta;}
|
{hash ^= m_meta;}
|
||||||
ShaderTag(const hecl::Frontend::IR& ir, uint8_t c, uint8_t u, uint8_t w, uint8_t s, uint8_t t, boo::Primitive pt,
|
ShaderTag(const hecl::Frontend::IR& ir, uint8_t c, uint8_t u, uint8_t w, uint8_t s, boo::Primitive pt,
|
||||||
Backend::ReflectionType reflectionType, bool depthTest, bool depthWrite, bool backfaceCulling)
|
Backend::ReflectionType reflectionType, bool depthTest, bool depthWrite, bool backfaceCulling)
|
||||||
: Hash(ir.m_hash), m_colorCount(c), m_uvCount(u), m_weightCount(w), m_skinSlotCount(s), m_texMtxCount(t),
|
: Hash(ir.m_hash), m_colorCount(c), m_uvCount(u), m_weightCount(w), m_skinSlotCount(s),
|
||||||
m_primitiveType(uint8_t(pt)), m_reflectionType(uint8_t(reflectionType)),
|
m_primitiveType(uint8_t(pt)), m_reflectionType(uint8_t(reflectionType)),
|
||||||
m_depthTest(depthTest), m_depthWrite(depthWrite), m_backfaceCulling(backfaceCulling)
|
m_depthTest(depthTest), m_depthWrite(depthWrite), m_backfaceCulling(backfaceCulling)
|
||||||
{hash ^= m_meta;}
|
{hash ^= m_meta;}
|
||||||
ShaderTag(uint64_t hashin, uint8_t c, uint8_t u, uint8_t w, uint8_t s, uint8_t t, boo::Primitive pt,
|
ShaderTag(uint64_t hashin, uint8_t c, uint8_t u, uint8_t w, uint8_t s, boo::Primitive pt,
|
||||||
Backend::ReflectionType reflectionType, bool depthTest, bool depthWrite, bool backfaceCulling)
|
Backend::ReflectionType reflectionType, bool depthTest, bool depthWrite, bool backfaceCulling)
|
||||||
: Hash(hashin), m_colorCount(c), m_uvCount(u), m_weightCount(w), m_skinSlotCount(s), m_texMtxCount(t),
|
: Hash(hashin), m_colorCount(c), m_uvCount(u), m_weightCount(w), m_skinSlotCount(s),
|
||||||
m_primitiveType(uint8_t(pt)), m_reflectionType(uint8_t(reflectionType)),
|
m_primitiveType(uint8_t(pt)), m_reflectionType(uint8_t(reflectionType)),
|
||||||
m_depthTest(depthTest), m_depthWrite(depthWrite), m_backfaceCulling(backfaceCulling)
|
m_depthTest(depthTest), m_depthWrite(depthWrite), m_backfaceCulling(backfaceCulling)
|
||||||
{hash ^= m_meta;}
|
{hash ^= m_meta;}
|
||||||
|
@ -82,7 +81,6 @@ public:
|
||||||
uint8_t getUvCount() const {return m_uvCount;}
|
uint8_t getUvCount() const {return m_uvCount;}
|
||||||
uint8_t getWeightCount() const {return m_weightCount;}
|
uint8_t getWeightCount() const {return m_weightCount;}
|
||||||
uint8_t getSkinSlotCount() const {return m_skinSlotCount;}
|
uint8_t getSkinSlotCount() const {return m_skinSlotCount;}
|
||||||
uint8_t getTexMtxCount() const {return m_texMtxCount;}
|
|
||||||
boo::Primitive getPrimType() const {return boo::Primitive(m_primitiveType);}
|
boo::Primitive getPrimType() const {return boo::Primitive(m_primitiveType);}
|
||||||
Backend::ReflectionType getReflectionType() const {return Backend::ReflectionType(m_reflectionType);}
|
Backend::ReflectionType getReflectionType() const {return Backend::ReflectionType(m_reflectionType);}
|
||||||
bool getDepthTest() const {return m_depthTest;}
|
bool getDepthTest() const {return m_depthTest;}
|
||||||
|
|
|
@ -87,7 +87,7 @@ std::string GLSL::GenerateVertToFragStruct(size_t extTexCount, bool reflectionCo
|
||||||
return retval + "};\n";
|
return retval + "};\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GLSL::GenerateVertUniformStruct(unsigned skinSlots, unsigned texMtxs, bool reflectionCoords) const
|
std::string GLSL::GenerateVertUniformStruct(unsigned skinSlots, bool reflectionCoords) const
|
||||||
{
|
{
|
||||||
if (skinSlots == 0)
|
if (skinSlots == 0)
|
||||||
skinSlots = 1;
|
skinSlots = 1;
|
||||||
|
@ -98,16 +98,16 @@ std::string GLSL::GenerateVertUniformStruct(unsigned skinSlots, unsigned texMtxs
|
||||||
" mat4 proj;\n"
|
" mat4 proj;\n"
|
||||||
"};\n",
|
"};\n",
|
||||||
skinSlots, skinSlots);
|
skinSlots, skinSlots);
|
||||||
if (texMtxs)
|
|
||||||
retval += hecl::Format("struct HECLTCGMatrix\n"
|
retval += "struct HECLTCGMatrix\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" mat4 mtx;\n"
|
" mat4 mtx;\n"
|
||||||
" mat4 postMtx;\n"
|
" mat4 postMtx;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
"UBINDING1 uniform HECLTexMtxUniform\n"
|
"UBINDING1 uniform HECLTexMtxUniform\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" HECLTCGMatrix texMtxs[%u];\n"
|
" HECLTCGMatrix texMtxs[8];\n"
|
||||||
"};\n", texMtxs);
|
"};\n";
|
||||||
|
|
||||||
if (reflectionCoords)
|
if (reflectionCoords)
|
||||||
retval += "UBINDING3 uniform HECLReflectMtx\n"
|
retval += "UBINDING3 uniform HECLReflectMtx\n"
|
||||||
|
@ -151,14 +151,14 @@ void GLSL::reset(const IR& ir, Diagnostics& diag)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GLSL::makeVert(const char* glslVer, unsigned col, unsigned uv, unsigned w,
|
std::string GLSL::makeVert(const char* glslVer, unsigned col, unsigned uv, unsigned w,
|
||||||
unsigned s, unsigned tm, size_t extTexCount,
|
unsigned s, size_t extTexCount,
|
||||||
const TextureInfo* extTexs, ReflectionType reflectionType) const
|
const TextureInfo* extTexs, ReflectionType reflectionType) const
|
||||||
{
|
{
|
||||||
extTexCount = std::min(int(extTexCount), BOO_GLSL_MAX_TEXTURE_COUNT - int(m_tcgs.size()));
|
extTexCount = std::min(int(extTexCount), BOO_GLSL_MAX_TEXTURE_COUNT - int(m_tcgs.size()));
|
||||||
std::string retval = std::string(glslVer) + "\n" BOO_GLSL_BINDING_HEAD +
|
std::string retval = std::string(glslVer) + "\n" BOO_GLSL_BINDING_HEAD +
|
||||||
GenerateVertInStruct(col, uv, w) + "\n" +
|
GenerateVertInStruct(col, uv, w) + "\n" +
|
||||||
GenerateVertToFragStruct(extTexCount, reflectionType != ReflectionType::None) + "\n" +
|
GenerateVertToFragStruct(extTexCount, reflectionType != ReflectionType::None) + "\n" +
|
||||||
GenerateVertUniformStruct(s, tm, reflectionType != ReflectionType::None) +
|
GenerateVertUniformStruct(s, reflectionType != ReflectionType::None) +
|
||||||
"SBINDING(0) out VertToFrag vtf;\n\n"
|
"SBINDING(0) out VertToFrag vtf;\n\n"
|
||||||
"void main()\n{\n";
|
"void main()\n{\n";
|
||||||
|
|
||||||
|
@ -381,6 +381,18 @@ static const char* STD_TEXNAMES[] =
|
||||||
"tex7"
|
"tex7"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char* EXT_TEXNAMES[] =
|
||||||
|
{
|
||||||
|
"extTex0",
|
||||||
|
"extTex1",
|
||||||
|
"extTex2",
|
||||||
|
"extTex3",
|
||||||
|
"extTex4",
|
||||||
|
"extTex5",
|
||||||
|
"extTex6",
|
||||||
|
"extTex7"
|
||||||
|
};
|
||||||
|
|
||||||
struct GLSLBackendFactory : IShaderBackendFactory
|
struct GLSLBackendFactory : IShaderBackendFactory
|
||||||
{
|
{
|
||||||
Backend::GLSL m_backend;
|
Backend::GLSL m_backend;
|
||||||
|
@ -397,7 +409,7 @@ struct GLSLBackendFactory : IShaderBackendFactory
|
||||||
std::string vertSource =
|
std::string vertSource =
|
||||||
m_backend.makeVert("#version 330",
|
m_backend.makeVert("#version 330",
|
||||||
tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
||||||
tag.getSkinSlotCount(), tag.getTexMtxCount(), 0, nullptr, tag.getReflectionType());
|
tag.getSkinSlotCount(), 0, nullptr, tag.getReflectionType());
|
||||||
cachedSz += vertSource.size() + 1;
|
cachedSz += vertSource.size() + 1;
|
||||||
|
|
||||||
std::string fragSource = m_backend.makeFrag("#version 330",
|
std::string fragSource = m_backend.makeFrag("#version 330",
|
||||||
|
@ -490,7 +502,7 @@ struct GLSLBackendFactory : IShaderBackendFactory
|
||||||
|
|
||||||
sources.emplace_back(m_backend.makeVert("#version 330",
|
sources.emplace_back(m_backend.makeVert("#version 330",
|
||||||
tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
||||||
tag.getSkinSlotCount(), tag.getTexMtxCount(), slot.texCount,
|
tag.getSkinSlotCount(), slot.texCount,
|
||||||
slot.texs, tag.getReflectionType()),
|
slot.texs, tag.getReflectionType()),
|
||||||
m_backend.makeFrag("#version 330",
|
m_backend.makeFrag("#version 330",
|
||||||
tag.getDepthWrite() && m_backend.m_blendDst == hecl::Backend::BlendFactor::InvSrcAlpha,
|
tag.getDepthWrite() && m_backend.m_blendDst == hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||||
|
@ -519,10 +531,16 @@ struct GLSLBackendFactory : IShaderBackendFactory
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* ExtTexnames[8];
|
||||||
|
for (int i=0 ; i<8 ; ++i)
|
||||||
|
ExtTexnames[i] = STD_TEXNAMES[i];
|
||||||
|
for (int i=0 ; i<slot.texCount ; ++i)
|
||||||
|
ExtTexnames[slot.texs[i].mapIdx] = EXT_TEXNAMES[slot.texs[i].mapIdx];
|
||||||
|
|
||||||
auto ret =
|
auto ret =
|
||||||
static_cast<boo::GLDataFactory::Context&>(ctx).
|
static_cast<boo::GLDataFactory::Context&>(ctx).
|
||||||
newShaderPipeline(sources.back().first.c_str(), sources.back().second.c_str(),
|
newShaderPipeline(sources.back().first.c_str(), sources.back().second.c_str(),
|
||||||
8, STD_TEXNAMES, bc, bn,
|
8, ExtTexnames, bc, bn,
|
||||||
boo::BlendFactor((slot.srcFactor == hecl::Backend::BlendFactor::Original) ? m_backend.m_blendSrc : slot.srcFactor),
|
boo::BlendFactor((slot.srcFactor == hecl::Backend::BlendFactor::Original) ? m_backend.m_blendSrc : slot.srcFactor),
|
||||||
boo::BlendFactor((slot.dstFactor == hecl::Backend::BlendFactor::Original) ? m_backend.m_blendDst : slot.dstFactor),
|
boo::BlendFactor((slot.dstFactor == hecl::Backend::BlendFactor::Original) ? m_backend.m_blendDst : slot.dstFactor),
|
||||||
tag.getPrimType(), zTest, slot.noDepthWrite ? false : tag.getDepthWrite(), !slot.noColorWrite, !slot.noAlphaWrite,
|
tag.getPrimType(), zTest, slot.noDepthWrite ? false : tag.getDepthWrite(), !slot.noColorWrite, !slot.noAlphaWrite,
|
||||||
|
@ -602,10 +620,16 @@ struct GLSLBackendFactory : IShaderBackendFactory
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* ExtTexnames[8];
|
||||||
|
for (int i=0 ; i<8 ; ++i)
|
||||||
|
ExtTexnames[i] = STD_TEXNAMES[i];
|
||||||
|
for (int i=0 ; i<slot.texCount ; ++i)
|
||||||
|
ExtTexnames[slot.texs[i].mapIdx] = EXT_TEXNAMES[slot.texs[i].mapIdx];
|
||||||
|
|
||||||
auto ret =
|
auto 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(),
|
||||||
8, STD_TEXNAMES, bc, bn,
|
8, ExtTexnames, bc, bn,
|
||||||
boo::BlendFactor((slot.srcFactor == hecl::Backend::BlendFactor::Original) ? blendSrc : slot.srcFactor),
|
boo::BlendFactor((slot.srcFactor == hecl::Backend::BlendFactor::Original) ? blendSrc : slot.srcFactor),
|
||||||
boo::BlendFactor((slot.dstFactor == hecl::Backend::BlendFactor::Original) ? blendDst : slot.dstFactor),
|
boo::BlendFactor((slot.dstFactor == hecl::Backend::BlendFactor::Original) ? blendDst : slot.dstFactor),
|
||||||
tag.getPrimType(), zTest, slot.noDepthWrite ? false : tag.getDepthWrite(), !slot.noColorWrite, !slot.noAlphaWrite,
|
tag.getPrimType(), zTest, slot.noDepthWrite ? false : tag.getDepthWrite(), !slot.noColorWrite, !slot.noAlphaWrite,
|
||||||
|
@ -643,7 +667,7 @@ struct SPIRVBackendFactory : IShaderBackendFactory
|
||||||
std::string vertSource =
|
std::string vertSource =
|
||||||
m_backend.makeVert("#version 330",
|
m_backend.makeVert("#version 330",
|
||||||
tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
||||||
tag.getSkinSlotCount(), tag.getTexMtxCount(), 0, nullptr,
|
tag.getSkinSlotCount(), 0, nullptr,
|
||||||
tag.getReflectionType());
|
tag.getReflectionType());
|
||||||
|
|
||||||
std::string fragSource = m_backend.makeFrag("#version 330",
|
std::string fragSource = m_backend.makeFrag("#version 330",
|
||||||
|
@ -771,7 +795,7 @@ struct SPIRVBackendFactory : IShaderBackendFactory
|
||||||
std::string vertSource =
|
std::string vertSource =
|
||||||
m_backend.makeVert("#version 330",
|
m_backend.makeVert("#version 330",
|
||||||
tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
||||||
tag.getSkinSlotCount(), tag.getTexMtxCount(), slot.texCount, slot.texs,
|
tag.getSkinSlotCount(), slot.texCount, slot.texs,
|
||||||
tag.getReflectionType());
|
tag.getReflectionType());
|
||||||
|
|
||||||
std::string fragSource = m_backend.makeFrag("#version 330",
|
std::string fragSource = m_backend.makeFrag("#version 330",
|
||||||
|
|
|
@ -80,7 +80,7 @@ std::string HLSL::GenerateVertToFragStruct(size_t extTexCount, bool reflectionCo
|
||||||
return retval + "};\n";
|
return retval + "};\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string HLSL::GenerateVertUniformStruct(unsigned skinSlots, unsigned texMtxs, bool reflectionCoords) const
|
std::string HLSL::GenerateVertUniformStruct(unsigned skinSlots, bool reflectionCoords) const
|
||||||
{
|
{
|
||||||
if (skinSlots == 0)
|
if (skinSlots == 0)
|
||||||
skinSlots = 1;
|
skinSlots = 1;
|
||||||
|
@ -91,16 +91,15 @@ std::string HLSL::GenerateVertUniformStruct(unsigned skinSlots, unsigned texMtxs
|
||||||
" float4x4 proj;\n"
|
" float4x4 proj;\n"
|
||||||
"};\n",
|
"};\n",
|
||||||
skinSlots, skinSlots);
|
skinSlots, skinSlots);
|
||||||
if (texMtxs)
|
retval += "struct TCGMtx\n"
|
||||||
retval += hecl::Format("struct TCGMtx\n"
|
|
||||||
"{\n"
|
"{\n"
|
||||||
" float4x4 mtx;\n"
|
" float4x4 mtx;\n"
|
||||||
" float4x4 postMtx;\n"
|
" float4x4 postMtx;\n"
|
||||||
"};\n"
|
"};\n"
|
||||||
"cbuffer HECLTCGMatrix : register(b1)\n"
|
"cbuffer HECLTCGMatrix : register(b1)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" TCGMtx texMtxs[%u];\n"
|
" TCGMtx texMtxs[8];\n"
|
||||||
"};\n", texMtxs);
|
"};\n";
|
||||||
|
|
||||||
if (reflectionCoords)
|
if (reflectionCoords)
|
||||||
retval += "cbuffer HECLReflectMtx : register(b3)\n"
|
retval += "cbuffer HECLReflectMtx : register(b3)\n"
|
||||||
|
@ -144,13 +143,13 @@ void HLSL::reset(const IR& ir, Diagnostics& diag)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string HLSL::makeVert(unsigned col, unsigned uv, unsigned w,
|
std::string HLSL::makeVert(unsigned col, unsigned uv, unsigned w,
|
||||||
unsigned s, unsigned tm, size_t extTexCount,
|
unsigned s, size_t extTexCount,
|
||||||
const TextureInfo* extTexs, ReflectionType reflectionType) const
|
const TextureInfo* extTexs, ReflectionType reflectionType) const
|
||||||
{
|
{
|
||||||
std::string retval =
|
std::string retval =
|
||||||
GenerateVertInStruct(col, uv, w) + "\n" +
|
GenerateVertInStruct(col, uv, w) + "\n" +
|
||||||
GenerateVertToFragStruct(extTexCount, reflectionType != ReflectionType::None) + "\n" +
|
GenerateVertToFragStruct(extTexCount, reflectionType != ReflectionType::None) + "\n" +
|
||||||
GenerateVertUniformStruct(s, tm, reflectionType != ReflectionType::None) + "\n" +
|
GenerateVertUniformStruct(s, reflectionType != ReflectionType::None) + "\n" +
|
||||||
"VertToFrag main(in VertData v)\n"
|
"VertToFrag main(in VertData v)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" VertToFrag vtf;\n";
|
" VertToFrag vtf;\n";
|
||||||
|
@ -365,7 +364,7 @@ struct HLSLBackendFactory : IShaderBackendFactory
|
||||||
|
|
||||||
std::string vertSource =
|
std::string vertSource =
|
||||||
m_backend.makeVert(tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
m_backend.makeVert(tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
||||||
tag.getSkinSlotCount(), tag.getTexMtxCount(), 0, nullptr,
|
tag.getSkinSlotCount(), 0, nullptr,
|
||||||
tag.getReflectionType());
|
tag.getReflectionType());
|
||||||
|
|
||||||
std::string fragSource = m_backend.makeFrag(tag.getDepthWrite() && m_backend.m_blendDst == hecl::Backend::BlendFactor::InvSrcAlpha,
|
std::string fragSource = m_backend.makeFrag(tag.getDepthWrite() && m_backend.m_blendDst == hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||||
|
@ -505,7 +504,7 @@ struct HLSLBackendFactory : IShaderBackendFactory
|
||||||
{
|
{
|
||||||
std::string vertSource =
|
std::string vertSource =
|
||||||
m_backend.makeVert(tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
m_backend.makeVert(tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
||||||
tag.getSkinSlotCount(), tag.getTexMtxCount(), slot.texCount, slot.texs,
|
tag.getSkinSlotCount(), slot.texCount, slot.texs,
|
||||||
tag.getReflectionType());
|
tag.getReflectionType());
|
||||||
|
|
||||||
std::string fragSource = m_backend.makeFrag(tag.getDepthWrite() && m_backend.m_blendDst == hecl::Backend::BlendFactor::InvSrcAlpha,
|
std::string fragSource = m_backend.makeFrag(tag.getDepthWrite() && m_backend.m_blendDst == hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||||
|
|
|
@ -148,12 +148,10 @@ void Metal::reset(const IR& ir, Diagnostics& diag)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Metal::makeVert(unsigned col, unsigned uv, unsigned w,
|
std::string Metal::makeVert(unsigned col, unsigned uv, unsigned w,
|
||||||
unsigned s, unsigned tm, size_t extTexCount,
|
unsigned s, size_t extTexCount,
|
||||||
const TextureInfo* extTexs, ReflectionType reflectionType) const
|
const TextureInfo* extTexs, ReflectionType reflectionType) const
|
||||||
{
|
{
|
||||||
std::string tmStr;
|
std::string tmStr = ",\nconstant TexMtxs* texMtxs [[ buffer(3) ]]";
|
||||||
if (tm)
|
|
||||||
tmStr = hecl::Format(",\nconstant TexMtxs* texMtxs [[ buffer(3) ]]");
|
|
||||||
if (reflectionType != ReflectionType::None)
|
if (reflectionType != ReflectionType::None)
|
||||||
tmStr += ",\nconstant ReflectTexMtxs& reflectMtxs [[ buffer(5) ]]";
|
tmStr += ",\nconstant ReflectTexMtxs& reflectMtxs [[ buffer(5) ]]";
|
||||||
std::string retval = "#include <metal_stdlib>\nusing namespace metal;\n" +
|
std::string retval = "#include <metal_stdlib>\nusing namespace metal;\n" +
|
||||||
|
@ -447,7 +445,7 @@ struct MetalBackendFactory : IShaderBackendFactory
|
||||||
|
|
||||||
std::string vertSource =
|
std::string vertSource =
|
||||||
m_backend.makeVert(tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
m_backend.makeVert(tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
||||||
tag.getSkinSlotCount(), tag.getTexMtxCount(), 0, nullptr, tag.getReflectionType());
|
tag.getSkinSlotCount(), 0, nullptr, tag.getReflectionType());
|
||||||
|
|
||||||
std::string fragSource = m_backend.makeFrag(0, nullptr,
|
std::string fragSource = m_backend.makeFrag(0, nullptr,
|
||||||
tag.getDepthWrite() && m_backend.m_blendDst == hecl::Backend::BlendFactor::InvSrcAlpha,
|
tag.getDepthWrite() && m_backend.m_blendDst == hecl::Backend::BlendFactor::InvSrcAlpha,
|
||||||
|
@ -537,7 +535,7 @@ struct MetalBackendFactory : IShaderBackendFactory
|
||||||
{
|
{
|
||||||
std::string vertSource =
|
std::string vertSource =
|
||||||
m_backend.makeVert(tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
m_backend.makeVert(tag.getColorCount(), tag.getUvCount(), tag.getWeightCount(),
|
||||||
tag.getSkinSlotCount(), tag.getTexMtxCount(), slot.texCount, slot.texs,
|
tag.getSkinSlotCount(), slot.texCount, slot.texs,
|
||||||
slot.noReflection ? Backend::ReflectionType::None : tag.getReflectionType());
|
slot.noReflection ? Backend::ReflectionType::None : tag.getReflectionType());
|
||||||
std::string fragSource =
|
std::string fragSource =
|
||||||
m_backend.makeFrag(slot.blockCount, slot.blockNames,
|
m_backend.makeFrag(slot.blockCount, slot.blockNames,
|
||||||
|
|
Loading…
Reference in New Issue