-
Notifications
You must be signed in to change notification settings - Fork 205
Try to fix clip optimization #1202
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -958,10 +958,11 @@ fn main( | |
| // main interpretation loop | ||
| while true { | ||
| let tag = ptcl[cmd_ix]; | ||
| if tag == CMD_END { | ||
| let cmd = tag & 0xFFu; | ||
| if cmd == CMD_END { | ||
| break; | ||
| } | ||
| switch tag { | ||
| switch cmd { | ||
| case CMD_FILL: { | ||
| let fill = read_fill(cmd_ix); | ||
| #ifdef msaa | ||
|
|
@@ -987,18 +988,23 @@ fn main( | |
| cmd_ix += 2u; | ||
| } | ||
| case CMD_BEGIN_CLIP: { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My vague plan for implementing this was to turn it into a whole new command, as the operations are at least a little different. I presume you didn't want to do that to avoid the code duplication? |
||
| let is_non_isolated = (tag & NON_ISOLATED_BLENDING_FLAG) != 0; | ||
| var rgba_mul = vec4(0.0); | ||
| if is_non_isolated { | ||
| rgba_mul = vec4(1.0); | ||
| } | ||
| if clip_depth < BLEND_STACK_SPLIT { | ||
| for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) { | ||
| blend_stack[clip_depth][i] = pack4x8unorm(rgba[i]); | ||
| rgba[i] = vec4(0.0); | ||
| } | ||
| rgba[i] *= rgba_mul; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're sure the backdrop isn't now double counted, even if it has alpha? I think that |
||
| } | ||
| } else { | ||
| let blend_in_scratch = clip_depth - BLEND_STACK_SPLIT; | ||
| let local_tile_ix = local_id.x * PIXELS_PER_THREAD + local_id.y * TILE_WIDTH; | ||
| let local_blend_start = blend_offset + blend_in_scratch * TILE_WIDTH * TILE_HEIGHT + local_tile_ix; | ||
| for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) { | ||
| blend_spill[local_blend_start + i] = pack4x8unorm(rgba[i]); | ||
| rgba[i] = vec4(0.0); | ||
| rgba[i] *= rgba_mul; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Obviously this is assuming that doing a floating point multiply is extremely cheap, right?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I presume that the multiply by one (or indeed by zero) can't cause rendering differences. Given that these are only colours, I can't see that it can. |
||
| } | ||
| } | ||
| clip_depth += 1u; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handy that this was available. Seeing what the blend mode was at "write begin clip" time was my greatest worry in implementing this (as in I was worried it would be annoying)