Title: [121474] trunk
Revision
121474
Author
[email protected]
Date
2012-06-28 14:55:12 -0700 (Thu, 28 Jun 2012)

Log Message

Add support for DEPTH_STENCIL to WEBGL_depth_texture
https://bugs.webkit.org/show_bug.cgi?id=90109

Patch by Gregg Tavares <[email protected]> on 2012-06-28
Reviewed by Kenneth Russell.

Source/WebCore:

* html/canvas/WebGLDepthTexture.idl:
* html/canvas/WebGLFramebuffer.cpp:
* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::validateTexFuncFormatAndType):

LayoutTests:

* fast/canvas/webgl/webgl-depth-texture-expected.txt:
* fast/canvas/webgl/webgl-depth-texture.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (121473 => 121474)


--- trunk/LayoutTests/ChangeLog	2012-06-28 21:51:36 UTC (rev 121473)
+++ trunk/LayoutTests/ChangeLog	2012-06-28 21:55:12 UTC (rev 121474)
@@ -1,3 +1,13 @@
+2012-06-28  Gregg Tavares  <[email protected]>
+
+        Add support for DEPTH_STENCIL to WEBGL_depth_texture
+        https://bugs.webkit.org/show_bug.cgi?id=90109
+
+        Reviewed by Kenneth Russell.
+
+        * fast/canvas/webgl/webgl-depth-texture-expected.txt:
+        * fast/canvas/webgl/webgl-depth-texture.html:
+
 2012-06-28  Stephen Chenney  <[email protected]>
 
         [chromium] rebaseline svg text layouts?

Modified: trunk/LayoutTests/fast/canvas/webgl/webgl-depth-texture-expected.txt (121473 => 121474)


--- trunk/LayoutTests/fast/canvas/webgl/webgl-depth-texture-expected.txt	2012-06-28 21:51:36 UTC (rev 121473)
+++ trunk/LayoutTests/fast/canvas/webgl/webgl-depth-texture-expected.txt	2012-06-28 21:55:12 UTC (rev 121474)
@@ -28,6 +28,10 @@
 PASS gl.generateMipmap(gl.TEXTURE_2D) generated expected GL error: INVALID_OPERATION.
 PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) is gl.FRAMEBUFFER_COMPLETE
 PASS depth texture rendered correctly.
+PASS gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, tex, 0) generated expected GL error: NO_ERROR.
+PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) is not gl.FRAMEBUFFER_COMPLETE
+PASS gl.clear(gl.DEPTH_BUFFER_BIT) generated expected GL error: INVALID_FRAMEBUFFER_OPERATION.
+PASS gl.getError() is gl.NO_ERROR
 
 testing: UNSIGNED_INT
 PASS gl.texImage2D(gl.TEXTURE_CUBE_MAP_NEGATIVE_X, 1, gl.DEPTH_COMPONENT, 1, 1, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null) generated expected GL error: INVALID_OPERATION.
@@ -46,5 +50,31 @@
 PASS gl.generateMipmap(gl.TEXTURE_2D) generated expected GL error: INVALID_OPERATION.
 PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) is gl.FRAMEBUFFER_COMPLETE
 PASS depth texture rendered correctly.
+PASS gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, tex, 0) generated expected GL error: NO_ERROR.
+PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) is not gl.FRAMEBUFFER_COMPLETE
+PASS gl.clear(gl.DEPTH_BUFFER_BIT) generated expected GL error: INVALID_FRAMEBUFFER_OPERATION.
+PASS gl.getError() is gl.NO_ERROR
 
