WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
284250
[TextureMapper] Preserve 3d may split layers unnecessarily when they don't intersect
https://bugs.webkit.org/show_bug.cgi?id=284250
Summary
[TextureMapper] Preserve 3d may split layers unnecessarily when they don't in...
Jani Hautakangas
Reported
2024-12-08 13:43:11 PST
The BSP (Binary Space Partitioning) calculation in the TextureMapper uses the 3D plane formula to determine layer ordering and splits layer primitives into two parts if they intersect. The implementation creates a plane formula for the layer polygon and checks if other layers intersect this plane. Since the plane spans infinitely across the entire scene, it may detect intersections of layers that are spatially distant from the tested layer polygon. This leads to incorrect splitting of layers, even when they don't physically intersect. To mitigate this issue, a preprocessing step using bounding volumes can be introduced before creating the BSP tree. This step would limit the calculation to only potentially intersecting volumes, improving accuracy and reducing unnecessary splits.
Attachments
WIP patch
(11.27 KB, patch)
2024-12-09 07:03 PST
,
Jani Hautakangas
no flags
Details
Formatted Diff
Diff
Overlap test case
(1.87 KB, text/html)
2024-12-12 20:39 PST
,
Jani Hautakangas
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Jani Hautakangas
Comment 1
2024-12-09 07:03:09 PST
Created
attachment 473511
[details]
WIP patch
Jani Hautakangas
Comment 2
2024-12-09 07:03:19 PST
This change shows only marginal improvement on specific tests and does not significantly address the issues highlighted in
Bug 283820
. I have decided to set this aside for now and redirect my efforts toward
Bug 284279
. For reference, a WIP patch is attached.
Fujii Hironori
Comment 3
2024-12-09 12:44:53 PST
poster-circle has no intersecting layers. I think no needs to use stencil clipping if we can precisely compute intersecting layers and sort layers correctly.
https://webkit.org/blog-files/3d-transforms/poster-circle.html
Jani Hautakangas
Comment 4
2024-12-10 03:00:28 PST
That's correct, the layers in the poster-circle example don’t actually intersect. The intersections arise from how the BSP tree splits the scene rather than from the layers themselves. I’ve tried to refine the BSP splitting logic, but ultimately the BSP tree must be constructed using splitting planes, so there’s limited flexibility there. In my WIP patch, I attempted using axis-aligned bounding boxes (AABBs) to detect collisions and pre-sort layers before entering the BSP phase. AABBs are computationally fast but they don’t yield correct results in this scenario because the poster-circle scene rotates and undergoes perspective transformations thus invalidating the assumptions AABBs rely on. Another approach might be oriented bounding boxes (OBBs), which would be more accurate but also significantly more expensive to compute. I’m still planning to explore that option to see how it performs on RPi3. The underlying cause of the regression (issue 283820) is that stencil usage on the RPi3 is very slow, whereas on many other platforms stencil operations are much faster. The ultimate fix for this is 284279. Skia includes a fast path that checks at runtime whether it can achieve clipping by rendering only a portion of the target when the clip is simple enough. Unfortunately, implementing a similar strategy in TextureMapper is challenging. TextureMapper was designed from the ground up with the assumption of rectangular rendering, making more advanced clipping techniques difficult to integrate without stencil usage.
Jani Hautakangas
Comment 5
2024-12-12 20:38:03 PST
I have OBB collision/intersection detection now in place and it resolves poster-circle regression. However, there's a regression. In certain scenarios, multiple layers appear to overlap from the viewer’s perspective, creating a situation where none of them are clearly frontmost. Even though no actual 3D intersection occurs in these cases, layers still need to be split to maintain correct visual ordering. When using 3d collision detection to filter out non-colliding layers, these purely visual overlap scenarios fail to render correctly. Although I was aware of these situations, I didn’t fully recognize until now that 3D intersection detection alone does not handle them. Attached an example.
Jani Hautakangas
Comment 6
2024-12-12 20:39:16 PST
Created
attachment 473558
[details]
Overlap test case
Nikolas Zimmermann
Comment 7
2024-12-13 00:42:13 PST
That sounds promising Jani -- do you have ideas left how to fix the remaining regression with the solve-poster-circle-regression-patch?
Jani Hautakangas
Comment 8
2024-12-13 01:04:13 PST
I have a few ideas in mind, and I’ll start experimenting with them now. I’ve had limited time recently, but I’ll be able to devote more time on this now.
Jani Hautakangas
Comment 9
2024-12-16 15:07:52 PST
Pull request:
https://github.com/WebKit/WebKit/pull/38039
EWS
Comment 10
2024-12-19 01:08:35 PST
Committed
288080@main
(ca6c3486ddd3): <
https://commits.webkit.org/288080@main
> Reviewed commits have been landed. Closing PR #38039 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug