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
QRhiVertexInputBinding Class Reference

\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h More...

#include <qrhi.h>

Collaboration diagram for QRhiVertexInputBinding:

Public Types

enum  Classification { PerVertex , PerInstance }
 Describes the input data classification. More...

Public Member Functions

 QRhiVertexInputBinding ()=default
 Constructs a default vertex input binding description.
 QRhiVertexInputBinding (quint32 stride, Classification cls=PerVertex, quint32 stepRate=1)
 Constructs a vertex input binding description with the specified stride, classification cls, and instance step rate stepRate.
quint32 stride () const
void setStride (quint32 s)
 Sets the stride to s.
Classification classification () const
void setClassification (Classification c)
 Sets the input data classification c.
quint32 instanceStepRate () const
void setInstanceStepRate (quint32 rate)
 Sets the instance step rate.

Friends

bool operator== (const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept
bool operator!= (const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b) noexcept
size_t qHash (const QRhiVertexInputBinding &v, size_t seed=0) noexcept
 \qhash{QRhiVertexInputBinding}

Detailed Description

\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h

Since
6.6

Describes a vertex input binding.

Specifies the stride (in bytes, must be a multiple of 4), the classification and optionally the instance step rate.

As an example, assume a vertex shader with the following inputs:

\badcode layout(location = 0) in vec4 position; layout(location = 1) in vec2 texcoord;

Now let's assume also that 3 component vertex positions {(x, y, z)} and 2 component texture coordinates {(u, v)} are provided in a non-interleaved format in a buffer (or separate buffers even). Defining two bindings could then be done like this:

inputLayout.setBindings({
{ 3 * sizeof(float) },
{ 2 * sizeof(float) }
});
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:322
void setBindings(std::initializer_list< QRhiVertexInputBinding > list)
Sets the bindings from the specified list.
Definition qrhi.h:326

Only the stride is interesting here since instancing is not used. The binding number is given by the index of the QRhiVertexInputBinding element in the bindings vector of the QRhiVertexInputLayout.

Once a graphics pipeline with this vertex input layout is bound, the vertex inputs could be set up like the following for drawing a cube with 36 vertices, assuming we have a single buffer with first the positions and then the texture coordinates:

const QRhiCommandBuffer::VertexInput vbufBindings[] = {
{ cubeBuf, 0 },
{ cubeBuf, 36 * 3 * sizeof(float) }
};
cb->setVertexInput(0, 2, vbufBindings);
std::pair< QRhiBuffer *, quint32 > VertexInput
Synonym for std::pair<QRhiBuffer *, quint32>.
Definition qrhi.h:1724
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)

Note how the index defined by {startBinding + i}, where i is the index in the second argument of \l{QRhiCommandBuffer::setVertexInput()}{setVertexInput()}, matches the index of the corresponding entry in the bindings vector of the QRhiVertexInputLayout.

Note
the stride must always be a multiple of 4.
This is a RHI API with limited compatibility guarantees, see \l QRhi for details.
See also
QRhiCommandBuffer::setVertexInput()

Definition at line 179 of file qrhi.h.

Member Enumeration Documentation

◆ Classification

Describes the input data classification.

\value PerVertex Data is per-vertex \value PerInstance Data is per-instance

Enumerator
PerVertex 
PerInstance 

Definition at line 182 of file qrhi.h.

Constructor & Destructor Documentation

◆ QRhiVertexInputBinding() [1/2]

QRhiVertexInputBinding::QRhiVertexInputBinding ( )
default

Constructs a default vertex input binding description.

◆ QRhiVertexInputBinding() [2/2]

QRhiVertexInputBinding::QRhiVertexInputBinding ( quint32 stride,
Classification cls = PerVertex,
quint32 stepRate = 1 )

Constructs a vertex input binding description with the specified stride, classification cls, and instance step rate stepRate.

Note
stepRate other than 1 is only supported when QRhi::CustomInstanceStepRate is reported to be supported.

Definition at line 1619 of file qrhi.cpp.

Member Function Documentation

◆ classification()

Classification QRhiVertexInputBinding::classification ( ) const
inline
Returns
the input data classification.

Definition at line 193 of file qrhi.h.

◆ instanceStepRate()

quint32 QRhiVertexInputBinding::instanceStepRate ( ) const
inline
Returns
the instance step rate.

Definition at line 196 of file qrhi.h.

◆ setClassification()

void QRhiVertexInputBinding::setClassification ( Classification c)
inline

Sets the input data classification c.

By default this is set to PerVertex.

Definition at line 194 of file qrhi.h.

◆ setInstanceStepRate()

void QRhiVertexInputBinding::setInstanceStepRate ( quint32 rate)
inline

Sets the instance step rate.

By default this is set to 1.

Definition at line 197 of file qrhi.h.

◆ setStride()

void QRhiVertexInputBinding::setStride ( quint32 s)
inline

Sets the stride to s.

Definition at line 191 of file qrhi.h.

◆ stride()

quint32 QRhiVertexInputBinding::stride ( ) const
inline
Returns
the stride in bytes.

Definition at line 190 of file qrhi.h.

◆ operator!=

bool operator!= ( const QRhiVertexInputBinding & a,
const QRhiVertexInputBinding & b )
friend
Returns
false if the values in the two QRhiVertexInputBinding objects a and b are equal; otherwise returns true.

Definition at line 211 of file qrhi.h.

◆ operator==

bool operator== ( const QRhiVertexInputBinding & a,
const QRhiVertexInputBinding & b )
friend
Returns
true if the values in the two QRhiVertexInputBinding objects a and b are equal.

Definition at line 204 of file qrhi.h.

◆ qHash

size_t qHash ( const QRhiVertexInputBinding & v,
size_t seed = 0 )
friend

\qhash{QRhiVertexInputBinding}

Definition at line 216 of file qrhi.h.


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