Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| (...skipping 6058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6069 renderbuffer = GetRenderbuffer(client_renderbuffer_id); | 6069 renderbuffer = GetRenderbuffer(client_renderbuffer_id); |
| 6070 if (!renderbuffer) { | 6070 if (!renderbuffer) { |
| 6071 LOCAL_SET_GL_ERROR( | 6071 LOCAL_SET_GL_ERROR( |
| 6072 GL_INVALID_OPERATION, | 6072 GL_INVALID_OPERATION, |
| 6073 "glFramebufferRenderbuffer", "unknown renderbuffer"); | 6073 "glFramebufferRenderbuffer", "unknown renderbuffer"); |
| 6074 return; | 6074 return; |
| 6075 } | 6075 } |
| 6076 service_id = renderbuffer->service_id(); | 6076 service_id = renderbuffer->service_id(); |
| 6077 } | 6077 } |
| 6078 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer"); | 6078 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer"); |
| 6079 glFramebufferRenderbufferEXT( | 6079 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
| 6080 target, attachment, renderbuffertarget, service_id); | 6080 glFramebufferRenderbufferEXT( |
| 6081 target, GL_DEPTH_ATTACHMENT, renderbuffertarget, service_id); | |
| 6082 glFramebufferRenderbufferEXT( | |
| 6083 target, GL_STENCIL_ATTACHMENT, renderbuffertarget, service_id); | |
| 6084 } else { | |
| 6085 glFramebufferRenderbufferEXT( | |
| 6086 target, attachment, renderbuffertarget, service_id); | |
| 6087 } | |
| 6081 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer"); | 6088 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer"); |
| 6082 if (error == GL_NO_ERROR) { | 6089 if (error == GL_NO_ERROR) { |
| 6083 framebuffer->AttachRenderbuffer(attachment, renderbuffer); | 6090 framebuffer->AttachRenderbuffer(attachment, renderbuffer); |
| 6084 } | 6091 } |
| 6085 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 6092 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
| 6086 framebuffer_state_.clear_state_dirty = true; | 6093 framebuffer_state_.clear_state_dirty = true; |
| 6087 } | 6094 } |
| 6088 OnFboChanged(); | 6095 OnFboChanged(); |
| 6089 } | 6096 } |
| 6090 | 6097 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6257 !texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) { | 6264 !texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) { |
| 6258 LOCAL_SET_GL_ERROR( | 6265 LOCAL_SET_GL_ERROR( |
| 6259 GL_INVALID_VALUE, | 6266 GL_INVALID_VALUE, |
| 6260 name, "level out of range"); | 6267 name, "level out of range"); |
| 6261 return; | 6268 return; |
| 6262 } | 6269 } |
| 6263 | 6270 |
| 6264 if (texture_ref) | 6271 if (texture_ref) |
| 6265 DoCopyTexImageIfNeeded(texture_ref->texture(), textarget); | 6272 DoCopyTexImageIfNeeded(texture_ref->texture(), textarget); |
| 6266 | 6273 |
| 6274 std::vector<GLenum> attachments; | |
| 6275 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | |
| 6276 attachments.push_back(GL_DEPTH_ATTACHMENT); | |
| 6277 attachments.push_back(GL_STENCIL_ATTACHMENT); | |
| 6278 } else { | |
| 6279 attachments.push_back(attachment); | |
| 6280 } | |
| 6267 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(name); | 6281 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(name); |
| 6268 if (0 == samples) { | 6282 for (size_t ii = 0; ii < attachments.size(); ++ii) { |
| 6269 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level); | 6283 if (0 == samples) { |
| 6270 } else { | 6284 glFramebufferTexture2DEXT( |
| 6271 if (features().use_img_for_multisampled_render_to_texture) { | 6285 target, attachments[ii], textarget, service_id, level); |
| 6272 glFramebufferTexture2DMultisampleIMG(target, attachment, textarget, | |
| 6273 service_id, level, samples); | |
| 6274 } else { | 6286 } else { |
| 6275 glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, | 6287 if (features().use_img_for_multisampled_render_to_texture) { |
| 6276 service_id, level, samples); | 6288 glFramebufferTexture2DMultisampleIMG( |
| 6289 target, attachments[ii], textarget, service_id, level, samples); | |
| 6290 } else { | |
| 6291 glFramebufferTexture2DMultisampleEXT( | |
| 6292 target, attachments[ii], textarget, service_id, level, samples); | |
| 6293 } | |
| 6277 } | 6294 } |
| 6278 } | 6295 } |
| 6279 GLenum error = LOCAL_PEEK_GL_ERROR(name); | 6296 GLenum error = LOCAL_PEEK_GL_ERROR(name); |
| 6280 if (error == GL_NO_ERROR) { | 6297 if (error == GL_NO_ERROR) { |
| 6281 framebuffer->AttachTexture(attachment, texture_ref, textarget, level, | 6298 framebuffer->AttachTexture(attachment, texture_ref, textarget, level, |
| 6282 samples); | 6299 samples); |
| 6283 } | 6300 } |
| 6284 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 6301 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
| 6285 framebuffer_state_.clear_state_dirty = true; | 6302 framebuffer_state_.clear_state_dirty = true; |
| 6286 } | 6303 } |
| (...skipping 3762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10049 uint32_t channels = GLES2Util::GetChannelsForFormat(format); | 10066 uint32_t channels = GLES2Util::GetChannelsForFormat(format); |
| 10050 if ((feature_info_->feature_flags().angle_depth_texture || | 10067 if ((feature_info_->feature_flags().angle_depth_texture || |
| 10051 feature_info_->IsES3Enabled()) | 10068 feature_info_->IsES3Enabled()) |
| 10052 && (channels & GLES2Util::kDepth) != 0) { | 10069 && (channels & GLES2Util::kDepth) != 0) { |
| 10053 // It's a depth format and ANGLE doesn't allow texImage2D or texSubImage2D | 10070 // It's a depth format and ANGLE doesn't allow texImage2D or texSubImage2D |
| 10054 // on depth formats. | 10071 // on depth formats. |
| 10055 GLuint fb = 0; | 10072 GLuint fb = 0; |
| 10056 glGenFramebuffersEXT(1, &fb); | 10073 glGenFramebuffersEXT(1, &fb); |
| 10057 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb); | 10074 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb); |
| 10058 | 10075 |
| 10076 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT, | |
| 10077 target, texture->service_id(), level); | |
| 10059 bool have_stencil = (channels & GLES2Util::kStencil) != 0; | 10078 bool have_stencil = (channels & GLES2Util::kStencil) != 0; |
| 10060 GLenum attachment = have_stencil ? GL_DEPTH_STENCIL_ATTACHMENT : | 10079 if (have_stencil) { |
| 10061 GL_DEPTH_ATTACHMENT; | 10080 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT, |
|
piman
2016/02/08 17:44:39
Do we need to split this one too?
Zhenyao Mo
2016/02/08 18:52:48
What do you mean? This one is already split into
piman
2016/02/08 20:49:12
Huh, must have misread, apologies.
| |
| 10081 target, texture->service_id(), level); | |
| 10082 } | |
| 10062 | 10083 |
| 10063 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, attachment, target, | |
| 10064 texture->service_id(), level); | |
| 10065 // ANGLE promises a depth only attachment ok. | 10084 // ANGLE promises a depth only attachment ok. |
| 10066 if (glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT) != | 10085 if (glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT) != |
| 10067 GL_FRAMEBUFFER_COMPLETE) { | 10086 GL_FRAMEBUFFER_COMPLETE) { |
| 10068 return false; | 10087 return false; |
| 10069 } | 10088 } |
| 10070 glClearStencil(0); | 10089 glClearStencil(0); |
| 10071 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); | 10090 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); |
| 10072 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); | 10091 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); |
| 10073 glClearDepth(1.0f); | 10092 glClearDepth(1.0f); |
| 10074 state_.SetDeviceDepthMask(GL_TRUE); | 10093 state_.SetDeviceDepthMask(GL_TRUE); |
| (...skipping 5513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 15588 } | 15607 } |
| 15589 | 15608 |
| 15590 // Include the auto-generated part of this file. We split this because it means | 15609 // Include the auto-generated part of this file. We split this because it means |
| 15591 // we can easily edit the non-auto generated parts right here in this file | 15610 // we can easily edit the non-auto generated parts right here in this file |
| 15592 // instead of having to edit some template or the code generator. | 15611 // instead of having to edit some template or the code generator. |
| 15593 #include "base/macros.h" | 15612 #include "base/macros.h" |
| 15594 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15613 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 15595 | 15614 |
| 15596 } // namespace gles2 | 15615 } // namespace gles2 |
| 15597 } // namespace gpu | 15616 } // namespace gpu |
| OLD | NEW |