QRhiShaderStage 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 | Type { Vertex, TessellationControl, TessellationEvaluation, Fragment, Compute, Geometry } |
パブリック関数
| QRhiShaderStage() | |
| QRhiShaderStage(QRhiShaderStage::Type type, const QShader &shader, QShader::Variant v = QShader::StandardShader) | |
| void | setShader(const QShader &s) |
| void | setShaderVariant(QShader::Variant v) |
| void | setType(QRhiShaderStage::Type t) |
| QShader | shader() const |
| QShader::Variant | shaderVariant() const |
| QRhiShaderStage::Type | type() const |
関連する非メンバ
| size_t | qHash(const QRhiShaderStage &key, size_t seed = 0) |
| bool | operator!=(const QRhiShaderStage &a, const QRhiShaderStage &b) |
| bool | operator==(const QRhiShaderStage &a, const QRhiShaderStage &b) |
詳細な説明
QRhiGraphicsPipeline を設定する際には、シェーダステージのコレクションが指定されます。 QRhiShaderStage には、QShader と、グラフィックス・パイプライン・ステージや選択するshader variant などの関連メタデータが含まれています。実行時に使用されるQRhi バックエンドが、QShader 内のコレクションから適切なシェーダー・バージョンを選択するため、シェーダー言語やバージョンを指定する必要はありません。
一般的な使用法は、QRhiGraphicsPipeline::setShaderStages() と組み合わせて行うもので、ここでは、オフラインまたはビルド時に生成された.qsb ファイルからQShader を読み込む簡単なアプローチを示します:
QShader getShader(const QString &name)
{
QFile f(name);
return f.open(QIODevice::ReadOnly) ? QShader::fromSerialized(f.readAll()) : QShader();
}
QShader vs = getShader("material.vert.qsb");
QShader fs = getShader("material.frag.qsb");
pipeline->setShaderStages({
{ QRhiShaderStage::Vertex, vs },
{ QRhiShaderStage::Fragment, fs }
});注:これは 互換性の保証が限定的なRHI APIです。詳細については、QRhi を参照してください。
メンバ型のドキュメント
enum QRhiShaderStage::Type
シェーダーステージのタイプを指定します。
| 定数 | 値 | 説明 |
|---|---|---|
QRhiShaderStage::Vertex | 0 | 頂点ステージ |
QRhiShaderStage::TessellationControl | 1 | テッセレーション制御(ハルシェーダー)ステージ。QRhi::Tessellation 機能がサポートされている場合にのみ使用する必要があります。 |
QRhiShaderStage::TessellationEvaluation | 2 | テッセレーション評価(ドメインシェーダー)ステージ。QRhi::Tessellation 機能がサポートされている場合にのみ使用する必要があります。 |
QRhiShaderStage::Fragment | 4 | フラグメント(ピクセルシェーダー)ステージ |
QRhiShaderStage::Compute | 5 | コンピュートステージ。QRhi::Compute 機能がサポートされている場合にのみ使用する必要があります。 |
QRhiShaderStage::Geometry | 3 | ジオメトリステージ。QRhi::GeometryShader 機能がサポートされている場合にのみ使用する必要があります。 |
メンバ関数のドキュメント
[noexcept default] QRhiShaderStage::QRhiShaderStage()
QShader を空の状態にして、頂点ステージ用のシェーダステージ記述を構築します。
QRhiShaderStage::QRhiShaderStage(QRhiShaderStage::Type type, const QShader &shader, QShader::Variant v = QShader::StandardShader)
ステージのtype とshader を用いて、シェーダーステージの記述を構築します。
シェーダーバリアント `v ` のデフォルト値は `QShader::StandardShader` です。`QShader ` には、シェーダーの複数のソース版およびバイナリ版が含まれます。さらに、コードがわずかに変更されたシェーダーのバリアントも含めることができます。その後、`v ` を使用して、目的のバリアントを選択できます。
void QRhiShaderStage::setShader(const QShader &s)
シェーダーコレクション `s` を設定します。
shader()も参照してください 。
void QRhiShaderStage::setShaderVariant(QShader::Variant v)
要求されたシェーダーバリアントv を設定します。
shaderVariant()も参照してください 。
void QRhiShaderStage::setType(QRhiShaderStage::Type t)
ステージの型をt に設定します。実際には、セッターを使用する必要はほとんどないでしょう。ほとんどのアプリケーションでは、ほとんどの場合、QRhiShaderStage コンストラクタが使用されるでしょう。
type()も参照してください 。
QShader QRhiShaderStage::shader() const
グラフィックスパイプラインのこのステージで使用されるQShader を返します。
「setShader()」も参照してください 。
QShader::Variant QRhiShaderStage::shaderVariant() const
指定されたシェーダーバリアントを返します。
setShaderVariant()も参照してください 。
QRhiShaderStage::Type QRhiShaderStage::type() const
ステージの型を返します。
setType()も参照してください 。
関連する非メンバー
[noexcept] size_t qHash(const QRhiShaderStage &key, size_t seed = 0)
`key` のハッシュ値を返します。計算のシードには `seed ` を使用します。
[noexcept] bool operator!=(const QRhiShaderStage &a, const QRhiShaderStage &b)
2つのQRhiShaderStage オブジェクトa とb の値が等しい場合はfalse を返し、そうでない場合はtrue を返します。
[noexcept] bool operator==(const QRhiShaderStage &a, const QRhiShaderStage &b)
2つのQRhiShaderStage オブジェクト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.