mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
fix attribute offset (#2126)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user