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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 } | 139 } |
140 | 140 |
141 GLenum WebGLRenderbufferAttachment::type() const | 141 GLenum WebGLRenderbufferAttachment::type() const |
142 { | 142 { |
143 notImplemented(); | 143 notImplemented(); |
144 return 0; | 144 return 0; |
145 } | 145 } |
146 | 146 |
147 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment { | 147 class WebGLTextureAttachment final : public WebGLFramebuffer::WebGLAttachment { |
148 public: | 148 public: |
149 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level); | 149 static WebGLFramebuffer::WebGLAttachment* create(WebGLTexture*, GLenum targe t, GLint level, GLint layer); |
150 | 150 |
151 DECLARE_VIRTUAL_TRACE(); | 151 DECLARE_VIRTUAL_TRACE(); |
152 | 152 |
153 private: | 153 private: |
154 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level); | 154 WebGLTextureAttachment(WebGLTexture*, GLenum target, GLint level, GLint laye r); |
155 WebGLTextureAttachment() { } | 155 WebGLTextureAttachment() { } |
156 | 156 |
157 GLsizei width() const override; | 157 GLsizei width() const override; |
158 GLsizei height() const override; | 158 GLsizei height() const override; |
159 GLenum format() const override; | 159 GLenum format() const override; |
160 GLenum type() const override; | 160 GLenum type() const override; |
161 WebGLSharedObject* object() const override; | 161 WebGLSharedObject* object() const override; |
162 bool isSharedObject(WebGLSharedObject*) const override; | 162 bool isSharedObject(WebGLSharedObject*) const override; |
163 bool valid() const override; | 163 bool valid() const override; |
164 void onDetached(WebGraphicsContext3D*) override; | 164 void onDetached(WebGraphicsContext3D*) override; |
165 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e; | 165 void attach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overrid e; |
166 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide; | 166 void unattach(WebGraphicsContext3D*, GLenum target, GLenum attachment) overr ide; |
167 | 167 |
168 Member<WebGLTexture> m_texture; | 168 Member<WebGLTexture> m_texture; |
169 GLenum m_target; | 169 GLenum m_target; |
170 GLint m_level; | 170 GLint m_level; |
171 GLint m_layer; | |
171 }; | 172 }; |
172 | 173 |
173 WebGLFramebuffer::WebGLAttachment* WebGLTextureAttachment::create(WebGLTexture* texture, GLenum target, GLint level) | 174 WebGLFramebuffer::WebGLAttachment* WebGLTextureAttachment::create(WebGLTexture* texture, GLenum target, GLint level, GLint layer) |
174 { | 175 { |
175 return new WebGLTextureAttachment(texture, target, level); | 176 return new WebGLTextureAttachment(texture, target, level, layer); |
176 } | 177 } |
177 | 178 |
178 DEFINE_TRACE(WebGLTextureAttachment) | 179 DEFINE_TRACE(WebGLTextureAttachment) |
179 { | 180 { |
180 visitor->trace(m_texture); | 181 visitor->trace(m_texture); |
181 WebGLFramebuffer::WebGLAttachment::trace(visitor); | 182 WebGLFramebuffer::WebGLAttachment::trace(visitor); |
182 } | 183 } |
183 | 184 |
184 WebGLTextureAttachment::WebGLTextureAttachment(WebGLTexture* texture, GLenum tar get, GLint level) | 185 WebGLTextureAttachment::WebGLTextureAttachment(WebGLTexture* texture, GLenum tar get, GLint level, GLint layer) |
185 : m_texture(texture) | 186 : m_texture(texture) |
186 , m_target(target) | 187 , m_target(target) |
187 , m_level(level) | 188 , m_level(level) |
189 , m_layer(layer) | |
188 { | 190 { |
189 } | 191 } |
190 | 192 |
191 GLsizei WebGLTextureAttachment::width() const | 193 GLsizei WebGLTextureAttachment::width() const |
192 { | 194 { |
193 return m_texture->getWidth(m_target, m_level); | 195 return m_texture->getWidth(m_target, m_level); |
194 } | 196 } |
195 | 197 |
196 GLsizei WebGLTextureAttachment::height() const | 198 GLsizei WebGLTextureAttachment::height() const |
197 { | 199 { |
(...skipping 21 matching lines...) Expand all Loading... | |
219 } | 221 } |
220 | 222 |
221 void WebGLTextureAttachment::onDetached(WebGraphicsContext3D* context) | 223 void WebGLTextureAttachment::onDetached(WebGraphicsContext3D* context) |
222 { | 224 { |
223 m_texture->onDetached(context); | 225 m_texture->onDetached(context); |
224 } | 226 } |
225 | 227 |
226 void WebGLTextureAttachment::attach(WebGraphicsContext3D* context, GLenum target , GLenum attachment) | 228 void WebGLTextureAttachment::attach(WebGraphicsContext3D* context, GLenum target , GLenum attachment) |
227 { | 229 { |
228 Platform3DObject object = objectOrZero(m_texture.get()); | 230 Platform3DObject object = objectOrZero(m_texture.get()); |
229 context->framebufferTexture2D(target, attachment, m_target, object, m_level) ; | 231 if (target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) { |
232 context->framebufferTextureLayer(target, attachment, object, m_level, m_ layer); | |
Ken Russell (switch to Gerrit)
2015/10/27 16:47:59
The logic here has become really confusing. I am h
| |
233 } else { | |
234 context->framebufferTexture2D(target, attachment, m_target, object, m_le vel); | |
235 } | |
230 } | 236 } |
231 | 237 |
232 void WebGLTextureAttachment::unattach(WebGraphicsContext3D* context, GLenum targ et, GLenum attachment) | 238 void WebGLTextureAttachment::unattach(WebGraphicsContext3D* context, GLenum targ et, GLenum attachment) |
233 { | 239 { |
234 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 240 if (target == GL_TEXTURE_3D || target == GL_TEXTURE_2D_ARRAY) { |
235 context->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, m_target, 0, m_level); | 241 context->framebufferTextureLayer(target, attachment, 0, m_level, m_layer ); |
Zhenyao Mo
2015/10/27 21:21:31
Here I think you need to handle the same DEPTH_STE
qiankun
2015/10/27 23:25:27
DEPTH_STENCIL_ATTACHMENT is supported in ES 3. Do
Zhenyao Mo
2015/10/27 23:40:28
OK, then could you please add a comment that DEPTH
qiankun
2015/10/27 23:55:59
Done.
| |
236 context->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, m_target, 0 , m_level); | |
237 } else { | 242 } else { |
238 context->framebufferTexture2D(target, attachment, m_target, 0, m_level); | 243 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
244 context->framebufferTexture2D(target, GL_DEPTH_ATTACHMENT, m_target, 0, m_level); | |
245 context->framebufferTexture2D(target, GL_STENCIL_ATTACHMENT, m_targe t, 0, m_level); | |
246 } else { | |
247 context->framebufferTexture2D(target, attachment, m_target, 0, m_lev el); | |
248 } | |
239 } | 249 } |
240 } | 250 } |
241 | 251 |
242 GLenum WebGLTextureAttachment::type() const | 252 GLenum WebGLTextureAttachment::type() const |
243 { | 253 { |
244 return m_texture->getType(m_target, m_level); | 254 return m_texture->getType(m_target, m_level); |
245 } | 255 } |
246 | 256 |
247 bool isColorRenderable(GLenum internalformat) | 257 bool isColorRenderable(GLenum internalformat) |
248 { | 258 { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 { | 353 { |
344 // Attachments in |m_attachments| will be deleted from other | 354 // Attachments in |m_attachments| will be deleted from other |
345 // places, and we must not touch that map in deleteObjectImpl once | 355 // places, and we must not touch that map in deleteObjectImpl once |
346 // the destructor has been entered. | 356 // the destructor has been entered. |
347 m_destructionInProgress = true; | 357 m_destructionInProgress = true; |
348 | 358 |
349 // See the comment in WebGLObject::detachAndDeleteObject(). | 359 // See the comment in WebGLObject::detachAndDeleteObject(). |
350 detachAndDeleteObject(); | 360 detachAndDeleteObject(); |
351 } | 361 } |
352 | 362 |
353 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, GLenum texTarget, WebGLTexture* texture, GLint level) | 363 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, GLenum texTarget, WebGLTexture* texture, GLint level, GLint layer) |
354 { | 364 { |
355 ASSERT(isBound(target)); | 365 ASSERT(isBound(target)); |
356 removeAttachmentFromBoundFramebuffer(target, attachment); | 366 removeAttachmentFromBoundFramebuffer(target, attachment); |
357 if (!m_object) | 367 if (!m_object) |
358 return; | 368 return; |
359 if (texture && texture->object()) { | 369 if (texture && texture->object()) { |
360 m_attachments.add(attachment, WebGLTextureAttachment::create(texture, te xTarget, level)); | 370 m_attachments.add(attachment, WebGLTextureAttachment::create(texture, te xTarget, level, 0)); |
361 drawBuffersIfNecessary(false); | 371 drawBuffersIfNecessary(false); |
362 texture->onAttached(); | 372 texture->onAttached(); |
363 } | 373 } |
364 } | 374 } |
365 | 375 |
366 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, WebGLRenderbuffer* renderbuffer) | 376 void WebGLFramebuffer::setAttachmentForBoundFramebuffer(GLenum target, GLenum at tachment, WebGLRenderbuffer* renderbuffer) |
367 { | 377 { |
368 ASSERT(isBound(target)); | 378 ASSERT(isBound(target)); |
369 removeAttachmentFromBoundFramebuffer(target, attachment); | 379 removeAttachmentFromBoundFramebuffer(target, attachment); |
370 if (!m_object) | 380 if (!m_object) |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
660 return true; | 670 return true; |
661 } | 671 } |
662 | 672 |
663 DEFINE_TRACE(WebGLFramebuffer) | 673 DEFINE_TRACE(WebGLFramebuffer) |
664 { | 674 { |
665 visitor->trace(m_attachments); | 675 visitor->trace(m_attachments); |
666 WebGLContextObject::trace(visitor); | 676 WebGLContextObject::trace(visitor); |
667 } | 677 } |
668 | 678 |
669 } | 679 } |
OLD | NEW |