summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDrChat <arkolbed@gmail.com>2018-03-03 12:34:19 -0600
committerDrChat <arkolbed@gmail.com>2018-03-03 12:34:19 -0600
commita9d2a50082281303a3081578ceb01581420c4958 (patch)
treea6bff2c97a0f725cc69077d5ae438f5fe8ba8833 /src
parent3fb7b9d94446eae6e6eae9f1c3f652b2ba997b8d (diff)
[Vulkan] Add AMD shader statistics info support
Diffstat (limited to 'src')
-rw-r--r--src/xenia/gpu/vulkan/pipeline_cache.cc54
-rw-r--r--src/xenia/gpu/vulkan/pipeline_cache.h2
2 files changed, 55 insertions, 1 deletions
diff --git a/src/xenia/gpu/vulkan/pipeline_cache.cc b/src/xenia/gpu/vulkan/pipeline_cache.cc
index d9a6a598f..4d5594276 100644
--- a/src/xenia/gpu/vulkan/pipeline_cache.cc
+++ b/src/xenia/gpu/vulkan/pipeline_cache.cc
@@ -333,7 +333,12 @@ VkPipeline PipelineCache::GetPipeline(const RenderState* render_state,
// Dump shader disassembly.
if (FLAGS_vulkan_dump_disasm) {
- DumpShaderDisasmNV(pipeline_info);
+ if (device_->HasEnabledExtension(VK_AMD_SHADER_INFO_EXTENSION_NAME)) {
+ DumpShaderDisasmAMD(pipeline);
+ } else if (device_->device_info().properties.vendorID == 0x10DE) {
+ // NVIDIA cards
+ DumpShaderDisasmNV(pipeline_info);
+ }
}
// Add to cache with the hash key for reuse.
@@ -374,6 +379,53 @@ bool PipelineCache::TranslateShader(VulkanShader* shader,
return shader->is_valid();
}
+static void DumpShaderStatisticsAMD(const VkShaderStatisticsInfoAMD& stats) {
+ XELOGI(" - resource usage:");
+ XELOGI(" numUsedVgprs: %d", stats.resourceUsage.numUsedVgprs);
+ XELOGI(" numUsedSgprs: %d", stats.resourceUsage.numUsedSgprs);
+ XELOGI(" ldsSizePerLocalWorkGroup: %d",
+ stats.resourceUsage.ldsSizePerLocalWorkGroup);
+ XELOGI(" ldsUsageSizeInBytes : %d",
+ stats.resourceUsage.ldsUsageSizeInBytes);
+ XELOGI(" scratchMemUsageInBytes : %d",
+ stats.resourceUsage.scratchMemUsageInBytes);
+ XELOGI("numPhysicalVgprs : %d", stats.numPhysicalVgprs);
+ XELOGI("numPhysicalSgprs : %d", stats.numPhysicalSgprs);
+ XELOGI("numAvailableVgprs: %d", stats.numAvailableVgprs);
+ XELOGI("numAvailableSgprs: %d", stats.numAvailableSgprs);
+}
+
+void PipelineCache::DumpShaderDisasmAMD(VkPipeline pipeline) {
+ auto fn_GetShaderInfoAMD = (PFN_vkGetShaderInfoAMD)vkGetDeviceProcAddr(
+ *device_, "vkGetShaderInfoAMD");
+
+ VkResult status = VK_SUCCESS;
+ size_t data_size = 0;
+
+ VkShaderStatisticsInfoAMD stats;
+ data_size = sizeof(stats);
+
+ // Vertex shader
+ status = fn_GetShaderInfoAMD(*device_, pipeline, VK_SHADER_STAGE_VERTEX_BIT,
+ VK_SHADER_INFO_TYPE_STATISTICS_AMD, &data_size,
+ &stats);
+ if (status == VK_SUCCESS) {
+ XELOGI("AMD Vertex Shader Statistics:");
+ DumpShaderStatisticsAMD(stats);
+ }
+
+ // Fragment shader
+ status = fn_GetShaderInfoAMD(*device_, pipeline, VK_SHADER_STAGE_FRAGMENT_BIT,
+ VK_SHADER_INFO_TYPE_STATISTICS_AMD, &data_size,
+ &stats);
+ if (status == VK_SUCCESS) {
+ XELOGI("AMD Fragment Shader Statistics:");
+ DumpShaderStatisticsAMD(stats);
+ }
+
+ // TODO(DrChat): Eventually dump the disasm...
+}
+
void PipelineCache::DumpShaderDisasmNV(
const VkGraphicsPipelineCreateInfo& pipeline_info) {
// !! HACK !!: This only works on NVidia drivers. Dumps shader disasm.
diff --git a/src/xenia/gpu/vulkan/pipeline_cache.h b/src/xenia/gpu/vulkan/pipeline_cache.h
index 4a40855a5..efb49f97c 100644
--- a/src/xenia/gpu/vulkan/pipeline_cache.h
+++ b/src/xenia/gpu/vulkan/pipeline_cache.h
@@ -80,6 +80,8 @@ class PipelineCache {
VkPipeline GetPipeline(const RenderState* render_state, uint64_t hash_key);
bool TranslateShader(VulkanShader* shader, xenos::xe_gpu_program_cntl_t cntl);
+
+ void DumpShaderDisasmAMD(VkPipeline pipeline);
void DumpShaderDisasmNV(const VkGraphicsPipelineCreateInfo& info);
// Gets a geometry shader used to emulate the given primitive type.