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

Passing an image to a function causing a spirv-val validation error "type does not match function parameter type" #1720

Closed
nicovize opened this issue Mar 8, 2019 · 3 comments

Comments

@nicovize
Copy link

nicovize commented Mar 8, 2019

Hello,

I get the following error from spirv-val when I try to pass an image to a function :

error: line 24: OpFunctionCall Argument '15[%TestRWTex]'s type does not match Function '8[%ptr_UniformConstant_7]'s parameter type.
%16 = OpFunctionCall %void %f_I21
%TestRWTex

Here is the minimal compute shader that causes the problem from the validator (this compiles fine, however) :

#version 450

layout (binding=0, rgba32f)  uniform image2D TestRWTex;

void f(image2D rwTexture)
{
}

void main()
{
    f(TestRWTex);
}

I used the following command line to get the error :

glslangValidator -o image_passed_to_function.spv -V --target-env vulkan1.1 image_passed_to_function.comp
spirv-val image_passed_to_function.spv

I'm not sure if there is a workaround, as declaring a "uniform image2D" in nested function scope is not allowed in GLSL, it seems.

glslangvalidator version infos (version from 1.1.101.0 Vulkan SDK) :

Glslang Version: 7.11.3113
ESSL Version: OpenGL ES GLSL 3.20 glslang Khronos. 11.3113
GLSL Version: 4.60 glslang Khronos. 11.3113
SPIR-V Version 0x00010300, Revision 6
GLSL.std.450 Version 100, Revision 1
Khronos Tool ID 8
SPIR-V Generator Version 7
GL_KHR_vulkan_glsl version 100
ARB_GL_gl_spirv version 100

best regards,

@johnkslang
Copy link
Member

johnkslang commented Mar 11, 2019

I think this is a problem with GLSL itself, which Khronos is currently looking into.

The types don't match, because one has the layout rgba32f and the other does not, yet GLSL seems to require it on the global (unless it is writeonly) and generally does not allow qualifiers on the function parameter (though perhaps it should for this purpose).

Given your variable name, I doubt it helps, but the following works:

#version 450

writeonly layout (binding=0)  uniform image2D TestRWTex;

void f(writeonly image2D rwTexture)
{
}

void main()
{
    f(TestRWTex);
}

@johnkslang
Copy link
Member

See KhronosGroup/GLSL#57.

This is pending an extension that enables the use of the qualifiers needed.

In the meantime, I'll see if glslang should be issuing an error for this at the GLSL level.

@nicovize
Copy link
Author

Hi John,
Thanks for sharing this info!
This is great that an extension is coming to handle this case.
If the issue can be resolved at GLSL level, still better :)
best regards

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