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

Incorrect validation for writeonly image2d uniform declarations in GLSL #4530

Open
spencerkohan opened this issue Sep 17, 2022 · 1 comment
Labels
area: naga front-end lang: GLSL OpenGL Shading Language naga Shader Translator type: bug Something isn't working type: enhancement New feature or request

Comments

@spencerkohan
Copy link

I am trying to validate the following shader using Naga:

#version 450

#define WORKGROUP_SIZE 16
layout (local_size_x = WORKGROUP_SIZE, local_size_y = WORKGROUP_SIZE, local_size_z = 1 ) in;

precision highp float;

layout(binding = 2) uniform writeonly image2D outputImage;

void main () {
    ivec2 textureSize = imageSize(outputImage);
    
    if (gl_GlobalInvocationID.x >= textureSize.x || gl_GlobalInvocationID.y >= textureSize.y) {
        return;
    }
    
    ivec2 index = ivec2(gl_GlobalInvocationID.xy);
    vec4 colorOut = vec4(1, 0, 1, 1);
    imageStore(outputImage, index, colorOut);
}

And I get the following validation errors:

image types require a format layout qualifier
Unknown function 'imageStore'

The requirement for a format layout qualifier is incorrect. According to the specification:

mage variables can be declared with a format qualifier; this specifies the format for any read operations done on the image. Therefore, a format qualifier is required if you do not declare the variable with the writeonly memory qualifier. Write-only variables cannot be used as in any reading operations; this includes calling load and atomic (read/modify/write) functions. So if you want to read from an image, you must declare the format.

In other words, the format qualifier should not be required in the presence of writeonly.

@spencerkohan
Copy link
Author

I created a PR for this here: gfx-rs/naga#2061

@JCapucho JCapucho added kind: bug area: naga front-end lang: GLSL OpenGL Shading Language type: enhancement New feature or request labels Oct 21, 2022
@cwfitzgerald cwfitzgerald transferred this issue from gfx-rs/naga Oct 25, 2023
@cwfitzgerald cwfitzgerald added naga Shader Translator type: bug Something isn't working and removed kind: bug labels Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga front-end lang: GLSL OpenGL Shading Language naga Shader Translator type: bug Something isn't working type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants