PySide6.QtGui.QRhiVertexInputAttribute

class QRhiVertexInputAttribute

Describes a single vertex input element.

Details

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:

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:

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

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

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

QRhiVertexInputLayout inputLayout;
inputLayout.setBindings({
    { 5 * sizeof(float) }
});
inputLayout.setAttributes({
    { 0, 0, QRhiVertexInputAttribute::Float3, 0 },
    { 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 QRhi for details.

See also

setVertexInput()

Added in version 6.6.

Synopsis

Methods

Note

This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE

class Format

Specifies the type of the element data.

Constant

Description

QRhiVertexInputAttribute.Format.Float4

Four component float vector

QRhiVertexInputAttribute.Format.Float3

Three component float vector

QRhiVertexInputAttribute.Format.Float2

Two component float vector

QRhiVertexInputAttribute.Format.Float

Float

QRhiVertexInputAttribute.Format.UNormByte4

Four component normalized unsigned byte vector

QRhiVertexInputAttribute.Format.UNormByte2

Two component normalized unsigned byte vector

QRhiVertexInputAttribute.Format.UNormByte

Normalized unsigned byte

QRhiVertexInputAttribute.Format.UInt4

Four component unsigned integer vector

QRhiVertexInputAttribute.Format.UInt3

Three component unsigned integer vector

QRhiVertexInputAttribute.Format.UInt2

Two component unsigned integer vector

QRhiVertexInputAttribute.Format.UInt

Unsigned integer

QRhiVertexInputAttribute.Format.SInt4

Four component signed integer vector

QRhiVertexInputAttribute.Format.SInt3

Three component signed integer vector

QRhiVertexInputAttribute.Format.SInt2

Two component signed integer vector

QRhiVertexInputAttribute.Format.SInt

Signed integer

QRhiVertexInputAttribute.Format.Half4

Four component half precision (16 bit) float vector

QRhiVertexInputAttribute.Format.Half3

Three component half precision (16 bit) float vector

QRhiVertexInputAttribute.Format.Half2

Two component half precision (16 bit) float vector

QRhiVertexInputAttribute.Format.Half

Half precision (16 bit) float

QRhiVertexInputAttribute.Format.UShort4

Four component unsigned short (16 bit) integer vector

QRhiVertexInputAttribute.Format.UShort3

Three component unsigned short (16 bit) integer vector

QRhiVertexInputAttribute.Format.UShort2

Two component unsigned short (16 bit) integer vector

QRhiVertexInputAttribute.Format.UShort

Unsigned short (16 bit) integer

QRhiVertexInputAttribute.Format.SShort4

Four component signed short (16 bit) integer vector

QRhiVertexInputAttribute.Format.SShort3

Three component signed short (16 bit) integer vector

QRhiVertexInputAttribute.Format.SShort2

Two component signed short (16 bit) integer vector

QRhiVertexInputAttribute.Format.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.

Note

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.

__init__()

Constructs a default vertex input attribute description.

__init__(binding, location, format, offset[, matrixSlice=-1])
Parameters:
  • binding – int

  • location – int

  • formatFormat

  • offset – int

  • matrixSlice – int

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.

binding()
Return type:

int

Returns the binding point index.

See also

setBinding()

format()
Return type:

Format

Returns the format of the vertex input element.

See also

setFormat()

location()
Return type:

int

Returns the location of the vertex input element.

See also

setLocation()

matrixSlice()
Return type:

int

Returns the matrix slice if the input element corresponds to a row or column of a matrix, or -1 if not relevant.

See also

setMatrixSlice()

offset()
Return type:

int

Returns the byte offset for the input element.

See also

setOffset()

__ne__(b)
Parameters:

bQRhiVertexInputAttribute

Return type:

bool

__eq__(b)
Parameters:

bQRhiVertexInputAttribute

Return type:

bool

setBinding(b)
Parameters:

b – int

Sets the binding point index to b. By default this is set to 0.

See also

binding()

setFormat(f)
Parameters:

fFormat

Sets the format of the vertex input element to f. By default this is set to Float4.

See also

format()

setLocation(loc)
Parameters:

loc – int

Sets the location of the vertex input element to loc. By default this is set to 0.

See also

location()

setMatrixSlice(slice)
Parameters:

slice – int

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.

See also

matrixSlice()

setOffset(ofs)
Parameters:

ofs – int

Sets the byte offset for the input element to ofs.

See also

offset()