diff options
author | liamwhite <liamwhite@users.noreply.github.com> | 2024-01-22 16:55:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-22 16:55:39 +0100 |
commit | 8bd10473d60503c7acddc399604a51b9c9947541 (patch) | |
tree | f713f84942681321fca27ba028e31d6c74a09013 /src/video_core/renderer_vulkan | |
parent | Merge pull request #12747 from t895/homescreen-widget (diff) | |
parent | device_memory_manager: use unique_lock for update (diff) | |
download | yuzu-8bd10473d60503c7acddc399604a51b9c9947541.tar yuzu-8bd10473d60503c7acddc399604a51b9c9947541.tar.gz yuzu-8bd10473d60503c7acddc399604a51b9c9947541.tar.bz2 yuzu-8bd10473d60503c7acddc399604a51b9c9947541.tar.lz yuzu-8bd10473d60503c7acddc399604a51b9c9947541.tar.xz yuzu-8bd10473d60503c7acddc399604a51b9c9947541.tar.zst yuzu-8bd10473d60503c7acddc399604a51b9c9947541.zip |
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r-- | src/video_core/renderer_vulkan/pipeline_helper.h | 1 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/renderer_vulkan.cpp | 12 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/renderer_vulkan.h | 8 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_blit_screen.cpp | 17 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_blit_screen.h | 12 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_buffer_cache.cpp | 10 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_buffer_cache.h | 7 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | 1 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 8 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_pipeline_cache.h | 6 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_query_cache.cpp | 62 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_query_cache.h | 4 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 44 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.h | 41 |
14 files changed, 120 insertions, 113 deletions
diff --git a/src/video_core/renderer_vulkan/pipeline_helper.h b/src/video_core/renderer_vulkan/pipeline_helper.h index 71c783709..850c34a3a 100644 --- a/src/video_core/renderer_vulkan/pipeline_helper.h +++ b/src/video_core/renderer_vulkan/pipeline_helper.h @@ -12,7 +12,6 @@ #include "shader_recompiler/shader_info.h" #include "video_core/renderer_vulkan/vk_texture_cache.h" #include "video_core/renderer_vulkan/vk_update_descriptor.h" -#include "video_core/texture_cache/texture_cache.h" #include "video_core/texture_cache/types.h" #include "video_core/vulkan_common/vulkan_device.h" diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index 100b70918..1631276c6 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -82,10 +82,10 @@ Device CreateDevice(const vk::Instance& instance, const vk::InstanceDispatch& dl RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_, Core::Frontend::EmuWindow& emu_window, - Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_, + Tegra::MaxwellDeviceMemoryManager& device_memory_, Tegra::GPU& gpu_, std::unique_ptr<Core::Frontend::GraphicsContext> context_) try : RendererBase(emu_window, std::move(context_)), telemetry_session(telemetry_session_), - cpu_memory(cpu_memory_), gpu(gpu_), library(OpenLibrary(context.get())), + device_memory(device_memory_), gpu(gpu_), library(OpenLibrary(context.get())), instance(CreateInstance(*library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type, Settings::values.renderer_debug.GetValue())), debug_messenger(Settings::values.renderer_debug ? CreateDebugUtilsCallback(instance) @@ -97,9 +97,9 @@ RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_, render_window.GetFramebufferLayout().height), present_manager(instance, render_window, device, memory_allocator, scheduler, swapchain, surface), - blit_screen(cpu_memory, render_window, device, memory_allocator, swapchain, present_manager, - scheduler, screen_info), - rasterizer(render_window, gpu, cpu_memory, screen_info, device, memory_allocator, + blit_screen(device_memory, render_window, device, memory_allocator, swapchain, + present_manager, scheduler, screen_info), + rasterizer(render_window, gpu, device_memory, screen_info, device, memory_allocator, state_tracker, scheduler) { if (Settings::values.renderer_force_max_clock.GetValue() && device.ShouldBoostClocks()) { turbo_mode.emplace(instance, dld); @@ -128,7 +128,7 @@ void RendererVulkan::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) { screen_info.width = framebuffer->width; screen_info.height = framebuffer->height; - const VAddr framebuffer_addr = framebuffer->address + framebuffer->offset; + const DAddr framebuffer_addr = framebuffer->address + framebuffer->offset; const bool use_accelerated = rasterizer.AccelerateDisplay(*framebuffer, framebuffer_addr, framebuffer->stride); RenderScreenshot(*framebuffer, use_accelerated); diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.h b/src/video_core/renderer_vulkan/renderer_vulkan.h index 14e257cf7..11c52287a 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.h +++ b/src/video_core/renderer_vulkan/renderer_vulkan.h @@ -7,12 +7,12 @@ #include <string> #include <variant> -#include "video_core/renderer_vulkan/vk_rasterizer.h" - #include "common/dynamic_library.h" +#include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/renderer_base.h" #include "video_core/renderer_vulkan/vk_blit_screen.h" #include "video_core/renderer_vulkan/vk_present_manager.h" +#include "video_core/renderer_vulkan/vk_rasterizer.h" #include "video_core/renderer_vulkan/vk_scheduler.h" #include "video_core/renderer_vulkan/vk_state_tracker.h" #include "video_core/renderer_vulkan/vk_swapchain.h" @@ -42,7 +42,7 @@ class RendererVulkan final : public VideoCore::RendererBase { public: explicit RendererVulkan(Core::TelemetrySession& telemtry_session, Core::Frontend::EmuWindow& emu_window, - Core::Memory::Memory& cpu_memory_, Tegra::GPU& gpu_, + Tegra::MaxwellDeviceMemoryManager& device_memory_, Tegra::GPU& gpu_, std::unique_ptr<Core::Frontend::GraphicsContext> context_); ~RendererVulkan() override; @@ -62,7 +62,7 @@ private: void RenderScreenshot(const Tegra::FramebufferConfig& framebuffer, bool use_accelerated); Core::TelemetrySession& telemetry_session; - Core::Memory::Memory& cpu_memory; + Tegra::MaxwellDeviceMemoryManager& device_memory; Tegra::GPU& gpu; std::shared_ptr<Common::DynamicLibrary> library; diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.cpp b/src/video_core/renderer_vulkan/vk_blit_screen.cpp index 60432f5ad..610f27c84 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.cpp +++ b/src/video_core/renderer_vulkan/vk_blit_screen.cpp @@ -14,8 +14,8 @@ #include "common/settings.h" #include "core/core.h" #include "core/frontend/emu_window.h" -#include "core/memory.h" #include "video_core/gpu.h" +#include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/host_shaders/fxaa_frag_spv.h" #include "video_core/host_shaders/fxaa_vert_spv.h" #include "video_core/host_shaders/present_bicubic_frag_spv.h" @@ -121,11 +121,12 @@ struct BlitScreen::BufferData { // Unaligned image data goes here }; -BlitScreen::BlitScreen(Core::Memory::Memory& cpu_memory_, Core::Frontend::EmuWindow& render_window_, - const Device& device_, MemoryAllocator& memory_allocator_, - Swapchain& swapchain_, PresentManager& present_manager_, - Scheduler& scheduler_, const ScreenInfo& screen_info_) - : cpu_memory{cpu_memory_}, render_window{render_window_}, device{device_}, +BlitScreen::BlitScreen(Tegra::MaxwellDeviceMemoryManager& device_memory_, + Core::Frontend::EmuWindow& render_window_, const Device& device_, + MemoryAllocator& memory_allocator_, Swapchain& swapchain_, + PresentManager& present_manager_, Scheduler& scheduler_, + const ScreenInfo& screen_info_) + : device_memory{device_memory_}, render_window{render_window_}, device{device_}, memory_allocator{memory_allocator_}, swapchain{swapchain_}, present_manager{present_manager_}, scheduler{scheduler_}, image_count{swapchain.GetImageCount()}, screen_info{screen_info_} { resource_ticks.resize(image_count); @@ -219,8 +220,8 @@ void BlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer, if (!use_accelerated) { const u64 image_offset = GetRawImageOffset(framebuffer); - const VAddr framebuffer_addr = framebuffer.address + framebuffer.offset; - const u8* const host_ptr = cpu_memory.GetPointer(framebuffer_addr); + const DAddr framebuffer_addr = framebuffer.address + framebuffer.offset; + const u8* const host_ptr = device_memory.GetPointer<u8>(framebuffer_addr); // TODO(Rodrigo): Read this from HLE constexpr u32 block_height_log2 = 4; diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.h b/src/video_core/renderer_vulkan/vk_blit_screen.h index 78b32416d..3eff76009 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.h +++ b/src/video_core/renderer_vulkan/vk_blit_screen.h @@ -6,6 +6,7 @@ #include <memory> #include "core/frontend/framebuffer_layout.h" +#include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/vulkan_common/vulkan_memory_allocator.h" #include "video_core/vulkan_common/vulkan_wrapper.h" @@ -13,10 +14,6 @@ namespace Core { class System; } -namespace Core::Memory { -class Memory; -} - namespace Core::Frontend { class EmuWindow; } @@ -56,8 +53,9 @@ struct ScreenInfo { class BlitScreen { public: - explicit BlitScreen(Core::Memory::Memory& cpu_memory, Core::Frontend::EmuWindow& render_window, - const Device& device, MemoryAllocator& memory_manager, Swapchain& swapchain, + explicit BlitScreen(Tegra::MaxwellDeviceMemoryManager& device_memory, + Core::Frontend::EmuWindow& render_window, const Device& device, + MemoryAllocator& memory_manager, Swapchain& swapchain, PresentManager& present_manager, Scheduler& scheduler, const ScreenInfo& screen_info); ~BlitScreen(); @@ -109,7 +107,7 @@ private: u64 CalculateBufferSize(const Tegra::FramebufferConfig& framebuffer) const; u64 GetRawImageOffset(const Tegra::FramebufferConfig& framebuffer) const; - Core::Memory::Memory& cpu_memory; + Tegra::MaxwellDeviceMemoryManager& device_memory; Core::Frontend::EmuWindow& render_window; const Device& device; MemoryAllocator& memory_allocator; diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp index 3c61799fa..31001d142 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp @@ -79,7 +79,7 @@ vk::Buffer CreateBuffer(const Device& device, const MemoryAllocator& memory_allo } // Anonymous namespace Buffer::Buffer(BufferCacheRuntime& runtime, VideoCommon::NullBufferParams null_params) - : VideoCommon::BufferBase<VideoCore::RasterizerInterface>(null_params), tracker{4096} { + : VideoCommon::BufferBase(null_params), tracker{4096} { if (runtime.device.HasNullDescriptor()) { return; } @@ -88,11 +88,9 @@ Buffer::Buffer(BufferCacheRuntime& runtime, VideoCommon::NullBufferParams null_p is_null = true; } -Buffer::Buffer(BufferCacheRuntime& runtime, VideoCore::RasterizerInterface& rasterizer_, - VAddr cpu_addr_, u64 size_bytes_) - : VideoCommon::BufferBase<VideoCore::RasterizerInterface>(rasterizer_, cpu_addr_, size_bytes_), - device{&runtime.device}, buffer{CreateBuffer(*device, runtime.memory_allocator, SizeBytes())}, - tracker{SizeBytes()} { +Buffer::Buffer(BufferCacheRuntime& runtime, DAddr cpu_addr_, u64 size_bytes_) + : VideoCommon::BufferBase(cpu_addr_, size_bytes_), device{&runtime.device}, + buffer{CreateBuffer(*device, runtime.memory_allocator, SizeBytes())}, tracker{SizeBytes()} { if (runtime.device.HasDebuggingToolAttached()) { buffer.SetObjectNameEXT(fmt::format("Buffer 0x{:x}", CpuAddr()).c_str()); } diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.h b/src/video_core/renderer_vulkan/vk_buffer_cache.h index dc300d7cb..e273f4988 100644 --- a/src/video_core/renderer_vulkan/vk_buffer_cache.h +++ b/src/video_core/renderer_vulkan/vk_buffer_cache.h @@ -23,11 +23,10 @@ struct HostVertexBinding; class BufferCacheRuntime; -class Buffer : public VideoCommon::BufferBase<VideoCore::RasterizerInterface> { +class Buffer : public VideoCommon::BufferBase { public: explicit Buffer(BufferCacheRuntime&, VideoCommon::NullBufferParams null_params); - explicit Buffer(BufferCacheRuntime& runtime, VideoCore::RasterizerInterface& rasterizer_, - VAddr cpu_addr_, u64 size_bytes_); + explicit Buffer(BufferCacheRuntime& runtime, VAddr cpu_addr_, u64 size_bytes_); [[nodiscard]] VkBufferView View(u32 offset, u32 size, VideoCore::Surface::PixelFormat format); @@ -173,7 +172,7 @@ struct BufferCacheParams { using Runtime = Vulkan::BufferCacheRuntime; using Buffer = Vulkan::Buffer; using Async_Buffer = Vulkan::StagingBufferRef; - using MemoryTracker = VideoCommon::MemoryTrackerBase<VideoCore::RasterizerInterface>; + using MemoryTracker = VideoCommon::MemoryTrackerBase<Tegra::MaxwellDeviceMemoryManager>; static constexpr bool IS_OPENGL = false; static constexpr bool HAS_PERSISTENT_UNIFORM_BUFFER_BINDINGS = false; diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index f2fd2670f..ec6b3a4b0 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -19,6 +19,7 @@ #include "video_core/renderer_vulkan/vk_texture_cache.h" #include "video_core/renderer_vulkan/vk_update_descriptor.h" #include "video_core/shader_notify.h" +#include "video_core/texture_cache/texture_cache.h" #include "video_core/vulkan_common/vulkan_device.h" #if defined(_MSC_VER) && defined(NDEBUG) diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index d1841198d..1e1821b10 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -30,7 +30,6 @@ #include "video_core/renderer_vulkan/vk_compute_pipeline.h" #include "video_core/renderer_vulkan/vk_descriptor_pool.h" #include "video_core/renderer_vulkan/vk_pipeline_cache.h" -#include "video_core/renderer_vulkan/vk_rasterizer.h" #include "video_core/renderer_vulkan/vk_scheduler.h" #include "video_core/renderer_vulkan/vk_shader_util.h" #include "video_core/renderer_vulkan/vk_update_descriptor.h" @@ -299,12 +298,13 @@ bool GraphicsPipelineCacheKey::operator==(const GraphicsPipelineCacheKey& rhs) c return std::memcmp(&rhs, this, Size()) == 0; } -PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, const Device& device_, - Scheduler& scheduler_, DescriptorPool& descriptor_pool_, +PipelineCache::PipelineCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, + const Device& device_, Scheduler& scheduler_, + DescriptorPool& descriptor_pool_, GuestDescriptorQueue& guest_descriptor_queue_, RenderPassCache& render_pass_cache_, BufferCache& buffer_cache_, TextureCache& texture_cache_, VideoCore::ShaderNotify& shader_notify_) - : VideoCommon::ShaderCache{rasterizer_}, device{device_}, scheduler{scheduler_}, + : VideoCommon::ShaderCache{device_memory_}, device{device_}, scheduler{scheduler_}, descriptor_pool{descriptor_pool_}, guest_descriptor_queue{guest_descriptor_queue_}, render_pass_cache{render_pass_cache_}, buffer_cache{buffer_cache_}, texture_cache{texture_cache_}, shader_notify{shader_notify_}, diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h index e323ea0fd..797700128 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h @@ -20,6 +20,7 @@ #include "shader_recompiler/object_pool.h" #include "shader_recompiler/profile.h" #include "video_core/engines/maxwell_3d.h" +#include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/renderer_vulkan/fixed_pipeline_state.h" #include "video_core/renderer_vulkan/vk_buffer_cache.h" #include "video_core/renderer_vulkan/vk_compute_pipeline.h" @@ -79,7 +80,6 @@ class ComputePipeline; class DescriptorPool; class Device; class PipelineStatistics; -class RasterizerVulkan; class RenderPassCache; class Scheduler; @@ -99,8 +99,8 @@ struct ShaderPools { class PipelineCache : public VideoCommon::ShaderCache { public: - explicit PipelineCache(RasterizerVulkan& rasterizer, const Device& device, Scheduler& scheduler, - DescriptorPool& descriptor_pool, + explicit PipelineCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, const Device& device, + Scheduler& scheduler, DescriptorPool& descriptor_pool, GuestDescriptorQueue& guest_descriptor_queue, RenderPassCache& render_pass_cache, BufferCache& buffer_cache, TextureCache& texture_cache, VideoCore::ShaderNotify& shader_notify_); diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp index ad4caf688..7cbc9c73c 100644 --- a/src/video_core/renderer_vulkan/vk_query_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp @@ -13,9 +13,10 @@ #include "common/bit_util.h" #include "common/common_types.h" -#include "core/memory.h" #include "video_core/engines/draw_manager.h" +#include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/query_cache/query_cache.h" +#include "video_core/rasterizer_interface.h" #include "video_core/renderer_vulkan/vk_buffer_cache.h" #include "video_core/renderer_vulkan/vk_compute_pass.h" #include "video_core/renderer_vulkan/vk_query_cache.h" @@ -102,7 +103,7 @@ private: using BaseStreamer = VideoCommon::SimpleStreamer<VideoCommon::HostQueryBase>; struct HostSyncValues { - VAddr address; + DAddr address; size_t size; size_t offset; @@ -317,7 +318,7 @@ public: pending_sync.clear(); } - size_t WriteCounter(VAddr address, bool has_timestamp, u32 value, + size_t WriteCounter(DAddr address, bool has_timestamp, u32 value, [[maybe_unused]] std::optional<u32> subreport) override { PauseCounter(); auto index = BuildQuery(); @@ -738,7 +739,7 @@ public: pending_sync.clear(); } - size_t WriteCounter(VAddr address, bool has_timestamp, u32 value, + size_t WriteCounter(DAddr address, bool has_timestamp, u32 value, std::optional<u32> subreport_) override { auto index = BuildQuery(); auto* new_query = GetQuery(index); @@ -769,9 +770,9 @@ public: return index; } - std::optional<std::pair<VAddr, size_t>> GetLastQueryStream(size_t stream) { + std::optional<std::pair<DAddr, size_t>> GetLastQueryStream(size_t stream) { if (last_queries[stream] != 0) { - std::pair<VAddr, size_t> result(last_queries[stream], last_queries_stride[stream]); + std::pair<DAddr, size_t> result(last_queries[stream], last_queries_stride[stream]); return result; } return std::nullopt; @@ -974,7 +975,7 @@ private: size_t buffers_count{}; std::array<VkBuffer, NUM_STREAMS> counter_buffers{}; std::array<VkDeviceSize, NUM_STREAMS> offsets{}; - std::array<VAddr, NUM_STREAMS> last_queries; + std::array<DAddr, NUM_STREAMS> last_queries; std::array<size_t, NUM_STREAMS> last_queries_stride; Maxwell3D::Regs::PrimitiveTopology out_topology; u64 streams_mask; @@ -987,7 +988,7 @@ public: : VideoCommon::QueryBase(0, VideoCommon::QueryFlagBits::IsHostManaged, 0) {} // Parameterized constructor - PrimitivesQueryBase(bool has_timestamp, VAddr address) + PrimitivesQueryBase(bool has_timestamp, DAddr address) : VideoCommon::QueryBase(address, VideoCommon::QueryFlagBits::IsHostManaged, 0) { if (has_timestamp) { flags |= VideoCommon::QueryFlagBits::HasTimestamp; @@ -995,7 +996,7 @@ public: } u64 stride{}; - VAddr dependant_address{}; + DAddr dependant_address{}; Maxwell3D::Regs::PrimitiveTopology topology{Maxwell3D::Regs::PrimitiveTopology::Points}; size_t dependant_index{}; bool dependant_manage{}; @@ -1005,15 +1006,15 @@ class PrimitivesSucceededStreamer : public VideoCommon::SimpleStreamer<Primitive public: explicit PrimitivesSucceededStreamer(size_t id_, QueryCacheRuntime& runtime_, TFBCounterStreamer& tfb_streamer_, - Core::Memory::Memory& cpu_memory_) + Tegra::MaxwellDeviceMemoryManager& device_memory_) : VideoCommon::SimpleStreamer<PrimitivesQueryBase>(id_), runtime{runtime_}, - tfb_streamer{tfb_streamer_}, cpu_memory{cpu_memory_} { + tfb_streamer{tfb_streamer_}, device_memory{device_memory_} { MakeDependent(&tfb_streamer); } ~PrimitivesSucceededStreamer() = default; - size_t WriteCounter(VAddr address, bool has_timestamp, u32 value, + size_t WriteCounter(DAddr address, bool has_timestamp, u32 value, std::optional<u32> subreport_) override { auto index = BuildQuery(); auto* new_query = GetQuery(index); @@ -1063,6 +1064,8 @@ public: } }); } + auto* ptr = device_memory.GetPointer<u8>(new_query->dependant_address); + ASSERT(ptr != nullptr); new_query->dependant_manage = must_manage_dependance; pending_flush_queries.push_back(index); @@ -1100,7 +1103,7 @@ public: num_vertices = dependant_query->value / query->stride; tfb_streamer.Free(query->dependant_index); } else { - u8* pointer = cpu_memory.GetPointer(query->dependant_address); + u8* pointer = device_memory.GetPointer<u8>(query->dependant_address); u32 result; std::memcpy(&result, pointer, sizeof(u32)); num_vertices = static_cast<u64>(result) / query->stride; @@ -1137,7 +1140,7 @@ public: private: QueryCacheRuntime& runtime; TFBCounterStreamer& tfb_streamer; - Core::Memory::Memory& cpu_memory; + Tegra::MaxwellDeviceMemoryManager& device_memory; // syncing queue std::vector<size_t> pending_sync; @@ -1152,12 +1155,13 @@ private: struct QueryCacheRuntimeImpl { QueryCacheRuntimeImpl(QueryCacheRuntime& runtime, VideoCore::RasterizerInterface* rasterizer_, - Core::Memory::Memory& cpu_memory_, Vulkan::BufferCache& buffer_cache_, - const Device& device_, const MemoryAllocator& memory_allocator_, - Scheduler& scheduler_, StagingBufferPool& staging_pool_, + Tegra::MaxwellDeviceMemoryManager& device_memory_, + Vulkan::BufferCache& buffer_cache_, const Device& device_, + const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, + StagingBufferPool& staging_pool_, ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool) - : rasterizer{rasterizer_}, cpu_memory{cpu_memory_}, + : rasterizer{rasterizer_}, device_memory{device_memory_}, buffer_cache{buffer_cache_}, device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, staging_pool{staging_pool_}, guest_streamer(0, runtime), @@ -1168,7 +1172,7 @@ struct QueryCacheRuntimeImpl { scheduler, memory_allocator, staging_pool), primitives_succeeded_streamer( static_cast<size_t>(QueryType::StreamingPrimitivesSucceeded), runtime, tfb_streamer, - cpu_memory_), + device_memory_), primitives_needed_minus_succeeded_streamer( static_cast<size_t>(QueryType::StreamingPrimitivesNeededMinusSucceeded), runtime, 0u), hcr_setup{}, hcr_is_set{}, is_hcr_running{}, maxwell3d{} { @@ -1195,7 +1199,7 @@ struct QueryCacheRuntimeImpl { } VideoCore::RasterizerInterface* rasterizer; - Core::Memory::Memory& cpu_memory; + Tegra::MaxwellDeviceMemoryManager& device_memory; Vulkan::BufferCache& buffer_cache; const Device& device; @@ -1210,7 +1214,7 @@ struct QueryCacheRuntimeImpl { PrimitivesSucceededStreamer primitives_succeeded_streamer; VideoCommon::StubStreamer<QueryCacheParams> primitives_needed_minus_succeeded_streamer; - std::vector<std::pair<VAddr, VAddr>> little_cache; + std::vector<std::pair<DAddr, DAddr>> little_cache; std::vector<std::pair<VkBuffer, VkDeviceSize>> buffers_to_upload_to; std::vector<size_t> redirect_cache; std::vector<std::vector<VkBufferCopy>> copies_setup; @@ -1229,14 +1233,14 @@ struct QueryCacheRuntimeImpl { }; QueryCacheRuntime::QueryCacheRuntime(VideoCore::RasterizerInterface* rasterizer, - Core::Memory::Memory& cpu_memory_, + Tegra::MaxwellDeviceMemoryManager& device_memory_, Vulkan::BufferCache& buffer_cache_, const Device& device_, const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, StagingBufferPool& staging_pool_, ComputePassDescriptorQueue& compute_pass_descriptor_queue, DescriptorPool& descriptor_pool) { impl = std::make_unique<QueryCacheRuntimeImpl>( - *this, rasterizer, cpu_memory_, buffer_cache_, device_, memory_allocator_, scheduler_, + *this, rasterizer, device_memory_, buffer_cache_, device_, memory_allocator_, scheduler_, staging_pool_, compute_pass_descriptor_queue, descriptor_pool); } @@ -1309,7 +1313,7 @@ void QueryCacheRuntime::HostConditionalRenderingCompareValueImpl(VideoCommon::Lo ResumeHostConditionalRendering(); } -void QueryCacheRuntime::HostConditionalRenderingCompareBCImpl(VAddr address, bool is_equal) { +void QueryCacheRuntime::HostConditionalRenderingCompareBCImpl(DAddr address, bool is_equal) { VkBuffer to_resolve; u32 to_resolve_offset; { @@ -1350,11 +1354,11 @@ bool QueryCacheRuntime::HostConditionalRenderingCompareValues(VideoCommon::Looku return false; } - const auto check_in_bc = [&](VAddr address) { + const auto check_in_bc = [&](DAddr address) { return impl->buffer_cache.IsRegionGpuModified(address, 8); }; - const auto check_value = [&](VAddr address) { - u8* ptr = impl->cpu_memory.GetPointer(address); + const auto check_value = [&](DAddr address) { + u8* ptr = impl->device_memory.GetPointer<u8>(address); u64 value{}; std::memcpy(&value, ptr, sizeof(value)); return value == 0; @@ -1477,8 +1481,8 @@ void QueryCacheRuntime::SyncValues(std::span<SyncValuesType> values, VkBuffer ba for (auto& sync_val : values) { total_size += sync_val.size; bool found = false; - VAddr base = Common::AlignDown(sync_val.address, Core::Memory::YUZU_PAGESIZE); - VAddr base_end = base + Core::Memory::YUZU_PAGESIZE; + DAddr base = Common::AlignDown(sync_val.address, Core::DEVICE_PAGESIZE); + DAddr base_end = base + Core::DEVICE_PAGESIZE; for (size_t i = 0; i < impl->little_cache.size(); i++) { const auto set_found = [&] { impl->redirect_cache.push_back(i); diff --git a/src/video_core/renderer_vulkan/vk_query_cache.h b/src/video_core/renderer_vulkan/vk_query_cache.h index e9a1ea169..f6151123e 100644 --- a/src/video_core/renderer_vulkan/vk_query_cache.h +++ b/src/video_core/renderer_vulkan/vk_query_cache.h @@ -27,7 +27,7 @@ struct QueryCacheRuntimeImpl; class QueryCacheRuntime { public: explicit QueryCacheRuntime(VideoCore::RasterizerInterface* rasterizer, - Core::Memory::Memory& cpu_memory_, + Tegra::MaxwellDeviceMemoryManager& device_memory_, Vulkan::BufferCache& buffer_cache_, const Device& device_, const MemoryAllocator& memory_allocator_, Scheduler& scheduler_, StagingBufferPool& staging_pool_, @@ -61,7 +61,7 @@ public: private: void HostConditionalRenderingCompareValueImpl(VideoCommon::LookupData object, bool is_equal); - void HostConditionalRenderingCompareBCImpl(VAddr address, bool is_equal); + void HostConditionalRenderingCompareBCImpl(DAddr address, bool is_equal); friend struct QueryCacheRuntimeImpl; std::unique_ptr<QueryCacheRuntimeImpl> impl; }; diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 241fc34be..5bf41b81f 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -18,6 +18,7 @@ #include "video_core/engines/draw_manager.h" #include "video_core/engines/kepler_compute.h" #include "video_core/engines/maxwell_3d.h" +#include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/renderer_vulkan/blit_image.h" #include "video_core/renderer_vulkan/fixed_pipeline_state.h" #include "video_core/renderer_vulkan/maxwell_to_vk.h" @@ -163,10 +164,11 @@ DrawParams MakeDrawParams(const MaxwellDrawState& draw_state, u32 num_instances, } // Anonymous namespace RasterizerVulkan::RasterizerVulkan(Core::Frontend::EmuWindow& emu_window_, Tegra::GPU& gpu_, - Core::Memory::Memory& cpu_memory_, ScreenInfo& screen_info_, - const Device& device_, MemoryAllocator& memory_allocator_, - StateTracker& state_tracker_, Scheduler& scheduler_) - : RasterizerAccelerated{cpu_memory_}, gpu{gpu_}, screen_info{screen_info_}, device{device_}, + Tegra::MaxwellDeviceMemoryManager& device_memory_, + ScreenInfo& screen_info_, const Device& device_, + MemoryAllocator& memory_allocator_, StateTracker& state_tracker_, + Scheduler& scheduler_) + : gpu{gpu_}, device_memory{device_memory_}, screen_info{screen_info_}, device{device_}, memory_allocator{memory_allocator_}, state_tracker{state_tracker_}, scheduler{scheduler_}, staging_pool(device, memory_allocator, scheduler), descriptor_pool(device, scheduler), guest_descriptor_queue(device, scheduler), compute_pass_descriptor_queue(device, scheduler), @@ -174,14 +176,14 @@ RasterizerVulkan::RasterizerVulkan(Core::Frontend::EmuWindow& emu_window_, Tegra texture_cache_runtime{ device, scheduler, memory_allocator, staging_pool, blit_image, render_pass_cache, descriptor_pool, compute_pass_descriptor_queue}, - texture_cache(texture_cache_runtime, *this), + texture_cache(texture_cache_runtime, device_memory), buffer_cache_runtime(device, memory_allocator, scheduler, staging_pool, guest_descriptor_queue, compute_pass_descriptor_queue, descriptor_pool), - buffer_cache(*this, cpu_memory_, buffer_cache_runtime), - query_cache_runtime(this, cpu_memory_, buffer_cache, device, memory_allocator, scheduler, + buffer_cache(device_memory, buffer_cache_runtime), + query_cache_runtime(this, device_memory, buffer_cache, device, memory_allocator, scheduler, staging_pool, compute_pass_descriptor_queue, descriptor_pool), - query_cache(gpu, *this, cpu_memory_, query_cache_runtime), - pipeline_cache(*this, device, scheduler, descriptor_pool, guest_descriptor_queue, + query_cache(gpu, *this, device_memory, query_cache_runtime), + pipeline_cache(device_memory, device, scheduler, descriptor_pool, guest_descriptor_queue, render_pass_cache, buffer_cache, texture_cache, gpu.ShaderNotify()), accelerate_dma(buffer_cache, texture_cache, scheduler), fence_manager(*this, gpu, texture_cache, buffer_cache, query_cache, device, scheduler), @@ -508,7 +510,7 @@ void Vulkan::RasterizerVulkan::DisableGraphicsUniformBuffer(size_t stage, u32 in void RasterizerVulkan::FlushAll() {} -void RasterizerVulkan::FlushRegion(VAddr addr, u64 size, VideoCommon::CacheType which) { +void RasterizerVulkan::FlushRegion(DAddr addr, u64 size, VideoCommon::CacheType which) { if (addr == 0 || size == 0) { return; } @@ -525,7 +527,7 @@ void RasterizerVulkan::FlushRegion(VAddr addr, u64 size, VideoCommon::CacheType } } -bool RasterizerVulkan::MustFlushRegion(VAddr addr, u64 size, VideoCommon::CacheType which) { +bool RasterizerVulkan::MustFlushRegion(DAddr addr, u64 size, VideoCommon::CacheType which) { if ((True(which & VideoCommon::CacheType::BufferCache))) { std::scoped_lock lock{buffer_cache.mutex}; if (buffer_cache.IsRegionGpuModified(addr, size)) { @@ -542,7 +544,7 @@ bool RasterizerVulkan::MustFlushRegion(VAddr addr, u64 size, VideoCommon::CacheT return false; } -VideoCore::RasterizerDownloadArea RasterizerVulkan::GetFlushArea(VAddr addr, u64 size) { +VideoCore::RasterizerDownloadArea RasterizerVulkan::GetFlushArea(DAddr addr, u64 size) { { std::scoped_lock lock{texture_cache.mutex}; auto area = texture_cache.GetFlushArea(addr, size); @@ -551,14 +553,14 @@ VideoCore::RasterizerDownloadArea RasterizerVulkan::GetFlushArea(VAddr addr, u64 } } VideoCore::RasterizerDownloadArea new_area{ - .start_address = Common::AlignDown(addr, Core::Memory::YUZU_PAGESIZE), - .end_address = Common::AlignUp(addr + size, Core::Memory::YUZU_PAGESIZE), + .start_address = Common::AlignDown(addr, Core::DEVICE_PAGESIZE), + .end_address = Common::AlignUp(addr + size, Core::DEVICE_PAGESIZE), .preemtive = true, }; return new_area; } -void RasterizerVulkan::InvalidateRegion(VAddr addr, u64 size, VideoCommon::CacheType which) { +void RasterizerVulkan::InvalidateRegion(DAddr addr, u64 size, VideoCommon::CacheType which) { if (addr == 0 || size == 0) { return; } @@ -578,7 +580,7 @@ void RasterizerVulkan::InvalidateRegion(VAddr addr, u64 size, VideoCommon::Cache } } -void RasterizerVulkan::InnerInvalidation(std::span<const std::pair<VAddr, std::size_t>> sequences) { +void RasterizerVulkan::InnerInvalidation(std::span<const std::pair<DAddr, std::size_t>> sequences) { { std::scoped_lock lock{texture_cache.mutex}; for (const auto& [addr, size] : sequences) { @@ -599,7 +601,7 @@ void RasterizerVulkan::InnerInvalidation(std::span<const std::pair<VAddr, std::s } } -bool RasterizerVulkan::OnCPUWrite(VAddr addr, u64 size) { +bool RasterizerVulkan::OnCPUWrite(DAddr addr, u64 size) { if (addr == 0 || size == 0) { return false; } @@ -620,7 +622,7 @@ bool RasterizerVulkan::OnCPUWrite(VAddr addr, u64 size) { return false; } -void RasterizerVulkan::OnCacheInvalidation(VAddr addr, u64 size) { +void RasterizerVulkan::OnCacheInvalidation(DAddr addr, u64 size) { if (addr == 0 || size == 0) { return; } @@ -640,7 +642,7 @@ void RasterizerVulkan::InvalidateGPUCache() { gpu.InvalidateGPUCache(); } -void RasterizerVulkan::UnmapMemory(VAddr addr, u64 size) { +void RasterizerVulkan::UnmapMemory(DAddr addr, u64 size) { { std::scoped_lock lock{texture_cache.mutex}; texture_cache.UnmapMemory(addr, size); @@ -679,7 +681,7 @@ void RasterizerVulkan::ReleaseFences(bool force) { fence_manager.WaitPendingFences(force); } -void RasterizerVulkan::FlushAndInvalidateRegion(VAddr addr, u64 size, +void RasterizerVulkan::FlushAndInvalidateRegion(DAddr addr, u64 size, VideoCommon::CacheType which) { if (Settings::IsGPULevelExtreme()) { FlushRegion(addr, size, which); @@ -782,7 +784,7 @@ void RasterizerVulkan::AccelerateInlineToMemory(GPUVAddr address, size_t copy_si } bool RasterizerVulkan::AccelerateDisplay(const Tegra::FramebufferConfig& config, - VAddr framebuffer_addr, u32 pixel_stride) { + DAddr framebuffer_addr, u32 pixel_stride) { if (!framebuffer_addr) { return false; } diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h index ad069556c..881ee0993 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.h +++ b/src/video_core/renderer_vulkan/vk_rasterizer.h @@ -7,14 +7,13 @@ #include <boost/container/static_vector.hpp> -#include "video_core/renderer_vulkan/vk_buffer_cache.h" - #include "common/common_types.h" #include "video_core/control/channel_state_cache.h" #include "video_core/engines/maxwell_dma.h" -#include "video_core/rasterizer_accelerated.h" +#include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/rasterizer_interface.h" #include "video_core/renderer_vulkan/blit_image.h" +#include "video_core/renderer_vulkan/vk_buffer_cache.h" #include "video_core/renderer_vulkan/vk_descriptor_pool.h" #include "video_core/renderer_vulkan/vk_fence_manager.h" #include "video_core/renderer_vulkan/vk_pipeline_cache.h" @@ -34,10 +33,14 @@ namespace Core::Frontend { class EmuWindow; } -namespace Tegra::Engines { +namespace Tegra { + +namespace Engines { class Maxwell3D; } +} // namespace Tegra + namespace Vulkan { struct ScreenInfo; @@ -70,13 +73,14 @@ private: Scheduler& scheduler; }; -class RasterizerVulkan final : public VideoCore::RasterizerAccelerated, +class RasterizerVulkan final : public VideoCore::RasterizerInterface, protected VideoCommon::ChannelSetupCaches<VideoCommon::ChannelInfo> { public: explicit RasterizerVulkan(Core::Frontend::EmuWindow& emu_window_, Tegra::GPU& gpu_, - Core::Memory::Memory& cpu_memory_, ScreenInfo& screen_info_, - const Device& device_, MemoryAllocator& memory_allocator_, - StateTracker& state_tracker_, Scheduler& scheduler_); + Tegra::MaxwellDeviceMemoryManager& device_memory_, + ScreenInfo& screen_info_, const Device& device_, + MemoryAllocator& memory_allocator_, StateTracker& state_tracker_, + Scheduler& scheduler_); ~RasterizerVulkan() override; void Draw(bool is_indexed, u32 instance_count) override; @@ -90,18 +94,18 @@ public: void BindGraphicsUniformBuffer(size_t stage, u32 index, GPUVAddr gpu_addr, u32 size) override; void DisableGraphicsUniformBuffer(size_t stage, u32 index) override; void FlushAll() override; - void FlushRegion(VAddr addr, u64 size, + void FlushRegion(DAddr addr, u64 size, VideoCommon::CacheType which = VideoCommon::CacheType::All) override; - bool MustFlushRegion(VAddr addr, u64 size, + bool MustFlushRegion(DAddr addr, u64 size, VideoCommon::CacheType which = VideoCommon::CacheType::All) override; - VideoCore::RasterizerDownloadArea GetFlushArea(VAddr addr, u64 size) override; - void InvalidateRegion(VAddr addr, u64 size, + VideoCore::RasterizerDownloadArea GetFlushArea(DAddr addr, u64 size) override; + void InvalidateRegion(DAddr addr, u64 size, VideoCommon::CacheType which = VideoCommon::CacheType::All) override; - void InnerInvalidation(std::span<const std::pair<VAddr, std::size_t>> sequences) override; - void OnCacheInvalidation(VAddr addr, u64 size) override; - bool OnCPUWrite(VAddr addr, u64 size) override; + void InnerInvalidation(std::span<const std::pair<DAddr, std::size_t>> sequences) override; + void OnCacheInvalidation(DAddr addr, u64 size) override; + bool OnCPUWrite(DAddr addr, u64 size) override; void InvalidateGPUCache() override; - void UnmapMemory(VAddr addr, u64 size) override; + void UnmapMemory(DAddr addr, u64 size) override; void ModifyGPUMemory(size_t as_id, GPUVAddr addr, u64 size) override; void SignalFence(std::function<void()>&& func) override; void SyncOperation(std::function<void()>&& func) override; @@ -109,7 +113,7 @@ public: void SignalReference() override; void ReleaseFences(bool force = true) override; void FlushAndInvalidateRegion( - VAddr addr, u64 size, VideoCommon::CacheType which = VideoCommon::CacheType::All) override; + DAddr addr, u64 size, VideoCommon::CacheType which = VideoCommon::CacheType::All) override; void WaitForIdle() override; void FragmentBarrier() override; void TiledCacheBarrier() override; @@ -122,7 +126,7 @@ public: Tegra::Engines::AccelerateDMAInterface& AccessAccelerateDMA() override; void AccelerateInlineToMemory(GPUVAddr address, size_t copy_size, std::span<const u8> memory) override; - bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr, + bool AccelerateDisplay(const Tegra::FramebufferConfig& config, DAddr framebuffer_addr, u32 pixel_stride) override; void LoadDiskResources(u64 title_id, std::stop_token stop_loading, const VideoCore::DiskResourceLoadCallback& callback) override; @@ -176,6 +180,7 @@ private: void UpdateVertexInput(Tegra::Engines::Maxwell3D::Regs& regs); Tegra::GPU& gpu; + Tegra::MaxwellDeviceMemoryManager& device_memory; ScreenInfo& screen_info; const Device& device; |