Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QVkCommandBuffer Struct Reference

#include <qrhivulkan_p.h>

Inheritance diagram for QVkCommandBuffer:
Collaboration diagram for QVkCommandBuffer:

Classes

struct  Command

Public Types

enum  PassType { NoPass , RenderPass , ComputePass }
Public Types inherited from QRhiCommandBuffer
enum  IndexFormat { IndexUInt16 , IndexUInt32 }
 Specifies the index data type. More...
enum  BeginPassFlag { ExternalContent = 0x01 , DoNotTrackResourcesForCompute = 0x02 }
 Flag values for QRhi::beginPass() More...
using DynamicOffset = std::pair<int, quint32>
 Synonym for std::pair<int, quint32>.
using VertexInput = std::pair<QRhiBuffer *, quint32>
 Synonym for std::pair<QRhiBuffer *, quint32>.
Public Types inherited from QRhiResource
enum  Type {
  Buffer , Texture , Sampler , RenderBuffer ,
  RenderPassDescriptor , SwapChainRenderTarget , TextureRenderTarget , ShaderResourceBindings ,
  GraphicsPipeline , SwapChain , ComputePipeline , CommandBuffer ,
  ShadingRateMap
}
 Specifies type of the resource. More...

Public Member Functions

 QVkCommandBuffer (QRhiImplementation *rhi)
 ~QVkCommandBuffer ()
void destroy () override
 Releases (or requests deferred releasing of) the underlying native graphics resources.
const QRhiNativeHandlesnativeHandles ()
void resetState ()
void resetPerPassState ()
void resetCommands ()
void resetPools ()
Public Member Functions inherited from QRhiCommandBuffer
QRhiResource::Type resourceType () const override
void resourceUpdate (QRhiResourceUpdateBatch *resourceUpdates)
 Sometimes committing resource updates is necessary or just more convenient without starting a render pass.
void beginPass (QRhiRenderTarget *rt, const QColor &colorClearValue, const QRhiDepthStencilClearValue &depthStencilClearValue, QRhiResourceUpdateBatch *resourceUpdates=nullptr, BeginPassFlags flags={})
 Records starting a new render pass targeting the render target rt.
void endPass (QRhiResourceUpdateBatch *resourceUpdates=nullptr)
 Records ending the current render pass.
void setGraphicsPipeline (QRhiGraphicsPipeline *ps)
 Records setting a new graphics pipeline ps.
void setShaderResources (QRhiShaderResourceBindings *srb=nullptr, int dynamicOffsetCount=0, const DynamicOffset *dynamicOffsets=nullptr)
 Records binding a set of shader resources, such as, uniform buffers or textures, that are made visible to one or more shader stages.
void setVertexInput (int startBinding, int bindingCount, const VertexInput *bindings, QRhiBuffer *indexBuf=nullptr, quint32 indexOffset=0, IndexFormat indexFormat=IndexUInt16)
 Records vertex input bindings.
void setViewport (const QRhiViewport &viewport)
 Records setting the active viewport rectangle specified in viewport.
void setScissor (const QRhiScissor &scissor)
 Records setting the active scissor rectangle specified in scissor.
void setBlendConstants (const QColor &c)
 Records setting the active blend constants to c.
void setStencilRef (quint32 refValue)
 Records setting the active stencil reference value to refValue.
void setShadingRate (const QSize &coarsePixelSize)
 Sets the shading rate for the following draw calls to coarsePixelSize.
void draw (quint32 vertexCount, quint32 instanceCount=1, quint32 firstVertex=0, quint32 firstInstance=0)
 Records a non-indexed draw.
void drawIndexed (quint32 indexCount, quint32 instanceCount=1, quint32 firstIndex=0, qint32 vertexOffset=0, quint32 firstInstance=0)
 Records an indexed draw.
void debugMarkBegin (const QByteArray &name)
 Records a named debug group on the command buffer with the specified name.
void debugMarkEnd ()
 Records the end of a debug group.
void debugMarkMsg (const QByteArray &msg)
 Inserts a debug message msg into the command stream.
void beginComputePass (QRhiResourceUpdateBatch *resourceUpdates=nullptr, BeginPassFlags flags={})
 Records starting a new compute pass.
void endComputePass (QRhiResourceUpdateBatch *resourceUpdates=nullptr)
 Records ending the current compute pass.
void setComputePipeline (QRhiComputePipeline *ps)
 Records setting a new compute pipeline ps.
void dispatch (int x, int y, int z)
 Records dispatching compute work items, with x, y, and z specifying the number of local workgroups in the corresponding dimension.
const QRhiNativeHandlesnativeHandles ()
void beginExternal ()
 To be called when the application before the application is about to enqueue commands to the current pass' command buffer by calling graphics API functions directly.
void endExternal ()
 To be called once the externally added commands are recorded to the command buffer or context.
double lastCompletedGpuTime ()
Public Member Functions inherited from QRhiResource
virtual ~QRhiResource ()
 Destructor.
void deleteLater ()
 When called without a frame being recorded, this function is equivalent to deleting the object.
QByteArray name () const
void setName (const QByteArray &name)
 Sets a name for the object.
quint64 globalResourceId () const
QRhirhi () const

Public Attributes

VkCommandBuffer cb = VK_NULL_HANDLE
QRhiVulkanCommandBufferNativeHandles nativeHandlesStruct
PassType recordingPass
bool passUsesSecondaryCb
double lastGpuTime = 0
QRhiRenderTargetcurrentTarget
QRhiGraphicsPipelinecurrentGraphicsPipeline
QRhiComputePipelinecurrentComputePipeline
uint currentPipelineGeneration
QRhiShaderResourceBindingscurrentGraphicsSrb
QRhiShaderResourceBindingscurrentComputeSrb
uint currentSrbGeneration
int currentDescSetSlot
VkBuffer currentIndexBuffer
quint32 currentIndexOffset
VkIndexType currentIndexFormat
VkBuffer currentVertexBuffers [VERTEX_INPUT_RESOURCE_SLOT_COUNT]
quint32 currentVertexOffsets [VERTEX_INPUT_RESOURCE_SLOT_COUNT]
QVarLengthArray< VkCommandBuffer, 4 > activeSecondaryCbStack
bool inExternal
bool hasShadingRateSet
struct { 
   QHash< QRhiResource *, std::pair< VkAccessFlags, bool > >   writtenResources 
computePassState
QRhiBackendCommandList< Commandcommands
QVector< QRhiPassResourceTrackerpassResTrackers
int currentPassResTrackerIndex
struct { 
   QVarLengthArray< VkClearValue, 4 >   clearValue 
   QVarLengthArray< VkBufferImageCopy, 16 >   bufferImageCopy 
   QVarLengthArray< uint32_t, 4 >   dynamicOffset 
   QVarLengthArray< VkBuffer, 4 >   vertexBuffer 
   QVarLengthArray< VkDeviceSize, 4 >   vertexBufferOffset 
   QVarLengthArray< QByteArray, 4 >   debugMarkerData 
   QVarLengthArray< VkImageMemoryBarrier, 8 >   imageBarrier 
   QVarLengthArray< VkBufferMemoryBarrier, 8 >   bufferBarrier 
pools

Static Public Attributes

static const int VERTEX_INPUT_RESOURCE_SLOT_COUNT = 32

Friends

class QRhiVulkan

Additional Inherited Members

Protected Member Functions inherited from QRhiCommandBuffer
 QRhiCommandBuffer (QRhiImplementation *rhi)
Protected Member Functions inherited from QRhiResource
 QRhiResource (QRhiImplementation *rhi)
Protected Attributes inherited from QRhiResource
QRhiImplementationm_rhi = nullptr
quint64 m_id
QByteArray m_objectName

Detailed Description

Definition at line 329 of file qrhivulkan_p.h.

Member Enumeration Documentation

◆ PassType

Enumerator
NoPass 
RenderPass 
ComputePass 

Definition at line 340 of file qrhivulkan_p.h.

Constructor & Destructor Documentation

◆ QVkCommandBuffer()

QVkCommandBuffer::QVkCommandBuffer ( QRhiImplementation * rhi)

Definition at line 8582 of file qrhivulkan.cpp.

References QVkCommandBuffer(), and resetState().

Referenced by QRhiVulkan::OffscreenFrame::OffscreenFrame(), and QVkCommandBuffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~QVkCommandBuffer()

QVkCommandBuffer::~QVkCommandBuffer ( )

Definition at line 8588 of file qrhivulkan.cpp.

References destroy().

Here is the call graph for this function:

Member Function Documentation

◆ destroy()

void QVkCommandBuffer::destroy ( )
overridevirtual

Releases (or requests deferred releasing of) the underlying native graphics resources.

Safe to call multiple times, subsequent invocations will be a no-op then.

Once destroy() is called, the QRhiResource instance can be reused, by calling create() again. That will then result in creating new native graphics resources underneath.

Note
Resources referenced by commands for the current frame should not be released until the frame is submitted by QRhi::endFrame().

The QRhiResource destructor also performs the same task, so calling this function is not necessary before deleting a QRhiResource.

See also
deleteLater()

Implements QRhiResource.

Definition at line 8593 of file qrhivulkan.cpp.

Referenced by ~QVkCommandBuffer().

Here is the caller graph for this function:

◆ nativeHandles()

const QRhiNativeHandles * QVkCommandBuffer::nativeHandles ( )

Definition at line 8598 of file qrhivulkan.cpp.

References NoPass, and recordingPass.

◆ resetCommands()

void QVkCommandBuffer::resetCommands ( )
inline

Definition at line 566 of file qrhivulkan_p.h.

References currentPassResTrackerIndex, and resetPools().

Referenced by QRhiVulkan::beginExternal(), QRhiVulkan::finish(), and resetState().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetPerPassState()

void QVkCommandBuffer::resetPerPassState ( )
inline

Definition at line 356 of file qrhivulkan_p.h.

References currentDescSetSlot, hasShadingRateSet, and inExternal.

Referenced by QRhiVulkan::beginComputePass(), QRhiVulkan::beginPass(), QRhiVulkan::endExternal(), and resetState().

Here is the caller graph for this function:

◆ resetPools()

void QVkCommandBuffer::resetPools ( )
inline

Definition at line 574 of file qrhivulkan_p.h.

Referenced by resetCommands().

Here is the caller graph for this function:

◆ resetState()

void QVkCommandBuffer::resetState ( )
inline

Definition at line 346 of file qrhivulkan_p.h.

References lastGpuTime, NoPass, passUsesSecondaryCb, recordingPass, resetCommands(), and resetPerPassState().

Referenced by QVkCommandBuffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ QRhiVulkan

friend class QRhiVulkan
friend

Definition at line 596 of file qrhivulkan_p.h.

Member Data Documentation

◆ activeSecondaryCbStack

QVarLengthArray<VkCommandBuffer, 4> QVkCommandBuffer::activeSecondaryCbStack

Definition at line 390 of file qrhivulkan_p.h.

◆ bufferBarrier

QVarLengthArray<VkBufferMemoryBarrier, 8> QVkCommandBuffer::bufferBarrier

Definition at line 593 of file qrhivulkan_p.h.

◆ bufferImageCopy

QVarLengthArray<VkBufferImageCopy, 16> QVkCommandBuffer::bufferImageCopy

Definition at line 587 of file qrhivulkan_p.h.

◆ cb

VkCommandBuffer QVkCommandBuffer::cb = VK_NULL_HANDLE

Definition at line 337 of file qrhivulkan_p.h.

◆ clearValue

QVarLengthArray<VkClearValue, 4> QVkCommandBuffer::clearValue

Definition at line 586 of file qrhivulkan_p.h.

◆ commands

QRhiBackendCommandList<Command> QVkCommandBuffer::commands

Definition at line 562 of file qrhivulkan_p.h.

◆ [struct]

struct { ... } QVkCommandBuffer::computePassState

◆ currentComputePipeline

QRhiComputePipeline* QVkCommandBuffer::currentComputePipeline

Definition at line 378 of file qrhivulkan_p.h.

◆ currentComputeSrb

QRhiShaderResourceBindings* QVkCommandBuffer::currentComputeSrb

Definition at line 381 of file qrhivulkan_p.h.

◆ currentDescSetSlot

int QVkCommandBuffer::currentDescSetSlot

Definition at line 383 of file qrhivulkan_p.h.

Referenced by resetPerPassState().

◆ currentGraphicsPipeline

QRhiGraphicsPipeline* QVkCommandBuffer::currentGraphicsPipeline

Definition at line 377 of file qrhivulkan_p.h.

◆ currentGraphicsSrb

QRhiShaderResourceBindings* QVkCommandBuffer::currentGraphicsSrb

Definition at line 380 of file qrhivulkan_p.h.

◆ currentIndexBuffer

VkBuffer QVkCommandBuffer::currentIndexBuffer

Definition at line 384 of file qrhivulkan_p.h.

◆ currentIndexFormat

VkIndexType QVkCommandBuffer::currentIndexFormat

Definition at line 386 of file qrhivulkan_p.h.

◆ currentIndexOffset

quint32 QVkCommandBuffer::currentIndexOffset

Definition at line 385 of file qrhivulkan_p.h.

◆ currentPassResTrackerIndex

◆ currentPipelineGeneration

uint QVkCommandBuffer::currentPipelineGeneration

Definition at line 379 of file qrhivulkan_p.h.

◆ currentSrbGeneration

uint QVkCommandBuffer::currentSrbGeneration

Definition at line 382 of file qrhivulkan_p.h.

◆ currentTarget

QRhiRenderTarget* QVkCommandBuffer::currentTarget

Definition at line 376 of file qrhivulkan_p.h.

◆ currentVertexBuffers

VkBuffer QVkCommandBuffer::currentVertexBuffers[VERTEX_INPUT_RESOURCE_SLOT_COUNT]

Definition at line 388 of file qrhivulkan_p.h.

◆ currentVertexOffsets

quint32 QVkCommandBuffer::currentVertexOffsets[VERTEX_INPUT_RESOURCE_SLOT_COUNT]

Definition at line 389 of file qrhivulkan_p.h.

◆ debugMarkerData

QVarLengthArray<QByteArray, 4> QVkCommandBuffer::debugMarkerData

Definition at line 591 of file qrhivulkan_p.h.

◆ dynamicOffset

QVarLengthArray<uint32_t, 4> QVkCommandBuffer::dynamicOffset

Definition at line 588 of file qrhivulkan_p.h.

◆ hasShadingRateSet

bool QVkCommandBuffer::hasShadingRateSet

Definition at line 392 of file qrhivulkan_p.h.

Referenced by QRhiVulkan::beginPass(), and resetPerPassState().

◆ imageBarrier

QVarLengthArray<VkImageMemoryBarrier, 8> QVkCommandBuffer::imageBarrier

Definition at line 592 of file qrhivulkan_p.h.

◆ inExternal

bool QVkCommandBuffer::inExternal

◆ lastGpuTime

double QVkCommandBuffer::lastGpuTime = 0

◆ nativeHandlesStruct

QRhiVulkanCommandBufferNativeHandles QVkCommandBuffer::nativeHandlesStruct

Definition at line 338 of file qrhivulkan_p.h.

◆ passResTrackers

QVector<QRhiPassResourceTracker> QVkCommandBuffer::passResTrackers

Definition at line 563 of file qrhivulkan_p.h.

◆ passUsesSecondaryCb

◆ [struct]

struct { ... } QVkCommandBuffer::pools

◆ recordingPass

◆ VERTEX_INPUT_RESOURCE_SLOT_COUNT

const int QVkCommandBuffer::VERTEX_INPUT_RESOURCE_SLOT_COUNT = 32
static

Definition at line 387 of file qrhivulkan_p.h.

◆ vertexBuffer

QVarLengthArray<VkBuffer, 4> QVkCommandBuffer::vertexBuffer

Definition at line 589 of file qrhivulkan_p.h.

◆ vertexBufferOffset

QVarLengthArray<VkDeviceSize, 4> QVkCommandBuffer::vertexBufferOffset

Definition at line 590 of file qrhivulkan_p.h.

◆ writtenResources

QHash<QRhiResource *, std::pair<VkAccessFlags, bool> > QVkCommandBuffer::writtenResources

Definition at line 395 of file qrhivulkan_p.h.


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