mirror of https://github.com/AxioDL/boo.git
Add frontface culling support to Metal
This commit is contained in:
parent
ca20aea834
commit
73891af56a
|
@ -554,12 +554,23 @@ class MetalShaderPipeline : public IShaderPipeline
|
||||||
MetalShareableShader::Token&& frag,
|
MetalShareableShader::Token&& frag,
|
||||||
const MetalVertexFormat* vtxFmt, NSUInteger targetSamples,
|
const MetalVertexFormat* vtxFmt, NSUInteger targetSamples,
|
||||||
BlendFactor srcFac, BlendFactor dstFac, Primitive prim,
|
BlendFactor srcFac, BlendFactor dstFac, Primitive prim,
|
||||||
bool depthTest, bool depthWrite, bool backfaceCulling)
|
bool depthTest, bool depthWrite, CullMode culling)
|
||||||
: m_drawPrim(PRIMITIVE_TABLE[int(prim)]), m_vtxFmt(vtxFmt),
|
: m_drawPrim(PRIMITIVE_TABLE[int(prim)]), m_vtxFmt(vtxFmt),
|
||||||
m_vert(std::move(vert)), m_frag(std::move(frag))
|
m_vert(std::move(vert)), m_frag(std::move(frag))
|
||||||
{
|
{
|
||||||
if (backfaceCulling)
|
switch (culling)
|
||||||
|
{
|
||||||
|
case CullMode::None:
|
||||||
|
default:
|
||||||
|
m_cullMode = MTLCullModeNone;
|
||||||
|
break;
|
||||||
|
case CullMode::Backface:
|
||||||
m_cullMode = MTLCullModeBack;
|
m_cullMode = MTLCullModeBack;
|
||||||
|
break;
|
||||||
|
case CullMode::Frontface:
|
||||||
|
m_cullMode = MTLCullModeFront;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
MTLRenderPipelineDescriptor* desc = [MTLRenderPipelineDescriptor new];
|
MTLRenderPipelineDescriptor* desc = [MTLRenderPipelineDescriptor new];
|
||||||
desc.vertexFunction = m_vert.get().m_shader;
|
desc.vertexFunction = m_vert.get().m_shader;
|
||||||
|
@ -1219,7 +1230,7 @@ IShaderPipeline* MetalDataFactory::Context::newShaderPipeline(const char* vertSo
|
||||||
|
|
||||||
MetalShaderPipeline* retval = new MetalShaderPipeline(factory.m_ctx, std::move(vertShader), std::move(fragShader),
|
MetalShaderPipeline* retval = new MetalShaderPipeline(factory.m_ctx, std::move(vertShader), std::move(fragShader),
|
||||||
static_cast<const MetalVertexFormat*>(vtxFmt), targetSamples,
|
static_cast<const MetalVertexFormat*>(vtxFmt), targetSamples,
|
||||||
srcFac, dstFac, prim, depthTest, depthWrite, backfaceCulling);
|
srcFac, dstFac, prim, depthTest, depthWrite, culling);
|
||||||
MetalDataFactoryImpl::m_deferredData->m_SPs.emplace_back(retval);
|
MetalDataFactoryImpl::m_deferredData->m_SPs.emplace_back(retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,7 +403,7 @@ struct TestApplicationCallback : IApplicationCallback
|
||||||
|
|
||||||
pipeline = metalF.newShaderPipeline(VS, FS, vfmt, 1,
|
pipeline = metalF.newShaderPipeline(VS, FS, vfmt, 1,
|
||||||
BlendFactor::One, BlendFactor::Zero, Primitive::TriStrips,
|
BlendFactor::One, BlendFactor::Zero, Primitive::TriStrips,
|
||||||
true, true, false);
|
true, true, boo::CullMode::None);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue