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

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

Issue 1673113002: Move WebGL1 attachment image type / attachment point matching check to command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return m_renderbuffer->height(); 86 return m_renderbuffer->height();
87 } 87 }
88 88
89 GLsizei WebGLRenderbufferAttachment::depth() const 89 GLsizei WebGLRenderbufferAttachment::depth() const
90 { 90 {
91 return 1; 91 return 1;
92 } 92 }
93 93
94 GLenum WebGLRenderbufferAttachment::format() const 94 GLenum WebGLRenderbufferAttachment::format() const
95 { 95 {
96 GLenum format = m_renderbuffer->internalFormat(); 96 return m_renderbuffer->internalFormat();
97 if (format == GL_DEPTH_STENCIL_OES
98 && m_renderbuffer->emulatedStencilBuffer()
99 && m_renderbuffer->emulatedStencilBuffer()->internalFormat() != GL_STENC IL_INDEX8) {
100 return 0;
101 }
102 return format;
103 } 97 }
104 98
105 WebGLSharedObject* WebGLRenderbufferAttachment::object() const 99 WebGLSharedObject* WebGLRenderbufferAttachment::object() const
106 { 100 {
107 return m_renderbuffer->object() ? m_renderbuffer.get() : 0; 101 return m_renderbuffer->object() ? m_renderbuffer.get() : 0;
108 } 102 }
109 103
110 bool WebGLRenderbufferAttachment::isSharedObject(WebGLSharedObject* object) cons t 104 bool WebGLRenderbufferAttachment::isSharedObject(WebGLSharedObject* object) cons t
111 { 105 {
112 return object == m_renderbuffer; 106 return object == m_renderbuffer;
113 } 107 }
114 108
115 bool WebGLRenderbufferAttachment::valid() const 109 bool WebGLRenderbufferAttachment::valid() const
116 { 110 {
117 return m_renderbuffer->object(); 111 return m_renderbuffer->object();
118 } 112 }
119 113
120 void WebGLRenderbufferAttachment::onDetached(WebGraphicsContext3D* context) 114 void WebGLRenderbufferAttachment::onDetached(WebGraphicsContext3D* context)
121 { 115 {
122 m_renderbuffer->onDetached(context); 116 m_renderbuffer->onDetached(context);
123 } 117 }
124 118
125 void WebGLRenderbufferAttachment::attach(WebGraphicsContext3D* context, GLenum t arget, GLenum attachment) 119 void WebGLRenderbufferAttachment::attach(WebGraphicsContext3D* context, GLenum t arget, GLenum attachment)
126 { 120 {
127 Platform3DObject object = objectOrZero(m_renderbuffer.get()); 121 Platform3DObject object = objectOrZero(m_renderbuffer.get());
128 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT && m_renderbuffer->emulatedSte ncilBuffer()) { 122 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, object );
129 context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, GL_RENDERB UFFER, object);
130 context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, GL_RENDE RBUFFER, objectOrZero(m_renderbuffer->emulatedStencilBuffer()));
131 } else {
132 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, ob ject);
133 }
134 } 123 }
135 124
136 void WebGLRenderbufferAttachment::unattach(WebGraphicsContext3D* context, GLenum target, GLenum attachment) 125 void WebGLRenderbufferAttachment::unattach(WebGraphicsContext3D* context, GLenum target, GLenum attachment)
137 { 126 {
138 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 127 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, 0);
139 context->framebufferRenderbuffer(target, GL_DEPTH_ATTACHMENT, GL_RENDERB UFFER, 0);
140 context->framebufferRenderbuffer(target, GL_STENCIL_ATTACHMENT, GL_RENDE RBUFFER, 0);
141 } else {
142 context->framebufferRenderbuffer(target, attachment, GL_RENDERBUFFER, 0) ;
143 }
144 } 128 }
145 129
146 GLenum WebGLRenderbufferAttachment::type() const 130 GLenum WebGLRenderbufferAttachment::type() const
147 { 131 {
148 return WebGLTexture::getValidTypeForInternalFormat(m_renderbuffer->internalF ormat()); 132 return WebGLTexture::getValidTypeForInternalFormat(m_renderbuffer->internalF ormat());
149 } 133 }
150 134
151 bool WebGLRenderbufferAttachment::isCubeComplete() const 135 bool WebGLRenderbufferAttachment::isCubeComplete() const
152 { 136 {
153 ASSERT_NOT_REACHED(); 137 ASSERT_NOT_REACHED();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 context->framebufferTexture2D(target, attachment, m_target, object, m_le vel); 235 context->framebufferTexture2D(target, attachment, m_target, object, m_le vel);
252 } 236 }
253 } 237 }
254 238
255 void WebGLTextureAttachment::unattach(WebGraphicsContext3D* context, GLenum targ et, GLenum attachment) 239 void WebGLTextureAttachment::unattach(WebGraphicsContext3D* context, GLenum targ et, GLenum attachment)
256 { 240 {
257 // GL_DEPTH_STENCIL_ATTACHMENT attachment is valid in ES3. 241 // GL_DEPTH_STENCIL_ATTACHMENT attachment is valid in ES3.
258 if (m_target == GL_TEXTURE_3D || m_target == GL_TEXTURE_2D_ARRAY) { 242 if (m_target == GL_TEXTURE_3D || m_target == GL_TEXTURE_2D_ARRAY) {
259 context->framebufferTextureLayer(target, attachment, 0, m_level, m_layer ); 243 context->framebufferTextureLayer(target, attachment, 0, m_level, m_layer );
260 } else { 244 } else {
261 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 245 context->framebufferTexture2D(target, attachment, m_target, 0, m_level);
262 context->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, m_target, 0, m_level);
263 context->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, m_targe t, 0, m_level);
264 } else {
265 context->framebufferTexture2D(target, attachment, m_target, 0, m_lev el);
266 }
267 } 246 }
268 } 247 }
269 248
270 GLenum WebGLTextureAttachment::type() const 249 GLenum WebGLTextureAttachment::type() const
271 { 250 {
272 return m_texture->getType(m_target, m_level); 251 return m_texture->getType(m_target, m_level);
273 } 252 }
274 253
275 bool WebGLTextureAttachment::isCubeComplete() const 254 bool WebGLTextureAttachment::isCubeComplete() const
276 { 255 {
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 if (attachmentObject) { 477 if (attachmentObject) {
499 attachmentObject->onDetached(context()->webContext()); 478 attachmentObject->onDetached(context()->webContext());
500 m_attachments.remove(attachment); 479 m_attachments.remove(attachment);
501 drawBuffersIfNecessary(false); 480 drawBuffersIfNecessary(false);
502 switch (attachment) { 481 switch (attachment) {
503 case GL_DEPTH_STENCIL_ATTACHMENT: 482 case GL_DEPTH_STENCIL_ATTACHMENT:
504 attach(target, GL_DEPTH_ATTACHMENT, GL_DEPTH_ATTACHMENT); 483 attach(target, GL_DEPTH_ATTACHMENT, GL_DEPTH_ATTACHMENT);
505 attach(target, GL_STENCIL_ATTACHMENT, GL_STENCIL_ATTACHMENT); 484 attach(target, GL_STENCIL_ATTACHMENT, GL_STENCIL_ATTACHMENT);
506 break; 485 break;
507 case GL_DEPTH_ATTACHMENT: 486 case GL_DEPTH_ATTACHMENT:
508 attach(target, GL_DEPTH_STENCIL_ATTACHMENT, GL_DEPTH_ATTACHMENT);
509 break;
510 case GL_STENCIL_ATTACHMENT: 487 case GL_STENCIL_ATTACHMENT:
511 attach(target, GL_DEPTH_STENCIL_ATTACHMENT, GL_STENCIL_ATTACHMENT); 488 attach(target, GL_DEPTH_STENCIL_ATTACHMENT, GL_DEPTH_STENCIL_ATTACHM ENT);
512 break; 489 break;
513 } 490 }
514 } 491 }
515 } 492 }
516 493
517 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum target, WebGL SharedObject* attachment) 494 void WebGLFramebuffer::removeAttachmentFromBoundFramebuffer(GLenum target, WebGL SharedObject* attachment)
518 { 495 {
519 ASSERT(isBound(target)); 496 ASSERT(isBound(target));
520 if (!m_object) 497 if (!m_object)
521 return; 498 return;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 GLenum WebGLFramebuffer::checkDepthStencilStatus(const char** reason) const 594 GLenum WebGLFramebuffer::checkDepthStencilStatus(const char** reason) const
618 { 595 {
619 if (context()->isWebGL2OrHigher()) 596 if (context()->isWebGL2OrHigher())
620 return GL_FRAMEBUFFER_COMPLETE; 597 return GL_FRAMEBUFFER_COMPLETE;
621 WebGLAttachment* depthAttachment = nullptr; 598 WebGLAttachment* depthAttachment = nullptr;
622 WebGLAttachment* stencilAttachment = nullptr; 599 WebGLAttachment* stencilAttachment = nullptr;
623 WebGLAttachment* depthStencilAttachment = nullptr; 600 WebGLAttachment* depthStencilAttachment = nullptr;
624 for (const auto& it : m_attachments) { 601 for (const auto& it : m_attachments) {
625 WebGLAttachment* attachment = it.value.get(); 602 WebGLAttachment* attachment = it.value.get();
626 ASSERT(attachment); 603 ASSERT(attachment);
627 GLenum internalformat = attachment->format();
628 switch (it.key) { 604 switch (it.key) {
629 case GL_DEPTH_ATTACHMENT: 605 case GL_DEPTH_ATTACHMENT:
630 depthAttachment = attachment; 606 depthAttachment = attachment;
631 if (!isDepthRenderable(internalformat, false)) {
632 *reason = "the internalformat of the attached image is not depth -renderable";
633 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
634 }
635 break; 607 break;
636 case GL_STENCIL_ATTACHMENT: 608 case GL_STENCIL_ATTACHMENT:
637 stencilAttachment = attachment; 609 stencilAttachment = attachment;
638 if (!isStencilRenderable(internalformat, false)) {
639 *reason = "the internalformat of the attached image is not stenc il-renderable";
640 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
641 }
642 break; 610 break;
643 case GL_DEPTH_STENCIL_ATTACHMENT: 611 case GL_DEPTH_STENCIL_ATTACHMENT:
644 depthStencilAttachment = attachment; 612 depthStencilAttachment = attachment;
645 if (internalformat != GL_DEPTH_STENCIL_OES) {
646 *reason = "the internalformat of the attached image is not DEPTH _STENCIL";
647 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
648 }
649 break; 613 break;
650 default: 614 default:
651 break; 615 break;
652 } 616 }
653 } 617 }
654 if ((depthStencilAttachment && (depthAttachment || stencilAttachment)) 618 if ((depthStencilAttachment && (depthAttachment || stencilAttachment))
655 || (depthAttachment && stencilAttachment)) { 619 || (depthAttachment && stencilAttachment)) {
656 *reason = "conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments"; 620 *reason = "conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments";
657 return GL_FRAMEBUFFER_UNSUPPORTED; 621 return GL_FRAMEBUFFER_UNSUPPORTED;
658 } 622 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 return true; 712 return true;
749 } 713 }
750 714
751 DEFINE_TRACE(WebGLFramebuffer) 715 DEFINE_TRACE(WebGLFramebuffer)
752 { 716 {
753 visitor->trace(m_attachments); 717 visitor->trace(m_attachments);
754 WebGLContextObject::trace(visitor); 718 WebGLContextObject::trace(visitor);
755 } 719 }
756 720
757 } // namespace blink 721 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698