mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-14 04:29:15 +01:00
[dxvk] Store various image properties inside the view
This commit is contained in:
parent
4bd97f44c8
commit
77216867cc
@ -234,23 +234,30 @@ namespace dxvk {
|
||||
|
||||
// Self-assignment is possible here if we
|
||||
// just update the image properties
|
||||
bool invalidateViews = false;
|
||||
m_storage = std::move(resource);
|
||||
|
||||
if (m_storage != old) {
|
||||
m_imageInfo = m_storage->getImageInfo();
|
||||
m_version += 1u;
|
||||
|
||||
if (unlikely(m_info.debugName))
|
||||
updateDebugName();
|
||||
|
||||
invalidateViews = true;
|
||||
}
|
||||
|
||||
if ((m_info.access | usageInfo.access) != m_info.access)
|
||||
invalidateViews = true;
|
||||
|
||||
m_info.flags |= usageInfo.flags;
|
||||
m_info.usage |= usageInfo.usage;
|
||||
m_info.stages |= usageInfo.stages;
|
||||
m_info.access |= usageInfo.access;
|
||||
|
||||
if (usageInfo.layout != VK_IMAGE_LAYOUT_UNDEFINED)
|
||||
if (usageInfo.layout != VK_IMAGE_LAYOUT_UNDEFINED) {
|
||||
m_info.layout = usageInfo.layout;
|
||||
invalidateViews = true;
|
||||
}
|
||||
|
||||
if (usageInfo.colorSpace != VK_COLOR_SPACE_MAX_ENUM_KHR)
|
||||
m_info.colorSpace = usageInfo.colorSpace;
|
||||
@ -266,6 +273,10 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
m_stableAddress |= usageInfo.stableGpuAddress;
|
||||
|
||||
if (invalidateViews)
|
||||
m_version += 1u;
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
@ -423,8 +434,9 @@ namespace dxvk {
|
||||
DxvkImageView::DxvkImageView(
|
||||
DxvkImage* image,
|
||||
const DxvkImageViewKey& key)
|
||||
: m_image(image), m_key(key) {
|
||||
|
||||
: m_image (image),
|
||||
m_key (key) {
|
||||
updateProperties();
|
||||
}
|
||||
|
||||
|
||||
@ -509,6 +521,9 @@ namespace dxvk {
|
||||
|
||||
|
||||
void DxvkImageView::updateViews() {
|
||||
// Latch updated image properties
|
||||
updateProperties();
|
||||
|
||||
// Update all views that are not currently null
|
||||
for (uint32_t i = 0; i < m_views.size(); i++) {
|
||||
if (m_views[i])
|
||||
@ -517,5 +532,12 @@ namespace dxvk {
|
||||
|
||||
m_version = m_image->m_version;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DxvkImageView::updateProperties() {
|
||||
m_properties.layout = m_image->info().layout;
|
||||
m_properties.samples = m_image->info().sampleCount;
|
||||
m_properties.layout = m_image->info().layout;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -104,6 +104,18 @@ namespace dxvk {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Image properties stored in the view
|
||||
*
|
||||
* Used to reduce some pointer chasing.
|
||||
*/
|
||||
struct DxvkImageViewImageProperties {
|
||||
VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
VkSampleCountFlagBits samples = VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM;
|
||||
VkAccessFlags access = 0u;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Virtual image view
|
||||
*
|
||||
@ -272,6 +284,30 @@ namespace dxvk {
|
||||
view->imageSubresources());
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Queries the default image layout
|
||||
*
|
||||
* Used when binding the view as a descriptor.
|
||||
* \returns Default image layout
|
||||
*/
|
||||
VkImageLayout defaultLayout() const {
|
||||
return m_properties.layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Checks whether the image is multisampled
|
||||
* \returns \c true if the image is multisampled
|
||||
*/
|
||||
bool isMultisampled() const {
|
||||
return m_properties.samples > VK_SAMPLE_COUNT_1_BIT;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Checks whether the image has graphics stores
|
||||
* \returns \c true if the image has graphics pipeline stores
|
||||
*/
|
||||
bool hasGfxStores() const;
|
||||
|
||||
private:
|
||||
|
||||
DxvkImage* m_image = nullptr;
|
||||
@ -279,12 +315,16 @@ namespace dxvk {
|
||||
|
||||
uint32_t m_version = 0u;
|
||||
|
||||
DxvkImageViewImageProperties m_properties = { };
|
||||
|
||||
std::array<VkImageView, ViewCount> m_views = { };
|
||||
|
||||
VkImageView createView(VkImageViewType type) const;
|
||||
|
||||
void updateViews();
|
||||
|
||||
void updateProperties();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -760,4 +800,10 @@ namespace dxvk {
|
||||
return m_views[viewType];
|
||||
}
|
||||
|
||||
|
||||
inline bool DxvkImageView::hasGfxStores() const {
|
||||
return (m_properties.access & VK_ACCESS_SHADER_WRITE_BIT)
|
||||
&& (m_image->hasGfxStores());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user