MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / GetCache

Function GetCache

Source/Engine/Graphics/Shaders/GPUVertexLayout.cpp:47–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45 ConcurrentDictionary<VertexBufferLayouts, GPUVertexLayout*> VertexBufferCache;
46
47 GPUVertexLayout* GetCache(const VertexBufferLayouts& key, int32 count)
48 {
49 GPUVertexLayout* result;
50 if (!VertexBufferCache.TryGet(key, result))
51 {
52 GPUVertexLayout::Elements elements;
53 bool anyValid = false;
54 for (int32 slot = 0; slot < count; slot++)
55 {
56 if (key.Layouts[slot])
57 {
58 anyValid = true;
59 int32 start = elements.Count();
60 elements.Add(key.Layouts[slot]->GetElements());
61 for (int32 j = start; j < elements.Count(); j++)
62 elements.Get()[j].Slot = (byte)slot;
63 }
64 }
65 result = anyValid ? GPUVertexLayout::Get(elements, true) : nullptr;
66 if (!VertexBufferCache.Add(key, result))
67 {
68 // Other thread added the value
69 Delete(result);
70 bool found = VertexBufferCache.TryGet(key, result);
71 ASSERT(found);
72 }
73
74 }
75 return result;
76 }
77}
78
79String VertexElement::ToString() const

Callers 5

IsReadyMethod · 0.85
GetMethod · 0.85
LoadShaderCacheMethod · 0.85
HasContentLoadedMethod · 0.85
ApplySkyMethod · 0.85

Calls 6

DeleteFunction · 0.85
GetFunction · 0.50
TryGetMethod · 0.45
CountMethod · 0.45
AddMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected