Commit 326c1776 authored by eric@webkit.org's avatar eric@webkit.org
Browse files

2010-04-02 Zhenyao Mo <zmo@google.com>

        Reviewed by Eric Seidel.

        Implement and test new framebuffer object attachment behavior.
        https://bugs.webkit.org/show_bug.cgi?id=35611

        * fast/canvas/webgl/framebuffer-object-attachment-expected.txt: Added, test framebuffer object attachment behavior.
        * fast/canvas/webgl/framebuffer-object-attachment.html: Added, framebuffer object attachment behavior.
        * fast/canvas/webgl/script-tests/gl-object-get-calls.js: DEPTH_COMPONENT is no longer a valid input, use DEPTH_COMPONENT16 instead.
        * platform/mac-snowleopard/Skipped: The bot does not support EXT_packed_depth_stencil, skip the framebuffer-object-attachment.html test.
2010-04-02  Zhenyao Mo  <zmo@google.com>

        Reviewed by Eric Seidel.

        Implement and test new framebuffer object attachment behavior.
        https://bugs.webkit.org/show_bug.cgi?id=35611

        Test: fast/canvas/webgl/framebuffer-object-attachment.html

        * html/canvas/WebGLFramebuffer.cpp: Keep track of attached stencil/depth renderbuffers in WebGLFramebuffer.
        (WebCore::WebGLFramebuffer::WebGLFramebuffer):
        (WebCore::WebGLFramebuffer::setIsAttached):
        * html/canvas/WebGLFramebuffer.h: Ditto.
        (WebCore::WebGLFramebuffer::isDepthAttached):
        (WebCore::WebGLFramebuffer::isStencilAttached):
        (WebCore::WebGLFramebuffer::isDepthStencilAttached):
        * html/canvas/WebGLRenderbuffer.cpp: Keep track of internalformat.
        (WebCore::WebGLRenderbuffer::WebGLRenderbuffer):
        * html/canvas/WebGLRenderbuffer.h: Ditto.
        (WebCore::WebGLRenderbuffer::setInternalformat):
        (WebCore::WebGLRenderbuffer::getInternalformat):
        * html/canvas/WebGLRenderingContext.cpp:
        (WebCore::WebGLRenderingContext::framebufferRenderbuffer): Detect stencil/depth buffer conflicts.
        (WebCore::WebGLRenderingContext::getFramebufferAttachmentParameter): Handling DEPTH_STENCIL case.
        (WebCore::WebGLRenderingContext::getRenderbufferParameter): Get correct WebGL internalformat.
        (WebCore::WebGLRenderingContext::renderbufferStorage): Detect illegal enums.
        * html/canvas/WebGLRenderingContext.idl: Add DEPTH_STENCIL enums.
        * platform/graphics/GraphicsContext3D.h: Add DEPTH_STENCIL enums.
        (WebCore::GraphicsContext3D::):
        * platform/graphics/mac/GraphicsContext3DMac.cpp: Map to correct DEPTH_STENCIL format.
        (WebCore::GraphicsContext3D::framebufferRenderbuffer):
        (WebCore::GraphicsContext3D::renderbufferStorage):
        (WebCore::GraphicsContext3D::getFramebufferAttachmentParameteriv):
2010-04-02  Zhenyao Mo  <zmo@google.com>

        Reviewed by Eric Seidel.

        Implement and test new framebuffer object attachment behavior.
        https://bugs.webkit.org/show_bug.cgi?id=35611

        Test: fast/canvas/webgl/framebuffer-object-attachment.html

        * src/WebGraphicsContext3DDefaultImpl.cpp: Map to correct DEPTH_STENCIL format.
        (WebKit::WebGraphicsContext3DDefaultImpl::framebufferRenderbuffer):
        (WebKit::WebGraphicsContext3DDefaultImpl::getFramebufferAttachmentParameteriv):
        (WebKit::WebGraphicsContext3DDefaultImpl::renderbufferStorage):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@57018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 32b91b00
2010-04-02 Zhenyao Mo <zmo@google.com>
Reviewed by Eric Seidel.
Implement and test new framebuffer object attachment behavior.
https://bugs.webkit.org/show_bug.cgi?id=35611
* fast/canvas/webgl/framebuffer-object-attachment-expected.txt: Added, test framebuffer object attachment behavior.
* fast/canvas/webgl/framebuffer-object-attachment.html: Added, framebuffer object attachment behavior.
* fast/canvas/webgl/script-tests/gl-object-get-calls.js: DEPTH_COMPONENT is no longer a valid input, use DEPTH_COMPONENT16 instead.
* platform/mac-snowleopard/Skipped: The bot does not support EXT_packed_depth_stencil, skip the framebuffer-object-attachment.html test.
2010-04-02 Zhenyao Mo <zmo@google.com>
 
Reviewed by Eric Seidel.
......
Test framebuffer object attachment behaviors
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Create renderbuffers
PASS gl = create3DContext() is non-null.
PASS depthBuffer = gl.createRenderbuffer() is non-null.
PASS gl.getError() is gl.NO_ERROR
PASS stencilBuffer = gl.createRenderbuffer() is non-null.
PASS gl.getError() is gl.NO_ERROR
PASS depthStencilBuffer = gl.createRenderbuffer() is non-null.
PASS gl.getError() is gl.NO_ERROR
Attach depth using DEPTH_ATTACHMENT
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.NO_ERROR
Attach depth using STENCIL_ATTACHMENT
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.INVALID_OPERATION
Attach depth using DEPTH_STENCIL_ATTACHMENT
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.INVALID_OPERATION
Attach stencil using STENCIL_ATTACHMENT
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.NO_ERROR
Attach stencil using DEPTH_ATTACHMENT
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.INVALID_OPERATION
Attach stencil using DEPTH_STENCIL_ATTACHMENT
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.INVALID_OPERATION
Attach depthStencil using DEPTH_STENCIL_ATTACHMENT
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.NO_ERROR
Attach depthStencil using DEPTH_ATTACHMENT
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.INVALID_OPERATION
Attach depthStencil using STENCIL_ATTACHMENT
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.INVALID_OPERATION
Attach depth, then stencil, causing conflict
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.NO_ERROR
PASS gl.getError() is gl.INVALID_OPERATION
Attach stencil, then depth, causing conflict
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.NO_ERROR
PASS gl.getError() is gl.INVALID_OPERATION
Attach depth, then depthStencil, causing conflict
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.NO_ERROR
PASS gl.getError() is gl.INVALID_OPERATION
Attach depthStencil, then depth, causing conflict
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.NO_ERROR
PASS gl.getError() is gl.INVALID_OPERATION
Attach stencil, then depthStencil, causing conflict
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.NO_ERROR
PASS gl.getError() is gl.INVALID_OPERATION
Attach depthStencil, then stencil, causing conflict
PASS fbo = gl.createFramebuffer() is non-null.
PASS gl.getError() is gl.NO_ERROR
PASS gl.getError() is gl.INVALID_OPERATION
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
var gl;
var fbo;
var depthBuffer;
var stencilBuffer;
var depthStencilBuffer;
var width = 2;
var height = 2;
function testAttachment(attachment, buffer, isConflicted)
{
shouldBeNonNull("fbo = gl.createFramebuffer()");
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, buffer);
shouldBe("gl.getError()", isConflicted ? "gl.INVALID_OPERATION" : "gl.NO_ERROR");
}
function testAttachments(attachment0, buffer0, attachment1, buffer1, isConflicted)
{
shouldBeNonNull("fbo = gl.createFramebuffer()");
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment0, gl.RENDERBUFFER, buffer0);
shouldBe("gl.getError()", "gl.NO_ERROR");
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment1, gl.RENDERBUFFER, buffer1);
shouldBe("gl.getError()", isConflicted ? "gl.INVALID_OPERATION" : "gl.NO_ERROR");
}
description("Test framebuffer object attachment behaviors");
debug("Create renderbuffers");
shouldBeNonNull("gl = create3DContext()");
shouldBeNonNull("depthBuffer = gl.createRenderbuffer()");
gl.bindRenderbuffer(gl.RENDERBUFFER, depthBuffer);
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
shouldBe("gl.getError()", "gl.NO_ERROR");
shouldBeNonNull("stencilBuffer = gl.createRenderbuffer()");
gl.bindRenderbuffer(gl.RENDERBUFFER, stencilBuffer);
gl.renderbufferStorage(gl.RENDERBUFFER, gl.STENCIL_INDEX8, width, height);
shouldBe("gl.getError()", "gl.NO_ERROR");
shouldBeNonNull("depthStencilBuffer = gl.createRenderbuffer()");
gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
shouldBe("gl.getError()", "gl.NO_ERROR");
debug("Attach depth using DEPTH_ATTACHMENT");
testAttachment(gl.DEPTH_ATTACHMENT, depthBuffer, false);
debug("Attach depth using STENCIL_ATTACHMENT");
testAttachment(gl.STENCIL_ATTACHMENT, depthBuffer, true);
debug("Attach depth using DEPTH_STENCIL_ATTACHMENT");
testAttachment(gl.DEPTH_STENCIL_ATTACHMENT, depthBuffer, true);
debug("Attach stencil using STENCIL_ATTACHMENT");
testAttachment(gl.STENCIL_ATTACHMENT, stencilBuffer, false);
debug("Attach stencil using DEPTH_ATTACHMENT");
testAttachment(gl.DEPTH_ATTACHMENT, stencilBuffer, true);
debug("Attach stencil using DEPTH_STENCIL_ATTACHMENT");
testAttachment(gl.DEPTH_STENCIL_ATTACHMENT, stencilBuffer, true);
debug("Attach depthStencil using DEPTH_STENCIL_ATTACHMENT");
testAttachment(gl.DEPTH_STENCIL_ATTACHMENT, depthStencilBuffer, false);
debug("Attach depthStencil using DEPTH_ATTACHMENT");
testAttachment(gl.DEPTH_ATTACHMENT, depthStencilBuffer, true);
debug("Attach depthStencil using STENCIL_ATTACHMENT");
testAttachment(gl.STENCIL_ATTACHMENT, depthStencilBuffer, true);
debug("Attach depth, then stencil, causing conflict");
testAttachments(gl.DEPTH_ATTACHMENT, depthBuffer, gl.STENCIL_ATTACHMENT, stencilBuffer, true);
debug("Attach stencil, then depth, causing conflict");
testAttachments(gl.STENCIL_ATTACHMENT, stencilBuffer, gl.DEPTH_ATTACHMENT, depthBuffer, true);
debug("Attach depth, then depthStencil, causing conflict");
testAttachments(gl.DEPTH_ATTACHMENT, depthBuffer, gl.DEPTH_STENCIL_ATTACHMENT, depthStencilBuffer, true);
debug("Attach depthStencil, then depth, causing conflict");
testAttachments(gl.DEPTH_STENCIL_ATTACHMENT, depthStencilBuffer, gl.DEPTH_ATTACHMENT, depthBuffer, true);
debug("Attach stencil, then depthStencil, causing conflict");
testAttachments(gl.DEPTH_ATTACHMENT, depthBuffer, gl.DEPTH_STENCIL_ATTACHMENT, depthStencilBuffer, true);
debug("Attach depthStencil, then stencil, causing conflict");
testAttachments(gl.DEPTH_STENCIL_ATTACHMENT, depthStencilBuffer, gl.STENCIL_ATTACHMENT, stencilBuffer, true);
successfullyParsed = true;
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
</html>
......@@ -52,7 +52,7 @@ var renderbuffer = gl.createRenderbuffer();
shouldBe('gl.getError()', '0');
gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
shouldBe('gl.getError()', '0');
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT, 2, 2);
gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, 2, 2);
shouldBe('gl.getError()', '0');
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, renderbuffer);
// FIXME: on some machines (in particular the WebKit commit bots) the
......
......@@ -113,3 +113,7 @@ fast/forms/search-event-delay.html
# Color bitmap fonts not supported on Snow Leopard
platform/mac/fonts/color-bitmap.html
# Snow Leopard bot does not support EXT_packed_depth_stencil, which is required by WebGL.
# https://bugs.webkit.org/show_bug.cgi?id=36925
fast/canvas/webgl/framebuffer-object-attachment.html
2010-04-02 Zhenyao Mo <zmo@google.com>
Reviewed by Eric Seidel.
Implement and test new framebuffer object attachment behavior.
https://bugs.webkit.org/show_bug.cgi?id=35611
Test: fast/canvas/webgl/framebuffer-object-attachment.html
* html/canvas/WebGLFramebuffer.cpp: Keep track of attached stencil/depth renderbuffers in WebGLFramebuffer.
(WebCore::WebGLFramebuffer::WebGLFramebuffer):
(WebCore::WebGLFramebuffer::setIsAttached):
* html/canvas/WebGLFramebuffer.h: Ditto.
(WebCore::WebGLFramebuffer::isDepthAttached):
(WebCore::WebGLFramebuffer::isStencilAttached):
(WebCore::WebGLFramebuffer::isDepthStencilAttached):
* html/canvas/WebGLRenderbuffer.cpp: Keep track of internalformat.
(WebCore::WebGLRenderbuffer::WebGLRenderbuffer):
* html/canvas/WebGLRenderbuffer.h: Ditto.
(WebCore::WebGLRenderbuffer::setInternalformat):
(WebCore::WebGLRenderbuffer::getInternalformat):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::framebufferRenderbuffer): Detect stencil/depth buffer conflicts.
(WebCore::WebGLRenderingContext::getFramebufferAttachmentParameter): Handling DEPTH_STENCIL case.
(WebCore::WebGLRenderingContext::getRenderbufferParameter): Get correct WebGL internalformat.
(WebCore::WebGLRenderingContext::renderbufferStorage): Detect illegal enums.
* html/canvas/WebGLRenderingContext.idl: Add DEPTH_STENCIL enums.
* platform/graphics/GraphicsContext3D.h: Add DEPTH_STENCIL enums.
(WebCore::GraphicsContext3D::):
* platform/graphics/mac/GraphicsContext3DMac.cpp: Map to correct DEPTH_STENCIL format.
(WebCore::GraphicsContext3D::framebufferRenderbuffer):
(WebCore::GraphicsContext3D::renderbufferStorage):
(WebCore::GraphicsContext3D::getFramebufferAttachmentParameteriv):
2010-04-02 Kent Tamura <tkent@chromium.org>
 
Reviewed by Darin Adler.
......@@ -39,10 +39,28 @@ PassRefPtr<WebGLFramebuffer> WebGLFramebuffer::create(WebGLRenderingContext* ctx
WebGLFramebuffer::WebGLFramebuffer(WebGLRenderingContext* ctx)
: CanvasObject(ctx)
, m_isDepthAttached(false)
, m_isStencilAttached(false)
, m_isDepthStencilAttached(false)
{
setObject(context()->graphicsContext3D()->createFramebuffer());
}
void WebGLFramebuffer::setIsAttached(unsigned long attachment, bool isAttached)
{
switch (attachment) {
case GraphicsContext3D::DEPTH_ATTACHMENT:
m_isDepthAttached = isAttached;
break;
case GraphicsContext3D::STENCIL_ATTACHMENT:
m_isStencilAttached = isAttached;
break;
case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
m_isDepthStencilAttached = isAttached;
break;
}
}
void WebGLFramebuffer::_deleteObject(Platform3DObject object)
{
context()->graphicsContext3D()->deleteFramebuffer(object);
......
......@@ -39,10 +39,21 @@ namespace WebCore {
static PassRefPtr<WebGLFramebuffer> create(WebGLRenderingContext*);
void setIsAttached(unsigned long attachment, bool isAttached);
bool isDepthAttached() const { return m_isDepthAttached; }
bool isStencilAttached() const { return m_isStencilAttached; }
bool isDepthStencilAttached() const { return m_isDepthStencilAttached; }
protected:
WebGLFramebuffer(WebGLRenderingContext*);
virtual void _deleteObject(Platform3DObject);
private:
bool m_isDepthAttached;
bool m_isStencilAttached;
bool m_isDepthStencilAttached;
};
} // namespace WebCore
......
......@@ -44,12 +44,14 @@ PassRefPtr<WebGLRenderbuffer> WebGLRenderbuffer::create(WebGLRenderingContext* c
WebGLRenderbuffer::WebGLRenderbuffer(WebGLRenderingContext* ctx)
: CanvasObject(ctx)
, m_internalformat(GraphicsContext3D::RGBA4)
{
setObject(context()->graphicsContext3D()->createRenderbuffer());
}
WebGLRenderbuffer::WebGLRenderbuffer(WebGLRenderingContext* ctx, Platform3DObject obj)
: CanvasObject(ctx)
, m_internalformat(GraphicsContext3D::RGBA4)
{
setObject(obj, false);
}
......
......@@ -43,11 +43,17 @@ namespace WebCore {
// FIXME: should consider canonicalizing these objects
static PassRefPtr<WebGLRenderbuffer> create(WebGLRenderingContext*, Platform3DObject renderbuffer);
void setInternalformat(unsigned long internalformat) { m_internalformat = internalformat; }
unsigned long getInternalformat() const { return m_internalformat; }
protected:
WebGLRenderbuffer(WebGLRenderingContext*);
WebGLRenderbuffer(WebGLRenderingContext*, Platform3DObject);
virtual void _deleteObject(Platform3DObject);
private:
unsigned long m_internalformat;
};
} // namespace WebCore
......
......@@ -790,6 +790,45 @@ void WebGLRenderingContext::framebufferRenderbuffer(unsigned long target, unsign
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
if (buffer->object()) {
bool isConflicted = false;
bool isDepthOrStencil = true;
switch (attachment) {
case GraphicsContext3D::DEPTH_ATTACHMENT:
if (m_framebufferBinding->isDepthStencilAttached() || m_framebufferBinding->isStencilAttached())
isConflicted = true;
if (buffer->getInternalformat() != GraphicsContext3D::DEPTH_COMPONENT16)
isConflicted = true;
break;
case GraphicsContext3D::STENCIL_ATTACHMENT:
if (m_framebufferBinding->isDepthStencilAttached() || m_framebufferBinding->isDepthAttached())
isConflicted = true;
if (buffer->getInternalformat() != GraphicsContext3D::STENCIL_INDEX8)
isConflicted = true;
break;
case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
if (m_framebufferBinding->isDepthAttached() || m_framebufferBinding->isStencilAttached())
isConflicted = true;
if (buffer->getInternalformat() != GraphicsContext3D::DEPTH_STENCIL)
isConflicted = true;
break;
default:
isDepthOrStencil = false;
}
if (isConflicted) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
if (isDepthOrStencil)
m_framebufferBinding->setIsAttached(attachment, true);
} else { // Detach
switch (attachment) {
case GraphicsContext3D::DEPTH_ATTACHMENT:
case GraphicsContext3D::STENCIL_ATTACHMENT:
case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
m_framebufferBinding->setIsAttached(attachment, false);
}
}
m_context->framebufferRenderbuffer(target, attachment, renderbuffertarget, buffer);
cleanupAfterGraphicsCall(false);
}
......@@ -897,7 +936,8 @@ WebGLGetInfo WebGLRenderingContext::getFramebufferAttachmentParameter(unsigned l
if (target != GraphicsContext3D::FRAMEBUFFER
|| (attachment != GraphicsContext3D::COLOR_ATTACHMENT0
&& attachment != GraphicsContext3D::DEPTH_ATTACHMENT
&& attachment != GraphicsContext3D::STENCIL_ATTACHMENT)
&& attachment != GraphicsContext3D::STENCIL_ATTACHMENT
&& attachment != GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT)
|| (pname != GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
&& pname != GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
&& pname != GraphicsContext3D::FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL
......@@ -1176,8 +1216,11 @@ WebGLGetInfo WebGLRenderingContext::getRenderbufferParameter(unsigned long targe
m_context->getRenderbufferParameteriv(target, pname, &value);
return WebGLGetInfo(static_cast<long>(value));
case GraphicsContext3D::RENDERBUFFER_INTERNAL_FORMAT:
m_context->getRenderbufferParameteriv(target, pname, &value);
return WebGLGetInfo(static_cast<unsigned long>(value));
if (!m_renderbufferBinding) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return WebGLGetInfo();
}
return WebGLGetInfo(m_renderbufferBinding->getInternalformat());
default:
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
return WebGLGetInfo();
......@@ -1559,8 +1602,21 @@ void WebGLRenderingContext::releaseShaderCompiler()
void WebGLRenderingContext::renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height)
{
m_context->renderbufferStorage(target, internalformat, width, height);
cleanupAfterGraphicsCall(false);
switch (internalformat) {
case GraphicsContext3D::DEPTH_COMPONENT16:
case GraphicsContext3D::RGBA4:
case GraphicsContext3D::RGB5_A1:
case GraphicsContext3D::RGB565:
case GraphicsContext3D::STENCIL_INDEX8:
case GraphicsContext3D::DEPTH_STENCIL:
m_context->renderbufferStorage(target, internalformat, width, height);
if (m_renderbufferBinding)
m_renderbufferBinding->setInternalformat(internalformat);
cleanupAfterGraphicsCall(false);
break;
default:
m_context->synthesizeGLError(GraphicsContext3D::INVALID_ENUM);
}
}
void WebGLRenderingContext::sampleCoverage(double value, bool invert)
......
......@@ -423,6 +423,7 @@ module html {
const unsigned int DEPTH_COMPONENT16 = 0x81A5;
const unsigned int STENCIL_INDEX = 0x1901;
const unsigned int STENCIL_INDEX8 = 0x8D48;
const unsigned int DEPTH_STENCIL = 0x84F9;
const unsigned int RENDERBUFFER_WIDTH = 0x8D42;
const unsigned int RENDERBUFFER_HEIGHT = 0x8D43;
......@@ -442,6 +443,7 @@ module html {
const unsigned int COLOR_ATTACHMENT0 = 0x8CE0;
const unsigned int DEPTH_ATTACHMENT = 0x8D00;
const unsigned int STENCIL_ATTACHMENT = 0x8D20;
const unsigned int DEPTH_STENCIL_ATTACHMENT = 0x821A;
const unsigned int NONE = 0;
......
......@@ -362,6 +362,7 @@ namespace WebCore {
DEPTH_COMPONENT16 = 0x81A5,
STENCIL_INDEX = 0x1901,
STENCIL_INDEX8 = 0x8D48,
DEPTH_STENCIL = 0x84F9,
RENDERBUFFER_WIDTH = 0x8D42,
RENDERBUFFER_HEIGHT = 0x8D43,
RENDERBUFFER_INTERNAL_FORMAT = 0x8D44,
......@@ -378,6 +379,7 @@ namespace WebCore {
COLOR_ATTACHMENT0 = 0x8CE0,
DEPTH_ATTACHMENT = 0x8D00,
STENCIL_ATTACHMENT = 0x8D20,
DEPTH_STENCIL_ATTACHMENT = 0x821A,
NONE = 0,
FRAMEBUFFER_COMPLETE = 0x8CD5,
FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6,
......
......@@ -591,7 +591,12 @@ void GraphicsContext3D::flush()
void GraphicsContext3D::framebufferRenderbuffer(unsigned long target, unsigned long attachment, unsigned long renderbuffertarget, WebGLRenderbuffer* buffer)
{
ensureContext(m_contextObj);
::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, buffer ? (GLuint) buffer->object() : 0);
GLuint renderbuffer = (buffer ? (GLuint) buffer->object() : 0);
if (attachment == DEPTH_STENCIL_ATTACHMENT) {
::glFramebufferRenderbufferEXT(target, DEPTH_ATTACHMENT, renderbuffertarget, renderbuffer);
::glFramebufferRenderbufferEXT(target, STENCIL_ATTACHMENT, renderbuffertarget, renderbuffer);
} else
::glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer);
}
void GraphicsContext3D::framebufferTexture2D(unsigned long target, unsigned long attachment, unsigned long textarget, WebGLTexture* texture, long level)
......@@ -822,6 +827,10 @@ void GraphicsContext3D::releaseShaderCompiler()
void GraphicsContext3D::renderbufferStorage(unsigned long target, unsigned long internalformat, unsigned long width, unsigned long height)
{
ensureContext(m_contextObj);
if (internalformat == DEPTH_STENCIL)
internalformat = GL_DEPTH24_STENCIL8_EXT;
else if (internalformat == DEPTH_COMPONENT16)
internalformat = GL_DEPTH_COMPONENT;
::glRenderbufferStorageEXT(target, internalformat, width, height);
}
......@@ -1117,6 +1126,8 @@ void GraphicsContext3D::getFloatv(unsigned long pname, float* value)
void GraphicsContext3D::getFramebufferAttachmentParameteriv(unsigned long target, unsigned long attachment, unsigned long pname, int* value)
{
ensureContext(m_contextObj);
if (attachment == DEPTH_STENCIL_ATTACHMENT)
attachment = DEPTH_ATTACHMENT; // Or STENCIL_ATTACHMENT, either works.
::glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, value);
}
......
2010-04-02 Zhenyao Mo <zmo@google.com>
Reviewed by Eric Seidel.
Implement and test new framebuffer object attachment behavior.
https://bugs.webkit.org/show_bug.cgi?id=35611
Test: fast/canvas/webgl/framebuffer-object-attachment.html
* src/WebGraphicsContext3DDefaultImpl.cpp: Map to correct DEPTH_STENCIL format.
(WebKit::WebGraphicsContext3DDefaultImpl::framebufferRenderbuffer):
(WebKit::WebGraphicsContext3DDefaultImpl::getFramebufferAttachmentParameteriv):
(WebKit::WebGraphicsContext3DDefaultImpl::renderbufferStorage):
2010-04-02 Jay Civelli <jcivelli@chromium.org>
Reviewed by Darin Fisher.
......
......@@ -885,7 +885,16 @@ DELEGATE_TO_GL(finish, Finish)
DELEGATE_TO_GL(flush, Flush)
DELEGATE_TO_GL_4(framebufferRenderbuffer, FramebufferRenderbufferEXT, unsigned long, unsigned long, unsigned long, WebGLId)
void WebGraphicsContext3DDefaultImpl::framebufferRenderbuffer(unsigned long target, unsigned long attachment,
unsigned long renderbuffertarget, WebGLId buffer)
{
makeContextCurrent();
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
glFramebufferRenderbufferEXT(target, GL_DEPTH_ATTACHMENT, renderbuffertarget, buffer);
glFramebufferRenderbufferEXT(target, GL_STENCIL_ATTACHMENT, renderbuffertarget, buffer);
} else
glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, buffer);
}
DELEGATE_TO_GL_5(framebufferTexture2D, FramebufferTexture2DEXT, unsigned long, unsigned long, unsigned long, WebGLId, long)
......@@ -985,7 +994,14 @@ unsigned long WebGraphicsContext3DDefaultImpl::getError()
DELEGATE_TO_GL_2(getFloatv, GetFloatv, unsigned long, float*)
DELEGATE_TO_GL_4(getFramebufferAttachmentParameteriv, GetFramebufferAttachmentParameterivEXT, unsigned long, unsigned long, unsigned long, int*)
void WebGraphicsContext3DDefaultImpl::getFramebufferAttachmentParameteriv(unsigned long target, unsigned long attachment,
unsigned long pname, int* value)
{
makeContextCurrent();
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
attachment = GL_DEPTH_ATTACHMENT; // Or GL_STENCIL_ATTACHMENT, either works.
glGetFramebufferAttachmentParameterivEXT(target, attachment, pname, value);
}
DELEGATE_TO_GL_2(getIntegerv, GetIntegerv, unsigned long, int*)
......@@ -1133,7 +1149,18 @@ void WebGraphicsContext3DDefaultImpl::releaseShaderCompiler()
{
}
DELEGATE_TO_GL_4(renderbufferStorage, RenderbufferStorageEXT, unsigned long, unsigned long, unsigned long, unsigned long)
void WebGraphicsContext3DDefaultImpl::renderbufferStorage(unsigned long target,
unsigned long internalformat,
unsigned long width,
unsigned long height)
{
makeContextCurrent();
if (internalformat == GL_DEPTH_STENCIL)
internalformat = GL_DEPTH24_STENCIL8_EXT;
else if (internalformat == GL_DEPTH_COMPONENT16)
internalformat = GL_DEPTH_COMPONENT;
glRenderbufferStorageEXT(target, internalformat, width, height);
}
DELEGATE_TO_GL_2(sampleCoverage, SampleCoverage, double, bool)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment