summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2022-07-07 11:02:58 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2022-07-07 17:53:23 +0200
commitcd3a6fa41497ba6f3dac123536d22b88c61c17a2 (patch)
tree94774096bd0c5f380d334270deae59f34fbc8fb2 /src
parent6619c9408778b8607948e46079ddb369f750214f (diff)
rhi: Fix up the instancing step rate type
This is a UINT/uint32_t/GLuint/NSUInteger in all APIs (with Metal being special due to being 64-bit in 64-bit apps whereas all others are 32-bit always, at least on 64-bit Windows) As the stride is already an uint32, follow suit for the step rate. There was no reason to have this as int in the first place. As an added bonus, some casts, that were previously needed when mapping to the underlying API reality, can now be removed. Change-Id: I8e0eef037bd795b637578dfc3e59dc2efaa5976c Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/gui/rhi/qrhi.cpp2
-rw-r--r--src/gui/rhi/qrhi_p.h8
-rw-r--r--src/gui/rhi/qrhid3d11.cpp2
-rw-r--r--src/gui/rhi/qrhigles2.cpp2
-rw-r--r--src/gui/rhi/qrhivulkan.cpp2
5 files changed, 8 insertions, 8 deletions
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp
index e0194e4f58..b269e95053 100644
--- a/src/gui/rhi/qrhi.cpp
+++ b/src/gui/rhi/qrhi.cpp
@@ -1177,7 +1177,7 @@ QDebug operator<<(QDebug dbg, const QRhiScissor &s)
\note \a stepRate other than 1 is only supported when
QRhi::CustomInstanceStepRate is reported to be supported.
*/
-QRhiVertexInputBinding::QRhiVertexInputBinding(quint32 stride, Classification cls, int stepRate)
+QRhiVertexInputBinding::QRhiVertexInputBinding(quint32 stride, Classification cls, quint32 stepRate)
: m_stride(stride),
m_classification(cls),
m_instanceStepRate(stepRate)
diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h
index 053049eaf8..ea1e6b312d 100644
--- a/src/gui/rhi/qrhi_p.h
+++ b/src/gui/rhi/qrhi_p.h
@@ -131,7 +131,7 @@ public:
};
QRhiVertexInputBinding() = default;
- QRhiVertexInputBinding(quint32 stride, Classification cls = PerVertex, int stepRate = 1);
+ QRhiVertexInputBinding(quint32 stride, Classification cls = PerVertex, quint32 stepRate = 1);
quint32 stride() const { return m_stride; }
void setStride(quint32 s) { m_stride = s; }
@@ -139,13 +139,13 @@ public:
Classification classification() const { return m_classification; }
void setClassification(Classification c) { m_classification = c; }
- int instanceStepRate() const { return m_instanceStepRate; }
- void setInstanceStepRate(int rate) { m_instanceStepRate = rate; }
+ quint32 instanceStepRate() const { return m_instanceStepRate; }
+ void setInstanceStepRate(quint32 rate) { m_instanceStepRate = rate; }
private:
quint32 m_stride = 0;
Classification m_classification = PerVertex;
- int m_instanceStepRate = 1;
+ quint32 m_instanceStepRate = 1;
};
Q_DECLARE_TYPEINFO(QRhiVertexInputBinding, Q_RELOCATABLE_TYPE);
diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp
index fddef52cee..4a5c909392 100644
--- a/src/gui/rhi/qrhid3d11.cpp
+++ b/src/gui/rhi/qrhid3d11.cpp
@@ -4425,7 +4425,7 @@ bool QD3D11GraphicsPipeline::create()
const QRhiVertexInputBinding *inputBinding = m_vertexInputLayout.bindingAt(it->binding());
if (inputBinding->classification() == QRhiVertexInputBinding::PerInstance) {
desc.InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
- desc.InstanceDataStepRate = UINT(inputBinding->instanceStepRate());
+ desc.InstanceDataStepRate = inputBinding->instanceStepRate();
} else {
desc.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
}
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index a2f909fbbe..11f56b945e 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -2889,7 +2889,7 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
f->glEnableVertexAttribArray(GLuint(locationIdx));
}
if (inputBinding->classification() == QRhiVertexInputBinding::PerInstance && caps.instancing) {
- f->glVertexAttribDivisor(GLuint(locationIdx), GLuint(inputBinding->instanceStepRate()));
+ f->glVertexAttribDivisor(GLuint(locationIdx), inputBinding->instanceStepRate());
if (Q_LIKELY(locationIdx < CommandBufferExecTrackedState::TRACKED_ATTRIB_COUNT))
state.nonzeroAttribDivisor[locationIdx] = true;
else
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp
index f1a700f926..72e32fd01a 100644
--- a/src/gui/rhi/qrhivulkan.cpp
+++ b/src/gui/rhi/qrhivulkan.cpp
@@ -6909,7 +6909,7 @@ bool QVkGraphicsPipeline::create()
};
if (it->classification() == QRhiVertexInputBinding::PerInstance && it->instanceStepRate() != 1) {
if (rhiD->caps.vertexAttribDivisor) {
- nonOneStepRates.append({ uint32_t(bindingIndex), uint32_t(it->instanceStepRate()) });
+ nonOneStepRates.append({ uint32_t(bindingIndex), it->instanceStepRate() });
} else {
qWarning("QRhiVulkan: Instance step rates other than 1 not supported without "
"VK_EXT_vertex_attribute_divisor on the device and "