Skip to content

fix(dx12): reconcile resource states across submissions#262

Open
besmpl wants to merge 1 commit into
gogpu:mainfrom
besmpl:codex/upstream-dx12-state-tracker
Open

fix(dx12): reconcile resource states across submissions#262
besmpl wants to merge 1 commit into
gogpu:mainfrom
besmpl:codex/upstream-dx12-state-tracker

Conversation

@besmpl

@besmpl besmpl commented Jul 14, 2026

Copy link
Copy Markdown

Summary

  • track first-use and final resource states per command buffer, then reconcile them in submission order with queue-local preamble barriers
  • retain preamble allocators, command lists, staging resources, and explicit destination COM references until a trustworthy fence or safe terminal teardown
  • handle 2D-array and padded 3D buffer/texture copies with exact D3D12 footprints, including block-compressed rows
  • make packed depth/stencil SRV, DSV, clear, and companion-plane transitions agree, with complete descriptor-allocation rollback

This replaces the narrower but unsound draft #259. The DX12 indirect-argument ABI correction remains isolated in #258.

Why

Recording-time currentState is 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 ./...
  • focused Windows amd64 and 386 cross-compilation for hal/dx12 and hal/dx12/d3d12
  • git diff --check
  • two independent read-only reviews of state/copy/view correctness and queue/COM lifetime

Remaining 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.

@besmpl besmpl marked this pull request as ready for review July 14, 2026 20:56
@besmpl besmpl requested a review from kolkov as a code owner July 14, 2026 20:56
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.

1 participant