Skip to content

Commit

Permalink
Merge pull request #2350 from billhollings/misc-dbg-log-fixs
Browse files Browse the repository at this point in the history
Misc minor debug logging improvements.
  • Loading branch information
billhollings authored Sep 25, 2024
2 parents 872d13d + 2ace6d9 commit 685b7b5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
4 changes: 3 additions & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ class MVKDescriptorSetLayoutBinding : public MVKBaseDeviceObject {
/** Returns whether this binding should be applied to the shader stage. */
bool getApplyToStage(MVKShaderStage stage) { return _applyToStage[stage]; }

/** Returns a text description of this binding. */
std::string getLogDescription();

MVKDescriptorSetLayoutBinding(MVKDevice* device,
MVKDescriptorSetLayout* layout,
const VkDescriptorSetLayoutBinding* pBinding,
Expand Down Expand Up @@ -190,7 +193,6 @@ class MVKDescriptorSetLayoutBinding : public MVKBaseDeviceObject {
void encodeImmutableSamplersToMetalArgumentBuffer(MVKDescriptorSet* mvkDescSet);
uint8_t getMaxPlaneCount();
uint32_t getMTLResourceCount(uint32_t variableDescriptorCount = kMVKVariableDescriptorCountUnknown);
std::string getLogDescription();

MVKDescriptorSetLayout* _layout;
VkDescriptorSetLayoutBinding _info;
Expand Down
10 changes: 8 additions & 2 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ class MVKDescriptorSetLayout : public MVKVulkanAPIDeviceObject {
/** Returns whether descriptor sets from this layout requires an auxilliary buffer-size buffer. */
bool needsBufferSizeAuxBuffer() { return _maxBufferIndex >= 0; }

/** Returns a text description of this layout. */
std::string getLogDescription();

MVKDescriptorSetLayout(MVKDevice* device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo);

protected:
Expand All @@ -134,7 +137,6 @@ class MVKDescriptorSetLayout : public MVKVulkanAPIDeviceObject {
id <MTLArgumentEncoder> getMTLArgumentEncoder(uint32_t variableDescriptorCount);
uint64_t getMetal3ArgumentBufferEncodedLength(uint32_t variableDescriptorCount);
bool checkCanUseArgumentBuffers(const VkDescriptorSetLayoutCreateInfo* pCreateInfo);
std::string getLogDescription();

MVKSmallVector<MVKDescriptorSetLayoutBinding> _bindings;
std::unordered_map<uint32_t, uint32_t> _bindingToIndex;
Expand Down Expand Up @@ -280,6 +282,9 @@ class MVKDescriptorPool : public MVKVulkanAPIDeviceObject {
/** Destroys all currently allocated descriptor sets. */
VkResult reset(VkDescriptorPoolResetFlags flags);

/** Returns a text description of this pool. */
std::string getLogDescription();

MVKDescriptorPool(MVKDevice* device, const VkDescriptorPoolCreateInfo* pCreateInfo);

~MVKDescriptorPool() override;
Expand All @@ -297,7 +302,6 @@ class MVKDescriptorPool : public MVKVulkanAPIDeviceObject {
NSUInteger getMetalArgumentBufferEncodedResourceStorageSize(NSUInteger bufferCount, NSUInteger textureCount, NSUInteger samplerCount);
MTLArgumentDescriptor* getMTLArgumentDescriptor(MTLDataType resourceType, NSUInteger argIndex, NSUInteger count);
size_t getPoolSize(const VkDescriptorPoolCreateInfo* pCreateInfo, VkDescriptorType descriptorType);
std::string getLogDescription();

MVKSmallVector<MVKDescriptorSet> _descriptorSets;
MVKBitArray _descriptorSetAvailablility;
Expand All @@ -317,6 +321,8 @@ class MVKDescriptorPool : public MVKVulkanAPIDeviceObject {
MVKDescriptorTypePool<MVKCombinedImageSamplerDescriptor> _combinedImageSamplerDescriptors;
MVKDescriptorTypePool<MVKUniformTexelBufferDescriptor> _uniformTexelBufferDescriptors;
MVKDescriptorTypePool<MVKStorageTexelBufferDescriptor> _storageTexelBufferDescriptors;

VkDescriptorPoolCreateFlags _flags;
};


Expand Down
8 changes: 6 additions & 2 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,10 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
<< " (" << _##descPool##Descriptors.getRemainingDescriptorCount() << " remaining)"; }

std::stringstream descStr;
descStr << "VkDescriptorPool " << this << " with " << _descriptorSetAvailablility.size() << " descriptor sets, and pooled descriptors:";
descStr << "VkDescriptorPool " << this;
descStr << " with " << _descriptorSetAvailablility.size() << " descriptor sets";
descStr << " (reset " << (mvkIsAnyFlagEnabled(_flags, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT) ? "or free" : "only") << ")";
descStr << ", and pooled descriptors:";
printDescCnt(UNIFORM_BUFFER, " ", uniformBuffer);
printDescCnt(STORAGE_BUFFER, " ", storageBuffer);
printDescCnt(UNIFORM_BUFFER_DYNAMIC, " ", uniformBufferDynamic);
Expand Down Expand Up @@ -992,7 +995,8 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
_samplerDescriptors(getPoolSize(pCreateInfo, VK_DESCRIPTOR_TYPE_SAMPLER)),
_combinedImageSamplerDescriptors(getPoolSize(pCreateInfo, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)),
_uniformTexelBufferDescriptors(getPoolSize(pCreateInfo, VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER)),
_storageTexelBufferDescriptors(getPoolSize(pCreateInfo, VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
_storageTexelBufferDescriptors(getPoolSize(pCreateInfo, VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)),
_flags(pCreateInfo->flags) {

initMetalArgumentBuffer(pCreateInfo);
MVKLogDebugIf(getMVKConfig().debugMode, "Created %s\n", getLogDescription().c_str());
Expand Down
6 changes: 4 additions & 2 deletions MoltenVK/MoltenVK/GPUObjects/MVKDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,10 @@ class MVKPhysicalDevice : public MVKDispatchableVulkanAPIObject {
/** Returns the external memory properties supported for images for the handle type. */
VkExternalMemoryProperties& getExternalImageProperties(VkExternalMemoryHandleTypeFlagBits handleType);


/** Returns the amount of memory currently consumed by the GPU. */
size_t getCurrentAllocatedSize();


#pragma mark Metal

/** Populates the specified structure with the Metal-specific features of this device. */
Expand Down Expand Up @@ -430,7 +433,6 @@ class MVKPhysicalDevice : public MVKDispatchableVulkanAPIObject {
void setMemoryType(uint32_t typeIndex, uint32_t heapIndex, VkMemoryPropertyFlags propertyFlags);
uint64_t getVRAMSize();
uint64_t getRecommendedMaxWorkingSetSize();
uint64_t getCurrentAllocatedSize();
uint32_t getMaxSamplerCount();
uint32_t getMaxPerSetDescriptorCount();
void initExternalMemoryProperties();
Expand Down
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3286,7 +3286,7 @@ static uint32_t mvkGetEntryProperty(io_registry_entry_t entry, CFStringRef prope
}

// If possible, retrieve from the MTLDevice, otherwise use the current memory used by this process.
uint64_t MVKPhysicalDevice::getCurrentAllocatedSize() {
size_t MVKPhysicalDevice::getCurrentAllocatedSize() {
if ( [_mtlDevice respondsToSelector: @selector(currentAllocatedSize)] ) {
return _mtlDevice.currentAllocatedSize;
}
Expand Down
4 changes: 3 additions & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ class MVKPipelineLayout : public MVKVulkanAPIDeviceObject {
/** Returns the descriptor set layout. */
MVKDescriptorSetLayout* getDescriptorSetLayout(uint32_t descSetIndex) { return _descriptorSetLayouts[descSetIndex]; }

/** Returns a text description of this layout. */
std::string getLogDescription();

/** Constructs an instance for the specified device. */
MVKPipelineLayout(MVKDevice* device, const VkPipelineLayoutCreateInfo* pCreateInfo);

Expand All @@ -89,7 +92,6 @@ class MVKPipelineLayout : public MVKVulkanAPIDeviceObject {

void propagateDebugName() override {}
bool stageUsesPushConstants(MVKShaderStage mvkStage);
std::string getLogDescription();

MVKSmallVector<MVKDescriptorSetLayout*, 1> _descriptorSetLayouts;
MVKSmallVector<MVKShaderResourceBinding, 1> _dslMTLResourceIndexOffsets;
Expand Down

0 comments on commit 685b7b5

Please sign in to comment.