Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QRhiVertexInputBinding Class Reference

\inmodule QtGui 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
 

Detailed Description

\inmodule QtGui

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 QtGui
Definition qrhi.h:321
void setBindings(std::initializer_list< QRhiVertexInputBinding > list)
Sets the bindings from the specified list.
Definition qrhi.h:325

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);
QPair< QRhiBuffer *, quint32 > VertexInput
Synonym for QPair<QRhiBuffer *, quint32>.
Definition qrhi.h:1680
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 178 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 181 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 1536 of file qrhi.cpp.

Member Function Documentation

◆ classification()

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

Definition at line 192 of file qrhi.h.

◆ instanceStepRate()

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

Definition at line 195 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 193 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 196 of file qrhi.h.

◆ setStride()

void QRhiVertexInputBinding::setStride ( quint32 s)
inline

Sets the stride to s.

Definition at line 190 of file qrhi.h.

◆ stride()

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

Definition at line 189 of file qrhi.h.

Referenced by QRhiD3D11::setVertexInput().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

bool QRhiVertexInputBinding::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 210 of file qrhi.h.

◆ operator==

bool QRhiVertexInputBinding::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 203 of file qrhi.h.

◆ qHash

size_t QRhiVertexInputBinding::qHash ( const QRhiVertexInputBinding & v,
size_t seed = 0 )
friend
Returns
the hash value for v, using seed to seed the calculation.

Definition at line 215 of file qrhi.h.


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