![]() |
OGRE-Next 4.0.0unstable
Object-Oriented Graphics Rendering Engine
|
#include <OgreVulkanVaoManager.h>
Inheritance diagram for Ogre::VulkanVaoManager:Classes | |
| struct | Block |
| struct | DirtyBlock |
| struct | StrideChanger |
Public Types | |
| typedef vector< Block >::type | BlockVec |
| typedef FastArray< DirtyBlock > | DirtyBlockArray |
| typedef vector< StrideChanger >::type | StrideChangerVec |
| enum | VboFlag { CPU_INACCESSIBLE , CPU_WRITE_PERSISTENT , CPU_WRITE_PERSISTENT_COHERENT , CPU_READ_WRITE , TEXTURES_OPTIMAL , MAX_VBO_FLAG } |
Public Types inherited from Ogre::VaoManager | |
| typedef vector< MemoryStatsEntry >::type | MemoryStatsEntryVec |
Public Member Functions | |
| VulkanVaoManager (VulkanDevice *device, VulkanRenderSystem *renderSystem, const NameValuePairList *params) | |
| ~VulkanVaoManager () override | |
| void | _notifyDeviceStalled () |
| void | _notifyNewCommandBuffer () |
| void | _schedulePoolAdvanceFrame (VulkanDescriptorPool *pool) |
| void | _update () override |
| void | addDelayedFunc (VulkanDelayedFuncBase *cmd) |
| VulkanRawBuffer | allocateRawBuffer (VboFlag vboFlag, size_t sizeBytes, size_t alignment=4u) |
| VkDeviceMemory | allocateTexture (const VkMemoryRequirements &memReq, size_t &outVboIdx, size_t &outBufferOffset) |
| void | bindDrawIdVertexBuffer (VkCommandBuffer cmdBuffer, uint32 binding=15) |
| void | cleanupEmptyPools () override |
| Frees GPU memory if there are empty, unused pools. | |
| AsyncTicketPtr | createAsyncTicket (BufferPacked *creator, StagingBuffer *stagingBuffer, size_t elementStart, size_t elementCount) override |
| StagingBuffer * | createStagingBuffer (size_t sizeBytes, bool forUpload) override |
| Creates a new staging buffer and adds it to the pool. | |
| VulkanStagingTexture * | createStagingTexture (PixelFormatGpu formatFamily, size_t sizeBytes) |
| void | createVkResources () |
| void | deallocateRawBuffer (VulkanRawBuffer &rawBuffer, bool bImmediately) |
| void | deallocateTexture (size_t vboIdx, size_t bufferOffset, size_t sizeBytes) |
| void | destroyStagingTexture (VulkanStagingTexture *stagingTexture) |
| void | destroyVkResources (bool finalDestruction=false) |
| VkSemaphore | getAvailableSemaphore () |
| void | getAvailableSemaphores (VkSemaphoreArray &semaphoreArray, size_t numSemaphores) |
| Insert into the end of semaphoreArray 'numSemaphores' number of semaphores that are safe for use. | |
| VulkanDescriptorPool * | getDescriptorPool (const VulkanRootLayout *rootLayout, size_t setIdx, VkDescriptorSetLayout setLayout) |
| VulkanDevice * | getDevice () const |
| VertexBufferPacked * | getDrawId () const |
| void | getMemoryStats (MemoryStatsEntryVec &outStats, size_t &outCapacityBytes, size_t &outFreeBytes, Log *log, bool &outIncludesTextures) const override |
| Retrieves memory stats about our GPU pools being managed. | |
| VulkanRenderSystem * | getVkRenderSystem () |
| void | initDrawIdVertexBuffer () |
| bool | isFrameFinished (uint32 frameCount) override |
| See VaoManager::isFrameFinished. | |
| void | notifyPresentationWaitSemaphoreSubmitted (VkSemaphore semaphore, uint32 swapchainIdx) |
| After we call vkQueuePresentKHR(), the swapchain passed to VkPresentInfoKHR::pWaitSemaphores must NOT be recycled via notifyWaitSemaphoreSubmitted(). | |
| void | notifySemaphoreUnused (VkSemaphore semaphore) |
| This semaphore can no longer be used and should be destroyed. | |
| void | notifySwapchainIndexAcquired (uint32 swapchainIdx) |
| Notifies that all past semaphores scheduled for recycling via notifyPresentationWaitSemaphoreSubmitted() for the given swapchainIdx have become available again. | |
| void | notifyWaitSemaphoresSubmitted (const VkSemaphoreArray &semaphores) |
| void | notifyWaitSemaphoreSubmitted (VkSemaphore semaphore) |
| Call this function after you've submitted to the GPU a VkSemaphore that will be waited on. | |
| bool | supportsCoherentMapping () const |
| bool | supportsNonCoherentMapping () const |
| void | waitForSpecificFrameToFinish (uint32 frameCount) override |
| See VaoManager::waitForSpecificFrameToFinish. | |
| uint8 | waitForTailFrameToFinish () override |
| Returns the current frame # (which wraps to 0 every mDynamicBufferMultiplier times). | |
Public Member Functions inherited from Ogre::VaoManager | |
| VaoManager (const NameValuePairList *params) | |
| virtual | ~VaoManager () |
| virtual void | _beginFrame () |
| uint8 | _getDynamicBufferCurrentFrameNoWait () const |
| void | _notifyStagingBufferEnteredZeroRef (StagingBuffer *stagingBuffer) |
| void | _notifyStagingBufferLeftZeroRef (StagingBuffer *stagingBuffer) |
| virtual void | _waitUntilCommitedCommandBufferCompleted () |
| Waits for the last committed command buffer completion instead of the last frame completion with command buffer switching, so we can continue to work with current command buffer. | |
| ConstBufferPacked * | createConstBuffer (size_t sizeBytes, BufferType bufferType, void *initialData, bool keepAsShadow) |
| Creates an constant buffer based on the given parameters. | |
| IndexBufferPacked * | createIndexBuffer (IndexBufferPacked::IndexType indexType, size_t numIndices, BufferType bufferType, void *initialData, bool keepAsShadow) |
| Creates an index buffer based on the given parameters. | |
| IndirectBufferPacked * | createIndirectBuffer (size_t sizeBytes, BufferType bufferType, void *initialData, bool keepAsShadow) |
| Creates an indirect buffer. | |
| ReadOnlyBufferPacked * | createReadOnlyBuffer (PixelFormatGpu pixelFormat, size_t sizeBytes, BufferType bufferType, void *initialData, bool keepAsShadow) |
| Creates a read-only buffer based on the given parameters. | |
| TexBufferPacked * | createTexBuffer (PixelFormatGpu pixelFormat, size_t sizeBytes, BufferType bufferType, void *initialData, bool keepAsShadow) |
| Creates an constant buffer based on the given parameters. | |
| UavBufferPacked * | createUavBuffer (size_t numElements, uint32 bytesPerElement, uint32 bindFlags, void *initialData, bool keepAsShadow) |
| Creates an UAV buffer based on the given parameters. | |
| VertexArrayObject * | createVertexArrayObject (const VertexBufferPackedVec &vertexBuffers, IndexBufferPacked *indexBuffer, OperationType opType) |
| Creates a VertexArrayObject that binds all the vertex buffers with their respective declarations, and the index buffers. | |
| VertexBufferPacked * | createVertexBuffer (const VertexElement2Vec &vertexElements, size_t numVertices, BufferType bufferType, void *initialData, bool keepAsShadow) |
| Creates a vertex buffer based on the given parameters. | |
| void | deleteStagingBuffers () |
| void | destroyConstBuffer (ConstBufferPacked *constBuffer) |
| Destroys the given constant buffer created with createConstBuffer. | |
| void | destroyIndexBuffer (IndexBufferPacked *indexBuffer) |
| Destroys the given index buffer created with createIndexBuffer. | |
| void | destroyIndirectBuffer (IndirectBufferPacked *indirectBuffer) |
| Destroys the given indirect buffer created with createIndirectBuffer. | |
| void | destroyReadOnlyBuffer (ReadOnlyBufferPacked *readOnlyBuffer) |
| Destroys the given texture buffer created with createReadOnlyBuffer. | |
| void | destroyTexBuffer (TexBufferPacked *texBuffer) |
| Destroys the given texture buffer created with createTexBuffer. | |
| void | destroyUavBuffer (UavBufferPacked *uavBuffer) |
| Destroys the given UAV buffer created with createUavBuffer. | |
| void | destroyVertexArrayObject (VertexArrayObject *vao) |
| Destroys the input pointer. | |
| void | destroyVertexBuffer (VertexBufferPacked *vertexBuffer) |
| Destroys the given vertex buffer created with createVertexBuffer. | |
| uint32 | getConstBufferAlignment () const |
| size_t | getConstBufferMaxSize () const |
| uint32 | getDefaultStagingBufferLifetime () const |
| uint32 | getDefaultStagingBufferUnfencedTime () const |
| uint8 | getDynamicBufferMultiplier () const |
| uint32 | getFrameCount () |
| size_t | getReadOnlyBufferMaxSize () const |
| StagingBuffer * | getStagingBuffer (size_t minSizeBytes, bool forUpload) |
| Retrieves a staging buffer for use. | |
| uint32 | getTexBufferAlignment () const |
| size_t | getTexBufferMaxSize () const |
| Timer * | getTimer () |
| uint32 | getUavBufferAlignment () const |
| size_t | getUavBufferMaxSize () const |
| bool | readOnlyIsTexBuffer () const |
| When true, ReadOnlyBufferPacked behaves like TexBufferPacked, i.e. | |
| void | setDefaultStagingBufferlifetime (uint32 lifetime, uint32 unfencedTime) |
| Sets the default time for staging buffers. | |
| bool | supportsBaseInstance () const |
| bool | supportsIndirectBuffers () const |
| When false, IndirectBufferPacked will emulate the mapping behavior, and we need to use the emulated calls in RenderSystem. | |
| bool | supportsPersistentMapping () const |
Static Public Member Functions | |
| static uint32 | getAttributeIndexFor (VertexElementSemantic semantic) |
| static void | mergeContiguousBlocks (BlockVec::iterator blockToMerge, BlockVec &blocks) |
| static VkFence | waitFor (VkFence fenceName, VulkanQueue *queue) |
| Will stall undefinitely until GPU finishes (signals the sync object). | |
Static Public Member Functions inherited from Ogre::VaoManager | |
| static uint32 | calculateVertexSize (const VertexElement2Vec &vertexElements) |
| Returns the size of a single vertex buffer source with the given declaration, in bytes. | |
| typedef vector<Block>::type Ogre::VulkanVaoManager::BlockVec |
| typedef vector<StrideChanger>::type Ogre::VulkanVaoManager::StrideChangerVec |
| Ogre::VulkanVaoManager::VulkanVaoManager | ( | VulkanDevice * | device, |
| VulkanRenderSystem * | renderSystem, | ||
| const NameValuePairList * | params | ||
| ) |
|
override |
| void Ogre::VulkanVaoManager::_notifyDeviceStalled | ( | ) |
| void Ogre::VulkanVaoManager::_notifyNewCommandBuffer | ( | ) |
| void Ogre::VulkanVaoManager::_schedulePoolAdvanceFrame | ( | VulkanDescriptorPool * | pool | ) |
|
overridevirtual |
Reimplemented from Ogre::VaoManager.
| void Ogre::VulkanVaoManager::addDelayedFunc | ( | VulkanDelayedFuncBase * | cmd | ) |
| VulkanRawBuffer Ogre::VulkanVaoManager::allocateRawBuffer | ( | VboFlag | vboFlag, |
| size_t | sizeBytes, | ||
| size_t | alignment = 4u |
||
| ) |
| VkDeviceMemory Ogre::VulkanVaoManager::allocateTexture | ( | const VkMemoryRequirements & | memReq, |
| size_t & | outVboIdx, | ||
| size_t & | outBufferOffset | ||
| ) |
| void Ogre::VulkanVaoManager::bindDrawIdVertexBuffer | ( | VkCommandBuffer | cmdBuffer, |
| uint32 | binding = 15 |
||
| ) |
|
overridevirtual |
Frees GPU memory if there are empty, unused pools.
Implements Ogre::VaoManager.
|
overridevirtual |
Implements Ogre::VaoManager.
|
overridevirtual |
Creates a new staging buffer and adds it to the pool.
Implements Ogre::VaoManager.
| VulkanStagingTexture * Ogre::VulkanVaoManager::createStagingTexture | ( | PixelFormatGpu | formatFamily, |
| size_t | sizeBytes | ||
| ) |
| void Ogre::VulkanVaoManager::createVkResources | ( | ) |
| void Ogre::VulkanVaoManager::deallocateRawBuffer | ( | VulkanRawBuffer & | rawBuffer, |
| bool | bImmediately | ||
| ) |
| void Ogre::VulkanVaoManager::deallocateTexture | ( | size_t | vboIdx, |
| size_t | bufferOffset, | ||
| size_t | sizeBytes | ||
| ) |
| void Ogre::VulkanVaoManager::destroyStagingTexture | ( | VulkanStagingTexture * | stagingTexture | ) |
| void Ogre::VulkanVaoManager::destroyVkResources | ( | bool | finalDestruction = false | ) |
|
static |
| VkSemaphore Ogre::VulkanVaoManager::getAvailableSemaphore | ( | ) |
| void Ogre::VulkanVaoManager::getAvailableSemaphores | ( | VkSemaphoreArray & | semaphoreArray, |
| size_t | numSemaphores | ||
| ) |
Insert into the end of semaphoreArray 'numSemaphores' number of semaphores that are safe for use.
Transfers ownership.
| VulkanDescriptorPool * Ogre::VulkanVaoManager::getDescriptorPool | ( | const VulkanRootLayout * | rootLayout, |
| size_t | setIdx, | ||
| VkDescriptorSetLayout | setLayout | ||
| ) |
|
inline |
|
inline |
|
overridevirtual |
Retrieves memory stats about our GPU pools being managed.
The output in the Log will be csv data that resembles the following: Pool Type Offset Bytes Pool Capacity CPU_INACCESSIBLE 0 148128 67108864 CPU_INACCESSIBLE 200000 1024 67108864 CPU_ACCESSIBLE_PERSISTENT 0 1152 16777216
These are the chunks of memory currently in use. If there are multiple entries belonging to the same pool, that means the memory has been fragmented.
The actual output may vary depending on the RenderSystem.
| outStats | Detailed information about each entry. |
| outCapacityBytes | Total capacity i.e. total used VRAM in GPU. |
| outFreeBytes | Total free memory available for consumption. |
| log | Optional to dump all information to a CSV file. Nullptr to avoid dumping. |
| outIncludesTextures | [out] When true, memory reports in outCapacityBytes & outFreeBytes include textures. See Tutorial_Memory on how to deal with this output. |
Note outIncludesTextures may be false but some entries in outStats[n].bPoolHasTextures may be true. If this happens, then outCapacityBytes & outFreeBytes don't include texture consumption; but the pools with bPoolHasTextures in MemoryStatsEntryVec may.
Implements Ogre::VaoManager.
|
inline |
| void Ogre::VulkanVaoManager::initDrawIdVertexBuffer | ( | ) |
|
overridevirtual |
See VaoManager::isFrameFinished.
Implements Ogre::VaoManager.
|
static |
| void Ogre::VulkanVaoManager::notifyPresentationWaitSemaphoreSubmitted | ( | VkSemaphore | semaphore, |
| uint32 | swapchainIdx | ||
| ) |
After we call vkQueuePresentKHR(), the swapchain passed to VkPresentInfoKHR::pWaitSemaphores must NOT be recycled via notifyWaitSemaphoreSubmitted().
This is because there is no guarantee that this semaphore will become available after enough frames. We must be specifically be informed of this fact via notifySwapchainIndexAcquired(). After that, it goes back to a pool for getAvailableSemaphores() to use.
See https://www.reddit.com/r/vulkan/comments/1kpfyo5/comment/mt03b5z/
WARNING: Failing to call notifySwapchainIndexAcquired() would cause semaphores to leak.
| void Ogre::VulkanVaoManager::notifySemaphoreUnused | ( | VkSemaphore | semaphore | ) |
This semaphore can no longer be used and should be destroyed.
| void Ogre::VulkanVaoManager::notifySwapchainIndexAcquired | ( | uint32 | swapchainIdx | ) |
Notifies that all past semaphores scheduled for recycling via notifyPresentationWaitSemaphoreSubmitted() for the given swapchainIdx have become available again.
| void Ogre::VulkanVaoManager::notifyWaitSemaphoresSubmitted | ( | const VkSemaphoreArray & | semaphores | ) |
| void Ogre::VulkanVaoManager::notifyWaitSemaphoreSubmitted | ( | VkSemaphore | semaphore | ) |
Call this function after you've submitted to the GPU a VkSemaphore that will be waited on.
i.e. 'semaphore' is part of VkSubmitInfo::pWaitSemaphores. But it must NOT be part of VkPresentInfoKHR::pWaitSemaphores.
After enough frames have passed, this semaphore goes back to a pool for getAvailableSemaphores to use.
IMPORTANT: See notifyPresentationWaitSemaphoreSubmitted().
| bool Ogre::VulkanVaoManager::supportsCoherentMapping | ( | ) | const |
| bool Ogre::VulkanVaoManager::supportsNonCoherentMapping | ( | ) | const |
|
static |
Will stall undefinitely until GPU finishes (signals the sync object).
| fenceName | Sync object to wait for. Will be released on success. On failure, throws an exception and fenceName will not be released. |
| queue | VulkanQueue this fence is linked to. |
|
overridevirtual |
See VaoManager::waitForSpecificFrameToFinish.
Implements Ogre::VaoManager.
|
overridevirtual |
Returns the current frame # (which wraps to 0 every mDynamicBufferMultiplier times).
But first stalls until that mDynamicBufferMultiplier-1 frame behind is finished.
Implements Ogre::VaoManager.