Commit c61ea851 authored by Laszlo Agocs's avatar Laszlo Agocs

Make texture upload/copy/read/gen ops run in order

The order is important here, if there are multiple operations
targeting or reading from the same texture.
parent 0426af6d
......@@ -3728,7 +3728,7 @@ void QRhiResourceUpdateBatch::uploadStaticBuffer(QRhiBuffer *buf, const void *da
*/
void QRhiResourceUpdateBatch::uploadTexture(QRhiTexture *tex, const QRhiTextureUploadDescription &desc)
{
d->textureUploads.append({ tex, desc });
d->textureOps.append(QRhiResourceUpdateBatchPrivate::TextureOp::textureUpload(tex, desc));
}
/*!
......@@ -3753,7 +3753,7 @@ void QRhiResourceUpdateBatch::uploadTexture(QRhiTexture *tex, const QImage &imag
*/
void QRhiResourceUpdateBatch::copyTexture(QRhiTexture *dst, QRhiTexture *src, const QRhiTextureCopyDescription &desc)
{
d->textureCopies.append({ dst, src, desc });
d->textureOps.append(QRhiResourceUpdateBatchPrivate::TextureOp::textureCopy(dst, src, desc));
}
/*!
......@@ -3796,7 +3796,7 @@ void QRhiResourceUpdateBatch::copyTexture(QRhiTexture *dst, QRhiTexture *src, co
*/
void QRhiResourceUpdateBatch::readBackTexture(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
{
d->textureReadbacks.append({ rb, result });
d->textureOps.append(QRhiResourceUpdateBatchPrivate::TextureOp::textureRead(rb, result));
}
/*!
......@@ -3807,7 +3807,7 @@ void QRhiResourceUpdateBatch::readBackTexture(const QRhiReadbackDescription &rb,
*/
void QRhiResourceUpdateBatch::generateMips(QRhiTexture *tex)
{
d->textureMipGens.append(QRhiResourceUpdateBatchPrivate::TextureMipGen(tex));
d->textureOps.append(QRhiResourceUpdateBatchPrivate::TextureOp::textureMipGen(tex));
}
/*!
......@@ -3858,10 +3858,7 @@ void QRhiResourceUpdateBatchPrivate::free()
dynamicBufferUpdates.clear();
staticBufferUploads.clear();
textureUploads.clear();
textureCopies.clear();
textureReadbacks.clear();
textureMipGens.clear();
textureOps.clear();
rhi->resUpdPoolMap.clearBit(poolIndex);
poolIndex = -1;
......@@ -3871,10 +3868,7 @@ void QRhiResourceUpdateBatchPrivate::merge(QRhiResourceUpdateBatchPrivate *other
{
dynamicBufferUpdates += other->dynamicBufferUpdates;
staticBufferUploads += other->staticBufferUploads;
textureUploads += other->textureUploads;
textureCopies += other->textureCopies;
textureReadbacks += other->textureReadbacks;
textureMipGens += other->textureMipGens;
textureOps += other->textureOps;
}
/*!
......
......@@ -240,51 +240,71 @@ public:
QByteArray data;
};
struct TextureUpload {
TextureUpload() { }
TextureUpload(QRhiTexture *tex_, const QRhiTextureUploadDescription &desc_)
: tex(tex_), desc(desc_)
{ }
QRhiTexture *tex = nullptr;
QRhiTextureUploadDescription desc;
};
struct TextureCopy {
TextureCopy() { }
TextureCopy(QRhiTexture *dst_, QRhiTexture *src_, const QRhiTextureCopyDescription &desc_)
: dst(dst_), src(src_), desc(desc_)
{ }
QRhiTexture *dst = nullptr;
QRhiTexture *src = nullptr;
QRhiTextureCopyDescription desc;
};
struct TextureRead {
TextureRead() { }
TextureRead(const QRhiReadbackDescription &rb_, QRhiReadbackResult *result_)
: rb(rb_), result(result_)
{ }
struct TextureOp {
enum Type {
TexUpload,
TexCopy,
TexRead,
TexMipGen
};
Type type;
struct Upload {
QRhiTexture *tex = nullptr;
QRhiTextureUploadDescription desc;
} upload;
struct Copy {
QRhiTexture *dst = nullptr;
QRhiTexture *src = nullptr;
QRhiTextureCopyDescription desc;
} copy;
struct Read {
QRhiReadbackDescription rb;
QRhiReadbackResult *result;
} read;
struct MipGen {
QRhiTexture *tex = nullptr;
} mipgen;
static TextureOp textureUpload(QRhiTexture *tex, const QRhiTextureUploadDescription &desc)
{
TextureOp op;
op.type = TexUpload;
op.upload.tex = tex;
op.upload.desc = desc;
return op;
}
QRhiReadbackDescription rb;
QRhiReadbackResult *result;
};
static TextureOp textureCopy(QRhiTexture *dst, QRhiTexture *src, const QRhiTextureCopyDescription &desc)
{
TextureOp op;
op.type = TexCopy;
op.copy.dst = dst;
op.copy.src = src;
op.copy.desc = desc;
return op;
}
struct TextureMipGen {
TextureMipGen() { }
TextureMipGen(QRhiTexture *tex_) : tex(tex_)
{ }
static TextureOp textureRead(const QRhiReadbackDescription &rb, QRhiReadbackResult *result)
{
TextureOp op;
op.type = TexRead;
op.read.rb = rb;
op.read.result = result;
return op;
}
QRhiTexture *tex = nullptr;
static TextureOp textureMipGen(QRhiTexture *tex)
{
TextureOp op;
op.type = TexMipGen;
op.mipgen.tex = tex;
return op;
}
};
QVector<DynamicBufferUpdate> dynamicBufferUpdates;
QVector<StaticBufferUpload> staticBufferUploads;
QVector<TextureUpload> textureUploads;
QVector<TextureCopy> textureCopies;
QVector<TextureRead> textureReadbacks;
QVector<TextureMipGen> textureMipGens;
QVector<TextureOp> textureOps;
QRhiResourceUpdateBatch *q = nullptr;
QRhiImplementation *rhi = nullptr;
......@@ -298,10 +318,7 @@ public:
Q_DECLARE_TYPEINFO(QRhiResourceUpdateBatchPrivate::DynamicBufferUpdate, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QRhiResourceUpdateBatchPrivate::StaticBufferUpload, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QRhiResourceUpdateBatchPrivate::TextureUpload, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QRhiResourceUpdateBatchPrivate::TextureCopy, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QRhiResourceUpdateBatchPrivate::TextureRead, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QRhiResourceUpdateBatchPrivate::TextureMipGen, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(QRhiResourceUpdateBatchPrivate::TextureOp, Q_MOVABLE_TYPE);
class Q_RHI_PRIVATE_EXPORT QRhiShaderResourceBindingPrivate
{
......
This diff is collapsed.
This diff is collapsed.
......@@ -62,15 +62,6 @@ struct QGles2Buffer : public QRhiBuffer
GLuint buffer = 0;
GLenum target;
QByteArray ubuf;
// struct ChangeRange {
// ChangeRange(int b = -1, int e = -1)
// : changeBegin(b), changeEnd(e)
// { }
// bool isNull() const { return changeBegin == -1 && changeEnd == -1; }
// int changeBegin;
// int changeEnd;
// };
// ChangeRange ubufChangeRange;
friend class QRhiGles2;
};
......
This diff is collapsed.
This diff is collapsed.
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