RESOLVED FIXED 59029
Reduce size of GraphicsContext3D's compiled code
https://bugs.webkit.org/show_bug.cgi?id=59029
Summary Reduce size of GraphicsContext3D's compiled code
Kenneth Russell
Reported 2011-04-20 15:41:13 PDT
GraphicsContext3D necessarily contains comprehensive image format conversion code in order to support all of the conversions that might be needed during texture uploading. Currently each format conversion is expressed as a function handling a single pixel, and these functions are passed as template parameters so they can be inlined. Unfortunately, this is causing excessive code bloat. In http://crbug.com/78976 thakis suggests making the conversion functions do their work line-by-line and passing them as function pointers instead of template parameters to reduce the code size.
Attachments
Patch (96.89 KB, patch)
2011-04-20 15:51 PDT, Kenneth Russell
jamesr: review+
kbr: commit-queue-
Kenneth Russell
Comment 1 2011-04-20 15:51:11 PDT
Zhenyao Mo
Comment 2 2011-04-20 16:06:19 PDT
LGTM.
James Robinson
Comment 3 2011-04-20 16:53:48 PDT
Comment on attachment 90430 [details] Patch Nifty. What's the before/after size of GraphicsContext3D.o ?
Nico Weber
Comment 4 2011-04-20 16:57:25 PDT
jamesr: See ChangeLog
Kenneth Russell
Comment 5 2011-04-20 17:28:29 PDT
James Robinson
Comment 6 2011-04-20 17:29:20 PDT
(In reply to comment #4) > jamesr: See ChangeLog Oh. I can reads good
Stephen White
Comment 7 2011-04-21 10:41:46 PDT
Comment on attachment 90430 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=90430&action=review > Source/WebCore/platform/graphics/GraphicsContext3D.cpp:373 > + destination[3] = convertColor16LittleTo8(source[3]); Not really related to this work, but if performance is a consideration, doing these conversions an int at a time (or least, using an int pointer for the destination doing a single store) is often much faster than doing char-by-char. SSE2+ would even better would be even better (but more work).
Nico Weber
Comment 8 2011-04-21 10:51:35 PDT
On the chrome bug I suggested jitting up the right conversion function, which is probably best wrt performance. But if anything needs to be color converted on the cpu on every frame, things won't be very fast anyhow.
Benoit Jacob
Comment 9 2011-08-02 08:54:02 PDT
Possibly related: http://code.google.com/p/chromium/issues/detail?id=91208#c7 As I explain there, I disagree with unstripped object file size as a metric for code bloat. Here, using `nm` tells me that the code generated by these templates is just 25k.
Note You need to log in before you can comment on or make changes to this bug.