Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.cpp

Issue 1555543002: Revert of WebGL 2: generate appropriate error for different dimensions of images attached to fbo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 28 matching lines...) Expand all
39 static WebGLFramebuffer::WebGLAttachment* create(WebGLRenderbuffer*); 39 static WebGLFramebuffer::WebGLAttachment* create(WebGLRenderbuffer*);
40 40
41 DECLARE_VIRTUAL_TRACE(); 41 DECLARE_VIRTUAL_TRACE();
42 42
43 private: 43 private:
44 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*); 44 explicit WebGLRenderbufferAttachment(WebGLRenderbuffer*);
45 WebGLRenderbufferAttachment() { } 45 WebGLRenderbufferAttachment() { }
46 46
47 GLsizei width() const override; 47 GLsizei width() const override;
48 GLsizei height() const override; 48 GLsizei height() const override;
49 GLsizei depth() const override;
50 GLenum format() const override; 49 GLenum format() const override;
51 GLenum type() const override; 50 GLenum type() const override;
52 bool isCubeComplete() const override; 51 bool isCubeComplete() const override;
53 WebGLSharedObject* object() const override; 52 WebGLSharedObject* object() const override;
54 bool isSharedObject(WebGLSharedObject*) const override; 53 bool isSharedObject(WebGLSharedObject*) const override;
55 bool valid() const override; 54 bool valid() const override;
56 void onDetached(WebGraphicsContext3D*) override; 55 void onDetached(WebGraphicsContext3D*) override;
57 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e; 56 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e;
58 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide; 57 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide;
59 58
(...skipping 19 matching lines...) Expand all
79 GLsizei WebGLRenderbufferAttachment::width() const 78 GLsizei WebGLRenderbufferAttachment::width() const
80 { 79 {
81 return m_renderbuffer->width(); 80 return m_renderbuffer->width();
82 } 81 }
83 82
84 GLsizei WebGLRenderbufferAttachment::height() const 83 GLsizei WebGLRenderbufferAttachment::height() const
85 { 84 {
86 return m_renderbuffer->height(); 85 return m_renderbuffer->height();
87 } 86 }
88 87
89 GLsizei WebGLRenderbufferAttachment::depth() const
90 {
91 return 1;
92 }
93
94 GLenum WebGLRenderbufferAttachment::format() const 88 GLenum WebGLRenderbufferAttachment::format() const
95 { 89 {
96 GLenum format = m_renderbuffer->internalFormat(); 90 GLenum format = m_renderbuffer->internalFormat();
97 if (format == GL_DEPTH_STENCIL_OES 91 if (format == GL_DEPTH_STENCIL_OES
98 && m_renderbuffer->emulatedStencilBuffer() 92 && m_renderbuffer->emulatedStencilBuffer()
99 && m_renderbuffer->emulatedStencilBuffer()->internalFormat() != GL_STENC IL_INDEX8) { 93 && m_renderbuffer->emulatedStencilBuffer()->internalFormat() != GL_STENC IL_INDEX8) {
100 return 0; 94 return 0;
101 } 95 }
102 return format; 96 return format;
103 } 97 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level, GLint layer); 153 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level, GLint layer);
160 154
161 DECLARE_VIRTUAL_TRACE(); 155 DECLARE_VIRTUAL_TRACE();
162 156
163 private: 157 private:
164 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye r); 158 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye r);
165 WebGLTextureAttachment() { } 159 WebGLTextureAttachment() { }
166 160
167 GLsizei width() const override; 161 GLsizei width() const override;
168 GLsizei height() const override; 162 GLsizei height() const override;
169 GLsizei depth() const override;
170 GLenum format() const override; 163 GLenum format() const override;
171 GLenum type() const override; 164 GLenum type() const override;
172 bool isCubeComplete() const override; 165 bool isCubeComplete() const override;
173 WebGLSharedObject* object() const override; 166 WebGLSharedObject* object() const override;
174 bool isSharedObject(WebGLSharedObject*) const override; 167 bool isSharedObject(WebGLSharedObject*) const override;
175 bool valid() const override; 168 bool valid() const override;
176 void onDetached(WebGraphicsContext3D*) override; 169 void onDetached(WebGraphicsContext3D*) override;
177 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e; 170 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e;
178 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide; 171 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide;
179 172
(...skipping 25 matching lines...) Expand all
205 GLsizei WebGLTextureAttachment::width() const 198 GLsizei WebGLTextureAttachment::width() const
206 { 199 {
207 return m_texture->getWidth(m_target, m_level); 200 return m_texture->getWidth(m_target, m_level);
208 } 201 }
209 202
210 GLsizei WebGLTextureAttachment::height() const 203 GLsizei WebGLTextureAttachment::height() const
211 { 204 {
212 return m_texture->getHeight(m_target, m_level); 205 return m_texture->getHeight(m_target, m_level);
213 } 206 }
214 207
215 GLsizei WebGLTextureAttachment::depth() const
216 {
217 return m_texture->getDepth(m_target, m_level);
218 }
219
220 GLenum WebGLTextureAttachment::format() const 208 GLenum WebGLTextureAttachment::format() const
221 { 209 {
222 return m_texture->getInternalFormat(m_target, m_level); 210 return m_texture->getInternalFormat(m_target, m_level);
223 } 211 }
224 212
225 WebGLSharedObject* WebGLTextureAttachment::object() const 213 WebGLSharedObject* WebGLTextureAttachment::object() const
226 { 214 {
227 return m_texture->object() ? m_texture.get() : 0; 215 return m_texture->object() ? m_texture.get() : 0;
228 } 216 }
229 217
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 return 0; 532 return 0;
545 WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0); 533 WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0);
546 if (!attachment) 534 if (!attachment)
547 return 0; 535 return 0;
548 return attachment->format(); 536 return attachment->format();
549 } 537 }
550 538
551 GLenum WebGLFramebuffer::checkStatus(const char** reason) const 539 GLenum WebGLFramebuffer::checkStatus(const char** reason) const
552 { 540 {
553 unsigned count = 0; 541 unsigned count = 0;
554 GLsizei width = 0, height = 0, depth = 0; 542 GLsizei width = 0, height = 0;
555 WebGLAttachment* depthAttachment = nullptr; 543 WebGLAttachment* depthAttachment = nullptr;
556 WebGLAttachment* stencilAttachment = nullptr; 544 WebGLAttachment* stencilAttachment = nullptr;
557 WebGLAttachment* depthStencilAttachment = nullptr; 545 WebGLAttachment* depthStencilAttachment = nullptr;
558 bool isWebGL2OrHigher = context()->isWebGL2OrHigher(); 546 bool isWebGL2OrHigher = context()->isWebGL2OrHigher();
559 for (const auto& it : m_attachments) { 547 for (const auto& it : m_attachments) {
560 WebGLAttachment* attachment = it.value.get(); 548 WebGLAttachment* attachment = it.value.get();
561 if (!isAttachmentComplete(attachment, it.key, reason)) 549 if (!isAttachmentComplete(attachment, it.key, reason))
562 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 550 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
563 if (!attachment->valid()) { 551 if (!attachment->valid()) {
564 *reason = "attachment is not valid"; 552 *reason = "attachment is not valid";
565 return GL_FRAMEBUFFER_UNSUPPORTED; 553 return GL_FRAMEBUFFER_UNSUPPORTED;
566 } 554 }
567 if (!attachment->format()) { 555 if (!attachment->format()) {
568 *reason = "attachment is an unsupported format"; 556 *reason = "attachment is an unsupported format";
569 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 557 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
570 } 558 }
571 switch (it.key) { 559 switch (it.key) {
572 case GL_DEPTH_ATTACHMENT: 560 case GL_DEPTH_ATTACHMENT:
573 depthAttachment = attachment; 561 depthAttachment = attachment;
574 break; 562 break;
575 case GL_STENCIL_ATTACHMENT: 563 case GL_STENCIL_ATTACHMENT:
576 stencilAttachment = attachment; 564 stencilAttachment = attachment;
577 break; 565 break;
578 case GL_DEPTH_STENCIL_ATTACHMENT: 566 case GL_DEPTH_STENCIL_ATTACHMENT:
579 depthStencilAttachment = attachment; 567 depthStencilAttachment = attachment;
580 break; 568 break;
581 } 569 }
582 // Note: In GLES 3, images for a framebuffer need not to have the same d imensions to be framebuffer complete. 570 if (!isWebGL2OrHigher) {
583 // However, in Direct3D 11, on top of which OpenGL ES 3 behavior is emul ated in Windows, all render targets 571 if (!count) {
584 // must have the same size in all dimensions. In order to have consisten t WebGL 2 behaviors across platforms, 572 width = attachment->width();
585 // we generate FRAMEBUFFER_INCOMPLETE_DIMENSIONS in this situation. 573 height = attachment->height();
586 if (!count) { 574 } else {
587 width = attachment->width(); 575 if (width != attachment->width() || height != attachment->height ()) {
588 height = attachment->height(); 576 *reason = "attachments do not have the same dimensions";
589 depth = attachment->depth(); 577 return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
590 } else { 578 }
591 if (width != attachment->width() || height != attachment->height() | | depth != attachment->depth()) {
592 *reason = "attachments do not have the same dimensions";
593 return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
594 } 579 }
595 } 580 }
596 ++count; 581 ++count;
597 } 582 }
598 if (!count) { 583 if (!count) {
599 *reason = "no attachments"; 584 *reason = "no attachments";
600 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; 585 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
601 } 586 }
602 // WebGL 1 specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments. 587 // WebGL 1 specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments.
603 if (!isWebGL2OrHigher 588 if (!isWebGL2OrHigher
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 return true; 695 return true;
711 } 696 }
712 697
713 DEFINE_TRACE(WebGLFramebuffer) 698 DEFINE_TRACE(WebGLFramebuffer)
714 { 699 {
715 visitor->trace(m_attachments); 700 visitor->trace(m_attachments);
716 WebGLContextObject::trace(visitor); 701 WebGLContextObject::trace(visitor);
717 } 702 }
718 703
719 } 704 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLFramebuffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698