mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-13 19:29:14 +01:00
[dxvk] Register image views with the parent image
Needed for image renaming.
This commit is contained in:
parent
8770a14743
commit
2c457e496a
@ -125,11 +125,30 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void DxvkImage::addView(DxvkImageView* view) {
|
||||
m_viewList.push_back(view);
|
||||
}
|
||||
|
||||
|
||||
void DxvkImage::removeView(DxvkImageView* view) {
|
||||
for (size_t i = 0; i < m_viewList.size(); i++) {
|
||||
if (m_viewList[i] == view) {
|
||||
m_viewList[i] = m_viewList.back();
|
||||
m_viewList.pop_back();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DxvkImageView::DxvkImageView(
|
||||
const Rc<vk::DeviceFn>& vkd,
|
||||
const Rc<DxvkImage>& image,
|
||||
const DxvkImageViewCreateInfo& info)
|
||||
: m_vkd(vkd), m_image(image), m_info(info) {
|
||||
std::lock_guard lock(m_image->m_viewLock);
|
||||
m_image->addView(this);
|
||||
|
||||
createViews();
|
||||
}
|
||||
|
||||
@ -137,6 +156,9 @@ namespace dxvk {
|
||||
DxvkImageView::~DxvkImageView() {
|
||||
for (uint32_t i = 0; i < ViewCount; i++)
|
||||
m_vkd->vkDestroyImageView(m_vkd->device(), m_views[i], nullptr);
|
||||
|
||||
std::lock_guard lock(m_image->m_viewLock);
|
||||
m_image->removeView(this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include "dxvk_util.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
class DxvkImageView;
|
||||
|
||||
/**
|
||||
* \brief Image create info
|
||||
@ -104,7 +106,7 @@ namespace dxvk {
|
||||
* memory type and if created with the linear tiling option.
|
||||
*/
|
||||
class DxvkImage : public DxvkResource {
|
||||
|
||||
friend class DxvkImageView;
|
||||
public:
|
||||
|
||||
DxvkImage(
|
||||
@ -283,6 +285,12 @@ namespace dxvk {
|
||||
|
||||
small_vector<VkFormat, 4> m_viewFormats;
|
||||
|
||||
sync::Spinlock m_viewLock;
|
||||
small_vector<DxvkImageView*, 4> m_viewList;
|
||||
|
||||
void addView(DxvkImageView* view);
|
||||
void removeView(DxvkImageView* view);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -290,6 +298,7 @@ namespace dxvk {
|
||||
* \brief DXVK image view
|
||||
*/
|
||||
class DxvkImageView : public DxvkResource {
|
||||
friend class DxvkImage;
|
||||
constexpr static uint32_t ViewCount = VK_IMAGE_VIEW_TYPE_CUBE_ARRAY + 1;
|
||||
public:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user