Commit 0930b4cb authored by Laszlo Agocs's avatar Laszlo Agocs

Add instanceStepRate to vertex input binding description

Only downside is that values other than 1 are not supported with Vulkan 1.0.
parent e0cd39dd
......@@ -126,11 +126,12 @@ struct Q_RHI_EXPORT QRhiVertexInputLayout
PerInstance
};
Binding() { }
Binding(quint32 stride_, Classification cls = PerVertex)
: stride(stride_), classification(cls)
Binding(quint32 stride_, Classification cls = PerVertex, int stepRate = 1)
: stride(stride_), classification(cls), instanceStepRate(stepRate)
{ }
quint32 stride; // must be a multiple of 4
Classification classification;
int instanceStepRate;
};
struct Q_RHI_EXPORT Attribute {
......
......@@ -1744,7 +1744,7 @@ bool QD3D11GraphicsPipeline::build()
const QRhiVertexInputLayout::Binding &binding(m_vertexInputLayout.bindings[attribute.binding]);
if (binding.classification == QRhiVertexInputLayout::Binding::PerInstance) {
desc.InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
desc.InstanceDataStepRate = 1;
desc.InstanceDataStepRate = binding.instanceStepRate;
} else {
desc.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
}
......
......@@ -1073,7 +1073,7 @@ bool QMetalGraphicsPipeline::build()
inputLayout.layouts[layoutIdx].stepFunction =
binding.classification == QRhiVertexInputLayout::Binding::PerInstance
? MTLVertexStepFunctionPerInstance : MTLVertexStepFunctionPerVertex;
inputLayout.layouts[layoutIdx].stepRate = 1;
inputLayout.layouts[layoutIdx].stepRate = binding.instanceStepRate;
inputLayout.layouts[layoutIdx].stride = binding.stride;
}
......
......@@ -3071,8 +3071,15 @@ bool QVkGraphicsPipeline::build()
VkVertexInputBindingDescription bindingInfo = {
uint32_t(i),
binding.stride,
binding.classification == QRhiVertexInputLayout::Binding::PerVertex ? VK_VERTEX_INPUT_RATE_VERTEX : VK_VERTEX_INPUT_RATE_INSTANCE
binding.classification == QRhiVertexInputLayout::Binding::PerVertex
? VK_VERTEX_INPUT_RATE_VERTEX : VK_VERTEX_INPUT_RATE_INSTANCE
};
if (binding.classification == QRhiVertexInputLayout::Binding::PerInstance
&& binding.instanceStepRate != 1)
{
// ### could be supported with VK_EXT_vertex_attribute_divisor (Vulkan 1.1)
qWarning("QRhiVulkan: Instance step rates other than 1 not currently supported");
}
vertexBindings.append(bindingInfo);
}
QVarLengthArray<VkVertexInputAttributeDescription, 4> vertexAttributes;
......
......@@ -4,7 +4,6 @@ mtl: fix Dynamic for non-uniform buffers
mtl: forcing immut. to Shared should not need multiple backing buffers
mtl: textures
mtl: mrt
what's up with instance step rate
d3d: show something about adapter or such when starting up
d3d: msaa (onscreen)
mtl: msaa (onscreen)
......@@ -37,12 +36,14 @@ compute?
tessellation?
indirect draw?
more tex: 3d, array?
vk: support instanceStepRate via VK_EXT_vertex_attribute_divisor
shadertools:
bytecode (fxc/dxc) for d3d?
bytecode for metal?
+++ done
what's up with instance step rate
remove geometry shader from enum
hlsl version config to qsb
msl version config to qsb
......
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