KiCad PCB EDA Suite
Loading...
Searching...
No Matches
RHI_DEVICE Class Referenceabstract

Creates, uses and destroys GPU resources through one graphics API backend. More...

#include <rhi_device.h>

Inheritance diagram for RHI_DEVICE:
RHI_VULKAN_DEVICE

Public Member Functions

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

virtual void ExecuteDeferredReleases ()=0
 
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
 

Detailed Description

Creates, uses and destroys GPU resources through one graphics API backend.

RhiCreatePlatformDevice() creates the backend a platform is built with.

Definition at line 65 of file rhi_device.h.

Constructor & Destructor Documentation

◆ ~RHI_DEVICE()

virtual RHI_DEVICE::~RHI_DEVICE ( )
virtualdefault

Member Function Documentation

◆ BeginRenderPass()

virtual bool RHI_DEVICE::BeginRenderPass ( const RHI_RENDER_PASS_BEGIN_DESC & desc)
pure virtual

Draws and dynamic state changes must come between this and EndRenderPass().

Returns false if a render pass is already active or a handle is invalid.

Implemented in RHI_VULKAN_DEVICE.

◆ BeginUploadBatch()

virtual void RHI_DEVICE::BeginUploadBatch ( )
inlinevirtual

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

The default does nothing.

Reimplemented in RHI_VULKAN_DEVICE.

Definition at line 159 of file rhi_device.h.

◆ BindGroup()

virtual void RHI_DEVICE::BindGroup ( uint32_t groupIndex,
RHI_BindGroupHandle group )
pure virtual

Only valid inside a render pass with a bound pipeline.

Implemented in RHI_VULKAN_DEVICE.

References group.

◆ BindIndexBuffer()

virtual void RHI_DEVICE::BindIndexBuffer ( RHI_BufferHandle buffer)
pure virtual

Indices are 16 bits on every backend.

Only valid inside a render pass.

Implemented in RHI_VULKAN_DEVICE.

◆ BindPipeline()

virtual void RHI_DEVICE::BindPipeline ( RHI_PipelineHandle pipeline)
pure virtual

Only valid inside a render pass.

Implemented in RHI_VULKAN_DEVICE.

◆ BindVertexBuffer()

virtual void RHI_DEVICE::BindVertexBuffer ( uint32_t slot,
RHI_BufferHandle buffer )
pure virtual

Only valid inside a render pass.

Implemented in RHI_VULKAN_DEVICE.

◆ ComputeDeviceLimits()

virtual RHI_COMPUTE_DEVICE_LIMITS RHI_DEVICE::ComputeDeviceLimits ( ) const
inlinevirtual

Reimplemented in RHI_VULKAN_DEVICE.

Definition at line 72 of file rhi_device.h.

◆ ComputePipelineLimits()

virtual RHI_COMPUTE_PIPELINE_LIMITS RHI_DEVICE::ComputePipelineLimits ( RHI_ComputePipelineHandle ) const
inlinevirtual

Reimplemented in RHI_VULKAN_DEVICE.

Definition at line 75 of file rhi_device.h.

◆ CopyFramebufferDepth()

virtual bool RHI_DEVICE::CopyFramebufferDepth ( RHI_FramebufferHandle aSource,
RHI_FramebufferHandle aDestination,
uint32_t aSourceX = 0,
uint32_t aSourceY = 0 )
inlinevirtual

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 in RHI_VULKAN_DEVICE.

Definition at line 297 of file rhi_device.h.

◆ CreateBindGroup()

virtual RHI_BindGroupHandle RHI_DEVICE::CreateBindGroup ( const RHI_BIND_GROUP_DESC & desc)
pure virtual

Returns a null handle on failure.

Implemented in RHI_VULKAN_DEVICE.

◆ CreateBindGroupLayout()

virtual RHI_BindGroupLayoutHandle RHI_DEVICE::CreateBindGroupLayout ( const RHI_BIND_GROUP_LAYOUT_DESC & desc)
pure virtual

Returns a null handle on failure.

Implemented in RHI_VULKAN_DEVICE.

◆ CreateBuffer()

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

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()

virtual RHI_ComputePipelineHandle RHI_DEVICE::CreateComputePipeline ( const RHI_COMPUTE_PIPELINE_DESC & )
inlinevirtual

Reimplemented in RHI_VULKAN_DEVICE.

Definition at line 73 of file rhi_device.h.

◆ CreateFramebuffer()

virtual RHI_FramebufferHandle RHI_DEVICE::CreateFramebuffer ( const RHI_FRAMEBUFFER_DESC & desc)
pure virtual

Returns a null handle on failure.

Implemented in RHI_VULKAN_DEVICE.

◆ CreatePipeline()

virtual RHI_PipelineHandle RHI_DEVICE::CreatePipeline ( const RHI_PIPELINE_DESC & desc)
pure virtual

Returns a null handle on failure.

Implemented in RHI_VULKAN_DEVICE.

◆ CreateRenderPass()

virtual RHI_RenderPassHandle RHI_DEVICE::CreateRenderPass ( const RHI_RENDER_PASS_DESC & desc)
pure virtual

Returns a null handle on failure.

Implemented in RHI_VULKAN_DEVICE.

◆ CreateShader()

virtual RHI_ShaderHandle RHI_DEVICE::CreateShader ( const RHI_SHADER_DESC & desc)
pure virtual

Returns a null handle on failure.

Implemented in RHI_VULKAN_DEVICE.

◆ CreateSurface()

virtual RHI_SurfaceHandle RHI_DEVICE::CreateSurface ( const RHI_SURFACE_DESC & desc)
pure virtual

Returns a null handle if the native window handle is invalid.

Implemented in RHI_VULKAN_DEVICE.

◆ CreateSwapchain()

virtual RHI_SwapchainHandle RHI_DEVICE::CreateSwapchain ( const RHI_SWAPCHAIN_DESC & desc)
pure virtual

Returns a null handle on failure.

Implemented in RHI_VULKAN_DEVICE.

◆ CreateTexture()

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

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().

◆ deferDestroy()

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

◆ DestroyBindGroup()

virtual void RHI_DEVICE::DestroyBindGroup ( RHI_BindGroupHandle handle)
pure virtual

Implemented in RHI_VULKAN_DEVICE.

Referenced by Release().

◆ DestroyBindGroupLayout()

virtual void RHI_DEVICE::DestroyBindGroupLayout ( RHI_BindGroupLayoutHandle handle)
pure virtual

Implemented in RHI_VULKAN_DEVICE.

Referenced by Release().

◆ DestroyBuffer()

virtual void RHI_DEVICE::DestroyBuffer ( RHI_BufferHandle handle)
pure virtual

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.

Implemented in RHI_VULKAN_DEVICE.

Referenced by Release().

◆ DestroyComputePipeline()

virtual void RHI_DEVICE::DestroyComputePipeline ( RHI_ComputePipelineHandle )
inlinevirtual

Reimplemented in RHI_VULKAN_DEVICE.

Definition at line 74 of file rhi_device.h.

◆ DestroyFramebuffer()

virtual void RHI_DEVICE::DestroyFramebuffer ( RHI_FramebufferHandle handle)
pure virtual

Implemented in RHI_VULKAN_DEVICE.

Referenced by Release().

◆ DestroyPipeline()

virtual void RHI_DEVICE::DestroyPipeline ( RHI_PipelineHandle handle)
pure virtual

Implemented in RHI_VULKAN_DEVICE.

Referenced by Release().

◆ DestroyRenderPass()

virtual void RHI_DEVICE::DestroyRenderPass ( RHI_RenderPassHandle handle)
pure virtual

Implemented in RHI_VULKAN_DEVICE.

Referenced by Release().

◆ DestroyShader()

virtual void RHI_DEVICE::DestroyShader ( RHI_ShaderHandle handle)
pure virtual

Implemented in RHI_VULKAN_DEVICE.

Referenced by Release().

◆ DestroySurface()

virtual void RHI_DEVICE::DestroySurface ( RHI_SurfaceHandle handle)
pure virtual

Destroy the surface's swapchain first.

Implemented in RHI_VULKAN_DEVICE.

Referenced by Release().

◆ DestroySwapchain()

virtual void RHI_DEVICE::DestroySwapchain ( RHI_SwapchainHandle handle)
pure virtual

Implemented in RHI_VULKAN_DEVICE.

Referenced by Release().

◆ DestroyTexture()

virtual void RHI_DEVICE::DestroyTexture ( RHI_TextureHandle handle)
pure virtual

Render thread only.

See DestroyBuffer().

Implemented in RHI_VULKAN_DEVICE.

Referenced by Release().

◆ Draw()

virtual void RHI_DEVICE::Draw ( uint32_t vertexCount,
uint32_t firstVertex = 0 )
pure virtual

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

Implemented in RHI_VULKAN_DEVICE.

◆ DrawIndexedInstanced()

virtual void RHI_DEVICE::DrawIndexedInstanced ( uint32_t indexCount,
uint32_t instanceCount,
uint32_t firstIndex = 0,
int32_t vertexOffset = 0,
uint32_t firstInstance = 0 )
pure virtual

Reads 16-bit indices from the bound index buffer.

Implemented in RHI_VULKAN_DEVICE.

◆ DrawInstanced()

virtual void RHI_DEVICE::DrawInstanced ( uint32_t vertexCount,
uint32_t instanceCount,
uint32_t firstVertex = 0,
int32_t vertexOffset = 0,
uint32_t firstInstance = 0 )
pure virtual

Non-indexed, so vertexOffset is ignored.

Implemented in RHI_VULKAN_DEVICE.

◆ EndFrame()

virtual void RHI_DEVICE::EndFrame ( )
inlinevirtual

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()

virtual bool RHI_DEVICE::EndRenderPass ( )
pure virtual

Returns false if no render pass is active.

Implemented in RHI_VULKAN_DEVICE.

◆ EndUploadBatch()

virtual void RHI_DEVICE::EndUploadBatch ( )
inlinevirtual

Reimplemented in RHI_VULKAN_DEVICE.

Definition at line 160 of file rhi_device.h.

◆ ExecuteCompute()

virtual RHI_COMPUTE_RESULT RHI_DEVICE::ExecuteCompute ( const RHI_COMPUTE_JOB & )
inlinevirtual

Submit, wait for completion, and copy all readbacks before returning.

Reimplemented in RHI_VULKAN_DEVICE.

Definition at line 78 of file rhi_device.h.

References INVALID.

◆ ExecuteDeferredReleases()

virtual void RHI_DEVICE::ExecuteDeferredReleases ( )
protectedpure virtual

Implemented in RHI_VULKAN_DEVICE.

Referenced by EndFrame().

◆ GetBackend()

virtual RHI_BACKEND RHI_DEVICE::GetBackend ( ) const
pure virtual

Implemented in RHI_VULKAN_DEVICE.

◆ GetFramebufferColorTexture()

virtual RHI_TextureHandle RHI_DEVICE::GetFramebufferColorTexture ( RHI_FramebufferHandle handle,
uint32_t attachmentIndex = 0 ) const
pure virtual

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.

Implemented in RHI_VULKAN_DEVICE.

◆ GetName()

virtual const char * RHI_DEVICE::GetName ( ) const
pure virtual

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

Implemented in RHI_VULKAN_DEVICE.

◆ IsInitialized()

virtual bool RHI_DEVICE::IsInitialized ( ) const
pure virtual

Implemented in RHI_VULKAN_DEVICE.

◆ LastDisplayRefresh()

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

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.

◆ MaxTextureSize()

virtual uint32_t RHI_DEVICE::MaxTextureSize ( ) const
inlinevirtual

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 in RHI_VULKAN_DEVICE.

Definition at line 89 of file rhi_device.h.

◆ PendingDeferredReleases()

size_t RHI_DEVICE::PendingDeferredReleases ( ) const
inline

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

Definition at line 355 of file rhi_device.h.

References m_deferredReleaseQueue.

◆ PollSurfaceExtent()

virtual RHI_SURFACE_EXTENT_POLL_RESULT RHI_DEVICE::PollSurfaceExtent ( RHI_SwapchainHandle aSwapchain)
inlinevirtual

Retry a fixed surface extent that lagged behind the requested window size.

Reimplemented in RHI_VULKAN_DEVICE.

Definition at line 316 of file rhi_device.h.

References IDLE.

◆ Present()

virtual RHI_FRAME_OP_RESULT RHI_DEVICE::Present ( RHI_SwapchainHandle handle,
RHI_FramebufferHandle aSrcFBO = {},
const RHI_SCISSOR_RECT * aSourceRect = nullptr )
pure virtual

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.

Implemented in RHI_VULKAN_DEVICE.

◆ PresentReplacesQueued()

virtual bool RHI_DEVICE::PresentReplacesQueued ( RHI_SwapchainHandle aSwapchain) const
inlinevirtual

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 in RHI_VULKAN_DEVICE.

Definition at line 331 of file rhi_device.h.

◆ PresentWaitsForDisplay()

virtual bool RHI_DEVICE::PresentWaitsForDisplay ( RHI_SwapchainHandle aSwapchain) const
inlinevirtual

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 in RHI_VULKAN_DEVICE.

Definition at line 325 of file rhi_device.h.

◆ ReadbackFramebufferPixels()

virtual bool RHI_DEVICE::ReadbackFramebufferPixels ( RHI_FramebufferHandle handle,
uint32_t attachmentIndex,
void * buffer,
size_t bufferSize )
pure virtual

buffer must hold at least width * height * bpp bytes.

Returns false if the handle or attachment index is invalid or the backend cannot read back.

Implemented in RHI_VULKAN_DEVICE.

◆ RealizeBuffer()

virtual bool RHI_DEVICE::RealizeBuffer ( RHI_BufferHandle handle,
const RHI_BUFFER_DESC & desc )
pure virtual

Create the GPU buffer for a reserved handle.

Render thread only. On failure the handle is released and false is returned.

Implemented in RHI_VULKAN_DEVICE.

Referenced by CreateBuffer().

◆ RealizeTexture()

virtual bool RHI_DEVICE::RealizeTexture ( RHI_TextureHandle handle,
const RHI_TEXTURE_DESC & desc )
pure virtual

Create the GPU texture for a reserved handle.

Render thread only. On failure the handle is released and false is returned.

Implemented in RHI_VULKAN_DEVICE.

Referenced by CreateTexture().

◆ Release() [1/10]

void RHI_DEVICE::Release ( RHI_BindGroupHandle & aHandle)
inline

Definition at line 267 of file rhi_device.h.

References DestroyBindGroup().

◆ Release() [2/10]

void RHI_DEVICE::Release ( RHI_BindGroupLayoutHandle & aHandle)
inline

Definition at line 264 of file rhi_device.h.

References DestroyBindGroupLayout().

◆ Release() [3/10]

void RHI_DEVICE::Release ( RHI_BufferHandle & aHandle)
inline

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)
inline

Definition at line 266 of file rhi_device.h.

References DestroyFramebuffer().

◆ Release() [5/10]

void RHI_DEVICE::Release ( RHI_PipelineHandle & aHandle)
inline

Definition at line 263 of file rhi_device.h.

References DestroyPipeline().

◆ Release() [6/10]

void RHI_DEVICE::Release ( RHI_RenderPassHandle & aHandle)
inline

