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.
This commit is contained in:
Wunkolo 2023-11-20 14:06:00 -08:00
parent 4de9d81b50
commit ad61d72f2c
3 changed files with 16 additions and 16 deletions

View File

@ -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;
}

View File

@ -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<vk::ImageView, 2> 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<vk::ImageView, 4> attachments;

View File

@ -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;