+testing: UNSIGNED_INT_24_8_WEBGL
+PASS gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 1, gl.DEPTH_STENCIL, 1, 1, 0, gl.DEPTH_STENCIL, ext.UNSIGNED_INT_24_8_WEBGL, null) generated expected GL error: INVALID_OPERATION.
+PASS gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 1, gl.DEPTH_STENCIL, 1, 1, 0, gl.DEPTH_STENCIL, ext.UNSIGNED_INT_24_8_WEBGL, null) generated expected GL error: INVALID_OPERATION.
+PASS gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 1, gl.DEPTH_STENCIL, 1, 1, 0, gl.DEPTH_STENCIL, ext.UNSIGNED_INT_24_8_WEBGL, null) generated expected GL error: INVALID_OPERATION.
+PASS gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 1, gl.DEPTH_STENCIL, 1, 1, 0, gl.DEPTH_STENCIL, ext.UNSIGNED_INT_24_8_WEBGL, null) generated expected GL error: INVALID_OPERATION.
+PASS gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 1, gl.DEPTH_STENCIL, 1, 1, 0, gl.DEPTH_STENCIL, ext.UNSIGNED_INT_24_8_WEBGL, null) generated expected GL error: INVALID_OPERATION.
+PASS gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_Y, 1, gl.DEPTH_STENCIL, 1, 1, 0, gl.DEPTH_STENCIL, ext.UNSIGNED_INT_24_8_WEBGL, null) generated expected GL error: INVALID_OPERATION.
+PASS gl.texImage2D(gl.TEXTURE_2D, 1, gl.DEPTH_STENCIL, 1, 1, 0, gl.DEPTH_STENCIL, ext.UNSIGNED_INT_24_8_WEBGL, null) generated expected GL error: INVALID_OPERATION.
+PASS gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, 1, 1, 0, gl.DEPTH_STENCIL, ext.UNSIGNED_INT_24_8_WEBGL, new Uint32Array(1)) generated expected GL error: INVALID_OPERATION.
+PASS gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, gl.DEPTH_STENCIL, ext.UNSIGNED_INT_24_8_WEBGL, canvas2) generated one of expected GL errors: INVALID_VALUE or INVALID_ENUM or INVALID_OPERATION.
+PASS gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, 0, 0, 1, 1, 0) generated one of expected GL errors: INVALID_ENUM or INVALID_OPERATION.
+PASS gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, 8, 8, 0, gl.DEPTH_STENCIL, ext.UNSIGNED_INT_24_8_WEBGL, null) generated expected GL error: NO_ERROR.
+PASS gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 1, 1, gl.DEPTH_STENCIL, ext.UNSIGNED_INT_24_8_WEBGL, new Uint32Array(1)) generated expected GL error: INVALID_OPERATION.
+PASS gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1) generated expected GL error: INVALID_OPERATION.
+PASS gl.generateMipmap(gl.TEXTURE_2D) generated expected GL error: INVALID_OPERATION.
+PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) is gl.FRAMEBUFFER_COMPLETE
+PASS depth texture rendered correctly.
+PASS gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, tex, 0) generated expected GL error: NO_ERROR.
+PASS gl.checkFramebufferStatus(gl.FRAMEBUFFER) is not gl.FRAMEBUFFER_COMPLETE
+PASS gl.clear(gl.DEPTH_BUFFER_BIT) generated expected GL error: INVALID_FRAMEBUFFER_OPERATION.
+PASS gl.getError() is gl.NO_ERROR
 
+

Modified: trunk/LayoutTests/fast/canvas/webgl/webgl-depth-texture.html (121473 => 121474)


--- trunk/LayoutTests/fast/canvas/webgl/webgl-depth-texture.html	2012-06-28 21:51:36 UTC (rev 121473)
+++ trunk/LayoutTests/fast/canvas/webgl/webgl-depth-texture.html	2012-06-28 21:55:12 UTC (rev 121474)
@@ -43,6 +43,7 @@
 var program = wtu.setupTexturedQuad(gl);
 var ext = null;
 var vao = null;
+var tex;
 var name;
 var supportedFormats;
 
@@ -144,13 +145,15 @@
     gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
 
     var types = [
-        {type: 'UNSIGNED_SHORT', data: 'new Uint16Array(1)' },
-        {type: 'UNSIGNED_INT',   data: 'new Uint32Array(1)' }
+        {obj: 'gl',  attachment: 'DEPTH_ATTACHMENT',         format: 'DEPTH_COMPONENT', type: 'UNSIGNED_SHORT',          data: 'new Uint16Array(1)' },
+        {obj: 'gl',  attachment: 'DEPTH_ATTACHMENT',         format: 'DEPTH_COMPONENT', type: 'UNSIGNED_INT',            data: 'new Uint32Array(1)' },
+        {obj: 'ext', attachment: 'DEPTH_STENCIL_ATTACHMENT', format: 'DEPTH_STENCIL',   type: 'UNSIGNED_INT_24_8_WEBGL', data: 'new Uint32Array(1)' }
     ];
 
     for (var ii = 0; ii < types.length; ++ii) {
         var typeInfo = types[ii];
         var type = typeInfo.type;
+        var typeStr = typeInfo.obj + '.' + type;
 
         debug("");
         debug("testing: " + type);
@@ -167,11 +170,11 @@
           'TEXTURE_CUBE_MAP_NEGATIVE_Z'
         ];
         for (var tt = 0; tt < targets.length; ++tt) {
-            shouldGenerateGLError(gl, gl.INVALID_OPERATION, 'gl.texImage2D(gl.' + targets[ii] + ', 1, gl.DEPTH_COMPONENT, 1, 1, 0, gl.DEPTH_COMPONENT, gl.' + type + ', null)');
+            shouldGenerateGLError(gl, gl.INVALID_OPERATION, 'gl.texImage2D(gl.' + targets[ii] + ', 1, gl.' + typeInfo.format + ', 1, 1, 0, gl.' + typeInfo.format + ', ' + typeStr + ', null)');
         }
 
         // check 2d textures.
-        var tex = gl.createTexture();
+        tex = gl.createTexture();
         gl.bindTexture(gl.TEXTURE_2D, tex);
         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
@@ -179,22 +182,22 @@
         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
 
         // test level > 0
-        shouldGenerateGLError(gl, gl.INVALID_OPERATION, 'gl.texImage2D(gl.TEXTURE_2D, 1, gl.DEPTH_COMPONENT, 1, 1, 0, gl.DEPTH_COMPONENT, gl.' + type + ', null)');
+        shouldGenerateGLError(gl, gl.INVALID_OPERATION, 'gl.texImage2D(gl.TEXTURE_2D, 1, gl.' + typeInfo.format + ', 1, 1, 0, gl.' + typeInfo.format + ', ' + typeStr + ', null)');
 
         // test with data
-        shouldGenerateGLError(gl, gl.INVALID_OPERATION, 'gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, 1, 1, 0, gl.DEPTH_COMPONENT, gl.' + type + ', ' + typeInfo.data + ')');
+        shouldGenerateGLError(gl, gl.INVALID_OPERATION, 'gl.texImage2D(gl.TEXTURE_2D, 0, gl.' + typeInfo.format + ', 1, 1, 0, gl.' + typeInfo.format + ', ' + typeStr + ', ' + typeInfo.data + ')');
 
         // test with canvas
-        shouldGenerateGLError(gl, [gl.INVALID_VALUE, gl.INVALID_ENUM, gl.INVALID_OPERATION], 'gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, gl.DEPTH_COMPONENT, gl.' + type  + ', canvas2)');
+        shouldGenerateGLError(gl, [gl.INVALID_VALUE, gl.INVALID_ENUM, gl.INVALID_OPERATION], 'gl.texImage2D(gl.TEXTURE_2D, 0, gl.' + typeInfo.format + ', gl.' + typeInfo.format + ', ' + typeStr  + ', canvas2)');
 
         // test copyTexImage2D
-        shouldGenerateGLError(gl, [gl.INVALID_ENUM, gl.INVALID_OPERATION], 'gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, 0, 0, 1, 1, 0)');
+        shouldGenerateGLError(gl, [gl.INVALID_ENUM, gl.INVALID_OPERATION], 'gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.' + typeInfo.format + ', 0, 0, 1, 1, 0)');
 
         // test real thing
-        shouldGenerateGLError(gl, gl.NO_ERROR, 'gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, ' + res + ', ' + res + ', 0, gl.DEPTH_COMPONENT, gl.' + type + ', null)');
+        shouldGenerateGLError(gl, gl.NO_ERROR, 'gl.texImage2D(gl.TEXTURE_2D, 0, gl.' + typeInfo.format + ', ' + res + ', ' + res + ', 0, gl.' + typeInfo.format + ', ' + typeStr + ', null)');
 
         // test texSubImage2D
-        shouldGenerateGLError(gl, gl.INVALID_OPERATION, 'gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 1, 1, gl.DEPTH_COMPONENT, gl.' + type  + ', ' + typeInfo.data + ')');
+        shouldGenerateGLError(gl, gl.INVALID_OPERATION, 'gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 1, 1, gl.' + typeInfo.format + ', ' + typeStr  + ', ' + typeInfo.data + ')');
 
         // test copyTexSubImage2D
         shouldGenerateGLError(gl, gl.INVALID_OPERATION, 'gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 1, 1)');
@@ -204,8 +207,9 @@
 
         var fbo = gl.createFramebuffer();
         gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
-        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, tex, 0);
-        //if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE)
+        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl[typeInfo.attachment], gl.TEXTURE_2D, tex, 0);
+        // TODO: remove this check if the spec is updated to require these combinations to work.
+        if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE)
         {
             // try adding a color buffer.
             var colorTex = gl.createTexture();
@@ -260,8 +264,9 @@
                 testFailed('R != B');
                 success = false;
             }
-            if (actualPixels[actual + 3] != 0xFF) {
-                testFailed('A != 255');
+            // ALPHA is implementation dependent
+            if (actualPixels[actual + 3] != 0xFF && actualPixels[actual + 3] != actualPixels[actual + 0]) {
+                testFailed('A != 255 && A != R');
                 success = false;
             }
 
@@ -289,6 +294,16 @@
         if (success) {
             testPassed("depth texture rendered correctly.");
         }
+
+        // check limitations
+        gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
+        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl[typeInfo.attachment], gl.TEXTURE_2D, null, 0);
+        var badAttachment = typeInfo.attachment == 'DEPTH_ATTACHMENT' ? 'DEPTH_STENCIL_ATTACHMENT' : 'DEPTH_ATTACHMENT';
+        shouldGenerateGLError(gl, gl.NO_ERROR, 'gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.' + badAttachment + ', gl.TEXTURE_2D, tex, 0)');
+        shouldNotBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
+        shouldGenerateGLError(gl, gl.INVALID_FRAMEBUFFER_OPERATION, 'gl.clear(gl.DEPTH_BUFFER_BIT)');
+        gl.bindFramebuffer(gl.FRAMEBUFFER, null);
+        shouldBe('gl.getError()', 'gl.NO_ERROR');
     }
 }
 

Modified: trunk/Source/WebCore/ChangeLog (121473 => 121474)


--- trunk/Source/WebCore/ChangeLog	2012-06-28 21:51:36 UTC (rev 121473)
+++ trunk/Source/WebCore/ChangeLog	2012-06-28 21:55:12 UTC (rev 121474)
@@ -1,3 +1,16 @@
+2012-06-28  Gregg Tavares  <[email protected]>
+
+        Add support for DEPTH_STENCIL to WEBGL_depth_texture
+        https://bugs.webkit.org/show_bug.cgi?id=90109
+
+        Reviewed by Kenneth Russell.
+
+        * html/canvas/WebGLDepthTexture.idl:
+        * html/canvas/WebGLFramebuffer.cpp:
+        * html/canvas/WebGLRenderingContext.cpp:
+        (WebCore):
+        (WebCore::WebGLRenderingContext::validateTexFuncFormatAndType):
+
 2012-06-28  James Robinson  <[email protected]>
 
         [chromium] Move chromium compositor implementation files into separate section in WebCore.gypi

Modified: trunk/Source/WebCore/html/canvas/WebGLDepthTexture.idl (121473 => 121474)


--- trunk/Source/WebCore/html/canvas/WebGLDepthTexture.idl	2012-06-28 21:51:36 UTC (rev 121473)
+++ trunk/Source/WebCore/html/canvas/WebGLDepthTexture.idl	2012-06-28 21:55:12 UTC (rev 121474)
@@ -27,7 +27,9 @@
     interface [
         Conditional=WEBGL,
         JSGenerateIsReachable=ImplContext,
-        OmitConstructor
+        OmitConstructor,
+        DoNotCheckConstants
     ] WebGLDepthTexture {
+        const unsigned int UNSIGNED_INT_24_8_WEBGL = 0x84FA;
     };
 }

Modified: trunk/Source/WebCore/html/canvas/WebGLFramebuffer.cpp (121473 => 121474)


--- trunk/Source/WebCore/html/canvas/WebGLFramebuffer.cpp	2012-06-28 21:51:36 UTC (rev 121473)
+++ trunk/Source/WebCore/html/canvas/WebGLFramebuffer.cpp	2012-06-28 21:55:12 UTC (rev 121474)
@@ -226,7 +226,11 @@
 
     void WebGLTextureAttachment::unattach(GraphicsContext3D* context, GC3Denum attachment)
     {
-        context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, attachment, m_target, 0, m_level);
+        if (attachment == GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT) {
+            context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::DEPTH_ATTACHMENT, m_target, 0, m_level);
+            context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::STENCIL_ATTACHMENT, m_target, 0, m_level);
+        } else
+            context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, attachment, m_target, 0, m_level);
     }
 
     bool isAttachmentComplete(WebGLFramebuffer::WebGLAttachment* attachedObject, GC3Denum attachment, const char** reason)

Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp (121473 => 121474)


--- trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2012-06-28 21:51:36 UTC (rev 121473)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp	2012-06-28 21:55:12 UTC (rev 121474)
@@ -4726,10 +4726,11 @@
     case GraphicsContext3D::RGB:
     case GraphicsContext3D::RGBA:
         break;
+    case GraphicsContext3D::DEPTH_STENCIL:
     case GraphicsContext3D::DEPTH_COMPONENT:
         if (m_webglDepthTexture)
             break;
-        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "DEPTH_COMPONENT texture format not enabled");
+        synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "depth texture formats not enabled");
         return false;
     default:
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture format");
@@ -4748,6 +4749,7 @@
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid texture type");
         return false;
     case GraphicsContext3D::UNSIGNED_INT:
+    case GraphicsContext3D::UNSIGNED_INT_24_8:
     case GraphicsContext3D::UNSIGNED_SHORT:
         if (m_webglDepthTexture)
             break;
@@ -4801,6 +4803,20 @@
           return false;
         }
         break;
+    case GraphicsContext3D::DEPTH_STENCIL:
+        if (!m_webglDepthTexture) {
+            synthesizeGLError(GraphicsContext3D::INVALID_ENUM, functionName, "invalid format. DEPTH_STENCIL not enabled");
+            return false;
+        }
+        if (type != GraphicsContext3D::UNSIGNED_INT_24_8) {
+            synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "invalid type for DEPTH_STENCIL format");
+            return false;
+        }
+        if (level > 0) {
+          synthesizeGLError(GraphicsContext3D::INVALID_OPERATION, functionName, "level must be 0 for DEPTH_STENCIL format");
+          return false;
+        }
+        break;
     default:
         ASSERT_NOT_REACHED();
     }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to