OLD | NEW |
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 Loading... |
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; |
49 GLenum format() const override; | 50 GLenum format() const override; |
50 GLenum type() const override; | 51 GLenum type() const override; |
51 bool isCubeComplete() const override; | 52 bool isCubeComplete() const override; |
52 WebGLSharedObject* object() const override; | 53 WebGLSharedObject* object() const override; |
53 bool isSharedObject(WebGLSharedObject*) const override; | 54 bool isSharedObject(WebGLSharedObject*) const override; |
54 bool valid() const override; | 55 bool valid() const override; |
55 void onDetached(WebGraphicsContext3D*) override; | 56 void onDetached(WebGraphicsContext3D*) override; |
56 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid
e; | 57 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid
e; |
57 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr
ide; | 58 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr
ide; |
58 | 59 |
(...skipping 19 matching lines...) Expand all Loading... |
78 GLsizei WebGLRenderbufferAttachment::width() const | 79 GLsizei WebGLRenderbufferAttachment::width() const |
79 { | 80 { |
80 return m_renderbuffer->width(); | 81 return m_renderbuffer->width(); |
81 } | 82 } |
82 | 83 |
83 GLsizei WebGLRenderbufferAttachment::height() const | 84 GLsizei WebGLRenderbufferAttachment::height() const |
84 { | 85 { |
85 return m_renderbuffer->height(); | 86 return m_renderbuffer->height(); |
86 } | 87 } |
87 | 88 |
| 89 GLsizei WebGLRenderbufferAttachment::depth() const |
| 90 { |
| 91 return 1; |
| 92 } |
| 93 |
88 GLenum WebGLRenderbufferAttachment::format() const | 94 GLenum WebGLRenderbufferAttachment::format() const |
89 { | 95 { |
90 GLenum format = m_renderbuffer->internalFormat(); | 96 GLenum format = m_renderbuffer->internalFormat(); |
91 if (format == GL_DEPTH_STENCIL_OES | 97 if (format == GL_DEPTH_STENCIL_OES |
92 && m_renderbuffer->emulatedStencilBuffer() | 98 && m_renderbuffer->emulatedStencilBuffer() |
93 && m_renderbuffer->emulatedStencilBuffer()->internalFormat() != GL_STENC
IL_INDEX8) { | 99 && m_renderbuffer->emulatedStencilBuffer()->internalFormat() != GL_STENC
IL_INDEX8) { |
94 return 0; | 100 return 0; |
95 } | 101 } |
96 return format; | 102 return format; |
97 } | 103 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe
t, GLint level, GLint layer); | 159 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe
t, GLint level, GLint layer); |
154 | 160 |
155 DECLARE_VIRTUAL_TRACE(); | 161 DECLARE_VIRTUAL_TRACE(); |
156 | 162 |
157 private: | 163 private: |
158 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye
r); | 164 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye
r); |
159 WebGLTextureAttachment() { } | 165 WebGLTextureAttachment() { } |
160 | 166 |
161 GLsizei width() const override; | 167 GLsizei width() const override; |
162 GLsizei height() const override; | 168 GLsizei height() const override; |
| 169 GLsizei depth() const override; |
163 GLenum format() const override; | 170 GLenum format() const override; |
164 GLenum type() const override; | 171 GLenum type() const override; |
165 bool isCubeComplete() const override; | 172 bool isCubeComplete() const override; |
166 WebGLSharedObject* object() const override; | 173 WebGLSharedObject* object() const override; |
167 bool isSharedObject(WebGLSharedObject*) const override; | 174 bool isSharedObject(WebGLSharedObject*) const override; |
168 bool valid() const override; | 175 bool valid() const override; |
169 void onDetached(WebGraphicsContext3D*) override; | 176 void onDetached(WebGraphicsContext3D*) override; |
170 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid
e; | 177 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid
e; |
171 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr
ide; | 178 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr
ide; |
172 | 179 |
(...skipping 25 matching lines...) Expand all Loading... |
198 GLsizei WebGLTextureAttachment::width() const | 205 GLsizei WebGLTextureAttachment::width() const |
199 { | 206 { |
200 return m_texture->getWidth(m_target, m_level); | 207 return m_texture->getWidth(m_target, m_level); |
201 } | 208 } |
202 | 209 |
203 GLsizei WebGLTextureAttachment::height() const | 210 GLsizei WebGLTextureAttachment::height() const |
204 { | 211 { |
205 return m_texture->getHeight(m_target, m_level); | 212 return m_texture->getHeight(m_target, m_level); |
206 } | 213 } |
207 | 214 |
| 215 GLsizei WebGLTextureAttachment::depth() const |
| 216 { |
| 217 return m_texture->getDepth(m_target, m_level); |
| 218 } |
| 219 |
208 GLenum WebGLTextureAttachment::format() const | 220 GLenum WebGLTextureAttachment::format() const |
209 { | 221 { |
210 return m_texture->getInternalFormat(m_target, m_level); | 222 return m_texture->getInternalFormat(m_target, m_level); |
211 } | 223 } |
212 | 224 |
213 WebGLSharedObject* WebGLTextureAttachment::object() const | 225 WebGLSharedObject* WebGLTextureAttachment::object() const |
214 { | 226 { |
215 return m_texture->object() ? m_texture.get() : 0; | 227 return m_texture->object() ? m_texture.get() : 0; |
216 } | 228 } |
217 | 229 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 return 0; | 544 return 0; |
533 WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0); | 545 WebGLAttachment* attachment = getAttachment(GL_COLOR_ATTACHMENT0); |
534 if (!attachment) | 546 if (!attachment) |
535 return 0; | 547 return 0; |
536 return attachment->format(); | 548 return attachment->format(); |
537 } | 549 } |
538 | 550 |
539 GLenum WebGLFramebuffer::checkStatus(const char** reason) const | 551 GLenum WebGLFramebuffer::checkStatus(const char** reason) const |
540 { | 552 { |
541 unsigned count = 0; | 553 unsigned count = 0; |
542 GLsizei width = 0, height = 0; | 554 GLsizei width = 0, height = 0, depth = 0; |
543 WebGLAttachment* depthAttachment = nullptr; | 555 WebGLAttachment* depthAttachment = nullptr; |
544 WebGLAttachment* stencilAttachment = nullptr; | 556 WebGLAttachment* stencilAttachment = nullptr; |
545 WebGLAttachment* depthStencilAttachment = nullptr; | 557 WebGLAttachment* depthStencilAttachment = nullptr; |
546 bool isWebGL2OrHigher = context()->isWebGL2OrHigher(); | 558 bool isWebGL2OrHigher = context()->isWebGL2OrHigher(); |
547 for (const auto& it : m_attachments) { | 559 for (const auto& it : m_attachments) { |
548 WebGLAttachment* attachment = it.value.get(); | 560 WebGLAttachment* attachment = it.value.get(); |
549 if (!isAttachmentComplete(attachment, it.key, reason)) | 561 if (!isAttachmentComplete(attachment, it.key, reason)) |
550 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 562 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
551 if (!attachment->valid()) { | 563 if (!attachment->valid()) { |
552 *reason = "attachment is not valid"; | 564 *reason = "attachment is not valid"; |
553 return GL_FRAMEBUFFER_UNSUPPORTED; | 565 return GL_FRAMEBUFFER_UNSUPPORTED; |
554 } | 566 } |
555 if (!attachment->format()) { | 567 if (!attachment->format()) { |
556 *reason = "attachment is an unsupported format"; | 568 *reason = "attachment is an unsupported format"; |
557 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 569 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
558 } | 570 } |
559 switch (it.key) { | 571 switch (it.key) { |
560 case GL_DEPTH_ATTACHMENT: | 572 case GL_DEPTH_ATTACHMENT: |
561 depthAttachment = attachment; | 573 depthAttachment = attachment; |
562 break; | 574 break; |
563 case GL_STENCIL_ATTACHMENT: | 575 case GL_STENCIL_ATTACHMENT: |
564 stencilAttachment = attachment; | 576 stencilAttachment = attachment; |
565 break; | 577 break; |
566 case GL_DEPTH_STENCIL_ATTACHMENT: | 578 case GL_DEPTH_STENCIL_ATTACHMENT: |
567 depthStencilAttachment = attachment; | 579 depthStencilAttachment = attachment; |
568 break; | 580 break; |
569 } | 581 } |
570 if (!isWebGL2OrHigher) { | 582 // Note: In GLES 3, images for a framebuffer need not to have the same d
imensions to be framebuffer complete. |
571 if (!count) { | 583 // However, in Direct3D 11, on top of which OpenGL ES 3 behavior is emul
ated in Windows, all render targets |
572 width = attachment->width(); | 584 // must have the same size in all dimensions. In order to have consisten
t WebGL 2 behaviors across platforms, |
573 height = attachment->height(); | 585 // we generate FRAMEBUFFER_INCOMPLETE_DIMENSIONS in this situation. |
574 } else { | 586 if (!count) { |
575 if (width != attachment->width() || height != attachment->height
()) { | 587 width = attachment->width(); |
576 *reason = "attachments do not have the same dimensions"; | 588 height = attachment->height(); |
577 return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; | 589 depth = attachment->depth(); |
578 } | 590 } else { |
| 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; |
579 } | 594 } |
580 } | 595 } |
581 ++count; | 596 ++count; |
582 } | 597 } |
583 if (!count) { | 598 if (!count) { |
584 *reason = "no attachments"; | 599 *reason = "no attachments"; |
585 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; | 600 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; |
586 } | 601 } |
587 // WebGL 1 specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments. | 602 // WebGL 1 specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments. |
588 if (!isWebGL2OrHigher | 603 if (!isWebGL2OrHigher |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 return true; | 710 return true; |
696 } | 711 } |
697 | 712 |
698 DEFINE_TRACE(WebGLFramebuffer) | 713 DEFINE_TRACE(WebGLFramebuffer) |
699 { | 714 { |
700 visitor->trace(m_attachments); | 715 visitor->trace(m_attachments); |
701 WebGLContextObject::trace(visitor); | 716 WebGLContextObject::trace(visitor); |
702 } | 717 } |
703 | 718 |
704 } | 719 } |
OLD | NEW |