mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-19 18:36:53 +02:00
renderer: simplify image view cache
This commit is contained in:
@@ -736,15 +736,10 @@ Image::~Image() {
|
||||
if (m_graphics == nullptr) {
|
||||
return;
|
||||
}
|
||||
{
|
||||
std::lock_guard lock(views.mutex);
|
||||
for (auto& cached: views.views) {
|
||||
if (cached.view != nullptr) {
|
||||
m_graphics->device.destroyImageView(cached.view, nullptr);
|
||||
cached.view = nullptr;
|
||||
}
|
||||
for (const auto& cached: views) {
|
||||
if (cached.view != nullptr) {
|
||||
m_graphics->device.destroyImageView(cached.view, nullptr);
|
||||
}
|
||||
views.views.clear();
|
||||
}
|
||||
if (backing.image != nullptr) {
|
||||
m_graphics->DeleteImage(backing);
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <compare>
|
||||
#include <limits>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <utility>
|
||||
@@ -27,14 +26,6 @@ struct CachedImageView {
|
||||
vk::ImageView view = nullptr;
|
||||
};
|
||||
|
||||
struct ImageViewCache {
|
||||
ImageViewCache() = default;
|
||||
KYTY_CLASS_NO_COPY(ImageViewCache);
|
||||
|
||||
std::mutex mutex;
|
||||
std::vector<CachedImageView> views;
|
||||
};
|
||||
|
||||
struct ImageUsage {
|
||||
bool texture = false;
|
||||
bool storage = false;
|
||||
@@ -150,7 +141,7 @@ public:
|
||||
|
||||
ImageInfo info;
|
||||
VulkanImage backing;
|
||||
ImageViewCache views;
|
||||
std::vector<CachedImageView> views;
|
||||
ImageUsage usage;
|
||||
ImageBinding binding;
|
||||
bool registered = false;
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "graphics/host_gpu/graphicContext.h"
|
||||
#include "graphics/host_gpu/renderer/image/image.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace Libs::Graphics {
|
||||
|
||||
namespace {
|
||||
@@ -357,8 +355,7 @@ vk::ImageView Image::FindView(const ImageViewInfo& view_info) {
|
||||
image.layers);
|
||||
}
|
||||
|
||||
std::lock_guard lock(views.mutex);
|
||||
for (const auto& cached: views.views) {
|
||||
for (const auto& cached: views) {
|
||||
if (cached.info == normalized) {
|
||||
return cached.view;
|
||||
}
|
||||
@@ -394,7 +391,7 @@ vk::ImageView Image::FindView(const ImageViewInfo& view_info) {
|
||||
view_info.level_count, view_info.base_layer, view_info.layer_count,
|
||||
static_cast<vk::ImageUsageFlags::MaskType>(view_info.usage));
|
||||
}
|
||||
views.views.push_back({normalized, view});
|
||||
views.push_back({normalized, view});
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
@@ -2772,7 +2772,7 @@ public:
|
||||
array != first && reinterpreted != nullptr &&
|
||||
reinterpreted != first && storage != nullptr &&
|
||||
storage != first && attachment == first &&
|
||||
color.views.views.size() == 7,
|
||||
color.views.size() == 7,
|
||||
"dynamic view identity omitted mapping, format, mip, layer, type, "
|
||||
"or storage usage");
|
||||
|
||||
@@ -2820,7 +2820,7 @@ public:
|
||||
depth_alias == depth_first && depth_array != nullptr &&
|
||||
depth_array != depth_first && depth_attachment != nullptr &&
|
||||
depth_attachment != depth_array &&
|
||||
depth.views.views.size() == 3,
|
||||
depth.views.size() == 3,
|
||||
"unified depth view cache lost sampled/attachment identity");
|
||||
|
||||
auto depth_stencil_info = depth_info;
|
||||
@@ -2841,10 +2841,10 @@ public:
|
||||
Require(name, "depth/stencil aspects",
|
||||
depth_only != nullptr && combined != nullptr &&
|
||||
depth_only != combined &&
|
||||
depth_stencil.views.views.size() == 2 &&
|
||||
depth_stencil.views.views[0].info.aspect ==
|
||||
depth_stencil.views.size() == 2 &&
|
||||
depth_stencil.views[0].info.aspect ==
|
||||
vk::ImageAspectFlagBits::eDepth &&
|
||||
depth_stencil.views.views[1].info.aspect ==
|
||||
depth_stencil.views[1].info.aspect ==
|
||||
(vk::ImageAspectFlagBits::eDepth |
|
||||
vk::ImageAspectFlagBits::eStencil),
|
||||
"explicit depth-only and combined aspects shared one image view");
|
||||
@@ -3833,7 +3833,7 @@ public:
|
||||
name, "dynamic views",
|
||||
first_view != nullptr && repeated_view == first_view &&
|
||||
mapped_view != nullptr && mapped_view != first_view &&
|
||||
image.views.views.size() == 2 && !image.usage.texture &&
|
||||
image.views.size() == 2 && !image.usage.texture &&
|
||||
!image.IsGpuModified() && !image.IsCpuDirty() &&
|
||||
!TextureCacheTestAccess::PendingDownload(texture_cache, first),
|
||||
"TextureCache::FindTexture did not preserve sampled view "
|
||||
@@ -8174,7 +8174,7 @@ public:
|
||||
const auto &sampled_depth_image =
|
||||
texture_cache.GetImage(sampled_depth_binding.image_id);
|
||||
const bool normalized_depth_view = std::ranges::any_of(
|
||||
sampled_depth_image.views.views, [&](const auto &cached) {
|
||||
sampled_depth_image.views, [&](const auto &cached) {
|
||||
return cached.view == sampled_depth_view &&
|
||||
cached.info.format == vk::Format::eD32Sfloat &&
|
||||
cached.info.aspect == vk::ImageAspectFlagBits::eDepth &&
|
||||
|
||||
Reference in New Issue
Block a user