QRhiVertexInputAttribute Class
Beschreibt ein einzelnes Eingabeelement für einen Knoten. Mehr...
| Header: | #include <rhi/qrhi.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS GuiPrivate) target_link_libraries(mytarget PRIVATE Qt6::GuiPrivate) |
| qmake: | QT += gui-private |
| Seit: | Qt 6.6 |
Öffentliche Typen
| enum | Format { Float4, Float3, Float2, Float, UNormByte4, …, SShort } |
Öffentliche Funktionen
| QRhiVertexInputAttribute() | |
| QRhiVertexInputAttribute(int binding, int location, QRhiVertexInputAttribute::Format format, quint32 offset, int matrixSlice = -1) | |
| int | binding() const |
| QRhiVertexInputAttribute::Format | format() const |
| int | location() const |
| int | matrixSlice() const |
| quint32 | offset() const |
| void | setBinding(int b) |
| void | setFormat(QRhiVertexInputAttribute::Format f) |
| void | setLocation(int loc) |
| void | setMatrixSlice(int slice) |
| void | setOffset(quint32 ofs) |
Verwandte Nicht-Mitglieder
| size_t | qHash(const QRhiVertexInputAttribute &key, size_t seed = 0) |
| bool | operator!=(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) |
| bool | operator==(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b) |
Ausführliche Beschreibung
Die Elemente legen die Bindungsnummer, die Position, das Format und den Offset für ein einzelnes Vertex-Eingabeelement fest.
Hinweis: Bei HLSL wird davon ausgegangen, dass der aus SPIR-V übersetzte Vertex-Shader „ TEXCOORD<location> “ als Semantik für jede Eingabe verwendet. Daher gibt es keinen separaten Semantiknamen und -index.
Nehmen wir als Beispiel einen Vertex-Shader mit den folgenden Eingaben:
layout(location = 0) in vec4 position;
layout(location = 1) in vec2 texcoord;Nehmen wir nun an, dass 3-Komponenten-Vertexpositionen (x, y, z) und 2-Komponenten-Texturkoordinaten (u, v) in einem nicht-verschachtelten Format in einem Puffer (oder sogar in separaten Puffern) bereitgestellt werden. Sobald zwei Bindungen definiert sind, könnten die Attribute wie folgt angegeben werden:
QRhiVertexInputLayout inputLayout;
inputLayout.setBindings({
{ 3 * sizeof(float) },
{ 2 * sizeof(float) }
});
inputLayout.setAttributes({
{ 0, 0, QRhiVertexInputAttribute::Float3, 0 },
{ 1, 1, QRhiVertexInputAttribute::Float2, 0 }
});Sobald eine Grafikpipeline mit diesem Vertex-Eingabelayout gebunden ist, könnten die Vertex-Eingaben wie folgt eingerichtet werden, um einen Würfel mit 36 Scheitelpunkten zu zeichnen, vorausgesetzt, wir haben einen einzigen Puffer, in dem zuerst die Positionen und dann die Texturkoordinaten gespeichert sind:
const QRhiCommandBuffer::VertexInput vbufBindings[] = {
{ cubeBuf, 0 },
{ cubeBuf, 36 * 3 * sizeof(float) }
};
cb->setVertexInput(0, 2, vbufBindings);Bei der Arbeit mit verschachtelten Daten gibt es in der Regel nur eine Bindung, wobei mehrere Attribute auf denselben Puffer-Bindungspunkt verweisen:
QRhiVertexInputLayout inputLayout;
inputLayout.setBindings({
{ 5 * sizeof(float) }
});
inputLayout.setAttributes({
{ 0, 0, QRhiVertexInputAttribute::Float3, 0 },
{ 0, 1, QRhiVertexInputAttribute::Float2, 3 * sizeof(float) }
});und dann:
const QRhiCommandBuffer::VertexInput vbufBinding(interleavedCubeBuf, 0);
cb->setVertexInput(0, 1, &vbufBinding);Hinweis: Dies ist eine RHI-API mit eingeschränkten Kompatibilitätsgarantien; weitere Informationen finden Sie unter QRhi.
Siehe auch QRhiCommandBuffer::setVertexInput().
Dokumentation zu Mitgliedstypen
enum QRhiVertexInputAttribute::Format
Gibt den Typ der Elementdaten an.
| Konstante | Wert | Beschreibung |
|---|---|---|
QRhiVertexInputAttribute::Float4 | 0 | Vektor mit vier Float-Komponenten |
QRhiVertexInputAttribute::Float3 | 1 | Dreikomponenten-Float-Vektor |
QRhiVertexInputAttribute::Float2 | 2 | Zweikomponenten-Float-Vektor |
QRhiVertexInputAttribute::Float | 3 | Float |
QRhiVertexInputAttribute::UNormByte4 | 4 | Vektor mit vier Komponenten vom Typ „normalisiertes vorzeichenloses Byte“ |
QRhiVertexInputAttribute::UNormByte2 | 5 | Zweikomponentiger normalisierter Vektor aus vorzeichenlosen Bytes |
QRhiVertexInputAttribute::UNormByte | 6 | Normiertes vorzeichenloses Byte |
QRhiVertexInputAttribute::UInt4 | 7 | Vektor aus vier vorzeichenlosen Ganzzahlen |
QRhiVertexInputAttribute::UInt3 | 8 | Dreikomponentiger Vektor aus vorzeichenlosen Ganzzahlen |
QRhiVertexInputAttribute::UInt2 | 9 | Zweikomponentiger Vektor aus vorzeichenlosen Ganzzahlen |
QRhiVertexInputAttribute::UInt | 10 | Ganzzahl ohne Vorzeichen |
QRhiVertexInputAttribute::SInt4 | 11 | Vektor mit vier Komponenten als vorzeichenbehaftete Ganzzahl |
QRhiVertexInputAttribute::SInt3 | 12 | Dreikomponentiger Vektor aus vorzeichenbehafteten Ganzzahlen |
QRhiVertexInputAttribute::SInt2 | 13 | Zweikomponentiger Vektor aus vorzeichenbehafteten Ganzzahlen |
QRhiVertexInputAttribute::SInt | 14 | Vorzeichenbehaftete Ganzzahl |
QRhiVertexInputAttribute::Half4 | 15 | Vektor mit vier Komponenten mit halber Genauigkeit (16 Bit) |
QRhiVertexInputAttribute::Half3 | 16 | Dreikomponentiger Halbpräzisions-Float-Vektor (16 Bit) |
QRhiVertexInputAttribute::Half2 | 17 | Zweikomponentiger Vektor mit Halbpräzisions-Gleitkommazahlen (16 Bit) |
QRhiVertexInputAttribute::Half | 18 | Fließkommazahl mit halber Genauigkeit (16 Bit) |
QRhiVertexInputAttribute::UShort4 | 19 | Vektor aus vier vorzeichenlosen Short-Ganzzahlen (16 Bit) |
QRhiVertexInputAttribute::UShort3 | 20 | Dreikomponentiger Vektor aus vorzeichenlosen kurzen Ganzzahlen (16 Bit) |
QRhiVertexInputAttribute::UShort2 | 21 | Zweikomponentiger Vektor aus vorzeichenlosen Short-Ganzzahlen (16 Bit) |
QRhiVertexInputAttribute::UShort | 22 | Ganzzahl vom Typ „Unsigned Short“ (16 Bit) |
QRhiVertexInputAttribute::SShort4 | 23 | Vektor aus vier vorzeichenbehafteten „short“-Ganzzahlen (16 Bit) |
QRhiVertexInputAttribute::SShort3 | 24 | Dreikomponentiger Vektor aus vorzeichenbehafteten „short“-Ganzzahlen (16 Bit) |
QRhiVertexInputAttribute::SShort2 | 25 | Zweikomponentiger Vektor aus vorzeichenbehafteten „short“-Ganzzahlen (16 Bit) |
QRhiVertexInputAttribute::SShort | 26 | Vorzeichenbehaftete „short“ (16 Bit)-Ganzzahl Hinweis: Die Unterstützung für Gleitkommaattribute mit halber Genauigkeit wird zur Laufzeit durch das Feature-Flag „ QRhi::Feature::HalfAttributes “ angezeigt. Hinweis: Direct3D 11/12 unterstützt 16-Bit-Eingabeattribute, jedoch nicht die Typen „Half3“, „UShort3“ oder „SShort3“. Die D3D-Backends leiten „Half3“ als „Half4“, „UShort3“ als „UShort4“ und „SShort3“ als „SShort4“ weiter. Um plattformübergreifende Kompatibilität zu gewährleisten, sollten 16-Bit-Eingaben auf 8 Byte aufgefüllt werden. |
Dokumentation zu den Mitgliedsfunktionen
[constexpr noexcept default] QRhiVertexInputAttribute::QRhiVertexInputAttribute()
Erstellt eine Standardbeschreibung für ein Vertex-Eingabeattribut.
QRhiVertexInputAttribute::QRhiVertexInputAttribute(int binding, int location, QRhiVertexInputAttribute::Format format, quint32 offset, int matrixSlice = -1)
Erstellt eine Beschreibung eines Vertex-Eingabeattributs mit der angegebenen Anzahl von „ binding “, „ location “, „ format “ und „ offset “.
matrixSlice sollte den Wert -1 haben, es sei denn, dieses Attribut entspricht einer Zeile oder Spalte einer Matrix (beispielsweise wird eine 4x4-Matrix zu 4 vec4s, die 4 aufeinanderfolgende Vertex-Eingabepositionen belegen); in diesem Fall ist es der Index der Zeile oder Spalte. location - matrixSlice muss immer dem „ location “ für die erste Zeile oder Spalte der entrollten Matrix entsprechen.
int QRhiVertexInputAttribute::binding() const
Gibt den Index des Bindungspunkts zurück.
Siehe auch ` setBinding()`.
QRhiVertexInputAttribute::Format QRhiVertexInputAttribute::format() const
Gibt das Format des Eingabeelements „vertex“ zurück.
Siehe auch „ setFormat()“.
int QRhiVertexInputAttribute::location() const
Gibt die Position des Eingabeelements „Vertex“ zurück.
Siehe auch „ setLocation()“.
int QRhiVertexInputAttribute::matrixSlice() const
Gibt den Matrixausschnitt zurück, wenn das Eingabeelement einer Zeile oder Spalte einer Matrix entspricht, andernfalls -1.
Siehe auch „ setMatrixSlice()“.
quint32 QRhiVertexInputAttribute::offset() const
Gibt den Byte-Offset für das Eingabeelement zurück.
Siehe auch ` setOffset()`.
void QRhiVertexInputAttribute::setBinding(int b)
Setzt den Bindungspunktindex auf „ b “. Standardmäßig ist dieser auf 0 gesetzt.
Siehe auch binding().
void QRhiVertexInputAttribute::setFormat(QRhiVertexInputAttribute::Format f)
Legt das Format des Vertex-Eingabeelements auf „ f “ fest. Standardmäßig ist hier „Float4“ eingestellt.
Siehe auch ` format()`.
void QRhiVertexInputAttribute::setLocation(int loc)
Legt die Position des Eckpunkt-Eingabeelements auf „ loc “ fest. Standardmäßig ist dieser Wert auf 0 gesetzt.
Siehe auch location().
void QRhiVertexInputAttribute::setMatrixSlice(int slice)
Legt die Matrix slice fest. Standardmäßig ist dieser Wert auf -1 gesetzt und sollte nur dann auf einen Wert >= 0 gesetzt werden, wenn dieses Attribut einer Zeile oder Spalte einer Matrix entspricht (beispielsweise wird eine 4x4-Matrix zu 4 vec4s, die 4 aufeinanderfolgende Vertex-Eingabepositionen belegen); in diesem Fall entspricht der Wert dem Index der Zeile oder Spalte. location - matrixSlice muss immer dem „ location “ für die erste Zeile oder Spalte der entrollten Matrix entsprechen.
Siehe auch matrixSlice().
void QRhiVertexInputAttribute::setOffset(quint32 ofs)
Setzt den Byte-Offset für das Eingabeelement auf ofs.
Siehe auch ` offset()`.
Verwandte Nicht-Mitglieder
[noexcept] size_t qHash(const QRhiVertexInputAttribute &key, size_t seed = 0)
Gibt den Hash-Wert für „ key “ zurück, wobei „ seed “ als Startwert für die Berechnung verwendet wird.
[noexcept] bool operator!=(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b)
Gibt „ false “ zurück, wenn die Werte in den beiden „ QRhiVertexInputAttribute “-Objekten „ a “ und „ b “ gleich sind; andernfalls wird „ true “ zurückgegeben.
[noexcept] bool operator==(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b)
Gibt „ true “ zurück, wenn die Werte in den beiden „ QRhiVertexInputAttribute “-Objekten „ a “ und „ b “ identisch sind.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.