Skip to content

Commit

Permalink
Minor improvement in pipeline-to-string (debug)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Mar 19, 2018
1 parent 8f87a9f commit 3e5757d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 30 deletions.
84 changes: 54 additions & 30 deletions GPU/Vulkan/PipelineManagerVulkan.cpp
Expand Up @@ -313,6 +313,10 @@ VulkanPipeline *PipelineManagerVulkan::GetOrCreatePipeline(VkPipelineLayout layo

PROFILE_THIS_SCOPE("pipelinebuild");

std::string temp;
key.ToString(&temp);
NOTICE_LOG(G3D, "Creating: %s", temp.c_str());

VulkanPipeline *pipeline = CreateVulkanPipeline(
vulkan_->GetDevice(), pipelineCache_, layout, renderPass,
rasterKey, decFmt, vs, fs, useHwTransform, lineWidth_);
Expand Down Expand Up @@ -367,6 +371,25 @@ static const char *const compareOps[8] = {
"ALWAYS",
};

static const char *const logicOps[] = {
"CLEAR",
"AND",
"AND_REV",
"COPY",
"AND_INV",
"NOOP",
"XOR",
"OR",
"NOR",
"EQUIV",
"INVERT",
"OR_REV",
"COPY_INV",
"OR_INV",
"NAND",
"SET",
};

static const char *const stencilOps[8] = {
"KEEP",
"ZERO",
Expand Down Expand Up @@ -412,65 +435,66 @@ std::string PipelineManagerVulkan::DebugGetObjectString(std::string id, DebugSha
return "";
}

std::string str = pipelineKey.GetDescription(stringType);
return StringFromFormat("%p: %s", iter, str.c_str());
}

std::string VulkanPipelineKey::GetDescription(DebugShaderStringType stringType) const {
switch (stringType) {
case SHADER_STRING_SHORT_DESC:
{
std::stringstream str;
str << topologies[pipelineKey.raster.topology] << " ";
if (pipelineKey.raster.blendEnable) {
str << "Blend(";
str << "C:" << blendOps[pipelineKey.raster.blendOpColor] << "/"
<< blendFactors[pipelineKey.raster.srcColor] << ":" << blendFactors[pipelineKey.raster.destColor] << " ";
if (pipelineKey.raster.blendOpAlpha != VK_BLEND_OP_ADD ||
pipelineKey.raster.srcAlpha != VK_BLEND_FACTOR_ONE ||
pipelineKey.raster.destAlpha != VK_BLEND_FACTOR_ZERO) {
str << "A:" << blendOps[pipelineKey.raster.blendOpAlpha] << "/"
<< blendFactors[pipelineKey.raster.srcColor] << ":" << blendFactors[pipelineKey.raster.destColor] << " ";
str << topologies[raster.topology] << " ";
if (raster.blendEnable) {
str << "Blend(C:" << blendOps[raster.blendOpColor] << "/"
<< blendFactors[raster.srcColor] << ":" << blendFactors[raster.destColor] << " ";
if (raster.blendOpAlpha != VK_BLEND_OP_ADD ||
raster.srcAlpha != VK_BLEND_FACTOR_ONE ||
raster.destAlpha != VK_BLEND_FACTOR_ZERO) {
str << "A:" << blendOps[raster.blendOpAlpha] << "/"
<< blendFactors[raster.srcColor] << ":" << blendFactors[raster.destColor] << " ";
}
str << ") ";
}
if (pipelineKey.raster.colorWriteMask != 0xF) {
if (raster.colorWriteMask != 0xF) {
str << "Mask(";
for (int i = 0; i < 4; i++) {
if (pipelineKey.raster.colorWriteMask & (1 << i)) {
if (raster.colorWriteMask & (1 << i)) {
str << "RGBA"[i];
} else {
str << "_";
}
}
str << ") ";
}
if (pipelineKey.raster.depthTestEnable) {
if (raster.depthTestEnable) {
str << "Depth(";
if (pipelineKey.raster.depthWriteEnable)
if (raster.depthWriteEnable)
str << "W, ";
if (pipelineKey.raster.depthCompareOp)
str << compareOps[pipelineKey.raster.depthCompareOp & 7];
if (raster.depthCompareOp)
str << compareOps[raster.depthCompareOp & 7];
str << ") ";
}
if (pipelineKey.raster.stencilTestEnable) {
if (raster.stencilTestEnable) {
str << "Stencil(";
str << compareOps[pipelineKey.raster.stencilCompareOp & 7] << " ";
str << stencilOps[pipelineKey.raster.stencilPassOp & 7] << "/";
str << stencilOps[pipelineKey.raster.stencilFailOp & 7] << "/";
str << stencilOps[pipelineKey.raster.stencilDepthFailOp& 7];
str << compareOps[raster.stencilCompareOp & 7] << " ";
str << stencilOps[raster.stencilPassOp & 7] << "/";
str << stencilOps[raster.stencilFailOp & 7] << "/";
str << stencilOps[raster.stencilDepthFailOp& 7];
str << ") ";
}
if (pipelineKey.raster.logicOpEnable) {
str << "Logic(";
str << ") ";
if (raster.logicOpEnable) {
str << "Logic(" << logicOps[raster.logicOp & 15] << ") ";
}
if (pipelineKey.useHWTransform) {
if (useHWTransform) {
str << "HWX ";
}
if (pipelineKey.vtxFmtId) {
str << "V(";
str << StringFromFormat("%08x", pipelineKey.vtxFmtId); // TODO: Format nicer.
str << ") ";
if (vtxFmtId) {
str << "V(" << StringFromFormat("%08x", vtxFmtId) << ") "; // TODO: Format nicer.
} else {
str << "SWX ";
}
return StringFromFormat("%p: %s", iter, str.str().c_str());
return str.str();
}

case SHADER_STRING_SOURCE_CODE:
Expand Down
1 change: 1 addition & 0 deletions GPU/Vulkan/PipelineManagerVulkan.h
Expand Up @@ -53,6 +53,7 @@ struct VulkanPipelineKey {
void FromString(const std::string &str) {
memcpy(this, &str[0], sizeof(*this));
}
std::string GetDescription(DebugShaderStringType stringType) const;
};

struct StoredVulkanPipelineKey {
Expand Down

0 comments on commit 3e5757d

Please sign in to comment.