このページでは

QRhiTextureUploadDescription 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

パブリック関数

QRhiTextureUploadDescription()
QRhiTextureUploadDescription(const QRhiTextureUploadEntry &entry)
QRhiTextureUploadDescription(std::initializer_list<QRhiTextureUploadEntry> list)
const QRhiTextureUploadEntry *cbeginEntries() const
const QRhiTextureUploadEntry *cendEntries() const
const QRhiTextureUploadEntry *entryAt(qsizetype index) const
qsizetype entryCount() const
void setEntries(std::initializer_list<QRhiTextureUploadEntry> list)
void setEntries(InputIterator first, InputIterator last)

詳細な説明

QRhiResourceUpdateBatch::uploadTexture() とともに使用されます。この関数には 2 つのバリエーションがあります。1 つは `QImage ` を引数に取るもので、もう 1 つは `QRhiTextureUploadDescription` を引数に取るものです。前者は便宜上のバージョンであり、内部でレイヤー 0 のターゲットレベル 0 を指定した単一の画像を持つ `QRhiTextureUploadDescription` を作成します。

QImage の内容を、ピクセルサイズが一致するQRhiTexture にアップロードしたいという、一般的で単純なケースの例:

QImage image(256, 256, QImage::Format_RGBA8888);
image.fill(Qt::green); // or could use a QPainter targeting image
QRhiTexture *texture = rhi->newTexture(QRhiTexture::RGBA8, QSize(256, 256));
texture->create();
QRhiResourceUpdateBatch *u = rhi->nextResourceUpdateBatch();
u->uploadTexture(texture, image);

キューブマップ、事前に生成されたミップ画像、圧縮テクスチャ、または部分的なアップロードが関与する場合は、アプリケーションはこのクラスを使用する必要があります。

QRhiTextureUploadDescription では、バッチアップロードの指定も可能であり、これは例えばアトラスやグリフキャッシュテクスチャを生成する際に役立ちます: 同一のサブリソース(つまり、同じレイヤーおよびレベル)に対する複数の部分アップロードがサポートされており、バックエンドや基盤となるグラフィックスAPIによっては、それぞれに対して個別のuploadTexture()コマンドを発行するよりも、同じQRhiTextureUploadDescriptionにバッチ処理した方が効率的になる場合があります。

注:キューブマップには、 +X、-X、+Y、-Y、+Z、-Z の順で、6つの面それぞれに対応する1つのレイヤーがあります。

たとえば、キューブマップの面を指定する場合は、次のような形になります。

QImage faces[6];
// ...
QVarLengthArray<QRhiTextureUploadEntry, 6> entries;
for (int i = 0; i < 6; ++i)
  entries.append(QRhiTextureUploadEntry(i, 0, faces[i]));
QRhiTextureUploadDescription desc;
desc.setEntries(entries.cbegin(), entries.cend());
resourceUpdates->uploadTexture(texture, desc);

圧縮テクスチャのミップ画像を指定する別の例:

QList<QRhiTextureUploadEntry> entries;
const int mipCount = rhi->mipLevelsForSize(compressedTexture->pixelSize());
for (int level = 0; level < mipCount; ++level) {
    const QByteArray compressedDataForLevel = ..
    entries.append(QRhiTextureUploadEntry(0, level, compressedDataForLevel));
}
QRhiTextureUploadDescription desc;
desc.setEntries(entries.cbegin(), entries.cend());
resourceUpdates->uploadTexture(compressedTexture, desc);

同じサブリソースを対象とする部分的なアップロードについては、可能な限り単一のアップロードリクエストにまとめて行うことを推奨します:

QRhiTextureSubresourceUploadDescription subresDesc(image);
subresDesc.setSourceSize(QSize(10, 10));
subResDesc.setDestinationTopLeft(QPoint(50, 40));
QRhiTextureUploadEntry entry(0, 0, subresDesc); // layer 0, level 0

QRhiTextureSubresourceUploadDescription subresDesc2(image);
subresDesc2.setSourceSize(QSize(30, 40));
subResDesc2.setDestinationTopLeft(QPoint(100, 200));
QRhiTextureUploadEntry entry2(0, 0, subresDesc2); // layer 0, level 0, i.e. same subresource

QRhiTextureUploadDescription desc({ entry, entry2});
resourceUpdates->uploadTexture(texture, desc);

注:これは 互換性の保証が限定的な RHI API です。詳細については、QRhi を参照してください。

QRhiResourceUpdateBatchも参照してください 。

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

[constexpr noexcept default] QRhiTextureUploadDescription::QRhiTextureUploadDescription()

空のテクスチャアップロード記述を作成します。

QRhiTextureUploadDescription::QRhiTextureUploadDescription(const QRhiTextureUploadEntry &entry)

entry で定義される単一のサブリソースのアップロードを含む、テクスチャアップロード記述を作成します。

QRhiTextureUploadDescription::QRhiTextureUploadDescription(std::initializer_list<QRhiTextureUploadEntry> list)

指定されたlist のエントリを使用して、テクスチャアップロード記述を作成します。

注: list には 、同じレイヤーおよびレベルを持つ複数のQRhiTextureUploadEntry 要素を含めることもできます。これは、それらのアップロードが部分的な場合(つまり、サブリソース記述のソースサイズまたは画像がサブリソースの寸法よりも小さい場合)に意味があり、個別のuploadTexture()を呼び出すよりも効率的になる場合があります。

const QRhiTextureUploadEntry *QRhiTextureUploadDescription::cbeginEntries() const

エントリリストの最初の項目を指す const イテレータを返します。

const QRhiTextureUploadEntry *QRhiTextureUploadDescription::cendEntries() const

エントリリストの最後の項目の直後を指す const イテレータを返します。

const QRhiTextureUploadEntry *QRhiTextureUploadDescription::entryAt(qsizetype index) const

index にあるエントリを返します。

qsizetype QRhiTextureUploadDescription::entryCount() const

エントリの数を返します。

void QRhiTextureUploadDescription::setEntries(std::initializer_list<QRhiTextureUploadEntry> list)

エントリのlist を設定します。

template <typename InputIterator> void QRhiTextureUploadDescription::setEntries(InputIterator first, InputIterator last)

イテレータ `first ` および `last` を使用して、エントリのリストを設定します。

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