Skip to content

Commit

Permalink
When labeling Metal objects, add a unique identifier.
Browse files Browse the repository at this point in the history
It shows up in the GPU capture and in case of a GPU crash in the crash report.
  • Loading branch information
js6i committed Aug 9, 2024
1 parent 07d7bfb commit 8068084
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKVulkanAPIObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ class MVKDispatchableVulkanAPIObject : public MVKVulkanAPIObject {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-method-access"
/** Generically avoids setting a label to nil, which many objects don't like. */
static inline void setLabelIfNotNil(id object, NSString* label) { if (label) { [object setLabel: label]; } }
extern std::atomic<uint64_t> nextMetalObjectIdentifier;
static inline void setLabelIfNotNil(id object, NSString* label) { if (label) { [object setLabel: [label stringByAppendingFormat:@" (%llu)", nextMetalObjectIdentifier++]]; } }
#pragma clang diagnostic pop


2 changes: 2 additions & 0 deletions MoltenVK/MoltenVK/GPUObjects/MVKVulkanAPIObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#pragma mark -
#pragma mark MVKVulkanAPIObject

std::atomic<uint64_t> nextMetalObjectIdentifier;

VkResult MVKVulkanAPIObject::setDebugName(const char* pObjectName) {
if (pObjectName) {
[_debugName release];
Expand Down

0 comments on commit 8068084

Please sign in to comment.