Changeset 141706 in webkit


Ignore:
Timestamp:
Feb 2, 2013 2:32:34 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Optimize some operations for float type in texture format conversions of WebGL
https://bugs.webkit.org/show_bug.cgi?id=107526

Patch by Jun Jiang <jun.a.jiang@intel.com> on 2013-02-02
Reviewed by Darin Adler.

Some small changes are made to optimize the operations for float type in the texture format conversion of WebGL to improve performance.

Already covered by current tests.

  • platform/graphics/GraphicsContext3D.cpp:

(WebCore):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r141704 r141706  
     12013-02-02  Jun Jiang  <jun.a.jiang@intel.com>
     2
     3        Optimize some operations for float type in texture format conversions of WebGL
     4        https://bugs.webkit.org/show_bug.cgi?id=107526
     5
     6        Reviewed by Darin Adler.
     7
     8        Some small changes are made to optimize the operations for float type in the texture format conversion of WebGL to improve performance.
     9
     10        Already covered by current tests.
     11
     12        * platform/graphics/GraphicsContext3D.cpp:
     13        (WebCore):
     14
    1152013-02-02  Simon Fraser  <simon.fraser@apple.com>
    216
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3D.cpp

    r140497 r141706  
    825825{
    826826    for (unsigned int i = 0; i < pixelsPerRow; ++i) {
    827         float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
     827        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
    828828        uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
    829829        destination[0] = sourceR;
     
    859859{
    860860    for (unsigned int i = 0; i < pixelsPerRow; ++i) {
    861         float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
     861        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
    862862        uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
    863863        destination[0] = sourceR;
     
    898898{
    899899    for (unsigned int i = 0; i < pixelsPerRow; ++i) {
    900         float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
     900        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
    901901        uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
    902902        uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor);
     
    936936{
    937937    for (unsigned int i = 0; i < pixelsPerRow; ++i) {
    938         float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
     938        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
    939939        uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
    940940        uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor);
     
    984984{
    985985    for (unsigned int i = 0; i < pixelsPerRow; ++i) {
    986         float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
     986        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
    987987        uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
    988988        uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor);
     
    10321032{
    10331033    for (unsigned int i = 0; i < pixelsPerRow; ++i) {
    1034         float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
     1034        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
    10351035        uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
    10361036        uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor);
     
    10781078{
    10791079    for (unsigned int i = 0; i < pixelsPerRow; ++i) {
    1080         float scaleFactor = 1.0f / (source[3] ? source[3] / 255.0f : 1.0f);
     1080        float scaleFactor = source[3] ? 255.0f / source[3] : 1.0f;
    10811081        uint8_t sourceR = static_cast<uint8_t>(static_cast<float>(source[0]) * scaleFactor);
    10821082        uint8_t sourceG = static_cast<uint8_t>(static_cast<float>(source[1]) * scaleFactor);
     
    11281128template<> ALWAYS_INLINE void pack<GraphicsContext3D::DataFormatRGBA32F, GraphicsContext3D::AlphaDoNothing, float, float>(const float* source, float* destination, unsigned pixelsPerRow)
    11291129{
    1130     for (unsigned int i = 0; i < pixelsPerRow; ++i) {
    1131         destination[0] = source[0];
    1132         destination[1] = source[1];
    1133         destination[2] = source[2];
    1134         destination[3] = source[3];
    1135         source += 4;
    1136         destination += 4;
    1137     }
     1130    memcpy(destination, source, pixelsPerRow * 4 * sizeof(float));
    11381131}
    11391132
Note: See TracChangeset for help on using the changeset viewer.