KiCad PCB EDA Suite
Loading...
Searching...
No Matches
RHI_VULKAN_DEVICE Class Reference
Inheritance diagram for RHI_VULKAN_DEVICE:
RHI_DEVICE

Classes

struct  BindGroupAllocation
 
struct  BindGroupLayoutAllocation
 
struct  BufferAllocation
 
struct  ComputePipelineAllocation
 
struct  DescriptorPoolEntry
 
struct  FramebufferAllocation
 
struct  PipelineAllocation
 
struct  RenderPassAllocation
 
struct  ShaderAllocation
 
struct  StagingBuffer
 
struct  SurfaceAllocation
 
struct  SwapchainAllocation
 
struct  TextureAllocation
 
struct  VkSwapchainTry
 

Public Member Functions

 RHI_VULKAN_DEVICE (bool enableValidation)
 
 ~RHI_VULKAN_DEVICE () override
 
const char * GetName () const override
 Backend and GPU name for display, such as "Vulkan (GeForce RTX 3080)".
 
RHI_BACKEND GetBackend () const override
 
uint32_t MaxTextureSize () const override
 Largest texture width or height in texels.
 
bool IsInitialized () const override
 
bool SupportsCompute () const override
 Compute defaults keep backends without compute support usable for graphics.
 
RHI_COMPUTE_DEVICE_LIMITS ComputeDeviceLimits () const override
 
RHI_ComputePipelineHandle CreateComputePipeline (const RHI_COMPUTE_PIPELINE_DESC &aDesc) override
 
void DestroyComputePipeline (RHI_ComputePipelineHandle aHandle) override
 
RHI_COMPUTE_PIPELINE_LIMITS ComputePipelineLimits (RHI_ComputePipelineHandle aHandle) const override
 
RHI_COMPUTE_RESULT ExecuteCompute (const RHI_COMPUTE_JOB &aJob) override
 Submit, wait for completion, and copy all readbacks before returning.
 
RHI_BufferHandle ReserveBufferHandle () override
 Reserve a handle without creating the GPU buffer, so the UI thread can hand out handles while RealizeBuffer() runs later on the render thread.
 
bool RealizeBuffer (RHI_BufferHandle handle, const RHI_BUFFER_DESC &desc) override
 Create the GPU buffer for a reserved handle.
 
void DestroyBuffer (RHI_BufferHandle handle) override
 The handle's generation is retired, so later use of the stale handle is detected.
 
void UpdateBuffer (RHI_BufferHandle handle, const void *data, size_t sizeBytes, size_t offset=0) override
 The buffer need not be mappable.
 
RHI_TextureHandle ReserveTextureHandle () override
 Thread-safe handle reservation, realized later by RealizeTexture().
 
bool RealizeTexture (RHI_TextureHandle handle, const RHI_TEXTURE_DESC &desc) override
 Create the GPU texture for a reserved handle.
 
void DestroyTexture (RHI_TextureHandle handle) override
 Render thread only.
 
void UploadTexture (RHI_TextureHandle handle, const void *data, size_t sizeBytes) override
 Data is tightly packed rows in the texture's format, exactly width * height * bpp bytes.
 
RHI_ShaderHandle CreateShader (const RHI_SHADER_DESC &desc) override
 Returns a null handle on failure.
 
void DestroyShader (RHI_ShaderHandle handle) override
 
RHI_PipelineHandle CreatePipeline (const RHI_PIPELINE_DESC &desc) override
 Returns a null handle on failure.
 
void DestroyPipeline (RHI_PipelineHandle handle) override
 
RHI_BindGroupLayoutHandle CreateBindGroupLayout (const RHI_BIND_GROUP_LAYOUT_DESC &desc) override
 Returns a null handle on failure.
 
void DestroyBindGroupLayout (RHI_BindGroupLayoutHandle handle) override
 
RHI_BindGroupHandle CreateBindGroup (const RHI_BIND_GROUP_DESC &desc) override
 Returns a null handle on failure.
 
void DestroyBindGroup (RHI_BindGroupHandle handle) override
 
void BindGroup (uint32_t groupIndex, RHI_BindGroupHandle group) override
 Only valid inside a render pass with a bound pipeline.
 
RHI_RenderPassHandle CreateRenderPass (const RHI_RENDER_PASS_DESC &desc) override
 Returns a null handle on failure.
 
void DestroyRenderPass (RHI_RenderPassHandle handle) override
 
RHI_FramebufferHandle CreateFramebuffer (const RHI_FRAMEBUFFER_DESC &desc) override
 Returns a null handle on failure.
 
void DestroyFramebuffer (RHI_FramebufferHandle handle) override
 
RHI_TextureHandle GetFramebufferColorTexture (RHI_FramebufferHandle handle, uint32_t attachmentIndex=0) const override
 The texture lets a later pass sample the framebuffer.
 
bool BeginRenderPass (const RHI_RENDER_PASS_BEGIN_DESC &desc) override
 Draws and dynamic state changes must come between this and EndRenderPass().
 
bool EndRenderPass () override
 Returns false if no render pass is active.
 
void SetViewport (const RHI_VIEWPORT &viewport) override
 Only valid inside a render pass.
 
void SetScissor (const RHI_SCISSOR_RECT &scissor) override
 Only valid inside a render pass.
 
void BindPipeline (RHI_PipelineHandle pipeline) override
 Only valid inside a render pass.
 
void SetPushConstants (const void *data, size_t sizeBytes) override
 Size must not exceed RHI_MAX_PUSH_CONSTANT_BYTES.
 
void BindVertexBuffer (uint32_t slot, RHI_BufferHandle buffer) override
 Only valid inside a render pass.
 
void BindIndexBuffer (RHI_BufferHandle buffer) override
 Indices are 16 bits on every backend.
 
void Draw (uint32_t vertexCount, uint32_t firstVertex=0) override
 Draws are only valid inside a render pass with a bound pipeline.
 
void DrawInstanced (uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex=0, int32_t vertexOffset=0, uint32_t firstInstance=0) override
 Non-indexed, so vertexOffset is ignored.
 
void DrawIndexedInstanced (uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex=0, int32_t vertexOffset=0, uint32_t firstInstance=0) override
 Reads 16-bit indices from the bound index buffer.
 
RHI_SurfaceHandle CreateSurface (const RHI_SURFACE_DESC &desc) override
 Returns a null handle if the native window handle is invalid.
 
void DestroySurface (RHI_SurfaceHandle handle) override
 Destroy the surface's swapchain first.
 
RHI_SwapchainHandle CreateSwapchain (const RHI_SWAPCHAIN_DESC &desc) override
 Returns a null handle on failure.
 
bool ResizeSwapchain (RHI_SwapchainHandle handle, uint32_t width, uint32_t height, float dpiScale) override
 Call when the window size or DPI scale changes.
 
void DestroySwapchain (RHI_SwapchainHandle handle) override
 
bool WaitForPresentSlot (RHI_SwapchainHandle aSwapchain, std::chrono::milliseconds aTimeout, int aAllowed) override
 Wait until fewer than aAllowed presents are queued for the display or the timeout passes, so the next frame renders from the newest input.
 
RHI_SURFACE_EXTENT_POLL_RESULT PollSurfaceExtent (RHI_SwapchainHandle aSwapchain) override
 Retry a fixed surface extent that lagged behind the requested window size.
 
bool PresentWaitsForDisplay (RHI_SwapchainHandle aSwapchain) const override
 False when presents show at once instead of at the next vertical blank, so frames drawn faster than the display refreshes are never seen.
 
bool PresentReplacesQueued (RHI_SwapchainHandle aSwapchain) const override
 True when a present replaces one still queued for the next vertical blank, as in Vulkan MAILBOX mode, so frames drawn faster than the display only cost GPU time.
 
RHI_FRAME_OP_RESULT Present (RHI_SwapchainHandle handle, RHI_FramebufferHandle aSrcFBO={}, const RHI_SCISSOR_RECT *aSourceRect=nullptr) override
 When aSrcFBO is valid its first color attachment is copied to the swapchain first.
 
bool ReadbackFramebufferPixels (RHI_FramebufferHandle handle, uint32_t attachmentIndex, void *buffer, size_t bufferSize) override
 buffer must hold at least width * height * bpp bytes.
 
bool CopyFramebufferDepth (RHI_FramebufferHandle aSource, RHI_FramebufferHandle aDestination, uint32_t aSourceX=0, uint32_t aSourceY=0) override
 Fill all of aDestination with source depth from (aSourceX, aSourceY) on, ordered after passes already issued.
 
