From ad61d72f2c9e4b08295428fcd8a282caa18e12a1 Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Mon, 20 Nov 2023 14:06:00 -0800 Subject: [PATCH] vk_texture_runtime: Use highest priority image for image-views by default Never write the MSAA image to descriptor sets or for sampling though, default to a starting index of 1 in those cases. This should probably be an enum. --- .../renderer_vulkan/vk_rasterizer.cpp | 4 ++-- .../renderer_vulkan/vk_texture_runtime.cpp | 18 +++++++++--------- .../renderer_vulkan/vk_texture_runtime.h | 10 +++++----- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 138560a64..51fc2459f 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -594,7 +594,7 @@ void RasterizerVulkan::SyncTextureUnits(const Framebuffer* framebuffer) { Surface& surface = res_cache.GetTextureSurface(texture); Sampler& sampler = res_cache.GetSampler(texture.config); if (!IsFeedbackLoop(texture_index, framebuffer, surface, sampler)) { - pipeline_cache.BindTexture(texture_index, surface.ImageView(), sampler.Handle()); + pipeline_cache.BindTexture(texture_index, surface.ImageView(1), sampler.Handle()); } } } @@ -784,7 +784,7 @@ bool RasterizerVulkan::AccelerateDisplay(const Pica::FramebufferConfig& config, (float)src_rect.bottom / (float)scaled_height, (float)src_rect.left / (float)scaled_width, (float)src_rect.top / (float)scaled_height, (float)src_rect.right / (float)scaled_width); - screen_info.image_view = src_surface.ImageView(); + screen_info.image_view = src_surface.ImageView(1); return true; } diff --git a/src/video_core/renderer_vulkan/vk_texture_runtime.cpp b/src/video_core/renderer_vulkan/vk_texture_runtime.cpp index f07dba5a0..b9cb58863 100644 --- a/src/video_core/renderer_vulkan/vk_texture_runtime.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_runtime.cpp @@ -1367,11 +1367,10 @@ vk::ImageView Surface::CopyImageView() noexcept { } vk::ImageView Surface::ImageView(u32 index) const noexcept { - const auto& image_view = handles[index].image_view.get(); - if (!image_view) { - return handles[0].image_view.get(); - } - return image_view; + const auto it = + std::find_if(handles.crend() - index - 1, handles.crend(), + [](const Handle& handle) -> bool { return handle.image_view.get(); }); + return it->image_view.get(); } vk::ImageView Surface::FramebufferView(u32 index) noexcept { @@ -1438,7 +1437,7 @@ vk::ImageView Surface::StorageView(u32 index) noexcept { is_storage = true; const vk::ImageViewCreateInfo storage_view_info = { - .image = sample_count > 1 ? Image(3) : Image(), + .image = Image(), .viewType = vk::ImageViewType::e2D, .format = vk::Format::eR32Uint, .subresourceRange{ @@ -1465,7 +1464,7 @@ vk::Framebuffer Surface::Framebuffer() noexcept { const auto render_pass = runtime->renderpass_cache.GetRenderpass(color_format, depth_format, false, sample_count); boost::container::static_vector attachments; - attachments.emplace_back(ImageView()); + attachments.emplace_back(ImageView(1)); if (sample_count > 1) { attachments.emplace_back(ImageView(3)); } @@ -1597,8 +1596,9 @@ Framebuffer::Framebuffer(TextureRuntime& runtime, const VideoCore::FramebufferPa formats[index] = surface->pixel_format; } aspects[index] = surface->Aspect(); - images[index] = surface->Image(); - image_views[index] = shadow_rendering ? surface->StorageView() : surface->FramebufferView(); + images[index] = surface->Image(1); + image_views[index] = + shadow_rendering ? surface->StorageView(1) : surface->FramebufferView(1); }; boost::container::static_vector attachments; diff --git a/src/video_core/renderer_vulkan/vk_texture_runtime.h b/src/video_core/renderer_vulkan/vk_texture_runtime.h index 7795be0b3..9442ac91c 100644 --- a/src/video_core/renderer_vulkan/vk_texture_runtime.h +++ b/src/video_core/renderer_vulkan/vk_texture_runtime.h @@ -126,22 +126,22 @@ public: vk::Image Image(u32 index = 3) const noexcept; /// Returns the image view at index, otherwise the base view - vk::ImageView ImageView(u32 index = 1) const noexcept; + vk::ImageView ImageView(u32 index = 3) const noexcept; /// Returns a copy of the upscaled image handle, used for feedback loops. vk::ImageView CopyImageView() noexcept; /// Returns the framebuffer view of the surface image - vk::ImageView FramebufferView(u32 index = 1) noexcept; + vk::ImageView FramebufferView(u32 index = 3) noexcept; /// Returns the depth view of the surface image - vk::ImageView DepthView(u32 index = 1) noexcept; + vk::ImageView DepthView(u32 index = 3) noexcept; /// Returns the stencil view of the surface image - vk::ImageView StencilView(u32 index = 1) noexcept; + vk::ImageView StencilView(u32 index = 3) noexcept; /// Returns the R32 image view used for atomic load/store - vk::ImageView StorageView(u32 index = 1) noexcept; + vk::ImageView StorageView(u32 index = 3) noexcept; /// Returns a framebuffer handle for rendering to this surface vk::Framebuffer Framebuffer() noexcept;