mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Refactor render pass objects to not use reference counting
Like pipeline objects, we keep these around anyway so there's no reason to add ref count overhead. Also use a hash map to perform the lookup.
This commit is contained in:
parent
d01b6baf38
commit
13bc3df92f
@ -4,7 +4,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkFramebuffer::DxvkFramebuffer(
|
DxvkFramebuffer::DxvkFramebuffer(
|
||||||
const Rc<vk::DeviceFn>& vkd,
|
const Rc<vk::DeviceFn>& vkd,
|
||||||
const Rc<DxvkRenderPass>& renderPass,
|
DxvkRenderPass* renderPass,
|
||||||
const DxvkRenderTargets& renderTargets,
|
const DxvkRenderTargets& renderTargets,
|
||||||
const DxvkFramebufferSize& defaultSize)
|
const DxvkFramebufferSize& defaultSize)
|
||||||
: m_vkd (vkd),
|
: m_vkd (vkd),
|
||||||
|
@ -56,7 +56,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
DxvkFramebuffer(
|
DxvkFramebuffer(
|
||||||
const Rc<vk::DeviceFn>& vkd,
|
const Rc<vk::DeviceFn>& vkd,
|
||||||
const Rc<DxvkRenderPass>& renderPass,
|
DxvkRenderPass* renderPass,
|
||||||
const DxvkRenderTargets& renderTargets,
|
const DxvkRenderTargets& renderTargets,
|
||||||
const DxvkFramebufferSize& defaultSize);
|
const DxvkFramebufferSize& defaultSize);
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ namespace dxvk {
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
const Rc<vk::DeviceFn> m_vkd;
|
const Rc<vk::DeviceFn> m_vkd;
|
||||||
const Rc<DxvkRenderPass> m_renderPass;
|
DxvkRenderPass* m_renderPass;
|
||||||
const DxvkRenderTargets m_renderTargets;
|
const DxvkRenderTargets m_renderTargets;
|
||||||
const DxvkFramebufferSize m_renderSize;
|
const DxvkFramebufferSize m_renderSize;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
bool DxvkRenderPassFormat::matches(const DxvkRenderPassFormat& fmt) const {
|
bool DxvkRenderPassFormat::eq(const DxvkRenderPassFormat& fmt) const {
|
||||||
bool eq = sampleCount == fmt.sampleCount;
|
bool eq = sampleCount == fmt.sampleCount;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < MaxNumRenderTargets && eq; i++) {
|
for (uint32_t i = 0; i < MaxNumRenderTargets && eq; i++) {
|
||||||
@ -17,6 +17,21 @@ namespace dxvk {
|
|||||||
|
|
||||||
return eq;
|
return eq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
size_t DxvkRenderPassFormat::hash() const {
|
||||||
|
DxvkHashState state;
|
||||||
|
state.add(uint32_t(sampleCount));
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
|
||||||
|
state.add(uint32_t(color[i].format));
|
||||||
|
state.add(uint32_t(color[i].layout));
|
||||||
|
}
|
||||||
|
|
||||||
|
state.add(uint32_t(depth.format));
|
||||||
|
state.add(uint32_t(depth.layout));
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DxvkRenderPass::DxvkRenderPass(
|
DxvkRenderPass::DxvkRenderPass(
|
||||||
@ -39,7 +54,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
bool DxvkRenderPass::hasCompatibleFormat(const DxvkRenderPassFormat& fmt) const {
|
bool DxvkRenderPass::hasCompatibleFormat(const DxvkRenderPassFormat& fmt) const {
|
||||||
return m_format.matches(fmt);
|
return m_format.eq(fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -216,17 +231,17 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Rc<DxvkRenderPass> DxvkRenderPassPool::getRenderPass(const DxvkRenderPassFormat& fmt) {
|
DxvkRenderPass* DxvkRenderPassPool::getRenderPass(const DxvkRenderPassFormat& fmt) {
|
||||||
std::lock_guard<std::mutex> lock(m_mutex);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
|
|
||||||
|
auto entry = m_renderPasses.find(fmt);
|
||||||
|
if (entry != m_renderPasses.end())
|
||||||
|
return &entry->second;
|
||||||
|
|
||||||
for (const auto& r : m_renderPasses) {
|
auto result = m_renderPasses.emplace(std::piecewise_construct,
|
||||||
if (r->hasCompatibleFormat(fmt))
|
std::tuple(fmt),
|
||||||
return r;
|
std::tuple(m_vkd, fmt));
|
||||||
}
|
return &result.first->second;
|
||||||
|
|
||||||
Rc<DxvkRenderPass> rp = new DxvkRenderPass(m_vkd, fmt);
|
|
||||||
m_renderPasses.push_back(rp);
|
|
||||||
return rp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -32,7 +32,9 @@ namespace dxvk {
|
|||||||
DxvkAttachmentFormat depth;
|
DxvkAttachmentFormat depth;
|
||||||
DxvkAttachmentFormat color[MaxNumRenderTargets];
|
DxvkAttachmentFormat color[MaxNumRenderTargets];
|
||||||
|
|
||||||
bool matches(const DxvkRenderPassFormat& fmt) const;
|
bool eq(const DxvkRenderPassFormat& fmt) const;
|
||||||
|
|
||||||
|
size_t hash() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -101,7 +103,7 @@ namespace dxvk {
|
|||||||
* render passes which share the same format but
|
* render passes which share the same format but
|
||||||
* may differ in their attachment operations.
|
* may differ in their attachment operations.
|
||||||
*/
|
*/
|
||||||
class DxvkRenderPass : public RcObject {
|
class DxvkRenderPass {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -211,7 +213,7 @@ namespace dxvk {
|
|||||||
* \param [in] fmt The render pass format
|
* \param [in] fmt The render pass format
|
||||||
* \returns Matching render pass object
|
* \returns Matching render pass object
|
||||||
*/
|
*/
|
||||||
Rc<DxvkRenderPass> getRenderPass(
|
DxvkRenderPass* getRenderPass(
|
||||||
const DxvkRenderPassFormat& fmt);
|
const DxvkRenderPassFormat& fmt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -219,7 +221,10 @@ namespace dxvk {
|
|||||||
const Rc<vk::DeviceFn> m_vkd;
|
const Rc<vk::DeviceFn> m_vkd;
|
||||||
|
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
std::vector<Rc<DxvkRenderPass>> m_renderPasses;
|
std::unordered_map<
|
||||||
|
DxvkRenderPassFormat,
|
||||||
|
DxvkRenderPass,
|
||||||
|
DxvkHash, DxvkEq> m_renderPasses;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ namespace dxvk {
|
|||||||
for (auto e = entries.first; e != entries.second; e++) {
|
for (auto e = entries.first; e != entries.second; e++) {
|
||||||
const DxvkStateCacheEntry& entry = m_entries[e->second];
|
const DxvkStateCacheEntry& entry = m_entries[e->second];
|
||||||
|
|
||||||
if (entry.format.matches(format) && entry.gpState == state)
|
if (entry.format.eq(format) && entry.gpState == state)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user