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

\inmodule QtGui More...

#include <qrhi.h>

+ Collaboration diagram for QRhiVertexInputAttribute:

Public Types

enum  Format {
  Float4 , Float3 , Float2 , Float ,
  UNormByte4 , UNormByte2 , UNormByte , UInt4 ,
  UInt3 , UInt2 , UInt , SInt4 ,
  SInt3 , SInt2 , SInt , Half4 ,
  Half3 , Half2 , Half , UShort4 ,
  UShort3 , UShort2 , UShort , SShort4 ,
  SShort3 , SShort2 , SShort
}
 Specifies the type of the element data. More...
 

Public Member Functions

 QRhiVertexInputAttribute ()=default
 Constructs a default vertex input attribute description.
 
 QRhiVertexInputAttribute (int binding, int location, Format format, quint32 offset, int matrixSlice=-1)
 Constructs a vertex input attribute description with the specified binding number, location, format, and offset.
 
int binding () const
 
void setBinding (int b)
 Sets the binding point index to b.
 
int location () const
 
void setLocation (int loc)
 Sets the location of the vertex input element to loc.
 
Format format () const
 
void setFormat (Format f)
 Sets the format of the vertex input element to f.
 
quint32 offset () const
 
void setOffset (quint32 ofs)
 Sets the byte offset for the input element to ofs.
 
int matrixSlice () const
 
void setMatrixSlice (int slice)
 Sets the matrix slice.
 

Friends

bool operator== (const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept
 
bool operator!= (const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) noexcept
 
size_t qHash (const QRhiVertexInputAttribute &v, size_t seed=0) noexcept
 

Detailed Description

\inmodule QtGui

Since
6.6

Describes a single vertex input element.

The members specify the binding number, location, format, and offset for a single vertex input element.

Note
For HLSL it is assumed that the vertex shader translated from SPIR-V uses {TEXCOORD<location>} as the semantic for each input. Hence no separate semantic name and index.

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 that we have 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). Once two bindings are defined, the attributes could be specified as:

inputLayout.setBindings({
{ 3 * sizeof(float) },
{ 2 * sizeof(float) }
});
inputLayout.setAttributes({
});
\inmodule QtGui
Definition qrhi.h:321
void setBindings(std::initializer_list< QRhiVertexInputBinding > list)
Sets the bindings from the specified list.
Definition qrhi.h:325
void setAttributes(std::initializer_list< QRhiVertexInputAttribute > list)
Sets the attributes from the specified list.
Definition qrhi.h:337

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)

When working with interleaved data, there will typically be just one binding, with multiple attributes referring to that same buffer binding point:

inputLayout.setBindings({
{ 5 * sizeof(float) }
});
inputLayout.setAttributes({
{ 0, 1, QRhiVertexInputAttribute::Float2, 3 * sizeof(float) }
});

and then:

const QRhiCommandBuffer::VertexInput vbufBinding(interleavedCubeBuf, 0);
cb->setVertexInput(0, 1, &vbufBinding);
Note
This is a RHI API with limited compatibility guarantees, see \l QRhi for details.
See also
QRhiCommandBuffer::setVertexInput()

Definition at line 231 of file qrhi.h.

Member Enumeration Documentation

◆ Format

Specifies the type of the element data.

\value Float4 Four component float vector \value Float3 Three component float vector \value Float2 Two component float vector \value Float Float \value UNormByte4 Four component normalized unsigned byte vector \value UNormByte2 Two component normalized unsigned byte vector \value UNormByte Normalized unsigned byte \value UInt4 Four component unsigned integer vector \value UInt3 Three component unsigned integer vector \value UInt2 Two component unsigned integer vector \value UInt Unsigned integer \value SInt4 Four component signed integer vector \value SInt3 Three component signed integer vector \value SInt2 Two component signed integer vector \value SInt Signed integer \value Half4 Four component half precision (16 bit) float vector \value Half3 Three component half precision (16 bit) float vector \value Half2 Two component half precision (16 bit) float vector \value Half Half precision (16 bit) float \value UShort4 Four component unsigned short (16 bit) integer vector \value UShort3 Three component unsigned short (16 bit) integer vector \value UShort2 Two component unsigned short (16 bit) integer vector \value UShort Unsigned short (16 bit) integer \value SShort4 Four component signed short (16 bit) integer vector \value SShort3 Three component signed short (16 bit) integer vector \value SShort2 Two component signed short (16 bit) integer vector \value SShort Signed short (16 bit) integer

