diff --git a/hecl/include/hecl/Backend/Backend.hpp b/hecl/include/hecl/Backend/Backend.hpp index e31abafc6..1ca3f97e2 100644 --- a/hecl/include/hecl/Backend/Backend.hpp +++ b/hecl/include/hecl/Backend/Backend.hpp @@ -46,6 +46,14 @@ enum class ZTest : uint8_t Original = 0xff }; +enum class CullMode : uint8_t +{ + None, + Backface, + Frontface, + Original = 0xff +}; + struct TextureInfo { TexGenSrc src; diff --git a/hecl/include/hecl/Runtime.hpp b/hecl/include/hecl/Runtime.hpp index 783e71e28..a983e4833 100644 --- a/hecl/include/hecl/Runtime.hpp +++ b/hecl/include/hecl/Runtime.hpp @@ -141,7 +141,7 @@ public: Backend::BlendFactor srcFactor = Backend::BlendFactor::Original; Backend::BlendFactor dstFactor = Backend::BlendFactor::Original; Backend::ZTest depthTest = Backend::ZTest::Original; - bool frontfaceCull = false; + Backend::CullMode cullMode = Backend::CullMode::Backface; bool noDepthWrite = false; bool noColorWrite = false; bool noAlphaWrite = false; @@ -162,7 +162,7 @@ public: size_t texCount, const Backend::TextureInfo* texs, Backend::BlendFactor srcFactor, Backend::BlendFactor dstFactor, Backend::ZTest depthTest = Backend::ZTest::Original, - bool frontfaceCull = false, + Backend::CullMode cullMode = Backend::CullMode::Backface, bool noDepthWrite = false, bool noColorWrite = false, bool noAlphaWrite = false, @@ -179,7 +179,7 @@ public: slot.srcFactor = srcFactor; slot.dstFactor = dstFactor; slot.depthTest = depthTest; - slot.frontfaceCull = frontfaceCull; + slot.cullMode = cullMode; slot.noDepthWrite = noDepthWrite; slot.noColorWrite = noColorWrite; slot.noAlphaWrite = noAlphaWrite; diff --git a/hecl/lib/Backend/GLSL.cpp b/hecl/lib/Backend/GLSL.cpp index e41406552..1ec88df29 100644 --- a/hecl/lib/Backend/GLSL.cpp +++ b/hecl/lib/Backend/GLSL.cpp @@ -527,8 +527,9 @@ struct GLSLBackendFactory : IShaderBackendFactory 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), tag.getPrimType(), zTest, slot.noDepthWrite ? false : tag.getDepthWrite(), !slot.noColorWrite, !slot.noAlphaWrite, - slot.frontfaceCull ? boo::CullMode::Frontface : - (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None)); + (slot.cullMode == hecl::Backend::CullMode::Original) ? + (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) : + boo::CullMode(slot.cullMode)); if (!ret) Log.report(logvisor::Fatal, "unable to build shader"); returnFunc(ret); @@ -609,8 +610,9 @@ struct GLSLBackendFactory : IShaderBackendFactory boo::BlendFactor((slot.srcFactor == hecl::Backend::BlendFactor::Original) ? blendSrc : slot.srcFactor), boo::BlendFactor((slot.dstFactor == hecl::Backend::BlendFactor::Original) ? blendDst : slot.dstFactor), tag.getPrimType(), zTest, slot.noDepthWrite ? false : tag.getDepthWrite(), !slot.noColorWrite, !slot.noAlphaWrite, - slot.frontfaceCull ? boo::CullMode::Frontface : - (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None)); + (slot.cullMode == hecl::Backend::CullMode::Original) ? + (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) : + boo::CullMode(slot.cullMode)); if (!ret) Log.report(logvisor::Fatal, "unable to build shader"); returnFunc(ret); @@ -790,8 +792,9 @@ struct SPIRVBackendFactory : IShaderBackendFactory tag.getPrimType(), tag.getDepthTest() ? boo::ZTest::LEqual : boo::ZTest::None, slot.noDepthWrite ? false : tag.getDepthWrite(), !slot.noColorWrite, !slot.noAlphaWrite, - slot.frontfaceCull ? boo::CullMode::Frontface : - (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None)); + (slot.cullMode == hecl::Backend::CullMode::Original) ? + (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) : + boo::CullMode(slot.cullMode)); if (!ret) Log.report(logvisor::Fatal, "unable to build shader"); cachedSz += pipeBlob.vert.size() * sizeof(unsigned int); @@ -904,8 +907,9 @@ struct SPIRVBackendFactory : IShaderBackendFactory boo::BlendFactor((slot.dstFactor == hecl::Backend::BlendFactor::Original) ? blendDst : slot.dstFactor), tag.getPrimType(), zTest, slot.noDepthWrite ? false : tag.getDepthWrite(), !slot.noColorWrite, !slot.noAlphaWrite, - slot.frontfaceCull ? boo::CullMode::Frontface : - (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None)); + (slot.cullMode == hecl::Backend::CullMode::Original) ? + (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) : + boo::CullMode(slot.cullMode)); if (!ret) Log.report(logvisor::Fatal, "unable to build shader"); returnFunc(ret); diff --git a/hecl/lib/Backend/HLSL.cpp b/hecl/lib/Backend/HLSL.cpp index 68c8b1221..fd94354b7 100644 --- a/hecl/lib/Backend/HLSL.cpp +++ b/hecl/lib/Backend/HLSL.cpp @@ -544,8 +544,9 @@ struct HLSLBackendFactory : IShaderBackendFactory 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, - slot.frontfaceCull ? boo::CullMode::Frontface : - (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None)); + (slot.cullMode == hecl::Backend::CullMode::Original) ? + (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) : + boo::CullMode(slot.cullMode)); if (!ret) Log.report(logvisor::Fatal, "unable to build shader"); if (thisPipeBlobs.vert) @@ -664,8 +665,9 @@ struct HLSLBackendFactory : IShaderBackendFactory boo::BlendFactor((slot.dstFactor == hecl::Backend::BlendFactor::Original) ? blendDst : slot.dstFactor), tag.getPrimType(), zTest, slot.noDepthWrite ? false : tag.getDepthWrite(), !slot.noColorWrite, !slot.noAlphaWrite, - slot.frontfaceCull ? boo::CullMode::Frontface : - (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None)); + (slot.cullMode == hecl::Backend::CullMode::Original) ? + (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) : + boo::CullMode(slot.cullMode)); if (!ret) Log.report(logvisor::Fatal, "unable to build shader"); returnFunc(ret); diff --git a/hecl/lib/Backend/Metal.cpp b/hecl/lib/Backend/Metal.cpp index 26f3865fb..ed62300f8 100644 --- a/hecl/lib/Backend/Metal.cpp +++ b/hecl/lib/Backend/Metal.cpp @@ -591,8 +591,9 @@ struct MetalBackendFactory : IShaderBackendFactory 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, - slot.frontfaceCull ? boo::CullMode::Frontface : - (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None)); + (slot.cullMode == hecl::Backend::CullMode::Original) ? + (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) : + boo::CullMode(slot.cullMode)); if (!ret) Log.report(logvisor::Fatal, "unable to build shader"); @@ -683,8 +684,9 @@ struct MetalBackendFactory : IShaderBackendFactory boo::BlendFactor((slot.dstFactor == hecl::Backend::BlendFactor::Original) ? blendDst : slot.dstFactor), tag.getPrimType(), zTest, slot.noDepthWrite ? false : tag.getDepthWrite(), !slot.noColorWrite, !slot.noAlphaWrite, - slot.frontfaceCull ? boo::CullMode::Frontface : - (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None)); + (slot.cullMode == hecl::Backend::CullMode::Original) ? + (tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None) : + boo::CullMode(slot.cullMode)); if (!ret) Log.report(logvisor::Fatal, "unable to build shader"); returnFunc(ret); diff --git a/hecl/lib/Runtime/ShaderCacheManager.cpp b/hecl/lib/Runtime/ShaderCacheManager.cpp index b5aff33e6..b42358760 100644 --- a/hecl/lib/Runtime/ShaderCacheManager.cpp +++ b/hecl/lib/Runtime/ShaderCacheManager.cpp @@ -66,7 +66,7 @@ uint64_t ShaderCacheExtensions::hashExtensions() const UpdateFieldHash(&st, slot.srcFactor); UpdateFieldHash(&st, slot.dstFactor); UpdateFieldHash(&st, slot.depthTest); - UpdateFieldHash(&st, slot.frontfaceCull); + UpdateFieldHash(&st, slot.cullMode); UpdateFieldHash(&st, slot.noDepthWrite); UpdateFieldHash(&st, slot.noColorWrite); UpdateFieldHash(&st, slot.noAlphaWrite);