Add shader mode for constant alpha overwrite

This commit is contained in:
Jack Andersen 2018-02-04 20:54:35 -10:00
parent ae076c5a32
commit 7a60440d58
6 changed files with 26 additions and 21 deletions

2
hecl/extern/boo vendored

@ -1 +1 @@
Subproject commit 25dfeb64aae6321ec18b82b1608b3624f1f5279c
Subproject commit 1e5e26ced8cdb7e91cc6e6076457bfe14cb75b51

View File

@ -143,6 +143,7 @@ public:
bool noDepthWrite = false;
bool noColorWrite = false;
bool noAlphaWrite = false;
bool noAlphaOverwrite = false;
bool noReflection = false;
};
std::vector<ExtensionSlot> m_extensionSlots;
@ -164,6 +165,7 @@ public:
bool noDepthWrite = false,
bool noColorWrite = false,
bool noAlphaWrite = false,
bool noAlphaOverwrite = false,
bool noReflection = false)
{
m_extensionSlots.emplace_back();
@ -181,6 +183,7 @@ public:
slot.noDepthWrite = noDepthWrite;
slot.noColorWrite = noColorWrite;
slot.noAlphaWrite = noAlphaWrite;
slot.noAlphaOverwrite = noAlphaOverwrite;
slot.noReflection = noReflection;
return m_extensionSlots.size() - 1;
}

View File

@ -15,9 +15,9 @@ std::string GLSL::EmitTexGenSource2(TexGenSrc src, int uvIdx) const
switch (src)
{
case TexGenSrc::Position:
return "posIn.xy";
return "vtf.mvPos.xy";
case TexGenSrc::Normal:
return "normIn.xy";
return "vtf.mvNorm.xy";
case TexGenSrc::UV:
return hecl::Format("uvIn[%u]", uvIdx);
default: break;
@ -30,9 +30,9 @@ std::string GLSL::EmitTexGenSource4(TexGenSrc src, int uvIdx) const
switch (src)
{
case TexGenSrc::Position:
return "vec4(posIn, 1.0)";
return "vec4(vtf.mvPos.xyz, 1.0)";
case TexGenSrc::Normal:
return "vec4(normIn, 1.0)";
return "vec4(vtf.mvNorm.xyz, 1.0)";
case TexGenSrc::UV:
return hecl::Format("vec4(uvIn[%u], 0.0, 1.0)", uvIdx);
default: break;
@ -546,7 +546,7 @@ struct GLSLBackendFactory : IShaderBackendFactory
tag.getPrimType(), zTest, slot.noDepthWrite ? false : tag.getDepthWrite(), !slot.noColorWrite, !slot.noAlphaWrite,
(slot.cullMode == hecl::Backend::CullMode::Original) ?
(tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) :
boo::CullMode(slot.cullMode));
boo::CullMode(slot.cullMode), !slot.noAlphaOverwrite);
if (!ret)
Log.report(logvisor::Fatal, "unable to build shader");
returnFunc(ret);
@ -635,7 +635,7 @@ struct GLSLBackendFactory : IShaderBackendFactory
tag.getPrimType(), zTest, slot.noDepthWrite ? false : tag.getDepthWrite(), !slot.noColorWrite, !slot.noAlphaWrite,
(slot.cullMode == hecl::Backend::CullMode::Original) ?
(tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) :
boo::CullMode(slot.cullMode));
boo::CullMode(slot.cullMode), !slot.noAlphaOverwrite);
if (!ret)
Log.report(logvisor::Fatal, "unable to build shader");
returnFunc(ret);
@ -817,7 +817,7 @@ struct SPIRVBackendFactory : IShaderBackendFactory
!slot.noColorWrite, !slot.noAlphaWrite,
(slot.cullMode == hecl::Backend::CullMode::Original) ?
(tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) :
boo::CullMode(slot.cullMode));
boo::CullMode(slot.cullMode), !slot.noAlphaOverwrite);
if (!ret)
Log.report(logvisor::Fatal, "unable to build shader");
cachedSz += pipeBlob.vert.size() * sizeof(unsigned int);
@ -932,7 +932,7 @@ struct SPIRVBackendFactory : IShaderBackendFactory
!slot.noColorWrite, !slot.noAlphaWrite,
(slot.cullMode == hecl::Backend::CullMode::Original) ?
(tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) :
boo::CullMode(slot.cullMode));
boo::CullMode(slot.cullMode), !slot.noAlphaOverwrite);
if (!ret)
Log.report(logvisor::Fatal, "unable to build shader");
returnFunc(ret);

