rebase renderer_vulkan

This commit is contained in:
Reg Tiangha 2024-03-29 16:06:08 -06:00
parent a7a73e0f23
commit e70301d48c
No known key found for this signature in database
GPG key ID: 00D437798B1C2970
3 changed files with 63 additions and 8 deletions

View file

@ -53,8 +53,9 @@ constexpr static std::array<vk::DescriptorSetLayoutBinding, 1> PRESENT_BINDINGS
RendererVulkan::RendererVulkan(Core::System& system, Pica::PicaCore& pica_, RendererVulkan::RendererVulkan(Core::System& system, Pica::PicaCore& pica_,
Frontend::EmuWindow& window, Frontend::EmuWindow* secondary_window) Frontend::EmuWindow& window, Frontend::EmuWindow* secondary_window)
: RendererBase{system, window, secondary_window}, memory{system.Memory()}, pica{pica_}, : RendererBase{system, window, secondary_window}, memory{system.Memory()}, pica{pica_},
instance{window, Settings::values.physical_device.GetValue()}, scheduler{instance}, instance{system.TelemetrySession(), window, Settings::values.physical_device.GetValue()},
render_manager{instance, scheduler}, main_window{window, instance, scheduler}, scheduler{instance}, renderpass_cache{instance, scheduler}, pool{instance},
main_window{window, instance, scheduler},
vertex_buffer{instance, scheduler, vk::BufferUsageFlagBits::eVertexBuffer, vertex_buffer{instance, scheduler, vk::BufferUsageFlagBits::eVertexBuffer,
VERTEX_BUFFER_SIZE}, VERTEX_BUFFER_SIZE},
rasterizer{memory, rasterizer{memory,

View file

@ -9,6 +9,7 @@
#include "common/assert.h" #include "common/assert.h"
#include "common/settings.h" #include "common/settings.h"
#include "core/frontend/emu_window.h" #include "core/frontend/emu_window.h"
#include "core/telemetry_session.h"
#include "video_core/custom_textures/custom_format.h" #include "video_core/custom_textures/custom_format.h"
#include "video_core/renderer_vulkan/vk_instance.h" #include "video_core/renderer_vulkan/vk_instance.h"
#include "video_core/renderer_vulkan/vk_platform.h" #include "video_core/renderer_vulkan/vk_platform.h"
@ -137,11 +138,12 @@ Instance::Instance(bool enable_validation, bool dump_command_buffers)
enable_validation, dump_command_buffers)}, enable_validation, dump_command_buffers)},
physical_devices{instance->enumeratePhysicalDevices()} {} physical_devices{instance->enumeratePhysicalDevices()} {}
Instance::Instance(Frontend::EmuWindow& window, u32 physical_device_index) Instance::Instance(Core::TelemetrySession& telemetry, Frontend::EmuWindow& window,
: library{OpenLibrary(&window)}, u32 physical_device_index)
instance{CreateInstance(*library, window.GetWindowInfo().type, : library{OpenLibrary(&window)}, instance{CreateInstance(
Settings::values.renderer_debug.GetValue(), *library, window.GetWindowInfo().type,
Settings::values.dump_command_buffers.GetValue())}, Settings::values.renderer_debug.GetValue(),
Settings::values.dump_command_buffers.GetValue())},
debug_callback{CreateDebugCallback(*instance, debug_utils_supported)}, debug_callback{CreateDebugCallback(*instance, debug_utils_supported)},
physical_devices{instance->enumeratePhysicalDevices()} { physical_devices{instance->enumeratePhysicalDevices()} {
const std::size_t num_physical_devices = static_cast<u16>(physical_devices.size()); const std::size_t num_physical_devices = static_cast<u16>(physical_devices.size());
@ -159,7 +161,9 @@ Instance::Instance(Frontend::EmuWindow& window, u32 physical_device_index)
VK_VERSION_MAJOR(properties.apiVersion), VK_VERSION_MINOR(properties.apiVersion))); VK_VERSION_MAJOR(properties.apiVersion), VK_VERSION_MINOR(properties.apiVersion)));
} }
CollectTelemetryParameters(telemetry);
CreateDevice(); CreateDevice();
CollectToolingInfo();
CreateFormatTable(); CreateFormatTable();
CreateCustomFormatTable(); CreateCustomFormatTable();
CreateAttribTable(); CreateAttribTable();
@ -641,4 +645,45 @@ void Instance::CreateAllocator() {
} }
} }
void Instance::CollectTelemetryParameters(Core::TelemetrySession& telemetry) {
const vk::StructureChain property_chain =
physical_device
.getProperties2<vk::PhysicalDeviceProperties2, vk::PhysicalDeviceDriverProperties>();
const vk::PhysicalDeviceDriverProperties driver =
property_chain.get<vk::PhysicalDeviceDriverProperties>();
driver_id = driver.driverID;
vendor_name = driver.driverName.data();
const std::string model_name{GetModelName()};
const std::string driver_version = GetDriverVersionName();
const std::string driver_name = fmt::format("{} {}", vendor_name, driver_version);
const std::string api_version = GetReadableVersion(properties.apiVersion);
const std::string extensions = fmt::format("{}", fmt::join(available_extensions, ", "));
LOG_INFO(Render_Vulkan, "VK_DRIVER: {}", driver_name);
LOG_INFO(Render_Vulkan, "VK_DEVICE: {}", model_name);
LOG_INFO(Render_Vulkan, "VK_VERSION: {}", api_version);
static constexpr auto field = Common::Telemetry::FieldType::UserSystem;
telemetry.AddField(field, "GPU_Vendor", vendor_name);
telemetry.AddField(field, "GPU_Model", model_name);
telemetry.AddField(field, "GPU_Vulkan_Driver", driver_name);
telemetry.AddField(field, "GPU_Vulkan_Version", api_version);
telemetry.AddField(field, "GPU_Vulkan_Extensions", extensions);
}
void Instance::CollectToolingInfo() {
if (!tooling_info) {
return;
}
const auto tools = physical_device.getToolPropertiesEXT();
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 } // namespace Vulkan

View file

@ -10,6 +10,10 @@
#include "video_core/rasterizer_cache/pixel_format.h" #include "video_core/rasterizer_cache/pixel_format.h"
#include "video_core/renderer_vulkan/vk_platform.h" #include "video_core/renderer_vulkan/vk_platform.h"
namespace Core {
class TelemetrySession;
}
namespace Frontend { namespace Frontend {
class EmuWindow; class EmuWindow;
} }
@ -37,7 +41,8 @@ struct FormatTraits {
class Instance { class Instance {
public: public:
explicit Instance(bool validation = false, bool dump_command_buffers = false); explicit Instance(bool validation = false, bool dump_command_buffers = false);
explicit Instance(Frontend::EmuWindow& window, u32 physical_device_index); explicit Instance(Core::TelemetrySession& telemetry, Frontend::EmuWindow& window,
u32 physical_device_index);
~Instance(); ~Instance();
/// Returns the FormatTraits struct for the provided pixel format /// Returns the FormatTraits struct for the provided pixel format
@ -285,6 +290,10 @@ private:
/// Creates the VMA allocator handle /// Creates the VMA allocator handle
void CreateAllocator(); void CreateAllocator();
/// Collects telemetry information from the device.
void CollectTelemetryParameters(Core::TelemetrySession& telemetry);
void CollectToolingInfo();
private: private:
std::shared_ptr<Common::DynamicLibrary> library; std::shared_ptr<Common::DynamicLibrary> library;
vk::UniqueInstance instance; vk::UniqueInstance instance;