Changeset 265317 in webkit


Ignore:
Timestamp:
Aug 5, 2020 6:58:09 PM (4 years ago)
Author:
commit-queue@webkit.org
Message:

[WebGL2] Upgrade vertexAttribPointer with new supported types
https://bugs.webkit.org/show_bug.cgi?id=215036

Patch by James Darpinian <James Darpinian> on 2020-08-05
Reviewed by Dean Jackson.

Tested by updated WebGL conformance tests webgl/2.0.0/conformance/attribs/gl-vertexattribpointer-offsets.html and webgl/2.0.0/conformance/attribs/gl-vertexattribpointer.html

  • html/canvas/WebGLRenderingContextBase.cpp:

(WebCore::WebGLRenderingContextBase::sizeInBytes):
(WebCore::WebGLRenderingContextBase::vertexAttribPointer):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/webgl/2.0.0/resources/webgl_test_files/conformance/attribs/gl-vertexattribpointer-offsets.html

    r232783 r265317  
    11<!--
    2 
    3 /*
    4 ** Copyright (c) 2012 The Khronos Group Inc.
    5 **
    6 ** Permission is hereby granted, free of charge, to any person obtaining a
    7 ** copy of this software and/or associated documentation files (the
    8 ** "Materials"), to deal in the Materials without restriction, including
    9 ** without limitation the rights to use, copy, modify, merge, publish,
    10 ** distribute, sublicense, and/or sell copies of the Materials, and to
    11 ** permit persons to whom the Materials are furnished to do so, subject to
    12 ** the following conditions:
    13 **
    14 ** The above copyright notice and this permission notice shall be included
    15 ** in all copies or substantial portions of the Materials.
    16 **
    17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
    24 */
    25 
     2Copyright (c) 2019 The Khronos Group Inc.
     3Use of this source code is governed by an MIT-style license that can be
     4found in the LICENSE.txt file.
    265-->
    276
     
    7453                normalize: false,
    7554              },
    76               { data: new Float32Array([ 0, 1, 0, 1, 0, 0, 0, 0, 0 ]),
    77                 type: gl.FLOAT,
    78                 componentSize: 4,
    79                 normalize: false,
    80               },
    81               { data: new Uint16Array([ 0, 32767, 0, 32767, 0, 0, 0, 0, 0 ]),
     55              { data: new Uint16Array([ 0, 32767, 0, 32767, 0, 0, 0, 0, 0]),
    8256                type: gl.SHORT,
    8357                componentSize: 2,
     
    12094              }
    12195            ];
     96
     97            if (wtu.getDefault3DContextVersion() >= 2) {
     98              tests.push(...[
     99                  { data: new Int32Array([ 0, 1, 0, 1, 0, 0, 0, 0, 0]),
     100                    type: gl.INT,
     101                    componentSize: 4,
     102                    normalize: false,
     103                  },
     104                  { data: new Int32Array([ 0, 2147483647, 0, 2147483647, 0, 0, 0, 0, 0]),
     105                    type: gl.INT,
     106                    componentSize: 4,
     107                    normalize: true,
     108                  },
     109                  { data: new Uint32Array([ 0, 1, 0, 1, 0, 0, 0, 0, 0]),
     110                    type: gl.UNSIGNED_INT,
     111                    componentSize: 4,
     112                    normalize: false,
     113                  },
     114                  { data: new Uint32Array([ 0, 4294967295, 0, 4294967295, 0, 0, 0, 0, 0]),
     115                    type: gl.UNSIGNED_INT,
     116                    componentSize: 4,
     117                    normalize: true,
     118                  },
     119                  { data: new Uint16Array([ 0, 0b11110000000000, 0, 0b11110000000000, 0, 0, 0, 0, 0]),
     120                    type: gl.HALF_FLOAT,
     121                    componentSize: 2,
     122                    normalize: false,
     123                  },
     124                  { data: new Uint16Array([ 0, 0b11110000000000, 0, 0b11110000000000, 0, 0, 0, 0, 0]),
     125                    type: gl.HALF_FLOAT,
     126                    componentSize: 2,
     127                    normalize: false,
     128                  }
     129                ]);
     130            }
    122131
    123132            var vertexObject = gl.createBuffer();
  • trunk/LayoutTests/webgl/2.0.0/resources/webgl_test_files/conformance/attribs/gl-vertexattribpointer.html

    r264997 r265317  
    11<!--
    2 
    3 /*
    4 ** Copyright (c) 2012 The Khronos Group Inc.
    5 **
    6 ** Permission is hereby granted, free of charge, to any person obtaining a
    7 ** copy of this software and/or associated documentation files (the
    8 ** "Materials"), to deal in the Materials without restriction, including
    9 ** without limitation the rights to use, copy, modify, merge, publish,
    10 ** distribute, sublicense, and/or sell copies of the Materials, and to
    11 ** permit persons to whom the Materials are furnished to do so, subject to
    12 ** the following conditions:
    13 **
    14 ** The above copyright notice and this permission notice shall be included
    15 ** in all copies or substantial portions of the Materials.
    16 **
    17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
    24 */
    25 
     2Copyright (c) 2019 The Khronos Group Inc.
     3Use of this source code is governed by an MIT-style license that can be
     4found in the LICENSE.txt file.
    265-->
    276
     
    7453  wtu.glErrorShouldBe(gl, gl.NO_ERROR);
    7554
    76   //gl.bindBuffer(gl.ARRAY_BUFFER, null);
    77   //gl.vertexAttribPointer(0, 1, gl.FLOAT, false, 0, 0);
    78   //wtu.glErrorShouldBe(gl, gl.NO_ERROR,
    79   //    "vertexAttribPointer should succeed if no buffer is bound and `offset` is zero.");
     55  gl.bindBuffer(gl.ARRAY_BUFFER, null);
     56  gl.vertexAttribPointer(0, 1, gl.FLOAT, false, 0, 0);
     57  wtu.glErrorShouldBe(gl, gl.NO_ERROR,
     58      "vertexAttribPointer should succeed if no buffer is bound and `offset` is zero.");
    8059
    8160  gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
     
    8968    wtu.glErrorShouldBe(gl, gl.INVALID_ENUM,
    9069            "vertexAttribPointer should not support UNSIGNED_INT");
    91     gl.vertexAttribPointer(0, 1, gl.FIXED, 0, 0, 0);
    92     wtu.glErrorShouldBe(gl, gl.INVALID_ENUM,
    93             "vertexAttribPointer should not support FIXED");
    9470  }
     71  gl.vertexAttribPointer(0, 1, gl.FIXED, 0, 0, 0);
     72  wtu.glErrorShouldBe(gl, gl.INVALID_ENUM,
     73          "vertexAttribPointer should not support FIXED");
    9574
    9675  var checkVertexAttribPointer = function(
     
    122101  ];
    123102
     103  if (wtu.getDefault3DContextVersion() >= 2) {
     104    types.push(...[
     105        { type:gl.INT,                         bytesPerComponent: 4 },
     106        { type:gl.UNSIGNED_INT,                bytesPerComponent: 4 },
     107        { type:gl.HALF_FLOAT,                  bytesPerComponent: 2 },
     108        { type:gl.INT_2_10_10_10_REV,          bytesPerComponent: 4, minSize: 4 },
     109        { type:gl.UNSIGNED_INT_2_10_10_10_REV, bytesPerComponent: 4, minSize: 4 },
     110      ]);
     111  }
     112
    124113  for (var ii = 0; ii < types.length; ++ii) {
    125114    var info = types[ii];
     
    150139            err = gl.INVALID_OPERATION;
    151140          }
     141          if (size < info.minSize) {
     142            reason = "because size < minSize";
     143            err = gl.INVALID_OPERATION;
     144          }
    152145          checkVertexAttribPointer(
    153146              gl, err, reason, size, info.type, false, stride, offset);
     
    157150        if (offset == 0) {
    158151          checkVertexAttribPointer(
    159               gl, gl.NO_ERROR, "at stride limit",
     152              gl, size < info.minSize ? gl.INVALID_OPERATION : gl.NO_ERROR, "at stride limit",
    160153              size, info.type, false, stride, offset);
    161154          checkVertexAttribPointer(
    162               gl, gl.INVALID_VALUE, "over stride limit",
     155              gl, size < info.minSize ? gl.INVALID_OPERATION : gl.INVALID_VALUE, "over stride limit",
    163156              size, info.type, false,
    164157              stride + info.bytesPerComponent, offset);
  • trunk/Source/WebCore/ChangeLog

    r265315 r265317  
     12020-08-05  James Darpinian  <jdarpinian@chromium.org>
     2
     3        [WebGL2] Upgrade vertexAttribPointer with new supported types
     4        https://bugs.webkit.org/show_bug.cgi?id=215036
     5
     6        Reviewed by Dean Jackson.
     7
     8        Tested by updated WebGL conformance tests webgl/2.0.0/conformance/attribs/gl-vertexattribpointer-offsets.html and webgl/2.0.0/conformance/attribs/gl-vertexattribpointer.html
     9
     10        * html/canvas/WebGLRenderingContextBase.cpp:
     11        (WebCore::WebGLRenderingContextBase::sizeInBytes):
     12        (WebCore::WebGLRenderingContextBase::vertexAttribPointer):
     13
    1142020-08-05  Tim Horton  <timothy_horton@apple.com>
    215
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r265208 r265317  
    12961296    case GraphicsContextGL::FLOAT:
    12971297        return sizeof(GCGLfloat);
     1298    case GraphicsContextGL::HALF_FLOAT:
     1299        return 2;
     1300    case GraphicsContextGL::INT_2_10_10_10_REV:
     1301    case GraphicsContextGL::UNSIGNED_INT_2_10_10_10_REV:
     1302        return 4;
    12981303    }
    12991304    ASSERT_NOT_REACHED();
     
    59665971        break;
    59675972    default:
    5968         synthesizeGLError(GraphicsContextGL::INVALID_ENUM, "vertexAttribPointer", "invalid type");
    5969         return;
     5973        if (!isWebGL2()) {
     5974            synthesizeGLError(GraphicsContextGL::INVALID_ENUM, "vertexAttribPointer", "invalid type");
     5975            return;
     5976        }
     5977        switch (type) {
     5978        case GraphicsContextGL::INT:
     5979        case GraphicsContextGL::UNSIGNED_INT:
     5980        case GraphicsContextGL::HALF_FLOAT:
     5981            break;
     5982        case GraphicsContextGL::INT_2_10_10_10_REV:
     5983        case GraphicsContextGL::UNSIGNED_INT_2_10_10_10_REV:
     5984            if (size != 4) {
     5985                synthesizeGLError(GraphicsContextGL::INVALID_OPERATION, "vertexAttribPointer", "[UNSIGNED_]INT_2_10_10_10_REV requires size 4");
     5986                return;
     5987            }
     5988            break;
     5989        default:
     5990            synthesizeGLError(GraphicsContextGL::INVALID_ENUM, "vertexAttribPointer", "invalid type");
     5991            return;
     5992        }
    59705993    }
    59715994    if (index >= m_maxVertexAttribs) {
Note: See TracChangeset for help on using the changeset viewer.