[DX] View instancing follow-up: 4-view test (#1051)#1238
Draft
alsepkow wants to merge 7 commits into
Draft
Conversation
Adds a new `Texture2DArray` `ResourceKind` and wires it through the DirectX backend so shaders can `Load` from layered SRVs: * `OutputProperties` gains an `ArraySize` field (default 1) and the YAML size validation now accounts for it. * `getResourceDescription` sets `DepthOrArraySize` from `ArraySize` for `Texture2DArray` resources and rejects mismatched uses of `ArraySize > 1` on non-array kinds. * `getSRVDescription` emits a `TEXTURE2DARRAY` view covering all slices. * The upload path enumerates slices via `CopyTextureRegion` with a per-slice `D3D12_PLACED_SUBRESOURCE_FOOTPRINT`; the host-side data layout is tightly packed slice-major (slice0 rows | slice1 rows | ...). Vulkan and Metal switches gain `Texture2DArray` cases for build completeness; their device implementations remain TODO and the new test is gated `UNSUPPORTED: Vulkan || Metal`. Adds `Feature/Textures/Texture2DArray.Load.test.yaml` exercising a 2x2x3 array with `Load(int4)` and offset variants. Verified passing on d3d12 (NVIDIA RTX 5060 Ti) and warp-d3d12. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
First slice of view-instancing support: schema, pipeline plumbing, and
the alternate PSO_STREAM creation path needed to attach a view-instancing
subobject. Render-target multi-slice readback and the actual test land
in a follow-up commit; existing graphics tests are unaffected because
the new code path is gated on `ViewInstanceCount > 1`.
* Pipeline schema: new `Pipeline.ViewInstanceCount` (default 1)
parsed in `Pipeline.cpp`.
* API plumbing: `TraditionalRasterPipelineCreateDesc.ViewInstanceCount`
and `TextureCreateDesc.ArraySize`; `createRenderTargetFromCPUBuffer`
now threads `OutputProps.ArraySize` so render targets become
`Texture2DArray` resources when requested.
* DX backend:
- `createTexture` honours `Desc.ArraySize` for the resource
descriptor (`DepthOrArraySize`); the default `nullptr` RTV/DSV
descriptor naturally yields a TEXTURE2DARRAY view covering all
slices.
- `createTraditionalRasterPipeline` now builds a
`CD3DX12_PIPELINE_STATE_STREAM2` and attaches a
`CD3DX12_VIEW_INSTANCING_DESC` (view N -> RT array slice N) when
`ViewInstanceCount > 1`; non-VI pipelines continue to use the
existing `D3D12_GRAPHICS_PIPELINE_STATE_DESC` path.
- `executeProgram` propagates `P.ViewInstanceCount` to the
pipeline descriptor.
Follow-up (next commit / tick):
* Multi-slice render-target readback (`CopyTextureRegion` per slice,
larger readback buffer, slice-major `copyFromTexture`).
* Per-view depth-stencil target ArraySize matching.
* `Feature/ViewInstancing/multiview-2views.test`.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…1051) Extends the D3D12 render target readback path to handle Texture2DArray render targets: * getAlignedTextureBufferSize() rounds each slice up to D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT (512) and multiplies by ArraySize so the staging buffer is sized correctly. * createGraphicsCommands() now issues one CopyTextureRegion per array slice with placement-aligned per-slice footprints. * readBack() walks slices, copying each one tightly into CPUBuffer.Data[0] slice-major using the actual padded RowPitch reported by GetCopyableFootprints. * createDefaultDepthStencilTarget gains an ArraySize argument; createDepthStencil threads OutputProps.ArraySize through so the DSV slice count matches the bound RT when a view-instanced pipeline is dispatched. * validateTextureCreateDesc cross-checks ArraySize and the expected total buffer size now factors ArraySize in. Adds Feature/ViewInstancing/multiview-2views.test which exercises a 2x2 ArraySize=2 RT with ViewInstanceCount=2 (PSO ViewInstancingDesc routes view N to RT slice N). Pixel shader reads SV_ViewID (ps_6_1) so each slice gets a distinct color. PASSes on d3d12 (RTX 5060 Ti) and warp-d3d12; UNSUPPORTED on Vulkan/Metal until those backends gain a setViewInstanceCount equivalent. 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>
Add a 4-view D3D12 view-instancing variant that validates SV_ViewID output routing across four render target array slices. 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>
# Conflicts: # include/Support/Pipeline.h
Open
3 tasks
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.
Follow-up to the initial view instancing scaffolding: adds a 4-view test exercising
SV_ViewIDacross multiple viewports. The schema gainsPipeline.Viewports(a list of{X, Y, Width, Height}) and the DX backend configures bothRSSetViewportsandRSSetScissorRectsfrom the list, with view instancing enabled at PSO creation when more than one viewport is declared. Feature is gated onD3D12_VIEW_INSTANCING_TIER_1.Tests:
ViewInstancing.4view.testrenders a single draw call broadcast across four viewports, each with its own per-view color selected bySV_ViewIDin the VS. PASS ond3d12.Remaining on parent #1051 (not in this PR):
multiviewandmultiViewportdevice features, configure the render pass for multiview rendering, set multiple viewports / scissors at draw time.PSO_STREAMso view instancing configuration is first-class (covered separately by draft [DRAFT] [DirectX] Migrate all PSO creation to PSO_STREAM (CD3DX12_PIPELINE_STATE_STREAM2) #1263).Refs #1051
Assisted by Claude Opus 4.7.