From e84f78b60bc750ebffdec2960bda24dee4b2ad63 Mon Sep 17 00:00:00 2001 From: Attila Kocsis Date: Sun, 21 Apr 2019 11:31:43 +0200 Subject: [PATCH] fixed uninitialized constant buffer memory --- src/renderer_mtl.mm | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/renderer_mtl.mm b/src/renderer_mtl.mm index 05ebdb8d1..da4242468 100644 --- a/src/renderer_mtl.mm +++ b/src/renderer_mtl.mm @@ -3953,7 +3953,6 @@ namespace bgfx { namespace mtl const RenderCompute& compute = renderItem.compute; bool programChanged = false; - bool constantsChanged = compute.m_uniformBegin < compute.m_uniformEnd; rendererUpdateUniforms(this, _render->m_uniformBuffer[compute.m_uniformIdx], compute.m_uniformBegin, compute.m_uniformEnd); if (key.m_program.idx != currentProgram.idx) @@ -3969,8 +3968,7 @@ namespace bgfx { namespace mtl } m_computeCommandEncoder.setComputePipelineState(currentPso->m_cps); - programChanged = - constantsChanged = true; + programChanged = true; } if (isValid(currentProgram) @@ -3984,13 +3982,10 @@ namespace bgfx { namespace mtl m_computeCommandEncoder.setBuffer(m_uniformBuffer, m_uniformBufferVertexOffset, 0); } - if (constantsChanged) + UniformBuffer* vcb = currentPso->m_vshConstantBuffer; + if (NULL != vcb) { - UniformBuffer* vcb = currentPso->m_vshConstantBuffer; - if (NULL != vcb) - { - commit(*vcb); - } + commit(*vcb); } viewState.setPredefined<4>(this, view, *currentPso, _render, compute); @@ -4233,7 +4228,6 @@ namespace bgfx { namespace mtl } bool programChanged = false; - bool constantsChanged = draw.m_uniformBegin < draw.m_uniformEnd; rendererUpdateUniforms(this, _render->m_uniformBuffer[draw.m_uniformIdx], draw.m_uniformBegin, draw.m_uniformEnd); bool vertexStreamChanged = hasVertexStreamChanged(currentState, draw); @@ -4333,8 +4327,7 @@ namespace bgfx { namespace mtl rce.setVertexBuffer(inst.m_ptr, draw.m_instanceDataOffset, numStreams+1); } - programChanged = - constantsChanged = true; + programChanged = true; } if (isValid(currentProgram) ) @@ -4355,19 +4348,16 @@ namespace bgfx { namespace mtl rce.setFragmentBuffer(m_uniformBuffer, m_uniformBufferFragmentOffset, 0); } - if (constantsChanged) + UniformBuffer* vcb = currentPso->m_vshConstantBuffer; + if (NULL != vcb) { - UniformBuffer* vcb = currentPso->m_vshConstantBuffer; - if (NULL != vcb) - { - commit(*vcb); - } - - UniformBuffer* fcb = currentPso->m_fshConstantBuffer; - if (NULL != fcb) - { - commit(*fcb); - } + commit(*vcb); + } + + UniformBuffer* fcb = currentPso->m_fshConstantBuffer; + if (NULL != fcb) + { + commit(*fcb); } viewState.setPredefined<4>(this, view, *currentPso, _render, draw);