| 49 | } |
| 50 | |
| 51 | nvrhi::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 | |
| 91 | void BindingCache::Clear() |
| 92 | { |
no test coverage detected