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

Garbled output with reschart #68

Closed
ishitatsuyuki opened this issue Feb 28, 2021 · 4 comments · Fixed by #73
Closed

Garbled output with reschart #68

ishitatsuyuki opened this issue Feb 28, 2021 · 4 comments · Fixed by #73

Comments

@ishitatsuyuki
Copy link
Collaborator

ishitatsuyuki commented Feb 28, 2021

For some reason, piet-gpu seems to give garbled rendering for the reschart test. The test svg is attached below, and it consists of only typical path and strokes, which piet-gpu should have no problem handling. (It does use a transform to flip the image upside down, but piet-gpu simply ignore so it's unrelated to the issue.)

(File taken from MPVG test suite, renamed to txt for uploading to GitHub)

reschart.svg.txt

piet-gpu rendering (cargo run --release --bin cli -- reschart.svg --scale 2):

image

Looks like backdrop calculation is all over the place, but I'm not sure what is causing that.

@raphlinus
Copy link
Contributor

Thanks for bringing this up. It's evidence that the numerical stability issues in the coarse rasterizer are not fully resolved. The reschart image is definitely a stress test for it.

Honestly, I haven't prioritized the issue, in part because I'm fairly confident it can be solved. There are challenges, though, not least of which is that shaders are generally compiled with the equivalent of -ffast-math, so it's difficult to get absolute bit level equality guarantees even when subexpressions are identical. A systematic approach will involve some combination of analytical reasoning and thorough testing.

@ishitatsuyuki
Copy link
Collaborator Author

I tried out @eliasnaur's branch at #72, and I got the exactly same broken output as before. So it's deterministically broken and unrelated to the transform monoid.

@eliasnaur
Copy link
Collaborator

I think this is caused by reschart.svg relying on the SVG auto-close property and the piet-gpu parser doesn't support it. I can reproduce the corruption with just a single path from the original:

<svg>
<defs>
</defs>
<path id="path103" fill-rule="nonzero" stroke="none" fill="rgb(0,0,0)" d="M 428.031,84.3669 L 450.707,84.3669 450.707,78.699 428.031,78.699 "/>
</svg>

There are only 3 line commands, the fourth being implicit. The corruption is gone if I explicitly close the path:

<path id="path103" fill-rule="nonzero" stroke="none" fill="rgb(0,0,0)" d="M 428.031,84.3669 L 450.707,84.3669 450.707,78.699 428.031,78.699 428.031,84.3669"/>

@raphlinus
Copy link
Contributor

I think you're right, and it is good news indeed if that is the explanation; it should be fixable in the path encoding (CPU side) when generating paths for fill that lack a closepath element.

ishitatsuyuki added a commit to ishitatsuyuki/piet-gpu that referenced this issue Mar 16, 2021
ishitatsuyuki added a commit to ishitatsuyuki/piet-gpu that referenced this issue Mar 16, 2021
ishitatsuyuki added a commit to ishitatsuyuki/piet-gpu that referenced this issue Mar 16, 2021
ishitatsuyuki added a commit to ishitatsuyuki/piet-gpu that referenced this issue Mar 16, 2021
ishitatsuyuki added a commit to ishitatsuyuki/piet-gpu that referenced this issue Mar 16, 2021
ishitatsuyuki added a commit that referenced this issue Mar 16, 2021
Always close fill paths, fix #68

Close #68
Close #74
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 a pull request may close this issue.

3 participants