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

print: use OpNames to replace the T1/F2/v3 style, when unambiguous. #36

Merged
merged 2 commits into from
Jun 18, 2023

Conversation

eddyb
Copy link
Contributor

@eddyb eddyb commented Jun 8, 2023

I've also made the T1 style use subscripts (so more like T₁), because I wasn't happy with the aesthetics of having digits exactly as large as the prefix.

The reason I haven't done the subscript change earlier is e.g. v5 already looks great, and v₅ and T₅ still looks different because the T is larger than the v - the missing trick was to make the subscripts larger when the prefix is uppercase, which seems to balance things out.

Comparison (using Kajiya's assets/shaders/ircache/raster_origins_vs.hlsl, compiled by DXC, like #39):

Before
(click for complete pretty HTML example)
After
(click for complete pretty HTML example)
image image
image image

@eddyb eddyb changed the title [WIP] start using OpNames to replace e.g. type123 in some cases. Use OpNames to replace the type1/func2/v3 style, when unambiguous. Jun 9, 2023
eddyb added a commit that referenced this pull request Jun 11, 2023
…dth back to 120. (#37)

*Originally found/fixed during the #33/#34/#35/#36 series of
pretty-printing PRs.*

Before this PR, we were treating all text the same, regardless of style,
but this PR introduces the concept of "fractional columns" (integer
multiples of `0.1ch`, because our `font-size`s are always integer
multiples of `0.1em`).

The result is much more accurate, and so far appears to perfectly match
browser behavior (i.e. the transition of `MAX_LINE_WIDTH` from `N-1` to
`N`, where multi-line layout gets replaced with single-line layout,
results in a line that "tightly fits" in a `max-width: Nch` container,
with no spurious gaps or overflows).

Note however that the increased accuracy makes the layout favor HTML
over plaintext (and we don't have a plaintext-vs-HTML "simultaneous
layout", nor a way to hint what the output of pretty layout will be used
for), so the plaintext output may feel more inconsistent as a result
(but its aesthetics are of dubious value anyway).
eddyb added a commit that referenced this pull request Jun 13, 2023
… syntax. (#35)

This moves us from my ad-hoc `#{A, B, C}` to a Rust-style `#[A] #[B]
#[C]` attribute syntax, and removes the idea of a "attribute set
shorthand" (`attrs123 = #{...}` followed by uses of `#attrs123`), which
was more annoying than useful (attributes can't refer to other
attributes so there was no "exponential deduplication" need for it).

With `#[...]` syntax, it also makes sense to never say e.g. `OpDecorate`
(as the operand itself will contain the word `Decoration`), or to use
`#[name = "..."]` Rust-style syntax for `OpName`.

(I didn't touch `OpMember{Name,Decorate}`, might be worth having a
SPIR-T `struct` type declaration syntax just to clean those up but it
feels even more ad-hoc than usual - maybe it might make more sense after
#36?)

Comparison (using Kajiya's `assets/shaders/raster_simple_ps.hlsl`,
compiled by DXC, like #33):

|[**Before**](https://htmlpreview.github.io/?https://gist.github.com/eddyb/124d807950059893678ad55f51ee5107/raw/0-before-spirt%252335-raster_simple_ps.hlsl.structured.spirt.html)<br><sub>(click
for complete pretty HTML
example)</sub>|[**After**](https://htmlpreview.github.io/?https://gist.github.com/eddyb/124d807950059893678ad55f51ee5107/raw/1-after-spirt%252335-raster_simple_ps.hlsl.structured.spirt.html)<br><sub>(click
for complete pretty HTML example)</sub>|
|-|-|

|![image](https://github.com/EmbarkStudios/spirt/assets/77424/82ee846a-0ed7-4f6b-be4f-7c6ccd1ba2fa)|![image](https://github.com/EmbarkStudios/spirt/assets/77424/f725b9bd-7715-4c96-8e4e-e573e41a8478)|
@eddyb eddyb changed the title Use OpNames to replace the type1/func2/v3 style, when unambiguous. print: use OpNames to replace the T1/F2/v3 style, when unambiguous. Jun 15, 2023
@eddyb eddyb force-pushed the print-names branch 2 times, most recently from e703079 to 20828bf Compare June 15, 2023 08:52
@eddyb eddyb marked this pull request as ready for review June 18, 2023 03:49
@eddyb eddyb added this pull request to the merge queue Jun 18, 2023
Merged via the queue into main with commit e8b4a47 Jun 18, 2023
@eddyb eddyb deleted the print-names branch June 18, 2023 03:53
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.

1 participant