Skip to content

[SPIR-V] Get on an immediate return value of a function of type vk::BufferPointer misgenerates code #7302

Closed

Description

Description

I OpBitcast with inline SPIR-V intrinsics my integer addresses to PhysicalStoragePointers to get equivalent behaviour of old vk::RawBuffer.

Steps to Reproduce

Full Godbolt, uncomment the commented lines https://godbolt.org/z/nKj5PT4xj and remove -Vd flag.

Actual Behavior

For some reason there's an extra OpLoad of the struct type being emitted on the pointer before the access chain that resolves the .Get().a which is then done an a SSA return value and not the thing loaded

fatal error: generated SPIR-V is invalid: The Base <id> '20[%20]' in OpAccessChain instruction must be a pointer.
  %21 = OpAccessChain %_ptr_Function_int %20 %int_0

The load is gabage anyway because .Get() isn't supposed to result in a load to Function storage space, and member access is just supposed to form access chains which are still in the PhysicalStorageBuffer space.

If I save the return value of the bitcast function, it fixes the problem.

Tag Dan Brown (@danbrown-amd)

Environment

  • DXC version 3b1a29b
  • Host Operating System Godbolt

Activity

  1. added
    bug
    needs-triage
    spirv
    on Apr 3, 2025
  2. added a commit that references this issue on Apr 6, 2025
    a2dc0b7
  3. added a commit that references this issue on Apr 14, 2025
    47e11af
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triagespirv

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions