Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
A simple helper class to decouple command buffers rotation from frames presenting. More...
#include <RingCommandContext.h>
Classes | |
struct | RingItem |
Public Types | |
using | UploadBufferFunction = std::function< void(u8 *)> |
Public Member Functions | |
CRingCommandContext (CDevice *device, const size_t size, const uint32_t queueFamilyIndex, CSubmitScheduler &submitScheduler) | |
~CRingCommandContext () | |
VkCommandBuffer | GetCommandBuffer () |
void | Flush () |
Submits the current command buffer to the SubmitScheduler. More... | |
void | FlushAndWait () |
The same as Flush but also waits until it's completed. More... | |
void | ScheduleUpload (CTexture *texture, const Format dataFormat, const void *data, const size_t dataSize, const uint32_t level, const uint32_t layer) |
Schedules uploads until next render pass or flush. More... | |
void | ScheduleUpload (CTexture *texture, const Format dataFormat, const void *data, const size_t dataSize, const uint32_t xOffset, const uint32_t yOffset, const uint32_t width, const uint32_t height, const uint32_t level, const uint32_t layer) |
void | ScheduleUpload (CBuffer *buffer, const void *data, const uint32_t dataOffset, const uint32_t dataSize) |
void | ScheduleUpload (CBuffer *buffer, const uint32_t dataOffset, const uint32_t dataSize, const UploadBufferFunction &uploadFunction) |
Private Member Functions | |
void | Begin () |
void | End () |
void | ScheduleUpload (CBuffer *buffer, const uint32_t dataOffset, const uint32_t dataSize, const uint32_t acquiredOffset) |
uint32_t | AcquireFreeSpace (const uint32_t requiredSize, const uint32_t requiredAlignment) |
uint32_t | GetFreeSpaceOffset (const uint32_t requiredSize, const uint32_t requiredAlignment) const |
void | WaitUntilFree (RingItem &item) |
Private Attributes | |
CDevice * | m_Device = nullptr |
CSubmitScheduler & | m_SubmitScheduler |
std::unique_ptr< CBuffer > | m_StagingBuffer |
uint32_t | m_StagingBufferFirst = 0 |
uint32_t | m_StagingBufferCurrentFirst = 0 |
uint32_t | m_StagingBufferLast = 0 |
uint32_t | m_OptimalBufferCopyOffsetAlignment = 1 |
uint32_t | m_MaxStagingBufferCapacity = 0 |
std::vector< RingItem > | m_Ring |
size_t | m_RingIndex = 0 |
A simple helper class to decouple command buffers rotation from frames presenting.
It might be useful when sometimes we need to submit more work than we can usually have during a frame. For example if we need to upload something, an upload buffer is full and we can't extend it at the moment. Then the only way is to wait until uploading is done and submit more work.
using Renderer::Backend::Vulkan::CRingCommandContext::UploadBufferFunction = std::function<void(u8*)> |
Renderer::Backend::Vulkan::CRingCommandContext::CRingCommandContext | ( | CDevice * | device, |
const size_t | size, | ||
const uint32_t | queueFamilyIndex, | ||
CSubmitScheduler & | submitScheduler | ||
) |
Renderer::Backend::Vulkan::CRingCommandContext::~CRingCommandContext | ( | ) |
|
private |
|
private |
|
private |
void Renderer::Backend::Vulkan::CRingCommandContext::Flush | ( | ) |
Submits the current command buffer to the SubmitScheduler.
void Renderer::Backend::Vulkan::CRingCommandContext::FlushAndWait | ( | ) |
The same as Flush but also waits until it's completed.
It means it forces SubmitScheduler to submit all previously queued work to GPU.
VkCommandBuffer Renderer::Backend::Vulkan::CRingCommandContext::GetCommandBuffer | ( | ) |
|
private |
|
private |
void Renderer::Backend::Vulkan::CRingCommandContext::ScheduleUpload | ( | CBuffer * | buffer, |
const uint32_t | dataOffset, | ||
const uint32_t | dataSize, | ||
const UploadBufferFunction & | uploadFunction | ||
) |
void Renderer::Backend::Vulkan::CRingCommandContext::ScheduleUpload | ( | CBuffer * | buffer, |
const void * | data, | ||
const uint32_t | dataOffset, | ||
const uint32_t | dataSize | ||
) |
void Renderer::Backend::Vulkan::CRingCommandContext::ScheduleUpload | ( | CTexture * | texture, |
const Format | dataFormat, | ||
const void * | data, | ||
const size_t | dataSize, | ||
const uint32_t | level, | ||
const uint32_t | layer | ||
) |
Schedules uploads until next render pass or flush.
void Renderer::Backend::Vulkan::CRingCommandContext::ScheduleUpload | ( | CTexture * | texture, |
const Format | dataFormat, | ||
const void * | data, | ||
const size_t | dataSize, | ||
const uint32_t | xOffset, | ||
const uint32_t | yOffset, | ||
const uint32_t | width, | ||
const uint32_t | height, | ||
const uint32_t | level, | ||
const uint32_t | layer | ||
) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |