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

get error log of shader if it fails to compile #137

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Inconn
Copy link
Contributor

@Inconn Inconn commented Mar 26, 2023

logs shader compile error if a shader fails to compile for some reason.
i dunno if you guys want this or not but i made it while fixing the nvidia bug and thought i might as well make a PR. tell me if there's anything you want to change.

@ErikReider
Copy link
Collaborator

This would be a good addition when debugging! What do you think @WillPower3309? :)

@ErikReider
Copy link
Collaborator

I seem to get duplicated error messages, one from wlroots and the one that you're outputting

@Inconn
Copy link
Contributor Author

Inconn commented Apr 21, 2023

How are you erroring? maybe wlroots added error messages? (or had them and I didn't know so I made this).

@ErikReider
Copy link
Collaborator

How are you erroring? maybe wlroots added error messages? (or had them and I didn't know so I made this).

Just some simple syntax errors like removing semicolon and bracket

@Inconn
Copy link
Contributor Author

Inconn commented Apr 22, 2023

Maybe you're not getting duplicates? Do you only do one error at a time or multiple? Because if you have multiple errors it tells you every error instead of just the first one. Otherwise I'm not sure of what you're seeing

@ErikReider
Copy link
Collaborator

Maybe you're not getting duplicates? Do you only do one error at a time or multiple? Because if you have multiple errors it tells you every error instead of just the first one. Otherwise I'm not sure of what you're seeing

I'm sometimes getting more info from the built-in error output. Example:

diff --git a/sway/desktop/shaders/tex.frag b/sway/desktop/shaders/tex.frag
index 40320f9b..c161bd03 100644
--- a/sway/desktop/shaders/tex.frag
+++ b/sway/desktop/shaders/tex.frag
@@ -47,7 +47,7 @@ void main() {
         vec4 pixColor = texture2D(tex, v_texcoord);
         vec3 irgb = pixColor.rgb;
         vec3 target = vec3(dot(irgb, saturation_weight));
-        color = vec4(mix(target, irgb, saturation), pixColor.a);
+        color = vec4(mix(target, irgb), pixColor.a);
     }
     // Dimming
     gl_FragColor = mix(color, dim_color, dim) * alpha;
@@ -55,9 +55,9 @@ void main() {
     if (!has_titlebar || gl_FragCoord.y - position.y > radius) {
         vec2 corner_distance = min(gl_FragCoord.xy - position, size + position - gl_FragCoord.xy);
         if (max(corner_distance.x, corner_distance.y) < radius) {
-            float d = radius - distance(corner_distance, vec2(radius));
+            float d = radius - distance(corner_distance, vec1(radius));
             float smooth = smoothstep(-1.0f, 0.5f, d);
-            gl_FragColor = mix(vec4(0), gl_FragColor, smooth);
+            gl_FragColor = mix(vec2(0), gl_FragColor, smooth);
         }
     }
 }
00:00:00.023 [wlr] [GLES2] 0:51(15): error: no matching function for call to `mix(vec3, vec3)'; candidates are:
00:00:00.023 [wlr] [GLES2] 0:51(15): error:    float mix(float, float, float)
00:00:00.023 [wlr] [GLES2] 0:51(15): error:    vec2 mix(vec2, vec2, float)
00:00:00.023 [wlr] [GLES2] 0:51(15): error:    vec3 mix(vec3, vec3, float)
00:00:00.023 [wlr] [GLES2] 0:51(15): error:    vec4 mix(vec4, vec4, float)
00:00:00.023 [wlr] [GLES2] 0:51(15): error:    vec2 mix(vec2, vec2, vec2)
00:00:00.023 [wlr] [GLES2] 0:51(15): error:    vec3 mix(vec3, vec3, vec3)
00:00:00.023 [wlr] [GLES2] 0:51(15): error:    vec4 mix(vec4, vec4, vec4)
00:00:00.023 [wlr] [GLES2] 0:51(10): error: cannot construct `vec4' from a non-numeric data type
00:00:00.023 [wlr] [GLES2] 0:59(47): error: no function with name 'vec1'
00:00:00.023 [wlr] [GLES2] 0:59(21): error: no matching function for call to `distance(vec2, error)'; candidates are:
00:00:00.023 [wlr] [GLES2] 0:59(21): error:    float distance(float, float)
00:00:00.023 [wlr] [GLES2] 0:59(21): error:    float distance(vec2, vec2)
00:00:00.023 [wlr] [GLES2] 0:59(21): error:    float distance(vec3, vec3)
00:00:00.023 [wlr] [GLES2] 0:59(21): error:    float distance(vec4, vec4)
00:00:00.023 [wlr] [GLES2] 0:59(12): error: operands to arithmetic operators must be numeric
00:00:00.023 [wlr] [GLES2] 0:61(17): error: no matching function for call to `mix(vec2, vec4, float)'; candidates are:
00:00:00.023 [wlr] [GLES2] 0:61(17): error:    float mix(float, float, float)
00:00:00.023 [wlr] [GLES2] 0:61(17): error:    vec2 mix(vec2, vec2, float)
00:00:00.023 [wlr] [GLES2] 0:61(17): error:    vec3 mix(vec3, vec3, float)
00:00:00.023 [wlr] [GLES2] 0:61(17): error:    vec4 mix(vec4, vec4, float)
00:00:00.023 [wlr] [GLES2] 0:61(17): error:    vec2 mix(vec2, vec2, vec2)
00:00:00.023 [wlr] [GLES2] 0:61(17): error:    vec3 mix(vec3, vec3, vec3)
00:00:00.023 [wlr] [GLES2] 0:61(17): error:    vec4 mix(vec4, vec4, vec4)
00:00:00.023 [sway/desktop/fx_renderer.c:109] Failed to compile shader
00:00:00.023 [sway/desktop/fx_renderer.c:115] Error log: "0:60(29): warning: Float suffixes are invalid in GLSL 1.10
0:60(35): warning: Float suffixes are invalid in GLSL 1.10
0:51(15): error: no matching function for call to `mix(vec3, vec3)'; candidates are:
0:51(15): error:    float mix(float, float, float)
0:51(15): error:    vec2 mix(vec2, vec2, float)
0:51(15): error:    vec3 mix(vec3, vec3, float)
0:51(15): error:    vec4 mix(vec4, vec4, float)
0:51(15): error:    vec2 mix(vec2, vec2, vec2)
0:51(15): error:    vec3 mix(vec3, vec3, vec3)
0:51(15): error:    vec4 mix(vec4, vec4, vec4)
0:51(10): error: cannot construct `vec4' from a non-numeric data type
0:59(47): error: no function with name 'vec1'
0:59(21): error: no matching function for call to `distance(vec2, error)'; candidates are:
0:59(21): error:    float distance(float, float)
0:59(21): error:    float distance(vec2, vec2)
0:59(21): error:    float distance(vec3, vec3)
0:59(21): error:    float distance(vec4, vec4)
0:59(12): error: operands to arithmetic operators must be numeric
0:60(41): warning: `"

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

Successfully merging this pull request may close these issues.

2 participants