Skip to content

Commit

Permalink
Merge pull request #2126 from aitor-lunarg/fix-va-translate
Browse files Browse the repository at this point in the history
Fix translation of fully remapped multi vertex attribute bindings
  • Loading branch information
billhollings authored Jan 16, 2024
2 parents b51ae71 + a3bb0b8 commit c4f90e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ struct MVKTranslatedVertexBinding {
uint16_t binding;
uint16_t translationBinding;
uint32_t translationOffset;
uint32_t mappedAttributeCount;
};

/** Describes a vertex buffer binding whose divisor is zero. */
Expand Down
5 changes: 3 additions & 2 deletions MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ static MTLVertexFormat mvkAdjustFormatVectorToSize(MTLVertexFormat format, uint3
vbXltdDesc.stride = vbDesc.stride;
vbXltdDesc.stepFunction = vbDesc.stepFunction;
vbXltdDesc.stepRate = vbDesc.stepRate;
xldtVACnt++;
xldtVACnt += xltdBind.mappedAttributeCount;
}
}

Expand Down Expand Up @@ -1533,13 +1533,14 @@ static MTLVertexFormat mvkAdjustFormatVectorToSize(MTLVertexFormat format, uint3
// See if a translated binding already exists (for example if more than one VA needs the same translation).
for (auto& xltdBind : _translatedVertexBindings) {
if (xltdBind.binding == binding && xltdBind.translationOffset == translationOffset) {
xltdBind.mappedAttributeCount++;
return xltdBind.translationBinding;
}
}

// Get next available binding point and add a translation binding description for it
uint16_t xltdBindPt = (uint16_t)(maxBinding + _translatedVertexBindings.size() + 1);
_translatedVertexBindings.push_back( {.binding = (uint16_t)binding, .translationBinding = xltdBindPt, .translationOffset = translationOffset} );
_translatedVertexBindings.push_back( {.binding = (uint16_t)binding, .translationBinding = xltdBindPt, .translationOffset = translationOffset, .mappedAttributeCount = 1u} );

return xltdBindPt;
}
Expand Down

0 comments on commit c4f90e8

Please sign in to comment.