microsoft / microsoft/DirectXShaderCompiler

[SPIR-V] Invalid SPIR-V when mutating struct using method and vk::BufferPointer

Open
#8,403 0 comments 0 reactions 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
Trying to mutate a struct using a method through a vk::BufferPointer causes invalid SPIR-V with non-aligned load ops to be generated.

Steps to Reproduce
https://godbolt.org/z/1vPTjjn6n

struct Foo {
    uint a;
    void increment() {
        a += 1;    
    }
};

[[vk::push_constant]]
struct Pc {
    vk::BufferPointer<Foo> ptr;
} pc;

[numthreads(1, 1, 1)]
void main() {
    pc.ptr.Get().increment();
}

Actual Behavior
fatal error: generated SPIR-V is invalid: [VUID-StandaloneSpirv-PhysicalStorageBuffer64-04708] Memory accesses with PhysicalStorageBuffer must use Aligned.
%20 = OpLoad %uint %19

Environment

  • DXC trunk

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 by reproducing the HLSL example from the linked Godbolt case with DXC trunk and inspect the generated SPIR-V around the reported OpLoad. Use the PhysicalStorageBuffer64-04708 validation error as the completion criterion: the mutation through vk::BufferPointer should no longer generate invalid, non-aligned load operations.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.