microsoft / microsoft/DirectXShaderCompiler

SamplerDescriptorHeap can be used to load textures.

Open
#6,649 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description

From HLSL_SM_6_6_DynamicResources, it looks like SamplerDescriptorHeap must be used to access Samplers, not textures.
But if we use it to load a texture, DXC says OK.

Steps to Reproduce

float4 main() : SV_Target {
  SamplerState Sampler = SamplerDescriptorHeap[2];
  Texture2D Texture = SamplerDescriptorHeap[3];
  return Texture.Sample(Sampler, float2(0, 0));
}
dxc -T ps_6_6 repro.hlsl

Actual Behavior

DXC compiles. dx.op.createHandleFromHeap is created, loading a texture from a sampler heap.
As I'm adding this feature in the SPIR-V backend, I'm fine accepting this (since for us both heaps would be the same). But it looks like this should be illegal.

Environment

  • DXC version: HEAD
  • Host Operating System: linux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided repro with dxc -T ps_6_6 and compare the result with the HLSL_SM_6_6_DynamicResources specification. Trace how dx.op.createHandleFromHeap is generated for SamplerDescriptorHeap and determine the validation point; done means the compiler consistently rejects texture loads from a sampler heap, with coverage for the repro.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.