diff --git a/src/video_core/texture_cache/image_view.cpp b/src/video_core/texture_cache/image_view.cpp index bb2d9053..e30c1264 100644 --- a/src/video_core/texture_cache/image_view.cpp +++ b/src/video_core/texture_cache/image_view.cpp @@ -114,11 +114,11 @@ ImageViewInfo::ImageViewInfo(const AmdGpu::Liverpool::DepthBuffer& depth_buffer, } ImageView::ImageView(const Vulkan::Instance& instance, const ImageViewInfo& info_, Image& image, - ImageId image_id_, std::optional usage_override /*= {}*/) + ImageId image_id_) : image_id{image_id_}, info{info_} { - vk::ImageViewUsageCreateInfo usage_ci{}; - if (usage_override) { - usage_ci.usage = usage_override.value(); + vk::ImageViewUsageCreateInfo usage_ci{.usage = image.usage}; + if (!info.is_storage) { + usage_ci.usage &= ~vk::ImageUsageFlagBits::eStorage; } // When sampling D32 texture from shader, the T# specifies R32 Float format so adjust it. vk::Format format = info.format; @@ -134,7 +134,7 @@ ImageView::ImageView(const Vulkan::Instance& instance, const ImageViewInfo& info } const vk::ImageViewCreateInfo image_view_ci = { - .pNext = usage_override ? &usage_ci : nullptr, + .pNext = &usage_ci, .image = image.image, .viewType = info.type, .format = instance.GetSupportedFormat(format), diff --git a/src/video_core/texture_cache/image_view.h b/src/video_core/texture_cache/image_view.h index fbc62db3..7d53590d 100644 --- a/src/video_core/texture_cache/image_view.h +++ b/src/video_core/texture_cache/image_view.h @@ -8,8 +8,6 @@ #include "video_core/renderer_vulkan/vk_common.h" #include "video_core/texture_cache/types.h" -#include - namespace Vulkan { class Instance; class Scheduler; @@ -28,7 +26,7 @@ struct ImageViewInfo { vk::Format format = vk::Format::eR8G8B8A8Unorm; SubresourceRange range; vk::ComponentMapping mapping{}; - bool is_storage; + bool is_storage = false; auto operator<=>(const ImageViewInfo&) const = default; }; @@ -38,8 +36,8 @@ struct Image; constexpr Common::SlotId NULL_IMAGE_VIEW_ID{0}; struct ImageView { - explicit ImageView(const Vulkan::Instance& instance, const ImageViewInfo& info, Image& image, - ImageId image_id, std::optional usage_override = {}); + ImageView(const Vulkan::Instance& instance, const ImageViewInfo& info, Image& image, + ImageId image_id); ~ImageView(); ImageView(const ImageView&) = delete; diff --git a/src/video_core/texture_cache/texture_cache.cpp b/src/video_core/texture_cache/texture_cache.cpp index 37bb5da1..c4548a79 100644 --- a/src/video_core/texture_cache/texture_cache.cpp +++ b/src/video_core/texture_cache/texture_cache.cpp @@ -243,16 +243,7 @@ ImageView& TextureCache::RegisterImageView(ImageId image_id, const ImageViewInfo return slot_image_views[view_id]; } - // All tiled images are created with storage usage flag. This makes set of formats (e.g. sRGB) - // impossible to use. However, during view creation, if an image isn't used as storage we can - // temporary remove its storage bit. - std::optional usage_override; - if (!image.info.usage.storage) { - usage_override = image.usage & ~vk::ImageUsageFlagBits::eStorage; - } - - const ImageViewId view_id = - slot_image_views.insert(instance, view_info, image, image_id, usage_override); + const ImageViewId view_id = slot_image_views.insert(instance, view_info, image, image_id); image.image_view_infos.emplace_back(view_info); image.image_view_ids.emplace_back(view_id); return slot_image_views[view_id];