Skip to content

Commit

Permalink
Merge pull request #2263 from billhollings/mtl3-argbuff-xc14
Browse files Browse the repository at this point in the history
Wrap Metal 3 argument buffer references in Xcode 14 guard code.
  • Loading branch information
billhollings committed Jul 3, 2024
2 parents 6aa713d + a5011de commit 9d9028d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,29 @@
if (_mtlArgumentEncoder) {
[_mtlArgumentEncoder setBuffer: mtlBuff offset: offset atIndex: index];
} else {
#if MVK_XCODE_14
*(uint64_t*)getArgumentPointer(index) = mtlBuff.gpuAddress + offset;
#endif
}
}

void MVKMetalArgumentBuffer::setTexture(id<MTLTexture> mtlTex, uint32_t index) {
if (_mtlArgumentEncoder) {
[_mtlArgumentEncoder setTexture: mtlTex atIndex: index];
} else {
#if MVK_XCODE_14
*(MTLResourceID*)getArgumentPointer(index) = mtlTex.gpuResourceID;
#endif
}
}

void MVKMetalArgumentBuffer::setSamplerState(id<MTLSamplerState> mtlSamp, uint32_t index) {
if (_mtlArgumentEncoder) {
[_mtlArgumentEncoder setSamplerState: mtlSamp atIndex: index];
} else {
#if MVK_XCODE_14
*(MTLResourceID*)getArgumentPointer(index) = mtlSamp.gpuResourceID;
#endif
}
}

Expand Down
6 changes: 6 additions & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2402,10 +2402,14 @@
_properties.vendorID == kIntelVendorId));

// Argument encoders are not needed if Metal 3 plus Tier 2 argument buffers.
#if MVK_XCODE_14
_metalFeatures.needsArgumentBufferEncoders = (_metalFeatures.argumentBuffers &&
!(mvkOSVersionIsAtLeast(13.0, 16.0, 1.0) &&
supportsMTLGPUFamily(Metal3) &&
_metalFeatures.argumentBuffersTier >= MTLArgumentBuffersTier2));
#else
_metalFeatures.needsArgumentBufferEncoders = _metalFeatures.argumentBuffers;
#endif

_isUsingMetalArgumentBuffers = _metalFeatures.descriptorSetArgumentBuffers && getMVKConfig().useMetalArgumentBuffers;;

Expand Down Expand Up @@ -3486,7 +3490,9 @@ static uint32_t mvkGetEntryProperty(io_registry_entry_t entry, CFStringRef prope
logMsg += "\n\tMetal Shading Language %s";
logMsg += "\n\tsupports the following GPU Features:";

#if MVK_XCODE_14
if (supportsMTLGPUFamily(Metal3)) { logMsg += "\n\t\tGPU Family Metal 3"; }
#endif
#if MVK_XCODE_15 && (MVK_IOS || MVK_MACOS)
if (supportsMTLGPUFamily(Apple9)) { logMsg += "\n\t\tGPU Family Apple 9"; }
#endif
Expand Down

0 comments on commit 9d9028d

Please sign in to comment.