Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 28, 2025

SPIRV debug info for StructuredBuffer types emits "unamed" for the internal array member, making it difficult for debuggers to parse the structure. The alternative solution from the issue is to use the __member0 naming convention.

Changes

  • slang-ir-spirv-legalize.cpp: Add name hint decoration to the array key in lowerStructuredBufferType
  • tests/spirv/debug-structured-buffer-member-name.slang: Regression test for the fix

Before/After

// Before
%50 = OpString "unamed"
OpMemberName %StructuredBuffer 0 "unamed"

// After  
%50 = OpString "__member0"
OpMemberName %StructuredBuffer 0 "__member0"
Original prompt

This section details on the original issue you should resolve

<issue_title>StructuredBuffer DebugInfo should match how it's used in shader source</issue_title>
<issue_description># Problem Description
For the following shader, for example:

struct VertexInputData
{
    float3 position;
    float3 color;
};

struct VertexOutputData
{
    float4 vertPosition : SV_Position;
    float3 vertColor;
};

struct SSBOData
{
    float3 positionShift;
    float3 colorShift;
};

StructuredBuffer<SSBOData> ssbo : register(t1);

VertexOutputData main(VertexInputData vertIn)
{
    VertexOutputData vertOut = {
        float4(vertIn.position + ssbo[0].positionShift, 1.0),
        vertIn.color + ssbo[0].colorShift,
    };

    return vertOut;
}

compiled with: slangc.exe shader.vs -target spirv -g3 -O0 -stage vertex -o shader.spv -entry main

The debuginfo that gets generated for ssbo treats ssbo as a structure with a single element, which appears as an unnamed array of SSBOData. This doesn't align with what debuggers expect, and it would be good to generate output that aligns more closely with how ssbo is used in the shader source.

Preferred Solution

Ideally, we would emit debuginfo that represents ssbo directly as an array of SSBOData, rather than as a struct with a single member which is an array of SSBOData.

Alternative Solutions

If the ideal solution isn't possible, then we could reasonably just attach an easier-to-parse name to the array member of the struct. Existing solutions expect naming like __member0, where subsequent members (if they exist) would increment that (__member1, etc.).</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: zangold-nv <242329104+zangold-nv@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix StructuredBuffer debug info to match shader source usage Fix StructuredBuffer DebugInfo to use __member0 naming for array member Nov 28, 2025
Copilot AI requested a review from zangold-nv November 28, 2025 23:10
Copilot finished work on behalf of zangold-nv November 28, 2025 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StructuredBuffer<T> DebugInfo should match how it's used in shader source

2 participants