Skip to content

Commit

Permalink
Merge pull request #2222 from aitor-lunarg/main
Browse files Browse the repository at this point in the history
Allow vertex buffer binding when they are used disregarding implicit buffer index
  • Loading branch information
billhollings committed May 4, 2024
2 parents f6fc303 + 2eea02d commit 75fb949
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ class MVKGraphicsPipeline : public MVKPipeline {
uint32_t _tessCtlPatchOutputBufferIndex = 0;
uint32_t _tessCtlLevelBufferIndex = 0;

static constexpr uint32_t kMVKMaxVertexInputBindingBufferCount = 31u; // Taken from Metal Feature Set Table. Highest value out of all present GPUs
bool _isVertexInputBindingUsed[kMVKMaxVertexInputBindingBufferCount] = { false };
bool _primitiveRestartEnable = true;
bool _hasRasterInfo = false;
bool _needsVertexSwizzleBuffer = false;
Expand Down
3 changes: 2 additions & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,7 @@ static MTLVertexFormat mvkAdjustFormatVectorToSize(MTLVertexFormat format, uint3

maxBinding = max(pVKVB->binding, maxBinding);
uint32_t vbIdx = getMetalBufferIndexForVertexAttributeBinding(pVKVB->binding);
_isVertexInputBindingUsed[vbIdx] = true;
auto vbDesc = inputDesc.layouts[vbIdx];
if (isVtxStrideStatic && pVKVB->stride == 0) {
// Stride can't be 0, it will be set later to attributes' maximum offset + size
Expand Down Expand Up @@ -1842,7 +1843,7 @@ static MTLVertexFormat mvkAdjustFormatVectorToSize(MTLVertexFormat format, uint3
}

bool MVKGraphicsPipeline::isValidVertexBufferIndex(MVKShaderStage stage, uint32_t mtlBufferIndex) {
return mtlBufferIndex < _descriptorBufferCounts.stages[stage] || mtlBufferIndex > getImplicitBufferIndex(stage, 0);
return _isVertexInputBindingUsed[mtlBufferIndex] || mtlBufferIndex < _descriptorBufferCounts.stages[stage] || mtlBufferIndex > getImplicitBufferIndex(stage, 0);
}

// Initializes the vertex attributes in a shader conversion configuration.
Expand Down

0 comments on commit 75fb949

Please sign in to comment.