llvm / llvm/offload-test-suite
[Vulkan][DirectX] Support testing of multi-sampled textures
@Icohedron is already working on this.
Since Aug 7, 2026.
- Dominant language
- C++
- Stars
- 18
- Forks
- 39
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 40
Description
There is currently no support for testing multi-sampled texture types `Texture2DMS` and `Texture2DMSArray`.
There is an existing (closed) PR that adds support for Vulkan: https://github.com/llvm/offload-test-suite/pull/1079
There are read-write variants (`RWTexture2DMS`) as well, but it is not currently implemented in the DXC side for SPIR-V (https://github.com/microsoft/DirectXShaderCompiler/issues/5244).
The main problem to overcome with multi-sampled textures is you cannot upload data into an MSAA texture from the CPU.
Problem Summary by Copilot:
Neither API allows a buffer→image copy into a multisampled resource:
* **D3D12** — `CopyTextureRegion`/`CopyResource` reject MSAA destinations; `CopyResource` only works MS→MS with identical sample count/quality. `ResolveSubresource` is MS→single-sample only (wrong direction).
* **Vulkan** — `vkCmdCopyBufferToImage` requires `samples == 1`; `vkCmdResolveImage` is MS→single-sample only.
So per-sample contents must be **written by a shader**. Two mechanisms exist:
### Option A — storage-image / UAV compute write (what PR #1079 did)
* Vulkan: `image2DMS` storage image + `imageStore(img, coord, sample, value)`. Requires the **optional** `shaderStorageImageMultisample` device feature.
* DirectX: `RWTexture2DMS` (SM 6.7 "Advanced Texture Ops" / `TextureStoreSample` DXIL op — DXC does implement this, see `DirectXShaderCompiler/lib/HLSL/HLOperationLower.cpp:4593`) and requires `D3D12_FEATURE_D3D12_OPTIONS14::WriteableMSAATexturesSupported`.
Pros: fits the existing compute-encoder-based resource creation flow exactly; smallest structural change.
Cons: two optional features that meaningfully shrink device coverage (PR #1079 already had to `XFAIL: Intel && Vulkan` because Intel advertises `shaderStorageImageMultisample` but produced wrong sample data); the DX side additionally needs SM 6.7 hardware/driver.
### Option B — render-pass write (portable) (to be supported by https://github.com/llvm/offload-test-suite/issues/1043)
Bind the MSAA texture as a color attachment / RTV and draw one full-screen triangle with a pixel shader that reads `SV_SampleIndex` and fetches its value from a `Buffer` SRV:
```hlsl
Out = Src.Load(uint((Pos.y * Width + Pos.x)) * NumSamples + SampleIndex);
```
Reading `SV_SampleIndex` forces per-sample execution on D3D12 (no cap needed) and requires the near-universal core `sampleRateShading` feature on Vulkan. A cap-free fallback is N draws with the sample mask set to `1 << i`.
Pros: no optional features; identical algorithm on both backends; works on older hardware, WARP and lavapipe.
Cons: needs a graphics pipeline + render pass created *inside* resource creation (today resource upload runs on a `ComputeEncoder`); Vulkan render pass / pipeline creation currently hardcodes `samples = VK_SAMPLE_COUNT_1_BIT` (`lib/API/VK/Device.cpp:2308`, `:2502`, `:2989`, `:3018`) so sample count must be plumbed through; requires a VS+PS pair per backend.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.