Commit 23cf53ec authored by yunchao.he's avatar yunchao.he Committed by Commit bot

WebGL 2: generate appropriate error for different dimensions of images attached to fbo.

This change fixed the bug in framebuffer-object-attachment.html

BUG=295792
TEST=conformance2/renderbuffers/framebuffer-object-attachment.html

Review URL: https://codereview.chromium.org/1549393002

Cr-Commit-Position: refs/heads/master@{#367053}
parent 0b36cf70
......@@ -46,6 +46,7 @@ private:
GLsizei width() const override;
GLsizei height() const override;
GLsizei depth() const override;
GLenum format() const override;
GLenum type() const override;
bool isCubeComplete() const override;
......@@ -85,6 +86,11 @@ GLsizei WebGLRenderbufferAttachment::height() const
return m_renderbuffer->height();
}
GLsizei WebGLRenderbufferAttachment::depth() const
{
return 1;
}
GLenum WebGLRenderbufferAttachment::format() const
{
GLenum format = m_renderbuffer->internalFormat();
......@@ -160,6 +166,7 @@ private:
GLsizei width() const override;
GLsizei height() const override;
GLsizei depth() const override;
GLenum format() const override;
GLenum type() const override;
bool isCubeComplete() const override;
......@@ -205,6 +212,11 @@ GLsizei WebGLTextureAttachment::height() const
return m_texture->getHeight(m_target, m_level);
}
GLsizei WebGLTextureAttachment::depth() const
{
return m_texture->getDepth(m_target, m_level);
}
GLenum WebGLTextureAttachment::format() const
{
return m_texture->getInternalFormat(m_target, m_level);
......@@ -539,7 +551,7 @@ GLenum WebGLFramebuffer::colorBufferFormat() const
GLenum WebGLFramebuffer::checkStatus(const char** reason) const
{
unsigned count = 0;
GLsizei width = 0, height = 0;
GLsizei width = 0, height = 0, depth = 0;
WebGLAttachment* depthAttachment = nullptr;
WebGLAttachment* stencilAttachment = nullptr;
WebGLAttachment* depthStencilAttachment = nullptr;
......@@ -567,17 +579,20 @@ GLenum WebGLFramebuffer::checkStatus(const char** reason) const
depthStencilAttachment = attachment;
break;
}
if (!isWebGL2OrHigher) {
// Note: In GLES 3, images for a framebuffer need not to have the same dimensions to be framebuffer complete.
// However, in Direct3D 11, on top of which OpenGL ES 3 behavior is emulated in Windows, all render targets
// must have the same size in all dimensions. In order to have consistent WebGL 2 behaviors across platforms,
// we generate FRAMEBUFFER_INCOMPLETE_DIMENSIONS in this situation.
if (!count) {
width = attachment->width();
height = attachment->height();
depth = attachment->depth();
} else {
if (width != attachment->width() || height != attachment->height()) {
if (width != attachment->width() || height != attachment->height() || depth != attachment->depth()) {
*reason = "attachments do not have the same dimensions";
return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
}
}
}
++count;
}
if (!count) {
......
......@@ -43,6 +43,7 @@ public:
virtual GLsizei width() const = 0;
virtual GLsizei height() const = 0;
virtual GLsizei depth() const = 0;
virtual GLenum format() const = 0;
// For texture attachment, type() returns the type of the attached texture.
// For renderbuffer attachment, the type of the renderbuffer may vary with GL implementation.
......
Markdown is supported
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