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: ...@@ -46,6 +46,7 @@ private:
GLsizei width() const override; GLsizei width() const override;
GLsizei height() const override; GLsizei height() const override;
GLsizei depth() const override;
GLenum format() const override; GLenum format() const override;
GLenum type() const override; GLenum type() const override;
bool isCubeComplete() const override; bool isCubeComplete() const override;
...@@ -85,6 +86,11 @@ GLsizei WebGLRenderbufferAttachment::height() const ...@@ -85,6 +86,11 @@ GLsizei WebGLRenderbufferAttachment::height() const
return m_renderbuffer->height(); return m_renderbuffer->height();
} }
GLsizei WebGLRenderbufferAttachment::depth() const
{
return 1;
}
GLenum WebGLRenderbufferAttachment::format() const GLenum WebGLRenderbufferAttachment::format() const
{ {
GLenum format = m_renderbuffer->internalFormat(); GLenum format = m_renderbuffer->internalFormat();
...@@ -160,6 +166,7 @@ private: ...@@ -160,6 +166,7 @@ private:
GLsizei width() const override; GLsizei width() const override;
GLsizei height() const override; GLsizei height() const override;
GLsizei depth() const override;
GLenum format() const override; GLenum format() const override;
GLenum type() const override; GLenum type() const override;
bool isCubeComplete() const override; bool isCubeComplete() const override;
...@@ -205,6 +212,11 @@ GLsizei WebGLTextureAttachment::height() const ...@@ -205,6 +212,11 @@ GLsizei WebGLTextureAttachment::height() const
return m_texture->getHeight(m_target, m_level); return m_texture->getHeight(m_target, m_level);
} }
GLsizei WebGLTextureAttachment::depth() const
{
return m_texture->getDepth(m_target, m_level);
}
GLenum WebGLTextureAttachment::format() const GLenum WebGLTextureAttachment::format() const
{ {
return m_texture->getInternalFormat(m_target, m_level); return m_texture->getInternalFormat(m_target, m_level);
...@@ -539,7 +551,7 @@ GLenum WebGLFramebuffer::colorBufferFormat() const ...@@ -539,7 +551,7 @@ GLenum WebGLFramebuffer::colorBufferFormat() const
GLenum WebGLFramebuffer::checkStatus(const char** reason) const GLenum WebGLFramebuffer::checkStatus(const char** reason) const
{ {
unsigned count = 0; unsigned count = 0;
GLsizei width = 0, height = 0; GLsizei width = 0, height = 0, depth = 0;
WebGLAttachment* depthAttachment = nullptr; WebGLAttachment* depthAttachment = nullptr;
WebGLAttachment* stencilAttachment = nullptr; WebGLAttachment* stencilAttachment = nullptr;
WebGLAttachment* depthStencilAttachment = nullptr; WebGLAttachment* depthStencilAttachment = nullptr;
...@@ -567,17 +579,20 @@ GLenum WebGLFramebuffer::checkStatus(const char** reason) const ...@@ -567,17 +579,20 @@ GLenum WebGLFramebuffer::checkStatus(const char** reason) const
depthStencilAttachment = attachment; depthStencilAttachment = attachment;
break; 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) { if (!count) {
width = attachment->width(); width = attachment->width();
height = attachment->height(); height = attachment->height();
depth = attachment->depth();
} else { } 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"; *reason = "attachments do not have the same dimensions";
return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
} }
} }
}
++count; ++count;
} }
if (!count) { if (!count) {
......
...@@ -43,6 +43,7 @@ public: ...@@ -43,6 +43,7 @@ public:
virtual GLsizei width() const = 0; virtual GLsizei width() const = 0;
virtual GLsizei height() const = 0; virtual GLsizei height() const = 0;
virtual GLsizei depth() const = 0;
virtual GLenum format() const = 0; virtual GLenum format() const = 0;
// For texture attachment, type() returns the type of the attached texture. // For texture attachment, type() returns the type of the attached texture.
// For renderbuffer attachment, the type of the renderbuffer may vary with GL implementation. // 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