void BeginUploadBatch () override
 UpdateBuffer() and UploadTexture() calls between these share one submission instead of syncing with the GPU each time.
 
void EndUploadBatch () override
 
RHI_BufferHandle CreateBuffer (const RHI_BUFFER_DESC &desc)
 Reserve and realize in one call, so render thread only.
 
RHI_TextureHandle CreateTexture (const RHI_TEXTURE_DESC &desc)
 Reserve and realize in one call, so render thread only.
 
void Release (RHI_BufferHandle &aHandle)
 Destroy the resource, if there is one, and clear the handle.
 
void Release (RHI_TextureHandle &aHandle)
 
void Release (RHI_ShaderHandle &aHandle)
 
void Release (RHI_PipelineHandle &aHandle)
 
void Release (RHI_BindGroupLayoutHandle &aHandle)
 
void Release (RHI_RenderPassHandle &aHandle)
 
void Release (RHI_FramebufferHandle &aHandle)
 
void Release (RHI_BindGroupHandle &aHandle)
 
void Release (RHI_SurfaceHandle &aHandle)
 
void Release (RHI_SwapchainHandle &aHandle)
 
virtual std::optional< std::chrono::steady_clock::time_point > LastDisplayRefresh (RHI_SwapchainHandle aSwapchain) const
 The vertical blank at which the display last showed a frame, or nothing if the backend cannot tell.
 
virtual void EndFrame ()
 Retire deferred releases that are due.
 
size_t PendingDeferredReleases () const
 Releases still waiting on later frames, which only EndFrame() retires.
 

Protected Member Functions

template<typename Tag>
void deferDestroy (RHI_HANDLE_POOL< Tag > &aPool, RHI_DEFERRED_RESOURCE_TYPE aType, RHI_HANDLE< Tag > aHandle)
 Only the destroy that wins the pending-destroy claim enqueues, so racing destroys of one handle cannot free it twice.
 

Protected Attributes

uint64_t m_frameCounter = 0
 
RHI_DEFERRED_RELEASE_QUEUE m_deferredReleaseQueue
 

Private Member Functions

bool InitLoader ()
 
bool CreateVkInstance (bool enableValidation)
 
bool SelectPhysicalDevice ()
 
bool CreateLogicalDevice ()
 
void LoadDeviceFunctions ()
 
bool InitVMA ()
 
bool InitCommandPool ()
 
void ReadDeviceProperties ()
 
void * LoadVulkanFunction (const char *name)
 
void * LoadInstanceFunction (const char *name)
 
VkRenderPass makeRenderPass (const std::vector< VK_ATTACHMENT > &aColor, const std::optional< VK_ATTACHMENT > &aDepth)
 
void * LoadDeviceFunction (const char *name)
 
bool allocateCommandBuffer (VkCommandBuffer &aCmd)
 
VkResult beginOneTimeCommands (VkCommandBuffer aCmd)
 
VkResult submitCommands (VkCommandBuffer aCmd)
 
VkCommandBuffer beginUploadCommands (std::unique_lock< std::recursive_mutex > &aLock)
 
bool endUploadCommands (VkCommandBuffer aCmd, const std::unique_lock< std::recursive_mutex > &aLock)
 
bool SubmitOneShot (VkCommandBuffer cmd)
 
VkCommandBuffer EnsureUploadCmdBuf ()
 
bool CurrentThreadOwnsUploadBatch () const
 
int AcquireStaging (size_t aSizeBytes)
 
void ReleaseStaging (int aIndex)
 
int stageData (const void *aData, size_t aSizeBytes, VkBuffer &aBuffer)
 
void endStagedUpload (VkCommandBuffer aCmd, std::unique_lock< std::recursive_mutex > &aLock, int aStaging)
 
void DestroyStagingPool ()
 
VkDescriptorPool AcquireDescriptorPool ()
 
void ReleaseDescriptorSet (VkDescriptorPool pool, VkDescriptorSet dset=VK_NULL_HANDLE)
 
void TransitionTexture (VkCommandBuffer cmd, TextureAllocation &tex, VkImageLayout newLayout, VkPipelineStageFlags srcStage, VkPipelineStageFlags dstStage)
 
void destroyFramebufferObjects (FramebufferAllocation &aFb)
 
void destroyTexture (TextureAllocation &aTexture)
 
bool createImage2D (VkFormat aFormat, uint32_t aWidth, uint32_t aHeight, VkImageUsageFlags aUsage, bool aDedicated, VkImage &aImage, VmaAllocation &aAllocation)
 
VkImageView createView (VkImage aImage, VkFormat aFormat, VkImageAspectFlags aAspect)
 
VkSampler createSampler (VkFilter aFilter)
 
bool acquirePassCmd (VkCommandBuffer &aCmd)
 
VkResult submitPassCmd (VkCommandBuffer aCmd)
 
VkDescriptorSetLayout createSetLayout (const RHI_BIND_GROUP_LAYOUT_DESC &aDesc)
 
VkResult buildPipeline (VkShaderModule aVertex, VkShaderModule aFragment, const VkPipelineVertexInputStateCreateInfo &aVertexInput, VkPrimitiveTopology aTopology, const std::vector< VkPipelineColorBlendAttachmentState > &aBlend, const VkPipelineDepthStencilStateCreateInfo &aDepthStencil, const std::vector< VkDynamicState > &aDynamicStates, VkPipelineLayout aLayout, VkRenderPass aRenderPass, VkPipeline &aPipeline)
 
void destroyPipeline (PipelineAllocation &aPipeline)
 
void ExecuteDeferredReleases () override
 
void ExecuteDeferredRelease (const RHI_DEFERRED_RELEASE_ENTRY &aEntry)
 
bool FindPresentQueueFamily (VkSurfaceKHR vkSurface, uint32_t &outFamily)
 
VkPresentModeKHR ChoosePresentMode (const SurfaceAllocation &aSurface)
 
bool CreateSwapchainResources (SwapchainAllocation &swa)
 
void DestroySwapchainResources (SwapchainAllocation &swa, bool aKeepSwapchain=false)
 
void destroySwapchainObjects (SwapchainAllocation &aSwa)
 
VkSwapchainTry createVkSwapchain (const SurfaceAllocation &aSurface, const VkSurfaceCapabilitiesKHR &aCaps, VkSurfaceFormatKHR aFormat, VkExtent2D aExtent, VkSwapchainKHR aOld, bool aResize)
 
VkPipeline EnsurePresentBlit (VkFormat aSwapchainFormat)
 
void DestroyPresentBlit ()
 
void MarkBufferInUse (BufferAllocation &aBuffer)
 
void OnQueueIdle ()
 
void SyncSubmittedPasses ()
 

Static Private Member Functions

static VkBufferUsageFlags TranslateBufferUsage (RHI_BUFFER_TYPE type)
 
static VkFormat TranslateTextureFormat (RHI_TEXTURE_FORMAT format)
 
static VkFilter TranslateFilter (RHI_FILTER filter)
 

Private Attributes

wxDynamicLibrary m_vulkanLib
 
VkInstance m_instance = VK_NULL_HANDLE
 
VkDebugUtilsMessengerEXT m_debugMessenger = VK_NULL_HANDLE
 
VkPhysicalDevice m_physicalDevice = VK_NULL_HANDLE
 
VkDevice m_device = VK_NULL_HANDLE
 
VkQueue m_graphicsQueue = VK_NULL_HANDLE
 
uint32_t m_graphicsQueueFamily = UINT32_MAX
 
VmaAllocator m_allocator = VK_NULL_HANDLE
 
VkCommandPool m_commandPool = VK_NULL_HANDLE
 
std::recursive_mutex m_deviceMutex
 
VkPipelineCache m_pipelineCache = VK_NULL_HANDLE
 
double m_totalPipelineCreateMs = 0.0
 
uint32_t m_maxTextureSize = 4096
 
VkPhysicalDeviceLimits m_deviceLimits {}
 
bool m_computeQueue = false
 
uint32_t m_computeSubgroupSize = 0
 
bool m_storageDescriptors = false
 
VulkanFunctions m_vk
 
std::string m_deviceName
 
bool m_initialized = false
 
std::atomic< std::thread::id > m_uploadBatchOwner { std::thread::id{} }
 
VkCommandBuffer m_uploadCmdBuf = VK_NULL_HANDLE
 
std::vector< StagingBuffer > m_stagingPool
 
std::vector< size_t > m_batchPooledStaging
 
RHI_HANDLE_POOL< RHI_TAG_BUFFER > m_bufferPool
 
std::unordered_map< uint32_t, BufferAllocation > m_buffers
 
RHI_HANDLE_POOL< RHI_TAG_TEXTURE > m_texturePool
 
std::unordered_map< uint32_t, TextureAllocation > m_textures
 
RHI_HANDLE_POOL< RHI_TAG_SHADER > m_shaderPool
 
std::unordered_map< uint32_t, ShaderAllocation > m_shaders
 
RHI_HANDLE_POOL< RHI_TAG_PIPELINE > m_pipelinePool
 
std::unordered_map< uint32_t, PipelineAllocation > m_pipelines
 
RHI_HANDLE_POOL< RHI_TAG_COMPUTE_PIPELINE > m_computePipelinePool
 
std::unordered_map< uint32_t, ComputePipelineAllocation > m_computePipelines
 
RHI_HANDLE_POOL< RHI_TAG_BIND_GROUP_LAYOUT > m_bindGroupLayoutPool
 
std::unordered_map< uint32_t, BindGroupLayoutAllocation > m_bindGroupLayouts
 
std::vector< DescriptorPoolEntry > m_descriptorPools
 
RHI_HANDLE_POOL< RHI_TAG_BIND_GROUP > m_bindGroupPool
 
std::unordered_map< uint32_t, BindGroupAllocation > m_bindGroups
 
RHI_HANDLE_POOL< RHI_TAG_RENDER_PASS > m_renderPassPool
 
std::unordered_map< uint32_t, RenderPassAllocation > m_renderPasses
 
RHI_HANDLE_POOL< RHI_TAG_FRAMEBUFFER > m_framebufferPool
 
std::unordered_map< uint32_t, FramebufferAllocation > m_framebuffers
 
RHI_HANDLE_POOL< RHI_TAG_SURFACE > m_surfacePool
 
std::unordered_map< uint32_t, SurfaceAllocation > m_surfaces
 
RHI_HANDLE_POOL< RHI_TAG_SWAPCHAIN > m_swapchainPool
 
std::unordered_map< uint32_t, SwapchainAllocation > m_swapchains
 
std::unordered_map< VkFormat, VkPipeline > m_presentBlitPipelines
 
VkPipelineLayout m_presentBlitLayout = VK_NULL_HANDLE
 
VkDescriptorSetLayout m_presentBlitDSLayout = VK_NULL_HANDLE
 
VkCommandBuffer m_currentCmd = VK_NULL_HANDLE
 
std::vector< VkCommandBuffer > m_submittedCmds
 
std::vector< VkCommandBuffer > m_freeCmds
 
uint64_t m_submitSerial = 0
 
uint64_t m_syncedSerial = 0
 
bool m_renderPassActive = false
 
bool m_presentWait = false
 
RHI_PipelineHandle m_activePipeline
 

Static Private Attributes

static constexpr size_t STAGING_MIN_BYTES = 64 * 1024
 
static constexpr size_t STAGING_POOL_BYTES = 256 * 1024 * 1024
 

Detailed Description

Definition at line 303 of file rhi_vulkan_device.cpp.

Constructor & Destructor Documentation

◆ RHI_VULKAN_DEVICE()

◆ ~RHI_VULKAN_DEVICE()

Member Function Documentation

◆ AcquireDescriptorPool()

VkDescriptorPool RHI_VULKAN_DEVICE::AcquireDescriptorPool ( )
private

◆ acquirePassCmd()

bool RHI_VULKAN_DEVICE::acquirePassCmd ( VkCommandBuffer & aCmd)
private

Definition at line 1491 of file rhi_vulkan_device.cpp.

References allocateCommandBuffer(), and m_freeCmds.

Referenced by BeginRenderPass(), and CopyFramebufferDepth().

◆ AcquireStaging()

◆ allocateCommandBuffer()

bool RHI_VULKAN_DEVICE::allocateCommandBuffer ( VkCommandBuffer & aCmd)
private

◆ beginOneTimeCommands()

VkResult RHI_VULKAN_DEVICE::beginOneTimeCommands ( VkCommandBuffer aCmd)
private

◆ BeginRenderPass()

◆ BeginUploadBatch()

void RHI_VULKAN_DEVICE::BeginUploadBatch ( )
overridevirtual

UpdateBuffer() and UploadTexture() calls between these share one submission instead of syncing with the GPU each time.

The default does nothing.

Reimplemented from RHI_DEVICE.

Definition at line 1592 of file rhi_vulkan_device.cpp.

References m_deviceMutex, m_uploadBatchOwner, and m_uploadCmdBuf.

◆ beginUploadCommands()

VkCommandBuffer RHI_VULKAN_DEVICE::beginUploadCommands ( std::unique_lock< std::recursive_mutex > & aLock)
private

◆ BindGroup()

void RHI_VULKAN_DEVICE::BindGroup ( uint32_t groupIndex,
RHI_BindGroupHandle group )
overridevirtual

◆ BindIndexBuffer()

void RHI_VULKAN_DEVICE::BindIndexBuffer ( RHI_BufferHandle buffer)
overridevirtual

Indices are 16 bits on every backend.

Only valid inside a render pass.

Implements RHI_DEVICE.

Definition at line 4221 of file rhi_vulkan_device.cpp.

References m_bufferPool, m_buffers, m_currentCmd, m_deviceMutex, m_renderPassActive, m_vk, MarkBufferInUse(), and RhiHandleIndex().

◆ BindPipeline()

void RHI_VULKAN_DEVICE::BindPipeline ( RHI_PipelineHandle pipeline)
overridevirtual

Only valid inside a render pass.

Implements RHI_DEVICE.

Definition at line 4150 of file rhi_vulkan_device.cpp.

References m_activePipeline, m_currentCmd, m_deviceMutex, m_pipelinePool, m_pipelines, m_renderPassActive, m_vk, and RhiHandleIndex().

◆ BindVertexBuffer()

void RHI_VULKAN_DEVICE::BindVertexBuffer ( uint32_t slot,
RHI_BufferHandle buffer )
overridevirtual

Only valid inside a render pass.

Implements RHI_DEVICE.

Definition at line 4197 of file rhi_vulkan_device.cpp.

References m_bufferPool, m_buffers, m_currentCmd, m_deviceMutex, m_renderPassActive, m_vk, MarkBufferInUse(), and RhiHandleIndex().

◆ buildPipeline()

VkResult RHI_VULKAN_DEVICE::buildPipeline ( VkShaderModule aVertex,
VkShaderModule aFragment,
const VkPipelineVertexInputStateCreateInfo & aVertexInput,
VkPrimitiveTopology aTopology,
const std::vector< VkPipelineColorBlendAttachmentState > & aBlend,
const VkPipelineDepthStencilStateCreateInfo & aDepthStencil,
const std::vector< VkDynamicState > & aDynamicStates,
VkPipelineLayout aLayout,
VkRenderPass aRenderPass,
VkPipeline & aPipeline )
private

Definition at line 2860 of file rhi_vulkan_device.cpp.

References m_device, m_pipelineCache, and m_vk.

Referenced by CreatePipeline(), and EnsurePresentBlit().

◆ ChoosePresentMode()

VkPresentModeKHR RHI_VULKAN_DEVICE::ChoosePresentMode ( const SurfaceAllocation & aSurface)
private

◆ ComputeDeviceLimits()

◆ ComputePipelineLimits()

RHI_COMPUTE_PIPELINE_LIMITS RHI_VULKAN_DEVICE::ComputePipelineLimits ( RHI_ComputePipelineHandle aHandle) const
overridevirtual

◆ CopyFramebufferDepth()

bool RHI_VULKAN_DEVICE::CopyFramebufferDepth ( RHI_FramebufferHandle aSource,
RHI_FramebufferHandle aDestination,
uint32_t aSourceX = 0,
uint32_t aSourceY = 0 )
overridevirtual

Fill all of aDestination with source depth from (aSourceX, aSourceY) on, ordered after passes already issued.

The offset counts texels in storage order, which follows normalized device Y on every backend. Must not be called inside a render pass.

Returns
false if either framebuffer lacks depth, the region does not fit in the source, the source has not been rendered yet or the device cannot copy depth.

Reimplemented from RHI_DEVICE.

Definition at line 5916 of file rhi_vulkan_device.cpp.

References acquirePassCmd(), beginOneTimeCommands(), RHI_VULKAN_DEVICE::FramebufferAllocation::depthImage, RHI_VULKAN_DEVICE::FramebufferAllocation::depthRendered, RHI_VULKAN_DEVICE::FramebufferAllocation::height, imageBarrier(), m_deviceMutex, m_framebufferPool, m_framebuffers, m_freeCmds, m_renderPassActive, m_vk, RhiHandleIndex(), submitPassCmd(), and RHI_VULKAN_DEVICE::FramebufferAllocation::width.

◆ CreateBindGroup()

◆ CreateBindGroupLayout()

◆ CreateBuffer()

RHI_BufferHandle RHI_DEVICE::CreateBuffer ( const RHI_BUFFER_DESC & desc)
inlineinherited

Reserve and realize in one call, so render thread only.

Returns a null handle on failure.

Definition at line 96 of file rhi_device.h.

References RealizeBuffer(), and ReserveBufferHandle().

◆ CreateComputePipeline()

◆ CreateFramebuffer()

RHI_FramebufferHandle RHI_VULKAN_DEVICE::CreateFramebuffer ( const RHI_FRAMEBUFFER_DESC & desc)
overridevirtual

Returns a null handle on failure.

Implements RHI_DEVICE.

Definition at line 3794 of file rhi_vulkan_device.cpp.

References allocateCommandBuffer(), RHI_VULKAN_DEVICE::TextureAllocation::allocation, beginOneTimeCommands(), RHI_VULKAN_DEVICE::FramebufferAllocation::colorAllocations, RHI_FRAMEBUFFER_DESC::colorFormats, RHI_VULKAN_DEVICE::FramebufferAllocation::colorFormats, RHI_VULKAN_DEVICE::FramebufferAllocation::colorImages, RHI_VULKAN_DEVICE::FramebufferAllocation::colorTextureHandles, RHI_VULKAN_DEVICE::FramebufferAllocation::colorViews, createImage2D(), createSampler(), createView(), RHI_VULKAN_DEVICE::FramebufferAllocation::depthAllocation, RHI_VULKAN_DEVICE::FramebufferAllocation::depthImage, RHI_VULKAN_DEVICE::FramebufferAllocation::depthView, destroyFramebufferObjects(), RHI_VULKAN_DEVICE::TextureAllocation::format, RHI_VULKAN_DEVICE::FramebufferAllocation::framebuffer, RHI_FRAMEBUFFER_DESC::hasDepthStencil, RHI_FRAMEBUFFER_DESC::height, RHI_VULKAN_DEVICE::FramebufferAllocation::height, RHI_VULKAN_DEVICE::TextureAllocation::height, image, RHI_VULKAN_DEVICE::TextureAllocation::image, RHI_VULKAN_DEVICE::TextureAllocation::imageView, RHI_VULKAN_DEVICE::FramebufferAllocation::internalRenderPass, m_allocator, m_commandPool, m_device, m_deviceMutex, m_framebufferPool, m_framebuffers, m_submitSerial, m_submittedCmds, m_texturePool, m_textures, m_vk, makeRenderPass(), RHI_VULKAN_DEVICE::TextureAllocation::ownedByFBO, RhiDefaultDepthFormat(), RhiHandleIndex(), RHI_VULKAN_DEVICE::TextureAllocation::sampler, submitCommands(), traceRhi, TransitionTexture(), TranslateTextureFormat(), RHI_FRAMEBUFFER_DESC::width, RHI_VULKAN_DEVICE::FramebufferAllocation::width, and RHI_VULKAN_DEVICE::TextureAllocation::width.

Referenced by LoadDeviceFunctions().

◆ createImage2D()

bool RHI_VULKAN_DEVICE::createImage2D ( VkFormat aFormat,
uint32_t aWidth,
uint32_t aHeight,
VkImageUsageFlags aUsage,
bool aDedicated,
VkImage & aImage,
VmaAllocation & aAllocation )
private

Definition at line 1944 of file rhi_vulkan_device.cpp.

References m_allocator.

Referenced by CreateFramebuffer(), and RealizeTexture().

◆ CreateLogicalDevice()

bool RHI_VULKAN_DEVICE::CreateLogicalDevice ( )
private

◆ CreatePipeline()

◆ CreateRenderPass()

◆ createSampler()

VkSampler RHI_VULKAN_DEVICE::createSampler ( VkFilter aFilter)
private

Definition at line 1991 of file rhi_vulkan_device.cpp.

References m_device, and m_vk.

Referenced by CreateFramebuffer(), and RealizeTexture().

◆ createSetLayout()

◆ CreateShader()

RHI_ShaderHandle RHI_VULKAN_DEVICE::CreateShader ( const RHI_SHADER_DESC & desc)
overridevirtual

Returns a null handle on failure.

Implements RHI_DEVICE.

Definition at line 2468 of file rhi_vulkan_device.cpp.

References RHI_SHADER_DESC::bytecode, m_device, m_shaderPool, m_shaders, m_vk, module, result, RhiHandleIndex(), RHI_SHADER_DESC::sizeBytes, traceRhi, and VkResultToString().

Referenced by CreateComputePipeline().

◆ CreateSurface()

◆ CreateSwapchain()

◆ CreateSwapchainResources()

◆ CreateTexture()

RHI_TextureHandle RHI_DEVICE::CreateTexture ( const RHI_TEXTURE_DESC & desc)
inlineinherited

Reserve and realize in one call, so render thread only.

Returns a null handle on failure.

Definition at line 130 of file rhi_device.h.

References RealizeTexture(), and ReserveTextureHandle().

◆ createView()

VkImageView RHI_VULKAN_DEVICE::createView ( VkImage aImage,
VkFormat aFormat,
VkImageAspectFlags aAspect )
private

Definition at line 1971 of file rhi_vulkan_device.cpp.

References m_device, and m_vk.

Referenced by CreateFramebuffer(), CreateSwapchainResources(), and RealizeTexture().

◆ CreateVkInstance()

bool RHI_VULKAN_DEVICE::CreateVkInstance ( bool enableValidation)
private

◆ createVkSwapchain()

◆ CurrentThreadOwnsUploadBatch()

bool RHI_VULKAN_DEVICE::CurrentThreadOwnsUploadBatch ( ) const
private

Definition at line 1768 of file rhi_vulkan_device.cpp.

References m_uploadBatchOwner.

Referenced by beginUploadCommands().

◆ deferDestroy()

template<typename Tag>
void RHI_DEVICE::deferDestroy ( RHI_HANDLE_POOL< Tag > & aPool,
RHI_DEFERRED_RESOURCE_TYPE aType,
RHI_HANDLE< Tag > aHandle )
inlineprotectedinherited

◆ DestroyBindGroup()

void RHI_VULKAN_DEVICE::DestroyBindGroup ( RHI_BindGroupHandle handle)
overridevirtual

Implements RHI_DEVICE.

Definition at line 3632 of file rhi_vulkan_device.cpp.

References BIND_GROUP, RHI_DEVICE::deferDestroy(), and m_bindGroupPool.

◆ DestroyBindGroupLayout()

void RHI_VULKAN_DEVICE::DestroyBindGroupLayout ( RHI_BindGroupLayoutHandle handle)
overridevirtual

◆ DestroyBuffer()

void RHI_VULKAN_DEVICE::DestroyBuffer ( RHI_BufferHandle handle)
overridevirtual

The handle's generation is retired, so later use of the stale handle is detected.

Render thread only, as it reads the frame counter. The UI thread destroys through RHI_DEVICE_PROXY.

Implements RHI_DEVICE.

Definition at line 2293 of file rhi_vulkan_device.cpp.

References BUFFER, RHI_DEVICE::deferDestroy(), m_allocator, and m_bufferPool.

◆ DestroyComputePipeline()

void RHI_VULKAN_DEVICE::DestroyComputePipeline ( RHI_ComputePipelineHandle aHandle)
overridevirtual

◆ DestroyFramebuffer()

void RHI_VULKAN_DEVICE::DestroyFramebuffer ( RHI_FramebufferHandle handle)
overridevirtual

Implements RHI_DEVICE.

Definition at line 3981 of file rhi_vulkan_device.cpp.

References RHI_DEVICE::deferDestroy(), FRAMEBUFFER, and m_framebufferPool.

Referenced by LoadDeviceFunctions().

◆ destroyFramebufferObjects()

◆ DestroyPipeline()

void RHI_VULKAN_DEVICE::DestroyPipeline ( RHI_PipelineHandle handle)
overridevirtual

Implements RHI_DEVICE.

Definition at line 2854 of file rhi_vulkan_device.cpp.

References RHI_DEVICE::deferDestroy(), m_pipelinePool, and PIPELINE.

Referenced by LoadDeviceFunctions().

◆ destroyPipeline()

◆ DestroyPresentBlit()

void RHI_VULKAN_DEVICE::DestroyPresentBlit ( )
private

◆ DestroyRenderPass()

void RHI_VULKAN_DEVICE::DestroyRenderPass ( RHI_RenderPassHandle handle)
overridevirtual

Implements RHI_DEVICE.

Definition at line 3788 of file rhi_vulkan_device.cpp.

References RHI_DEVICE::deferDestroy(), m_renderPassPool, and RENDER_PASS.

Referenced by LoadDeviceFunctions().

◆ DestroyShader()

void RHI_VULKAN_DEVICE::DestroyShader ( RHI_ShaderHandle handle)
overridevirtual

Implements RHI_DEVICE.

Definition at line 2509 of file rhi_vulkan_device.cpp.

References RHI_DEVICE::deferDestroy(), m_shaderPool, and SHADER.

Referenced by CreateComputePipeline().

◆ DestroyStagingPool()

void RHI_VULKAN_DEVICE::DestroyStagingPool ( )
private

Definition at line 1755 of file rhi_vulkan_device.cpp.

References m_allocator, m_batchPooledStaging, and m_stagingPool.

Referenced by ~RHI_VULKAN_DEVICE().

◆ DestroySurface()

void RHI_VULKAN_DEVICE::DestroySurface ( RHI_SurfaceHandle handle)
overridevirtual

Destroy the surface's swapchain first.

Implements RHI_DEVICE.

Definition at line 4794 of file rhi_vulkan_device.cpp.

References m_instance, m_surfacePool, m_surfaces, m_vk, and RhiHandleIndex().

◆ DestroySwapchain()

void RHI_VULKAN_DEVICE::DestroySwapchain ( RHI_SwapchainHandle handle)
overridevirtual

◆ destroySwapchainObjects()

◆ DestroySwapchainResources()

◆ DestroyTexture()

void RHI_VULKAN_DEVICE::DestroyTexture ( RHI_TextureHandle handle)
overridevirtual

Render thread only.

See DestroyBuffer().

Implements RHI_DEVICE.

Definition at line 2402 of file rhi_vulkan_device.cpp.

References RHI_DEVICE::deferDestroy(), m_texturePool, and TEXTURE.

◆ destroyTexture()

◆ Draw()

void RHI_VULKAN_DEVICE::Draw ( uint32_t vertexCount,
uint32_t firstVertex = 0 )
overridevirtual

Draws are only valid inside a render pass with a bound pipeline.

Implements RHI_DEVICE.

Definition at line 4242 of file rhi_vulkan_device.cpp.

References m_currentCmd, m_deviceMutex, m_renderPassActive, and m_vk.

◆ DrawIndexedInstanced()

void RHI_VULKAN_DEVICE::DrawIndexedInstanced ( uint32_t indexCount,
uint32_t instanceCount,
uint32_t firstIndex = 0,
int32_t vertexOffset = 0,
uint32_t firstInstance = 0 )
overridevirtual

Reads 16-bit indices from the bound index buffer.

Implements RHI_DEVICE.

Definition at line 4266 of file rhi_vulkan_device.cpp.

References m_currentCmd, m_deviceMutex, m_renderPassActive, and m_vk.

◆ DrawInstanced()

void RHI_VULKAN_DEVICE::DrawInstanced ( uint32_t vertexCount,
uint32_t instanceCount,
uint32_t firstVertex = 0,
int32_t vertexOffset = 0,
uint32_t firstInstance = 0 )
overridevirtual

Non-indexed, so vertexOffset is ignored.

Implements RHI_DEVICE.

Definition at line 4253 of file rhi_vulkan_device.cpp.

References m_currentCmd, m_deviceMutex, m_renderPassActive, and m_vk.

◆ EndFrame()

virtual void RHI_DEVICE::EndFrame ( )
inlinevirtualinherited

Retire deferred releases that are due.

The render thread must call this once per frame after presenting.

Definition at line 348 of file rhi_device.h.

References ExecuteDeferredReleases(), and m_frameCounter.

◆ EndRenderPass()

bool RHI_VULKAN_DEVICE::EndRenderPass ( )
overridevirtual

Returns false if no render pass is active.

Implements RHI_DEVICE.

Definition at line 4093 of file rhi_vulkan_device.cpp.

References m_activePipeline, m_currentCmd, m_deviceMutex, m_renderPassActive, m_vk, result, submitPassCmd(), and traceRhi.

◆ endStagedUpload()

void RHI_VULKAN_DEVICE::endStagedUpload ( VkCommandBuffer aCmd,
std::unique_lock< std::recursive_mutex > & aLock,
int aStaging )
private

Definition at line 1704 of file rhi_vulkan_device.cpp.

References endUploadCommands(), m_batchPooledStaging, and ReleaseStaging().

Referenced by UpdateBuffer(), and UploadTexture().

◆ EndUploadBatch()

void RHI_VULKAN_DEVICE::EndUploadBatch ( )
overridevirtual

◆ endUploadCommands()

bool RHI_VULKAN_DEVICE::endUploadCommands ( VkCommandBuffer aCmd,
const std::unique_lock< std::recursive_mutex > & aLock )
private

Definition at line 1581 of file rhi_vulkan_device.cpp.

References SubmitOneShot().

Referenced by endStagedUpload().

◆ EnsurePresentBlit()

VkPipeline RHI_VULKAN_DEVICE::EnsurePresentBlit ( VkFormat aSwapchainFormat)
private

◆ EnsureUploadCmdBuf()

VkCommandBuffer RHI_VULKAN_DEVICE::EnsureUploadCmdBuf ( )
private

◆ ExecuteCompute()

◆ ExecuteDeferredRelease()

◆ ExecuteDeferredReleases()

void RHI_VULKAN_DEVICE::ExecuteDeferredReleases ( )
overrideprivatevirtual

◆ FindPresentQueueFamily()

bool RHI_VULKAN_DEVICE::FindPresentQueueFamily ( VkSurfaceKHR vkSurface,
uint32_t & outFamily )
private

Definition at line 4278 of file rhi_vulkan_device.cpp.

References m_graphicsQueueFamily, m_physicalDevice, and m_vk.

Referenced by CreateSurface().

◆ GetBackend()

RHI_BACKEND RHI_VULKAN_DEVICE::GetBackend ( ) const
overridevirtual

Implements RHI_DEVICE.

Definition at line 2219 of file rhi_vulkan_device.cpp.

References VULKAN.

◆ GetFramebufferColorTexture()

RHI_TextureHandle RHI_VULKAN_DEVICE::GetFramebufferColorTexture ( RHI_FramebufferHandle handle,
uint32_t attachmentIndex = 0 ) const
overridevirtual

The texture lets a later pass sample the framebuffer.

Returns a null handle if the framebuffer or attachment index is invalid. The framebuffer owns the texture, so never destroy or release it.

Implements RHI_DEVICE.

Definition at line 3987 of file rhi_vulkan_device.cpp.

References m_framebuffers, and RhiHandleIndex().

◆ GetName()

const char * RHI_VULKAN_DEVICE::GetName ( ) const
overridevirtual

Backend and GPU name for display, such as "Vulkan (GeForce RTX 3080)".

Implements RHI_DEVICE.

Definition at line 2213 of file rhi_vulkan_device.cpp.

References m_deviceName.

Referenced by CreatePipeline().

◆ InitCommandPool()

bool RHI_VULKAN_DEVICE::InitCommandPool ( )
private

Definition at line 1421 of file rhi_vulkan_device.cpp.

References m_commandPool, m_device, m_graphicsQueueFamily, and m_vk.

Referenced by RHI_VULKAN_DEVICE().

◆ InitLoader()

bool RHI_VULKAN_DEVICE::InitLoader ( )
private

Definition at line 789 of file rhi_vulkan_device.cpp.

References LoadVulkanFunction(), m_vk, and m_vulkanLib.

Referenced by RHI_VULKAN_DEVICE().

◆ InitVMA()

bool RHI_VULKAN_DEVICE::InitVMA ( )
private

Definition at line 1282 of file rhi_vulkan_device.cpp.

References m_allocator, m_device, m_instance, m_physicalDevice, and m_vk.

Referenced by RHI_VULKAN_DEVICE().

◆ IsInitialized()

bool RHI_VULKAN_DEVICE::IsInitialized ( ) const
overridevirtual

Implements RHI_DEVICE.

Definition at line 2225 of file rhi_vulkan_device.cpp.

References m_initialized.

◆ LastDisplayRefresh()

virtual std::optional< std::chrono::steady_clock::time_point > RHI_DEVICE::LastDisplayRefresh ( RHI_SwapchainHandle aSwapchain) const
inlinevirtualinherited

The vertical blank at which the display last showed a frame, or nothing if the backend cannot tell.

