Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
Divide::VK_API Class Referencefinal

#include <VKWrapper.h>

+ Inheritance diagram for Divide::VK_API:

Classes

struct  DepthFormatInformation
 

Public Member Functions

 VK_API (GFXDevice &context) noexcept
 
VKDevicegetDevice ()
 
GFXDevicecontext () noexcept
 
const GFXDevicecontext () const noexcept
 
- Public Member Functions inherited from Divide::RenderAPIWrapper
virtual ~RenderAPIWrapper ()=default
 

Static Public Member Functions

static VKStateTrackerGetStateTracker () noexcept
 
static VkSampler GetSamplerHandle (SamplerDescriptor sampler, size_t &samplerHashInOut)
 Return the Vulkan sampler object's handle for the given hash value.
 
static void RegisterCustomAPIDelete (DELEGATE< void, VkDevice > &&cbk, bool isResourceTransient)
 
static void RegisterTransferRequest (const VKTransferQueue::TransferRequest &request)
 
static void FlushBufferTransferRequests (VkCommandBuffer cmdBuffer)
 
static void FlushBufferTransferRequests ()
 
static void SubmitTransferRequest (const VKTransferQueue::TransferRequest &request, VkCommandBuffer cmd)
 
static void InsertDebugMessage (VkCommandBuffer cmdBuffer, const char *message, U32 id=U32_MAX)
 
static void PushDebugMessage (VkCommandBuffer cmdBuffer, const char *message, U32 id=U32_MAX)
 
static void PopDebugMessage (VkCommandBuffer cmdBuffer)
 
static void OnShaderReloaded (vkShaderProgram *program)
 

Static Public Attributes

static constexpr VkPipelineStageFlagBits2 ALL_SHADER_STAGES
 
static bool s_hasDebugMarkerSupport = false
 
static bool s_hasPushDescriptorSupport = false
 
static bool s_hasDescriptorBufferSupport = false
 
static bool s_hasDynamicBlendStateSupport = false
 
static bool s_hasValidationFeaturesSupport = false
 
static DepthFormatInformation s_depthFormatInformation
 

Protected Member Functions

VkCommandBuffer getCurrentCommandBuffer () const noexcept
 
void idle (bool fast) noexcept override
 
bool drawToWindow (DisplayWindow &window) override
 
void onRenderThreadLoopStart () override
 
void onRenderThreadLoopEnd () override
 
void prepareFlushWindow (DisplayWindow &window) override
 
void flushWindow (DisplayWindow &window) override
 
bool frameStarted () override
 
bool frameEnded () override
 
ErrorCode initRenderingAPI (I32 argc, char **argv, Configuration &config) noexcept override
 
void closeRenderingAPI () override
 
void preFlushCommandBuffer (Handle< GFX::CommandBuffer > commandBuffer) override
 
void flushCommand (GFX::CommandBase *cmd) noexcept override
 
void postFlushCommandBuffer (Handle< GFX::CommandBuffer > commandBuffer) noexcept override
 
bool setViewportInternal (const Rect< I32 > &newViewport) noexcept override
 
bool setScissorInternal (const Rect< I32 > &newScissor) noexcept override
 
void onThreadCreated (const std::thread::id &threadID, bool isMainRenderThread) noexcept override
 
void initDescriptorSets () override
 
RenderTarget_uptr newRT (const RenderTargetDescriptor &descriptor) const override
 
GenericVertexData_ptr newGVD (U32 ringBufferLength, const std::string_view name) const override
 
ShaderBuffer_uptr newSB (const ShaderBufferDescriptor &descriptor) const override
 
virtual bool drawToWindow (DisplayWindow &window)=0
 
virtual void onRenderThreadLoopStart ()=0
 
virtual void onRenderThreadLoopEnd ()=0
 
virtual void prepareFlushWindow (DisplayWindow &window)=0
 
virtual void flushWindow (DisplayWindow &window)=0
 
virtual bool frameStarted ()=0
 
virtual bool frameEnded ()=0
 
virtual void idle (bool fast)=0
 
virtual ErrorCode initRenderingAPI (I32 argc, char **argv, Configuration &config)=0
 
virtual void closeRenderingAPI ()=0
 
virtual void preFlushCommandBuffer (Handle< GFX::CommandBuffer > commandBuffer)=0
 
virtual void flushCommand (GFX::CommandBase *cmd)=0
 
virtual void postFlushCommandBuffer (Handle< GFX::CommandBuffer > commandBuffer)=0
 
virtual bool setViewportInternal (const Rect< I32 > &newViewport)=0
 
virtual bool setScissorInternal (const Rect< I32 > &newScissor)=0
 
virtual void onThreadCreated (const std::thread::id &threadID, bool isMainRenderThread)=0
 
virtual bool bindShaderResources (const DescriptorSetEntries &descriptorSetEntries)=0
 
virtual void initDescriptorSets ()=0
 
virtual RenderTarget_uptr newRT (const RenderTargetDescriptor &descriptor) const =0
 
virtual GenericVertexData_ptr newGVD (U32 ringBufferLength, std::string_view name) const =0
 
virtual ShaderBuffer_uptr newSB (const ShaderBufferDescriptor &descriptor) const =0
 

Private Types

using SamplerObjectMap = hashMap< size_t, VkSampler, NoHash< size_t > >
 

Private Member Functions

void initStatePerWindow (VKPerWindowState &windowState)
 
void destroyStatePerWindow (VKPerWindowState &windowState)
 
void recreateSwapChain (VKPerWindowState &windowState)
 
bool setViewportInternal (const Rect< I32 > &newViewport, VkCommandBuffer cmdBuffer) noexcept
 
bool setScissorInternal (const Rect< I32 > &newScissor, VkCommandBuffer cmdBuffer) noexcept
 
void destroyPipelineCache ()
 
void destroyPipeline (CompiledPipeline &pipeline, bool defer)
 
void flushPushConstantsLocks ()
 
VkDescriptorSetLayout createLayoutFromBindings (const DescriptorSetUsage usage, const ShaderProgram::BindingsPerSetArray &bindings, DynamicBindings &dynamicBindings)
 
ShaderResult bindPipeline (const Pipeline &pipeline, VkCommandBuffer cmdBuffer)
 
void bindDynamicState (const RenderStateBlock &currentState, const RTBlendStates &blendStates, VkCommandBuffer cmdBuffer) noexcept
 
bool bindShaderResources (const DescriptorSetEntries &descriptorSetEntries) override
 

Static Private Member Functions

static bool Draw (const GenericDrawCommand &cmd, VkCommandBuffer cmdBuffer)
 

Private Attributes

GFXDevice_context
 
vkb::Instance _vkbInstance
 
VKDevice_uptr _device { nullptr }
 
VmaAllocator _allocator {VK_NULL_HANDLE}
 
VkPipelineCache _pipelineCache { VK_NULL_HANDLE }
 
VkDescriptorSet _dummyDescriptorSet {VK_NULL_HANDLE}
 
GFX::MemoryBarrierCommand _uniformsMemCommand {}
 
DescriptorLayoutCache_uptr _descriptorLayoutCache {nullptr}
 
hashMap< I64, VKPerWindowState_perWindowState
 
hashMap< size_t, CompiledPipeline_compiledPipelines
 
std::array< VkDescriptorSet, to_base(DescriptorSetUsage::COUNT)> _descriptorSets
 
std::array< DynamicBindings, to_base(DescriptorSetUsage::COUNT)> _descriptorDynamicBindings
 
std::array< VkDescriptorSetLayout, to_base(DescriptorSetUsage::COUNT)> _descriptorSetLayouts
 
bool _uniformsNeedLock { false }
 

Static Private Attributes

static SharedMutex s_samplerMapLock
 
static SamplerObjectMap s_samplerMap {}
 
static VKStateTracker s_stateTracker
 
static VKDeletionQueue s_transientDeleteQueue
 
static VKDeletionQueue s_deviceDeleteQueue
 
static VKTransferQueue s_transferQueue
 
static eastl::stack< vkShaderProgram * > s_reloadedShaders
 

Detailed Description

Definition at line 58 of file VKWrapper.h.

Member Typedef Documentation

◆ SamplerObjectMap

using Divide::VK_API::SamplerObjectMap = hashMap<size_t, VkSampler, NoHash<size_t> >
private

Definition at line 159 of file VKWrapper.h.

Constructor & Destructor Documentation

◆ VK_API()

Divide::VK_API::VK_API ( GFXDevice context)
noexcept

Definition at line 556 of file VKWrapper.cpp.

Member Function Documentation

◆ bindDynamicState()

void Divide::VK_API::bindDynamicState ( const RenderStateBlock currentState,
const RTBlendStates blendStates,
VkCommandBuffer  cmdBuffer 
)
privatenoexcept

Definition at line 1608 of file VKWrapper.cpp.

◆ bindPipeline()

ShaderResult Divide::VK_API::bindPipeline ( const Pipeline pipeline,
VkCommandBuffer  cmdBuffer 
)
private

Definition at line 1774 of file VKWrapper.cpp.

◆ bindShaderResources()

bool Divide::VK_API::bindShaderResources ( const DescriptorSetEntries descriptorSetEntries)
overrideprivatevirtual

Implements Divide::RenderAPIWrapper.

Definition at line 1320 of file VKWrapper.cpp.

◆ closeRenderingAPI()

void Divide::VK_API::closeRenderingAPI ( )
overrideprotectedvirtual

Implements Divide::RenderAPIWrapper.

Definition at line 1178 of file VKWrapper.cpp.

◆ context() [1/2]

const GFXDevice & Divide::VK_API::context ( ) const
inlinenoexcept

Definition at line 73 of file VKWrapper.h.

◆ context() [2/2]

GFXDevice & Divide::VK_API::context ( )
inlinenoexcept

Definition at line 72 of file VKWrapper.h.

◆ createLayoutFromBindings()

VkDescriptorSetLayout Divide::VK_API::createLayoutFromBindings ( const DescriptorSetUsage  usage,
const ShaderProgram::BindingsPerSetArray bindings,
DynamicBindings dynamicBindings 
)
private

Definition at line 2984 of file VKWrapper.cpp.

◆ destroyPipeline()

void Divide::VK_API::destroyPipeline ( CompiledPipeline pipeline,
bool  defer 
)
private

Definition at line 1129 of file VKWrapper.cpp.

◆ destroyPipelineCache()

void Divide::VK_API::destroyPipelineCache ( )
private

Definition at line 1168 of file VKWrapper.cpp.

◆ destroyStatePerWindow()

void Divide::VK_API::destroyStatePerWindow ( VKPerWindowState windowState)
private

Definition at line 752 of file VKWrapper.cpp.

◆ Draw()

bool Divide::VK_API::Draw ( const GenericDrawCommand cmd,
VkCommandBuffer  cmdBuffer 
)
staticprivate

Definition at line 1247 of file VKWrapper.cpp.

◆ drawToWindow()

bool Divide::VK_API::drawToWindow ( DisplayWindow window)
overrideprotectedvirtual

Implements Divide::RenderAPIWrapper.

Definition at line 571 of file VKWrapper.cpp.

◆ FlushBufferTransferRequests() [1/2]

void Divide::VK_API::FlushBufferTransferRequests ( )
static

Definition at line 2180 of file VKWrapper.cpp.

◆ FlushBufferTransferRequests() [2/2]

void Divide::VK_API::FlushBufferTransferRequests ( VkCommandBuffer  cmdBuffer)
static

Definition at line 2193 of file VKWrapper.cpp.

◆ flushCommand()

void Divide::VK_API::flushCommand ( GFX::CommandBase cmd)
overrideprotectedvirtualnoexcept

Implements Divide::RenderAPIWrapper.

Definition at line 2215 of file VKWrapper.cpp.

◆ flushPushConstantsLocks()

void Divide::VK_API::flushPushConstantsLocks ( )
private

Definition at line 1985 of file VKWrapper.cpp.

◆ flushWindow()

void Divide::VK_API::flushWindow ( DisplayWindow window)
overrideprotectedvirtual

Implements Divide::RenderAPIWrapper.

Definition at line 622 of file VKWrapper.cpp.

◆ frameEnded()

bool Divide::VK_API::frameEnded ( )
overrideprotectedvirtual

Implements Divide::RenderAPIWrapper.

Definition at line 680 of file VKWrapper.cpp.

