microsoft / microsoft/DirectX-Graphics-Samples
MiniEngine CommandSignature ByteStride doesn't take struct alignment into account
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 6.8k
- Forks
- 2.2k
- PR merge metrics
- No merged PRs in 30d
Description
In CommandSignature::Finalize, ByteStride is calculated by adding the size of each type in m_ParamArray (correctly).
However if the actual data is created using an array of structs, the alignment of the struct can cause ByteStride to not match the actual stride of the data.
E.g:
struct IndirectCommand
{
D3D12_GPU_VIRTUAL_ADDRESS constant_buffer;
D3D12_INDEX_BUFFER_VIEW index_buffer;
D3D12_VERTEX_BUFFER_VIEW vertex_buffer;
D3D12_DRAW_INDEXED_ARGUMENTS drawArguments;
};
This will give a size of 60 bytes by adding the size of each member, but the struct will be 64bytes due to 8 byte alignment.
I presume a fix would involve rounding the bytestride calc to the minimum struct alignment in CommandSignature::Finalize or making it clear that a packing value needs to be used when creating the signature to match the input struct size.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in CommandSignature::Finalize and trace how ByteStride is accumulated from m_ParamArray. Compare that calculation with the alignment and size of the IndirectCommand example, then determine whether the expected behavior is automatic alignment or documented packing; done means the signature stride consistently matches the data layout or the required packing is clearly specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100