Title: [113733] trunk
Revision
113733
Author
z...@google.com
Date
2012-04-10 10:25:01 -0700 (Tue, 10 Apr 2012)

Log Message

getShaderFormatPrecision should return sensible values
https://bugs.webkit.org/show_bug.cgi?id=83520

Reviewed by Kenneth Russell.

Source/WebCore: 

* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: Fix getShaderPrecisionFormat values.
(WebCore::GraphicsContext3D::getShaderPrecisionFormat):
* platform/graphics/qt/GraphicsContext3DQt.cpp: Ditto.
(WebCore::GraphicsContext3D::getShaderPrecisionFormat):

LayoutTests: 

* fast/canvas/webgl/shader-precision-format-expected.txt:
* fast/canvas/webgl/shader-precision-format.html: Add tests to make sure getShaderPrecisionFormat returns sensible values.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (113732 => 113733)


--- trunk/LayoutTests/ChangeLog	2012-04-10 17:20:32 UTC (rev 113732)
+++ trunk/LayoutTests/ChangeLog	2012-04-10 17:25:01 UTC (rev 113733)
@@ -1,3 +1,13 @@
+2012-04-09  Zhenyao Mo  <z...@google.com>
+
+        getShaderFormatPrecision should return sensible values
+        https://bugs.webkit.org/show_bug.cgi?id=83520
+
+        Reviewed by Kenneth Russell.
+
+        * fast/canvas/webgl/shader-precision-format-expected.txt:
+        * fast/canvas/webgl/shader-precision-format.html: Add tests to make sure getShaderPrecisionFormat returns sensible values.
+
 2012-04-10  Alexander Pavlov  <apav...@chromium.org>
 
         [Chromium] Unreviewed, add baselines for fast/dom/shadow/selection-in-shadow.html

Modified: trunk/LayoutTests/fast/canvas/webgl/shader-precision-format-expected.txt (113732 => 113733)


--- trunk/LayoutTests/fast/canvas/webgl/shader-precision-format-expected.txt	2012-04-10 17:20:32 UTC (rev 113732)
+++ trunk/LayoutTests/fast/canvas/webgl/shader-precision-format-expected.txt	2012-04-10 17:25:01 UTC (rev 113733)
@@ -24,6 +24,27 @@
 
 PASS gl.getShaderPrecisionFormat(gl.HIGH_INT, gl.VERTEX_SHADER) generated expected GL error: INVALID_ENUM.
 
+Test that WebGLShaderPrecisionFormat values are sensible.
+
+PASS shaderPrecisionFormat.rangeMin >= 1 is true
+PASS shaderPrecisionFormat.rangeMax >= 1 is true
+PASS shaderPrecisionFormat.precision >= 8 is true
+PASS shaderPrecisionFormat.rangeMin >= 14 is true
+PASS shaderPrecisionFormat.rangeMax >= 14 is true
+PASS shaderPrecisionFormat.precision >= 10 is true
+PASS shaderPrecisionFormat.rangeMin >= 62 is true
+PASS shaderPrecisionFormat.rangeMax >= 62 is true
+PASS shaderPrecisionFormat.precision >= 16 is true
+PASS shaderPrecisionFormat.rangeMin >= 8 is true
+PASS shaderPrecisionFormat.rangeMax >= 8 is true
+PASS shaderPrecisionFormat.precision == 0 is true
+PASS shaderPrecisionFormat.rangeMin >= 10 is true
+PASS shaderPrecisionFormat.rangeMax >= 10 is true
+PASS shaderPrecisionFormat.precision == 0 is true
+PASS shaderPrecisionFormat.rangeMin >= 16 is true
+PASS shaderPrecisionFormat.rangeMax >= 16 is true
+PASS shaderPrecisionFormat.precision == 0 is true
+
 Test that getShaderPrecisionFormat returns the same thing every call.
 
 PASS shaderPrecisionFormat.rangeMin == shaderPrecisionFormat2.rangeMin is true

Modified: trunk/LayoutTests/fast/canvas/webgl/shader-precision-format.html (113732 => 113733)


--- trunk/LayoutTests/fast/canvas/webgl/shader-precision-format.html	2012-04-10 17:20:32 UTC (rev 113732)
+++ trunk/LayoutTests/fast/canvas/webgl/shader-precision-format.html	2012-04-10 17:25:01 UTC (rev 113733)
@@ -48,10 +48,46 @@
 shouldGenerateGLError(gl, gl.INVALID_ENUM, 'gl.getShaderPrecisionFormat(gl.HIGH_INT, gl.VERTEX_SHADER)');
 
 debug("");
+debug("Test that WebGLShaderPrecisionFormat values are sensible.");
+debug("");
+
+// The minimum values are from OpenGL ES Shading Language spec, section 4.5.
+
+var shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
+shouldBeTrue('shaderPrecisionFormat.rangeMin >= 1');
+shouldBeTrue('shaderPrecisionFormat.rangeMax >= 1');
+shouldBeTrue('shaderPrecisionFormat.precision >= 8');
+
+shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT);
+shouldBeTrue('shaderPrecisionFormat.rangeMin >= 14');
+shouldBeTrue('shaderPrecisionFormat.rangeMax >= 14');
+shouldBeTrue('shaderPrecisionFormat.precision >= 10');
+
+shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT);
+shouldBeTrue('shaderPrecisionFormat.rangeMin >= 62');
+shouldBeTrue('shaderPrecisionFormat.rangeMax >= 62');
+shouldBeTrue('shaderPrecisionFormat.precision >= 16');
+
+shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_INT);
+shouldBeTrue('shaderPrecisionFormat.rangeMin >= 8');
+shouldBeTrue('shaderPrecisionFormat.rangeMax >= 8');
+shouldBeTrue('shaderPrecisionFormat.precision == 0');
+
+shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_INT);
+shouldBeTrue('shaderPrecisionFormat.rangeMin >= 10');
+shouldBeTrue('shaderPrecisionFormat.rangeMax >= 10');
+shouldBeTrue('shaderPrecisionFormat.precision == 0');
+
+shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_INT);
+shouldBeTrue('shaderPrecisionFormat.rangeMin >= 16');
+shouldBeTrue('shaderPrecisionFormat.rangeMax >= 16');
+shouldBeTrue('shaderPrecisionFormat.precision == 0');
+
+debug("");
 debug("Test that getShaderPrecisionFormat returns the same thing every call.");
 debug("");
 
-var shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
+shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
 var shaderPrecisionFormat2 = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
 shouldBeTrue('shaderPrecisionFormat.rangeMin == shaderPrecisionFormat2.rangeMin');
 shouldBeTrue('shaderPrecisionFormat.rangeMax == shaderPrecisionFormat2.rangeMax');

Modified: trunk/Source/WebCore/ChangeLog (113732 => 113733)


--- trunk/Source/WebCore/ChangeLog	2012-04-10 17:20:32 UTC (rev 113732)
+++ trunk/Source/WebCore/ChangeLog	2012-04-10 17:25:01 UTC (rev 113733)
@@ -1,3 +1,15 @@
+2012-04-09  Zhenyao Mo  <z...@google.com>
+
+        getShaderFormatPrecision should return sensible values
+        https://bugs.webkit.org/show_bug.cgi?id=83520
+
+        Reviewed by Kenneth Russell.
+
+        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: Fix getShaderPrecisionFormat values.
+        (WebCore::GraphicsContext3D::getShaderPrecisionFormat):
+        * platform/graphics/qt/GraphicsContext3DQt.cpp: Ditto.
+        (WebCore::GraphicsContext3D::getShaderPrecisionFormat):
+
 2012-04-10  Alexander Pavlov  <apav...@chromium.org>
 
         Web Inspector: Add Galaxy Nexus to the list of emulated user agents

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp (113732 => 113733)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp	2012-04-10 17:20:32 UTC (rev 113732)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp	2012-04-10 17:25:01 UTC (rev 113733)
@@ -197,22 +197,22 @@
 
     makeContextCurrent();
 
-    // These constants came from the Chromium port; we believe they originally
-    // came from making the actual API call on a representative desktop system.
     switch (precisionType) {
     case GraphicsContext3D::LOW_INT:
     case GraphicsContext3D::MEDIUM_INT:
     case GraphicsContext3D::HIGH_INT:
-        range[0] = -31;
-        range[1] = 31;
+        // These values are for a 32-bit twos-complement integer format.
+        range[0] = 31;
+        range[1] = 30;
         precision[0] = 0;
         break;
     case GraphicsContext3D::LOW_FLOAT:
     case GraphicsContext3D::MEDIUM_FLOAT:
     case GraphicsContext3D::HIGH_FLOAT:
-        range[0] = -62;
-        range[1] = 62;
-        precision[0] = -16;
+        // These values are for an IEEE single-precision floating-point format.
+        range[0] = 127;
+        range[1] = 127;
+        precision[0] = 23;
         break;
     default:
         ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp (113732 => 113733)


--- trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp	2012-04-10 17:20:32 UTC (rev 113732)
+++ trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp	2012-04-10 17:25:01 UTC (rev 113733)
@@ -1375,22 +1375,22 @@
 
     makeContextCurrent();
 
-    // These constants came from the Chromium port; we believe they originally
-    // came from making the actual API call on a representative desktop system.
     switch (precisionType) {
     case GraphicsContext3D::LOW_INT:
     case GraphicsContext3D::MEDIUM_INT:
     case GraphicsContext3D::HIGH_INT:
-        range[0] = -31;
-        range[1] = 31;
+        // These values are for a 32-bit twos-complement integer format.
+        range[0] = 31;
+        range[1] = 30;
         precision[0] = 0;
         break;
     case GraphicsContext3D::LOW_FLOAT:
     case GraphicsContext3D::MEDIUM_FLOAT:
     case GraphicsContext3D::HIGH_FLOAT:
-        range[0] = -62;
-        range[1] = 62;
-        precision[0] = -16;
+        // These values are for an IEEE single-precision floating-point format.
+        range[0] = 127;
+        range[1] = 127;
+        precision[0] = 23;
         break;
     default:
         ASSERT_NOT_REACHED();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to