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

textureLoad does not allows texture_multisampled_2d #9

Closed
IcanDivideBy0 opened this issue Jan 5, 2022 · 16 comments
Closed

textureLoad does not allows texture_multisampled_2d #9

IcanDivideBy0 opened this issue Jan 5, 2022 · 16 comments

Comments

@IcanDivideBy0
Copy link

no overload of `textureLoad` found for given arguments. Found (texture_2d_multisampled<f32>, vec2<i32>, i32), expected one of:
fn(texture_1d<T>, i32, i32) -> vec4<T>
fn(texture_2d<T>, vec2<i32>, i32) -> vec4<T>
fn(texture_2d_array<T>, vec2<i32>, i32, i32) -> vec4<T>
fn(texture_3d<T>, vec3<i32>, i32) -> vec4<T>
fn(texture_2d_multisampled_array<T>, vec2<i32>, i32) -> vec4<T>
fn(texture_depth_2d, vec2<i32>, i32) -> f32
fn(texture_depth_2d_array, vec2<i32>, i32, i32) -> f32
fn(texture_depth_2d_multisampled, vec2<i32>, i32) -> f32
fn(texture_external, vec2<i32>) -> vec4<f32>
fn(texture_storage_1d<F,read>, i32) -> F::StorageType
fn(texture_storage_2d<F,read>, vec2<i32>) -> F::StorageType
fn(texture_storage_2d_array<F,read>, vec2<i32>, i32) -> F::StorageType
fn(texture_storage_3d<F,read>, vec3<i32>) -> F::StorageType
@IcanDivideBy0
Copy link
Author

Just installed the extension from market place,
It looks like the analyzer should suport it tho ... https://github.com/wgsl-analyzer/wgsl-analyzer/blob/main/crates/hir_ty/builtins.wgsl#L183

@IcanDivideBy0
Copy link
Author

What's strange is that the error reports a texture_2d_multisampled but i'm using a texture_multisampled_2d

@IcanDivideBy0
Copy link
Author

@jakobhellermann
Copy link
Contributor

The order is incorrect as you pointed out, and the issue with textureLoad is that the builtins get generated from a file, but the multisampled_2d texture was recognized as arrayed: true which is false.

I pushed fixes for the formatting and the incorrect array texture, a new version 0.1.4 should be released once the CI finishes running.

@jakobhellermann
Copy link
Contributor

jakobhellermann commented Jan 5, 2022

The new version should be released now, can you check if the issue is fixed?

Edit: nevermind, I think it's still incorrect
Edit 2: Now it should work.

@IcanDivideBy0
Copy link
Author

IcanDivideBy0 commented Jan 5, 2022

thanks, the issue seems to be fixed for texture_multisampled_2d, now i'm having a similar error with texture_depth_multisampled_2d:

no overload of `textureLoad` found for given arguments. Found (texture_depth_multisampled_1d, vec2<i32>, i32), expected one of:
fn(texture_1d<T>, i32, i32) -> vec4<T>
fn(texture_2d<T>, vec2<i32>, i32) -> vec4<T>
fn(texture_2d_array<T>, vec2<i32>, i32, i32) -> vec4<T>
fn(texture_3d<T>, vec3<i32>, i32) -> vec4<T>
fn(texture_multisampled_2d<T>, vec2<i32>, i32) -> vec4<T>
fn(texture_depth_2d, vec2<i32>, i32) -> f32
fn(texture_depth_2d_array, vec2<i32>, i32, i32) -> f32
fn(texture_depth_multisampled_2d, vec2<i32>, i32) -> f32
fn(texture_external, vec2<i32>) -> vec4<f32>
fn(texture_storage_1d<F,read>, i32) -> F::StorageType
fn(texture_storage_2d<F,read>, vec2<i32>) -> F::StorageType
fn(texture_storage_2d_array<F,read>, vec2<i32>, i32) -> F::StorageType
fn(texture_storage_3d<F,read>, vec3<i32>) -> F::StorageType

@jakobhellermann
Copy link
Contributor

Fixed it: e3cd69a.

Is the shader you are using open source so I can try it locally or are are there other errors I should fix before releasing 0.1.6?

@IcanDivideBy0
Copy link
Author

yes, please, take a look here: https://github.com/IcanDivideBy0/calva/blob/master/calva-renderer/src/shaders/light.shadow.wgsl
there's many other errors like:

no overload of `dot` found for given arguments. Found (vec3<T>, vec3<f32>), expected one of:
fn(vecN<f32>, vecN<f32>) -> f32

@jakobhellermann
Copy link
Contributor

I found the issue, vec3<f32> and vec3<T> didn't get unified correctly when type checking the built-ins. Pushed the fix and released 0.1.6, everything should be working correctly now.

@IcanDivideBy0
Copy link
Author

thanks, this shader is fine now, i still have other issues tho, you can check other shaders in the same directory: https://github.com/IcanDivideBy0/calva/blob/master/calva-renderer/src/shaders/

most notabely:

let frag_pos_view = camera.inv_proj * vec4<f32>(in.ndc, z, 1.0);
let frag_pos_view = frag_pos_view.xyz / frag_pos_view.w;

let L = normalize(in.l_position - frag_pos_view); // frag_pos_view is considered a vec4 by wgsl-analyzer

and:

fn get_skinning_matrix(frame: u32, in: VertexInput) -> mat4x4<f32> {
    let joints = vec4<u32>(
        in.joints >>  0u & 0xFFu,
        in.joints >>  8u & 0xFFu,
        in.joints >> 16u & 0xFFu,
        in.joints >> 24u & 0xFFu,
    );

    let m1 = get_joint_matrix(frame, joints.x) * in.weights.x; // multiply matrix by a scalar is reported as an error
    let m2 = get_joint_matrix(frame, joints.y) * in.weights.y;
    let m3 = get_joint_matrix(frame, joints.z) * in.weights.z;
    let m4 = get_joint_matrix(frame, joints.w) * in.weights.w;

    return mat4x4<f32>(
        m1.x + m2.x + m3.x + m4.x, // accessing matrix rows with .x, .y, etc is reported as an error
        m1.y + m2.y + m3.y + m4.y,
        m1.z + m2.z + m3.z + m4.z,
        m1.w + m2.w + m3.w + m4.w,
    );
}

@jakobhellermann
Copy link
Contributor

The first example isn't valid wgsl, you can't shadow variables in the same scope. It seems to be accepted in naga right now but it shouldn't be: https://gpuweb.github.io/gpuweb/wgsl/#declaration-and-scope

@IcanDivideBy0
Copy link
Author

Oh, ok, thanks for pointing it out 👍

@jakobhellermann
Copy link
Contributor

Accessing matrix rows by x, y, z also isn't valid in mesh.simple.wgsl: https://gpuweb.github.io/gpuweb/wgsl/#matrix-access-expr

    let view3 = mat3x3<f32>(
        camera.view.x.xyz,
        camera.view.y.xyz,
        camera.view.z.xyz,
    );

You should use [0] based indices.

@IcanDivideBy0
Copy link
Author

Ok, those have been fixed, only thing left is the matrix multiplication by a scalar which is allowed by the spec

@jakobhellermann
Copy link
Contributor

Those were missing but are added now, 0.2.0 is on its way to be released.

@IcanDivideBy0
Copy link
Author

Works like a charm 💯 thanks for your responsiveness!

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

No branches or pull requests

2 participants