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>
This commit is contained in:
parent
6619c94087
commit
cd3a6fa414
@ -1177,7 +1177,7 @@ QDebug operator<<(QDebug dbg, const QRhiScissor &s)
|
|||||||
\note \a stepRate other than 1 is only supported when
|
\note \a stepRate other than 1 is only supported when
|
||||||
QRhi::CustomInstanceStepRate is reported to be supported.
|
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_stride(stride),
|
||||||
m_classification(cls),
|
m_classification(cls),
|
||||||
m_instanceStepRate(stepRate)
|
m_instanceStepRate(stepRate)
|
||||||
|
@ -131,7 +131,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
QRhiVertexInputBinding() = default;
|
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; }
|
quint32 stride() const { return m_stride; }
|
||||||
void setStride(quint32 s) { m_stride = s; }
|
void setStride(quint32 s) { m_stride = s; }
|
||||||
@ -139,13 +139,13 @@ public:
|
|||||||
Classification classification() const { return m_classification; }
|
Classification classification() const { return m_classification; }
|
||||||
void setClassification(Classification c) { m_classification = c; }
|
void setClassification(Classification c) { m_classification = c; }
|
||||||
|
|
||||||
int instanceStepRate() const { return m_instanceStepRate; }
|
quint32 instanceStepRate() const { return m_instanceStepRate; }
|
||||||
void setInstanceStepRate(int rate) { m_instanceStepRate = rate; }
|
void setInstanceStepRate(quint32 rate) { m_instanceStepRate = rate; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
quint32 m_stride = 0;
|
quint32 m_stride = 0;
|
||||||
Classification m_classification = PerVertex;
|
Classification m_classification = PerVertex;
|
||||||
int m_instanceStepRate = 1;
|
quint32 m_instanceStepRate = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_TYPEINFO(QRhiVertexInputBinding, Q_RELOCATABLE_TYPE);
|
Q_DECLARE_TYPEINFO(QRhiVertexInputBinding, Q_RELOCATABLE_TYPE);
|
||||||
|
@ -4425,7 +4425,7 @@ bool QD3D11GraphicsPipeline::create()
|
|||||||
const QRhiVertexInputBinding *inputBinding = m_vertexInputLayout.bindingAt(it->binding());
|
const QRhiVertexInputBinding *inputBinding = m_vertexInputLayout.bindingAt(it->binding());
|
||||||
if (inputBinding->classification() == QRhiVertexInputBinding::PerInstance) {
|
if (inputBinding->classification() == QRhiVertexInputBinding::PerInstance) {
|
||||||
desc.InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
|
desc.InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
|
||||||
desc.InstanceDataStepRate = UINT(inputBinding->instanceStepRate());
|
desc.InstanceDataStepRate = inputBinding->instanceStepRate();
|
||||||
} else {
|
} else {
|
||||||
desc.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
desc.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
|
||||||
}
|
}
|
||||||
|
@ -2889,7 +2889,7 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
|
|||||||
f->glEnableVertexAttribArray(GLuint(locationIdx));
|
f->glEnableVertexAttribArray(GLuint(locationIdx));
|
||||||
}
|
}
|
||||||
if (inputBinding->classification() == QRhiVertexInputBinding::PerInstance && caps.instancing) {
|
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))
|
if (Q_LIKELY(locationIdx < CommandBufferExecTrackedState::TRACKED_ATTRIB_COUNT))
|
||||||
state.nonzeroAttribDivisor[locationIdx] = true;
|
state.nonzeroAttribDivisor[locationIdx] = true;
|
||||||
else
|
else
|
||||||
|
@ -6909,7 +6909,7 @@ bool QVkGraphicsPipeline::create()
|
|||||||
};
|
};
|
||||||
if (it->classification() == QRhiVertexInputBinding::PerInstance && it->instanceStepRate() != 1) {
|
if (it->classification() == QRhiVertexInputBinding::PerInstance && it->instanceStepRate() != 1) {
|
||||||
if (rhiD->caps.vertexAttribDivisor) {
|
if (rhiD->caps.vertexAttribDivisor) {
|
||||||
nonOneStepRates.append({ uint32_t(bindingIndex), uint32_t(it->instanceStepRate()) });
|
nonOneStepRates.append({ uint32_t(bindingIndex), it->instanceStepRate() });
|
||||||
} else {
|
} else {
|
||||||
qWarning("QRhiVulkan: Instance step rates other than 1 not supported without "
|
qWarning("QRhiVulkan: Instance step rates other than 1 not supported without "
|
||||||
"VK_EXT_vertex_attribute_divisor on the device and "
|
"VK_EXT_vertex_attribute_divisor on the device and "
|
||||||
|
Loading…
Reference in New Issue
Block a user