shaders: report line numbers error accurately - #297
Conversation
| params->label ? params->label : "", s_with_numbers); | ||
| ngli_free(s_with_numbers); | ||
| } | ||
| LOG(ERROR, "failed to compile shader \"%s\"", params->label ? params->label : ""); |
There was a problem hiding this comment.
I tested a bit the PR, and for now, I think it makes debugging harder. While it works for simple cases, it does not scale well, especially since we are injecting the ressources / inputs / outputs / helpers, ie: there's no other way to visualize the whole assembled shader, which is of great help for debugging. This is even more true for builtin shaders assembled from different glsl helpers and/or when nopegl is distributed across multiple devices with different kind of gpus (for example, one shader can fail on a specific hw / driver combinaison and works nicely on the other devices). Just having the error reported without the full context would make debugging a nightmare.
There was a problem hiding this comment.
Another issue I see, is that it would not work with builtins such as ngl_texvideo() is they use more than one line. This is currently the case so not an issue. But I had the idea at some point to use multiple line to make the final shader more readable.
There was a problem hiding this comment.
With a debug option we could add a flag to keep dumping the whole thing for the project developers.
For users though the current experience as-is is much better experience. They don't have access to includes so and the line reset appears right before their input, which means the lines are aligned with their input, always (unless they have their own include system, in which case they can also use line directives in their own preprocessor).
There was a problem hiding this comment.
Another issue I see, is that it would not work with builtins such as ngl_texvideo() is they use more than one line. This is currently the case so not an issue. But I had the idea at some point to use multiple line to make the final shader more readable.
We could still trick it with something like that:
#line 34
tex = texture(
foo,
bar
);
#line 35And if we use a function declared before the user input it's a non-issue.
No description provided.