◆ frameStarted()

bool Divide::VK_API::frameStarted ( )
overrideprotectedvirtual

Implements Divide::RenderAPIWrapper.

Definition at line 660 of file VKWrapper.cpp.

◆ getCurrentCommandBuffer()

VkCommandBuffer Divide::VK_API::getCurrentCommandBuffer ( ) const
protectednoexcept

Definition at line 561 of file VKWrapper.cpp.

◆ getDevice()

VKDevice * Divide::VK_API::getDevice ( )
inline

Definition at line 70 of file VKWrapper.h.

◆ GetSamplerHandle()

VkSampler Divide::VK_API::GetSamplerHandle ( SamplerDescriptor  sampler,
size_t &  samplerHashInOut 
)
static

Return the Vulkan sampler object's handle for the given hash value.

Definition at line 3145 of file VKWrapper.cpp.

◆ GetStateTracker()

VKStateTracker & Divide::VK_API::GetStateTracker ( )
staticnoexcept

Definition at line 3088 of file VKWrapper.cpp.

◆ idle()

void Divide::VK_API::idle ( bool  fast)
overrideprotectedvirtualnoexcept

Implements Divide::RenderAPIWrapper.

Definition at line 566 of file VKWrapper.cpp.

◆ initDescriptorSets()

void Divide::VK_API::initDescriptorSets ( )
overrideprotectedvirtual

Implements Divide::RenderAPIWrapper.

Definition at line 3028 of file VKWrapper.cpp.

◆ initRenderingAPI()

ErrorCode Divide::VK_API::initRenderingAPI ( I32  argc,
char **  argv,
Configuration config 
)
overrideprotectedvirtualnoexcept

Implements Divide::RenderAPIWrapper.

Definition at line 764 of file VKWrapper.cpp.

◆ initStatePerWindow()

void Divide::VK_API::initStatePerWindow ( VKPerWindowState windowState)
private

Definition at line 739 of file VKWrapper.cpp.

◆ InsertDebugMessage()

void Divide::VK_API::InsertDebugMessage ( VkCommandBuffer  cmdBuffer,
const char *  message,
U32  id = U32_MAX 
)
static

Definition at line 3093 of file VKWrapper.cpp.

◆ newGVD()

GenericVertexData_ptr Divide::VK_API::newGVD ( U32  ringBufferLength,
const std::string_view  name 
) const
overrideprotectedvirtual

Implements Divide::RenderAPIWrapper.

Definition at line 3203 of file VKWrapper.cpp.

◆ newRT()

RenderTarget_uptr Divide::VK_API::newRT ( const RenderTargetDescriptor descriptor) const
overrideprotectedvirtual

Implements Divide::RenderAPIWrapper.

Definition at line 3198 of file VKWrapper.cpp.

◆ newSB()

ShaderBuffer_uptr Divide::VK_API::newSB ( const ShaderBufferDescriptor descriptor) const
overrideprotectedvirtual

Implements Divide::RenderAPIWrapper.

Definition at line 3208 of file VKWrapper.cpp.

◆ onRenderThreadLoopEnd()

void Divide::VK_API::onRenderThreadLoopEnd ( )
overrideprotectedvirtual

Implements Divide::RenderAPIWrapper.

Definition at line 614 of file VKWrapper.cpp.

◆ onRenderThreadLoopStart()

void Divide::VK_API::onRenderThreadLoopStart ( )
overrideprotectedvirtual

Implements Divide::RenderAPIWrapper.

Definition at line 610 of file VKWrapper.cpp.

◆ OnShaderReloaded()

void Divide::VK_API::OnShaderReloaded ( vkShaderProgram program)
static

Definition at line 3078 of file VKWrapper.cpp.

◆ onThreadCreated()

void Divide::VK_API::onThreadCreated ( const std::thread::id &  threadID,
bool  isMainRenderThread 
)
overrideprotectedvirtualnoexcept

Implements Divide::RenderAPIWrapper.

Definition at line 3074 of file VKWrapper.cpp.

◆ PopDebugMessage()

void Divide::VK_API::PopDebugMessage ( VkCommandBuffer  cmdBuffer)
static

Definition at line 3131 of file VKWrapper.cpp.

