mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05:52:11 +01:00
[dxvk] Introduce DxvkFramebufferKey
Can be used to cache framebuffer objects.
This commit is contained in:
parent
2527ea45b9
commit
a987b729a7
@ -70,6 +70,24 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
DxvkFramebufferKey DxvkFramebufferInfo::key() const {
|
||||
DxvkFramebufferKey result = { };
|
||||
|
||||
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
|
||||
if (m_renderTargets.color[i].view != nullptr)
|
||||
result.colorViews[i] = m_renderTargets.color[i].view->cookie();
|
||||
}
|
||||
|
||||
if (m_renderTargets.depth.view != nullptr)
|
||||
result.depthView = m_renderTargets.depth.view->cookie();
|
||||
|
||||
if (result.renderPass)
|
||||
result.renderPass = m_renderPass->getDefaultHandle();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
DxvkRenderPassFormat DxvkFramebufferInfo::getRenderPassFormat(const DxvkRenderTargets& renderTargets) {
|
||||
DxvkRenderPassFormat format;
|
||||
|
||||
@ -128,7 +146,7 @@ namespace dxvk {
|
||||
DxvkFramebuffer::DxvkFramebuffer(
|
||||
const Rc<vk::DeviceFn>& vkd,
|
||||
const DxvkFramebufferInfo& info)
|
||||
: m_vkd (vkd) {
|
||||
: m_vkd(vkd), m_key(info.key()) {
|
||||
std::array<VkImageView, MaxNumRenderTargets + 1> views;
|
||||
uint32_t attachmentCount = 0;
|
||||
|
||||
|
@ -17,7 +17,7 @@ namespace dxvk {
|
||||
uint32_t height;
|
||||
uint32_t layers;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \brief Framebuffer attachment
|
||||
@ -52,6 +52,33 @@ namespace dxvk {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Framebuffer key
|
||||
*/
|
||||
struct DxvkFramebufferKey {
|
||||
uint64_t colorViews[MaxNumRenderTargets];
|
||||
uint64_t depthView;
|
||||
VkRenderPass renderPass;
|
||||
|
||||
size_t hash() const {
|
||||
DxvkHashState state;
|
||||
state.add(depthView);
|
||||
for (uint32_t i = 0; i < MaxNumRenderTargets; i++)
|
||||
state.add(colorViews[i]);
|
||||
state.add(reinterpret_cast<uint64_t>(renderPass));
|
||||
return state;
|
||||
}
|
||||
|
||||
bool eq(const DxvkFramebufferKey& other) const {
|
||||
bool eq = depthView == other.depthView
|
||||
&& renderPass == other.renderPass;
|
||||
for (uint32_t i = 0; i < MaxNumRenderTargets; i++)
|
||||
eq &= colorViews[i] == other.colorViews[i];
|
||||
return eq;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \brief Framebuffer info
|
||||
*
|
||||
@ -192,6 +219,12 @@ namespace dxvk {
|
||||
*/
|
||||
bool isWritable(uint32_t attachmentIndex, VkImageAspectFlags aspects) const;
|
||||
|
||||
/**
|
||||
* \brief Generates framebuffer key
|
||||
* \returns Framebuffer key
|
||||
*/
|
||||
DxvkFramebufferKey key() const;
|
||||
|
||||
/**
|
||||
* \brief Generatess render pass format
|
||||
*
|
||||
@ -247,11 +280,19 @@ namespace dxvk {
|
||||
VkFramebuffer handle() const {
|
||||
return m_handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Framebuffer key
|
||||
*/
|
||||
const DxvkFramebufferKey& key() const {
|
||||
return m_key;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Rc<vk::DeviceFn> m_vkd;
|
||||
VkFramebuffer m_handle;
|
||||
Rc<vk::DeviceFn> m_vkd;
|
||||
VkFramebuffer m_handle;
|
||||
DxvkFramebufferKey m_key;
|
||||
|
||||
};
|
||||
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
std::atomic<uint64_t> DxvkImageView::s_cookie = { 0ull };
|
||||
|
||||
|
||||
DxvkImage::DxvkImage(
|
||||
const Rc<vk::DeviceFn>& vkd,
|
||||
const DxvkImageCreateInfo& createInfo,
|
||||
@ -135,7 +138,7 @@ namespace dxvk {
|
||||
const Rc<vk::DeviceFn>& vkd,
|
||||
const Rc<DxvkImage>& image,
|
||||
const DxvkImageViewCreateInfo& info)
|
||||
: m_vkd(vkd), m_image(image), m_info(info) {
|
||||
: m_vkd(vkd), m_image(image), m_info(info), m_cookie(++s_cookie) {
|
||||
for (uint32_t i = 0; i < ViewCount; i++)
|
||||
m_views[i] = VK_NULL_HANDLE;
|
||||
|
||||
|
@ -418,6 +418,18 @@ namespace dxvk {
|
||||
return imageFormatInfo(m_info.format);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Unique object identifier
|
||||
*
|
||||
* Can be used to identify an object even when
|
||||
* the lifetime of the object is unknown, and
|
||||
* without referencing the actual object.
|
||||
* \returns Unique identifier
|
||||
*/
|
||||
uint64_t cookie() const {
|
||||
return m_cookie;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Mip level size
|
||||
*
|
||||
@ -535,6 +547,10 @@ namespace dxvk {
|
||||
DxvkImageViewCreateInfo m_info;
|
||||
VkImageView m_views[ViewCount];
|
||||
|
||||
uint64_t m_cookie;
|
||||
|
||||
static std::atomic<uint64_t> s_cookie;
|
||||
|
||||
void createView(VkImageViewType type, uint32_t numLayers);
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user