Permalink
Browse files

Vulkan shader view (debug): Add a simple textural representation (inc…

…omplete) of pipelines
  • Loading branch information...
hrydgard committed Nov 13, 2017
1 parent 5c7f7c1 commit 47882212519488c4cae276c8f4e4bd491e880d67
Showing with 123 additions and 5 deletions.
  1. +121 −5 GPU/Vulkan/PipelineManagerVulkan.cpp
  2. +2 −0 UI/DevScreens.cpp
@@ -342,22 +342,138 @@ std::vector<std::string> PipelineManagerVulkan::DebugGetObjectIDs(DebugShaderTyp
return ids;
}
static const char *const topologies[8] = {
"POINTLIST",
"LINELIST",
"LINESTRIP",
"TRILIST",
"TRISTRIP",
"TRIFAN",
};
static const char *const blendOps[8] = {
"ADD",
"SUB",
"REVSUB",
"MIN",
"MAX",
};
static const char *const compareOps[8] = {
"NEVER",
"<",
"==",
"<=",
">",
">=",
"!=",
"ALWAYS",
};
static const char *const stencilOps[8] = {
"KEEP",
"ZERO",
"REPLACE",
"INC_CLAMP",
"DEC_CLAMP",
"INVERT",
"INC_WRAP",
"DEC_WRAP",
};
static const char *const blendFactors[19] = {
"ZERO",
"ONE",
"SRC_COLOR",
"ONE_MINUS_SRC_COLOR",
"DST_COLOR",
"ONE_MINUS_DST_COLOR",
"SRC_ALPHA",
"ONE_MINUS_SRC_ALPHA",
"DST_ALPHA",
"ONE_MINUS_DST_ALPHA",
"CONSTANT_COLOR",
"ONE_MINUS_CONSTANT_COLOR",
"CONSTANT_ALPHA",
"ONE_MINUS_CONSTANT_ALPHA",
"SRC_ALPHA_SATURATE",
"SRC1_COLOR",
"ONE_MINUS_SRC1_COLOR",
"SRC1_ALPHA",
"ONE_MINUS_SRC1_ALPHA",
};
std::string PipelineManagerVulkan::DebugGetObjectString(std::string id, DebugShaderType type, DebugShaderStringType stringType) {
if (type != SHADER_TYPE_PIPELINE)
return "N/A";
VulkanPipelineKey shaderId;
shaderId.FromString(id);
VulkanPipelineKey pipelineKey;
pipelineKey.FromString(id);
VulkanPipeline *iter = pipelines_.Get(shaderId);
VulkanPipeline *iter = pipelines_.Get(pipelineKey);
if (!iter) {
return "";
}
switch (stringType) {
case SHADER_STRING_SHORT_DESC:
{
return StringFromFormat("%p", iter);
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 << ") ";
}
if (pipelineKey.raster.colorWriteMask != 0xF) {
str << "Mask(";
for (int i = 0; i < 4; i++) {
if (pipelineKey.raster.colorWriteMask & (1 << i)) {
str << "RGBA"[i];
} else {
str << "_";
}
}
str << ") ";
}
if (pipelineKey.raster.depthTestEnable) {
str << "Depth(";
if (pipelineKey.raster.depthWriteEnable)
str << "W, ";
if (pipelineKey.raster.depthCompareOp)
str << compareOps[pipelineKey.raster.depthCompareOp & 7];
str << ") ";
}
if (pipelineKey.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 << ") ";
}
if (pipelineKey.raster.logicOpEnable) {
str << "Logic(";
str << ") ";
}
if (pipelineKey.useHWTransform) {
str << "HWX ";
}
if (pipelineKey.vtxDecId) {
str << "V(";
str << StringFromFormat("%08x", pipelineKey.vtxDecId); // TODO: Format nicer.
str << ") ";
} else {
str << "SWX ";
}
return StringFromFormat("%p: %s", iter, str.str().c_str());
}
case SHADER_STRING_SOURCE_CODE:
@@ -382,4 +498,4 @@ void PipelineManagerVulkan::SetLineWidth(float lineWidth) {
pipelines_.Remove(key);
}
});
}
}
View
@@ -399,7 +399,9 @@ void SystemInfoScreen::CreateViews() {
deviceSpecs->Add(new ItemHeader("OS Information"));
deviceSpecs->Add(new InfoItem("Memory Page Size", StringFromFormat("%d bytes", GetMemoryProtectPageSize())));
deviceSpecs->Add(new InfoItem("RW/RX exclusive: ", PlatformIsWXExclusive() ? "Yes" : "No"));
#ifdef ANDROID
deviceSpecs->Add(new InfoItem("Sustained perf mode: ", System_GetPropertyBool(SYSPROP_SUPPORTS_SUSTAINED_PERF_MODE) ? "Yes" : "No"));
#endif
const char *build = "Release";
#ifdef _DEBUG

0 comments on commit 4788221

Please sign in to comment.