feat(dx12): DirectComposition path for per-pixel alpha (#298) - #299
Merged
Conversation
…ition wrapper (#298) FEAT-DCOMP-001: CreateSwapChainForComposition method on IDXGIFactory6 FEAT-DCOMP-002: dcomp.go — lazy dcomp.dll loading, COM vtbl structs (IDCompositionDevice/Target/Visual), dcompState lifecycle Foundation for per-pixel alpha transparency via DirectComposition. ADR-057, Rust wgpu dcomp.rs parity.
FEAT-DCOMP-003: createSwapchain branches on AlphaMode — Premultiplied uses CreateSwapChainForComposition + DComp visual, Opaque uses HWND. DComp teardown in Unconfigure (reverse order after swapchain release). GOGPU_DX12_FORCE_HWND=1 env var for RenderDoc compatibility. FEAT-DCOMP-004: adapter reports Premultiplied only when dcompAvailable(). Both Adapter and AdapterLegacy fixed.
…298) - Configure: detect Opaque↔Premultiplied change, force full recreate instead of ResizeBuffers (which cannot change alpha mode) - MakeWindowAssociation: skip on DComp path (Rust wgpu parity) - Found by enterprise code review
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CompositeAlphaModePremultiplied)CreateSwapChainForHwndonly supportsDXGI_ALPHA_MODE_IGNORE— per-pixel alpha requiresCreateSwapChainForCompositionvia DirectComposition visual treedcomp.dllviasync.Once(Windows 8+, always present on our min Win10 1809)AlphaMode == Premultiplied→ DComp path,Opaque→ HWND path (unchanged)Premultipliedonly whendcompAvailable()GOGPU_DX12_FORCE_HWND=1env var for RenderDoc compatibilityChanges (5 files, +507/-27 LOC)
hal/dx12/dcomp.gohal/dx12/dxgi/factory.goCreateSwapChainForCompositionwrapper on IDXGIFactory6hal/dx12/surface.gocreateSwapchainbranching: DComp vs HWND based on AlphaMode. MakeWindowAssociation guarded for DComp path (Rust wgpu parity)hal/dx12/instance.godcomp *dcompStatefield on Surface. Teardown in Unconfigure. Alpha mode change detection in Configure (forces full recreate instead of ResizeBuffers)hal/dx12/adapter.godcompAvailable()Architecture (ADR-057)
Enterprise review findings (all addressed)
{C37EA93A-E7AA-450D-B16F-9746CB0407F3}: verifiedRequires (separate repo)
gogpu#361:
WS_EX_NOREDIRECTIONBITMAPwindow style +AlphaModepassthrough in renderer. Without this, DComp swap chain works but transparency is not visible (DWM redirection surface provides opaque background).Test plan
go build ./...(Windows, Linux, macOS)golangci-lint run --timeout=5m— 0 issuesgofmt— cleanGOOS=linux,GOOS=darwinWS_EX_NOREDIRECTIONBITMAP→ transparent (requires gogpu#361)GOGPU_DX12_FORCE_HWND=1falls back to HWND path