Skip to content

[DX] MSAA render target support (#1043)#1236

Draft
alsepkow wants to merge 6 commits into
llvm:mainfrom
alsepkow:alex/dx-msaa-1043
Draft

[DX] MSAA render target support (#1043)#1236
alsepkow wants to merge 6 commits into
llvm:mainfrom
alsepkow:alex/dx-msaa-1043

Conversation

@alsepkow

@alsepkow alsepkow commented May 27, 2026

Copy link
Copy Markdown
Collaborator

EXPERIMENTAL - NOT FOR REVIEW

AI-assisted exploration driving design discussion for llvm/wg-hlsl#400. Not intended for review/merge in current form.

Adds D3D12 backend support for MSAA render targets. The schema gains Pipeline.SampleCount (1, 2, 4, 8); the DX backend creates the RT with the requested SampleCount, threads it into PSO creation, and resolves to a single-sampled staging target before readback. Vulkan parity is on the parent issue.

Tests: MSAA.4x.test exercises a triangle rendered into a 4x MSAA target with edge antialiasing visible in readback. PASS on d3d12, warp-d3d12.

Remaining on parent #1043 (not in this PR):

Refs #1043


Assisted by Claude Opus 4.7.

alsepkow and others added 6 commits May 26, 2026 20:48
Adds support for multi-sample render targets on the D3D12 backend so the
offload test suite can exercise MSAA pipelines and validate resolved
output.

* Pipeline schema: new `OutputProperties.SampleCount` (default 1) on
  the render-target buffer, parsed in `Pipeline.cpp`.
* API plumbing: `TextureCreateDesc::SampleCount` and
  `TraditionalRasterPipelineCreateDesc::SampleCount`;
  `createDefaultDepthStencilTarget` now takes a sample-count override
  so the DSV always matches the bound RT.
* DX backend:
  - `createTexture` honours the sample count on RT allocations.
  - `createTraditionalRasterPipeline` sets `SampleDesc.Count` and
    `RasterizerState.MultisampleEnable` from the descriptor.
  - `createRenderTarget` allocates a single-sample
    `ResolvedRenderTarget` alongside the MSAA RT when SampleCount > 1.
  - `createGraphicsCommands` issues `ResolveSubresource` with the
    required `RESOLVE_SOURCE`/`RESOLVE_DEST` state transitions and
    copies the resolved texture (not the MSAA RT) into the readback
    buffer.
  - `createDepthStencil` threads SampleCount through so depth matches.
* VK / MTL backends: ignore the new field (default 1 keeps existing
  tests untouched); mesh-shader pipeline path left at SampleCount=1
  since no MSAA mesh-shader caller is wired yet.
* Test: `Feature/MSAA/render-target-msaa-resolve.test` renders a
  fully-covering triangle into a 2x2 4x-MSAA RT and validates the
  resolved 2x2 output. UNSUPPORTED: Vulkan || Metal. XFAIL: Clang.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Picks up the DriverVer fix (upstream llvm#1228) so clang-tidy stops failing on Device.cpp.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Report 4x R32G32B32A32_FLOAT MSAA support through api-query and expose it as the MSAA_4xSamples lit feature.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fixes misc-const-correctness warnings-as-errors from clang-tidy in CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The shared TextureCreateDesc.SampleCount field was added but VK and MTL
silently ignored it. Add explicit not-supported errors so the contract is
honest across backends. Tests that need MSAA already mark themselves
UNSUPPORTED: Vulkan || Metal, so this guard is belt-and-suspenders.

Tracks divergence concern raised in early PR review.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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