diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-05-19 19:30:53 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-05-31 17:16:57 +0200 |
commit | 51c22a1f51e2f91289c938be7754f957c9bfa47e (patch) | |
tree | 58eea1c4aeb83f4ee2ede516f321624ab5558181 /src/gui/rhi/qrhi_p_p.h | |
parent | 5eab5d62530f351307a01ca57af964e5c506079c (diff) |
rhi: Add support for 3D textures
Supported on OpenGL (and ES) 3.0+ and everywhere else.
Can also be a render target, targeting a single slice at a time.
Can be mipmapped, cannot be multisample.
Reading back a given slice from a 3D texture is left as a future
exercise, for now it is documented to be not supported.
Upload is going to be limited to one slice in one upload entry,
just like we specify one face or one miplevel for cubemap and
mipmapped textures.
This also involves some welcome hardening of how texture subresources
are described internally: as we no longer can count on a layer index
between 0..5 (as is the case with cubemaps), simply arrays with
MAX_LAYER==6 are no longer sufficient. Switch to sufficiently dynamic
data structures where applicable.
On Vulkan rendering to a slice needs Vulkan 1.1 (and 1.1 enabled on the
VkInstance).
Task-number: QTBUG-89703
Change-Id: Ide6c20124ec9201d94ffc339dd479cd1ece777b0
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhi_p_p.h')
-rw-r--r-- | src/gui/rhi/qrhi_p_p.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gui/rhi/qrhi_p_p.h b/src/gui/rhi/qrhi_p_p.h index f33626ae1d..89dd7b8e44 100644 --- a/src/gui/rhi/qrhi_p_p.h +++ b/src/gui/rhi/qrhi_p_p.h @@ -87,6 +87,7 @@ public: QRhiTexture::Format backingFormatHint) = 0; virtual QRhiTexture *createTexture(QRhiTexture::Format format, const QSize &pixelSize, + int depth, int sampleCount, QRhiTexture::Flags flags) = 0; virtual QRhiSampler *createSampler(QRhiSampler::Filter magFilter, @@ -180,7 +181,7 @@ public: QSize *blockDim) const; void textureFormatInfo(QRhiTexture::Format format, const QSize &size, quint32 *bpl, quint32 *byteSize, quint32 *bytesPerPixel) const; - quint32 approxByteSizeForTexture(QRhiTexture::Format format, const QSize &baseSize, + quint32 approxByteSizeForTexture(QRhiTexture::Format format, const QSize &baseSize, int depth, int mipCount, int layerCount); QRhiProfilerPrivate *profilerPrivateOrNull() @@ -447,7 +448,8 @@ public: // In the backend this can then end up, where applicable, as a // single, batched copy operation with only one set of barriers. // This helps when doing for example glyph cache fills. - QList<QRhiTextureSubresourceUploadDescription> subresDesc[QRhi::MAX_LAYERS][QRhi::MAX_LEVELS]; + using MipLevelUploadList = std::array<QVector<QRhiTextureSubresourceUploadDescription>, QRhi::MAX_MIP_LEVELS>; + QVarLengthArray<MipLevelUploadList, 6> subresDesc; QRhiTexture *src; QRhiTextureCopyDescription desc; QRhiReadbackDescription rb; @@ -458,6 +460,12 @@ public: TextureOp op = {}; op.type = Upload; op.dst = tex; + int maxLayer = -1; + for (auto it = desc.cbeginEntries(), itEnd = desc.cendEntries(); it != itEnd; ++it) { + if (it->layer() > maxLayer) + maxLayer = it->layer(); + } + op.subresDesc.resize(maxLayer + 1); for (auto it = desc.cbeginEntries(), itEnd = desc.cendEntries(); it != itEnd; ++it) op.subresDesc[it->layer()][it->level()].append(it->description()); return op; |