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

Method Allocate

Source/Engine/GraphicsDevice/Vulkan/GPUShaderVulkan.cpp:52–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52UniformBufferUploaderVulkan::Allocation UniformBufferUploaderVulkan::Allocate(uint64 size, uint32 alignment, GPUContextVulkan* context)
53{
54 alignment = Math::Max(_minAlignment, alignment);
55 uint64 offset = Math::AlignUp<uint64>(_offset, alignment);
56
57 // Check if wrap around ring buffer
58 if (offset + size >= _size)
59 {
60 auto cmdBuffer = context->GetCmdBufferManager()->GetActiveCmdBuffer();
61 if (_fenceCmdBuffer && _fenceCounter == cmdBuffer->GetFenceSignaledCounter())
62 {
63 LOG(Error, "Wrapped around the ring buffer! Need to wait on the GPU!");
64 context->Flush();
65 cmdBuffer = context->GetCmdBufferManager()->GetActiveCmdBuffer();
66 }
67
68 offset = 0;
69 _offset = size;
70
71 _fenceCmdBuffer = cmdBuffer;
72 _fenceCounter = cmdBuffer->GetSubmittedFenceCounter();
73 }
74 else
75 {
76 // Move within the buffer
77 _offset = offset + size;
78 }
79
80 Allocation result;
81 result.Offset = offset;
82 result.Size = size;
83 result.Buffer = _buffer;
84 result.CPUAddress = _mapped + offset;
85 return result;
86}
87
88void UniformBufferUploaderVulkan::OnReleaseGPU()
89{

Callers 7

CopyMethod · 0.45
GenerateMipMethod · 0.45
FromTextureDataMethod · 0.45
AllocateBufferMethod · 0.45
UpdateDescriptorSetsMethod · 0.45
UpdateCBMethod · 0.45

Calls 6

GetActiveCmdBufferMethod · 0.80
GetCmdBufferManagerMethod · 0.80
MaxFunction · 0.50
FlushMethod · 0.45

Tested by

no test coverage detected