1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 20:52:10 +01:00

[dxvk] Add method to query color attachment index from attachment index

This commit is contained in:
Philip Rebohle 2021-02-11 02:10:32 +01:00
parent 0956050db6
commit 436820d233
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 16 additions and 7 deletions

View File

@ -16,14 +16,14 @@ namespace dxvk {
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
if (m_renderTargets.color[i].view != nullptr) {
views[m_attachmentCount] = m_renderTargets.color[i].view->handle();
m_attachments[m_attachmentCount] = &m_renderTargets.color[i];
m_attachments[m_attachmentCount] = i;
m_attachmentCount += 1;
}
}
if (m_renderTargets.depth.view != nullptr) {
views[m_attachmentCount] = m_renderTargets.depth.view->handle();
m_attachments[m_attachmentCount] = &m_renderTargets.depth;
m_attachments[m_attachmentCount] = -1;
m_attachmentCount += 1;
}
@ -50,7 +50,7 @@ namespace dxvk {
int32_t DxvkFramebuffer::findAttachment(const Rc<DxvkImageView>& view) const {
for (uint32_t i = 0; i < m_attachmentCount; i++) {
if (m_attachments[i]->view == view)
if (getAttachment(i).view == view)
return int32_t(i);
}

View File

@ -159,6 +159,14 @@ namespace dxvk {
return m_attachmentCount;
}
/**
* \brief Queries color attachment index of a given attachment
* \returns The index, or -1 if the given attachment is the depth attachment
*/
const int32_t getColorAttachmentIndex(uint32_t id) const {
return m_attachments[id];
}
/**
* \brief Retrieves attachment by index
*
@ -166,7 +174,8 @@ namespace dxvk {
* \returns The framebuffer attachment
*/
const DxvkAttachment& getAttachment(uint32_t id) const {
return *m_attachments[id];
int32_t idx = getColorAttachmentIndex(id);
return idx < 0 ? m_renderTargets.depth : m_renderTargets.color[idx];
}
/**
@ -218,7 +227,7 @@ namespace dxvk {
const DxvkFramebufferSize m_renderSize;
uint32_t m_attachmentCount = 0;
std::array<const DxvkAttachment*, MaxNumRenderTargets + 1> m_attachments;
std::array<int32_t, MaxNumRenderTargets + 1> m_attachments;
VkFramebuffer m_handle = VK_NULL_HANDLE;