Bug 244564

Summary: TextureMapper: Calculate zFar and zNear for the projection matrix
Product: WebKit Reporter: Fujii Hironori <fujii.hironori>
Component: PlatformAssignee: Fujii Hironori <fujii.hironori>
Status: RESOLVED FIXED    
Severity: Normal CC: cmarcelo, darin, don.olmstead, ews-watchlist, kondapallykalyan, luiz, magomez, webkit-bug-importer, zdobersek
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
test case of w<0
none
Patch
none
Patch
none
[fast-cq] Patch for landing none

Fujii Hironori
Reported 2022-08-30 19:45:52 PDT
TextureMapper: Calculate zFar and zNear for the projection matrix This is blocking bug#244526 comment#2.
Attachments
Patch (9.84 KB, patch)
2022-08-30 19:52 PDT, Fujii Hironori
no flags
Patch (9.83 KB, patch)
2022-08-31 23:40 PDT, Fujii Hironori
no flags
Patch (9.56 KB, patch)
2022-08-31 23:46 PDT, Fujii Hironori
no flags
test case of w<0 (472 bytes, text/html)
2022-09-01 23:52 PDT, Fujii Hironori
no flags
Patch (10.00 KB, patch)
2022-09-02 00:05 PDT, Fujii Hironori
no flags
Patch (11.17 KB, patch)
2022-09-02 00:42 PDT, Fujii Hironori
no flags
[fast-cq] Patch for landing (10.18 KB, patch)
2022-09-26 22:55 PDT, Fujii Hironori
no flags
Fujii Hironori
Comment 1 2022-08-30 19:52:55 PDT
Darin Adler
Comment 2 2022-08-31 10:56:47 PDT
Comment on attachment 462019 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=462019&action=review > Source/WebCore/platform/graphics/texmap/TextureMapper.h:86 > + virtual void setDepthRange(float, float) { } Need argument names here. It’s not obvious what the two floats are. This class is mixing float with double. TransformationMatrix uses double, but we also use FloatRect and FloatPoint. It’s not obvious to me what would be best. > Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:872 > +static inline TransformationMatrix createProjectionMatrix(const IntSize& size, bool mirrored, float zNear, float zFar) Here we are converting floats to doubles when we put the results of our expression into a TransformationMatrix object. Maybe they should just be doubles from the start? I am not sure this mix of doubles and floats in the existing code is OK. I’d like to see tests that cover this somehow in the future. > Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h:38 > +struct TextureMapperComputeTransformData; I think this struct should be a member of the TextureMapperLayer class. It’s an implementation detail. I suggest naming it TextureMapperLayer::ComputeTransformsData.
Fujii Hironori
Comment 3 2022-08-31 23:35:14 PDT
Comment on attachment 462019 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=462019&action=review >> Source/WebCore/platform/graphics/texmap/TextureMapper.h:86 >> + virtual void setDepthRange(float, float) { } > > Need argument names here. It’s not obvious what the two floats are. > > This class is mixing float with double. TransformationMatrix uses double, but we also use FloatRect and FloatPoint. It’s not obvious to me what would be best. Will add argument names. WebCore is heavily depending on float values, and mixing floats and doubles. I don't think it's a problem to use float here. >> Source/WebCore/platform/graphics/texmap/TextureMapperGL.cpp:872 >> +static inline TransformationMatrix createProjectionMatrix(const IntSize& size, bool mirrored, float zNear, float zFar) > > Here we are converting floats to doubles when we put the results of our expression into a TransformationMatrix object. Maybe they should just be doubles from the start? I am not sure this mix of doubles and floats in the existing code is OK. > > I’d like to see tests that cover this somehow in the future. Those values come from TransformationMatrix::mapPoint. It inputs FloatPoint3D and outputs FloatPoint3D. FloatPoint3D TransformationMatrix::mapPoint(const FloatPoint3D&) I want the double version of FloatPoint3D, and TransformationMatrix::mapPoint should take it. >> Source/WebCore/platform/graphics/texmap/TextureMapperLayer.h:38 >> +struct TextureMapperComputeTransformData; > > I think this struct should be a member of the TextureMapperLayer class. It’s an implementation detail. I suggest naming it TextureMapperLayer::ComputeTransformsData. Will fix.
Fujii Hironori
Comment 4 2022-08-31 23:40:00 PDT
Fujii Hironori
Comment 5 2022-08-31 23:46:45 PDT
Fujii Hironori
Comment 6 2022-09-01 00:36:47 PDT
Fujii Hironori
Comment 7 2022-09-01 23:52:19 PDT
Created attachment 462089 [details] test case of w<0 In the test case, the perspective is 500px, and the part of the element is placed at z>500px. Then, w <= 0. It's beyond the infinity.
Fujii Hironori
Comment 8 2022-09-02 00:05:54 PDT
Fujii Hironori
Comment 9 2022-09-02 00:22:58 PDT
This patch introduces new warnings. /app/webkit/Source/WebCore/platform/graphics/texmap/TextureMapper.h:86:39: warning: unused parameter ‘zNear’ [-Wunused-parameter] /app/webkit/Source/WebCore/platform/graphics/texmap/TextureMapper.h:86:53: warning: unused parameter ‘zFar’ [-Wunused-parameter]
Fujii Hironori
Comment 10 2022-09-02 00:42:43 PDT
Fujii Hironori
Comment 11 2022-09-02 03:49:20 PDT
Comment on attachment 462091 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=462091&action=review > Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp:136 > + return std::numeric_limits<double>::max(); It should be possible to calculate zfar and znear more precisely by intersecting with the surface rect.
Radar WebKit Bug Importer
Comment 12 2022-09-06 21:00:25 PDT
Fujii Hironori
Comment 13 2022-09-26 22:55:40 PDT
Created attachment 462648 [details] [fast-cq] Patch for landing
EWS
Comment 14 2022-09-26 22:59:35 PDT
Committed 254897@main (922f8f09f0ca): <https://commits.webkit.org/254897@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 462648 [details].
Note You need to log in before you can comment on or make changes to this bug.