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

Readable shader error messages #2622

Merged
merged 1 commit into from Apr 5, 2018
Merged

Conversation

kvark
Copy link
Member

@kvark kvark commented Apr 5, 2018

Working with shaders, I find #line navigation experience to be rather poor:

  1. first, I take an apitrace capture
  2. load the capture, go to the last glShaderSource
  3. copy out the input into a new file
  4. for each #line directive, try to match the reported error number ...

This PR removes line overrides. Instead, it prints the relevant piece to the console, e.g.:

Loading shaders...
Failed to compile shader: cs_clip_image
0:1152(17): error: syntax error, unexpected NEW_IDENTIFIER, expecting ',' or ';'

|	    ClipScrollNode scroll_node = fetch_clip_scroll_node(cmi.scroll_node_id);
>	    DImageMaskData mask = fetch_mask_data(cmi.clip_data_address);
|	    RectWithSize local_rect = mask.local_rect;

This information instantly gives me an idea of what's wrong (note: unlike the original driver message), and makes all the listed steps unnecessary for 99% of cases. And when the steps are necessary, we don't have to check for each #line occurrence since the driver-reported line number is no longer ambiguous.


This change is Reviewable

@glennw
Copy link
Member

glennw commented Apr 5, 2018

Nice!

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit fc8a16c has been approved by glennw

@bors-servo
Copy link
Contributor

⌛ Testing commit fc8a16c with merge 97e9c3c...

bors-servo pushed a commit that referenced this pull request Apr 5, 2018
Readable shader error messages

Working with shaders, I find `#line` navigation experience to be rather poor:
  1. first, I take an `apitrace` capture
  2. load the capture, go to the last `glShaderSource`
  3. copy out the input into a new file
  4. for each `#line` directive, try to match the reported error number ...

This PR removes line overrides. Instead, it prints the relevant piece to the console, e.g.:
```
Loading shaders...
Failed to compile shader: cs_clip_image
0:1152(17): error: syntax error, unexpected NEW_IDENTIFIER, expecting ',' or ';'

|	    ClipScrollNode scroll_node = fetch_clip_scroll_node(cmi.scroll_node_id);
>	    DImageMaskData mask = fetch_mask_data(cmi.clip_data_address);
|	    RectWithSize local_rect = mask.local_rect;
```

This information instantly gives me an idea of what's wrong (note: unlike the original driver message), and makes all the listed steps unnecessary for 99% of cases. And when the steps are necessary, we don't have to check for each `#line` occurrence since the driver-reported line number is no longer ambiguous.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2622)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

☀️ Test successful - status-appveyor, status-taskcluster
Approved by: glennw
Pushing 97e9c3c to master...

@bors-servo bors-servo merged commit fc8a16c into servo:master Apr 5, 2018
@kvark kvark deleted the shader-error branch April 6, 2018 03:06
bors-servo pushed a commit that referenced this pull request Apr 6, 2018
Separate primitive shaders from clip shaders

Includes #2622

Note: this is not done because I'm bored.
The problem Szeged team has bumped into is that `aDataX` attributes end up being used in the shaders they don't relate to (e.g. clip shaders). This isn't affecting GLSL but it does affect GLSL -> SPIRV -> XXX shader pipelines.

The solution I came up with involves moving parts of `prim_shared` into separate shared modules, and turning `clip_shared` into a catch-all header of clip shades.

Downsides: more shader modules (but not programs) to navigate between.
Any suggestions on alternative solutions are welcome ;)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2623)
<!-- Reviewable:end -->
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.

None yet

3 participants