- Revision
- 126342
- Author
- [email protected]
- Date
- 2012-08-22 13:14:08 -0700 (Wed, 22 Aug 2012)
Log 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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (126341 => 126342)
--- trunk/Source/WebCore/ChangeLog 2012-08-22 19:55:34 UTC (rev 126341)
+++ trunk/Source/WebCore/ChangeLog 2012-08-22 20:14:08 UTC (rev 126342)
@@ -1,3 +1,34 @@
+2012-08-22 Dean Jackson <[email protected]>
+
+ [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.
+
2012-08-22 Tommy Widenflycht <[email protected]>
[chromium] MediaStream API: Add MockWebRTCPeerConnectionHandler
Modified: trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp (126341 => 126342)
--- trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp 2012-08-22 19:55:34 UTC (rev 126341)
+++ trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.cpp 2012-08-22 20:14:08 UTC (rev 126342)
@@ -66,7 +66,7 @@
m_resources = resources;
}
-bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog)
+bool ANGLEWebKitBridge::validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog, int extraCompileOptions)
{
if (!builtCompilers) {
m_fragmentCompiler = ShConstructCompiler(SH_FRAGMENT_SHADER, SH_WEBGL_SPEC, m_shaderOutput, &m_resources);
@@ -88,7 +88,7 @@
const char* const shaderSourceStrings[] = { shaderSource };
- bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, SH_OBJECT_CODE);
+ bool validateSuccess = ShCompile(compiler, shaderSourceStrings, 1, SH_OBJECT_CODE | extraCompileOptions);
if (!validateSuccess) {
int logSize = 0;
ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &logSize);
Modified: trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h (126341 => 126342)
--- trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h 2012-08-22 19:55:34 UTC (rev 126341)
+++ trunk/Source/WebCore/platform/graphics/ANGLEWebKitBridge.h 2012-08-22 20:14:08 UTC (rev 126342)
@@ -53,7 +53,7 @@
ShBuiltInResources getResources() { return m_resources; }
void setResources(ShBuiltInResources);
- bool validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog);
+ bool validateShaderSource(const char* shaderSource, ANGLEShaderType shaderType, String& translatedShaderSource, String& shaderValidationLog, int extraCompileOptions);
private:
Modified: trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp (126341 => 126342)
--- trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp 2012-08-22 19:55:34 UTC (rev 126341)
+++ trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp 2012-08-22 20:14:08 UTC (rev 126342)
@@ -121,9 +121,16 @@
String translatedShaderSource;
String shaderInfoLog;
+ int extraCompileOptions = 0;
- bool isValid = compiler.validateShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog);
+#if PLATFORM(MAC)
+ const char* vendor = reinterpret_cast<const char*>(::glGetString(GL_VENDOR));
+ if (vendor && (std::strstr(vendor, "ATI") || std::strstr(vendor, "AMD")))
+ extraCompileOptions |= SH_EMULATE_BUILT_IN_FUNCTIONS;
+#endif
+ bool isValid = compiler.validateShaderSource(entry.source.utf8().data(), shaderType, translatedShaderSource, shaderInfoLog, extraCompileOptions);
+
entry.log = shaderInfoLog;
entry.isValid = isValid;