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

[hlsl-out] error X3017: '_expr1': initializer does not match type #1892

Closed
hasali19 opened this issue May 4, 2022 · 1 comment · Fixed by #1893
Closed

[hlsl-out] error X3017: '_expr1': initializer does not match type #1892

hasali19 opened this issue May 4, 2022 · 1 comment · Fixed by #1893
Labels
area: back-end Outputs of shader conversion kind: bug Something isn't working lang: HLSL High-Level Shading Language

Comments

@hasali19
Copy link
Contributor

hasali19 commented May 4, 2022

This code results in an hlsl compilation error:

struct Struct_1 {
    a: vec3<u32>,
    b: u32,
    c: u32,
}

struct StorageBuffer {
    a: i32,
    b: Struct_1,
    c: i32,
    d: i32,
}

@group(0)
@binding(0)
var<storage, read_write> s_buf: StorageBuffer;

@compute
@workgroup_size(1)
fn main() {
    var x = s_buf;
}

Output:

The application panicked (crashed).
Message:  wgpu error: Validation Error

Caused by:
    In Device::create_compute_pipeline
    Internal error: D3DCompile error (0x80004005): \\wsl.localhost\Ubuntu\home\hasan\dev\wgslsmith\Shader@0x000002C9D5720AC0(36,19-178): error X3017: '_expr1': initializer does not match type

I think this is probably because the hlsl doesn't initialise the padding in the structs:


struct Struct_1_ {
    uint3 a;
    uint b;
    uint c;
    int _end_pad_0;
    int _end_pad_1;
    int _end_pad_2;
};

struct StorageBuffer {
    int a;
    int _pad1_0;
    int _pad1_1;
    int _pad1_2;
    Struct_1_ b;
    int c;
    int d;
    int _end_pad_0;
    int _end_pad_1;
};

RWByteAddressBuffer s_buf : register(u0);

[numthreads(1, 1, 1)]
void main()
{
    StorageBuffer x = (StorageBuffer)0;

    StorageBuffer _expr1 = {asint(s_buf.Load(0)), {asuint(s_buf.Load3(16+0)), asuint(s_buf.Load(16+12)), asuint(s_buf.Load(16+16))}, asint(s_buf.Load(48)), asint(s_buf.Load(52))};
    x = _expr1;
    return;
}
@teoxoy teoxoy added kind: bug Something isn't working area: back-end Outputs of shader conversion lang: HLSL High-Level Shading Language labels May 4, 2022
@teoxoy teoxoy added this to the WGSL Specification V1 milestone May 4, 2022
@teoxoy
Copy link
Member

teoxoy commented May 4, 2022

Thanks for the report!

Looks like loading from storage buffers uses a different code path and the constructor function is not used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: back-end Outputs of shader conversion kind: bug Something isn't working lang: HLSL High-Level Shading Language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants