Changeset 126342 in webkit


Ignore:
Timestamp:
Aug 22, 2012 1:14:08 PM (12 years ago)
Author:
dino@apple.com
Message:

[WebGL] Mac/ATI/AMD systems need to translate built-in GLSL functions
https://bugs.webkit.org/show_bug.cgi?id=94030

Reviewed by Tim Horton.

ATI/AMD GPUs on Apple platforms do not give correct values for some of
the built-in GLSL functions. Add a compile flag that is passed to ANGLE
so that, with this configuration, it will rewrite the shader to emulate
the function in code.

This is exposing some design weaknesses in the way we call ANGLE. We'll
soon need to add more compiler flags; Future bugs will likely clean
this code up. But this approach is satisfactory for the moment.

This change is tested by the Khronos WebGL conformance test suite, in particular:
conformance/glsl/functions/glsl-function-distance.html
conformance/glsl/functions/glsl-function-dot.html
conformance/glsl/functions/glsl-function-length.html

  • platform/graphics/ANGLEWebKitBridge.cpp:

(WebCore::ANGLEWebKitBridge::validateShaderSource): Test for ATI cards
on the Mac platform, and pass in an extra flag to the translation step.

  • platform/graphics/ANGLEWebKitBridge.h:

(ANGLEWebKitBridge): Add a new parameter to getTranslatedShaderSourceANGLE
that accepts some extra options to pass to ANGLE.

  • platform/graphics/opengl/Extensions3DOpenGLCommon.cpp:

(WebCore::Extensions3DOpenGLCommon::getTranslatedShaderSourceANGLE): Pass
the extra options into ANGLE's compile function.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r126341 r126342  
     12012-08-22  Dean Jackson  <dino@apple.com>
     2
     3        [WebGL] Mac/ATI/AMD systems need to translate built-in GLSL functions
     4        https://bugs.webkit.org/show_bug.cgi?id=94030
     5
     6        Reviewed by Tim Horton.
     7
     8        ATI/AMD GPUs on Apple platforms do not give correct values for some of
     9        the built-in GLSL functions. Add a compile flag that is passed to ANGLE
     10        so that, with this configuration, it will rewrite the shader to emulate
     11        the function in code.
     12
     13        This is exposing some design weaknesses in the way we call ANGLE. We'll
     14        soon need to add more compiler flags; Future bugs will likely clean
     15        this code up. But this approach is satisfactory for the moment.
     16
     17        This change is tested by the Khronos WebGL conformance test suite, in particular:
     18        conformance/glsl/functions/glsl-function-distance.html
     19        conformance/glsl/functions/glsl-function-dot.html
     20        conformance/glsl/functions/glsl-function-length.html
     21
     22        * platform/graphics/ANGLEWebKitBridge.cpp:
     23        (WebCore::ANGLEWebKitBridge::validateShaderSource): Test for ATI cards
     24        on the Mac platform, and pass in an extra flag to the translation step.
     25        * platform/graphics/ANGLEWebKitBridge.h:
     26        (ANGLEWebKitBridge): Add a new parameter to getTranslatedShaderSourceANGLE
     27        that accepts some extra options to pass to ANGLE.
     28        * platform/graphics/opengl/Extensions3DOpenGLCommon.cpp:
     29        (WebCore::Extensions3DOpenGLCommon::getTranslatedShaderSourceANGLE): Pass
     30        the extra options into ANGLE's compile function.
     31
    1322012-08-22  Tommy Widenflycht  <tommyw@google.com>
    233
  • trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp

    r122175 r126342  
    6767}
    6868
    69 bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog)
     69bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog, int extraCompileOptions)
    7070{
    7171    if (!builtCompilers) {
     
    8989    const char* const shaderSourceStrings[] = { shaderSource };
    9090
    91     bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, SH_OBJECT_CODE);
     91    bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, SH_OBJECT_CODE | extraCompileOptions);
    9292    if (!validateSuccess) {
    9393        int logSize = 0;
  • trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h

    r121259 r126342  
    5454    void setResources(ShBuiltInResources);
    5555   
    56     bool validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog);
     56    bool validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog, int extraCompileOptions);
    5757
    5858private:
  • trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp

    r125349 r126342  
    122122    String translatedShaderSource;
    123123    String shaderInfoLog;
     124    int extraCompileOptions = 0;
    124125
    125     bool isValid = compiler.validateShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog);
     126#if PLATFORM(MAC)
     127    const char* vendor = reinterpret_cast<const char*>(::glGetString(GL_VENDOR));
     128    if (vendor && (std::strstr(vendor, "ATI") || std::strstr(vendor, "AMD")))
     129        extraCompileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS;
     130#endif
     131
     132    bool isValid = compiler.validateShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog, extraCompileOptions);
    126133
    127134    entry.log = shaderInfoLog;
Note: See TracChangeset for help on using the changeset viewer.