summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi/qrhi_p_p.h
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2022-07-07 12:27:44 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2022-07-12 17:16:37 +0200
commit7de0f3e9ccff3b9eea1c240530834c52ca56d1c0 (patch)
tree3133d1a10a47fadd34d901fecd57ebea7d2e5c9f /src/gui/rhi/qrhi_p_p.h
parent7b6350fa7743fa4ca10f5aebe0962b6544604e33 (diff)
rhi: Clean up some inconsistencies
Some of the offsets are already quint32 in the API (vertex input attributes, dynamic offsets, offsets in draw calls), matching the reality of the underlying 3D APIs, but many buffer-related functions use int as of now, simply because that used to be the default choice, and the same goes for sizes (such as buffer or range sizes). This is not quite consistent and should be cleaned up if for nothing else then just to make the classes consistent, but also because no 3D API use a signed type for offsets, sizes, and strides. (except OpenGL for some) When it comes to strides (for vertex inputs and raw image texture uploads), those are already all quint32s. This is straightforward because most of the 3D APIs use 32-bit uints for these regardless of the architecture. Sizes and offsets are often architecture-dependent (Vulkan, Metal), but there is at least one API where they are always 32-bit even on 64-bit Windows (UINT == unsigned int, D3D11). In addition, we do not really care about buffer or texture data larger than 4 GB, at least not without realistic use cases and real world testing, which are quite unlikely to materialize for now (esp. since we still have the width/height of 2D textures limited to 16 or 32K in many cases even on desktops, whereas 2GB+ buffers are not guaranteed in practice even when an API seemingly allows it). In any case, the important change here is the signed->unsigned switch. A number of casts can now be removed here and there in the backends, because the offsets and sizes are now unsigned as well, matching the underlying API reality. The size can be potentially increased later on with minimal effort, if that becomes necessary for some reason. Change-Id: I404dbc365ac397eaeeb3bd2da9ce7eb98916da5f Reviewed-by: Inho Lee <inho.lee@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi/qrhi_p_p.h')
-rw-r--r--src/gui/rhi/qrhi_p_p.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/gui/rhi/qrhi_p_p.h b/src/gui/rhi/qrhi_p_p.h
index 516536575c..d7490f07c0 100644
--- a/src/gui/rhi/qrhi_p_p.h
+++ b/src/gui/rhi/qrhi_p_p.h
@@ -43,7 +43,7 @@ public:
virtual QRhiShaderResourceBindings *createShaderResourceBindings() = 0;
virtual QRhiBuffer *createBuffer(QRhiBuffer::Type type,
QRhiBuffer::UsageFlags usage,
- int size) = 0;
+ quint32 size) = 0;
virtual QRhiRenderBuffer *createRenderBuffer(QRhiRenderBuffer::Type type,
const QSize &pixelSize,
int sampleCount,
@@ -288,10 +288,10 @@ struct QRhiBufferDataPrivate
QRhiBufferDataPrivate() { }
~QRhiBufferDataPrivate() { delete[] largeData; }
int ref = 1;
- int size = 0;
- int largeAlloc = 0;
+ quint32 size = 0;
+ quint32 largeAlloc = 0;
char *largeData = nullptr;
- static constexpr int SMALL_DATA_SIZE = 1024;
+ static constexpr quint32 SMALL_DATA_SIZE = 1024;
char data[SMALL_DATA_SIZE];
};
@@ -326,11 +326,11 @@ public:
{
return d->size <= QRhiBufferDataPrivate::SMALL_DATA_SIZE ? d->data : d->largeData;
}
- int size() const
+ quint32 size() const
{
return d->size;
}
- void assign(const char *s, int size)
+ void assign(const char *s, quint32 size)
{
if (!d) {
d = new QRhiBufferDataPrivate;
@@ -367,12 +367,12 @@ public:
};
Type type;
QRhiBuffer *buf;
- int offset;
+ quint32 offset;
QRhiBufferData data;
- int readSize;
+ quint32 readSize;
QRhiBufferReadbackResult *result;
- static BufferOp dynamicUpdate(QRhiBuffer *buf, int offset, int size, const void *data)
+ static BufferOp dynamicUpdate(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
{
BufferOp op = {};
op.type = DynamicUpdate;
@@ -383,7 +383,7 @@ public:
return op;
}
- static void changeToDynamicUpdate(BufferOp *op, QRhiBuffer *buf, int offset, int size, const void *data)
+ static void changeToDynamicUpdate(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
{
op->type = DynamicUpdate;
op->buf = buf;
@@ -392,7 +392,7 @@ public:
op->data.assign(reinterpret_cast<const char *>(data), effectiveSize);
}
- static BufferOp staticUpload(QRhiBuffer *buf, int offset, int size, const void *data)
+ static BufferOp staticUpload(QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
{
BufferOp op = {};
op.type = StaticUpload;
@@ -403,7 +403,7 @@ public:
return op;
}
- static void changeToStaticUpload(BufferOp *op, QRhiBuffer *buf, int offset, int size, const void *data)
+ static void changeToStaticUpload(BufferOp *op, QRhiBuffer *buf, quint32 offset, quint32 size, const void *data)
{
op->type = StaticUpload;
op->buf = buf;
@@ -412,7 +412,7 @@ public:
op->data.assign(reinterpret_cast<const char *>(data), effectiveSize);
}
- static BufferOp read(QRhiBuffer *buf, int offset, int size, QRhiBufferReadbackResult *result)
+ static BufferOp read(QRhiBuffer *buf, quint32 offset, quint32 size, QRhiBufferReadbackResult *result)
{
BufferOp op = {};
op.type = Read;