Commit 81d4ed94 authored by dino@apple.com's avatar dino@apple.com

Source/WebCore: [WebGL] Implement ANGLE_instanced_arrays

https://bugs.webkit.org/show_bug.cgi?id=127257

Reviewed by Brent Fulgham.

Implement the instanced drawing WebGL extension,
ANGLE_instanced_arrays. This is currently Mac-only,
but should be portable to other platforms if their
OpenGL exposes the functions. It's also done in a way
that will make exposing it to WebGL2 simple.

Test: fast/canvas/webgl/angle-instanced-arrays.html

* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
Add the new files to all the build systems.

* bindings/js/JSWebGLRenderingContextCustom.cpp:
(WebCore::toJS): Link JS side to C++ side.

* html/canvas/ANGLEInstancedArrays.cpp: Added.
(WebCore::ANGLEInstancedArrays::ANGLEInstancedArrays):
* html/canvas/ANGLEInstancedArrays.h: Added.
* html/canvas/ANGLEInstancedArrays.idl: Added.
New boilerplate files that expose the extension methods.

* html/canvas/WebGLExtension.h: New extension enum.

* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::validateVertexAttributes): Add an optional
parameter representing the number of instance primitives we are asked
to draw. Use that for the draw count if looking at an instanced attribute.
Also make sure we see at least one non-instanced attribute.
(WebCore::WebGLRenderingContext::validateDrawArrays): Update this so it could
be used from either drawArrays or drawArraysInstanced.
(WebCore::WebGLRenderingContext::drawArrays):
(WebCore::WebGLRenderingContext::validateDrawElements): Same here, now can be
used by the instanced and non-instanced versions.
(WebCore::WebGLRenderingContext::drawElements):
(WebCore::WebGLRenderingContext::getExtension): Create and return the new extension.
(WebCore::WebGLRenderingContext::getSupportedExtensions): Add new extension to the list.
(WebCore::WebGLRenderingContext::getVertexAttrib): Intercept a query to the divisor
attribute and return the value we kept in the state.
(WebCore::WebGLRenderingContext::drawArraysInstanced): Call the GC3D method.
(WebCore::WebGLRenderingContext::drawElementsInstanced): Ditto.
(WebCore::WebGLRenderingContext::vertexAttribDivisor): Ditto.

* html/canvas/WebGLRenderingContext.h: Define the new methods and parameters.

* html/canvas/WebGLVertexArrayObjectOES.cpp:
(WebCore::WebGLVertexArrayObjectOES::setVertexAttribDivisor): Keep a record of the
divisor if we set it.
* html/canvas/WebGLVertexArrayObjectOES.h:
(WebCore::WebGLVertexArrayObjectOES::VertexAttribState::VertexAttribState):

* platform/graphics/GraphicsContext3D.h: New enum.
* platform/graphics/mac/GraphicsContext3DMac.mm:
(WebCore::GraphicsContext3D::drawArraysInstanced): The actual calls into OpenGL.
(WebCore::GraphicsContext3D::drawElementsInstanced): Ditto.
(WebCore::GraphicsContext3D::vertexAttribDivisor): Ditto.

* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: Empty implementations
for non-mac platforms.

* platform/graphics/ios/GraphicsContext3DIOS.h: Define the iOS names for the
functions.

LayoutTests: Implement ANGLE_instanced_arrays
https://bugs.webkit.org/show_bug.cgi?id=127257

Reviewed by Brent Fulgham.

Copied a slightly modified version of the Khronos instanced
arrays test (mostly modified due to the fact this comes from
an in-progress update to the test suite).

* fast/canvas/webgl/angle-instanced-arrays-expected.txt: Added.
* fast/canvas/webgl/angle-instanced-arrays.html: Added.
* fast/canvas/webgl/resources/webgl-test-utils.js:
(WebGLTestUtils): Added some new functions that were missing, and
some output to a checkColor test.
* platform/efl/TestExpectations: Skip this for EFL.
* platform/mac-mountainlion/fast/canvas/webgl/angle-instanced-arrays-expected.txt: Not
supported on Mountain Lion.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162565 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent aaddc8bd
2014-01-22 Dean Jackson <dino@apple.com>
Implement ANGLE_instanced_arrays
https://bugs.webkit.org/show_bug.cgi?id=127257
Reviewed by Brent Fulgham.
Copied a slightly modified version of the Khronos instanced
arrays test (mostly modified due to the fact this comes from
an in-progress update to the test suite).
* fast/canvas/webgl/angle-instanced-arrays-expected.txt: Added.
* fast/canvas/webgl/angle-instanced-arrays.html: Added.
* fast/canvas/webgl/resources/webgl-test-utils.js:
(WebGLTestUtils): Added some new functions that were missing, and
some output to a checkColor test.
* platform/efl/TestExpectations: Skip this for EFL.
* platform/mac-mountainlion/fast/canvas/webgl/angle-instanced-arrays-expected.txt: Not
supported on Mountain Lion.
2014-01-22 Zalan Bujtas <zalan@apple.com>
Unreviewed Apple Windows port gardering after r162553.
CONSOLE MESSAGE: WebGL: INVALID_ENUM: getVertexAttrib: invalid parameter name
CONSOLE MESSAGE: WebGL: INVALID_VALUE: vertexAttribDivisor: index out of range
CONSOLE MESSAGE: WebGL: INVALID_VALUE: drawArraysInstanced: primcount < 0
CONSOLE MESSAGE: WebGL: INVALID_VALUE: drawArraysInstanced: first or count < 0
CONSOLE MESSAGE: WebGL: INVALID_OPERATION: drawArraysInstanced: attempt to access out of bounds arrays
CONSOLE MESSAGE: WebGL: INVALID_ENUM: drawArraysInstanced: invalid draw mode
CONSOLE MESSAGE: WebGL: INVALID_ENUM: drawArraysInstanced: invalid draw mode
CONSOLE MESSAGE: WebGL: INVALID_ENUM: drawArraysInstanced: invalid draw mode
CONSOLE MESSAGE: WebGL: INVALID_VALUE: drawElementsInstanced: primcount < 0
CONSOLE MESSAGE: WebGL: INVALID_VALUE: drawElementsInstanced: count or offset < 0
CONSOLE MESSAGE: WebGL: INVALID_OPERATION: drawElementsInstanced: attempt to access out of bounds arrays
CONSOLE MESSAGE: WebGL: INVALID_ENUM: drawElementsInstanced: invalid draw mode
CONSOLE MESSAGE: WebGL: INVALID_ENUM: drawElementsInstanced: invalid draw mode
CONSOLE MESSAGE: WebGL: INVALID_ENUM: drawElementsInstanced: invalid draw mode
This test verifies the functionality of the ANGLE_instanced_arrays extension, if it is available.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS WebGL context exists
Testing VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE with extension disabled
PASS getError was expected value: INVALID_ENUM : VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE should not be queryable if extension is disabled
PASS Successfully enabled ANGLE_instanced_arrays extension
PASS ANGLE_instanced_arrays listed as supported and getExtension succeeded
Testing VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE with extension enabled
PASS ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE is 0x88FE
PASS Vertex attribute 0 must has a default divisor of 0
PASS Vertex attribute 1 must has a default divisor of 0
PASS Vertex attribute 2 must has a default divisor of 0
PASS Vertex attribute 3 must has a default divisor of 0
PASS Vertex attribute 4 must has a default divisor of 0
PASS Vertex attribute 5 must has a default divisor of 0
PASS Vertex attribute 6 must has a default divisor of 0
PASS Vertex attribute 7 must has a default divisor of 0
PASS Vertex attribute 8 must has a default divisor of 0
PASS Vertex attribute 9 must has a default divisor of 0
PASS Vertex attribute 10 must has a default divisor of 0
PASS Vertex attribute 11 must has a default divisor of 0
PASS Vertex attribute 12 must has a default divisor of 0
PASS Vertex attribute 13 must has a default divisor of 0
PASS Vertex attribute 14 must has a default divisor of 0
PASS Vertex attribute 15 must has a default divisor of 0
PASS getError was expected value: INVALID_VALUE : vertexAttribDivisorANGLE index set greater than or equal to MAX_VERTEX_ATTRIBS should be an invalid value
PASS getError was expected value: NO_ERROR : vertexAttribDivisorANGLE index set less than MAX_VERTEX_ATTRIBS should succeed
PASS Set value of VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE matches expecation
Testing that getExtension() returns the same object each time
PASS gl.getExtension("ANGLE_instanced_arrays").myProperty is 2
Testing various draws for valid built-in function behavior
Testing drawArraysInstancedANGLE
PASS Color was 255,0,0,255
PASS Color was 0,255,0,255
PASS Color was 0,0,255,255
PASS Color was 255,255,0,255
PASS getError was expected value: INVALID_VALUE : drawArraysInstancedANGLE cannot have a primcount less than 0
PASS getError was expected value: INVALID_VALUE : drawArraysInstancedANGLE cannot have a count less than 0
PASS getError was expected value: INVALID_OPERATION : There must be at least one vertex attribute with a divisor of zero when calling drawArraysInstancedANGLE
PASS getError was expected value: NO_ERROR : drawArraysInstancedANGLE with POINTS should succeed
PASS getError was expected value: NO_ERROR : drawArraysInstancedANGLE with LINES should succeed
PASS getError was expected value: NO_ERROR : drawArraysInstancedANGLE with LINE_LIST should return succeed
PASS getError was expected value: NO_ERROR : drawArraysInstancedANGLE with TRIANGLE_LIST should succeed
PASS getError was expected value: INVALID_ENUM : drawArraysInstancedANGLE with QUAD_STRIP should return INVALID_ENUM
PASS getError was expected value: INVALID_ENUM : drawArraysInstancedANGLE with QUADS should return INVALID_ENUM
PASS getError was expected value: INVALID_ENUM : drawArraysInstancedANGLE with POLYGON should return INVALID_ENUM
Testing drawElementsInstancedANGLE
PASS Color was 255,0,0,255
PASS Color was 0,255,0,255
PASS Color was 0,0,255,255
PASS Color was 255,255,0,255
PASS getError was expected value: INVALID_VALUE : drawElementsInstancedANGLE cannot have a primcount less than 0
PASS getError was expected value: INVALID_VALUE : drawElementsInstancedANGLE cannot have a count less than 0
PASS getError was expected value: INVALID_OPERATION : There must be at least one vertex attribute with a divisor of zero when calling drawElementsInstancedANGLE
PASS getError was expected value: NO_ERROR : drawElementsInstancedANGLE with UNSIGNED_BYTE should succeed
PASS getError was expected value: NO_ERROR : drawElementsInstancedANGLE with POINTS should succeed
PASS getError was expected value: NO_ERROR : drawElementsInstancedANGLE with LINES should succeed
PASS getError was expected value: NO_ERROR : drawElementsInstancedANGLE with LINE_LIST should return succeed
PASS getError was expected value: NO_ERROR : drawElementsInstancedANGLE with TRIANGLE_LIST should succeed
PASS getError was expected value: INVALID_ENUM : drawElementsInstancedANGLE with QUAD_STRIP should return INVALID_ENUM
PASS getError was expected value: INVALID_ENUM : drawElementsInstancedANGLE with QUADS should return INVALID_ENUM
PASS getError was expected value: INVALID_ENUM : drawElementsInstancedANGLE with POLYGON should return INVALID_ENUM
PASS successfullyParsed is true
TEST COMPLETE
This diff is collapsed.
......@@ -360,6 +360,125 @@ var setupQuad = function (
return objects;
};
/**
* Creates a unit quad with only positions of a given resolution.
* @param {!WebGLRenderingContext} gl The WebGLRenderingContext to use.
* @param {number} gridRes The resolution of the mesh grid,
* expressed in the number of quads across and down.
* @param {number} opt_positionLocation The attrib location for position.
*/
var setupIndexedQuad = function (
gl, gridRes, opt_positionLocation, opt_flipOddTriangles) {
return setupIndexedQuadWithOptions(gl,
{ gridRes: gridRes,
positionLocation: opt_positionLocation,
flipOddTriangles: opt_flipOddTriangles
});
};
/**
* Creates a quad with various options.
* @param {!WebGLRenderingContext} gl The WebGLRenderingContext to use.
* @param {!Object) options The options. See below.
* @return {!Array.<WebGLBuffer>} The created buffers.
* [positions, <colors>, indices]
*
* Options:
* gridRes: number of quads across and down grid.
* positionLocation: attrib location for position
* flipOddTriangles: reverse order of vertices of every other
* triangle
* positionOffset: offset added to each vertex
* positionMult: multipier for each vertex
* colorLocation: attrib location for vertex colors. If
* undefined no vertex colors will be created.
*/
var setupIndexedQuadWithOptions = function (gl, options) {
var positionLocation = options.positionLocation || 0;
var objects = [];
var gridRes = options.gridRes || 1;
var positionOffset = options.positionOffset || 0;
var positionMult = options.positionMult || 1;
var vertsAcross = gridRes + 1;
var numVerts = vertsAcross * vertsAcross;
var positions = new Float32Array(numVerts * 3);
var indices = new Uint16Array(6 * gridRes * gridRes);
var poffset = 0;
for (var yy = 0; yy <= gridRes; ++yy) {
for (var xx = 0; xx <= gridRes; ++xx) {
positions[poffset + 0] = (-1 + 2 * xx / gridRes) * positionMult + positionOffset;
positions[poffset + 1] = (-1 + 2 * yy / gridRes) * positionMult + positionOffset;
positions[poffset + 2] = 0;
poffset += 3;
}
}
var buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STATIC_DRAW);
gl.enableVertexAttribArray(positionLocation);
gl.vertexAttribPointer(positionLocation, 3, gl.FLOAT, false, 0, 0);
objects.push(buf);
if (options.colorLocation !== undefined) {
var colors = new Float32Array(numVerts * 4);
for (var yy = 0; yy <= gridRes; ++yy) {
for (var xx = 0; xx <= gridRes; ++xx) {
if (options.color !== undefined) {
colors[poffset + 0] = options.color[0];
colors[poffset + 1] = options.color[1];
colors[poffset + 2] = options.color[2];
colors[poffset + 3] = options.color[3];
} else {
colors[poffset + 0] = xx / gridRes;
colors[poffset + 1] = yy / gridRes;
colors[poffset + 2] = (xx / gridRes) * (yy / gridRes);
colors[poffset + 3] = (yy % 2) * 0.5 + 0.5;
}
poffset += 4;
}
}
var buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
gl.enableVertexAttribArray(options.colorLocation);
gl.vertexAttribPointer(options.colorLocation, 4, gl.FLOAT, false, 0, 0);
objects.push(buf);
}
var tbase = 0;
for (var yy = 0; yy < gridRes; ++yy) {
var index = yy * vertsAcross;
for (var xx = 0; xx < gridRes; ++xx) {
indices[tbase + 0] = index + 0;
indices[tbase + 1] = index + 1;
indices[tbase + 2] = index + vertsAcross;
indices[tbase + 3] = index + vertsAcross;
indices[tbase + 4] = index + 1;
indices[tbase + 5] = index + vertsAcross + 1;
if (options.flipOddTriangles) {
indices[tbase + 4] = index + vertsAcross + 1;
indices[tbase + 5] = index + 1;
}
index += 1;
tbase += 6;
}
}
var buf = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buf);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
objects.push(buf);
return objects;
};
/**
* Fills the given texture with a solid color
* @param {!WebGLContext} gl The WebGLContext to use.
......@@ -474,6 +593,128 @@ var drawIndexedQuad = function(gl, gridRes, opt_color) {
gl.drawElements(gl.TRIANGLES, gridRes * 6, gl.UNSIGNED_SHORT, 0);
};
/**
* Draws a previously setupIndexedQuad
* @param {!WebGLRenderingContext} gl The WebGLRenderingContext to use.
* @param {number} gridRes Resolution of grid.
* @param {!Array.<number>} opt_color The color to fill clear with before
* drawing. A 4 element array where each element is in the range 0 to
* 255. Default [255, 255, 255, 255]
*/
var clearAndDrawIndexedQuad = function(gl, gridRes, opt_color) {
opt_color = opt_color || [255, 255, 255, 255];
gl.clearColor(
opt_color[0] / 255,
opt_color[1] / 255,
opt_color[2] / 255,
opt_color[3] / 255);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
drawIndexedQuad(gl, gridRes);
};
/**
* Clips a range to min, max
* (Eg. clipToRange(-5,7,0,20) would return {value:0,extent:2}
* @param {number} value start of range
* @param {number} extent extent of range
* @param {number} min min.
* @param {number} max max.
* @return {!{value:number,extent:number} The clipped value.
*/
var clipToRange = function(value, extent, min, max) {
if (value < min) {
extent -= min - value;
value = min;
}
var end = value + extent;
if (end > max) {
extent -= end - max;
}
if (extent < 0) {
value = max;
extent = 0;
}
return {value:value, extent: extent};
};
/**
* Determines if the passed context is an instance of a WebGLRenderingContext
* or later variant (like WebGL2RenderingContext)
* @param {CanvasRenderingContext} ctx The context to check.
*/
var isWebGLContext = function(ctx) {
if (ctx instanceof WebGLRenderingContext)
return true;
if ('WebGL2RenderingContext' in window && ctx instanceof WebGL2RenderingContext)
return true;
return false;
};
/**
* Checks that a portion of a canvas is 1 color.
* @param {!WebGLRenderingContext|CanvasRenderingContext2D} gl The
* WebGLRenderingContext or 2D context to use.
* @param {number} x left corner of region to check.
* @param {number} y bottom corner of region to check in case of checking from
* a GL context or top corner in case of checking from a 2D context.
* @param {number} width width of region to check.
* @param {number} height width of region to check.
* @param {!Array.<number>} color The color expected. A 4 element array where
* each element is in the range 0 to 255.
* @param {number} opt_errorRange Optional. Acceptable error in
* color checking. 0 by default.
* @param {!function()} sameFn Function to call if all pixels
* are the same as color.
* @param {!function()} differentFn Function to call if a pixel
* is different than color
* @param {!function()} logFn Function to call for logging.
*/
var checkCanvasRectColor = function(gl, x, y, width, height, color, opt_errorRange, sameFn, differentFn, logFn) {
if (isWebGLContext(gl) && !gl.getParameter(gl.FRAMEBUFFER_BINDING)) {
// We're reading the backbuffer so clip.
var xr = clipToRange(x, width, 0, gl.canvas.width);
var yr = clipToRange(y, height, 0, gl.canvas.height);
if (!xr.extent || !yr.extent) {
logFn("checking rect: effective width or heigh is zero");
sameFn();
return;
}
x = xr.value;
y = yr.value;
width = xr.extent;
height = yr.extent;
}
var errorRange = opt_errorRange || 0;
if (!errorRange.length) {
errorRange = [errorRange, errorRange, errorRange, errorRange]
}
var buf;
if (isWebGLContext(gl)) {
buf = new Uint8Array(width * height * 4);
gl.readPixels(x, y, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
} else {
buf = gl.getImageData(x, y, width, height).data;
}
for (var i = 0; i < width * height; ++i) {
var offset = i * 4;
for (var j = 0; j < color.length; ++j) {
if (Math.abs(buf[offset + j] - color[j]) > errorRange[j]) {
differentFn();
var was = buf[offset + 0].toString();
for (j = 1; j < color.length; ++j) {
was += "," + buf[offset + j];
}
logFn('at (' + (x + (i % width)) + ', ' + (y + Math.floor(i / width)) +
') expected: ' + color + ' was ' + was);
return;
}
}
}
sameFn();
};
/**
* Checks that a portion of a canvas is 1 color.
* @param {!WebGLContext} gl The WebGLContext to use.
......@@ -506,6 +747,9 @@ var checkCanvasRect = function(gl, x, y, width, height, color, msg, errorRange)
}
}
}
if (!msg) {
msg = "Color was " + color;
}
testPassed(msg);
};
......@@ -1331,11 +1575,13 @@ var waitForComposite = function(gl, callback) {
return {
cancelAnimFrame: cancelAnimFrame,
clipToRange: clipToRange,
create3DContext: create3DContext,
create3DContextWithWrapperThatThrowsOnGLError:
create3DContextWithWrapperThatThrowsOnGLError,
create3DContextWithWrapperThatThrowsOnGLError,
checkCanvas: checkCanvas,
checkCanvasRect: checkCanvasRect,
checkCanvasRectColor: checkCanvasRectColor,
createColoredTexture: createColoredTexture,
drawQuad: drawQuad,
drawIndexedQuad: drawIndexedQuad,
......@@ -1369,6 +1615,8 @@ return {
setupColorQuad: setupColorQuad,
setupProgram: setupProgram,
setupQuad: setupQuad,
setupIndexedQuad: setupIndexedQuad,
setupIndexedQuadWithOptions: setupIndexedQuadWithOptions,
setupSimpleTextureFragmentShader: setupSimpleTextureFragmentShader,
setupSimpleTextureProgram: setupSimpleTextureProgram,
setupSimpleTextureVertexShader: setupSimpleTextureVertexShader,
......
......@@ -1681,6 +1681,9 @@ webgl/conformance/ogles/GL/sin/sin_001_to_006.html [ Failure ]
webgl/conformance/ogles/GL/vec3/vec3_001_to_008.html [ Failure ]
webgl/conformance/textures/texture-attachment-formats.html [ Failure ]
# ANGLE_instanced_arrays not implemented on efl
fast/canvas/webgl/angle-instanced-arrays.html [ Skip ]
# Text rendering is overflowing region
webkit.org/b/122511 fast/regions/selection/selecting-text-ignoring-region-horiz-bt.html [ ImageOnlyFailure ]
webkit.org/b/122511 fast/regions/selection/selecting-text-ignoring-region-vert-lr.html [ ImageOnlyFailure ]
......
CONSOLE MESSAGE: WebGL: INVALID_ENUM: getVertexAttrib: invalid parameter name
This test verifies the functionality of the ANGLE_instanced_arrays extension, if it is available.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS WebGL context exists
Testing VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE with extension disabled
PASS getError was expected value: INVALID_ENUM : VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE should not be queryable if extension is disabled
PASS No ANGLE_instanced_arrays support -- this is legal
PASS ANGLE_instanced_arrays not listed as supported and getExtension failed -- this is legal
PASS successfullyParsed is true
TEST COMPLETE
......@@ -496,6 +496,7 @@ set(WebCore_IDL_FILES
html/ValidityState.idl
html/VoidCallback.idl
html/canvas/ANGLEInstancedArrays.idl
html/canvas/CanvasGradient.idl
html/canvas/CanvasPattern.idl
html/canvas/CanvasProxy.idl
......@@ -1492,6 +1493,7 @@ set(WebCore_SOURCES
html/ValidationMessage.cpp
html/WeekInputType.cpp
html/canvas/ANGLEInstancedArrays.cpp
html/canvas/CanvasContextAttributes.cpp
html/canvas/CanvasGradient.cpp
html/canvas/CanvasPathMethods.cpp
......@@ -2664,6 +2666,7 @@ if (ENABLE_WEBGL)
add_definitions(-DWTF_USE_3D_GRAPHICS=1)
list(APPEND WebCore_SOURCES
html/canvas/ANGLEInstancedArrays.cpp
html/canvas/EXTDrawBuffers.cpp
html/canvas/EXTTextureFilterAnisotropic.cpp
html/canvas/OESElementIndexUint.cpp
......@@ -2700,6 +2703,7 @@ if (ENABLE_WEBGL)
html/canvas/WebGLVertexArrayObjectOES.cpp
)
list(APPEND WebCore_IDL_FILES
html/canvas/ANGLEInstancedArrays.idl
html/canvas/EXTDrawBuffers.idl
html/canvas/EXTTextureFilterAnisotropic.idl
html/canvas/OESElementIndexUint.idl
......
2014-01-22 Dean Jackson <dino@apple.com>
[WebGL] Implement ANGLE_instanced_arrays
https://bugs.webkit.org/show_bug.cgi?id=127257
Reviewed by Brent Fulgham.
Implement the instanced drawing WebGL extension,
ANGLE_instanced_arrays. This is currently Mac-only,
but should be portable to other platforms if their
OpenGL exposes the functions. It's also done in a way
that will make exposing it to WebGL2 simple.
Test: fast/canvas/webgl/angle-instanced-arrays.html
* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
Add the new files to all the build systems.
* bindings/js/JSWebGLRenderingContextCustom.cpp:
(WebCore::toJS): Link JS side to C++ side.
* html/canvas/ANGLEInstancedArrays.cpp: Added.
(WebCore::ANGLEInstancedArrays::ANGLEInstancedArrays):
* html/canvas/ANGLEInstancedArrays.h: Added.
* html/canvas/ANGLEInstancedArrays.idl: Added.
New boilerplate files that expose the extension methods.
* html/canvas/WebGLExtension.h: New extension enum.
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::validateVertexAttributes): Add an optional
parameter representing the number of instance primitives we are asked
to draw. Use that for the draw count if looking at an instanced attribute.
Also make sure we see at least one non-instanced attribute.
(WebCore::WebGLRenderingContext::validateDrawArrays): Update this so it could
be used from either drawArrays or drawArraysInstanced.
(WebCore::WebGLRenderingContext::drawArrays):
(WebCore::WebGLRenderingContext::validateDrawElements): Same here, now can be
used by the instanced and non-instanced versions.
(WebCore::WebGLRenderingContext::drawElements):
(WebCore::WebGLRenderingContext::getExtension): Create and return the new extension.
(WebCore::WebGLRenderingContext::getSupportedExtensions): Add new extension to the list.
(WebCore::WebGLRenderingContext::getVertexAttrib): Intercept a query to the divisor
attribute and return the value we kept in the state.
(WebCore::WebGLRenderingContext::drawArraysInstanced): Call the GC3D method.
(WebCore::WebGLRenderingContext::drawElementsInstanced): Ditto.
(WebCore::WebGLRenderingContext::vertexAttribDivisor): Ditto.
* html/canvas/WebGLRenderingContext.h: Define the new methods and parameters.
* html/canvas/WebGLVertexArrayObjectOES.cpp:
(WebCore::WebGLVertexArrayObjectOES::setVertexAttribDivisor): Keep a record of the
divisor if we set it.
* html/canvas/WebGLVertexArrayObjectOES.h:
(WebCore::WebGLVertexArrayObjectOES::VertexAttribState::VertexAttribState):
* platform/graphics/GraphicsContext3D.h: New enum.
* platform/graphics/mac/GraphicsContext3DMac.mm:
(WebCore::GraphicsContext3D::drawArraysInstanced): The actual calls into OpenGL.
(WebCore::GraphicsContext3D::drawElementsInstanced): Ditto.
(WebCore::GraphicsContext3D::vertexAttribDivisor): Ditto.
* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp: Empty implementations
for non-mac platforms.
* platform/graphics/ios/GraphicsContext3DIOS.h: Define the iOS names for the
functions.
2014-01-22 Zalan Bujtas <zalan@apple.com>
[CSS Shapes] shape-inside rectangle layout can fail
......@@ -27,6 +27,9 @@
#include "HTMLElementFactory.cpp"
#include "HTMLEntityTable.cpp"
#if ENABLE(WEBGL)
#include "JSANGLEInstancedArrays.cpp"
#endif
#include "JSAbstractWorker.cpp"
#include "JSAttr.cpp"
#include "JSBarProp.cpp"
......
......@@ -408,6 +408,7 @@ BINDING_IDLS = \
$(WebCore)/html/TimeRanges.idl \
$(WebCore)/html/ValidityState.idl \
$(WebCore)/html/VoidCallback.idl \
$(WebCore)/html/canvas/ANGLEInstancedArrays.idl \
$(WebCore)/html/canvas/CanvasGradient.idl \
$(WebCore)/html/canvas/CanvasPattern.idl \
$(WebCore)/html/canvas/CanvasProxy.idl \
......
......@@ -28,6 +28,8 @@ webcore_built_sources += \
DerivedSources/WebCore/InspectorWebFrontendDispatchers.h \
DerivedSources/WebCore/InspectorWebTypeBuilders.cpp \
DerivedSources/WebCore/InspectorWebTypeBuilders.h \
DerivedSources/WebCore/JSANGLEInstancedArrays.cpp \
DerivedSources/WebCore/JSANGLEInstancedArrays.h \
DerivedSources/WebCore/JSAbstractWorker.cpp \
DerivedSources/WebCore/JSAbstractWorker.h \
DerivedSources/WebCore/JSAllAudioCapabilities.cpp \
......@@ -1506,6 +1508,7 @@ dom_binding_idls += \
$(WebCore)/html/TimeRanges.idl \
$(WebCore)/html/ValidityState.idl \
$(WebCore)/html/VoidCallback.idl \
$(WebCore)/html/canvas/ANGLEInstancedArrays.idl \
$(WebCore)/html/canvas/CanvasGradient.idl \
$(WebCore)/html/canvas/CanvasPattern.idl \
$(WebCore)/html/canvas/CanvasProxy.idl \
......@@ -3240,6 +3243,8 @@ webcore_sources += \
Source/WebCore/html/BaseTextInputType.h \
Source/WebCore/html/ButtonInputType.cpp \
Source/WebCore/html/ButtonInputType.h \
Source/WebCore/html/canvas/ANGLEInstancedArrays.cpp \
Source/WebCore/html/canvas/ANGLEInstancedArrays.h \
Source/WebCore/html/canvas/CanvasContextAttributes.cpp \
Source/WebCore/html/canvas/CanvasContextAttributes.h \
Source/WebCore/html/canvas/CanvasGradient.cpp \
......
......@@ -290,6 +290,20 @@
</ClCompile>
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\CSSPropertyNames.cpp" />
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\CSSValueKeywords.cpp" />
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSANGLEInstancedArrays.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSEXTDrawBuffers.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
......@@ -6542,6 +6556,7 @@
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">ICUVersion.h</ForcedIncludeFiles>
<ForcedIncludeFiles Condition="'$(Configuration)|$(Platform)'=='Production|x64'">ICUVersion.h</ForcedIncludeFiles>
</ClCompile>
<ClCompile Include="..\html\canvas\ANGLEInstancedArrays.cpp" />
<ClCompile Include="..\html\canvas\CanvasContextAttributes.cpp" />
<ClCompile Include="..\html\canvas\CanvasPathMethods.cpp" />
<ClCompile Include="..\html\canvas\EXTDrawBuffers.cpp" />
......@@ -18553,6 +18568,7 @@
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\XMLViewerCSS.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\XMLViewerJS.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\XPathGrammar.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSANGLEInstancedArrays.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSEXTDrawBuffers.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSEXTTextureFilterAnisotropic.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSOESElementIndexUint.h" />
......@@ -18653,6 +18669,7 @@
<ClInclude Include="..\ForwardingHeaders\runtime\WeakGCMap.h" />
<ClInclude Include="..\ForwardingHeaders\runtime\WriteBarrier.h" />
<ClInclude Include="..\ForwardingHeaders\yarr\YarrJIT.h" />
<ClInclude Include="..\html\canvas\ANGLEInstancedArrays.h" />
<ClInclude Include="..\html\canvas\CanvasContextAttributes.h" />
<ClInclude Include="..\html\canvas\CanvasPathMethods.h" />
<ClInclude Include="..\html\canvas\EXTDrawBuffers.h" />
......@@ -6592,6 +6592,9 @@
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSWebGLVertexArrayObjectOES.cpp">
<Filter>DerivedSources</Filter>
</ClCompile>
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSANGLEInstancedArrays.cpp">
<Filter>DerivedSources</Filter>
</ClCompile>
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSEXTDrawBuffers.cpp">
<Filter>DerivedSources</Filter>
</ClCompile>
......@@ -6619,6 +6622,9 @@
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSOESVertexArrayObject.cpp">
<Filter>DerivedSources</Filter>
</ClCompile>
<ClCompile Include="..\html\canvas\ANGLEInstancedArrays.cpp">
<Filter>html\canvas</Filter>
</ClCompile>
<ClCompile Include="..\html\canvas\WebGLBuffer.cpp">
<Filter>html\canvas</Filter>
</ClCompile>
......@@ -14464,6 +14470,12 @@
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSOESVertexArrayObject.h">
<Filter>DerivedSources</Filter>
</ClInclude>
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\WebCore\DerivedSources\JSANGLEInstancedArrays.h">
<Filter>DerivedSources</Filter>
</ClInclude>
<ClInclude Include="..\html\canvas\ANGLEInstancedArrays.h">
<Filter>html\canvas</Filter>
</ClInclude>
<ClInclude Include="..\html\canvas\WebGLActiveInfo.h">
<Filter>html\canvas</Filter>
</ClInclude>
......
......@@ -1194,6 +1194,9 @@
319AE063142D6B24006563A1 /* StyleFilterData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 319AE061142D6B24006563A1 /* StyleFilterData.cpp */; };
319AE064142D6B24006563A1 /* StyleFilterData.h in Headers */ = {isa = PBXBuildFile; fileRef = 319AE062142D6B24006563A1 /* StyleFilterData.h */; settings = {ATTRIBUTES = (Private, ); }; };
319FBD5F15D2F464009640A6 /* CachedImageClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 319FBD5D15D2F444009640A6 /* CachedImageClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
31A795C61888BADC00382F90 /* JSANGLEInstancedArrays.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31A795C41888BAD100382F90 /* JSANGLEInstancedArrays.cpp */; };
31A795C71888BCB200382F90 /* ANGLEInstancedArrays.h in Headers */ = {isa = PBXBuildFile; fileRef = 31A795C21888B72400382F90 /* ANGLEInstancedArrays.h */; };
31A795C81888BCB500382F90 /* ANGLEInstancedArrays.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31A795C11888B72400382F90 /* ANGLEInstancedArrays.cpp */; };
31AB5000122878A2001A7DB0 /* GraphicsContext3DIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 31AB4FFF122878A2001A7DB0 /* GraphicsContext3DIOS.h */; };
31C0FF210E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31C0FF1B0E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp */; };
31C0FF220E4CEB6E007D6FE5 /* WebKitAnimationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 31C0FF1C0E4CEB6E007D6FE5 /* WebKitAnimationEvent.h */; };
......@@ -8068,6 +8071,11 @@
319AE061142D6B24006563A1 /* StyleFilterData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StyleFilterData.cpp; path = style/StyleFilterData.cpp; sourceTree = "<group>"; };
319AE062142D6B24006563A1 /* StyleFilterData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StyleFilterData.h; path = style/StyleFilterData.h; sourceTree = "<group>"; };
319FBD5D15D2F444009640A6 /* CachedImageClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedImageClient.h; sourceTree = "<group>"; };
31A795C11888B72400382F90 /* ANGLEInstancedArrays.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ANGLEInstancedArrays.cpp; path = canvas/ANGLEInstancedArrays.cpp; sourceTree = "<group>"; };
31A795C21888B72400382F90 /* ANGLEInstancedArrays.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ANGLEInstancedArrays.h; path = canvas/ANGLEInstancedArrays.h; sourceTree = "<group>"; };
31A795C31888B72400382F90 /* ANGLEInstancedArrays.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = ANGLEInstancedArrays.idl; path = canvas/ANGLEInstancedArrays.idl; sourceTree = "<group>"; };
31A795C41888BAD100382F90 /* JSANGLEInstancedArrays.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSANGLEInstancedArrays.cpp; sourceTree = "<group>"; };
31A795C51888BAD100382F90 /* JSANGLEInstancedArrays.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSANGLEInstancedArrays.h; sourceTree = "<group>"; };
31AB4FFF122878A2001A7DB0 /* GraphicsContext3DIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContext3DIOS.h; sourceTree = "<group>"; };
31C0FF1B0E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitAnimationEvent.cpp; sourceTree = "<group>"; };
31C0FF1C0E4CEB6E007D6FE5 /* WebKitAnimationEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitAnimationEvent.h; sourceTree = "<group>"; };
......@@ -15437,6 +15445,9 @@
49484FAE102CF01E00187DD3 /* canvas */ = {
isa = PBXGroup;
children = (
31A795C11888B72400382F90 /* ANGLEInstancedArrays.cpp */,
31A795C21888B72400382F90 /* ANGLEInstancedArrays.h */,
31A795C31888B72400382F90 /* ANGLEInstancedArrays.idl */,
6E4E91A710F7FB3100A2779C /* CanvasContextAttributes.cpp */,
6E4E91A810F7FB3100A2779C /* CanvasContextAttributes.h */,
49484FB3102CF23C00187DD3 /* CanvasGradient.cpp */,
......