Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upProvide the Primitive screen bounds to shaders? #1828
Comments
|
Here's my summary of the issue:
|
|
The mask is already limited by the primitive boundaries, so maybe the right thing to do here is to simply not render any pixels outside of the mask bounds? |
|
Currently we support this situation by creating a an empty mask that clips to the screen boundaries of the clip chain. webrender/webrender/src/prim_store.rs Lines 1620 to 1637 in f1cecd7 We decided that this was a good tradeoff between quite of bit of added complexity in the shaders versus a very marginal performance improvement. Given that and the amount that the code has changed, perhaps it makes sense to close this bug and retake it if the performance of the current approach becomes an issue? |
|
That sounds good, thanks! |
While investigating #1814, I found the real reason
inner_recthad to be ignored in the #1820 workaround. Problem comes from the fact that our clipping is not in sync between Rust and GPU sides:prim_screen_rect, which is used for culling/visibility but not actually passed down to the shadersThe workaround in #1820 is one way to address this. The comment needs to be changed, however, since it reads as if there is something wrong with the inner rect. It is untrue - this rectangle is totally correct. What is incorrect is skipping the axis-aligned clips that were already taken into account into the primitive screen bound, given that the shader doesn't know about this.
Another approach would be to add a rectangle to
Primitivestruct on the shader side, and then clipdevice_pos(before multiplication by the device-pixel ratio, I suppose) against it inwrite_transform_vertexof the vertex shader.The performance costs are:
PrimitiveGeometry- this may be concerning. I wonder if we can make it compile-time conditional based on the TRANSFORM define, in which case we should be safe.The benefit is: