From 3e1da36f390b4ddbc3a48977906c1f69f009614a Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 3 Feb 2019 15:37:19 -1000 Subject: [PATCH] Ensure previous pipeline state is rebound on metal after copying render texture --- lib/graphicsdev/Metal.mm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/graphicsdev/Metal.mm b/lib/graphicsdev/Metal.mm index b901bf0..70699ab 100644 --- a/lib/graphicsdev/Metal.mm +++ b/lib/graphicsdev/Metal.mm @@ -1189,13 +1189,17 @@ struct MetalCommandQueue : IGraphicsCommandQueue { MetalShaderDataBinding* m_boundData = nullptr; + void _setShaderDataBinding(MetalShaderDataBinding* cbind) { + cbind->bind(m_enc, m_fillBuf); + m_boundData = cbind; + [m_enc setFragmentSamplerStates:m_samplers withRange:NSMakeRange(0, 5)]; + [m_enc setVertexSamplerStates:m_samplers withRange:NSMakeRange(0, 5)]; + } + void setShaderDataBinding(const ObjToken& binding) { @autoreleasepool { MetalShaderDataBinding* cbind = binding.cast(); - cbind->bind(m_enc, m_fillBuf); - m_boundData = cbind; - [m_enc setFragmentSamplerStates:m_samplers withRange:NSMakeRange(0, 5)]; - [m_enc setVertexSamplerStates:m_samplers withRange:NSMakeRange(0, 5)]; + _setShaderDataBinding(cbind); } } @@ -1347,6 +1351,8 @@ struct MetalCommandQueue : IGraphicsCommandQueue { m_enc = [m_cmdBuf renderCommandEncoderWithDescriptor:clearDepth ? tex->m_clearDepthPassDesc : tex->m_passDesc]; [m_enc setFrontFacingWinding:MTLWindingCounterClockwise]; + if (m_boundData) + _setShaderDataBinding(m_boundData); if (m_boundVp.width || m_boundVp.height) [m_enc setViewport:m_boundVp]; if (m_boundScissor.width || m_boundScissor.height)