From a8d2684929c7de696b00416e07ae0032c53887f3 Mon Sep 17 00:00:00 2001 From: psucien Date: Wed, 23 Oct 2024 23:11:01 +0200 Subject: [PATCH] hot-fix: proper calculation of image samples num --- src/video_core/amdgpu/resource.h | 7 +++++++ src/video_core/texture_cache/image_info.cpp | 1 + src/video_core/texture_cache/image_view.cpp | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/video_core/amdgpu/resource.h b/src/video_core/amdgpu/resource.h index 97df40a0..83be0b0a 100644 --- a/src/video_core/amdgpu/resource.h +++ b/src/video_core/amdgpu/resource.h @@ -261,6 +261,13 @@ struct Image { return last_level + 1; } + u32 NumSamples() const { + if (GetType() == ImageType::Color2DMsaa || GetType() == ImageType::Color2DMsaaArray) { + return 1u << last_level; + } + return 1; + } + ImageType GetType() const noexcept { return static_cast(type); } diff --git a/src/video_core/texture_cache/image_info.cpp b/src/video_core/texture_cache/image_info.cpp index efb74ffa..055753db 100644 --- a/src/video_core/texture_cache/image_info.cpp +++ b/src/video_core/texture_cache/image_info.cpp @@ -219,6 +219,7 @@ ImageInfo::ImageInfo(const AmdGpu::Image& image, const Shader::ImageResource& de pitch = image.Pitch(); resources.levels = image.NumLevels(); resources.layers = image.NumLayers(desc.is_array); + num_samples = image.NumSamples(); num_bits = NumBits(image.GetDataFmt()); usage.texture = true; diff --git a/src/video_core/texture_cache/image_view.cpp b/src/video_core/texture_cache/image_view.cpp index db811349..7dbf1230 100644 --- a/src/video_core/texture_cache/image_view.cpp +++ b/src/video_core/texture_cache/image_view.cpp @@ -80,7 +80,12 @@ ImageViewInfo::ImageViewInfo(const AmdGpu::Image& image, const Shader::ImageReso } range.base.level = image.base_level; range.base.layer = image.base_array; - range.extent.levels = image.last_level - image.base_level + 1; + if (image.GetType() == AmdGpu::ImageType::Color2DMsaa || + image.GetType() == AmdGpu::ImageType::Color2DMsaaArray) { + range.extent.levels = 1; + } else { + range.extent.levels = image.last_level - image.base_level + 1; + } range.extent.layers = image.last_array - image.base_array + 1; type = ConvertImageViewType(image.GetType());