Note
Support for half precision floating point attributes is indicated at run time by the QRhi::Feature::HalfAttributes feature flag.
Direct3D 11/12 supports 16 bit input attributes, but does not support the Half3, UShort3 or SShort3 types. The D3D backends pass through Half3 as Half4, UShort3 as UShort4, and SShort3 as SShort4. To ensure cross platform compatibility, 16 bit inputs should be padded to 8 bytes.
Enumerator
Float4 
Float3 
Float2 
Float 
UNormByte4 
UNormByte2 
UNormByte 
UInt4 
UInt3 
UInt2 
UInt 
SInt4 
SInt3 
SInt2 
SInt 
Half4 
Half3 
Half2 
Half 
UShort4 
UShort3 
UShort2 
UShort 
SShort4 
SShort3 
SShort2 
SShort 

Definition at line 234 of file qrhi.h.

Constructor & Destructor Documentation

◆ QRhiVertexInputAttribute() [1/2]

QRhiVertexInputAttribute::QRhiVertexInputAttribute ( )
default

Constructs a default vertex input attribute description.

◆ QRhiVertexInputAttribute() [2/2]

QRhiVertexInputAttribute::QRhiVertexInputAttribute ( int binding,
int location,
Format format,
quint32 offset,
int matrixSlice = -1 )

Constructs a vertex input attribute description with the specified binding number, location, format, and offset.

matrixSlice should be -1 except when this attribute corresponds to a row or column of a matrix (for example, a 4x4 matrix becomes 4 vec4s, consuming 4 consecutive vertex input locations), in which case it is the index of the row or column. {location - matrixSlice} must always be equal to the location for the first row or column of the unrolled matrix.

Definition at line 1741 of file qrhi.cpp.

Member Function Documentation

◆ binding()

int QRhiVertexInputAttribute::binding ( ) const
inline
Returns
the binding point index.

Definition at line 267 of file qrhi.h.

◆ format()

QRhiVertexInputAttribute::Format QRhiVertexInputAttribute::format ( ) const
inline
Returns
the format of the vertex input element.

Definition at line 273 of file qrhi.h.

◆ location()

int QRhiVertexInputAttribute::location ( ) const
inline
Returns
the location of the vertex input element.

Definition at line 270 of file qrhi.h.

◆ matrixSlice()

int QRhiVertexInputAttribute::matrixSlice ( ) const
inline
Returns
the matrix slice if the input element corresponds to a row or column of a matrix, or -1 if not relevant.

Definition at line 279 of file qrhi.h.

◆ offset()

quint32 QRhiVertexInputAttribute::offset ( ) const
inline
Returns
the byte offset for the input element.

Definition at line 276 of file qrhi.h.

◆ setBinding()

void QRhiVertexInputAttribute::setBinding ( int b)
inline

Sets the binding point index to b.

By default this is set to 0.

Definition at line 268 of file qrhi.h.

◆ setFormat()

void QRhiVertexInputAttribute::setFormat ( Format f)
inline

Sets the format of the vertex input element to f.

By default this is set to Float4.

Definition at line 274 of file qrhi.h.

◆ setLocation()

void QRhiVertexInputAttribute::setLocation ( int loc)
inline

Sets the location of the vertex input element to loc.

By default this is set to 0.

Definition at line 271 of file qrhi.h.

◆ setMatrixSlice()

void QRhiVertexInputAttribute::setMatrixSlice ( int slice)
inline

Sets the matrix slice.

By default this is set to -1, and should be set to a >= 0 value only when this attribute corresponds to a row or column of a matrix (for example, a 4x4 matrix becomes 4 vec4s, consuming 4 consecutive vertex input locations), in which case it is the index of the row or column. {location - matrixSlice} must always be equal to the location for the first row or column of the unrolled matrix.

Definition at line 280 of file qrhi.h.

◆ setOffset()

void QRhiVertexInputAttribute::setOffset ( quint32 ofs)
inline

Sets the byte offset for the input element to ofs.

Definition at line 277 of file qrhi.h.

Friends And Related Symbol Documentation

◆ operator!=

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

Definition at line 298 of file qrhi.h.

◆ operator==

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

Definition at line 289 of file qrhi.h.

◆ qHash

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

Definition at line 303 of file qrhi.h.


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