Skip to content

Commit

Permalink
Merge pull request #2276 from billhollings/sdk-testing-fixes
Browse files Browse the repository at this point in the history
Fixes from Vulkan SDK 1.3.290 testing.
  • Loading branch information
billhollings authored Jul 19, 2024
2 parents d459406 + 66a2545 commit edbdcf0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
mtlArgBuffEncSize = mvkDSL->getMetal3ArgumentBufferEncodedLength(variableDescriptorCount);
}
}
uint64_t mtlArgBuffEncAlignedSize = mvkAlignByteCount(mtlArgBuffEncSize, getMetalFeatures().mtlBufferAlignment);

size_t dsCnt = _descriptorSetAvailablility.size();
_descriptorSetAvailablility.enumerateEnabledBits(true, [&](size_t dsIdx) {
Expand All @@ -665,7 +666,7 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
// on a reset pool), set the offset and update the next available offset value.
if ( !mtlArgBuffOffset && (dsIdx || !_nextMetalArgumentBufferOffset)) {
mtlArgBuffOffset = _nextMetalArgumentBufferOffset;
_nextMetalArgumentBufferOffset += mtlArgBuffEncSize;
_nextMetalArgumentBufferOffset += mtlArgBuffEncAlignedSize;
}

// Get the offset of the next desc set, if one exists and
Expand Down Expand Up @@ -975,9 +976,10 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
// contain buffers, we add an additional buffer at the end to track buffer sizes.
mtlBuffCnt += std::min<NSUInteger>(mtlBuffCnt, pCreateInfo->maxSets);

// Each descriptor set uses a separate Metal argument buffer, but all of these descriptor set
// Metal argument buffers share a single MTLBuffer. This single MTLBuffer needs to be large
// enough to hold all of the encoded resources for the descriptors.
// Each descriptor set uses a separate Metal argument buffer, but all of these
// descriptor set Metal argument buffers share a single MTLBuffer. This single
// MTLBuffer needs to be large enough to hold all of the encoded resources for the
// descriptors, plus additional buffer offset alignment space for each descriptor set.
NSUInteger metalArgBuffSize = 0;
if (needsMetalArgumentBufferEncoders()) {
// If argument buffer encoders are required, depending on the platform, a Metal argument
Expand All @@ -998,6 +1000,7 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
} else {
// For Metal 3, encoders are not required, and each arg buffer entry fits into 64 bits.
metalArgBuffSize = (mtlBuffCnt + mtlTexCnt + mtlSampCnt) * kMVKMetal3ArgBuffSlotSizeInBytes;
metalArgBuffSize += (mtlFeats.mtlBufferAlignment * pCreateInfo->maxSets);
}

if (metalArgBuffSize) {
Expand Down

0 comments on commit edbdcf0

Please sign in to comment.