QRhiTextureRenderTargetDescription Class

レンダーターゲットの色と深度、または深度とステンシルのアタッチメントを記述します。詳細...

ヘッダー #include <rhi/qrhi.h>
レンダリングターゲットの色と深度、または深度/ステンシルアタッチメントを記述します: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::GuiPrivate)
qmake: QT += gui-private
以来:Qt 6.6

パブリック関数

QRhiTextureRenderTargetDescription()
QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment)
QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment, QRhiRenderBuffer *depthStencilBuffer)
QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment, QRhiTexture *depthTexture)
const QRhiColorAttachment *cbeginColorAttachments() const
const QRhiColorAttachment *cendColorAttachments() const
const QRhiColorAttachment *colorAttachmentAt(qsizetype index) const
qsizetype colorAttachmentCount() const
(since 6.8) QRhiTexture *depthResolveTexture() const
QRhiRenderBuffer *depthStencilBuffer() const
QRhiTexture *depthTexture() const
void setColorAttachments(std::initializer_list<QRhiColorAttachment> list)
void setColorAttachments(InputIterator first, InputIterator last)
(since 6.8) void setDepthResolveTexture(QRhiTexture *tex)
void setDepthStencilBuffer(QRhiRenderBuffer *renderBuffer)
void setDepthTexture(QRhiTexture *texture)

詳細な説明

テクスチャレンダリングターゲットは、カラーアタッチメントとして0個以上のテクスチャ、深度/ステンシルバッファの組み合わせとして0個または1個のレンダーバッファ、または深度バッファとして0個または1個のテクスチャを持ちます。

注: depthStencilBuffer() とdepthTexture() の両方を設定することはできません(同時に非 NULL にすることはできません)。

QRhiTextureRenderTarget と組み合わせた使用例を見てみましょう。

コンストラクタのおかげで、テクスチャ(および深度/ステンシルバッファなし)をターゲットにするのは簡単です:

QRhiTexture *texture = rhi->newTexture(QRhiTexture::RGBA8, QSize(256, 256), 1, QRhiTexture::RenderTarget);
texture->create();
QRhiTextureRenderTarget *rt = rhi->newTextureRenderTarget({ texture }));

以下は、テクスチャのミップレベル#2をターゲットにするように設定されたテクスチャのレンダーターゲットを作成します:

QRhiTexture *texture = rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget | QRhiTexture::MipMapped);
texture->create();
QRhiColorAttachment colorAtt(texture);
colorAtt.setLevel(2);
QRhiTextureRenderTarget *rt = rhi->newTextureRenderTarget({ colorAtt });

別の例として、今度は深度テクスチャにレンダリングします:

QRhiTexture *shadowMap = rhi->newTexture(QRhiTexture::D32F, QSize(1024, 1024), 1, QRhiTexture::RenderTarget);
shadowMap->create();
QRhiTextureRenderTargetDescription rtDesc;
rtDesc.setDepthTexture(shadowMap);
QRhiTextureRenderTarget *rt = rhi->newTextureRenderTarget(rtDesc);

非常に一般的なケースで、カラーアタッチメントとしてテクスチャを持ち、深度テストを可能にするために深度/ステンシルとしてレンダーバッファを持つ:

QRhiTexture *texture = rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget);
texture->create();
QRhiRenderBuffer *depthStencil = rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, QSize(512, 512));
depthStencil->create();
QRhiTextureRenderTargetDescription rtDesc({ texture }, depthStencil);
QRhiTextureRenderTarget *rt = rhi->newTextureRenderTarget(rtDesc);

最後に、ポータブルな方法で(OpenGL ES 3.0もサポートする)マルチサンプルレンダリングを可能にするために、(マルチサンプルの)カラーバッファとしてQRhiRenderBuffer 、通常の(非マルチサンプルの)2Dテクスチャに分解します。深度テストを可能にするために、同じサンプルカウントを使用しなければならない深度ステンシルバッファも同様に使用されます:

QRhiRenderBuffer *colorBuffer = rhi->newRenderBuffer(QRhiRenderBuffer::Color, QSize(512, 512), 4); // 4x MSAA
colorBuffer->create();
QRhiRenderBuffer *depthStencil = rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, QSize(512, 512), 4);
depthStencil->create();
QRhiTexture *texture = rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget);
texture->create();
QRhiColorAttachment colorAtt(colorBuffer);
colorAtt.setResolveTexture(texture);
QRhiTextureRenderTarget *rt = rhi->newTextureRenderTarget({ colorAtt, depthStencil });

注意: マルチサンプル分解が有効な場合、マルチサンプルデータはまったく書き出されないことがあります。これは、カラーアタッチメント内のマルチサンプ ルテクスチャを、resolveテクスチャが設定されるたびに、シェーダでサンプ リング(または他の目的)のために後から使用してはならないことを意味 します。詳細はPreserveColorContents を参照してください。

Note: setDepthStencilBuffer() ではなく、setDepthTexture() を使用し、その後、深度(ステンシル)データに関心がない場合、QRhiTextureRenderTarget に DoNotStoreDepthStencilContents フラグを設定します。 これにより、深度/ステンシルデータを破棄できることを基礎となる 3D API に示すことができ、タイル型 GPU アーキテクチャでより良いパフォーマンスにつながる可能性があります。デプス・ステンシル・バッファがQRhiRenderBuffer の場合(およびマルチサンプル・カラー・テクスチャの場合も、前のノートを参照)、これは暗黙的ですが、デプス(ステンシル)QRhiTexture の場合は、明示的に宣言する必要があります。デフォルトでは、QRhi はデータが関心のあるものであると仮定します(例えば、深度テクスチャはその後にシェーダでサンプリングされます)。

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

QRhiColorAttachment およびQRhiTextureRenderTargetも参照して ください。

メンバ関数ドキュメント

[constexpr noexcept] QRhiTextureRenderTargetDescription::QRhiTextureRenderTargetDescription()

空のテクスチャレンダリングターゲット記述を構築します。

QRhiTextureRenderTargetDescription::QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment)

colorAttachment で記述された1つのアタッチメントを持つテクスチャ レンダー ターゲット記述を構築します。

QRhiTextureRenderTargetDescription::QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment, QRhiRenderBuffer *depthStencilBuffer)

colorAttachment で記述されたカラーアタッチメントと、depthStencilBuffer で記述された深度/ステンシルアタッチメントの、2つのアタッチメントを持つテクスチャーレンダリングターゲット記述を構築します。

QRhiTextureRenderTargetDescription::QRhiTextureRenderTargetDescription(const QRhiColorAttachment &colorAttachment, QRhiTexture *depthTexture)

colorAttachment で記述されたカラーアタッチメントと、depthTexture で記述された深度アタッチメントの 2 つのアタッチメントを持つテクスチャレンダリングターゲット記述を構築します。

注: depthTexture は、QRhiTexture::D16QRhiTexture::D32F のような適切なフォーマットでなければなりません。

const QRhiColorAttachment *QRhiTextureRenderTargetDescription::cbeginColorAttachments() const

添付ファイルリストの最初の項目を指す定数イテレータを返します。

const QRhiColorAttachment *QRhiTextureRenderTargetDescription::cendColorAttachments() const

添付ファイルリストの最後のアイテムの直後を指す定数イテレータを返します。

const QRhiColorAttachment *QRhiTextureRenderTargetDescription::colorAttachmentAt(qsizetype index) const

指定 し たindex での添付色を返 し ます。

qsizetype QRhiTextureRenderTargetDescription::colorAttachmentCount() const

現在設定されているカラーアタッチメントの数を返します。

[since 6.8] QRhiTexture *QRhiTextureRenderTargetDescription::depthResolveTexture() const

マルチサンプル深度(または深度ステンシル)テクスチャ(またはテクスチャ配列)が解決されるテクスチャを返します。nullptr 、これが最も一般的なケースですが、存在しない場合。

この関数は Qt 6.8 で導入されました。

setDepthResolveTexture(),QRhiColorAttachment::resolveTexture(),depthTexture()も参照してください

QRhiRenderBuffer *QRhiTextureRenderTargetDescription::depthStencilBuffer() const

深度ステンシルバッファとして使用されるレンダーバッファ、または何も設定されていない場合はnullptr を返します。

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

QRhiTexture *QRhiTextureRenderTargetDescription::depthTexture() const

現在参照されている深度テクスチャ、または何も設定されていない場合はnullptr を返します。

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

void QRhiTextureRenderTargetDescription::setColorAttachments(std::initializer_list<QRhiColorAttachment> list)

カラーアタッチメントのlist を設定する。

template <typename InputIterator> void QRhiTextureRenderTargetDescription::setColorAttachments(InputIterator first, InputIterator last)

イテレータfirstlast を使って、添付色のリストを設定します。

[since 6.8] void QRhiTextureRenderTargetDescription::setDepthResolveTexture(QRhiTexture *tex)

デプス(またはデプス-ステンシル)リゾルブテクスチャを設定するtex

tex は、 () を介して設定されたテクスチャに一致するフォーマットを持つ2Dテクスチャまたは2Dテクスチャ配列であることが期待されます。setDepthTexture

注意: 深度(または深度ステンシル)データの解決は、実行時にResolveDepthStencil機能がサポートされていると報告されている場合にのみ機能します。深度ステンシルの解決は、グラフィックス API 間で普遍的に使用できるわけではありません。そのため、無条件に depth-stencil resolve が利用可能であると仮定したデザインは移植不可能であり、避けるべきです。

注意: 特に OpenGL ES の追加制限として、深度解決テクスチャの設定は、setDepthStencilBuffer() ではなく、setDepthTexture() との組み合わせでのみ機能する可能性があります。

この関数は Qt 6.8 で導入されました。

depthResolveTexture(),QRhiColorAttachment::setResolveTexture(),setDepthTexture()も参照してください

void QRhiTextureRenderTargetDescription::setDepthStencilBuffer(QRhiRenderBuffer *renderBuffer)

depth-stencil のrenderBuffer を設定する。必須ではありません。例えば、このレンダーターゲットのいずれかのレンダーパスのグラフィックスパイプライン内で深度テスト/書き込みまたはステンシル関連の機能が使用されていない場合、nullptr に設定したままにすることができます。

注: depthStencilBuffer() とdepthTexture() の両方を設定することはできません(同時に非 NULL にすることはできません)。

深度または深度/ステンシルバッファとして 2DQRhiTexture の上にQRhiRenderBuffer を使用することは非常に一般的であり、アプリケーションで推奨されるアプローチです。QRhiTexture 、したがってsetDepthTexture ()を使用することは、深度データがその後にアクセスされる(たとえば、シェーダでサンプリングされる)ことが意図されている場合、またはmultiview rendering (その場合、深度テクスチャはテクスチャ配列でなければならないため)が関与している場合に関連してきます。

depthStencilBuffer() およびsetDepthTexture()も参照してください

void QRhiTextureRenderTargetDescription::setDepthTexture(QRhiTexture *texture)

depth-stencil のtexture を設定する。これはsetDepthStencilBuffer() の代替で、QRhiRenderBuffer の代わりに、適切な型 (たとえばQRhiTexture::D32F) を持つQRhiTexture を指定する。

注意: depthStencilBuffer() とdepthTexture() の両方を設定することはできません(同時に非 NULL にすることはできません)。

texture には、2Dテクスチャまたは2Dテクスチャ配列を指定できます(テクスチャ配列がサポートされている場合)。テクスチャ配列の指定は、特に と関連しています。multiview rendering

注: textureQRhiTexture::D24S8 のようなステンシルコンポーネントを持つフォーマットである場合、それはステンシルバッファとしても機能します。

depthTexture() およびsetDepthStencilBuffer()も参照

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