Skip to content

Commit

Permalink
Merge pull request #2389 from billhollings/log-desc-mtce
Browse files Browse the repository at this point in the history
When logging a pipeline layout, log contained descriptor set layouts.
  • Loading branch information
billhollings authored Nov 5, 2024
2 parents 8e1cb0f + e921f49 commit 758c4f2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class MVKDescriptorSetLayoutBinding : public MVKBaseDeviceObject {
bool getApplyToStage(MVKShaderStage stage) { return _applyToStage[stage]; }

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

MVKDescriptorSetLayoutBinding(MVKDevice* device,
MVKDescriptorSetLayout* layout,
Expand Down
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKDescriptor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ void mvkPopulateShaderConversionConfig(mvk::SPIRVToMSLConversionConfiguration& s
return mtlStages;
}

std::string MVKDescriptorSetLayoutBinding::getLogDescription() {
std::string MVKDescriptorSetLayoutBinding::getLogDescription(std::string indent) {
uint32_t elemCnt = getDescriptorCount();
std::stringstream descStr;
descStr << getDescriptorIndex() << ": ";
Expand Down
4 changes: 2 additions & 2 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class MVKDescriptorSetLayout : public MVKVulkanAPIDeviceObject {
bool needsBufferSizeAuxBuffer() { return _maxBufferIndex >= 0; }

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

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

Expand Down Expand Up @@ -285,7 +285,7 @@ class MVKDescriptorPool : public MVKVulkanAPIDeviceObject {
VkResult reset(VkDescriptorPoolResetFlags flags);

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

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

Expand Down
16 changes: 9 additions & 7 deletions MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,12 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
MVKLogDebugIf(getMVKConfig().debugMode, "Created %s\n", getLogDescription().c_str());
}

std::string MVKDescriptorSetLayout::getLogDescription() {
std::string MVKDescriptorSetLayout::getLogDescription(std::string indent) {
std::stringstream descStr;
descStr << "VkDescriptorSetLayout " << this << " with " << _bindings.size() << " bindings:";
descStr << "VkDescriptorSetLayout with " << _bindings.size() << " bindings:";
auto bindIndent = indent + "\t";
for (auto& dlb : _bindings) {
descStr << "\n\t" << dlb.getLogDescription();
descStr << "\n" << bindIndent << dlb.getLogDescription(bindIndent);
}
return descStr.str();
}
Expand Down Expand Up @@ -959,18 +960,19 @@ static void populateAuxBuffer(mvk::SPIRVToMSLConversionConfiguration& shaderConf
return descCnt;
}

std::string MVKDescriptorPool::getLogDescription() {
std::string MVKDescriptorPool::getLogDescription(std::string indent) {
#define STR(name) #name
#define printDescCnt(descType, spacing, descPool) \
if (_##descPool##Descriptors.size()) { \
descStr << "\n\t" STR(VK_DESCRIPTOR_TYPE_##descType) ": " spacing << _##descPool##Descriptors.size() \
descStr << "\n" << descCntIndent << STR(VK_DESCRIPTOR_TYPE_##descType) ": " spacing << _##descPool##Descriptors.size() \
<< " (" << _##descPool##Descriptors.getRemainingDescriptorCount() << " remaining)"; }

std::stringstream descStr;
descStr << "VkDescriptorPool " << this;
descStr << " with " << _descriptorSetAvailablility.size() << " descriptor sets";
descStr << "VkDescriptorPool with " << _descriptorSetAvailablility.size() << " descriptor sets";
descStr << " (reset " << (mvkIsAnyFlagEnabled(_flags, VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT) ? "or free" : "only") << ")";
descStr << ", and pooled descriptors:";

auto descCntIndent = indent + "\t";
printDescCnt(UNIFORM_BUFFER, " ", uniformBuffer);
printDescCnt(STORAGE_BUFFER, " ", storageBuffer);
printDescCnt(UNIFORM_BUFFER_DYNAMIC, " ", uniformBufferDynamic);
Expand Down
2 changes: 1 addition & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class MVKPipelineLayout : public MVKVulkanAPIDeviceObject {
MVKDescriptorSetLayout* getDescriptorSetLayout(uint32_t descSetIndex) { return _descriptorSetLayouts[descSetIndex]; }

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

/** Constructs an instance for the specified device. */
MVKPipelineLayout(MVKDevice* device, const VkPipelineLayoutCreateInfo* pCreateInfo);
Expand Down
7 changes: 4 additions & 3 deletions MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,13 @@
return false;
}

std::string MVKPipelineLayout::getLogDescription() {
std::string MVKPipelineLayout::getLogDescription(std::string indent) {
std::stringstream descStr;
size_t dslCnt = _descriptorSetLayouts.size();
descStr << "VkPipelineLayout " << this << " with " << dslCnt << " descriptor set layouts:";
descStr << "VkPipelineLayout with " << dslCnt << " descriptor set layouts:";
auto descLayoutIndent = indent + "\t";
for (uint32_t dslIdx = 0; dslIdx < dslCnt; dslIdx++) {
descStr << "\n\t" << dslIdx << ": " << _descriptorSetLayouts[dslIdx];
descStr << "\n" << descLayoutIndent << dslIdx << ": " << _descriptorSetLayouts[dslIdx]->getLogDescription(descLayoutIndent);
}
return descStr.str();
}
Expand Down

0 comments on commit 758c4f2

Please sign in to comment.