swayfx icon indicating copy to clipboard operation
swayfx copied to clipboard

get error log of shader if it fails to compile

Open Inconn opened this issue 1 year ago • 6 comments

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.

Inconn avatar Mar 26 '23 04:03 Inconn

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

ErikReider avatar Apr 21 '23 11:04 ErikReider

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

ErikReider avatar Apr 21 '23 15:04 ErikReider

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

Inconn avatar Apr 21 '23 22:04 Inconn

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

ErikReider avatar Apr 21 '23 22:04 ErikReider

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

Inconn avatar Apr 22 '23 02:04 Inconn

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: `"

ErikReider avatar Apr 23 '23 11:04 ErikReider