Definition at line 338 of file rhi_device.h.

◆ LoadDeviceFunction()

void * RHI_VULKAN_DEVICE::LoadDeviceFunction ( const char * name)
private

Definition at line 780 of file rhi_vulkan_device.cpp.

References m_device, m_vk, and name.

◆ LoadDeviceFunctions()

void RHI_VULKAN_DEVICE::LoadDeviceFunctions ( )
private

◆ LoadInstanceFunction()

void * RHI_VULKAN_DEVICE::LoadInstanceFunction ( const char * name)
private

Definition at line 771 of file rhi_vulkan_device.cpp.

References m_instance, m_vk, and name.

◆ LoadVulkanFunction()

void * RHI_VULKAN_DEVICE::LoadVulkanFunction ( const char * name)
private

Definition at line 762 of file rhi_vulkan_device.cpp.

References m_vulkanLib, and name.

Referenced by InitLoader().

◆ makeRenderPass()

VkRenderPass RHI_VULKAN_DEVICE::makeRenderPass ( const std::vector< VK_ATTACHMENT > & aColor,
const std::optional< VK_ATTACHMENT > & aDepth )
private

◆ MarkBufferInUse()

void RHI_VULKAN_DEVICE::MarkBufferInUse ( BufferAllocation & aBuffer)
inlineprivate

◆ MaxTextureSize()

uint32_t RHI_VULKAN_DEVICE::MaxTextureSize ( ) const
inlineoverridevirtual

Largest texture width or height in texels.

The default suits every GPU Metal runs on, and a backend that can query its GPU overrides it.

Reimplemented from RHI_DEVICE.

Definition at line 311 of file rhi_vulkan_device.cpp.

References m_maxTextureSize.

◆ OnQueueIdle()

void RHI_VULKAN_DEVICE::OnQueueIdle ( )
private

◆ PendingDeferredReleases()

size_t RHI_DEVICE::PendingDeferredReleases ( ) const
inlineinherited

Releases still waiting on later frames, which only EndFrame() retires.

Definition at line 355 of file rhi_device.h.

References m_deferredReleaseQueue.

◆ PollSurfaceExtent()

◆ Present()

RHI_FRAME_OP_RESULT RHI_VULKAN_DEVICE::Present ( RHI_SwapchainHandle handle,
RHI_FramebufferHandle aSrcFBO = {},
const RHI_SCISSOR_RECT * aSourceRect = nullptr )
overridevirtual

When aSrcFBO is valid its first color attachment is copied to the swapchain first.

OUT_OF_DATE means the swapchain must be recreated, and SURFACE_LOST means the surface must be too.

Parameters
aSourceRectthe part of aSrcFBO to show, in texels in storage order as for CopyFramebufferDepth(), or all of it when null.

Implements RHI_DEVICE.

Definition at line 5375 of file rhi_vulkan_device.cpp.

References allocateCommandBuffer(), beginOneTimeCommands(), RHI_VULKAN_DEVICE::SwapchainAllocation::currentImageIndex, DEVICE_LOST, RHI_VULKAN_DEVICE::SwapchainAllocation::dpiScale, EnsurePresentBlit(), ERROR, RHI_VULKAN_DEVICE::SwapchainAllocation::extent, RHI_VULKAN_DEVICE::SwapchainAllocation::format, RHI_SCISSOR_RECT::height, RHI_VULKAN_DEVICE::SwapchainAllocation::imageAvailable, imageBarrier(), RHI_VULKAN_DEVICE::SwapchainAllocation::images, RHI_VULKAN_DEVICE::SwapchainAllocation::inFlightFence, RHI_VULKAN_DEVICE::SwapchainAllocation::lastLoggedExtent, RHI_VULKAN_DEVICE::SwapchainAllocation::lastPresentCmd, RHI_VULKAN_DEVICE::SwapchainAllocation::lastPresentId, m_commandPool, m_device, m_deviceMutex, m_framebuffers, m_graphicsQueue, m_presentBlitLayout, m_presentWait, m_swapchainPool, m_swapchains, m_textures, m_vk, RHI_VULKAN_DEVICE::SwapchainAllocation::needsResize, OK, OUT_OF_DATE, RHI_VULKAN_DEVICE::SwapchainAllocation::presentAttemptCount, RHI_VULKAN_DEVICE::SwapchainAllocation::presentDescSet, RHI_VULKAN_DEVICE::SwapchainAllocation::presentFramebuffers, RHI_VULKAN_DEVICE::SwapchainAllocation::presentRenderPass, RHI_VULKAN_DEVICE::SwapchainAllocation::renderFinished, RHI_VULKAN_DEVICE::SwapchainAllocation::requestedExtent, ResizeSwapchain(), RhiHandleIndex(), PROF_TIMER::Start(), PROF_TIMER::Stop(), SURFACE_LOST, RHI_VULKAN_DEVICE::SwapchainAllocation::swapchain, traceRhi, VkElapsedMs(), VkResultToString(), RHI_SCISSOR_RECT::width, RHI_SCISSOR_RECT::x, and RHI_SCISSOR_RECT::y.

◆ PresentReplacesQueued()

bool RHI_VULKAN_DEVICE::PresentReplacesQueued ( RHI_SwapchainHandle aSwapchain) const
overridevirtual

True when a present replaces one still queued for the next vertical blank, as in Vulkan MAILBOX mode, so frames drawn faster than the display only cost GPU time.

Reimplemented from RHI_DEVICE.

Definition at line 5367 of file rhi_vulkan_device.cpp.

References m_swapchains, and RhiHandleIndex().

◆ PresentWaitsForDisplay()

bool RHI_VULKAN_DEVICE::PresentWaitsForDisplay ( RHI_SwapchainHandle aSwapchain) const
overridevirtual

False when presents show at once instead of at the next vertical blank, so frames drawn faster than the display refreshes are never seen.

Reimplemented from RHI_DEVICE.

Definition at line 5358 of file rhi_vulkan_device.cpp.

References m_swapchains, and RhiHandleIndex().

◆ ReadbackFramebufferPixels()

bool RHI_VULKAN_DEVICE::ReadbackFramebufferPixels ( RHI_FramebufferHandle handle,
uint32_t attachmentIndex,
void * buffer,
size_t bufferSize )
overridevirtual

◆ ReadDeviceProperties()

void RHI_VULKAN_DEVICE::ReadDeviceProperties ( )
private

◆ RealizeBuffer()

◆ RealizeTexture()

◆ Release() [1/10]

void RHI_DEVICE::Release ( RHI_BindGroupHandle & aHandle)
inlineinherited

Definition at line 267 of file rhi_device.h.

References DestroyBindGroup().

◆ Release() [2/10]

void RHI_DEVICE::Release ( RHI_BindGroupLayoutHandle & aHandle)
inlineinherited

Definition at line 264 of file rhi_device.h.

References DestroyBindGroupLayout().

◆ Release() [3/10]

void RHI_DEVICE::Release ( RHI_BufferHandle & aHandle)
inlineinherited

Destroy the resource, if there is one, and clear the handle.

Definition at line 260 of file rhi_device.h.

References DestroyBuffer().

Referenced by destroyDiffCopies().

◆ Release() [4/10]

void RHI_DEVICE::Release ( RHI_FramebufferHandle & aHandle)
inlineinherited

Definition at line 266 of file rhi_device.h.

References DestroyFramebuffer().

◆ Release() [5/10]

void RHI_DEVICE::Release ( RHI_PipelineHandle & aHandle)
inlineinherited

Definition at line 263 of file rhi_device.h.

References DestroyPipeline().

◆ Release() [6/10]

void RHI_DEVICE::Release ( RHI_RenderPassHandle & aHandle)
inlineinherited

Definition at line 265 of file rhi_device.h.

References DestroyRenderPass().

◆ Release() [7/10]

void RHI_DEVICE::Release ( RHI_ShaderHandle & aHandle)
inlineinherited

Definition at line 262 of file rhi_device.h.

References DestroyShader().

◆ Release() [8/10]

void RHI_DEVICE::Release ( RHI_SurfaceHandle & aHandle)
inlineinherited

Definition at line 268 of file rhi_device.h.

References DestroySurface().

◆ Release() [9/10]

void RHI_DEVICE::Release ( RHI_SwapchainHandle & aHandle)
inlineinherited

Definition at line 269 of file rhi_device.h.

References DestroySwapchain().

◆ Release() [10/10]

void RHI_DEVICE::Release ( RHI_TextureHandle & aHandle)
inlineinherited

Definition at line 261 of file rhi_device.h.

References DestroyTexture().

◆ ReleaseDescriptorSet()

void RHI_VULKAN_DEVICE::ReleaseDescriptorSet ( VkDescriptorPool pool,
VkDescriptorSet dset = VK_NULL_HANDLE )
private

Definition at line 3419 of file rhi_vulkan_device.cpp.

References m_descriptorPools, m_device, m_deviceMutex, and m_vk.

Referenced by CreateBindGroup(), and ExecuteDeferredRelease().

◆ ReleaseStaging()

◆ ReserveBufferHandle()

RHI_BufferHandle RHI_VULKAN_DEVICE::ReserveBufferHandle ( )
overridevirtual

Reserve a handle without creating the GPU buffer, so the UI thread can hand out handles while RealizeBuffer() runs later on the render thread.

Thread-safe. Returns a null handle when the pool is exhausted.

Implements RHI_DEVICE.

Definition at line 2233 of file rhi_vulkan_device.cpp.

References m_bufferPool.

◆ ReserveTextureHandle()

RHI_TextureHandle RHI_VULKAN_DEVICE::ReserveTextureHandle ( )
overridevirtual

Thread-safe handle reservation, realized later by RealizeTexture().

See ReserveBufferHandle().

Implements RHI_DEVICE.

Definition at line 2356 of file rhi_vulkan_device.cpp.

References m_texturePool.

◆ ResizeSwapchain()

◆ SelectPhysicalDevice()

bool RHI_VULKAN_DEVICE::SelectPhysicalDevice ( )
private

Definition at line 991 of file rhi_vulkan_device.cpp.

References m_instance, m_physicalDevice, m_vk, and traceRhi.

Referenced by RHI_VULKAN_DEVICE().

◆ SetPushConstants()

void RHI_VULKAN_DEVICE::SetPushConstants ( const void * data,
size_t sizeBytes )
overridevirtual

Size must not exceed RHI_MAX_PUSH_CONSTANT_BYTES.

Only valid inside a render pass.

Implements RHI_DEVICE.

Definition at line 4173 of file rhi_vulkan_device.cpp.

References m_activePipeline, m_currentCmd, m_deviceMutex, m_pipelinePool, m_pipelines, m_renderPassActive, m_vk, RHI_MAX_PUSH_CONSTANT_BYTES, and RhiHandleIndex().

◆ SetScissor()

void RHI_VULKAN_DEVICE::SetScissor ( const RHI_SCISSOR_RECT & scissor)
overridevirtual

◆ SetViewport()

void RHI_VULKAN_DEVICE::SetViewport ( const RHI_VIEWPORT & viewport)
overridevirtual

◆ stageData()

int RHI_VULKAN_DEVICE::stageData ( const void * aData,
size_t aSizeBytes,
VkBuffer & aBuffer )
private

◆ submitCommands()

VkResult RHI_VULKAN_DEVICE::submitCommands ( VkCommandBuffer aCmd)
private

Definition at line 1457 of file rhi_vulkan_device.cpp.

References m_graphicsQueue, and m_vk.

Referenced by CreateFramebuffer(), ExecuteCompute(), SubmitOneShot(), and submitPassCmd().

◆ SubmitOneShot()

bool RHI_VULKAN_DEVICE::SubmitOneShot ( VkCommandBuffer cmd)
private

◆ submitPassCmd()

VkResult RHI_VULKAN_DEVICE::submitPassCmd ( VkCommandBuffer aCmd)
private

◆ SupportsCompute()

bool RHI_VULKAN_DEVICE::SupportsCompute ( ) const
overridevirtual

Compute defaults keep backends without compute support usable for graphics.

Reimplemented from RHI_DEVICE.

Definition at line 2953 of file rhi_vulkan_device.cpp.

References m_computeQueue, m_initialized, and m_vk.

Referenced by ComputeDeviceLimits(), CreateComputePipeline(), and ExecuteCompute().

◆ SyncSubmittedPasses()

void RHI_VULKAN_DEVICE::SyncSubmittedPasses ( )
private

◆ TransitionTexture()

void RHI_VULKAN_DEVICE::TransitionTexture ( VkCommandBuffer cmd,
TextureAllocation & tex,
VkImageLayout newLayout,
VkPipelineStageFlags srcStage,
VkPipelineStageFlags dstStage )
private

◆ TranslateBufferUsage()

VkBufferUsageFlags RHI_VULKAN_DEVICE::TranslateBufferUsage ( RHI_BUFFER_TYPE type)
staticprivate

Definition at line 1299 of file rhi_vulkan_device.cpp.

References INDEX, STORAGE, UNIFORM, and VERTEX.

Referenced by RealizeBuffer().

◆ TranslateFilter()

VkFilter RHI_VULKAN_DEVICE::TranslateFilter ( RHI_FILTER filter)
staticprivate

Definition at line 1334 of file rhi_vulkan_device.cpp.

References BILINEAR, and filter.

Referenced by RealizeTexture().

◆ TranslateTextureFormat()

VkFormat RHI_VULKAN_DEVICE::TranslateTextureFormat ( RHI_TEXTURE_FORMAT format)
staticprivate

Definition at line 1317 of file rhi_vulkan_device.cpp.

References RGBA8.

Referenced by CreateFramebuffer(), CreatePipeline(), CreateRenderPass(), and RealizeTexture().

◆ UpdateBuffer()

void RHI_VULKAN_DEVICE::UpdateBuffer ( RHI_BufferHandle handle,
const void * data,
size_t sizeBytes,
size_t offset = 0 )
overridevirtual

The buffer need not be mappable.

The backend may go through a staging copy.

Implements RHI_DEVICE.

Definition at line 2302 of file rhi_vulkan_device.cpp.

References beginUploadCommands(), endStagedUpload(), m_allocator, m_bufferPool, m_buffers, m_deviceMutex, m_syncedSerial, m_vk, ReleaseStaging(), RhiHandleIndex(), RhiRangeWithinBuffer(), stageData(), and SyncSubmittedPasses().

◆ UploadTexture()

void RHI_VULKAN_DEVICE::UploadTexture ( RHI_TextureHandle handle,
const void * data,
size_t sizeBytes )
overridevirtual

◆ WaitForPresentSlot()

bool RHI_VULKAN_DEVICE::WaitForPresentSlot ( RHI_SwapchainHandle aSwapchain,
std::chrono::milliseconds aTimeout,
int aAllowed )
overridevirtual

Wait until fewer than aAllowed presents are queued for the display or the timeout passes, so the next frame renders from the newest input.

Returns
true if it had to wait.

Reimplemented from RHI_DEVICE.

Definition at line 5320 of file rhi_vulkan_device.cpp.

References RHI_VULKAN_DEVICE::SwapchainAllocation::inFlightFence, RHI_VULKAN_DEVICE::SwapchainAllocation::lastPresentId, m_device, m_presentWait, m_swapchainPool, m_swapchains, m_vk, result, RhiHandleIndex(), and RHI_VULKAN_DEVICE::SwapchainAllocation::swapchain.

Member Data Documentation

◆ m_activePipeline

RHI_PipelineHandle RHI_VULKAN_DEVICE::m_activePipeline
private

◆ m_allocator

◆ m_batchPooledStaging

std::vector<size_t> RHI_VULKAN_DEVICE::m_batchPooledStaging
private

Definition at line 508 of file rhi_vulkan_device.cpp.

Referenced by DestroyStagingPool(), endStagedUpload(), and EndUploadBatch().

◆ m_bindGroupLayoutPool

RHI_HANDLE_POOL<RHI_TAG_BIND_GROUP_LAYOUT> RHI_VULKAN_DEVICE::m_bindGroupLayoutPool
private

◆ m_bindGroupLayouts

std::unordered_map<uint32_t, BindGroupLayoutAllocation> RHI_VULKAN_DEVICE::m_bindGroupLayouts
private

◆ m_bindGroupPool

RHI_HANDLE_POOL<RHI_TAG_BIND_GROUP> RHI_VULKAN_DEVICE::m_bindGroupPool
private

◆ m_bindGroups

std::unordered_map<uint32_t, BindGroupAllocation> RHI_VULKAN_DEVICE::m_bindGroups
private

◆ m_bufferPool

◆ m_buffers

std::unordered_map<uint32_t, BufferAllocation> RHI_VULKAN_DEVICE::m_buffers
private

◆ m_commandPool

VkCommandPool RHI_VULKAN_DEVICE::m_commandPool = VK_NULL_HANDLE
private

◆ m_computePipelinePool

RHI_HANDLE_POOL<RHI_TAG_COMPUTE_PIPELINE> RHI_VULKAN_DEVICE::m_computePipelinePool
private

