[SPIR-V] GetVertexAttribute with -pack-optmized does not generate good type

Open
#8,990 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp

Research direction

Start with the Godbolt reproduction and compare the generated SPIR-V with and without --pack-optimized, focusing on the type of %in_var_GPUSCENE_VERTEXTOTRIBITMASKS. Trace the type from the SPIR-V emitVisitor into the optimization pass suspected in the report; done means the optimized output uses the expected array type and passes SPIR-V validation.

Written by the indexing model from the issue text.

Description

bug needs-triage spirv

Hi everyone, me again 😄

Description
Our shaders does not compile well with --pack-optimized. I don't know if it supposed to work or if it is a bug.
I had different errors. The reproduction on godbolt is this one PerVertexKHR must be declared as arrays. I also had validation errors on CompositeExtract : generated SPIR-V is invalid: Result type (OpTypeVector) does not match the type that results from indexing into the composite (OpTypeInt)

The issue is that my non interpolated variable fetched with GetVertexAtAttribute has a type OpTypePointer->OpTypeVector OpTypeInteger 4 but it should be OpTypePointer-> OptypeArray (OpTypeVector OpTypeInteger 4) 3. I tried to step into dxc but the type was good in the spirv emitVisitor so I suspect an optimization pass but I did not dive more :/

Without validation it is easy to see the difference between with and without --pack-optimized.

Steps to Reproduce
https://godbolt.org/z/nx5ozWrfW
It does not compile. Check with -Vd to see the actual type of %in_var_GPUSCENE_VERTEXTOTRIBITMASKS that is %_ptr_Input_v4uint and not %_ptr_Input__arr_v4uint_uint_3 if --pack-optimized is not used.

Actual Behavior

fatal error: generated SPIR-V is invalid: [VUID-StandaloneSpirv-Input-06778] PerVertexKHR must be declared as arrays
  %in_var_GPUSCENE_VERTEXTOTRIBITMASKS = OpVariable %_ptr_Input_v4uint Input
Compiler returned: 5

Environment
DXC trunk on godbolt
Reproduce also on windows 11 and custom fork of 1.10.2605.24.

As usual, if I did not understand something, please tell me :)

Have a wonderful day.
Cheers,
Robin.

Dominant language
C++
Stars
3.7k
Forks
926
Avg merge
3d 22h
Merged PRs (30d)
45

Getting set up

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.

More from microsoft/DirectXShaderCompiler

All issues in microsoft/DirectXShaderCompiler

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.