QRhiVertexInputAttribute Class
単一の頂点入力要素について説明します。詳細...
| ヘッダー: | #include <rhi/qrhi.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS GuiPrivate) 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);注:これは 互換性の保証が限定的な RHI API です。詳細についてはQRhi を参照してください。
QRhiCommandBuffer::setVertexInput()も参照してください 。
メンバ型のドキュメント
enum QRhiVertexInputAttribute::Format
要素データの型を指定します。
| 定数 | 値 | 説明 |
|---|---|---|
QRhiVertexInputAttribute::Float4 | 0 | 4 成分の float 型ベクトル |
QRhiVertexInputAttribute::Float3 | 1 | 3 成分の float ベクトル |
QRhiVertexInputAttribute::Float2 | 2 | 2成分のfloatベクトル |
QRhiVertexInputAttribute::Float | 3 | Float |
QRhiVertexInputAttribute::UNormByte4 | 4 | 4成分の正規化された符号なしバイトベクトル |
QRhiVertexInputAttribute::UNormByte2 | 5 | 2成分の正規化された符号なしバイトベクトル |
QRhiVertexInputAttribute::UNormByte | 6 | 正規化された符号なしバイト |
QRhiVertexInputAttribute::UInt4 | 7 | 4成分の符号なし整数ベクトル |
QRhiVertexInputAttribute::UInt3 | 8 | 3成分の符号なし整数ベクトル |
QRhiVertexInputAttribute::UInt2 | 9 | 2成分の符号なし整数ベクトル |
QRhiVertexInputAttribute::UInt | 10 | 符号なし整数 |
QRhiVertexInputAttribute::SInt4 | 11 | 4成分の符号付き整数ベクトル |
QRhiVertexInputAttribute::SInt3 | 12 | 3成分の符号付き整数ベクトル |
QRhiVertexInputAttribute::SInt2 | 13 | 2成分の符号付き整数ベクトル |
QRhiVertexInputAttribute::SInt | 14 | 符号付き整数 |
QRhiVertexInputAttribute::Half4 | 15 | 4成分の半精度(16ビット)浮動小数点ベクトル |
QRhiVertexInputAttribute::Half3 | 16 | 3成分の半精度(16ビット)浮動小数点ベクトル |
QRhiVertexInputAttribute::Half2 | 17 | 2成分の半精度(16ビット)浮動小数点ベクトル |
QRhiVertexInputAttribute::Half | 18 | ハーフプレシジョン(16ビット)浮動小数点数 |
QRhiVertexInputAttribute::UShort4 | 19 | 4成分の符号なしshort(16ビット)整数ベクトル |
QRhiVertexInputAttribute::UShort3 | 20 | 3成分の符号なしショート(16ビット)整数ベクトル |
QRhiVertexInputAttribute::UShort2 | 21 | 2成分の符号なしショート(16ビット)整数ベクトル |
QRhiVertexInputAttribute::UShort | 22 | 符号なしショート(16 ビット)整数 |
QRhiVertexInputAttribute::SShort4 | 23 | 4成分の符号付きショート(16ビット)整数ベクトル |
QRhiVertexInputAttribute::SShort3 | 24 | 3成分の符号付きshort(16ビット)整数ベクトル |
QRhiVertexInputAttribute::SShort2 | 25 | 2成分の符号付きshort(16ビット)整数ベクトル |
QRhiVertexInputAttribute::SShort | 26 | 符号付きショート(16 ビット)整数 注: ハーフプレシジョン浮動小数点属性のサポートは 、実行時にQRhi::Feature::HalfAttributes 機能フラグによって示されます。 注: Direct3D 11/12 は 16 ビットの入力属性をサポートしていますが、Half3、UShort3、SShort3 タイプはサポートしていません。 D3D バックエンドでは、Half3 は Half4 として、UShort3 は UShort4 として、SShort3 は SShort4 として渡されます。クロスプラットフォームの互換性を確保するため、16 ビットの入力は 8 バイトにパディングする必要があります。 |
メンバ関数のドキュメント
[constexpr noexcept default] QRhiVertexInputAttribute::QRhiVertexInputAttribute()
デフォルトの頂点入力属性の記述を作成します。
QRhiVertexInputAttribute::QRhiVertexInputAttribute(int binding, int location, QRhiVertexInputAttribute::Format format, quint32 offset, int matrixSlice = -1)
指定されたbinding 番号、location 、format 、およびoffset を用いて、頂点入力属性の記述を構築します。
matrixSlice この属性が行または列に対応する場合(たとえば、4x4の行列は4つのvec4となり、4つの連続した頂点入力位置を消費する)を除き、location - matrixSlice は-1である必要があります。その場合は、行または列のインデックスとなります。 は、常に展開された行列の最初の行または列のlocation と等しくなければなりません。
int QRhiVertexInputAttribute::binding() const
バインディングポイントのインデックスを返します。
setBinding()も参照してください 。
QRhiVertexInputAttribute::Format QRhiVertexInputAttribute::format() const
頂点入力要素のフォーマットを返します。
setFormat()も参照してください 。
int QRhiVertexInputAttribute::location() const
頂点入力要素の位置を返します。
setLocation()も参照してください 。
int QRhiVertexInputAttribute::matrixSlice() const
入力が行列の行または列に対応する場合は、その行列のスライスを返します。該当しない場合は-1を返します。
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 つの vec4 となり、4 つの連続した頂点入力位置を消費します)にのみ、a >= 0 の値に設定する必要があります。その場合、a はその行または列のインデックスとなります。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 オブジェクトa とb の値が等しい場合はfalse を返し、そうでない場合はtrue を返します。
[noexcept] bool operator==(const QRhiVertexInputAttribute &a, const QRhiVertexInputAttribute &b)
2つのQRhiVertexInputAttribute オブジェクトa とb の値が等しい場合、true を返します。
© 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.