MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / GetOrCreateBindingSet

Method GetOrCreateBindingSet

src/engine/BindingCache.cpp:51–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51nvrhi::BindingSetHandle BindingCache::GetOrCreateBindingSet(const nvrhi::BindingSetDesc& desc, nvrhi::IBindingLayout* layout)
52{
53 size_t hash = 0;
54 nvrhi::hash_combine(hash, desc);
55 nvrhi::hash_combine(hash, layout);
56
57 m_Mutex.lock_shared();
58
59 nvrhi::BindingSetHandle result;
60 auto it = m_BindingSets.find(hash);
61 if (it != m_BindingSets.end())
62 result = it->second;
63
64 m_Mutex.unlock_shared();
65
66 if (!result)
67 {
68 m_Mutex.lock();
69
70 nvrhi::BindingSetHandle& entry = m_BindingSets[hash];
71 if (!entry)
72 {
73 result = m_Device->createBindingSet(desc, layout);
74 entry = result;
75 }
76 else
77 result = entry;
78
79 m_Mutex.unlock();
80 }
81
82 if (result)
83 {
84 assert(result->getDesc());
85 assert(*result->getDesc() == desc);
86 }
87
88 return result;
89}
90
91void BindingCache::Clear()
92{

Callers 2

BlitTextureMethod · 0.80
RenderMethod · 0.80

Calls 1

endMethod · 0.45

Tested by

no test coverage detected