Skip to content

📐 d3d12: Respect a requested resource alignment above the reported one - #321

Merged
manon-traverse merged 1 commit into
mainfrom
d3d12-respect-resource-alignment
Nov 23, 2026
Merged

manon-traverse merged 1 commit into
mainfrom
d3d12-respect-resource-alignment

Conversation

@manon-traverse

Copy link
Copy Markdown
Collaborator

Written by Claude on behalf of Manon.

With D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT (Agility SDK 1.619.4+), a non-zero Alignment in the resource desc is a floor that CreatePlacedResource enforces, but GetResourceAllocationInfo keeps reporting the driver's own tight alignment. On an RX 7900 XTX that's 8 bytes for every buffer. create_resource() sub-allocated at that 8-byte alignment, so creating a buffer with a 16-byte floor failed:

ID3D12Device::CreatePlacedResource2: This resource cannot be created on this heap, due to unsatisfied
resource alignment requirements. The resource must be aligned to 16. [...] the resource offset in the heap is 1332008.
→ E_INVALIDARG (0x80070057)

This allocates at max(GetResourceAllocationInfo().Alignment, desc.Alignment), both in create_resource() and in AllocationCreateDesc::from_d3d12_resource_desc(). Without tight alignment, a non-zero Alignment is already one of the alignments GetResourceAllocationInfo reports, so nothing changes there.

Evidence

Breda's DX12 backend with tight-aligned buffers (16/64/256-byte floors per usage) on an RX 7900 XTX (Adrenalin 32.0.32015.2008) and an RTX 2080 Ti (610.88), Agility SDK 1.619.6:

without this fix with this fix
Evolve on RX 7900 XTX ❌ panics on the first buffer, E_INVALIDARG ✅ full benchmark runs, no debug-layer messages
Evolve on RTX 2080 Ti ❌ panics on the first AS buffer (driver reports 128, floor is 256) ✅ full benchmark runs, no debug-layer messages

Used by the breda PR that enables tight alignment, through the d3d12-respect-resource-alignment-ash-next branch (this commit cherry-picked onto the external-memory-allocation-ash-next rev that breda pins).

🤖 Generated with Claude Code

https://claude.ai/code/session_01WN9aBMjKHQG11Ekr2ojyLe

With D3D12_RESOURCE_FLAG_USE_TIGHT_ALIGNMENT, a non-zero Alignment in the
resource desc is a floor that CreatePlacedResource enforces, but
GetResourceAllocationInfo keeps reporting the driver's (smaller) tight
alignment. Sub-allocating at that alignment makes CreatePlacedResource fail
with E_INVALIDARG, so allocate at the larger of the two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WN9aBMjKHQG11Ekr2ojyLe
@manon-traverse
manon-traverse merged commit fc22df0 into main Nov 23, 2026
68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants