Skip to content

Commit e48f4ef

Browse files
committed
fix metal
1 parent 3865e8f commit e48f4ef

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

axmol/rhi/metal/RenderContextMTL.mm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ of this software and associated documentation files (the "Software"), to deal
4646
namespace
4747
{
4848

49+
// match with axmol 3.1 shader
50+
static constexpr int VS_UBO_BINDING_INDEX = 0;
51+
static constexpr int FS_UBO_BINDING_INDEX = 1;
52+
4953
#define byte(n) ((n) * 8)
5054
#define bit(n) (n)
5155
static uint8_t getBitsPerElementMTL(MTLPixelFormat pixleFormat)
@@ -528,19 +532,16 @@ static MTLCullMode toMTLCullMode(CullMode mode)
528532
for (auto& cb : callbackUniforms)
529533
cb.second(_programState, cb.first);
530534

531-
// axslcc spec, bound to 0
532-
constexpr int bindingIndex = DriverImpl::VBO_BINDING_INDEX_START;
533-
534535
auto vertexUB = _programState->getVertexUniformBuffer();
535536
if (!vertexUB.empty())
536537
{
537-
[_mtlRenderEncoder setVertexBytes:vertexUB.data() length:vertexUB.size() atIndex:bindingIndex];
538+
[_mtlRenderEncoder setVertexBytes:vertexUB.data() length:vertexUB.size() atIndex:VS_UBO_BINDING_INDEX];
538539
}
539540

540541
auto fragUB = _programState->getFragmentUniformBuffer();
541542
if (!fragUB.empty())
542543
{
543-
[_mtlRenderEncoder setFragmentBytes:fragUB.data() length:fragUB.size() atIndex:bindingIndex];
544+
[_mtlRenderEncoder setFragmentBytes:fragUB.data() length:fragUB.size() atIndex:FS_UBO_BINDING_INDEX];
544545
}
545546
}
546547
}

0 commit comments

Comments
 (0)