[DX] Implement Sampler support (#1042)#1231
Draft
alsepkow wants to merge 9 commits into
Draft
Conversation
Adds D3D12 backend support for HLSL samplers. The DX device now creates a shader-visible SAMPLER descriptor heap alongside the existing CBV_SRV_UAV heap, splits each DescriptorSet's bindings into separate resource and sampler descriptor tables in the implicit root signature, and writes sampler descriptors via ID3D12Device::CreateSampler driven by the pipeline.yaml Sampler entries. Helpers translate the offload-test-suite Sampler schema (Address, MinFilter, MagFilter, SamplerKind, CompareFunc) to D3D12_SAMPLER_DESC, including the comparison-reduction bit for SamplerComparisonState. Both the compute and graphics command builders now bind both heaps and emit one root descriptor table per present table per set. Removes the XFAIL on (or qualifies to Clang-only) the following tests that now PASS on d3d12 / warp-d3d12: Texture2D.Sampler.address, Texture2D.Sampler.filter, Texture2D.Gather. Adds a new minimal compute-shader sampler test (Texture2D.Sampler.compute) that exercises the new Sampler binding path with a 2x2 texture and nearest sampling. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Addresses code review feedback on the sampler-support change: the explicit RootParams path in createComputeCommands advanced the CBV/SRV/UAV descriptor handle by Resources.size() of the current set, which includes Sampler descriptors. Samplers live in a separate descriptor heap (SamplerHandle / SamplerHeap), so counting them here misaligns subsequent DescriptorTable bindings for sets containing both resources and samplers. Count only non-sampler resources, matching the fallback (implicit) RootParams path. Binding sampler tables via explicit RootParams remains unimplemented (the SAMPLER case of RootDescriptor still hits llvm_unreachable) and no test currently exercises this path, but the offset arithmetic is now correct in preparation for that work. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Apply clang-format 19.1.6 to changed regions per pr-code-format CI.
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>
Fixes misc-const-correctness warnings-as-errors from clang-tidy in CI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Two additional sites in the graphics-pipeline CopyBackResource that I missed in the earlier const sweep. Same misc-const-correctness rule as Device.cpp:2350/2363. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Adds D3D12 support for
SamplerandSamplerComparisonState, matching the existing Vulkan implementation. The schema, root signature plumbing, descriptor heap layout, and bind path are all updated so tests can declare samplers in YAML and consume them from compute or graphics shaders.The new
ResourceKind::Samplerflows through the existing switch sites inPipeline.hand the threeDevice.cppbackends. On D3D12, samplers live in a separateD3D12_DESCRIPTOR_HEAP_TYPE_SAMPLERheap; the root signature gains a parallel descriptor table whose range type isD3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, andSetDescriptorHeapsbinds both heaps simultaneously. Sampler properties (filter, address modes, comparison function, mip LOD bias, max anisotropy, border color) are mapped from the YAMLSamplerstruct one-to-one toD3D12_SAMPLER_DESC.Tests:
Sampler.Sample.test,Sampler.SampleLevel.test,SamplerComparisonState.SampleCmpLevelZero.test. PASS ond3d12,warp-d3d12,vk. Full Samplers sweep across 6 backends shows no regressions.Resolves #1042
Assisted by Claude Opus 4.7.