vk_instance: Collect tooling info

This commit is contained in:
GPUCode 2023-07-25 14:10:34 +03:00
parent 6b51afaf1f
commit a8d590ae80
5 changed files with 42 additions and 11 deletions

View file

@ -195,4 +195,10 @@ inline vk::FrontFace FrontFace(Pica::RasterizerRegs::CullMode mode) {
}
}
inline Common::Vec4f ColorRGBA8(const u32 color) {
const auto rgba =
Common::Vec4u{color >> 0 & 0xFF, color >> 8 & 0xFF, color >> 16 & 0xFF, color >> 24 & 0xFF};
return rgba / 255.0f;
}
} // namespace PicaToVK

View file

@ -134,8 +134,8 @@ Instance::Instance(Frontend::EmuWindow& window, u32 physical_device_index)
*library, window.GetWindowInfo().type,
Settings::values.renderer_debug.GetValue(),
Settings::values.dump_command_buffers.GetValue())},
debug_callback{CreateDebugCallback(*instance)}, physical_devices{
instance->enumeratePhysicalDevices()} {
debug_callback{CreateDebugCallback(*instance, debug_utils_supported)},
physical_devices{instance->enumeratePhysicalDevices()} {
const std::size_t num_physical_devices = static_cast<u16>(physical_devices.size());
ASSERT_MSG(physical_device_index < num_physical_devices,
"Invalid physical device index {} provided when only {} devices exist",
@ -146,6 +146,7 @@ Instance::Instance(Frontend::EmuWindow& window, u32 physical_device_index)
CollectTelemetryParameters();
CreateDevice();
CollectToolingInfo();
CreateFormatTable();
CreateCustomFormatTable();
CreateAttribTable();
@ -403,6 +404,7 @@ bool Instance::CreateDevice() {
add_extension(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
image_format_list = add_extension(VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);
shader_stencil_export = add_extension(VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME);
tooling_info = add_extension(VK_EXT_TOOLING_INFO_EXTENSION_NAME);
const bool has_timeline_semaphores = add_extension(
VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME, is_qualcomm, "it is broken on Qualcomm drivers");
const bool has_portability_subset = add_extension(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME);
@ -580,4 +582,17 @@ void Instance::CollectTelemetryParameters() {
vendor_name = driver.driverName.data();
}
void Instance::CollectToolingInfo() {
if (!tooling_info) {
return;
}
const auto tools = physical_device.getToolProperties();
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";
}
}
} // namespace Vulkan

View file

@ -90,6 +90,16 @@ public:
return present_queue;
}
/// Returns true when a known debugging tool is attached.
bool HasDebuggingToolAttached() const {
return has_renderdoc || has_nsight_graphics;
}
/// Returns true when VK_EXT_debug_utils is supported.
bool IsExtDebugUtilsSupported() const {
return debug_utils_supported;
}
/// Returns true if logic operations need shader emulation
bool NeedsLogicOpEmulation() const {
return !features.logicOp;
@ -145,11 +155,6 @@ public:
return shader_stencil_export;
}
/// Returns true if VK_EXT_debug_utils is supported
bool IsExtDebugUtilsSupported() const {
return debug_messenger_supported;
}
/// Returns the vendor ID of the physical device
u32 GetVendorID() const {
return properties.vendorID;
@ -249,6 +254,7 @@ private:
/// Collects telemetry information from the device.
void CollectTelemetryParameters();
void CollectToolingInfo();
private:
std::shared_ptr<Common::DynamicLibrary> library;
@ -280,7 +286,10 @@ private:
bool image_format_list{};
bool pipeline_creation_cache_control{};
bool shader_stencil_export{};
bool debug_messenger_supported{};
bool tooling_info{};
bool debug_utils_supported{};
bool has_nsight_graphics{};
bool has_renderdoc{};
};
} // namespace Vulkan

View file

@ -343,7 +343,7 @@ vk::UniqueDebugReportCallbackEXT CreateDebugReportCallback(vk::Instance instance
return instance.createDebugReportCallbackEXTUnique(callback_ci);
}
DebugCallback CreateDebugCallback(vk::Instance instance) {
DebugCallback CreateDebugCallback(vk::Instance instance, bool& debug_utils_supported) {
if (!Settings::values.renderer_debug) {
return {};
}
@ -356,7 +356,8 @@ DebugCallback CreateDebugCallback(vk::Instance instance) {
return std::strcmp(VK_EXT_DEBUG_UTILS_EXTENSION_NAME, prop.extensionName) == 0;
});
// Prefer debug util messenger if available.
if (it != properties.end()) {
debug_utils_supported = it != properties.end();
if (debug_utils_supported) {
return CreateDebugMessenger(instance);
}
// Otherwise fallback to debug report callback.

View file

@ -29,6 +29,6 @@ vk::UniqueInstance CreateInstance(const Common::DynamicLibrary& library,
Frontend::WindowSystemType window_type, bool enable_validation,
bool dump_command_buffers);
DebugCallback CreateDebugCallback(vk::Instance instance);
DebugCallback CreateDebugCallback(vk::Instance instance, bool& debug_utils_supported);
} // namespace Vulkan