Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
Updated rendering interface for boo
Browse files Browse the repository at this point in the history
  • Loading branch information
jackoalan committed Mar 17, 2017
1 parent 04330e9 commit 8e1bc5d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 9 deletions.
2 changes: 1 addition & 1 deletion extern/boo
38 changes: 32 additions & 6 deletions lib/Backend/GLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ struct SPIRVBackendFactory : IShaderBackendFactory
newShaderPipeline(vertSource.c_str(), fragSource.c_str(),
&vertBlob, &fragBlob, &pipelineBlob, tag.newVertexFormat(ctx),
boo::BlendFactor(m_backend.m_blendSrc), boo::BlendFactor(m_backend.m_blendDst),
tag.getPrimType(), tag.getDepthTest(), tag.getDepthWrite(),
tag.getPrimType(), tag.getDepthTest() ? boo::ZTest::LEqual : boo::ZTest::None,
tag.getDepthWrite(), true, false,
tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None);
if (!objOut)
Log.report(logvisor::Fatal, "unable to build shader");
Expand Down Expand Up @@ -679,7 +680,8 @@ struct SPIRVBackendFactory : IShaderBackendFactory
&vertBlob, &fragBlob, &pipelineBlob,
tag.newVertexFormat(ctx),
blendSrc, blendDst, tag.getPrimType(),
tag.getDepthTest(), tag.getDepthWrite(),
tag.getDepthTest() ? boo::ZTest::LEqual : boo::ZTest::None,
tag.getDepthWrite(), true, false,
tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None);
if (!ret)
Log.report(logvisor::Fatal, "unable to build shader");
Expand Down Expand Up @@ -726,9 +728,11 @@ struct SPIRVBackendFactory : IShaderBackendFactory
m_backend.m_blendSrc : slot.srcFactor),
boo::BlendFactor((slot.dstFactor == hecl::Backend::BlendFactor::Original) ?
m_backend.m_blendDst : slot.dstFactor),
tag.getPrimType(), tag.getDepthTest(), slot.noDepthWrite ? false : tag.getDepthWrite(),
tag.getPrimType(), tag.getDepthTest() ? boo::ZTest::LEqual : boo::ZTest::None,
slot.noDepthWrite ? false : tag.getDepthWrite(),
!slot.noColorWrite, !slot.noAlphaWrite,
tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None);
slot.frontfaceCull ? boo::CullMode::Frontface :
(tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None));
if (!ret)
Log.report(logvisor::Fatal, "unable to build shader");
cachedSz += pipeBlob.vert.size() * sizeof(unsigned int);
Expand Down Expand Up @@ -811,16 +815,38 @@ struct SPIRVBackendFactory : IShaderBackendFactory
if (r.hasError())
return false;

boo::ZTest zTest;
switch (slot.depthTest)
{
case hecl::Backend::ZTest::Original:
default:
zTest = tag.getDepthTest() ? boo::ZTest::LEqual : boo::ZTest::None;
break;
case hecl::Backend::ZTest::None:
zTest = boo::ZTest::None;
break;
case hecl::Backend::ZTest::LEqual:
zTest = boo::ZTest::LEqual;
break;
case hecl::Backend::ZTest::Greater:
zTest = boo::ZTest::Greater;
break;
case hecl::Backend::ZTest::Equal:
zTest = boo::ZTest::Equal;
break;
}

boo::IShaderPipeline* ret =
static_cast<boo::VulkanDataFactory::Context&>(ctx).
newShaderPipeline(nullptr, nullptr,
&vertBlob, &fragBlob, &pipelineBlob,
tag.newVertexFormat(ctx),
boo::BlendFactor((slot.srcFactor == hecl::Backend::BlendFactor::Original) ? blendSrc : slot.srcFactor),
boo::BlendFactor((slot.dstFactor == hecl::Backend::BlendFactor::Original) ? blendDst : slot.dstFactor),
tag.getPrimType(), tag.getDepthTest(), slot.noDepthWrite ? false : tag.getDepthWrite(),
tag.getPrimType(), zTest, slot.noDepthWrite ? false : tag.getDepthWrite(),
!slot.noColorWrite, !slot.noAlphaWrite,
tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None);
slot.frontfaceCull ? boo::CullMode::Frontface :
(tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None));
if (!ret)
Log.report(logvisor::Fatal, "unable to build shader");
returnFunc(ret);
Expand Down
6 changes: 4 additions & 2 deletions lib/Backend/HLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ struct HLSLBackendFactory : IShaderBackendFactory
boo::BlendFactor(m_backend.m_blendSrc),
boo::BlendFactor(m_backend.m_blendDst),
tag.getPrimType(),
tag.getDepthTest(), tag.getDepthWrite(),
tag.getDepthTest() ? boo::ZTest::LEqual : boo::ZTest::None, tag.getDepthWrite(), true, false,
tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None);
if (!objOut)
Log.report(logvisor::Fatal, "unable to build shader");
Expand Down Expand Up @@ -415,7 +415,7 @@ struct HLSLBackendFactory : IShaderBackendFactory
ReferenceComPtr(vertBlob), ReferenceComPtr(fragBlob), ReferenceComPtr(pipelineBlob),
tag.newVertexFormat(ctx),
blendSrc, blendDst, tag.getPrimType(),
tag.getDepthTest(), tag.getDepthWrite(),
tag.getDepthTest() ? boo::ZTest::LEqual : boo::ZTest::None, tag.getDepthWrite(), true, false,
tag.getBackfaceCulling() ? boo::CullMode::Backface : boo::CullMode::None);
if (!ret)
Log.report(logvisor::Fatal, "unable to build shader");
Expand Down Expand Up @@ -481,6 +481,7 @@ struct HLSLBackendFactory : 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));
if (!ret)
Expand Down Expand Up @@ -600,6 +601,7 @@ struct HLSLBackendFactory : 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));
if (!ret)
Expand Down
12 changes: 12 additions & 0 deletions lib/Runtime/ShaderCacheManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ static void UpdateFunctionHash(XXH64_state_t* st, const ShaderCacheExtensions::F
if (func.m_entry)
XXH64_update(st, func.m_entry, strlen(func.m_entry));
}
template<typename T>
static void UpdateFieldHash(XXH64_state_t* st, T field)
{
XXH64_update(st, &field, sizeof(field));
}
uint64_t ShaderCacheExtensions::hashExtensions() const
{
XXH64_state_t st;
Expand All @@ -56,6 +61,13 @@ uint64_t ShaderCacheExtensions::hashExtensions() const
{
UpdateFunctionHash(&st, slot.lighting);
UpdateFunctionHash(&st, slot.post);
UpdateFieldHash(&st, slot.srcFactor);
UpdateFieldHash(&st, slot.dstFactor);
UpdateFieldHash(&st, slot.depthTest);
UpdateFieldHash(&st, slot.frontfaceCull);
UpdateFieldHash(&st, slot.noDepthWrite);
UpdateFieldHash(&st, slot.noColorWrite);
UpdateFieldHash(&st, slot.noAlphaWrite);
}
return XXH64_digest(&st);
}
Expand Down

0 comments on commit 8e1bc5d

Please sign in to comment.