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

Method Flush

Source/Engine/Graphics/DynamicBuffer.cpp:25–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25void DynamicBuffer::Flush(GPUContext* context)
26{
27 const uint32 size = Data.Count();
28 if (size == 0)
29 return;
30
31 // Lazy-resize buffer
32 if (_buffer == nullptr)
33 _buffer = GPUDevice::Instance->CreateBuffer(_name);
34 if (_buffer->GetSize() < size || _buffer->GetDescription().Usage != Usage)
35 {
36 const int32 numElements = Math::AlignUp<int32>(static_cast<int32>((size / _stride) * 1.3f), 32);
37 GPUBufferDescription desc;
38 InitDesc(desc, numElements);
39 desc.Usage = Usage;
40 if (_buffer->Init(desc))
41 {
42 LOG(Fatal, "Cannot setup dynamic buffer '{0}'! Size: {1}", _name, Utilities::BytesToText(size));
43 return;
44 }
45 }
46
47 // Upload data to the buffer
48 if (context)
49 {
50 context->UpdateBuffer(_buffer, Data.Get(), size);
51 }
52 else if (GPUDevice::Instance->IsRendering())
53 {
54 RenderContext::GPULocker.Lock();
55 GPUDevice::Instance->GetMainContext()->UpdateBuffer(_buffer, Data.Get(), size);
56 RenderContext::GPULocker.Unlock();
57 }
58 else
59 {
60 _buffer->SetData(Data.Get(), size);
61 }
62}
63
64void DynamicBuffer::Dispose()
65{

Callers 3

DrawEndMethod · 0.45
BindDrawDataMethod · 0.45
RunDeformersMethod · 0.45

Calls 13

BytesToTextFunction · 0.85
IsRenderingMethod · 0.80
LockMethod · 0.80
UnlockMethod · 0.80
CountMethod · 0.45
CreateBufferMethod · 0.45
GetSizeMethod · 0.45
GetDescriptionMethod · 0.45
InitMethod · 0.45
UpdateBufferMethod · 0.45
GetMethod · 0.45
GetMainContextMethod · 0.45

Tested by

no test coverage detected