[SPIR-V] -fvk-use-dx-layout places cbuffer matrices with double columns at a different offset than DXIL

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

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

Start by searching the compiler for -fvk-use-dx-layout handling of cbuffer matrix member offsets, then look for tests covering DX-layout matrix padding, including the cases referenced in #3463 and #3672. Reproduce with the supplied HLSL and compare SPIR-V member offsets with DXIL reflection. Done means the double-matrix member offset matches DirectX’s 16-byte placement while the shared 32-byte column stride and existing float-matrix and vector cases remain unchanged.

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

描述

bug needs-triage spirv

Description
Under -fvk-use-dx-layout, a cbuffer matrix whose SPIR-V columns are larger than 16 bytes (3 or 4 doubles) doesn't get DirectX's offset. DirectX starts a cbuffer member on the next 16-byte row, so double a; double3x3 m; puts m at 16. The SPIR-V output instead aligns the matrix to its own 32-byte column stride and puts it at 32. The same HLSL therefore describes different bytes per backend, which defeats the point of the flag: one application-side struct can't serve both backends. Both backends agree on the 32-byte column stride; only the member offset differs.

These cases land identically on both backends:

  • float matrices
  • double vectors
  • double scalars

Related: #3463 / #3672 fixed DX-layout matrix padding for float matrices.

Steps to Reproduce
dxc -T cs_6_2 -E main -spirv -fvk-use-dx-layout repro.hlsl, compared with dxc -T cs_6_2 -E main repro.hlsl:

cbuffer CB { double a; double3x3 m; }
RWByteAddressBuffer o;
[numthreads(1, 1, 1)]
void main(uint id : SV_DispatchThreadID) { o.Store<float>(0, (float) (a + m[2][2])); }

A standalone repro comparing DXIL reflection against SPIRV-Reflect is attached (repro_dx_layout_double_matrix_spirv_reflect.cpp).

Actual Behavior
SPIR-V:

OpMemberDecorate %type_CB 0 Offset 0
OpMemberDecorate %type_CB 1 Offset 32
OpMemberDecorate %type_CB 1 MatrixStride 32

DXIL:

;       double a;                                     ; Offset:    0
;       column_major double3x3 m;                     ; Offset:   16

All cases:

cbuffer CB { double a; double3x3 m; }   m: DXIL 16, SPIR-V 32   <-- differs
cbuffer CB { double a; double3x2 m; }   m: DXIL 16, SPIR-V 32   <-- differs
cbuffer CB { float a; float3x3 m; }     m: DXIL 16, SPIR-V 16
cbuffer CB { double a; double3 b; }     b: DXIL 16, SPIR-V 16

Environment

  • DXC version: <latest release, from dxc --version>; also reproduces on main, libdxcompiler.so: 1.11(5563-75fba619)(1.10.0.15563)
  • Host Operating System: Windows (release); Linux x86_64 (main)
主要语言
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 摘要。