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