DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

[SPIR-V] Bitfields in structs fail to compile to SPIR-V

Open noahwhygodwhy opened this issue 1 year ago • 2 comments

Description

Structs with a specific setup of bitfields fail to compile to SPIR-V with the error

fatal error: generated SPIR-V is invalid: Index is out of bounds, can not find index 1 in the structure <id> '2'. This structure has 1 members. Largest valid index is 0.
  %19 = OpCompositeExtract %uint %17 1

I looked through and there were quite a few other issues that seemed like they might be related, but they all seemed to be resolved/merged pre-March 2024 release, and this issue is still present in that release version.

Steps to Reproduce

A struct with uint bitfields fails to compile when one of the members of the struct is accessed via a method that is not a structured buffer.

Here is the smallest example I could make. The compile options are at the top, followed by the error message, followed by the non-working example. At the bottom is a piece of code that I think functionally does the same thing, but successfully compiles. https://godbolt.org/z/hYd6faK1j

Actual Behavior Should compile successfully to spir-v as it does to dxil.

Environment

  • DXC versions:
    • Release 1.7.2308 (69e54e2) (August 2023)
    • Release 1.8.2403 (c9660a8) (March 2024)
    • Release 1.8.2403.1 (9c2b828 (March 2024 patch 1)
  • Host Operating System: Windows 11 23H2 (Build 22631.3296)

noahwhygodwhy avatar Mar 31 '24 00:03 noahwhygodwhy

Sorry. Did I mess up? I'm assuming marking this as For Google means that this is intended behavior and I should google how bitfields in spirv work and that this is expected? I only opened a issue because the error message asked.

noahwhygodwhy avatar Apr 05 '24 16:04 noahwhygodwhy

Thank you for reporting @noahwhygodwhy ! This is a bug, we'll take a look. The "For Google" tag is just to help us categorize incoming issues between the different teams at Microsoft and Google working on this repository.

sudonatalie avatar Apr 05 '24 17:04 sudonatalie