From cf8c4fe6c6898f2bb0210b59643a75abb2ccc2f2 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 14 Feb 2020 16:19:43 +0800 Subject: [PATCH] fix attribute offset (#2126) --- native/cocos/renderer/gfx-metal/MTLPipelineState.mm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/native/cocos/renderer/gfx-metal/MTLPipelineState.mm b/native/cocos/renderer/gfx-metal/MTLPipelineState.mm index e4d704ac20..4077414808 100644 --- a/native/cocos/renderer/gfx-metal/MTLPipelineState.mm +++ b/native/cocos/renderer/gfx-metal/MTLPipelineState.mm @@ -221,17 +221,15 @@ bool CCMTLPipelineState::createMTLRenderPipelineState() void CCMTLPipelineState::setVertexDescriptor(MTLRenderPipelineDescriptor* descriptor) { // attributes - uint streamOffsets[GFX_MAX_VERTEX_ATTRIBUTES] = {0}; int i = 0; uint stride = 0; for (const auto& attrib : _is.attributes) { descriptor.vertexDescriptor.attributes[i].format = mu::toMTLVertexFormat(attrib.format); - descriptor.vertexDescriptor.attributes[i].offset = streamOffsets[i]; + descriptor.vertexDescriptor.attributes[i].offset = stride; //FIXME: because translated metal shader binds argument buffers from 0. So bind vertex buffer to max buffer index: 30. descriptor.vertexDescriptor.attributes[i].bufferIndex = 30; - streamOffsets[i] += GFX_FORMAT_INFOS[(int)attrib.format].size; stride += GFX_FORMAT_INFOS[(int)attrib.format].size; ++i; }