diff options
| author | 2023-06-18 00:02:05 +0200 | |
|---|---|---|
| committer | 2023-06-18 00:02:05 +0200 | |
| commit | 27a36cd51bbc832b0b73cbbaef6bd8453368a38d (patch) | |
| tree | 00a30700c65665e2eaf2b02f03d73585c4d4f790 /src/video_core/texture_cache | |
| parent | Merge pull request #10783 from liamwhite/memory (diff) | |
| parent | video_core: Only apply AF to 2D (array) image types (diff) | |
| download | yuzu-27a36cd51bbc832b0b73cbbaef6bd8453368a38d.tar.gz yuzu-27a36cd51bbc832b0b73cbbaef6bd8453368a38d.tar.xz yuzu-27a36cd51bbc832b0b73cbbaef6bd8453368a38d.zip | |
Merge pull request #10744 from Wollnashorn/af-for-all
video_core: Improved anisotropic filtering heuristics
Diffstat (limited to 'src/video_core/texture_cache')
| -rw-r--r-- | src/video_core/texture_cache/image_view_base.cpp | 52 | ||||
| -rw-r--r-- | src/video_core/texture_cache/image_view_base.h | 2 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 30 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache_base.h | 12 |
4 files changed, 91 insertions, 5 deletions
diff --git a/src/video_core/texture_cache/image_view_base.cpp b/src/video_core/texture_cache/image_view_base.cpp index d134b6738..0c5f4450d 100644 --- a/src/video_core/texture_cache/image_view_base.cpp +++ b/src/video_core/texture_cache/image_view_base.cpp | |||
| @@ -45,4 +45,56 @@ ImageViewBase::ImageViewBase(const ImageInfo& info, const ImageViewInfo& view_in | |||
| 45 | 45 | ||
| 46 | ImageViewBase::ImageViewBase(const NullImageViewParams&) : image_id{NULL_IMAGE_ID} {} | 46 | ImageViewBase::ImageViewBase(const NullImageViewParams&) : image_id{NULL_IMAGE_ID} {} |
| 47 | 47 | ||
| 48 | bool ImageViewBase::SupportsAnisotropy() const noexcept { | ||
| 49 | const bool has_mips = range.extent.levels > 1; | ||
| 50 | const bool is_2d = type == ImageViewType::e2D || type == ImageViewType::e2DArray; | ||
| 51 | if (!has_mips || !is_2d) { | ||
| 52 | return false; | ||
| 53 | } | ||
| 54 | |||
| 55 | switch (format) { | ||
| 56 | case PixelFormat::R8_UNORM: | ||
| 57 | case PixelFormat::R8_SNORM: | ||
| 58 | case PixelFormat::R8_SINT: | ||
| 59 | case PixelFormat::R8_UINT: | ||
| 60 | case PixelFormat::BC4_UNORM: | ||
| 61 | case PixelFormat::BC4_SNORM: | ||
| 62 | case PixelFormat::BC5_UNORM: | ||
| 63 | case PixelFormat::BC5_SNORM: | ||
| 64 | case PixelFormat::R32G32_FLOAT: | ||
| 65 | case PixelFormat::R32G32_SINT: | ||
| 66 | case PixelFormat::R32_FLOAT: | ||
| 67 | case PixelFormat::R16_FLOAT: | ||
| 68 | case PixelFormat::R16_UNORM: | ||
| 69 | case PixelFormat::R16_SNORM: | ||
| 70 | case PixelFormat::R16_UINT: | ||
| 71 | case PixelFormat::R16_SINT: | ||
| 72 | case PixelFormat::R16G16_UNORM: | ||
| 73 | case PixelFormat::R16G16_FLOAT: | ||
| 74 | case PixelFormat::R16G16_UINT: | ||
| 75 | case PixelFormat::R16G16_SINT: | ||
| 76 | case PixelFormat::R16G16_SNORM: | ||
| 77 | case PixelFormat::R8G8_UNORM: | ||
| 78 | case PixelFormat::R8G8_SNORM: | ||
| 79 | case PixelFormat::R8G8_SINT: | ||
| 80 | case PixelFormat::R8G8_UINT: | ||
| 81 | case PixelFormat::R32G32_UINT: | ||
| 82 | case PixelFormat::R32_UINT: | ||
| 83 | case PixelFormat::R32_SINT: | ||
| 84 | case PixelFormat::G4R4_UNORM: | ||
| 85 | // Depth formats | ||
| 86 | case PixelFormat::D32_FLOAT: | ||
| 87 | case PixelFormat::D16_UNORM: | ||
| 88 | // Stencil formats | ||
| 89 | case PixelFormat::S8_UINT: | ||
| 90 | // DepthStencil formats | ||
| 91 | case PixelFormat::D24_UNORM_S8_UINT: | ||
| 92 | case PixelFormat::S8_UINT_D24_UNORM: | ||
| 93 | case PixelFormat::D32_FLOAT_S8_UINT: | ||
| 94 | return false; | ||
| 95 | default: | ||
| 96 | return true; | ||
| 97 | } | ||
| 98 | } | ||
| 99 | |||
| 48 | } // namespace VideoCommon | 100 | } // namespace VideoCommon |
diff --git a/src/video_core/texture_cache/image_view_base.h b/src/video_core/texture_cache/image_view_base.h index a25ae1d4a..87549ffff 100644 --- a/src/video_core/texture_cache/image_view_base.h +++ b/src/video_core/texture_cache/image_view_base.h | |||
| @@ -33,6 +33,8 @@ struct ImageViewBase { | |||
| 33 | return type == ImageViewType::Buffer; | 33 | return type == ImageViewType::Buffer; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | [[nodiscard]] bool SupportsAnisotropy() const noexcept; | ||
| 37 | |||
| 36 | ImageId image_id{}; | 38 | ImageId image_id{}; |
| 37 | GPUVAddr gpu_addr = 0; | 39 | GPUVAddr gpu_addr = 0; |
| 38 | PixelFormat format{}; | 40 | PixelFormat format{}; |
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index c7f7448e9..4027d860b 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -222,30 +222,50 @@ void TextureCache<P>::CheckFeedbackLoop(std::span<const ImageViewInOut> views) { | |||
| 222 | 222 | ||
| 223 | template <class P> | 223 | template <class P> |
| 224 | typename P::Sampler* TextureCache<P>::GetGraphicsSampler(u32 index) { | 224 | typename P::Sampler* TextureCache<P>::GetGraphicsSampler(u32 index) { |
| 225 | return &slot_samplers[GetGraphicsSamplerId(index)]; | ||
| 226 | } | ||
| 227 | |||
| 228 | template <class P> | ||
| 229 | typename P::Sampler* TextureCache<P>::GetComputeSampler(u32 index) { | ||
| 230 | return &slot_samplers[GetComputeSamplerId(index)]; | ||
| 231 | } | ||
| 232 | |||
| 233 | template <class P> | ||
| 234 | SamplerId TextureCache<P>::GetGraphicsSamplerId(u32 index) { | ||
| 225 | if (index > channel_state->graphics_sampler_table.Limit()) { | 235 | if (index > channel_state->graphics_sampler_table.Limit()) { |
| 226 | LOG_DEBUG(HW_GPU, "Invalid sampler index={}", index); | 236 | LOG_DEBUG(HW_GPU, "Invalid sampler index={}", index); |
| 227 | return &slot_samplers[NULL_SAMPLER_ID]; | 237 | return NULL_SAMPLER_ID; |
| 228 | } | 238 | } |
| 229 | const auto [descriptor, is_new] = channel_state->graphics_sampler_table.Read(index); | 239 | const auto [descriptor, is_new] = channel_state->graphics_sampler_table.Read(index); |
| 230 | SamplerId& id = channel_state->graphics_sampler_ids[index]; | 240 | SamplerId& id = channel_state->graphics_sampler_ids[index]; |
| 231 | if (is_new) { | 241 | if (is_new) { |
| 232 | id = FindSampler(descriptor); | 242 | id = FindSampler(descriptor); |
| 233 | } | 243 | } |
| 234 | return &slot_samplers[id]; | 244 | return id; |
| 235 | } | 245 | } |
| 236 | 246 | ||
| 237 | template <class P> | 247 | template <class P> |
| 238 | typename P::Sampler* TextureCache<P>::GetComputeSampler(u32 index) { | 248 | SamplerId TextureCache<P>::GetComputeSamplerId(u32 index) { |
| 239 | if (index > channel_state->compute_sampler_table.Limit()) { | 249 | if (index > channel_state->compute_sampler_table.Limit()) { |
| 240 | LOG_DEBUG(HW_GPU, "Invalid sampler index={}", index); | 250 | LOG_DEBUG(HW_GPU, "Invalid sampler index={}", index); |
| 241 | return &slot_samplers[NULL_SAMPLER_ID]; | 251 | return NULL_SAMPLER_ID; |
| 242 | } | 252 | } |
| 243 | const auto [descriptor, is_new] = channel_state->compute_sampler_table.Read(index); | 253 | const auto [descriptor, is_new] = channel_state->compute_sampler_table.Read(index); |
| 244 | SamplerId& id = channel_state->compute_sampler_ids[index]; | 254 | SamplerId& id = channel_state->compute_sampler_ids[index]; |
| 245 | if (is_new) { | 255 | if (is_new) { |
| 246 | id = FindSampler(descriptor); | 256 | id = FindSampler(descriptor); |
| 247 | } | 257 | } |
| 248 | return &slot_samplers[id]; | 258 | return id; |
| 259 | } | ||
| 260 | |||
| 261 | template <class P> | ||
| 262 | const typename P::Sampler& TextureCache<P>::GetSampler(SamplerId id) const noexcept { | ||
| 263 | return slot_samplers[id]; | ||
| 264 | } | ||
| 265 | |||
| 266 | template <class P> | ||
| 267 | typename P::Sampler& TextureCache<P>::GetSampler(SamplerId id) noexcept { | ||
| 268 | return slot_samplers[id]; | ||
| 249 | } | 269 | } |
| 250 | 270 | ||
| 251 | template <class P> | 271 | template <class P> |
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index 3bfa92154..d96ddea9d 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h | |||
| @@ -159,6 +159,18 @@ public: | |||
| 159 | /// Get the sampler from the compute descriptor table in the specified index | 159 | /// Get the sampler from the compute descriptor table in the specified index |
| 160 | Sampler* GetComputeSampler(u32 index); | 160 | Sampler* GetComputeSampler(u32 index); |
| 161 | 161 | ||
| 162 | /// Get the sampler id from the graphics descriptor table in the specified index | ||
| 163 | SamplerId GetGraphicsSamplerId(u32 index); | ||
| 164 | |||
| 165 | /// Get the sampler id from the compute descriptor table in the specified index | ||
| 166 | SamplerId GetComputeSamplerId(u32 index); | ||
| 167 | |||
| 168 | /// Return a constant reference to the given sampler id | ||
| 169 | [[nodiscard]] const Sampler& GetSampler(SamplerId id) const noexcept; | ||
| 170 | |||
| 171 | /// Return a reference to the given sampler id | ||
| 172 | [[nodiscard]] Sampler& GetSampler(SamplerId id) noexcept; | ||
| 173 | |||
| 162 | /// Refresh the state for graphics image view and sampler descriptors | 174 | /// Refresh the state for graphics image view and sampler descriptors |
| 163 | void SynchronizeGraphicsDescriptors(); | 175 | void SynchronizeGraphicsDescriptors(); |
| 164 | 176 | ||