View File

@ -14,9 +14,9 @@ std::string HLSL::EmitTexGenSource2(TexGenSrc src, int uvIdx) const
switch (src)
{
case TexGenSrc::Position:
return "v.posIn.xy\n";
return "vtf.mvPos.xy\n";
case TexGenSrc::Normal:
return "v.normIn.xy\n";
return "vtf.mvNorm.xy\n";
case TexGenSrc::UV:
return hecl::Format("v.uvIn[%u]", uvIdx);
default: break;
@ -29,9 +29,9 @@ std::string HLSL::EmitTexGenSource4(TexGenSrc src, int uvIdx) const
switch (src)
{
case TexGenSrc::Position:
return "float4(v.posIn, 1.0)\n";
return "float4(vtf.mvPos.xyz, 1.0)\n";
case TexGenSrc::Normal:
return "float4(v.normIn, 1.0)\n";
return "float4(vtf.mvNorm.xyz, 1.0)\n";
case TexGenSrc::UV:
return hecl::Format("float4(v.uvIn[%u], 0.0, 1.0)", uvIdx);
default: break;
@ -544,7 +544,7 @@ struct HLSLBackendFactory : IShaderBackendFactory
!slot.noColorWrite, !slot.noAlphaWrite,
(slot.cullMode == hecl::Backend::CullMode::Original) ?
(tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) :
boo::CullMode(slot.cullMode));
boo::CullMode(slot.cullMode), !slot.noAlphaOverwrite);
if (!ret)
Log.report(logvisor::Fatal, "unable to build shader");
if (thisPipeBlobs.vert)
@ -665,7 +665,7 @@ struct HLSLBackendFactory : IShaderBackendFactory
!slot.noColorWrite, !slot.noAlphaWrite,
(slot.cullMode == hecl::Backend::CullMode::Original) ?
(tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) :
boo::CullMode(slot.cullMode));
boo::CullMode(slot.cullMode), !slot.noAlphaOverwrite);
if (!ret)
Log.report(logvisor::Fatal, "unable to build shader");
returnFunc(ret);

View File

@ -14,9 +14,9 @@ std::string Metal::EmitTexGenSource2(TexGenSrc src, int uvIdx) const
switch (src)
{
case TexGenSrc::Position:
return "v.posIn.xy\n";
return "vtf.mvPos.xy\n";
case TexGenSrc::Normal:
return "v.normIn.xy\n";
return "vtf.mvNorm.xy\n";
case TexGenSrc::UV:
return hecl::Format("v.uvIn%u", uvIdx);
default: break;
@ -29,9 +29,9 @@ std::string Metal::EmitTexGenSource4(TexGenSrc src, int uvIdx) const
switch (src)
{
case TexGenSrc::Position:
return "float4(v.posIn, 1.0)\n";
return "float4(vtf.mvPos.xyz, 1.0)\n";
case TexGenSrc::Normal:
return "float4(v.normIn, 1.0)\n";
return "float4(vtf.mvNorm.xyz, 1.0)\n";
case TexGenSrc::UV:
return hecl::Format("float4(v.uvIn%u, 0.0, 1.0)", uvIdx);
default: break;
@ -576,7 +576,7 @@ struct MetalBackendFactory : IShaderBackendFactory
!slot.noColorWrite, !slot.noAlphaWrite,
(slot.cullMode == hecl::Backend::CullMode::Original) ?
(tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) :
boo::CullMode(slot.cullMode));
boo::CullMode(slot.cullMode), !slot.noAlphaOverwrite);
if (!ret)
Log.report(logvisor::Fatal, "unable to build shader");
@ -665,7 +665,7 @@ struct MetalBackendFactory : IShaderBackendFactory
!slot.noColorWrite, !slot.noAlphaWrite,
(slot.cullMode == hecl::Backend::CullMode::Original) ?
(tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) :
boo::CullMode(slot.cullMode));
boo::CullMode(slot.cullMode), !slot.noAlphaOverwrite);
if (!ret)
Log.report(logvisor::Fatal, "unable to build shader");
returnFunc(ret);

View File

@ -71,6 +71,8 @@ uint64_t ShaderCacheExtensions::hashExtensions() const
UpdateFieldHash(&st, slot.noDepthWrite);
UpdateFieldHash(&st, slot.noColorWrite);
UpdateFieldHash(&st, slot.noAlphaWrite);
UpdateFieldHash(&st, slot.noAlphaOverwrite);
UpdateFieldHash(&st, slot.noReflection);
}
return XXH64_digest(&st);
}