QRhiVertexInputAttribute Class

単一の頂点入力要素を記述します。詳細...

ヘッダー #include <rhi/qrhi.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::GuiPrivate)
qmake: QT += gui-private
以来:Qt 6.6

パブリックな型

enum Format { Float4, Float3, Float2, Float, UNormByte4, …, SShort }

パブリック関数

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

詳細説明

このメンバは、単一の頂点入力要素のバインディング番号、位置、フォーマット、およびオフセットを指定します。

注意: HLSL の場合、SPIR-V から変換された頂点シェーダーは、各入力のセマンティックとしてTEXCOORD<location> を使用すると想定されます。したがって、個別のセマンティック名とインデックスはありません。

例として、以下の入力を持つ頂点シェーダを想定します:

layout(location = 0) in vec4 position;
layout(location = 1) in vec2 texcoord;

ここで、3 つのコンポーネントの頂点位置(x, y, z) と 2 つのコンポーネントのテクスチャ座標(u, v) が、バッファ(または別々のバッファでもよい)にノンインターリーブ形式で提供されているとします。2つのバインディングが定義されると、属性は次のように指定できます:

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

この頂点入力レイアウトを持つグラフィックスパイプラインがバインドされると、頂点入力は、最初に位置、次にテクスチャ座標を持つ単一のバッファがあると仮定して、36個の頂点を持つ立方体を描画するために次のように設定できます:

const QRhiCommandBuffer::VertexInput vbufBindings[] = {
    { cubeBuf, 0 },
    { cubeBuf, 36 * 3 * sizeof(float) }
};
cb->setVertexInput(0, 2, vbufBindings);

インターリーブされたデータを扱う場合、バインディングは通常1つだけで、複数のアトリビュートが同じバッファのバインディングポイントを参照します:

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

となります:

const QRhiCommandBuffer::VertexInput vbufBinding(interleavedCubeBuf, 0);
cb->setVertexInput(0, 1, &vbufBinding);

Note: これは互換性保証に制限のあるRHI APIです。詳細はQRhi を参照してください。

QRhiCommandBuffer::setVertexInput()も参照

メンバー型ドキュメント

enum QRhiVertexInputAttribute::Format

要素データの型を指定します。

定数説明
QRhiVertexInputAttribute::Float404成分浮動小数点ベクトル
QRhiVertexInputAttribute::Float313成分浮動小数点ベクトル
QRhiVertexInputAttribute::Float222成分浮動小数点ベクトル
QRhiVertexInputAttribute::Float3浮動小数点
QRhiVertexInputAttribute::UNormByte444成分正規化符号なしバイトベクトル
QRhiVertexInputAttribute::UNormByte252成分正規化符号なしバイトベクトル
QRhiVertexInputAttribute::UNormByte6正規化符号なしバイト
QRhiVertexInputAttribute::UInt474成分符号なし整数ベクトル
QRhiVertexInputAttribute::UInt383成分符号なし整数ベクトル
QRhiVertexInputAttribute::UInt292成分符号なし整数ベクトル
QRhiVertexInputAttribute::UInt10符号なし整数
QRhiVertexInputAttribute::SInt4114成分符号なし整数ベクトル
QRhiVertexInputAttribute::SInt3123成分符号なし整数ベクトル
QRhiVertexInputAttribute::SInt2132成分符号なし整数ベクトル
QRhiVertexInputAttribute::SInt14符号付き整数
QRhiVertexInputAttribute::Half4154成分半精度(16ビット)浮動小数点ベクトル
QRhiVertexInputAttribute::Half3163成分半精度(16ビット)浮動小数点ベクトル
QRhiVertexInputAttribute::Half2172成分半精度(16ビット)浮動小数点ベクトル
QRhiVertexInputAttribute::Half18半精度(16ビット)浮動小数点
QRhiVertexInputAttribute::UShort4194成分符号なしショート(16ビット)整数ベクトル
QRhiVertexInputAttribute::UShort3203成分符号なしショート(16ビット)整数ベクトル
QRhiVertexInputAttribute::UShort2212成分符号なしショート(16ビット)整数ベクトル
QRhiVertexInputAttribute::UShort22符号なしショート(16ビット)整数
QRhiVertexInputAttribute::SShort4234成分符号なしショート(16ビット)整数ベクトル
QRhiVertexInputAttribute::SShort3243成分符号ありショート(16ビット)整数ベクトル
QRhiVertexInputAttribute::SShort2252コンポーネント符号ありショート(16ビット)整数ベクトル
QRhiVertexInputAttribute::SShort26符号付きショート(16ビット)整数

