1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-11-29 19:24:10 +01:00

[dxvk] Remove image renaming

Broken by design, has to be implemented by client APIs instead.
This commit is contained in:
Philip Rebohle 2020-01-23 22:19:59 +01:00
parent 0b3f9718c9
commit 81c3daa3d0
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
5 changed files with 6 additions and 175 deletions

View File

@ -752,14 +752,6 @@ namespace dxvk {
m_device->presentImage(m_presenter,
cSync.present, &m_presentStatus);
// Shift back buffers so that m_backBuffers[BackBufferCount]
// will contain the image that we just presented
for (uint32_t i = m_backBuffers.size(); i > 1; i--) {
ctx->swapImages(
m_backBuffers[i - 1]->GetCommonTexture()->GetImage(),
m_backBuffers[i - 2]->GetCommonTexture()->GetImage());
}
});
m_parent->FlushCsChunk();

View File

@ -1800,30 +1800,6 @@ namespace dxvk {
}
void DxvkContext::swapImages(
const Rc<DxvkImage>& image1,
const Rc<DxvkImage>& image2) {
Rc<DxvkImageViewDump> dump = new DxvkImageViewDump(m_device->vkd());
image1->swap(image2, dump);
// Usage flags are required to be identical
VkImageUsageFlags usage = image1->info().usage;
if (usage & (VK_IMAGE_USAGE_SAMPLED_BIT
| VK_IMAGE_USAGE_STORAGE_BIT)) {
m_flags.set(
DxvkContextFlag::GpDirtyResources,
DxvkContextFlag::CpDirtyResources);
}
if (usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
| VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT))
this->spillRenderPass();
m_cmd->trackResource<DxvkAccess::None>(dump);
}
void DxvkContext::transformImage(
const Rc<DxvkImage>& dstImage,
const VkImageSubresourceRange& dstSubresources,

View File

@ -708,21 +708,6 @@ namespace dxvk {
VkResolveModeFlagBitsKHR depthMode,
VkResolveModeFlagBitsKHR stencilMode);
/**
* \brief Swaps two images
*
* Exchanges the image handles and backing storage
* of the two images, and recreates all the views.
* Note that the two images must have been created
* with identical properties, including the memory
* properties.
* \param [in] image1 The first image
* \param [in] image2 The second image
*/
void swapImages(
const Rc<DxvkImage>& image1,
const Rc<DxvkImage>& image2);
/**
* \brief Transforms image subresource layouts
*

View File

@ -125,66 +125,11 @@ namespace dxvk {
}
void DxvkImage::swap(const Rc<DxvkImage>& next, const Rc<DxvkImageViewDump>& dump) {
// Technically this could deadlock if two threads
// call this method, but that's undefined behaviour
// anyway so let's not care about it too much.
std::lock_guard lock1(this->m_viewLock);
std::lock_guard lock2(next->m_viewLock);
std::swap(this->m_image, next->m_image);
this->recreateViews(dump);
next->recreateViews(dump);
}
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;
}
}
}
void DxvkImage::recreateViews(const Rc<DxvkImageViewDump>& dump) {
for (size_t i = 0; i < m_viewList.size(); i++) {
m_viewList[i]->discardViews(dump);
m_viewList[i]->createViews();
}
}
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();
}
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);
}
void DxvkImageView::createViews() {
for (uint32_t i = 0; i < ViewCount; i++)
m_views[i] = VK_NULL_HANDLE;
@ -227,18 +172,14 @@ namespace dxvk {
throw DxvkError(str::format("DxvkImageView: Invalid view type: ", m_info.type));
}
}
void DxvkImageView::discardViews(const Rc<DxvkImageViewDump>& dump) {
for (uint32_t i = 0; i < ViewCount; i++) {
if (m_views[i]) {
dump->addView(m_views[i]);
m_views[i] = VK_NULL_HANDLE;
}
}
}
DxvkImageView::~DxvkImageView() {
for (uint32_t i = 0; i < ViewCount; i++)
m_vkd->vkDestroyImageView(m_vkd->device(), m_views[i], nullptr);
}
void DxvkImageView::createView(VkImageViewType type, uint32_t numLayers) {
VkImageSubresourceRange subresourceRange;
subresourceRange.aspectMask = m_info.aspect;
@ -293,22 +234,5 @@ namespace dxvk {
"\n Tiling: ", m_image->info().tiling));
}
}
DxvkImageViewDump::DxvkImageViewDump(const Rc<vk::DeviceFn>& vkd)
: m_vkd(vkd) {
}
DxvkImageViewDump::~DxvkImageViewDump() {
for (auto view : m_views)
m_vkd->vkDestroyImageView(m_vkd->device(), view, nullptr);
}
void DxvkImageViewDump::addView(VkImageView view) {
m_views.push_back(view);
}
}

View File

@ -9,7 +9,6 @@
namespace dxvk {
class DxvkImageView;
class DxvkImageViewDump;
/**
* \brief Image create info
@ -285,16 +284,6 @@ namespace dxvk {
VkDeviceSize memSize() const {
return m_image.memory.length();
}
/**
* \brief Swaps the image with another
*
* \param [in] next The other image
* \param [in] dump Image view dump
*/
void swap(
const Rc<DxvkImage>& next,
const Rc<DxvkImageViewDump>& dump);
private:
@ -305,14 +294,6 @@ 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);
void recreateViews(const Rc<DxvkImageViewDump>& dump);
};
@ -492,35 +473,8 @@ namespace dxvk {
DxvkImageViewCreateInfo m_info;
VkImageView m_views[ViewCount];
void createViews();
void createView(VkImageViewType type, uint32_t numLayers);
void discardViews(const Rc<DxvkImageViewDump>& dump);
};
/**
* \brief Image view dump
*
* Takes orphaned image view objects and destroys
* them when they are no longer needed.
*/
class DxvkImageViewDump : public DxvkResource {
public:
DxvkImageViewDump(const Rc<vk::DeviceFn>& vkd);
~DxvkImageViewDump();
void addView(VkImageView view);
private:
Rc<vk::DeviceFn> m_vkd;
std::vector<VkImageView> m_views;
};
}