Commit 2db1c14c authored by Laszlo Agocs's avatar Laszlo Agocs
Browse files

Add a way to combine to res.update batches

parent 085a3bfe
...@@ -420,6 +420,11 @@ void QRhiResourceUpdateBatch::release() ...@@ -420,6 +420,11 @@ void QRhiResourceUpdateBatch::release()
d->free(); d->free();
} }
void QRhiResourceUpdateBatch::merge(QRhiResourceUpdateBatch *other)
{
d->merge(other->d);
}
void QRhiResourceUpdateBatch::updateDynamicBuffer(QRhiBuffer *buf, int offset, int size, const void *data) void QRhiResourceUpdateBatch::updateDynamicBuffer(QRhiBuffer *buf, int offset, int size, const void *data)
{ {
d->dynamicBufferUpdates.append({ buf, offset, size, data }); d->dynamicBufferUpdates.append({ buf, offset, size, data });
...@@ -487,6 +492,14 @@ void QRhiResourceUpdateBatchPrivate::free() ...@@ -487,6 +492,14 @@ void QRhiResourceUpdateBatchPrivate::free()
poolIndex = -1; poolIndex = -1;
} }
void QRhiResourceUpdateBatchPrivate::merge(QRhiResourceUpdateBatchPrivate *other)
{
dynamicBufferUpdates += other->dynamicBufferUpdates;
staticBufferUploads += other->staticBufferUploads;
textureUploads += other->textureUploads;
texturePrepares += other->texturePrepares;
}
int QRhi::ubufAligned(int v) const int QRhi::ubufAligned(int v) const
{ {
const int byteAlign = ubufAlignment(); const int byteAlign = ubufAlignment();
......
...@@ -267,6 +267,8 @@ struct Q_RHI_EXPORT QRhiTextureUploadDescription ...@@ -267,6 +267,8 @@ struct Q_RHI_EXPORT QRhiTextureUploadDescription
MipLevel(const QByteArray &compressedData_) : compressedData(compressedData_) { } MipLevel(const QByteArray &compressedData_) : compressedData(compressedData_) { }
QImage image; QImage image;
QByteArray compressedData; QByteArray compressedData;
QPointF topLeft; // (0, 0) by default
QSizeF size; // empty = entire image
}; };
Layer() { } Layer() { }
Layer(const QVector<MipLevel> &mipImages_) : mipImages(mipImages_) { } Layer(const QVector<MipLevel> &mipImages_) : mipImages(mipImages_) { }
...@@ -858,6 +860,12 @@ public: ...@@ -858,6 +860,12 @@ public:
// Puts the batch back to the pool without any processing. // Puts the batch back to the pool without any processing.
void release(); void release();
// Applications do not have to defer all upload preparation to the first
// frame: an update batch can be prepared in advance during initialization,
// and afterwards, if needed, merged into another that is then submitted to
// beginPass(). (nb the one we merged from must be release()'d manually)
void merge(QRhiResourceUpdateBatch *other);
// None of these execute anything. Deferred to beginPass. What exactly then // None of these execute anything. Deferred to beginPass. What exactly then
// happens underneath is hidden from the applications. // happens underneath is hidden from the applications.
void updateDynamicBuffer(QRhiBuffer *buf, int offset, int size, const void *data); void updateDynamicBuffer(QRhiBuffer *buf, int offset, int size, const void *data);
......
...@@ -188,6 +188,7 @@ struct QRhiResourceUpdateBatchPrivate ...@@ -188,6 +188,7 @@ struct QRhiResourceUpdateBatchPrivate
int poolIndex = -1; int poolIndex = -1;
void free(); void free();
void merge(QRhiResourceUpdateBatchPrivate *other);
static QRhiResourceUpdateBatchPrivate *get(QRhiResourceUpdateBatch *b) { return b->d; } static QRhiResourceUpdateBatchPrivate *get(QRhiResourceUpdateBatch *b) { return b->d; }
}; };
......
vk, d3d, gl, mtl: tex upload with rect
copyimage (color, with rect?, no resolve or transforms here)
mtl: rhi without a window, offscreen frame mtl: rhi without a window, offscreen frame
mtl: readback (tex, backbuffer) mtl: readback (tex, backbuffer)
gl, mtl: compressed textures gl, mtl: compressed textures
...@@ -13,7 +15,6 @@ test cubemap face as target ...@@ -13,7 +15,6 @@ test cubemap face as target
face cubemap readback? (test vk/d3d, impl for gl) face cubemap readback? (test vk/d3d, impl for gl)
cbuffer alignment rules - some things fail to translate (to hlsl e.g. with structs), which is fine but how to mitigate cbuffer alignment rules - some things fail to translate (to hlsl e.g. with structs), which is fine but how to mitigate
resource import/export, what's the co-op story? resource import/export, what's the co-op story?
copyimage (color and ds, no resolve or transforms here)
does reading back an msaa swapchain buffer work? does reading back an msaa swapchain buffer work?
msaa offscreen (msaa texture. no readback.) msaa offscreen (msaa texture. no readback.)
resolveimage (color and ds, only to resolve samples) resolveimage (color and ds, only to resolve samples)
...@@ -46,13 +47,15 @@ vk: subpasses? ...@@ -46,13 +47,15 @@ vk: subpasses?
more tex: 3d, array? more tex: 3d, array?
vk compressed tex: could it consume a complete ktx without any memcpys? vk compressed tex: could it consume a complete ktx without any memcpys?
multi-buffer (region) readback? multi-buffer (region) readback?
depth readback? depth readback
copy image depth
shadertools: shadertools:
dxc for d3d as an alternative to fxc? dxc for d3d as an alternative to fxc?
hlsl -> dxc -> spirv -> spirv-cross hmmm... hlsl -> dxc -> spirv -> spirv-cross hmmm...
+++ done +++ done
res upd batch combine
gl: offscreen frame, readback gl: offscreen frame, readback
d3d: readback d3d: readback
d3d: offscreen frame d3d: offscreen frame
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment