Changeset 162565 in webkit
- Timestamp:
- Jan 22, 2014 3:47:24 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r162563 r162565 1 2014-01-22 Dean Jackson <dino@apple.com> 2 3 Implement ANGLE_instanced_arrays 4 https://bugs.webkit.org/show_bug.cgi?id=127257 5 6 Reviewed by Brent Fulgham. 7 8 Copied a slightly modified version of the Khronos instanced 9 arrays test (mostly modified due to the fact this comes from 10 an in-progress update to the test suite). 11 12 * fast/canvas/webgl/angle-instanced-arrays-expected.txt: Added. 13 * fast/canvas/webgl/angle-instanced-arrays.html: Added. 14 * fast/canvas/webgl/resources/webgl-test-utils.js: 15 (WebGLTestUtils): Added some new functions that were missing, and 16 some output to a checkColor test. 17 * platform/efl/TestExpectations: Skip this for EFL. 18 * platform/mac-mountainlion/fast/canvas/webgl/angle-instanced-arrays-expected.txt: Not 19 supported on Mountain Lion. 20 1 21 2014-01-22 Zalan Bujtas <zalan@apple.com> 2 22 -
trunk/LayoutTests/fast/canvas/webgl/resources/webgl-test-utils.js
r161996 r162565 362 362 363 363 /** 364 * Creates a unit quad with only positions of a given resolution. 365 * @param {!WebGLRenderingContext} gl The WebGLRenderingContext to use. 366 * @param {number} gridRes The resolution of the mesh grid, 367 * expressed in the number of quads across and down. 368 * @param {number} opt_positionLocation The attrib location for position. 369 */ 370 var setupIndexedQuad = function ( 371 gl, gridRes, opt_positionLocation, opt_flipOddTriangles) { 372 return setupIndexedQuadWithOptions(gl, 373 { gridRes: gridRes, 374 positionLocation: opt_positionLocation, 375 flipOddTriangles: opt_flipOddTriangles 376 }); 377 }; 378 379 /** 380 * Creates a quad with various options. 381 * @param {!WebGLRenderingContext} gl The WebGLRenderingContext to use. 382 * @param {!Object) options The options. See below. 383 * @return {!Array.<WebGLBuffer>} The created buffers. 384 * [positions, <colors>, indices] 385 * 386 * Options: 387 * gridRes: number of quads across and down grid. 388 * positionLocation: attrib location for position 389 * flipOddTriangles: reverse order of vertices of every other 390 * triangle 391 * positionOffset: offset added to each vertex 392 * positionMult: multipier for each vertex 393 * colorLocation: attrib location for vertex colors. If 394 * undefined no vertex colors will be created. 395 */ 396 var setupIndexedQuadWithOptions = function (gl, options) { 397 var positionLocation = options.positionLocation || 0; 398 var objects = []; 399 400 var gridRes = options.gridRes || 1; 401 var positionOffset = options.positionOffset || 0; 402 var positionMult = options.positionMult || 1; 403 var vertsAcross = gridRes + 1; 404 var numVerts = vertsAcross * vertsAcross; 405 var positions = new Float32Array(numVerts * 3); 406 var indices = new Uint16Array(6 * gridRes * gridRes); 407 var poffset = 0; 408 409 for (var yy = 0; yy <= gridRes; ++yy) { 410 for (var xx = 0; xx <= gridRes; ++xx) { 411 positions[poffset + 0] = (-1 + 2 * xx / gridRes) * positionMult + positionOffset; 412 positions[poffset + 1] = (-1 + 2 * yy / gridRes) * positionMult + positionOffset; 413 positions[poffset + 2] = 0; 414 415 poffset += 3; 416 } 417 } 418 419 var buf = gl.createBuffer(); 420 gl.bindBuffer(gl.ARRAY_BUFFER, buf); 421 gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STATIC_DRAW); 422 gl.enableVertexAttribArray(positionLocation); 423 gl.vertexAttribPointer(positionLocation, 3, gl.FLOAT, false, 0, 0); 424 objects.push(buf); 425 426 if (options.colorLocation !== undefined) { 427 var colors = new Float32Array(numVerts * 4); 428 for (var yy = 0; yy <= gridRes; ++yy) { 429 for (var xx = 0; xx <= gridRes; ++xx) { 430 if (options.color !== undefined) { 431 colors[poffset + 0] = options.color[0]; 432 colors[poffset + 1] = options.color[1]; 433 colors[poffset + 2] = options.color[2]; 434 colors[poffset + 3] = options.color[3]; 435 } else { 436 colors[poffset + 0] = xx / gridRes; 437 colors[poffset + 1] = yy / gridRes; 438 colors[poffset + 2] = (xx / gridRes) * (yy / gridRes); 439 colors[poffset + 3] = (yy % 2) * 0.5 + 0.5; 440 } 441 poffset += 4; 442 } 443 } 444 445 var buf = gl.createBuffer(); 446 gl.bindBuffer(gl.ARRAY_BUFFER, buf); 447 gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW); 448 gl.enableVertexAttribArray(options.colorLocation); 449 gl.vertexAttribPointer(options.colorLocation, 4, gl.FLOAT, false, 0, 0); 450 objects.push(buf); 451 } 452 453 var tbase = 0; 454 for (var yy = 0; yy < gridRes; ++yy) { 455 var index = yy * vertsAcross; 456 for (var xx = 0; xx < gridRes; ++xx) { 457 indices[tbase + 0] = index + 0; 458 indices[tbase + 1] = index + 1; 459 indices[tbase + 2] = index + vertsAcross; 460 indices[tbase + 3] = index + vertsAcross; 461 indices[tbase + 4] = index + 1; 462 indices[tbase + 5] = index + vertsAcross + 1; 463 464 if (options.flipOddTriangles) { 465 indices[tbase + 4] = index + vertsAcross + 1; 466 indices[tbase + 5] = index + 1; 467 } 468 469 index += 1; 470 tbase += 6; 471 } 472 } 473 474 var buf = gl.createBuffer(); 475 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buf); 476 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW); 477 objects.push(buf); 478 479 return objects; 480 }; 481 482 /** 364 483 * Fills the given texture with a solid color 365 484 * @param {!WebGLContext} gl The WebGLContext to use. … … 473 592 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 474 593 gl.drawElements(gl.TRIANGLES, gridRes * 6, gl.UNSIGNED_SHORT, 0); 594 }; 595 596 /** 597 * Draws a previously setupIndexedQuad 598 * @param {!WebGLRenderingContext} gl The WebGLRenderingContext to use. 599 * @param {number} gridRes Resolution of grid. 600 * @param {!Array.<number>} opt_color The color to fill clear with before 601 * drawing. A 4 element array where each element is in the range 0 to 602 * 255. Default [255, 255, 255, 255] 603 */ 604 var clearAndDrawIndexedQuad = function(gl, gridRes, opt_color) { 605 opt_color = opt_color || [255, 255, 255, 255]; 606 gl.clearColor( 607 opt_color[0] / 255, 608 opt_color[1] / 255, 609 opt_color[2] / 255, 610 opt_color[3] / 255); 611 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); 612 drawIndexedQuad(gl, gridRes); 613 }; 614 615 /** 616 * Clips a range to min, max 617 * (Eg. clipToRange(-5,7,0,20) would return {value:0,extent:2} 618 * @param {number} value start of range 619 * @param {number} extent extent of range 620 * @param {number} min min. 621 * @param {number} max max. 622 * @return {!{value:number,extent:number} The clipped value. 623 */ 624 var clipToRange = function(value, extent, min, max) { 625 if (value < min) { 626 extent -= min - value; 627 value = min; 628 } 629 var end = value + extent; 630 if (end > max) { 631 extent -= end - max; 632 } 633 if (extent < 0) { 634 value = max; 635 extent = 0; 636 } 637 return {value:value, extent: extent}; 638 }; 639 640 /** 641 * Determines if the passed context is an instance of a WebGLRenderingContext 642 * or later variant (like WebGL2RenderingContext) 643 * @param {CanvasRenderingContext} ctx The context to check. 644 */ 645 var isWebGLContext = function(ctx) { 646 if (ctx instanceof WebGLRenderingContext) 647 return true; 648 649 if ('WebGL2RenderingContext' in window && ctx instanceof WebGL2RenderingContext) 650 return true; 651 652 return false; 653 }; 654 655 /** 656 * Checks that a portion of a canvas is 1 color. 657 * @param {!WebGLRenderingContext|CanvasRenderingContext2D} gl The 658 * WebGLRenderingContext or 2D context to use. 659 * @param {number} x left corner of region to check. 660 * @param {number} y bottom corner of region to check in case of checking from 661 * a GL context or top corner in case of checking from a 2D context. 662 * @param {number} width width of region to check. 663 * @param {number} height width of region to check. 664 * @param {!Array.<number>} color The color expected. A 4 element array where 665 * each element is in the range 0 to 255. 666 * @param {number} opt_errorRange Optional. Acceptable error in 667 * color checking. 0 by default. 668 * @param {!function()} sameFn Function to call if all pixels 669 * are the same as color. 670 * @param {!function()} differentFn Function to call if a pixel 671 * is different than color 672 * @param {!function()} logFn Function to call for logging. 673 */ 674 var checkCanvasRectColor = function(gl, x, y, width, height, color, opt_errorRange, sameFn, differentFn, logFn) { 675 if (isWebGLContext(gl) && !gl.getParameter(gl.FRAMEBUFFER_BINDING)) { 676 // We're reading the backbuffer so clip. 677 var xr = clipToRange(x, width, 0, gl.canvas.width); 678 var yr = clipToRange(y, height, 0, gl.canvas.height); 679 if (!xr.extent || !yr.extent) { 680 logFn("checking rect: effective width or heigh is zero"); 681 sameFn(); 682 return; 683 } 684 x = xr.value; 685 y = yr.value; 686 width = xr.extent; 687 height = yr.extent; 688 } 689 var errorRange = opt_errorRange || 0; 690 if (!errorRange.length) { 691 errorRange = [errorRange, errorRange, errorRange, errorRange] 692 } 693 var buf; 694 if (isWebGLContext(gl)) { 695 buf = new Uint8Array(width * height * 4); 696 gl.readPixels(x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf); 697 } else { 698 buf = gl.getImageData(x, y, width, height).data; 699 } 700 for (var i = 0; i < width * height; ++i) { 701 var offset = i * 4; 702 for (var j = 0; j < color.length; ++j) { 703 if (Math.abs(buf[offset + j] - color[j]) > errorRange[j]) { 704 differentFn(); 705 var was = buf[offset + 0].toString(); 706 for (j = 1; j < color.length; ++j) { 707 was += "," + buf[offset + j]; 708 } 709 logFn('at (' + (x + (i % width)) + ', ' + (y + Math.floor(i / width)) + 710 ') expected: ' + color + ' was ' + was); 711 return; 712 } 713 } 714 } 715 sameFn(); 475 716 }; 476 717 … … 506 747 } 507 748 } 749 } 750 if (!msg) { 751 msg = "Color was " + color; 508 752 } 509 753 testPassed(msg); … … 1332 1576 return { 1333 1577 cancelAnimFrame: cancelAnimFrame, 1578 clipToRange: clipToRange, 1334 1579 create3DContext: create3DContext, 1335 1580 create3DContextWithWrapperThatThrowsOnGLError: 1336 1581 create3DContextWithWrapperThatThrowsOnGLError, 1337 1582 checkCanvas: checkCanvas, 1338 1583 checkCanvasRect: checkCanvasRect, 1584 checkCanvasRectColor: checkCanvasRectColor, 1339 1585 createColoredTexture: createColoredTexture, 1340 1586 drawQuad: drawQuad, … … 1370 1616 setupProgram: setupProgram, 1371 1617 setupQuad: setupQuad, 1618 setupIndexedQuad: setupIndexedQuad, 1619 setupIndexedQuadWithOptions: setupIndexedQuadWithOptions, 1372 1620 setupSimpleTextureFragmentShader: setupSimpleTextureFragmentShader, 1373 1621 setupSimpleTextureProgram: setupSimpleTextureProgram, -
trunk/LayoutTests/platform/efl/TestExpectations
r162532 r162565 1682 1682 webgl/conformance/textures/texture-attachment-formats.html [ Failure ] 1683 1683 1684 # ANGLE_instanced_arrays not implemented on efl 1685 fast/canvas/webgl/angle-instanced-arrays.html [ Skip ] 1686 1684 1687 # Text rendering is overflowing region 1685 1688 webkit.org/b/122511 fast/regions/selection/selecting-text-ignoring-region-horiz-bt.html [ ImageOnlyFailure ] -
trunk/Source/WebCore/CMakeLists.txt
r162427 r162565 497 497 html/VoidCallback.idl 498 498 499 html/canvas/ANGLEInstancedArrays.idl 499 500 html/canvas/CanvasGradient.idl 500 501 html/canvas/CanvasPattern.idl … … 1493 1494 html/WeekInputType.cpp 1494 1495 1496 html/canvas/ANGLEInstancedArrays.cpp 1495 1497 html/canvas/CanvasContextAttributes.cpp 1496 1498 html/canvas/CanvasGradient.cpp … … 2665 2667 2666 2668 list(APPEND WebCore_SOURCES 2669 html/canvas/ANGLEInstancedArrays.cpp 2667 2670 html/canvas/EXTDrawBuffers.cpp 2668 2671 html/canvas/EXTTextureFilterAnisotropic.cpp … … 2701 2704 ) 2702 2705 list(APPEND WebCore_IDL_FILES 2706 html/canvas/ANGLEInstancedArrays.idl 2703 2707 html/canvas/EXTDrawBuffers.idl 2704 2708 html/canvas/EXTTextureFilterAnisotropic.idl -
trunk/Source/WebCore/ChangeLog
r162559 r162565 1 2014-01-22 Dean Jackson <dino@apple.com> 2 3 [WebGL] Implement ANGLE_instanced_arrays 4 https://bugs.webkit.org/show_bug.cgi?id=127257 5 6 Reviewed by Brent Fulgham. 7 8 Implement the instanced drawing WebGL extension, 9 ANGLE_instanced_arrays. This is currently Mac-only, 10 but should be portable to other platforms if their 11 OpenGL exposes the functions. It's also done in a way 12 that will make exposing it to WebGL2 simple. 13 14 Test: fast/canvas/webgl/angle-instanced-arrays.html 15 16 * CMakeLists.txt: 17 * DerivedSources.cpp: 18 * DerivedSources.make: 19 * GNUmakefile.list.am: 20 * WebCore.vcxproj/WebCore.vcxproj: 21 * WebCore.vcxproj/WebCore.vcxproj.filters: 22 * WebCore.xcodeproj/project.pbxproj: 23 Add the new files to all the build systems. 24 25 * bindings/js/JSWebGLRenderingContextCustom.cpp: 26 (WebCore::toJS): Link JS side to C++ side. 27 28 * html/canvas/ANGLEInstancedArrays.cpp: Added. 29 (WebCore::ANGLEInstancedArrays::ANGLEInstancedArrays): 30 * html/canvas/ANGLEInstancedArrays.h: Added. 31 * html/canvas/ANGLEInstancedArrays.idl: Added. 32 New boilerplate files that expose the extension methods. 33 34 * html/canvas/WebGLExtension.h: New extension enum. 35 36 * html/canvas/WebGLRenderingContext.cpp: 37 (WebCore::WebGLRenderingContext::validateVertexAttributes): Add an optional 38 parameter representing the number of instance primitives we are asked 39 to draw. Use that for the draw count if looking at an instanced attribute. 40 Also make sure we see at least one non-instanced attribute. 41 (WebCore::WebGLRenderingContext::validateDrawArrays): Update this so it could 42 be used from either drawArrays or drawArraysInstanced. 43 (WebCore::WebGLRenderingContext::drawArrays): 44 (WebCore::WebGLRenderingContext::validateDrawElements): Same here, now can be 45 used by the instanced and non-instanced versions. 46 (WebCore::WebGLRenderingContext::drawElements): 47 (WebCore::WebGLRenderingContext::getExtension): Create and return the new extension. 48 (WebCore::WebGLRenderingContext::getSupportedExtensions): Add new extension to the list. 49 (WebCore::WebGLRenderingContext::getVertexAttrib): Intercept a query to the divisor 50 attribute and return the value we kept in the state. 51 (WebCore::WebGLRenderingContext::drawArraysInstanced): Call the GC3D method. 52 (WebCore::WebGLRenderingContext::drawElementsInstanced): Ditto. 53 (WebCore::WebGLRenderingContext::vertexAttribDivisor): Ditto. 54 55 * html/canvas/WebGLRenderingContext.h: Define the new methods and parameters. 56 57 * html/canvas/WebGLVertexArrayObjectOES.cpp: 58 (WebCore::WebGLVertexArrayObjectOES::setVertexAttribDivisor): Keep a record of the 59 divisor if we set it. 60 * html/canvas/WebGLVertexArrayObjectOES.h: 61 (WebCore::WebGLVertexArrayObjectOES::VertexAttribState::VertexAttribState): 62 63 * platform/graphics/GraphicsContext3D.h: New enum. 64 * platform/graphics/mac/GraphicsContext3DMac.mm: 65 (WebCore::GraphicsContext3D::drawArraysInstanced): The actual calls into OpenGL. 66 (WebCore::GraphicsContext3D::drawElementsInstanced): Ditto. 67 (WebCore::GraphicsContext3D::vertexAttribDivisor): Ditto. 68 69 * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: Empty implementations 70 for non-mac platforms. 71 72 * platform/graphics/ios/GraphicsContext3DIOS.h: Define the iOS names for the 73 functions. 74 1 75 2014-01-22 Zalan Bujtas <zalan@apple.com> 2 76 -
trunk/Source/WebCore/DerivedSources.cpp
r161688 r162565 28 28 #include "HTMLElementFactory.cpp" 29 29 #include "HTMLEntityTable.cpp" 30 #if ENABLE(WEBGL) 31 #include "JSANGLEInstancedArrays.cpp" 32 #endif 30 33 #include "JSAbstractWorker.cpp" 31 34 #include "JSAttr.cpp" -
trunk/Source/WebCore/DerivedSources.make
r161901 r162565 409 409 $(WebCore)/html/ValidityState.idl \ 410 410 $(WebCore)/html/VoidCallback.idl \ 411 $(WebCore)/html/canvas/ANGLEInstancedArrays.idl \ 411 412 $(WebCore)/html/canvas/CanvasGradient.idl \ 412 413 $(WebCore)/html/canvas/CanvasPattern.idl \ -
trunk/Source/WebCore/GNUmakefile.list.am
r162372 r162565 29 29 DerivedSources/WebCore/InspectorWebTypeBuilders.cpp \ 30 30 DerivedSources/WebCore/InspectorWebTypeBuilders.h \ 31 DerivedSources/WebCore/JSANGLEInstancedArrays.cpp \ 32 DerivedSources/WebCore/JSANGLEInstancedArrays.h \ 31 33 DerivedSources/WebCore/JSAbstractWorker.cpp \ 32 34 DerivedSources/WebCore/JSAbstractWorker.h \ … … 1507 1509 $(WebCore)/html/ValidityState.idl \ 1508 1510 $(WebCore)/html/VoidCallback.idl \ 1511 $(WebCore)/html/canvas/ANGLEInstancedArrays.idl \ 1509 1512 $(WebCore)/html/canvas/CanvasGradient.idl \ 1510 1513 $(WebCore)/html/canvas/CanvasPattern.idl \ … … 3241 3244 Source/WebCore/html/ButtonInputType.cpp \ 3242 3245 Source/WebCore/html/ButtonInputType.h \ 3246 Source/WebCore/html/canvas/ANGLEInstancedArrays.cpp \ 3247 Source/WebCore/html/canvas/ANGLEInstancedArrays.h \ 3243 3248 Source/WebCore/html/canvas/CanvasContextAttributes.cpp \ 3244 3249 Source/WebCore/html/canvas/CanvasContextAttributes.h \ -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r162372 r162565 291 291 <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\CSSPropertyNames.cpp" /> 292 292 <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\CSSValueKeywords.cpp" /> 293 <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSANGLEInstancedArrays.cpp"> 294 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> 295 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> 296 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild> 297 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild> 298 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild> 299 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild> 300 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> 301 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> 302 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild> 303 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild> 304 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild> 305 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild> 306 </ClCompile> 293 307 <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSEXTDrawBuffers.cpp"> 294 308 <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> … … 6543 6557 <ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Production|x64'">ICUVersion.h</ForcedIncludeFiles> 6544 6558 </ClCompile> 6559 <ClCompile Include="..\html\canvas\ANGLEInstancedArrays.cpp" /> 6545 6560 <ClCompile Include="..\html\canvas\CanvasContextAttributes.cpp" /> 6546 6561 <ClCompile Include="..\html\canvas\CanvasPathMethods.cpp" /> … … 18554 18569 <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\XMLViewerJS.h" /> 18555 18570 <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\XPathGrammar.h" /> 18571 <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSANGLEInstancedArrays.h" /> 18556 18572 <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSEXTDrawBuffers.h" /> 18557 18573 <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSEXTTextureFilterAnisotropic.h" /> … … 18654 18670 <ClInclude Include="..\ForwardingHeaders\runtime\WriteBarrier.h" /> 18655 18671 <ClInclude Include="..\ForwardingHeaders\yarr\YarrJIT.h" /> 18672 <ClInclude Include="..\html\canvas\ANGLEInstancedArrays.h" /> 18656 18673 <ClInclude Include="..\html\canvas\CanvasContextAttributes.h" /> 18657 18674 <ClInclude Include="..\html\canvas\CanvasPathMethods.h" /> -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
r162440 r162565 6593 6593 <Filter>DerivedSources</Filter> 6594 6594 </ClCompile> 6595 <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSANGLEInstancedArrays.cpp"> 6596 <Filter>DerivedSources</Filter> 6597 </ClCompile> 6595 6598 <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSEXTDrawBuffers.cpp"> 6596 6599 <Filter>DerivedSources</Filter> … … 6619 6622 <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSOESVertexArrayObject.cpp"> 6620 6623 <Filter>DerivedSources</Filter> 6624 </ClCompile> 6625 <ClCompile Include="..\html\canvas\ANGLEInstancedArrays.cpp"> 6626 <Filter>html\canvas</Filter> 6621 6627 </ClCompile> 6622 6628 <ClCompile Include="..\html\canvas\WebGLBuffer.cpp"> … … 14464 14470 <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSOESVertexArrayObject.h"> 14465 14471 <Filter>DerivedSources</Filter> 14472 </ClInclude> 14473 <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSANGLEInstancedArrays.h"> 14474 <Filter>DerivedSources</Filter> 14475 </ClInclude> 14476 <ClInclude Include="..\html\canvas\ANGLEInstancedArrays.h"> 14477 <Filter>html\canvas</Filter> 14466 14478 </ClInclude> 14467 14479 <ClInclude Include="..\html\canvas\WebGLActiveInfo.h"> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r162454 r162565 1195 1195 319AE064142D6B24006563A1 /* StyleFilterData.h in Headers */ = {isa = PBXBuildFile; fileRef = 319AE062142D6B24006563A1 /* StyleFilterData.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1196 1196 319FBD5F15D2F464009640A6 /* CachedImageClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 319FBD5D15D2F444009640A6 /* CachedImageClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1197 31A795C61888BADC00382F90 /* JSANGLEInstancedArrays.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31A795C41888BAD100382F90 /* JSANGLEInstancedArrays.cpp */; }; 1198 31A795C71888BCB200382F90 /* ANGLEInstancedArrays.h in Headers */ = {isa = PBXBuildFile; fileRef = 31A795C21888B72400382F90 /* ANGLEInstancedArrays.h */; }; 1199 31A795C81888BCB500382F90 /* ANGLEInstancedArrays.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31A795C11888B72400382F90 /* ANGLEInstancedArrays.cpp */; }; 1197 1200 31AB5000122878A2001A7DB0 /* GraphicsContext3DIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 31AB4FFF122878A2001A7DB0 /* GraphicsContext3DIOS.h */; }; 1198 1201 31C0FF210E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31C0FF1B0E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp */; }; … … 8069 8072 319AE062142D6B24006563A1 /* StyleFilterData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleFilterData.h; path = style/StyleFilterData.h; sourceTree = "<group>"; }; 8070 8073 319FBD5D15D2F444009640A6 /* CachedImageClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedImageClient.h; sourceTree = "<group>"; }; 8074 31A795C11888B72400382F90 /* ANGLEInstancedArrays.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ANGLEInstancedArrays.cpp; path = canvas/ANGLEInstancedArrays.cpp; sourceTree = "<group>"; }; 8075 31A795C21888B72400382F90 /* ANGLEInstancedArrays.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ANGLEInstancedArrays.h; path = canvas/ANGLEInstancedArrays.h; sourceTree = "<group>"; }; 8076 31A795C31888B72400382F90 /* ANGLEInstancedArrays.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = ANGLEInstancedArrays.idl; path = canvas/ANGLEInstancedArrays.idl; sourceTree = "<group>"; }; 8077 31A795C41888BAD100382F90 /* JSANGLEInstancedArrays.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSANGLEInstancedArrays.cpp; sourceTree = "<group>"; }; 8078 31A795C51888BAD100382F90 /* JSANGLEInstancedArrays.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSANGLEInstancedArrays.h; sourceTree = "<group>"; }; 8071 8079 31AB4FFF122878A2001A7DB0 /* GraphicsContext3DIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContext3DIOS.h; sourceTree = "<group>"; }; 8072 8080 31C0FF1B0E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitAnimationEvent.cpp; sourceTree = "<group>"; }; … … 15438 15446 isa = PBXGroup; 15439 15447 children = ( 15448 31A795C11888B72400382F90 /* ANGLEInstancedArrays.cpp */, 15449 31A795C21888B72400382F90 /* ANGLEInstancedArrays.h */, 15450 31A795C31888B72400382F90 /* ANGLEInstancedArrays.idl */, 15440 15451 6E4E91A710F7FB3100A2779C /* CanvasContextAttributes.cpp */, 15441 15452 6E4E91A810F7FB3100A2779C /* CanvasContextAttributes.h */, … … 18193 18204 isa = PBXGroup; 18194 18205 children = ( 18206 31A795C41888BAD100382F90 /* JSANGLEInstancedArrays.cpp */, 18207 31A795C51888BAD100382F90 /* JSANGLEInstancedArrays.h */, 18195 18208 BE8EF03E171C8FF9009B48C3 /* JSAudioTrack.cpp */, 18196 18209 BE8EF03F171C8FF9009B48C3 /* JSAudioTrack.h */, … … 23665 23678 8AD0A59614C88358000D83C5 /* DOMWebKitCSSRegionRule.h in Headers */, 23666 23679 8AD0A59814C88358000D83C5 /* DOMWebKitCSSRegionRuleInternal.h in Headers */, 23680 31A795C71888BCB200382F90 /* ANGLEInstancedArrays.h in Headers */, 23667 23681 31611E610E1C4E1400F6A579 /* DOMWebKitCSSTransformValue.h in Headers */, 23668 23682 31611E630E1C4E1400F6A579 /* DOMWebKitCSSTransformValueInternal.h in Headers */, … … 28845 28859 5038BE2F1472AD230095E0D1 /* StyleCachedShader.cpp in Sources */, 28846 28860 50E18CD816F9285800C65486 /* StyleCustomFilterProgram.cpp in Sources */, 28861 31A795C81888BCB500382F90 /* ANGLEInstancedArrays.cpp in Sources */, 28847 28862 A5840E24187B8AC200843B10 /* PageInjectedScriptHost.cpp in Sources */, 28848 28863 50E18CD916F9285800C65486 /* StyleCustomFilterProgramCache.cpp in Sources */, … … 29290 29305 97AABD2614FA09D5007457AE /* WebSocketHandshake.cpp in Sources */, 29291 29306 0F580FA41496939100FB5BD8 /* WebTiledBackingLayer.mm in Sources */, 29307 31A795C61888BADC00382F90 /* JSANGLEInstancedArrays.cpp in Sources */, 29292 29308 CD82030B1395AB6A00F956C6 /* WebVideoFullscreenController.mm in Sources */, 29293 29309 CD82030D1395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.mm in Sources */, -
trunk/Source/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp
r161688 r162565 30 30 #include "JSWebGLRenderingContext.h" 31 31 32 #include "ANGLEInstancedArrays.h" 32 33 #include "EXTDrawBuffers.h" 33 34 #include "EXTTextureFilterAnisotropic.h" … … 35 36 #include "HTMLCanvasElement.h" 36 37 #include "HTMLImageElement.h" 38 #include "JSANGLEInstancedArrays.h" 37 39 #include "JSEXTDrawBuffers.h" 38 40 #include "JSEXTTextureFilterAnisotropic.h" … … 234 236 case WebGLExtension::WebGLDepthTextureName: 235 237 return toJS(exec, globalObject, static_cast<WebGLDepthTexture*>(extension)); 238 case WebGLExtension::ANGLEInstancedArraysName: 239 return toJS(exec, globalObject, static_cast<ANGLEInstancedArrays*>(extension)); 236 240 } 237 241 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/html/canvas/WebGLExtension.h
r161688 r162565 52 52 WebGLCompressedTextureATCName, 53 53 WebGLCompressedTexturePVRTCName, 54 ANGLEInstancedArraysName, 54 55 }; 55 56 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
r162180 r162565 30 30 #include "WebGLRenderingContext.h" 31 31 32 #include "ANGLEInstancedArrays.h" 32 33 #include "CachedImage.h" 33 34 #include "DOMWindow.h" … … 1887 1888 } 1888 1889 1889 bool WebGLRenderingContext::validateVertexAttributes(unsigned numElementsRequired)1890 bool WebGLRenderingContext::validateVertexAttributes(unsigned elementCount, unsigned primitiveCount) 1890 1891 { 1891 1892 if (!m_currentProgram) … … 1898 1899 } 1899 1900 1900 if ( numElementsRequired<= 0)1901 if (elementCount <= 0) 1901 1902 return true; 1902 1903 1903 // Look in each consumed vertex attrib (by the current program) and find the smallest buffer size 1904 unsigned smallestNumElements = UINT_MAX; 1904 1905 // Look in each consumed vertex attrib (by the current program). 1906 bool sawNonInstancedAttrib = false; 1907 bool sawEnabledAttrib = false; 1905 1908 int numActiveAttribLocations = m_currentProgram->numActiveAttribLocations(); 1906 1909 for (int i = 0; i < numActiveAttribLocations; ++i) { … … 1909 1912 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(loc); 1910 1913 if (state.enabled) { 1914 sawEnabledAttrib = true; 1911 1915 // Avoid off-by-one errors in numElements computation. 1912 1916 // For the last element, we will only touch the data for the … … 1917 1921 if (bytesRemaining >= state.bytesPerElement) 1918 1922 numElements = 1 + (bytesRemaining - state.bytesPerElement) / state.stride; 1919 if (numElements < smallestNumElements) 1920 smallestNumElements = numElements; 1923 if (!state.divisor) 1924 sawNonInstancedAttrib = true; 1925 if ((!state.divisor && elementCount > numElements) || (state.divisor && primitiveCount > numElements)) 1926 return false; 1921 1927 } 1922 1928 } 1923 1929 } 1924 1930 1925 if ( smallestNumElements == INT_MAX)1926 smallestNumElements = 0;1927 1928 return numElementsRequired <= smallestNumElements;1931 if (!sawNonInstancedAttrib && sawEnabledAttrib) 1932 return false; 1933 1934 return true; 1929 1935 } 1930 1936 … … 1942 1948 } 1943 1949 1944 void WebGLRenderingContext::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count, ExceptionCode& ec) 1945 { 1946 UNUSED_PARAM(ec); 1947 1948 if (isContextLost() || !validateDrawMode("drawArrays", mode)) 1949 return; 1950 1951 if (!validateStencilSettings("drawArrays")) 1952 return; 1950 bool WebGLRenderingContext::validateDrawArrays(const char* functionName, GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) 1951 { 1952 if (isContextLost() || !validateDrawMode(functionName, mode)) 1953 return false; 1954 1955 if (!validateStencilSettings(functionName)) 1956 return false; 1953 1957 1954 1958 if (first < 0 || count < 0) { 1955 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "drawArrays", "first or count < 0");1956 return ;1959 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "first or count < 0"); 1960 return false; 1957 1961 } 1958 1962 1959 1963 if (!count) { 1960 1964 cleanupAfterGraphicsCall(true); 1961 return; 1965 return false; 1966 } 1967 1968 if (primcount < 0) { 1969 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "primcount < 0"); 1970 return false; 1962 1971 } 1963 1972 … … 1967 1976 Checked<GC3Dint, RecordOverflow> checkedCount(count); 1968 1977 Checked<GC3Dint, RecordOverflow> checkedSum = checkedFirst + checkedCount; 1969 if (checkedSum.hasOverflowed() || !validateVertexAttributes(checkedSum.unsafeGet())) { 1970 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawArrays", "attempt to access out of bounds arrays"); 1971 return; 1978 Checked<GC3Dint, RecordOverflow> checkedPrimCount(primcount); 1979 if (checkedSum.hasOverflowed() || checkedPrimCount.hasOverflowed() || !validateVertexAttributes(checkedSum.unsafeGet(), checkedPrimCount.unsafeGet())) { 1980 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "attempt to access out of bounds arrays"); 1981 return false; 1972 1982 } 1973 1983 } else { 1974 1984 if (!validateVertexAttributes(0)) { 1975 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawArrays", "attribs not setup correctly");1976 return ;1985 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "attribs not setup correctly"); 1986 return false; 1977 1987 } 1978 1988 } … … 1980 1990 const char* reason = "framebuffer incomplete"; 1981 1991 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe(), &reason)) { 1982 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "drawArrays", reason); 1983 return; 1984 } 1992 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, functionName, reason); 1993 return false; 1994 } 1995 1996 return true; 1997 } 1998 1999 void WebGLRenderingContext::drawArrays(GC3Denum mode, GC3Dint first, GC3Dsizei count, ExceptionCode& ec) 2000 { 2001 UNUSED_PARAM(ec); 2002 2003 if (!validateDrawArrays("drawArrays", mode, first, count, 0)) 2004 return; 1985 2005 1986 2006 clearIfComposited(); … … 1999 2019 } 2000 2020 2001 void WebGLRenderingContext::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, ExceptionCode& ec) 2002 { 2003 UNUSED_PARAM(ec); 2004 2005 if (isContextLost() || !validateDrawMode("drawElements", mode)) 2006 return; 2007 2008 if (!validateStencilSettings("drawElements")) 2009 return; 2021 bool WebGLRenderingContext::validateDrawElements(const char* functionName, GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, unsigned& numElements) 2022 { 2023 if (isContextLost() || !validateDrawMode(functionName, mode)) 2024 return false; 2025 2026 if (!validateStencilSettings(functionName)) 2027 return false; 2010 2028 2011 2029 switch (type) { … … 2016 2034 if (m_oesElementIndexUint) 2017 2035 break; 2018 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "drawElements", "invalid type");2019 return ;2036 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid type"); 2037 return false; 2020 2038 default: 2021 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "drawElements", "invalid type");2022 return ;2039 synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid type"); 2040 return false; 2023 2041 } 2024 2042 2025 2043 if (count < 0 || offset < 0) { 2026 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "drawElements", "count or offset < 0");2027 return ;2044 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, functionName, "count or offset < 0"); 2045 return false; 2028 2046 } 2029 2047 2030 2048 if (!count) { 2031 2049 cleanupAfterGraphicsCall(true); 2032 return ;2050 return false; 2033 2051 } 2034 2052 2035 2053 if (!m_boundVertexArrayObject->getElementArrayBuffer()) { 2036 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawElements", "no ELEMENT_ARRAY_BUFFER bound"); 2037 return; 2038 } 2039 2040 unsigned numElements = 0; 2054 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "no ELEMENT_ARRAY_BUFFER bound"); 2055 return false; 2056 } 2057 2041 2058 if (!isErrorGeneratedOnOutOfBoundsAccesses()) { 2042 2059 // Ensure we have a valid rendering state 2043 2060 if (!validateElementArraySize(count, type, static_cast<GC3Dintptr>(offset))) { 2044 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawElements", "request out of bounds for current ELEMENT_ARRAY_BUFFER");2045 return ;2061 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "request out of bounds for current ELEMENT_ARRAY_BUFFER"); 2062 return false; 2046 2063 } 2047 2064 if (!count) 2048 return ;2065 return false; 2049 2066 if (!validateIndexArrayConservative(type, numElements) || !validateVertexAttributes(numElements)) { 2050 2067 if (!validateIndexArrayPrecise(count, type, static_cast<GC3Dintptr>(offset), numElements) || !validateVertexAttributes(numElements)) { 2051 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawElements", "attempt to access out of bounds arrays");2052 return ;2068 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "attempt to access out of bounds arrays"); 2069 return false; 2053 2070 } 2054 2071 } 2055 2072 } else { 2056 2073 if (!validateVertexAttributes(0)) { 2057 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, "drawElements", "attribs not setup correctly");2058 return ;2074 synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "attribs not setup correctly"); 2075 return false; 2059 2076 } 2060 2077 } … … 2062 2079 const char* reason = "framebuffer incomplete"; 2063 2080 if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe(), &reason)) { 2064 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "drawElements", reason); 2065 return; 2066 } 2081 synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, functionName, reason); 2082 return false; 2083 } 2084 2085 return true; 2086 } 2087 2088 void WebGLRenderingContext::drawElements(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, ExceptionCode& ec) 2089 { 2090 UNUSED_PARAM(ec); 2091 2092 unsigned numElements = 0; 2093 if (!validateDrawElements("drawElements", mode, count, type, offset, numElements)) 2094 return; 2095 2067 2096 clearIfComposited(); 2068 2097 … … 2477 2506 } 2478 2507 return m_extDrawBuffers.get(); 2508 } 2509 if (equalIgnoringCase(name, "ANGLE_instanced_arrays") && ANGLEInstancedArrays::supported(this)) { 2510 if (!m_angleInstancedArrays) { 2511 m_context->getExtensions()->ensureEnabled("GL_ANGLE_instanced_arrays"); 2512 m_angleInstancedArrays = ANGLEInstancedArrays::create(this); 2513 } 2514 return m_angleInstancedArrays.get(); 2479 2515 } 2480 2516 if (allowPrivilegedExtensions()) { … … 2999 3035 if (supportsDrawBuffers()) 3000 3036 result.append("EXT_draw_buffers"); 3037 if (ANGLEInstancedArrays::supported(this)) 3038 result.append("ANGLE_instanced_arrays"); 3001 3039 3002 3040 if (allowPrivilegedExtensions()) { … … 3211 3249 { 3212 3250 UNUSED_PARAM(ec); 3251 3213 3252 if (isContextLost()) 3214 3253 return WebGLGetInfo(); 3254 3215 3255 WebGLStateRestorer(this, false); 3256 3216 3257 if (index >= m_maxVertexAttribs) { 3217 3258 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "getVertexAttrib", "index out of range"); 3218 3259 return WebGLGetInfo(); 3219 3260 } 3261 3220 3262 const WebGLVertexArrayObjectOES::VertexAttribState& state = m_boundVertexArrayObject->getVertexAttribState(index); 3263 3264 if (m_angleInstancedArrays && pname == GraphicsContext3D::VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE) 3265 return WebGLGetInfo(state.divisor); 3266 3221 3267 switch (pname) { 3222 3268 case GraphicsContext3D::VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: … … 6103 6149 } 6104 6150 6151 void WebGLRenderingContext::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) 6152 { 6153 if (!validateDrawArrays("drawArraysInstanced", mode, first, count, primcount)) 6154 return; 6155 6156 if (primcount < 0) { 6157 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "drawArraysInstanced", "primcount < 0"); 6158 return; 6159 } 6160 6161 if (!primcount) { 6162 cleanupAfterGraphicsCall(true); 6163 return; 6164 } 6165 6166 clearIfComposited(); 6167 6168 bool vertexAttrib0Simulated = false; 6169 if (!isGLES2Compliant()) 6170 vertexAttrib0Simulated = simulateVertexAttrib0(first + count - 1); 6171 if (!isGLES2NPOTStrict()) 6172 checkTextureCompleteness("drawArraysInstanced", true); 6173 UNUSED_PARAM(primcount); 6174 m_context->drawArraysInstanced(mode, first, count, primcount); 6175 if (!isGLES2Compliant() && vertexAttrib0Simulated) 6176 restoreStatesAfterVertexAttrib0Simulation(); 6177 if (!isGLES2NPOTStrict()) 6178 checkTextureCompleteness("drawArraysInstanced", false); 6179 cleanupAfterGraphicsCall(true); 6180 } 6181 6182 void WebGLRenderingContext::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount) 6183 { 6184 unsigned numElements = 0; 6185 if (!validateDrawElements("drawElementsInstanced", mode, count, type, offset, numElements)) 6186 return; 6187 6188 if (primcount < 0) { 6189 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "drawElementsInstanced", "primcount < 0"); 6190 return; 6191 } 6192 6193 if (!primcount) { 6194 cleanupAfterGraphicsCall(true); 6195 return; 6196 } 6197 6198 clearIfComposited(); 6199 6200 bool vertexAttrib0Simulated = false; 6201 if (!isGLES2Compliant()) { 6202 if (!numElements) 6203 validateIndexArrayPrecise(count, type, static_cast<GC3Dintptr>(offset), numElements); 6204 vertexAttrib0Simulated = simulateVertexAttrib0(numElements); 6205 } 6206 if (!isGLES2NPOTStrict()) 6207 checkTextureCompleteness("drawElementsInstanced", true); 6208 m_context->drawElementsInstanced(mode, count, type, static_cast<GC3Dintptr>(offset), primcount); 6209 if (!isGLES2Compliant() && vertexAttrib0Simulated) 6210 restoreStatesAfterVertexAttrib0Simulation(); 6211 if (!isGLES2NPOTStrict()) 6212 checkTextureCompleteness("drawElementsInstanced", false); 6213 cleanupAfterGraphicsCall(true); 6214 } 6215 6216 void WebGLRenderingContext::vertexAttribDivisor(GC3Duint index, GC3Duint divisor) 6217 { 6218 if (isContextLost()) 6219 return; 6220 6221 if (index >= m_maxVertexAttribs) { 6222 synthesizeGLError(GraphicsContext3D::INVALID_VALUE, "vertexAttribDivisor", "index out of range"); 6223 return; 6224 } 6225 6226 m_boundVertexArrayObject->setVertexAttribDivisor(index, divisor); 6227 m_context->vertexAttribDivisor(index, divisor); 6228 } 6229 6230 6105 6231 } // namespace WebCore 6106 6232 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h
r162180 r162565 42 42 namespace WebCore { 43 43 44 class ANGLEInstancedArrays; 44 45 class EXTDrawBuffers; 45 46 class EXTTextureFilterAnisotropic; … … 324 325 unsigned getMaxVertexAttribs() const { return m_maxVertexAttribs; } 325 326 327 // ANGLE_instanced_arrays extension functions. 328 void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount); 329 void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount); 330 void vertexAttribDivisor(GC3Duint index, GC3Duint divisor); 331 326 332 private: 327 333 friend class EXTDrawBuffers; … … 379 385 // Precise but slow index validation -- only done if conservative checks fail 380 386 bool validateIndexArrayPrecise(GC3Dsizei count, GC3Denum type, GC3Dintptr offset, unsigned& numElementsRequired); 381 // If numElements <= 0, we only check if each enabled vertex attribute is bound to a buffer. 382 bool validateVertexAttributes(unsigned numElements); 387 bool validateVertexAttributes(unsigned elementCount, unsigned primitiveCount = 0); 383 388 384 389 bool validateWebGLObject(const char*, WebGLObject*); 390 391 bool validateDrawArrays(const char* functionName, GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount); 392 bool validateDrawElements(const char* functionName, GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, unsigned& numElements); 385 393 386 394 // Adds a compressed texture format. … … 541 549 OwnPtr<WebGLCompressedTextureS3TC> m_webglCompressedTextureS3TC; 542 550 OwnPtr<WebGLDepthTexture> m_webglDepthTexture; 551 OwnPtr<ANGLEInstancedArrays> m_angleInstancedArrays; 543 552 544 553 // Helpers for getParameter and others -
trunk/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.cpp
r129275 r162565 144 144 } 145 145 146 void WebGLVertexArrayObjectOES::setVertexAttribDivisor(GC3Duint index, GC3Duint divisor) 147 { 148 VertexAttribState& state = m_vertexAttribState[index]; 149 state.divisor = divisor; 150 } 151 146 152 } 147 153 -
trunk/Source/WebCore/html/canvas/WebGLVertexArrayObjectOES.h
r162180 r162565 56 56 , originalStride(0) 57 57 , offset(0) 58 , divisor(0) 58 59 { 59 60 } … … 71 72 GC3Dsizei originalStride; 72 73 GC3Dintptr offset; 74 GC3Duint divisor; 73 75 }; 74 76 … … 84 86 void setVertexAttribState(GC3Duint, GC3Dsizei, GC3Dint, GC3Denum, GC3Dboolean, GC3Dsizei, GC3Dintptr, PassRefPtr<WebGLBuffer>); 85 87 void unbindBuffer(PassRefPtr<WebGLBuffer>); 88 89 void setVertexAttribDivisor(GC3Duint index, GC3Duint divisor); 86 90 87 91 private: -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h
r162451 r162565 426 426 CONTEXT_LOST_WEBGL = 0x9242, 427 427 UNPACK_COLORSPACE_CONVERSION_WEBGL = 0x9243, 428 BROWSER_DEFAULT_WEBGL = 0x9244 428 BROWSER_DEFAULT_WEBGL = 0x9244, 429 VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 0x88FE 429 430 }; 430 431 … … 828 829 void reshape(int width, int height); 829 830 831 void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount); 832 void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount); 833 void vertexAttribDivisor(GC3Duint index, GC3Duint divisor); 834 830 835 #if PLATFORM(GTK) || PLATFORM(EFL) || USE(CAIRO) 831 836 void paintToCanvas(const unsigned char* imagePixels, int imageWidth, int imageHeight, -
trunk/Source/WebCore/platform/graphics/ios/GraphicsContext3DIOS.h
r162160 r162565 44 44 #define glRenderbufferStorageMultisampleEXT glRenderbufferStorageMultisampleAPPLE 45 45 46 #define glDrawArraysInstancedARB glDrawArraysInstancedEXT 47 #define glDrawElementsInstancedARB glDrawElementsInstancedEXT 48 #define glVertexAttribDivisorARB glVertexAttribDivisorEXT 49 46 50 #define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0 47 51 #define GL_DEPTH24_STENCIL8_EXT GL_DEPTH24_STENCIL8_OES -
trunk/Source/WebCore/platform/graphics/mac/GraphicsContext3DMac.mm
r161759 r162565 371 371 } 372 372 373 void GraphicsContext3D::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) 374 { 375 #if PLATFORM(IOS) || PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 376 makeContextCurrent(); 377 ::glDrawArraysInstancedARB(mode, first, count, primcount); 378 #else 379 UNUSED_PARAM(mode); 380 UNUSED_PARAM(first); 381 UNUSED_PARAM(count); 382 UNUSED_PARAM(primcount); 383 #endif 384 } 385 386 void GraphicsContext3D::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount) 387 { 388 #if PLATFORM(IOS) || PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 389 makeContextCurrent(); 390 ::glDrawElementsInstancedARB(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount); 391 #else 392 UNUSED_PARAM(mode); 393 UNUSED_PARAM(count); 394 UNUSED_PARAM(type); 395 UNUSED_PARAM(offset); 396 UNUSED_PARAM(primcount); 397 #endif 398 } 399 400 void GraphicsContext3D::vertexAttribDivisor(GC3Duint index, GC3Duint divisor) 401 { 402 #if PLATFORM(IOS) || PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 403 makeContextCurrent(); 404 ::glVertexAttribDivisorARB(index, divisor); 405 #else 406 UNUSED_PARAM(index); 407 UNUSED_PARAM(divisor); 408 #endif 409 } 410 373 411 } 374 412 -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp
r162451 r162565 352 352 } 353 353 354 #if !PLATFORM(MAC) 355 void GraphicsContext3D::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) 356 { 357 UNUSED_PARAM(mode); 358 UNUSED_PARAM(first); 359 UNUSED_PARAM(count); 360 UNUSED_PARAM(primcount); 361 } 362 363 void GraphicsContext3D::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount) 364 { 365 UNUSED_PARAM(mode); 366 UNUSED_PARAM(count); 367 UNUSED_PARAM(type); 368 UNUSED_PARAM(offset); 369 UNUSED_PARAM(primcount); 370 } 371 372 void GraphicsContext3D::vertexAttribDivisor(GC3Duint index, GC3Duint divisor) 373 { 374 UNUSED_PARAM(index); 375 UNUSED_PARAM(divisor); 376 } 377 #endif 378 354 379 } 355 380
Note: See TracChangeset
for help on using the changeset viewer.