◆ m_computePipelines

std::unordered_map<uint32_t, ComputePipelineAllocation> RHI_VULKAN_DEVICE::m_computePipelines
private

◆ m_computeQueue

bool RHI_VULKAN_DEVICE::m_computeQueue = false
private

Definition at line 480 of file rhi_vulkan_device.cpp.

Referenced by CreateLogicalDevice(), and SupportsCompute().

◆ m_computeSubgroupSize

uint32_t RHI_VULKAN_DEVICE::m_computeSubgroupSize = 0
private

Definition at line 481 of file rhi_vulkan_device.cpp.

Referenced by ComputePipelineLimits(), and ReadDeviceProperties().

◆ m_currentCmd

VkCommandBuffer RHI_VULKAN_DEVICE::m_currentCmd = VK_NULL_HANDLE
private

◆ m_debugMessenger

VkDebugUtilsMessengerEXT RHI_VULKAN_DEVICE::m_debugMessenger = VK_NULL_HANDLE
private

Definition at line 461 of file rhi_vulkan_device.cpp.

Referenced by CreateVkInstance(), and ~RHI_VULKAN_DEVICE().

◆ m_deferredReleaseQueue

RHI_DEFERRED_RELEASE_QUEUE RHI_DEVICE::m_deferredReleaseQueue
protectedinherited

◆ m_descriptorPools

std::vector<DescriptorPoolEntry> RHI_VULKAN_DEVICE::m_descriptorPools
private

◆ m_device

◆ m_deviceLimits

VkPhysicalDeviceLimits RHI_VULKAN_DEVICE::m_deviceLimits {}
private

◆ m_deviceMutex

◆ m_deviceName

std::string RHI_VULKAN_DEVICE::m_deviceName
private

Definition at line 485 of file rhi_vulkan_device.cpp.

Referenced by GetName(), ReadDeviceProperties(), and RHI_VULKAN_DEVICE().

◆ m_framebufferPool

◆ m_framebuffers

◆ m_frameCounter

uint64_t RHI_DEVICE::m_frameCounter = 0
protectedinherited

◆ m_freeCmds

std::vector<VkCommandBuffer> RHI_VULKAN_DEVICE::m_freeCmds
private

◆ m_graphicsQueue

VkQueue RHI_VULKAN_DEVICE::m_graphicsQueue = VK_NULL_HANDLE
private

◆ m_graphicsQueueFamily

uint32_t RHI_VULKAN_DEVICE::m_graphicsQueueFamily = UINT32_MAX
private

◆ m_initialized

bool RHI_VULKAN_DEVICE::m_initialized = false
private

◆ m_instance

VkInstance RHI_VULKAN_DEVICE::m_instance = VK_NULL_HANDLE
private

◆ m_maxTextureSize

uint32_t RHI_VULKAN_DEVICE::m_maxTextureSize = 4096
private

Definition at line 477 of file rhi_vulkan_device.cpp.

Referenced by MaxTextureSize(), and ReadDeviceProperties().

◆ m_physicalDevice

VkPhysicalDevice RHI_VULKAN_DEVICE::m_physicalDevice = VK_NULL_HANDLE
private

◆ m_pipelineCache

VkPipelineCache RHI_VULKAN_DEVICE::m_pipelineCache = VK_NULL_HANDLE
private

◆ m_pipelinePool

RHI_HANDLE_POOL<RHI_TAG_PIPELINE> RHI_VULKAN_DEVICE::m_pipelinePool
private

◆ m_pipelines

std::unordered_map<uint32_t, PipelineAllocation> RHI_VULKAN_DEVICE::m_pipelines
private

◆ m_presentBlitDSLayout

VkDescriptorSetLayout RHI_VULKAN_DEVICE::m_presentBlitDSLayout = VK_NULL_HANDLE
private

◆ m_presentBlitLayout

VkPipelineLayout RHI_VULKAN_DEVICE::m_presentBlitLayout = VK_NULL_HANDLE
private

Definition at line 734 of file rhi_vulkan_device.cpp.

Referenced by DestroyPresentBlit(), EnsurePresentBlit(), and Present().

◆ m_presentBlitPipelines

std::unordered_map<VkFormat, VkPipeline> RHI_VULKAN_DEVICE::m_presentBlitPipelines
private

Definition at line 733 of file rhi_vulkan_device.cpp.

Referenced by DestroyPresentBlit(), and EnsurePresentBlit().

◆ m_presentWait

bool RHI_VULKAN_DEVICE::m_presentWait = false
private

◆ m_renderPassActive

◆ m_renderPasses

std::unordered_map<uint32_t, RenderPassAllocation> RHI_VULKAN_DEVICE::m_renderPasses
private

◆ m_renderPassPool

RHI_HANDLE_POOL<RHI_TAG_RENDER_PASS> RHI_VULKAN_DEVICE::m_renderPassPool
private

◆ m_shaderPool

RHI_HANDLE_POOL<RHI_TAG_SHADER> RHI_VULKAN_DEVICE::m_shaderPool
private

◆ m_shaders

std::unordered_map<uint32_t, ShaderAllocation> RHI_VULKAN_DEVICE::m_shaders
private

◆ m_stagingPool

std::vector<StagingBuffer> RHI_VULKAN_DEVICE::m_stagingPool
private

◆ m_storageDescriptors

bool RHI_VULKAN_DEVICE::m_storageDescriptors = false
private

Definition at line 482 of file rhi_vulkan_device.cpp.

Referenced by AcquireDescriptorPool(), and CreateBindGroupLayout().

◆ m_submitSerial

uint64_t RHI_VULKAN_DEVICE::m_submitSerial = 0
private

◆ m_submittedCmds

std::vector<VkCommandBuffer> RHI_VULKAN_DEVICE::m_submittedCmds
private

Definition at line 746 of file rhi_vulkan_device.cpp.

Referenced by CreateFramebuffer(), OnQueueIdle(), and submitPassCmd().

◆ m_surfacePool

RHI_HANDLE_POOL<RHI_TAG_SURFACE> RHI_VULKAN_DEVICE::m_surfacePool
private

◆ m_surfaces

std::unordered_map<uint32_t, SurfaceAllocation> RHI_VULKAN_DEVICE::m_surfaces
private

◆ m_swapchainPool

RHI_HANDLE_POOL<RHI_TAG_SWAPCHAIN> RHI_VULKAN_DEVICE::m_swapchainPool
private

◆ m_swapchains

◆ m_syncedSerial

uint64_t RHI_VULKAN_DEVICE::m_syncedSerial = 0
private

Definition at line 749 of file rhi_vulkan_device.cpp.

Referenced by OnQueueIdle(), SyncSubmittedPasses(), and UpdateBuffer().

◆ m_texturePool

◆ m_textures

std::unordered_map<uint32_t, TextureAllocation> RHI_VULKAN_DEVICE::m_textures
private

◆ m_totalPipelineCreateMs

double RHI_VULKAN_DEVICE::m_totalPipelineCreateMs = 0.0
private

Definition at line 474 of file rhi_vulkan_device.cpp.

Referenced by CreatePipeline().

◆ m_uploadBatchOwner

std::atomic<std::thread::id> RHI_VULKAN_DEVICE::m_uploadBatchOwner { std::thread::id{} }
private

◆ m_uploadCmdBuf

VkCommandBuffer RHI_VULKAN_DEVICE::m_uploadCmdBuf = VK_NULL_HANDLE
private

Definition at line 491 of file rhi_vulkan_device.cpp.

Referenced by BeginUploadBatch(), EndUploadBatch(), and EnsureUploadCmdBuf().

◆ m_vk

VulkanFunctions RHI_VULKAN_DEVICE::m_vk
private

◆ m_vulkanLib

wxDynamicLibrary RHI_VULKAN_DEVICE::m_vulkanLib
private

Definition at line 459 of file rhi_vulkan_device.cpp.

Referenced by InitLoader(), LoadVulkanFunction(), and ~RHI_VULKAN_DEVICE().

◆ STAGING_MIN_BYTES

size_t RHI_VULKAN_DEVICE::STAGING_MIN_BYTES = 64 * 1024
staticconstexprprivate

Definition at line 504 of file rhi_vulkan_device.cpp.

Referenced by AcquireStaging().

◆ STAGING_POOL_BYTES

size_t RHI_VULKAN_DEVICE::STAGING_POOL_BYTES = 256 * 1024 * 1024
staticconstexprprivate

Definition at line 505 of file rhi_vulkan_device.cpp.

Referenced by ReleaseStaging().


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