DXC accepts `TextureCubeArray.SampleCmpGrad` despite explicit exclusion from hlsl-spec proposal 0014

未关闭
#9,060 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
56/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp
领域
compilers

调研方向

Read proposal 0014’s HLSL and DXIL exclusions, DXC’s TextureCUBEArrayMethods declarations, and tools/clang/test/HLSLFileCheck/hlsl/objects/Texture/SampleCmpGrad.hlsl. Reproduce with the supplied HLSL and compiler arguments, then determine whether cube-array support is intended. Done means the implementation, regression test, and proposal agree on the supported behavior.

由索引模型根据 Issue 内容生成。

描述

bug needs-triage

Summary

DXC 1.9.2609 accepts TextureCubeArray<float>.SampleCmpGrad in a pixel shader and emits DXIL sampleCmpGrad (opcode 254) using a cube-array resource. hlsl-specs proposal 0014 explicitly excludes this receiver in both its HLSL and DXIL sections.

It needs to be clarified whether cube-array support is intentional and align the implementation and proposal.

Reproduction

Godbolt: https://godbolt.org/z/PdTavoj7o

Self-contained source; no headers, defines or external files:

TextureCubeArray<float> tex : register(t0);
SamplerComparisonState cmp : register(s0);

float main(float4 location : TEXCOORD0) : SV_Target {
  return tex.SampleCmpGrad(cmp, location, 0.5f,
                           float3(0.01f, 0, 0),
                           float3(0, 0.01f, 0));
}

Compiler args are -T ps_6_8 -E main -HV 2021 -O3: pixel shader, SM6.8, entry main, HLSL2021, optimized DXIL output. The returned shader value keeps the texture operation observable.

Expected versus actual

Expected under the proposal’s stated exclusion: diagnose SampleCmpGrad on TextureCubeArray rather than generate the operation for that receiver.

Actual: compilation succeeds without diagnostics and generates dx.op.sampleCmpGrad.f32 with opcode 254. Its texture operand comes from an annotateHandle whose resource-properties kind is 9, identified by DXC’s disassembly as TextureCubeArray<F32>.

If cube-array support is intentional: correct the proposal’s HLSL and DXIL exclusions instead of rejecting currently supported programs.

Observed compiler results

Tested 2026-10-21 UTC through Compiler Explorer’s compilation API:

Compiler ID Returned name / version User arguments Exit code Decisive result
dxc_1_9_2609 DXC 1.9.2609 / 1.9.2609 -T ps_6_8 -E main -HV 2021 -O3 0 Emits dx.op.sampleCmpGrad.f32, opcode 254, using the annotated cube-array handle.
hlsl_clang_trunk Clang (trunk) / (trunk) -T ps_6_8 -E main -HV 2021 -O3 1 error: no member named 'SampleCmpGrad' in 'hlsl::TextureCubeArray<float>'

A nonarray control—replace TextureCubeArray<float> with TextureCube<float> and pass location.xyz—also compiles with DXC. Clang reports the same missing-member error for hlsl::TextureCube<float>. Its failure therefore does not establish that it implements the proposal’s cube-array restriction; it is comparison context, not the correctness oracle.

Compiler Explorer injects -Zi, -Qembed_debug and disassembly-output options. Its Clang adapter additionally supplies --driver-mode=dxc. Clang warns that the injected -Qembed_debug is unused and that HLSL2021 support is incomplete; those warnings are separate from the source diagnostic. Neither API result timed out or was truncated.

Conflicting references

主要语言
C++
星标
3.7k
派生
926
平均合并
3 天 22 小时
30 天内合并 PR
45

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/DirectXShaderCompiler 的其他 Issue

查看 microsoft/DirectXShaderCompiler 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。