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

Method Get

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

Source from the content-addressed store, hash-verified

150}
151
152GPUVertexLayout* GPUVertexLayout::Get(const Elements& elements, bool explicitOffsets)
153{
154 // Hash input layout
155 uint32 hash = explicitOffsets ? 131 : 0;
156 for (const VertexElement& element : elements)
157 {
158 CombineHash(hash, GetHash(element));
159 }
160
161 // Lookup existing cache
162 GPUVertexLayout* result;
163 if (!LayoutCache.TryGet(hash, result))
164 {
165 result = GPUDevice::Instance->CreateVertexLayout(elements, explicitOffsets);
166 if (!result)
167 {
168#if GPU_ENABLE_ASSERTION_LOW_LAYERS
169 for (auto& e : elements)
170 LOG(Error, " {}", e.ToString());
171#endif
172 LOG(Error, "Failed to create vertex layout");
173 return nullptr;
174 }
175 if (!LayoutCache.Add(hash, result))
176 {
177 // Other thread added the value
178 Delete(result);
179 bool found = LayoutCache.TryGet(hash, result);
180 ASSERT(found);
181 }
182 }
183
184 return result;
185}
186
187GPUVertexLayout* GPUVertexLayout::Get(const Span<GPUBuffer*>& vertexBuffers)
188{

Callers 15

runMethod · 0.45
UploadMipMapAsyncMethod · 0.45
RunMethod · 0.45
TextureData.hFile · 0.45
GetPixelsMethod · 0.45
CopyMethod · 0.45
GetTextureDataMethod · 0.45
GetTextureMipDataMethod · 0.45
SetPixelsMethod · 0.45
initMethod · 0.45
GenerateMipMethod · 0.45
FromTextureDataMethod · 0.45

Calls 10

CombineHashFunction · 0.85
DeleteFunction · 0.85
GetCacheFunction · 0.85
GetVertexLayoutMethod · 0.80
GetHashFunction · 0.70
TryGetMethod · 0.45
CreateVertexLayoutMethod · 0.45
ToStringMethod · 0.45
AddMethod · 0.45
LengthMethod · 0.45

Tested by

no test coverage detected