Copying a `half` array out of a dynamically indexed struct array produces invalid DXIL
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Start with the attached half_array_vector_type.hlsl and half_array_bitcast_struct.hlsl repros, compiling them with the listed DXC command and -enable-16bit-types. Compare the failing half-array cases with the float-array variant and trace where dynamic indexing and struct layout produce invalid DXIL. Done means both repros compile and the DXIL validator accepts their output.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
With -enable-16bit-types, copying a half array member out of an element of a local
struct array, where the element is selected by a dynamic index, makes DXC emit DXIL
that its own validator rejects. The struct also needs a 32-bit vector or matrix member.
The source is valid HLSL; the same shader with float h[3] instead of half h[3] compiles.
Depending on the struct layout the validator reports different errors:
Vector type '<4 x float>' is not allowed.(also<8 x float>,<1 x half>)Bitcast on struct types is not allowed.with
note: at '%7 = bitcast %class.matrix.float.2.4* %6 to <8 x float>*'- In the original generated shaders, also
Instructions must be of an allowed type.
Found by fuzzing WebGPU (WGSL -> Tint -> HLSL -> DXC) via Dawn; 6 generated shaders hit it,
most reporting both "Bitcast on struct types" and "Instructions must be of an allowed type".
One of them is attached as fuzzer-original.hlsl (arguments in fuzzer-original.args.txt).
Impact: this is reachable from web content. In Chrome 156 (which bundles DXC for WebGPU), the 13-line enable f16; WGSL shader in webgpu\b04_half_array.wgsl fails createComputePipeline with this validation error.
Steps to Reproduce
half_array_vector_type.hlsl:
struct Inner { float4 v; half h[3]; };
RWByteAddressBuffer buf : register(u0);
[numthreads(1, 1, 1)]
void main(uint gi : SV_GroupIndex) {
Inner arr[4] = (Inner[4])0;
half h[3] = arr[gi].h;
buf.Store<half>(0, h[gi % 3]);
}
dxc -T cs_6_2 -E main -enable-16bit-types half_array_vector_type.hlsl
half_array_bitcast_struct.hlsl:
struct Inner { float2x4 m[1]; half h[3]; };
struct Outer { half a; Inner inner; };
RWByteAddressBuffer buf : register(u0);
[numthreads(1, 1, 1)]
void main(uint gi : SV_GroupIndex) {
Outer arr[4] = (Outer[4])0;
half h[3] = arr[gi].inner.h;
buf.Store<half>(0, h[gi % 3]);
}
dxc -T cs_6_2 -E main -enable-16bit-types half_array_bitcast_struct.hlsl
Actual Behavior
error: validation errors
error: Vector type '<4 x float>' is not allowed.
error: Vector type '<4 x float>' is not allowed.
...
Validation failed.
and for the second file:
error: validation errors
error: Vector type '<4 x float>' is not allowed.
half_array_bitcast_struct.hlsl:6:28: error: Bitcast on struct types is not allowed.
note: at '%7 = bitcast %class.matrix.float.2.4* %6 to <8 x float>*' in block '#0' of function 'main'.
error: Vector type '<8 x float>' is not allowed.
...
Expected Behavior
Both shaders compile.
Environment
- DXC version: main (c3a85328, 1.10.0.10001), release v1.9.2609 (
1.9.2609.5 (01b62ad47)),
v1.9.2602 (1.9.2602.17 (21d28f727)) - all fail identically - Host operating system: Windows Server 2025 (x64)
- Ngôn ngữ chính
- C++
- Star
- 3.7k
- Fork
- 926
- Merge trung bình
- 3 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 45
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/DirectXShaderCompiler
-
bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/DirectXShaderCompiler#9173 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
microsoft/DirectXShaderCompiler#9155 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
bug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/DirectXShaderCompiler#9135 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
DXC emits DW_LANG_C_plus_plus instead of DW_LANG_HLSL for HLSLCó thể đã có người làm @rj123-nv đã nhận 18 ngày trước. Đang mởbug needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
microsoft/DirectXShaderCompiler#9087 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
microsoft/DirectXShaderCompiler#9086 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của microsoft/DirectXShaderCompiler
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
feature:config kind:docs os:windows toolchain:cmake triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
arch-based bug niri
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
noctalia-dev/noctalia#5552 ·
Maintainer thường phản hồi trong vòng 1 ngày