clean up renderer_vulkan

This commit is contained in:
Reg Tiangha 2024-03-29 16:13:08 -06:00
parent e70301d48c
commit a0087ead42
No known key found for this signature in database
GPG key ID: 00D437798B1C2970
6 changed files with 20 additions and 74 deletions

View file

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

View file

@ -9,7 +9,6 @@
#include "common/assert.h"
#include "common/settings.h"
#include "core/frontend/emu_window.h"
#include "core/telemetry_session.h"
#include "video_core/custom_textures/custom_format.h"
#include "video_core/renderer_vulkan/vk_instance.h"
#include "video_core/renderer_vulkan/vk_platform.h"
@ -133,15 +132,14 @@ std::string GetReadableVersion(u32 version) {
} // Anonymous namespace
Instance::Instance(bool enable_validation, bool dump_command_buffers)
: library{OpenLibrary()}, instance{CreateInstance(*library,
Frontend::WindowSystemType::Headless,
enable_validation, dump_command_buffers)},
: library{OpenLibrary()},
instance{CreateInstance(*library, Frontend::WindowSystemType::Headless, enable_validation,
dump_command_buffers)},
physical_devices{instance->enumeratePhysicalDevices()} {}
Instance::Instance(Core::TelemetrySession& telemetry, Frontend::EmuWindow& window,
u32 physical_device_index)
: library{OpenLibrary(&window)}, instance{CreateInstance(
*library, window.GetWindowInfo().type,
Instance::Instance(Frontend::EmuWindow& window, u32 physical_device_index)
: library{OpenLibrary(&window)},
instance{CreateInstance(*library, window.GetWindowInfo().type,
Settings::values.renderer_debug.GetValue(),
Settings::values.dump_command_buffers.GetValue())},
debug_callback{CreateDebugCallback(*instance, debug_utils_supported)},
@ -161,9 +159,7 @@ Instance::Instance(Core::TelemetrySession& telemetry, Frontend::EmuWindow& windo
VK_VERSION_MAJOR(properties.apiVersion), VK_VERSION_MINOR(properties.apiVersion)));
}
CollectTelemetryParameters(telemetry);
CreateDevice();
CollectToolingInfo();
CreateFormatTable();
CreateCustomFormatTable();
CreateAttribTable();
@ -645,45 +641,4 @@ 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

View file

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

View file

@ -100,8 +100,8 @@ bool CanBlitToSwapchain(const vk::PhysicalDevice& physical_device, vk::Format fo
PresentWindow::PresentWindow(Frontend::EmuWindow& emu_window_, const Instance& instance_,
Scheduler& scheduler_)
: emu_window{emu_window_}, instance{instance_}, scheduler{scheduler_},
surface{CreateSurface(instance.GetInstance(), emu_window)},
next_surface{surface}, swapchain{instance, emu_window.GetFramebufferLayout().width,
surface{CreateSurface(instance.GetInstance(), emu_window)}, next_surface{surface},
swapchain{instance, emu_window.GetFramebufferLayout().width,
emu_window.GetFramebufferLayout().height, surface},
graphics_queue{instance.GetGraphicsQueue()}, present_renderpass{CreateRenderpass()},
vsync_enabled{Settings::values.use_vsync_new.GetValue()},

View file

@ -61,8 +61,8 @@ RasterizerVulkan::RasterizerVulkan(Memory::MemorySystem& memory, Pica::PicaCore&
Scheduler& scheduler, DescriptorPool& pool,
RenderpassCache& renderpass_cache, u32 image_count)
: RasterizerAccelerated{memory, pica}, instance{instance}, scheduler{scheduler},
renderpass_cache{renderpass_cache}, pipeline_cache{instance, scheduler, renderpass_cache,
pool},
renderpass_cache{renderpass_cache},
pipeline_cache{instance, scheduler, renderpass_cache, pool},
runtime{instance, scheduler, renderpass_cache, pool, pipeline_cache.TextureProvider(),
image_count},
res_cache{memory, custom_tex_manager, runtime, regs, renderer},

View file

@ -1458,8 +1458,8 @@ void Surface::BlitScale(const VideoCore::TextureBlit& blit, bool up_scale) {
Framebuffer::Framebuffer(TextureRuntime& runtime, const VideoCore::FramebufferParams& params,
Surface* color, Surface* depth)
: VideoCore::FramebufferParams{params}, res_scale{color ? color->res_scale
: (depth ? depth->res_scale : 1u)} {
: VideoCore::FramebufferParams{params},
res_scale{color ? color->res_scale : (depth ? depth->res_scale : 1u)} {
auto& renderpass_cache = runtime.GetRenderpassCache();
if (shadow_rendering && !color) {
return;
@ -1552,8 +1552,8 @@ Sampler::Sampler(TextureRuntime& runtime, const VideoCore::SamplerParams& params
Sampler::~Sampler() = default;
DebugScope::DebugScope(TextureRuntime& runtime, Common::Vec4f color, std::string_view label)
: scheduler{runtime.GetScheduler()}, has_debug_tool{
runtime.GetInstance().HasDebuggingToolAttached()} {
: scheduler{runtime.GetScheduler()},
has_debug_tool{runtime.GetInstance().HasDebuggingToolAttached()} {
if (!has_debug_tool) {
return;
}