QRhiVertexInputBinding Class

Describes a vertex input binding. More...

Header: #include <QRhiVertexInputBinding>
qmake: QT += rhi

Public Types

enum Classification { PerVertex, PerInstance }

Public Functions

QRhiVertexInputBinding()
QRhiVertexInputBinding(quint32 stride, QRhiVertexInputBinding::Classification cls = PerVertex, int stepRate = 1)
QRhiVertexInputBinding::Classification classification() const
int instanceStepRate() const
void setClassification(QRhiVertexInputBinding::Classification c)
void setInstanceStepRate(int rate)
void setStride(quint32 s)
quint32 stride() const
uint qHash(const QRhiVertexInputBinding &v, uint seed = 0)
bool operator!=(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b)
bool operator==(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b)

Detailed Description

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:


  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). Definining two bindings could then be done like this:


  QRhiVertexInputLayout inputLayout;
  inputLayout.setBindings({
      { 3 * sizeof(float) },
      { 2 * sizeof(float) }
  });

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

Note how the index defined by startBinding + i, where i is the index in the second argument of 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.

See also QRhiCommandBuffer::setVertexInput().

Member Type Documentation

enum QRhiVertexInputBinding::Classification

Describes the input data classification.

ConstantValueDescription
QRhiVertexInputBinding::PerVertex0Data is per-vertex
QRhiVertexInputBinding::PerInstance1Data is per-instance

Property Documentation

Member Function Documentation

QRhiVertexInputBinding::QRhiVertexInputBinding()

Constructs a default vertex input binding description.

QRhiVertexInputBinding::QRhiVertexInputBinding(quint32 stride, QRhiVertexInputBinding::Classification cls = PerVertex, int 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.

QRhiVertexInputBinding::Classification QRhiVertexInputBinding::classification() const

See also setClassification().

int QRhiVertexInputBinding::instanceStepRate() const

See also setInstanceStepRate().

void QRhiVertexInputBinding::setClassification(QRhiVertexInputBinding::Classification c)

See also classification().

void QRhiVertexInputBinding::setInstanceStepRate(int rate)

See also instanceStepRate().

void QRhiVertexInputBinding::setStride(quint32 s)

See also stride().

quint32 QRhiVertexInputBinding::stride() const

See also setStride().

Member Variable Documentation

Related Non-Members

uint qHash(const QRhiVertexInputBinding &v, uint seed = 0)

Returns the hash value for v, using seed to seed the calculation.

bool operator!=(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b)

Returns false if the values in the two QRhiVertexInputBinding objects a and b are equal; otherwise returns true.

bool operator==(const QRhiVertexInputBinding &a, const QRhiVertexInputBinding &b)

Returns true if the values in the two QRhiVertexInputBinding objects a and b are equal.

Macro Documentation