only set buffer offset if needed

This commit is contained in:
Samuliak 2024-09-19 10:05:48 +02:00
parent aa81070e87
commit f03c0a2769

View File

@ -1318,7 +1318,27 @@ void MetalRenderer::SetBuffer(MTL::RenderCommandEncoder* renderCommandEncoder, M
if (buffer == boundBuffer.m_buffer && offset == boundBuffer.m_offset) if (buffer == boundBuffer.m_buffer && offset == boundBuffer.m_offset)
return; return;
// TODO: only set the offset if only offset changed if (buffer == boundBuffer.m_buffer)
{
// Just update the offset
boundBuffer.m_offset = offset;
switch (shaderType)
{
case METAL_SHADER_TYPE_VERTEX:
renderCommandEncoder->setVertexBufferOffset(offset, index);
break;
case METAL_SHADER_TYPE_OBJECT:
renderCommandEncoder->setObjectBufferOffset(offset, index);
break;
case METAL_SHADER_TYPE_MESH:
renderCommandEncoder->setMeshBufferOffset(offset, index);
break;
case METAL_SHADER_TYPE_FRAGMENT:
renderCommandEncoder->setFragmentBufferOffset(offset, index);
break;
}
}
boundBuffer = {buffer, offset}; boundBuffer = {buffer, offset};