microsoft / microsoft/DirectXShaderCompiler

[SPIR-V] Enum class bitfields are emitted into separate storage slots

Open
#8,470 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

DXC does not treat enum class bitfields as a plain integer type, which can cause the enum class-typed bitfield (type) to be placed into its own 32-bit storage slot instead of being packed with the following bitfields. This may lead to a larger-than-expected struct layout and prevents full bitfield packing.

Steps to Reproduce

https://godbolt.org/z/Ga61357fn In this example, the generated struct is 12 bytes instead of 8.

Related issue: https://github.com/microsoft/DirectXShaderCompiler/issues/5554

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 with the Compiler Explorer reproduction at https://godbolt.org/z/Ga61357fn and compare its generated layout with the related issue #5554. Trace how DXC lowers enum class-typed bitfields for SPIR-V and identify the storage-slot decision. Done means the enum class bitfield is packed with the following bitfields and the reproduced struct layout is 8 bytes rather than 12.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.