fix(dx12): reconcile resource states across submissions#262
Conversation
kolkov
left a comment
There was a problem hiding this comment.
The architecture makes sense — recording-time currentState is theoretically unsound for independently recorded command buffers, and submission-ordered reconciliation is the proper DX12 model. The depth/stencil plane handling and copy decomposition show real DX12 expertise.
However, our current DX12 backend runs 11,410+ frames stable on Intel Iris Xe with maxFramesInFlight=2. The practical risk of replacing working state tracking with a 2586-line rewrite that hasn't been tested on Windows is significant. State transition bugs manifest as TDR crashes or silent corruption — not something we can catch with cross-compilation.
Before we can consider merging:
-
Windows testing required. Run with D3D12 debug layer enabled. At minimum:
ggintegration example for 100+ frames on DX12 withoutDEVICE_REMOVED. We can help — our dev machine has Intel Iris Xe. -
Consider splitting — the view helpers fix (planeSlice SRV), copy decomposition, and state tracker could be independent PRs. Smaller pieces are easier to validate.
-
Preamble allocator pooling —
buildPreamble()creates a new allocator per submission. For frames with PRESENT→RENDER_TARGET transitions (every frame), this adds allocation overhead. Consider reusing from completed frames.
The quality of the DX12 knowledge is clear — we just need native validation before moving forward.
@lkmavi — this is a large DX12 rewrite, but the copy decomposition patterns may be relevant to the Metal texture handling in #261. Your perspective welcome.
2a5a611 to
97c722c
Compare
|
@kolkov Thanks for offering access to the Intel Iris Xe machine. I have pushed the review changes at I do not have access to native Windows hardware. Could you please run the remaining validation on Windows with the D3D12 debug layer enabled?
Cross-compilation for Windows amd64/386 and the full |
kolkov
left a comment
There was a problem hiding this comment.
Architecture is correct. Submission-ordered reconciliation is the proper DX12 model, and this PR implements it well. The depth/stencil plane handling, preamble pooling, and COM lifetime management all show deep DX12 expertise.
Preamble pooling addresses our previous review feedback — completed pairs returned to idle pool, capped at maxFramesInFlight, with fallback on reset failure.
Must-fix before merge
1. Five test failures in copy plan tests.
TestPlanBufferTextureCopiesSplitsArrayLayers, ...AlignsPlacedFootprintsByWholeRows, ...UsesBlockRowsForCompressedLayers, ...Keeps3DDepthInOneSubresource, ...Preserves3DRowsPerImageAsSliceStride — the want structs leave footprintWidth, rowPitch, copyWidth, copyHeight at zero but equalBufferTextureCopyPlans compares all fields. Please fill in the expected values.
2. Double planBufferTextureCopies computation.
copyBufferToTexture and copyTextureToBuffer call the planner twice — once for barriers, once for copies. Store the result from the first pass and reuse it.
Windows testing
We will run validation on Intel Iris Xe with D3D12 debug layer as requested — GOGPU_GRAPHICS_API=dx12 with gg integration, 100+ frames, checking for DEVICE_REMOVED and debug layer errors.
|
Saw your fix in We'll run validation on Intel Iris Xe with D3D12 debug layer next and re-approve after that. |
Issues addressed in 2f5bd8e. Windows tested on Intel Iris Xe — all pass, debug layer clean.
Summary
This replaces the narrower but unsound draft #259. The DX12 indirect-argument ABI correction remains isolated in #258.
Why
Recording-time
currentStateis not authoritative when command buffers are recorded independently and submitted later or in a different order. The queue now owns scheduled state, plans non-mutating reconciliation barriers immediately before each command buffer, and commits final state only after execution is handed to D3D12.Verification
CGO_ENABLED=0 go test ./...GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go test -exec=true ./...hal/dx12andhal/dx12/d3d12git diff --checkRemaining validation
This was developed on macOS, so native Windows execution and D3D12 debug-layer validation have not run yet. The PR is draft until that hardware evidence is available.