[gl, vk] Implement SampledView method for ImageView

This commit is contained in:
CamilleLaVey 2025-11-27 17:18:17 -04:00 committed by Caio Oliveira
parent 82a2574aeb
commit 885fc2746c
7 changed files with 46 additions and 3 deletions

View file

@ -189,7 +189,8 @@ inline void PushImageDescriptors(TextureCache& texture_cache,
const VideoCommon::ImageViewId image_view_id{(views++)->id};
const VideoCommon::SamplerId sampler_id{*(samplers++)};
ImageView& image_view{texture_cache.GetImageView(image_view_id)};
const VkImageView vk_image_view{image_view.Handle(desc.type)};
const VkImageView vk_image_view{
image_view.SampledView(desc.type, desc.component_type)};
const Sampler& sampler{texture_cache.GetSampler(sampler_id)};
const bool use_fallback_sampler{sampler.HasAddedAnisotropy() &&
!image_view.SupportsAnisotropy()};

View file

@ -24,6 +24,7 @@
#include "video_core/renderer_vulkan/vk_render_pass_cache.h"
#include "video_core/renderer_vulkan/vk_scheduler.h"
#include "video_core/renderer_vulkan/vk_staging_buffer_pool.h"
#include "video_core/surface.h"
#include "video_core/texture_cache/formatter.h"
#include "video_core/texture_cache/samples_helper.h"
#include "video_core/texture_cache/util.h"
@ -2211,6 +2212,29 @@ VkImageView ImageView::ColorView() {
return *color_view;
}
VkImageView ImageView::SampledView(Shader::TextureType texture_type,
Shader::SamplerComponentType component_type) {
using VideoCore::Surface::GetFormatType;
using VideoCore::Surface::SurfaceType;
const SurfaceType surface_type = GetFormatType(format);
switch (component_type) {
case Shader::SamplerComponentType::Depth:
if (surface_type == SurfaceType::Depth || surface_type == SurfaceType::DepthStencil) {
return DepthView();
}
break;
case Shader::SamplerComponentType::Stencil:
if (surface_type == SurfaceType::Stencil || surface_type == SurfaceType::DepthStencil) {
return StencilView();
}
break;
default:
break;
}
return Handle(texture_type);
}
VkImageView ImageView::StorageView(Shader::TextureType texture_type,
Shader::ImageFormat image_format) {
if (!image_handle) {

View file

@ -236,6 +236,9 @@ public:
[[nodiscard]] VkImageView ColorView();
[[nodiscard]] VkImageView SampledView(Shader::TextureType texture_type,
Shader::SamplerComponentType component_type);
[[nodiscard]] VkImageView StorageView(Shader::TextureType texture_type,
Shader::ImageFormat image_format);