Module: vkd3d
Branch: master
Commit: 13ca6322c73d33049e40d957a6cf03a3ffca7fbd
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=13ca6322c73d33049e40d95…
Author: David Gow <david(a)ingeniumdigital.com>
Date: Wed Mar 9 23:24:37 2022 +1000
vkd3d: Handle D3D12_APPEND_ALIGNED_ELEMENT for <4 byte wide elements.
In d3d12, input element alignment needs to be the _minimum_ of 4 and the size of
the type. See the D3D11 spec, section 4.4.6, which behaves similarly:
https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpe…
This is correctly taken into account when generating, e.g., the
vertex_buffer_stride_align_mask used for validation, but is not taken
into account when D3D12_APPEND_ALIGNED_ELEMENT is used to automatically
place input elements. Currently, vkd3d always assumes the alignment is
4.
This means that, for example, bytes or shorts should be packed tightly
together when D3D12_APPEND_ALIGNED_ELEMENT is used, but are instead
padded to 4 bytes.
Fixing this makes units appear in Age of Empires IV.
Signed-off-by: Conor McCarthy <cmccarthy(a)codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
libs/vkd3d/state.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 0e7800a4..72422897 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -2430,9 +2430,9 @@ static HRESULT compute_input_layout_offsets(const struct d3d12_device *device,
if (e->AlignedByteOffset != D3D12_APPEND_ALIGNED_ELEMENT)
offsets[i] = e->AlignedByteOffset;
else
- offsets[i] = input_slot_offsets[e->InputSlot];
+ offsets[i] = align(input_slot_offsets[e->InputSlot], min(4, format->byte_count));
- input_slot_offsets[e->InputSlot] = align(offsets[i] + format->byte_count, 4);
+ input_slot_offsets[e->InputSlot] = offsets[i] + format->byte_count;
}
return S_OK;