diff --git a/src/video_core/renderer_vulkan/pipeline_statistics.cpp b/src/video_core/renderer_vulkan/pipeline_statistics.cpp index ad288436a8..04f42c71a6 100644 --- a/src/video_core/renderer_vulkan/pipeline_statistics.cpp +++ b/src/video_core/renderer_vulkan/pipeline_statistics.cpp @@ -31,14 +31,13 @@ static u64 GetUint64(const VkPipelineExecutableStatisticKHR& statistic) { } } -PipelineStatistics::PipelineStatistics(const Device& device_) : device{device_} {} +PipelineStatistics::PipelineStatistics(const Device& device_) {} -void PipelineStatistics::Collect(VkPipeline pipeline) { - const auto& dev{device.GetLogical()}; - const std::vector properties{dev.GetPipelineExecutablePropertiesKHR(pipeline)}; +void PipelineStatistics::Collect(const Device& device, VkPipeline pipeline) { + const std::vector properties{device.GetLogical().GetPipelineExecutablePropertiesKHR(pipeline)}; const u32 num_executables{static_cast(properties.size())}; for (u32 executable = 0; executable < num_executables; ++executable) { - const auto statistics{dev.GetPipelineExecutableStatisticsKHR(pipeline, executable)}; + const auto statistics{device.GetLogical().GetPipelineExecutableStatisticsKHR(pipeline, executable)}; if (statistics.empty()) { continue; } diff --git a/src/video_core/renderer_vulkan/pipeline_statistics.h b/src/video_core/renderer_vulkan/pipeline_statistics.h index 197bb09363..42f491426f 100644 --- a/src/video_core/renderer_vulkan/pipeline_statistics.h +++ b/src/video_core/renderer_vulkan/pipeline_statistics.h @@ -16,9 +16,7 @@ class Device; class PipelineStatistics { public: explicit PipelineStatistics(const Device& device_); - - void Collect(VkPipeline pipeline); - + void Collect(const Device& device, VkPipeline pipeline); void Report() const; private: @@ -30,8 +28,6 @@ private: u64 branches_count{}; u64 basic_block_count{}; }; - - const Device& device; mutable std::mutex mutex; std::vector collected_stats; }; diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index 010cfd225d..35a3aedc23 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -189,7 +189,7 @@ void RendererVulkan::Composite(std::span framebu Frame* frame = present_manager.GetRenderFrame(); scheduler.RequestOutsideRenderPassOperationContext(); - blit_swapchain.DrawToFrame(rasterizer, frame, framebuffers, + blit_swapchain.DrawToFrame(device, rasterizer, frame, framebuffers, render_window.GetFramebufferLayout(), swapchain.GetImageCount(), swapchain.GetImageViewFormat()); scheduler.Flush(*frame->render_ready); @@ -227,12 +227,12 @@ vk::Buffer RendererVulkan::RenderToBuffer(std::span framebuffers, const Layout::FramebufferLayout& layout, size_t current_swapchain_image_count, @@ -107,8 +110,8 @@ void BlitScreen::DrawToFrame(RasterizerVulkan& rasterizer, Frame* frame, } if (resource_update_required) { - WaitIdle(); - SetWindowAdaptPass(); + WaitIdle(device); + SetWindowAdaptPass(device); if (presentation_recreate_required) { present_manager.RecreateFrame(frame, layout.width, layout.height, swapchain_view_format, @@ -138,15 +141,15 @@ void BlitScreen::DrawToFrame(RasterizerVulkan& rasterizer, Frame* frame, } } -vk::Framebuffer BlitScreen::CreateFramebuffer(const Layout::FramebufferLayout& layout, +vk::Framebuffer BlitScreen::CreateFramebuffer(const Device& device, const Layout::FramebufferLayout& layout, VkImageView image_view, VkFormat current_view_format) { bool format_updated = swapchain_view_format != current_view_format; swapchain_view_format = current_view_format; if (!window_adapt || scaling_filter != filters.get_scaling_filter() || format_updated) { - WaitIdle(); - SetWindowAdaptPass(); + WaitIdle(device); + SetWindowAdaptPass(device); image_index = 0; } @@ -155,10 +158,10 @@ vk::Framebuffer BlitScreen::CreateFramebuffer(const Layout::FramebufferLayout& l .height = layout.height, }; - return CreateFramebuffer(image_view, extent, window_adapt->GetRenderPass()); + return CreateFramebuffer(device, image_view, extent, window_adapt->GetRenderPass()); } -vk::Framebuffer BlitScreen::CreateFramebuffer(const VkImageView& image_view, VkExtent2D extent, +vk::Framebuffer BlitScreen::CreateFramebuffer(const Device& device, const VkImageView& image_view, VkExtent2D extent, VkRenderPass render_pass) { return device.GetLogical().CreateFramebuffer(VkFramebufferCreateInfo{ .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.h b/src/video_core/renderer_vulkan/vk_blit_screen.h index 531c57fc5c..911e6fac62 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.h +++ b/src/video_core/renderer_vulkan/vk_blit_screen.h @@ -52,23 +52,22 @@ public: Scheduler& scheduler, const PresentFilters& filters); ~BlitScreen(); - void DrawToFrame(RasterizerVulkan& rasterizer, Frame* frame, + void DrawToFrame(const Device& device, RasterizerVulkan& rasterizer, Frame* frame, std::span framebuffers, const Layout::FramebufferLayout& layout, size_t current_swapchain_image_count, VkFormat current_swapchain_view_format); - [[nodiscard]] vk::Framebuffer CreateFramebuffer(const Layout::FramebufferLayout& layout, + [[nodiscard]] vk::Framebuffer CreateFramebuffer(const Device& device, const Layout::FramebufferLayout& layout, VkImageView image_view, VkFormat current_view_format); private: - void WaitIdle(); - void SetWindowAdaptPass(); - vk::Framebuffer CreateFramebuffer(const VkImageView& image_view, VkExtent2D extent, + void WaitIdle(const Device& device); + void SetWindowAdaptPass(const Device& device); + vk::Framebuffer CreateFramebuffer(const Device& device, const VkImageView& image_view, VkExtent2D extent, VkRenderPass render_pass); Tegra::MaxwellDeviceMemoryManager& device_memory; - const Device& device; MemoryAllocator& memory_allocator; PresentManager& present_manager; Scheduler& scheduler; diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp index 81ff8fe31a..d588718266 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp @@ -94,7 +94,7 @@ ComputePipeline::ComputePipeline(const Device& device_, vk::PipelineCache& pipel } if (pipeline_statistics) { - pipeline_statistics->Collect(*pipeline); + pipeline_statistics->Collect(device, *pipeline); } std::scoped_lock lock{build_mutex}; is_built = true; diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 728554d6e6..a0c908062a 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -288,7 +288,7 @@ GraphicsPipeline::GraphicsPipeline( Validate(); MakePipeline(render_pass); if (pipeline_statistics) { - pipeline_statistics->Collect(*pipeline); + pipeline_statistics->Collect(device, *pipeline); } std::scoped_lock lock{build_mutex};