mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 00:42:48 +00:00
renderer_vulkan: Simplify debug marker settings.
This commit is contained in:
parent
1c3048ccc2
commit
c6b32edefd
@ -61,9 +61,10 @@ static u32 vblankDivider = 1;
|
||||
static bool vkValidation = false;
|
||||
static bool vkValidationSync = false;
|
||||
static bool vkValidationGpu = false;
|
||||
static bool rdocEnable = false;
|
||||
static bool vkMarkers = false;
|
||||
static bool vkCrashDiagnostic = false;
|
||||
static bool vkHostMarkers = false;
|
||||
static bool vkGuestMarkers = false;
|
||||
static bool rdocEnable = false;
|
||||
static s16 cursorState = HideCursorState::Idle;
|
||||
static int cursorHideTimeout = 5; // 5 seconds (default)
|
||||
static bool separateupdatefolder = false;
|
||||
@ -227,10 +228,6 @@ bool isRdocEnabled() {
|
||||
return rdocEnable;
|
||||
}
|
||||
|
||||
bool isMarkersEnabled() {
|
||||
return vkMarkers;
|
||||
}
|
||||
|
||||
u32 vblankDiv() {
|
||||
return vblankDivider;
|
||||
}
|
||||
@ -247,14 +244,20 @@ bool vkValidationGpuEnabled() {
|
||||
return vkValidationGpu;
|
||||
}
|
||||
|
||||
bool vkMarkersEnabled() {
|
||||
return vkMarkers || vkCrashDiagnostic; // Crash diagnostic forces markers on
|
||||
}
|
||||
|
||||
bool vkCrashDiagnosticEnabled() {
|
||||
return vkCrashDiagnostic;
|
||||
}
|
||||
|
||||
bool vkHostMarkersEnabled() {
|
||||
// Forced on when crash diagnostic enabled.
|
||||
return vkHostMarkers || vkCrashDiagnostic;
|
||||
}
|
||||
|
||||
bool vkGuestMarkersEnabled() {
|
||||
// Forced on when crash diagnostic enabled.
|
||||
return vkGuestMarkers || vkCrashDiagnostic;
|
||||
}
|
||||
|
||||
bool getSeparateUpdateEnabled() {
|
||||
return separateupdatefolder;
|
||||
}
|
||||
@ -644,9 +647,10 @@ void load(const std::filesystem::path& path) {
|
||||
vkValidation = toml::find_or<bool>(vk, "validation", false);
|
||||
vkValidationSync = toml::find_or<bool>(vk, "validation_sync", false);
|
||||
vkValidationGpu = toml::find_or<bool>(vk, "validation_gpu", true);
|
||||
rdocEnable = toml::find_or<bool>(vk, "rdocEnable", false);
|
||||
vkMarkers = toml::find_or<bool>(vk, "rdocMarkersEnable", false);
|
||||
vkCrashDiagnostic = toml::find_or<bool>(vk, "crashDiagnostic", false);
|
||||
vkHostMarkers = toml::find_or<bool>(vk, "hostMarkers", false);
|
||||
vkGuestMarkers = toml::find_or<bool>(vk, "guestMarkers", false);
|
||||
rdocEnable = toml::find_or<bool>(vk, "rdocEnable", false);
|
||||
}
|
||||
|
||||
if (data.contains("Debug")) {
|
||||
@ -752,9 +756,10 @@ void save(const std::filesystem::path& path) {
|
||||
data["Vulkan"]["validation"] = vkValidation;
|
||||
data["Vulkan"]["validation_sync"] = vkValidationSync;
|
||||
data["Vulkan"]["validation_gpu"] = vkValidationGpu;
|
||||
data["Vulkan"]["rdocEnable"] = rdocEnable;
|
||||
data["Vulkan"]["rdocMarkersEnable"] = vkMarkers;
|
||||
data["Vulkan"]["crashDiagnostic"] = vkCrashDiagnostic;
|
||||
data["Vulkan"]["hostMarkers"] = vkHostMarkers;
|
||||
data["Vulkan"]["guestMarkers"] = vkGuestMarkers;
|
||||
data["Vulkan"]["rdocEnable"] = rdocEnable;
|
||||
data["Debug"]["DebugDump"] = isDebugDump;
|
||||
data["Debug"]["CollectShader"] = isShaderDebug;
|
||||
|
||||
@ -852,9 +857,10 @@ void setDefaultValues() {
|
||||
vkValidation = false;
|
||||
vkValidationSync = false;
|
||||
vkValidationGpu = false;
|
||||
rdocEnable = false;
|
||||
vkMarkers = false;
|
||||
vkCrashDiagnostic = false;
|
||||
vkHostMarkers = false;
|
||||
vkGuestMarkers = false;
|
||||
rdocEnable = false;
|
||||
emulator_language = "en";
|
||||
m_language = 1;
|
||||
gpuId = -1;
|
||||
|
@ -100,8 +100,9 @@ void setRdocEnabled(bool enable);
|
||||
bool vkValidationEnabled();
|
||||
bool vkValidationSyncEnabled();
|
||||
bool vkValidationGpuEnabled();
|
||||
bool vkMarkersEnabled();
|
||||
bool vkCrashDiagnosticEnabled();
|
||||
bool vkHostMarkersEnabled();
|
||||
bool vkGuestMarkersEnabled();
|
||||
|
||||
// Gui
|
||||
void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h);
|
||||
|
@ -66,9 +66,10 @@ Emulator::Emulator() {
|
||||
LOG_INFO(Config, "Vulkan vkValidation: {}", Config::vkValidationEnabled());
|
||||
LOG_INFO(Config, "Vulkan vkValidationSync: {}", Config::vkValidationSyncEnabled());
|
||||
LOG_INFO(Config, "Vulkan vkValidationGpu: {}", Config::vkValidationGpuEnabled());
|
||||
LOG_INFO(Config, "Vulkan rdocEnable: {}", Config::isRdocEnabled());
|
||||
LOG_INFO(Config, "Vulkan rdocMarkersEnable: {}", Config::vkMarkersEnabled());
|
||||
LOG_INFO(Config, "Vulkan crashDiagnostics: {}", Config::vkCrashDiagnosticEnabled());
|
||||
LOG_INFO(Config, "Vulkan hostMarkers: {}", Config::vkHostMarkersEnabled());
|
||||
LOG_INFO(Config, "Vulkan guestMarkers: {}", Config::vkGuestMarkersEnabled());
|
||||
LOG_INFO(Config, "Vulkan rdocEnable: {}", Config::isRdocEnabled());
|
||||
|
||||
// Create stdin/stdout/stderr
|
||||
Common::Singleton<FileSys::HandleTable>::Instance()->CreateStdHandles();
|
||||
|
@ -199,7 +199,7 @@ void Render(const vk::CommandBuffer& cmdbuf, ::Vulkan::Frame* frame) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config::vkMarkersEnabled()) {
|
||||
if (Config::vkHostMarkersEnabled()) {
|
||||
cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{
|
||||
.pLabelName = "ImGui Render",
|
||||
});
|
||||
@ -224,7 +224,7 @@ void Render(const vk::CommandBuffer& cmdbuf, ::Vulkan::Frame* frame) {
|
||||
cmdbuf.beginRendering(render_info);
|
||||
Vulkan::RenderDrawData(*draw_data, cmdbuf);
|
||||
cmdbuf.endRendering();
|
||||
if (Config::vkMarkersEnabled()) {
|
||||
if (Config::vkHostMarkersEnabled()) {
|
||||
cmdbuf.endDebugUtilsLabelEXT();
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
|
||||
const std::string_view label{reinterpret_cast<const char*>(&nop->data_block[1]),
|
||||
marker_sz};
|
||||
if (rasterizer) {
|
||||
rasterizer->ScopeMarkerBegin(label);
|
||||
rasterizer->ScopeMarkerBegin(label, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -271,13 +271,13 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
|
||||
const u32 color = *reinterpret_cast<const u32*>(
|
||||
reinterpret_cast<const u8*>(&nop->data_block[1]) + marker_sz);
|
||||
if (rasterizer) {
|
||||
rasterizer->ScopedMarkerInsertColor(label, color);
|
||||
rasterizer->ScopedMarkerInsertColor(label, color, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PM4CmdNop::PayloadType::DebugMarkerPop: {
|
||||
if (rasterizer) {
|
||||
rasterizer->ScopeMarkerEnd();
|
||||
rasterizer->ScopeMarkerEnd(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -131,6 +131,8 @@ vk::BufferView Buffer::View(u32 offset, u32 size, bool is_written, AmdGpu::DataF
|
||||
vk::to_string(view_result));
|
||||
scheduler->DeferOperation(
|
||||
[view, device = instance->GetDevice()] { device.destroyBufferView(view); });
|
||||
Vulkan::SetObjectName(instance->GetDevice(), view, "BufferView {:#x}:{:#x}", cpu_addr + offset,
|
||||
size);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -92,15 +92,13 @@ std::string GetReadableVersion(u32 version) {
|
||||
Instance::Instance(bool enable_validation, bool enable_crash_diagnostic)
|
||||
: instance{CreateInstance(Frontend::WindowSystemType::Headless, enable_validation,
|
||||
enable_crash_diagnostic)},
|
||||
physical_devices{EnumeratePhysicalDevices(instance)},
|
||||
crash_diagnostic{enable_crash_diagnostic} {}
|
||||
physical_devices{EnumeratePhysicalDevices(instance)} {}
|
||||
|
||||
Instance::Instance(Frontend::WindowSDL& window, s32 physical_device_index,
|
||||
bool enable_validation /*= false*/, bool enable_crash_diagnostic /*= false*/)
|
||||
: instance{CreateInstance(window.GetWindowInfo().type, enable_validation,
|
||||
enable_crash_diagnostic)},
|
||||
physical_devices{EnumeratePhysicalDevices(instance)},
|
||||
crash_diagnostic{enable_crash_diagnostic} {
|
||||
physical_devices{EnumeratePhysicalDevices(instance)} {
|
||||
if (enable_validation) {
|
||||
debug_callback = CreateDebugCallback(*instance);
|
||||
}
|
||||
@ -562,10 +560,7 @@ void Instance::CollectToolingInfo() {
|
||||
return;
|
||||
}
|
||||
for (const vk::PhysicalDeviceToolProperties& tool : tools) {
|
||||
const std::string_view name = tool.name;
|
||||
LOG_INFO(Render_Vulkan, "Attached debugging tool: {}", name);
|
||||
has_renderdoc = has_renderdoc || name == "RenderDoc";
|
||||
has_nsight_graphics = has_nsight_graphics || name == "NVIDIA Nsight Graphics";
|
||||
LOG_INFO(Render_Vulkan, "Attached debugging tool: {}", tool.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,11 +79,6 @@ public:
|
||||
return profiler_context;
|
||||
}
|
||||
|
||||
/// Returns true when a known debugging tool is attached.
|
||||
bool HasDebuggingToolAttached() const {
|
||||
return crash_diagnostic || has_renderdoc || has_nsight_graphics;
|
||||
}
|
||||
|
||||
/// Returns true if anisotropic filtering is supported
|
||||
bool IsAnisotropicFilteringSupported() const {
|
||||
return features.samplerAnisotropy;
|
||||
@ -340,13 +335,9 @@ private:
|
||||
bool legacy_vertex_attributes{};
|
||||
bool image_load_store_lod{};
|
||||
bool amd_gcn_shader{};
|
||||
bool tooling_info{};
|
||||
u64 min_imported_host_pointer_alignment{};
|
||||
u32 subgroup_size{};
|
||||
bool tooling_info{};
|
||||
bool debug_utils_supported{};
|
||||
bool crash_diagnostic{};
|
||||
bool has_nsight_graphics{};
|
||||
bool has_renderdoc{};
|
||||
};
|
||||
|
||||
} // namespace Vulkan
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <variant>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "common/config.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/types.h"
|
||||
#include "video_core/renderer_vulkan/vk_common.h"
|
||||
@ -32,6 +33,9 @@ concept VulkanHandleType = vk::isVulkanHandleType<T>::value;
|
||||
|
||||
template <VulkanHandleType HandleType>
|
||||
void SetObjectName(vk::Device device, const HandleType& handle, std::string_view debug_name) {
|
||||
if (!Config::vkHostMarkersEnabled()) {
|
||||
return;
|
||||
}
|
||||
const vk::DebugUtilsObjectNameInfoEXT name_info = {
|
||||
.objectType = HandleType::objectType,
|
||||
.objectHandle = reinterpret_cast<u64>(static_cast<typename HandleType::NativeType>(handle)),
|
||||
@ -46,6 +50,9 @@ void SetObjectName(vk::Device device, const HandleType& handle, std::string_view
|
||||
template <VulkanHandleType HandleType, typename... Args>
|
||||
void SetObjectName(vk::Device device, const HandleType& handle, const char* format,
|
||||
const Args&... args) {
|
||||
if (!Config::vkHostMarkersEnabled()) {
|
||||
return;
|
||||
}
|
||||
const std::string debug_name = fmt::vformat(format, fmt::make_format_args(args...));
|
||||
SetObjectName(device, handle, debug_name);
|
||||
}
|
||||
|
@ -1195,42 +1195,43 @@ void Rasterizer::UpdateViewportScissorState() {
|
||||
cmdbuf.setScissorWithCountEXT(scissors);
|
||||
}
|
||||
|
||||
void Rasterizer::ScopeMarkerBegin(const std::string_view& str) {
|
||||
if (Config::nullGpu() || !Config::vkMarkersEnabled()) {
|
||||
void Rasterizer::ScopeMarkerBegin(const std::string_view& str, bool from_guest) {
|
||||
if ((from_guest && !Config::vkGuestMarkersEnabled()) ||
|
||||
(!from_guest && !Config::vkHostMarkersEnabled())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto cmdbuf = scheduler.CommandBuffer();
|
||||
cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{
|
||||
.pLabelName = str.data(),
|
||||
});
|
||||
}
|
||||
|
||||
void Rasterizer::ScopeMarkerEnd() {
|
||||
if (Config::nullGpu() || !Config::vkMarkersEnabled()) {
|
||||
void Rasterizer::ScopeMarkerEnd(bool from_guest) {
|
||||
if ((from_guest && !Config::vkGuestMarkersEnabled()) ||
|
||||
(!from_guest && !Config::vkHostMarkersEnabled())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto cmdbuf = scheduler.CommandBuffer();
|
||||
cmdbuf.endDebugUtilsLabelEXT();
|
||||
}
|
||||
|
||||
void Rasterizer::ScopedMarkerInsert(const std::string_view& str) {
|
||||
if (Config::nullGpu() || !Config::vkMarkersEnabled()) {
|
||||
void Rasterizer::ScopedMarkerInsert(const std::string_view& str, bool from_guest) {
|
||||
if ((from_guest && !Config::vkGuestMarkersEnabled()) ||
|
||||
(!from_guest && !Config::vkHostMarkersEnabled())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto cmdbuf = scheduler.CommandBuffer();
|
||||
cmdbuf.insertDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{
|
||||
.pLabelName = str.data(),
|
||||
});
|
||||
}
|
||||
|
||||
void Rasterizer::ScopedMarkerInsertColor(const std::string_view& str, const u32 color) {
|
||||
if (Config::nullGpu() || !Config::vkMarkersEnabled()) {
|
||||
void Rasterizer::ScopedMarkerInsertColor(const std::string_view& str, const u32 color,
|
||||
bool from_guest) {
|
||||
if ((from_guest && !Config::vkGuestMarkersEnabled()) ||
|
||||
(!from_guest && !Config::vkHostMarkersEnabled())) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto cmdbuf = scheduler.CommandBuffer();
|
||||
cmdbuf.insertDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{
|
||||
.pLabelName = str.data(),
|
||||
|
@ -47,10 +47,11 @@ public:
|
||||
void DispatchDirect();
|
||||
void DispatchIndirect(VAddr address, u32 offset, u32 size);
|
||||
|
||||
void ScopeMarkerBegin(const std::string_view& str);
|
||||
void ScopeMarkerEnd();
|
||||
void ScopedMarkerInsert(const std::string_view& str);
|
||||
void ScopedMarkerInsertColor(const std::string_view& str, const u32 color);
|
||||
void ScopeMarkerBegin(const std::string_view& str, bool from_guest = false);
|
||||
void ScopeMarkerEnd(bool from_guest = false);
|
||||
void ScopedMarkerInsert(const std::string_view& str, bool from_guest = false);
|
||||
void ScopedMarkerInsertColor(const std::string_view& str, const u32 color,
|
||||
bool from_guest = false);
|
||||
|
||||
void InlineData(VAddr address, const void* value, u32 num_bytes, bool is_gds);
|
||||
u32 ReadDataFromGds(u32 gsd_offset);
|
||||
|
@ -73,9 +73,7 @@ CommandPool::CommandPool(const Instance& instance, MasterSemaphore* master_semap
|
||||
ASSERT_MSG(pool_result == vk::Result::eSuccess, "Failed to create command pool: {}",
|
||||
vk::to_string(pool_result));
|
||||
cmd_pool = std::move(pool);
|
||||
if (instance.HasDebuggingToolAttached()) {
|
||||
SetObjectName(device, *cmd_pool, "CommandPool");
|
||||
}
|
||||
}
|
||||
|
||||
CommandPool::~CommandPool() = default;
|
||||
@ -94,11 +92,9 @@ void CommandPool::Allocate(std::size_t begin, std::size_t end) {
|
||||
device.allocateCommandBuffers(&buffer_alloc_info, cmd_buffers.data() + begin);
|
||||
ASSERT(result == vk::Result::eSuccess);
|
||||
|
||||
if (instance.HasDebuggingToolAttached()) {
|
||||
for (std::size_t i = begin; i < end; ++i) {
|
||||
SetObjectName(device, cmd_buffers[i], "CommandPool: Command Buffer {}", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vk::CommandBuffer CommandPool::Commit() {
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include "common/assert.h"
|
||||
#include "common/config.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "sdl_window.h"
|
||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||
@ -235,12 +236,10 @@ void Swapchain::RefreshSemaphores() {
|
||||
semaphore = sem;
|
||||
}
|
||||
|
||||
if (instance.HasDebuggingToolAttached()) {
|
||||
for (u32 i = 0; i < image_count; ++i) {
|
||||
SetObjectName(device, image_acquired[i], "Swapchain Semaphore: image_acquired {}", i);
|
||||
SetObjectName(device, present_ready[i], "Swapchain Semaphore: present_ready {}", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Swapchain::SetupImages() {
|
||||
@ -251,11 +250,9 @@ void Swapchain::SetupImages() {
|
||||
images = std::move(imgs);
|
||||
image_count = static_cast<u32>(images.size());
|
||||
|
||||
if (instance.HasDebuggingToolAttached()) {
|
||||
for (u32 i = 0; i < image_count; ++i) {
|
||||
SetObjectName(device, images[i], "Swapchain Image {}", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Vulkan
|
||||
|
@ -110,6 +110,13 @@ ImageView::ImageView(const Vulkan::Instance& instance, const ImageViewInfo& info
|
||||
ASSERT_MSG(view_result == vk::Result::eSuccess, "Failed to create image view: {}",
|
||||
vk::to_string(view_result));
|
||||
image_view = std::move(view);
|
||||
|
||||
const auto view_aspect = aspect & vk::ImageAspectFlagBits::eDepth ? "Depth"
|
||||
: aspect & vk::ImageAspectFlagBits::eStencil ? "Stencil"
|
||||
: "Color";
|
||||
Vulkan::SetObjectName(instance.GetDevice(), *image_view, "ImageView {}x{}x{} {:#x}:{:#x} ({})",
|
||||
image.info.size.width, image.info.size.height, image.info.size.depth,
|
||||
image.info.guest_address, image.info.guest_size, view_aspect);
|
||||
}
|
||||
|
||||
ImageView::~ImageView() = default;
|
||||
|
Loading…
Reference in New Issue
Block a user