Definition at line 265 of file rhi_device.h.

References DestroyRenderPass().

◆ Release() [7/10]

void RHI_DEVICE::Release ( RHI_ShaderHandle & aHandle)
inline

Definition at line 262 of file rhi_device.h.

References DestroyShader().

◆ Release() [8/10]

void RHI_DEVICE::Release ( RHI_SurfaceHandle & aHandle)
inline

Definition at line 268 of file rhi_device.h.

References DestroySurface().

◆ Release() [9/10]

void RHI_DEVICE::Release ( RHI_SwapchainHandle & aHandle)
inline

Definition at line 269 of file rhi_device.h.

References DestroySwapchain().

◆ Release() [10/10]

void RHI_DEVICE::Release ( RHI_TextureHandle & aHandle)
inline

Definition at line 261 of file rhi_device.h.

References DestroyTexture().

◆ ReserveBufferHandle()

virtual RHI_BufferHandle RHI_DEVICE::ReserveBufferHandle ( )
pure virtual

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.

Implemented in RHI_VULKAN_DEVICE.

Referenced by CreateBuffer().

◆ ReserveTextureHandle()

virtual RHI_TextureHandle RHI_DEVICE::ReserveTextureHandle ( )
pure virtual

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

See ReserveBufferHandle().

Implemented in RHI_VULKAN_DEVICE.

Referenced by CreateTexture().

◆ ResizeSwapchain()

virtual bool RHI_DEVICE::ResizeSwapchain ( RHI_SwapchainHandle handle,
uint32_t width,
uint32_t height,
float dpiScale )
pure virtual

Call when the window size or DPI scale changes.

Returns false on failure.

Implemented in RHI_VULKAN_DEVICE.

◆ SetPushConstants()

virtual void RHI_DEVICE::SetPushConstants ( const void * data,
size_t sizeBytes )
pure virtual

Size must not exceed RHI_MAX_PUSH_CONSTANT_BYTES.

Only valid inside a render pass.

Implemented in RHI_VULKAN_DEVICE.

◆ SetScissor()

virtual void RHI_DEVICE::SetScissor ( const RHI_SCISSOR_RECT & scissor)
pure virtual

Only valid inside a render pass.

Implemented in RHI_VULKAN_DEVICE.

◆ SetViewport()

virtual void RHI_DEVICE::SetViewport ( const RHI_VIEWPORT & viewport)
pure virtual

Only valid inside a render pass.

Implemented in RHI_VULKAN_DEVICE.

◆ SupportsCompute()

virtual bool RHI_DEVICE::SupportsCompute ( ) const
inlinevirtual

Compute defaults keep backends without compute support usable for graphics.

Reimplemented in RHI_VULKAN_DEVICE.

Definition at line 71 of file rhi_device.h.

◆ UpdateBuffer()

virtual void RHI_DEVICE::UpdateBuffer ( RHI_BufferHandle handle,
const void * data,
size_t sizeBytes,
size_t offset = 0 )
pure virtual

The buffer need not be mappable.

The backend may go through a staging copy.

Implemented in RHI_VULKAN_DEVICE.

◆ UploadTexture()

virtual void RHI_DEVICE::UploadTexture ( RHI_TextureHandle handle,
const void * data,
size_t sizeBytes )
pure virtual

Data is tightly packed rows in the texture's format, exactly width * height * bpp bytes.

Implemented in RHI_VULKAN_DEVICE.

◆ WaitForPresentSlot()

virtual bool RHI_DEVICE::WaitForPresentSlot ( RHI_SwapchainHandle aSwapchain,
std::chrono::milliseconds aTimeout,
int aAllowed )
inlinevirtual

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 in RHI_VULKAN_DEVICE.

Definition at line 309 of file rhi_device.h.

Member Data Documentation

◆ m_deferredReleaseQueue

◆ m_frameCounter

uint64_t RHI_DEVICE::m_frameCounter = 0
protected

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