Bug 89277 - [Texmap] Share gaussian formula between shaders in TextureMapperShaderManager.
Summary: [Texmap] Share gaussian formula between shaders in TextureMapperShaderManager.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-16 01:06 PDT by Dongseong Hwang
Modified: 2012-06-16 21:42 PDT (History)
2 users (show)

See Also:


Attachments
patch v.1 (12.09 KB, patch)
2012-06-16 01:08 PDT, Dongseong Hwang
noam: review-
noam: commit-queue-
Details | Formatted Diff | Diff
patch v.2 (12.74 KB, patch)
2012-06-16 19:17 PDT, Dongseong Hwang
noam: review+
noam: commit-queue-
Details | Formatted Diff | Diff
patch v.3 (12.71 KB, patch)
2012-06-16 20:25 PDT, Dongseong Hwang
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dongseong Hwang 2012-06-16 01:06:01 PDT
Remove "FIXME : share gaussian formula between shaders" in TextureMapperShaderManager.

Moreover, this patch can increase performance, because it calculates gaussian kernel only one time.
Comment 1 Dongseong Hwang 2012-06-16 01:08:09 PDT
Created attachment 147958 [details]
patch v.1
Comment 2 Dongseong Hwang 2012-06-16 01:09:59 PDT
Comment on attachment 147958 [details]
patch v.1

View in context: https://bugs.webkit.org/attachment.cgi?id=147958&action=review

> Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp:43
> +                              STRINGIFY_VAL(src)

It is needless, but I amended it for symmetric with FRAGMENT_SHADER.
Comment 3 Dongseong Hwang 2012-06-16 06:49:52 PDT
Comment on attachment 147958 [details]
patch v.1

View in context: https://bugs.webkit.org/attachment.cgi?id=147958&action=review

> Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp:46
> +                                STRINGIFY_VAL(src)

I add STRINGIFY_VAL in order to use macro in shader code, especially  GAUSSIAN_KERNEL_HALF_WIDTH and GAUSSIAN_KERNEL_STEP.
Comment 4 Noam Rosenthal 2012-06-16 07:03:14 PDT
Comment on attachment 147958 [details]
patch v.1

View in context: https://bugs.webkit.org/attachment.cgi?id=147958&action=review

> Source/WebCore/ChangeLog:8
> +        [Texmap] Share gaussian formula between shaders in TextureMapperShaderManager.
> +        https://bugs.webkit.org/show_bug.cgi?id=89277
> +
> +        Reviewed by NOBODY (OOPS!).
> +
> +        No new tests. This patch doesn't change behavior.

You're doing a lot more than that, actually moving to a more accurate gaussian blur...
I like that, but please describe in the Changelog.

> Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp:672
> +        }
> +        // Normalize the kernel

Extra line

> Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp:678
> +    }
> +    return kernel;

Extra line
Comment 5 Dongseong Hwang 2012-06-16 19:17:12 PDT
Created attachment 148000 [details]
patch v.2
Comment 6 Dongseong Hwang 2012-06-16 19:18:48 PDT
I'm glad because you like this. :)
Comment 7 Noam Rosenthal 2012-06-16 19:25:25 PDT
Comment on attachment 148000 [details]
patch v.2

View in context: https://bugs.webkit.org/attachment.cgi?id=148000&action=review

Awesome! Please fix nit-picks before committing.

> Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp:658
> +    return exp(- (x * x) / 2.f);

Remove space between - and (
Use 2. instead of 2.f

> Source/WebCore/platform/graphics/texmap/TextureMapperShaderManager.cpp:678
> +    if (!prepared) {
> +        kernel[0] = gauss(0);
> +        float sum = kernel[0];
> +        for (unsigned i = 1; i < GAUSSIAN_KERNEL_HALF_WIDTH; ++i) {
> +            kernel[i] = gauss(i * GAUSSIAN_KERNEL_STEP);
> +            sum += 2 * kernel[i];
> +        }
> +
> +        // Normalize the kernel
> +        float scale = 1 / sum;
> +        for (unsigned i = 0; i < GAUSSIAN_KERNEL_HALF_WIDTH; ++i)
> +            kernel[i] *= scale;
> +        prepared = true;
> +    }

Better to do 
if (prepared)
    return kernel;
Comment 8 Dongseong Hwang 2012-06-16 20:25:19 PDT
Created attachment 148004 [details]
patch v.3

Good advice.
Comment 9 WebKit Review Bot 2012-06-16 21:42:35 PDT
Comment on attachment 148004 [details]
patch v.3

Clearing flags on attachment: 148004

Committed r120545: <http://trac.webkit.org/changeset/120545>
Comment 10 WebKit Review Bot 2012-06-16 21:42:39 PDT
All reviewed patches have been landed.  Closing bug.