From 44145b1f0afaa6c442d4461acf59d5f27adb5e9c Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 22 May 2023 08:51:16 +0200 Subject: [PATCH] early-access version 3602 --- README.md | 2 +- src/video_core/renderer_opengl/gl_texture_cache.h | 4 ++++ src/video_core/renderer_vulkan/pipeline_helper.h | 7 +++++++ src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | 4 ++-- src/video_core/renderer_vulkan/vk_scheduler.h | 9 +++++++++ src/video_core/renderer_vulkan/vk_texture_cache.cpp | 6 ++++++ src/video_core/renderer_vulkan/vk_texture_cache.h | 2 ++ src/video_core/texture_cache/texture_cache.h | 5 +++++ src/video_core/texture_cache/texture_cache_base.h | 3 +++ 9 files changed, 39 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1a658c17b..9a11f084d 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3601. +This is the source code for early-access 3602. ## Legal Notice diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index 74522f029..df8780128 100755 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h @@ -144,6 +144,10 @@ public: return state_tracker; } + void CheckFeedbackLoop(ImageView& image_view) const noexcept { + // OpenGL does not require a barrier for attachment feedback loops. + } + private: struct StagingBuffers { explicit StagingBuffers(GLenum storage_flags_, GLenum map_flags_); diff --git a/src/video_core/renderer_vulkan/pipeline_helper.h b/src/video_core/renderer_vulkan/pipeline_helper.h index ee7f08a2b..8518205c6 100755 --- a/src/video_core/renderer_vulkan/pipeline_helper.h +++ b/src/video_core/renderer_vulkan/pipeline_helper.h @@ -175,6 +175,7 @@ public: std::array words{}; }; +template inline void PushImageDescriptors(TextureCache& texture_cache, GuestDescriptorQueue& guest_descriptor_queue, const Shader::Info& info, RescalingPushConstant& rescaling, @@ -192,6 +193,9 @@ inline void PushImageDescriptors(TextureCache& texture_cache, const VkImageView vk_image_view{image_view.Handle(desc.type)}; guest_descriptor_queue.AddSampledImage(vk_image_view, sampler); rescaling.PushTexture(texture_cache.IsRescaling(image_view)); + if constexpr (CheckFeedbackLoop) { + texture_cache.CheckFeedbackLoop(image_view); + } } } for (const auto& desc : info.image_descriptors) { @@ -203,6 +207,9 @@ inline void PushImageDescriptors(TextureCache& texture_cache, const VkImageView vk_image_view{image_view.StorageView(desc.type, desc.format)}; guest_descriptor_queue.AddImage(vk_image_view); rescaling.PushImage(texture_cache.IsRescaling(image_view)); + if constexpr (CheckFeedbackLoop) { + texture_cache.CheckFeedbackLoop(image_view); + } } } } diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index a8eb37274..6225e4abc 100755 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -457,8 +457,8 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) { const VideoCommon::ImageViewInOut* views_it{views.data()}; const auto prepare_stage{[&](size_t stage) LAMBDA_FORCEINLINE { buffer_cache.BindHostStageBuffers(stage); - PushImageDescriptors(texture_cache, guest_descriptor_queue, stage_infos[stage], rescaling, - samplers_it, views_it); + PushImageDescriptors(texture_cache, guest_descriptor_queue, stage_infos[stage], + rescaling, samplers_it, views_it); const auto& info{stage_infos[0]}; if (info.uses_render_area) { render_area.uses_render_area = true; diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h index 074b4b4df..160dfb322 100755 --- a/src/video_core/renderer_vulkan/vk_scheduler.h +++ b/src/video_core/renderer_vulkan/vk_scheduler.h @@ -106,6 +106,15 @@ public: return *master_semaphore; } + [[nodiscard]] bool IsRenderpassImage(VkImage image) const noexcept { + for (u32 i = 0; i < num_renderpass_images; i++) { + if (image == renderpass_images[i]) { + return true; + } + } + return false; + } + std::mutex submit_mutex; private: diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 5f8a14355..7d84a7e9f 100755 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -861,6 +861,12 @@ VkBuffer TextureCacheRuntime::GetTemporaryBuffer(size_t needed_size) { return *buffers[level]; } +void TextureCacheRuntime::CheckFeedbackLoop(ImageView& image_view) { + if (scheduler.IsRenderpassImage(image_view.ImageHandle())) { + scheduler.RequestOutsideRenderPassOperationContext(); + } +} + void TextureCacheRuntime::ReinterpretImage(Image& dst, Image& src, std::span copies) { std::vector vk_in_copies(copies.size()); diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index ee3fb833c..fddd46c28 100755 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h @@ -103,6 +103,8 @@ public: [[nodiscard]] VkBuffer GetTemporaryBuffer(size_t needed_size); + void CheckFeedbackLoop(ImageView& image_view); + const Device& device; Scheduler& scheduler; MemoryAllocator& memory_allocator; diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 841aeb534..324410071 100755 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -2374,6 +2374,11 @@ bool TextureCache

::IsFullClear(ImageViewId id) { scissor.max_y >= size.height; } +template +void TextureCache

::CheckFeedbackLoop(ImageView& image_view) { + runtime.CheckFeedbackLoop(image_view); +} + template void TextureCache

::CreateChannel(struct Tegra::Control::ChannelState& channel) { VideoCommon::ChannelSetupCaches::CreateChannel(channel); diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index af6436b6a..c69eb3925 100755 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h @@ -224,6 +224,9 @@ public: [[nodiscard]] bool IsRescaling(const ImageViewBase& image_view) const noexcept; + /// Handle feedback loops during draws. + void CheckFeedbackLoop(ImageView& image_view); + /// Create channel state. void CreateChannel(Tegra::Control::ChannelState& channel) final override;