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

Usage of Buffer and RWBuffer yields invalid WGSL code with no errors #6304

Open
aleino-nv opened this issue Feb 6, 2025 · 4 comments
Open
Assignees
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang

Comments

@aleino-nv
Copy link
Collaborator

aleino-nv commented Feb 6, 2025

From discord issue 'Oddity With Buffers When Targeting Wgsl in 2025.3.2'.

The following code

Buffer<float> InputTyped;
RWBuffer<float> OutputTyped;

[numthreads(64, 1, 1)]
void Main(uint3 DTid : SV_DispatchThreadID)
{
    OutputTyped[DTid.x] = InputTyped[DTid.x];
}

Compiling with .\slangc .\test.slang -target wgsl -entry Main -stage compute -o test.txt produces invalid WGSL without any errors:

@compute
@workgroup_size(64, 1, 1)
fn Main(@builtin(global_invocation_id) DTid_0 : vec3<u32>)
{
}
@aleino-nv aleino-nv self-assigned this Feb 6, 2025
@aleino-nv aleino-nv added the goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang label Feb 6, 2025
@aleino-nv
Copy link
Collaborator Author

gpuweb/gpuweb#162

https://www.w3.org/TR/WGSL/#resource-interface

@csyonghe We should be emitting an error when Buffer and RWBuffer is used when targeting WGSL, right? As far as I can tell, WebGPU doesn't support either of these use-cases.

@aleino-nv aleino-nv changed the title Usage of Buffer and RWBuffer yields invalid WGSL code with not errors Usage of Buffer and RWBuffer yields invalid WGSL code with no errors Feb 6, 2025
@csyonghe
Copy link
Collaborator

csyonghe commented Feb 6, 2025

I agree. Using Buffer on wgsl should be an error.

@aleino-nv
Copy link
Collaborator Author

I agree. Using Buffer on wgsl should be an error.

@csyonghe Can we (should we?) use the capability system to raise this error?
(I've only seen examples where we use the capability system to constrain use of functions, rather than types, so I'm not sure how this would look. Any examples?)

@csyonghe
Copy link
Collaborator

csyonghe commented Feb 7, 2025

Yes, this is exactly what the capability system is supposed to do. However we only implemented capability check in function calls and not on the type itself. For now let’s just mark the capability requirement on the Buffer type, and once the capability system is fully checking use sites of types we will get the error.

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

No branches or pull requests

2 participants