Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConstantBuffer inside a ParameterBlock breaks the compiler when targeting metal. #4687

Closed
csyonghe opened this issue Jul 18, 2024 · 0 comments · Fixed by #4752
Closed

ConstantBuffer inside a ParameterBlock breaks the compiler when targeting metal. #4687

csyonghe opened this issue Jul 18, 2024 · 0 comments · Fixed by #4752
Assignees
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang

Comments

@csyonghe
Copy link
Collaborator

Changes nested-parameter-block-2.slang line 21 from ParameterBlock to ConstantBuffer crashes the compiler.

Repro:

struct CB
{
    uint4 value;
}

struct MaterialSystem
{
    CB cb;
    RWStructuredBuffer<uint4> data;
}

struct Scene
{
    CB sceneCb;
    RWStructuredBuffer<uint4> data;
    ConstantBuffer<MaterialSystem> material;
}

//TEST_INPUT: set scene = new Scene { { {1,2,3,4} }, ubuffer(data=[1 2 3 4], stride=4), new MaterialSystem {{ {1,2,3,4} }, ubuffer(data=[1 2 3 4], stride=4)} }
ParameterBlock<Scene> scene;

struct MyBuffer
{
    RWStructuredBuffer<uint4> resultBuffer;
}
//TEST_INPUT: set pb2 = new MyBuffer { out ubuffer(data=[0 0 0 0], stride=4) }
ParameterBlock<MyBuffer> pb2;

// Main entry-point. Applies the transformation encoded by `transformer`
// to all elements in `buffer`.
[shader("compute")]
[numthreads(4,1,1)]
void computeMain(uint3 sv_dispatchThreadID : SV_DispatchThreadID)
{
    // CHECK: type: uint32_t
    // CHECK-NEXT: 4
    // CHECK-NEXT: 4
    // CHECK-NEXT: 4
    // CHECK-NEXT: 4
    pb2.resultBuffer[sv_dispatchThreadID.x] = scene.sceneCb.value.x + scene.data[0].x + scene.material.cb.value.x + scene.material.data[0].x;
}

@csyonghe csyonghe added the goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant