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: always print attributes inline and with per-attribute #[...] syntax. #35

Merged
merged 1 commit into from
Jun 13, 2023

Conversation

eddyb
Copy link
Contributor

@eddyb eddyb commented Jun 8, 2023

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
(click for complete pretty HTML example)
After
(click for complete pretty HTML example)
image image

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 eddyb marked this pull request as ready for review June 13, 2023 21:58
@eddyb eddyb added this pull request to the merge queue Jun 13, 2023
Merged via the queue into main with commit 7be6951 Jun 13, 2023
@eddyb eddyb deleted the print-attrs branch June 13, 2023 22:10
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