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

[dxvk] Improve internal framebuffer APIs

Removes an unnecessary dynamic memory allocation in favour
of a stack-allocated array.
This commit is contained in:
Philip Rebohle 2018-02-07 16:46:39 +01:00
parent ad6c45d6b1
commit 7f409f446a
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 12 additions and 9 deletions

View File

@ -33,18 +33,18 @@ namespace dxvk {
} }
std::vector<VkImageView> DxvkRenderTargets::getAttachments() const { uint32_t DxvkRenderTargets::getAttachments(VkImageView* viewHandles) const {
std::vector<VkImageView> result; uint32_t numViews = 0;
if (m_depthTarget.view != nullptr) if (m_depthTarget.view != nullptr)
result.push_back(m_depthTarget.view->handle()); viewHandles[numViews++] = m_depthTarget.view->handle();
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) { for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
if (m_colorTargets.at(i).view != nullptr) if (m_colorTargets.at(i).view != nullptr)
result.push_back(m_colorTargets.at(i).view->handle()); viewHandles[numViews++] = m_colorTargets.at(i).view->handle();
} }
return result; return numViews;
} }
@ -87,14 +87,15 @@ namespace dxvk {
m_renderPass (renderPass), m_renderPass (renderPass),
m_renderTargets (renderTargets), m_renderTargets (renderTargets),
m_framebufferSize (renderTargets.getImageSize()) { m_framebufferSize (renderTargets.getImageSize()) {
auto views = renderTargets.getAttachments(); std::array<VkImageView, MaxNumRenderTargets + 1> views;
uint32_t viewCount = renderTargets.getAttachments(views.data());
VkFramebufferCreateInfo info; VkFramebufferCreateInfo info;
info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
info.pNext = nullptr; info.pNext = nullptr;
info.flags = 0; info.flags = 0;
info.renderPass = renderPass->handle(); info.renderPass = renderPass->handle();
info.attachmentCount = views.size(); info.attachmentCount = viewCount;
info.pAttachments = views.data(); info.pAttachments = views.data();
info.width = m_framebufferSize.width; info.width = m_framebufferSize.width;
info.height = m_framebufferSize.height; info.height = m_framebufferSize.height;

View File

@ -95,9 +95,11 @@ namespace dxvk {
/** /**
* \brief Creates attachment list * \brief Creates attachment list
* \returns Framebuffer attachment list *
* \param [out] viewHandles Attachment handles
* \returns Framebuffer attachment count
*/ */
std::vector<VkImageView> getAttachments() const; uint32_t getAttachments(VkImageView* viewHandles) const;
/** /**
* \brief Framebuffer size * \brief Framebuffer size