メモ: QRhi::Feature::HalfAttributes 機能フラグにより、半精度浮動小数点属性のサポートが実行時に示されます。

メモ : Direct3D 11/12は16ビットの入力属性をサポートしますが、Half3、UShort3、SShort3タイプはサポートしません。D3Dバックエンドは、Half3をHalf4として、UShort3をUShort4として、SShort3をSShort4として通過させます。クロスプラットフォームの互換性を確保するため、16ビット入力は8バイトにパディングする必要があります。

メンバー関数ドキュメント

[constexpr noexcept] QRhiVertexInputAttribute::QRhiVertexInputAttribute()

デフォルトの頂点入力属性記述を構築します。

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

指定されたbinding 番号、locationformatoffset を持つ頂点入力属性記述を構築します。

matrixSlice ただし,この属性が行列の行または列に対応する場合(例えば,4x4 行列は 4 vec4s となり,4 つの連続した頂点入力位置が消費されます),その場合は行または列のインデックスとなります. は,展開された行列の最初の行または列の と常に等しくなければなりません.location - matrixSlice location

int QRhiVertexInputAttribute::binding() const

バ イ ンデ ィ ン グ点 イ ンデ ッ ク ス を返 し ます。

setBinding()も参照してください

QRhiVertexInputAttribute::Format QRhiVertexInputAttribute::format() const

頂点入力要素のフォーマットを返す。

setFormat()も参照してください

int QRhiVertexInputAttribute::location() const

頂点入力要素の位置を返す。

setLocation()も参照してください

int QRhiVertexInputAttribute::matrixSlice() const

入力要素が行列の行または列に対応する場合,その行列スライスを返します.

setMatrixSlice()も参照してください

quint32 QRhiVertexInputAttribute::offset() const

入力要素のバイトオフセットを返します。

setOffset()も参照

void QRhiVertexInputAttribute::setBinding(int b)

バ イ ンデ ィ ン グ点 イ ンデ ッ ク ス をb に設定 し ます。 デフ ォル ト では 0 に設定 さ れてい ます。

binding()も参照してください

void QRhiVertexInputAttribute::setFormat(QRhiVertexInputAttribute::Format f)

頂点入力要素のフォーマットをf に設定します。 デフォルトでは Float4 に設定されています。

format()も参照してください

void QRhiVertexInputAttribute::setLocation(int loc)

頂点入力要素の位置をloc に設定します。 デフォルトでは 0 に設定されています。

location()も参照してください

void QRhiVertexInputAttribute::setMatrixSlice(int slice)

行列slice を設定します.デフォルトでは -1 に設定されており,この属性が行列の行または列に対応する場合のみ(例えば,4x4 行列は 4 vec4s となり,4 つの連続した頂点入力位置を消費します),0 以上の値を設定する必要があります.この場合,行または列のインデックスとなります.location - matrixSlice は,展開された行列の最初の行または列のlocation と常に等しくなければなりません.

matrixSlice()も参照してください

void QRhiVertexInputAttribute::setOffset(quint32 ofs)

入力要素のバイトオフセットをofs に設定します。

offset()も参照

関連する非会員

[noexcept] size_t qHash(const QRhiVertexInputAttribute &key, size_t seed = 0)

key のハッシュ値を返す。計算のシードにはseed を使用する。

[noexcept] bool operator!=(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b)

2つのQRhiVertexInputAttribute オブジェクトab の値が等しい場合はfalse を返し、そうでない場合はtrue を返す。

[noexcept] bool operator==(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b)

2つのQRhiVertexInputAttribute オブジェクトab の値が等しい場合、true を返す。

© 2025 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.