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

Handle vector, matrix and array OOB accesses for HLSL #4389

Open
teoxoy opened this issue May 14, 2022 · 3 comments
Open

Handle vector, matrix and array OOB accesses for HLSL #4389

teoxoy opened this issue May 14, 2022 · 3 comments
Labels
area: naga back-end Outputs of naga shader conversion lang: HLSL D3D Shading Language naga Shader Translator

Comments

@teoxoy
Copy link
Member

teoxoy commented May 14, 2022

The following WGSL causes FXC to error with: error X3504: array index out of bounds

@compute @workgroup_size(1)
fn main() {
    var idx = 9;
    var v = vec2<f32>();
    var m = mat2x2<f32>();
    var a = array<f32,1>();
    var vi = v[idx];
    var mi = m[idx];
    var ai = a[idx];
}

https://shader-playground.timjones.io/19d35c227236839667eb8830d12a4af0

Related:

@teoxoy
Copy link
Member Author

teoxoy commented May 14, 2022

According to the WGSL spec the same example from above but using let instead of var should also work but validation currently errors.

@jimblandy can you confirm this?

@teoxoy teoxoy changed the title Handle OOB accesses for HLSL Handle vector, matrix and array OOB accesses for HLSL May 14, 2022
@jimblandy
Copy link
Member

Yes, with let I get:

error: Index 9 is out of bounds for expression [2]

This is Naga's fault: it's reporting as a compile-time error a problem that WGSL requires us to handle at run-time.

Could you file a separate issue for this?

@nical
Copy link
Contributor

nical commented Jan 3, 2024

See also: #4337

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga back-end Outputs of naga shader conversion lang: HLSL D3D Shading Language naga Shader Translator
Projects
Status: No status
Development

No branches or pull requests

4 participants