◆ postFlushCommandBuffer()

void Divide::VK_API::postFlushCommandBuffer ( Handle< GFX::CommandBuffer commandBuffer)
overrideprotectedvirtualnoexcept

Implements Divide::RenderAPIWrapper.

Definition at line 2929 of file VKWrapper.cpp.

◆ preFlushCommandBuffer()

void Divide::VK_API::preFlushCommandBuffer ( Handle< GFX::CommandBuffer commandBuffer)
overrideprotectedvirtual

Implements Divide::RenderAPIWrapper.

Definition at line 2917 of file VKWrapper.cpp.

◆ prepareFlushWindow()

void Divide::VK_API::prepareFlushWindow ( DisplayWindow window)
overrideprotectedvirtual

Implements Divide::RenderAPIWrapper.

Definition at line 618 of file VKWrapper.cpp.

◆ PushDebugMessage()

void Divide::VK_API::PushDebugMessage ( VkCommandBuffer  cmdBuffer,
const char *  message,
U32  id = U32_MAX 
)
static

Definition at line 3112 of file VKWrapper.cpp.

◆ recreateSwapChain()

void Divide::VK_API::recreateSwapChain ( VKPerWindowState windowState)
private

Definition at line 710 of file VKWrapper.cpp.

◆ RegisterCustomAPIDelete()

void Divide::VK_API::RegisterCustomAPIDelete ( DELEGATE< void, VkDevice > &&  cbk,
bool  isResourceTransient 
)
static

Definition at line 537 of file VKWrapper.cpp.

◆ RegisterTransferRequest()

void Divide::VK_API::RegisterTransferRequest ( const VKTransferQueue::TransferRequest request)
static

Definition at line 549 of file VKWrapper.cpp.

◆ setScissorInternal() [1/2]

bool Divide::VK_API::setScissorInternal ( const Rect< I32 > &  newScissor)
overrideprotectedvirtualnoexcept

Implements Divide::RenderAPIWrapper.

Definition at line 2968 of file VKWrapper.cpp.

◆ setScissorInternal() [2/2]

bool Divide::VK_API::setScissorInternal ( const Rect< I32 > &  newScissor,
VkCommandBuffer  cmdBuffer 
)
privatenoexcept

Definition at line 2973 of file VKWrapper.cpp.

◆ setViewportInternal() [1/2]

bool Divide::VK_API::setViewportInternal ( const Rect< I32 > &  newViewport)
overrideprotectedvirtualnoexcept

Implements Divide::RenderAPIWrapper.

Definition at line 2939 of file VKWrapper.cpp.

◆ setViewportInternal() [2/2]

bool Divide::VK_API::setViewportInternal ( const Rect< I32 > &  newViewport,
VkCommandBuffer  cmdBuffer 
)
privatenoexcept

Definition at line 2944 of file VKWrapper.cpp.

◆ SubmitTransferRequest()

void Divide::VK_API::SubmitTransferRequest ( const VKTransferQueue::TransferRequest request,
VkCommandBuffer  cmd 
)
static

Definition at line 2149 of file VKWrapper.cpp.

Member Data Documentation

◆ _allocator

VmaAllocator Divide::VK_API::_allocator {VK_NULL_HANDLE}
private

Definition at line 141 of file VKWrapper.h.

◆ _compiledPipelines

hashMap<size_t, CompiledPipeline> Divide::VK_API::_compiledPipelines
private

Definition at line 149 of file VKWrapper.h.

◆ _context

GFXDevice& Divide::VK_API::_context
private

Definition at line 138 of file VKWrapper.h.

◆ _descriptorDynamicBindings

std::array<DynamicBindings, to_base( DescriptorSetUsage::COUNT )> Divide::VK_API::_descriptorDynamicBindings
private

Definition at line 152 of file VKWrapper.h.

◆ _descriptorLayoutCache

DescriptorLayoutCache_uptr Divide::VK_API::_descriptorLayoutCache {nullptr}
private

Definition at line 146 of file VKWrapper.h.

◆ _descriptorSetLayouts

std::array<VkDescriptorSetLayout, to_base( DescriptorSetUsage::COUNT )> Divide::VK_API::_descriptorSetLayouts
private

Definition at line 153 of file VKWrapper.h.

◆ _descriptorSets

std::array<VkDescriptorSet, to_base( DescriptorSetUsage::COUNT )> Divide::VK_API::_descriptorSets
private

Definition at line 151 of file VKWrapper.h.

◆ _device

VKDevice_uptr Divide::VK_API::_device { nullptr }
private

Definition at line 140 of file VKWrapper.h.

◆ _dummyDescriptorSet

VkDescriptorSet Divide::VK_API::_dummyDescriptorSet {VK_NULL_HANDLE}
private

Definition at line 143 of file VKWrapper.h.

◆ _perWindowState

hashMap<I64, VKPerWindowState> Divide::VK_API::_perWindowState
private

Definition at line 148 of file VKWrapper.h.

◆ _pipelineCache

VkPipelineCache Divide::VK_API::_pipelineCache { VK_NULL_HANDLE }
private

Definition at line 142 of file VKWrapper.h.

◆ _uniformsMemCommand

GFX::MemoryBarrierCommand Divide::VK_API::_uniformsMemCommand {}
private

Definition at line 145 of file VKWrapper.h.

◆ _uniformsNeedLock

bool Divide::VK_API::_uniformsNeedLock { false }
private

Definition at line 156 of file VKWrapper.h.

◆ _vkbInstance

vkb::Instance Divide::VK_API::_vkbInstance
private

Definition at line 139 of file VKWrapper.h.

◆ ALL_SHADER_STAGES

constexpr VkPipelineStageFlagBits2 Divide::VK_API::ALL_SHADER_STAGES
staticconstexpr
Initial value:
= VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT |
VK_PIPELINE_STAGE_2_TESSELLATION_CONTROL_SHADER_BIT |
VK_PIPELINE_STAGE_2_TESSELLATION_EVALUATION_SHADER_BIT |
VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT |
VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT |
VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT

Definition at line 60 of file VKWrapper.h.

◆ s_depthFormatInformation

VK_API::DepthFormatInformation Divide::VK_API::s_depthFormatInformation
static

Definition at line 184 of file VKWrapper.h.

◆ s_deviceDeleteQueue

VKDeletionQueue Divide::VK_API::s_deviceDeleteQueue
staticprivate

Definition at line 165 of file VKWrapper.h.

◆ s_hasDebugMarkerSupport

bool Divide::VK_API::s_hasDebugMarkerSupport = false
static

Definition at line 179 of file VKWrapper.h.

◆ s_hasDescriptorBufferSupport

bool Divide::VK_API::s_hasDescriptorBufferSupport = false
static

Definition at line 181 of file VKWrapper.h.

◆ s_hasDynamicBlendStateSupport

bool Divide::VK_API::s_hasDynamicBlendStateSupport = false
static

Definition at line 182 of file VKWrapper.h.

◆ s_hasPushDescriptorSupport

bool Divide::VK_API::s_hasPushDescriptorSupport = false
static

Definition at line 180 of file VKWrapper.h.

◆ s_hasValidationFeaturesSupport

bool Divide::VK_API::s_hasValidationFeaturesSupport = false
static

Definition at line 183 of file VKWrapper.h.

◆ s_reloadedShaders

eastl::stack< vkShaderProgram * > Divide::VK_API::s_reloadedShaders
staticprivate

Definition at line 168 of file VKWrapper.h.

◆ s_samplerMap

VK_API::SamplerObjectMap Divide::VK_API::s_samplerMap {}
staticprivate

Definition at line 162 of file VKWrapper.h.

◆ s_samplerMapLock

SharedMutex Divide::VK_API::s_samplerMapLock
staticprivate

Definition at line 161 of file VKWrapper.h.

◆ s_stateTracker

VKStateTracker Divide::VK_API::s_stateTracker
staticprivate

Definition at line 163 of file VKWrapper.h.

◆ s_transferQueue

VKTransferQueue Divide::VK_API::s_transferQueue
staticprivate

Definition at line 166 of file VKWrapper.h.

◆ s_transientDeleteQueue

VKDeletionQueue Divide::VK_API::s_transientDeleteQueue
staticprivate

Definition at line 164 of file VKWrapper.h.


The documentation for this class was generated from the following files: