Changeset 113733 in webkit


Ignore:
Timestamp:
Apr 10, 2012, 10:25:01 AM (13 years ago)
Author:
zmo@google.com
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.
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r113727 r113733  
     12012-04-09  Zhenyao Mo  <zmo@google.com>
     2
     3        getShaderFormatPrecision should return sensible values
     4        https://bugs.webkit.org/show_bug.cgi?id=83520
     5
     6        Reviewed by Kenneth Russell.
     7
     8        * fast/canvas/webgl/shader-precision-format-expected.txt:
     9        * fast/canvas/webgl/shader-precision-format.html: Add tests to make sure getShaderPrecisionFormat returns sensible values.
     10
    1112012-04-10  Alexander Pavlov  <apavlov@chromium.org>
    212
  • trunk/LayoutTests/fast/canvas/webgl/shader-precision-format-expected.txt

    r113092 r113733  
    2525PASS gl.getShaderPrecisionFormat(gl.HIGH_INT, gl.VERTEX_SHADER) generated expected GL error: INVALID_ENUM.
    2626
     27Test that WebGLShaderPrecisionFormat values are sensible.
     28
     29PASS shaderPrecisionFormat.rangeMin >= 1 is true
     30PASS shaderPrecisionFormat.rangeMax >= 1 is true
     31PASS shaderPrecisionFormat.precision >= 8 is true
     32PASS shaderPrecisionFormat.rangeMin >= 14 is true
     33PASS shaderPrecisionFormat.rangeMax >= 14 is true
     34PASS shaderPrecisionFormat.precision >= 10 is true
     35PASS shaderPrecisionFormat.rangeMin >= 62 is true
     36PASS shaderPrecisionFormat.rangeMax >= 62 is true
     37PASS shaderPrecisionFormat.precision >= 16 is true
     38PASS shaderPrecisionFormat.rangeMin >= 8 is true
     39PASS shaderPrecisionFormat.rangeMax >= 8 is true
     40PASS shaderPrecisionFormat.precision == 0 is true
     41PASS shaderPrecisionFormat.rangeMin >= 10 is true
     42PASS shaderPrecisionFormat.rangeMax >= 10 is true
     43PASS shaderPrecisionFormat.precision == 0 is true
     44PASS shaderPrecisionFormat.rangeMin >= 16 is true
     45PASS shaderPrecisionFormat.rangeMax >= 16 is true
     46PASS shaderPrecisionFormat.precision == 0 is true
     47
    2748Test that getShaderPrecisionFormat returns the same thing every call.
    2849
  • trunk/LayoutTests/fast/canvas/webgl/shader-precision-format.html

    r113092 r113733  
    4949
    5050debug("");
     51debug("Test that WebGLShaderPrecisionFormat values are sensible.");
     52debug("");
     53
     54// The minimum values are from OpenGL ES Shading Language spec, section 4.5.
     55
     56var shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
     57shouldBeTrue('shaderPrecisionFormat.rangeMin >= 1');
     58shouldBeTrue('shaderPrecisionFormat.rangeMax >= 1');
     59shouldBeTrue('shaderPrecisionFormat.precision >= 8');
     60
     61shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT);
     62shouldBeTrue('shaderPrecisionFormat.rangeMin >= 14');
     63shouldBeTrue('shaderPrecisionFormat.rangeMax >= 14');
     64shouldBeTrue('shaderPrecisionFormat.precision >= 10');
     65
     66shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT);
     67shouldBeTrue('shaderPrecisionFormat.rangeMin >= 62');
     68shouldBeTrue('shaderPrecisionFormat.rangeMax >= 62');
     69shouldBeTrue('shaderPrecisionFormat.precision >= 16');
     70
     71shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_INT);
     72shouldBeTrue('shaderPrecisionFormat.rangeMin >= 8');
     73shouldBeTrue('shaderPrecisionFormat.rangeMax >= 8');
     74shouldBeTrue('shaderPrecisionFormat.precision == 0');
     75
     76shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_INT);
     77shouldBeTrue('shaderPrecisionFormat.rangeMin >= 10');
     78shouldBeTrue('shaderPrecisionFormat.rangeMax >= 10');
     79shouldBeTrue('shaderPrecisionFormat.precision == 0');
     80
     81shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_INT);
     82shouldBeTrue('shaderPrecisionFormat.rangeMin >= 16');
     83shouldBeTrue('shaderPrecisionFormat.rangeMax >= 16');
     84shouldBeTrue('shaderPrecisionFormat.precision == 0');
     85
     86debug("");
    5187debug("Test that getShaderPrecisionFormat returns the same thing every call.");
    5288debug("");
    5389
    54 var shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
     90shaderPrecisionFormat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
    5591var shaderPrecisionFormat2 = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
    5692shouldBeTrue('shaderPrecisionFormat.rangeMin == shaderPrecisionFormat2.rangeMin');
  • trunk/Source/WebCore/ChangeLog

    r113731 r113733  
     12012-04-09  Zhenyao Mo  <zmo@google.com>
     2
     3        getShaderFormatPrecision should return sensible values
     4        https://bugs.webkit.org/show_bug.cgi?id=83520
     5
     6        Reviewed by Kenneth Russell.
     7
     8        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: Fix getShaderPrecisionFormat values.
     9        (WebCore::GraphicsContext3D::getShaderPrecisionFormat):
     10        * platform/graphics/qt/GraphicsContext3DQt.cpp: Ditto.
     11        (WebCore::GraphicsContext3D::getShaderPrecisionFormat):
     12
    1132012-04-10  Alexander Pavlov  <apavlov@chromium.org>
    214
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp

    r113092 r113733  
    198198    makeContextCurrent();
    199199
    200     // These constants came from the Chromium port; we believe they originally
    201     // came from making the actual API call on a representative desktop system.
    202200    switch (precisionType) {
    203201    case GraphicsContext3D::LOW_INT:
    204202    case GraphicsContext3D::MEDIUM_INT:
    205203    case GraphicsContext3D::HIGH_INT:
    206         range[0] = -31;
    207         range[1] = 31;
     204        // These values are for a 32-bit twos-complement integer format.
     205        range[0] = 31;
     206        range[1] = 30;
    208207        precision[0] = 0;
    209208        break;
     
    211210    case GraphicsContext3D::MEDIUM_FLOAT:
    212211    case GraphicsContext3D::HIGH_FLOAT:
    213         range[0] = -62;
    214         range[1] = 62;
    215         precision[0] = -16;
     212        // These values are for an IEEE single-precision floating-point format.
     213        range[0] = 127;
     214        range[1] = 127;
     215        precision[0] = 23;
    216216        break;
    217217    default:
  • trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp

    r113123 r113733  
    13761376    makeContextCurrent();
    13771377
    1378     // These constants came from the Chromium port; we believe they originally
    1379     // came from making the actual API call on a representative desktop system.
    13801378    switch (precisionType) {
    13811379    case GraphicsContext3D::LOW_INT:
    13821380    case GraphicsContext3D::MEDIUM_INT:
    13831381    case GraphicsContext3D::HIGH_INT:
    1384         range[0] = -31;
    1385         range[1] = 31;
     1382        // These values are for a 32-bit twos-complement integer format.
     1383        range[0] = 31;
     1384        range[1] = 30;
    13861385        precision[0] = 0;
    13871386        break;
     
    13891388    case GraphicsContext3D::MEDIUM_FLOAT:
    13901389    case GraphicsContext3D::HIGH_FLOAT:
    1391         range[0] = -62;
    1392         range[1] = 62;
    1393         precision[0] = -16;
     1390        // These values are for an IEEE single-precision floating-point format.
     1391        range[0] = 127;
     1392        range[1] = 127;
     1393        precision[0] = 23;
    13941394        break;
    13951395    default:
Note: See TracChangeset for help on using the changeset viewer.