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

Argument variable using out keyword causes unexpected behaviour #238

Open
bogrundtman opened this issue Jun 21, 2024 · 0 comments
Open

Argument variable using out keyword causes unexpected behaviour #238

bogrundtman opened this issue Jun 21, 2024 · 0 comments

Comments

@bogrundtman
Copy link

When a variable is used with the out keyword in a function argument then it seems to trigger an if statement right below the function call even though the if statement should never execute.

This fragment shader turns the screen WHITE

#version 450
layout(location = 0) out vec4 out_color;
void empty_function(out vec3 color) {}

void main() {
    vec3 color = vec3(0, 0, 0);
    empty_function(color);              // When commenting out this line the if statement does not execute and the screen turns BLACK
    if (false) {color = vec3(1,1,1);}

    out_color = vec4(color, 1);
}

When involving another variable and taking the maximum of the two (In this case the screen would turn WHITE if the if statement executed) the issue seems to disappear.

This fragment shader turns the screen BLACK

#version 450
layout(location = 0) out vec4 out_color;
void empty_function(out vec3 color) {}

void main() {
    vec3 color = vec3(0, 0, 0);
    vec3 actual_color = vec3(0, 0, 0);
    empty_function(color);
    if (false) {actual_color = vec3(1,1,1);}

    out_color = vec4(max(color, actual_color), 1);
}

Info

Hardware: Intel Iris Xe Graphics
API: Vulkan 1.3.283

glslc --version

shaderc v2023.8 v2024.0
spirv-tools v2024.1 v2022.4-451-g04896c46
glslang 11.1.0-937-gd73712b8

Target: SPIR-V 1.0
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

1 participant