| 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 6060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6071 renderbuffer = GetRenderbuffer(client_renderbuffer_id); | 6071 renderbuffer = GetRenderbuffer(client_renderbuffer_id); |
| 6072 if (!renderbuffer) { | 6072 if (!renderbuffer) { |
| 6073 LOCAL_SET_GL_ERROR( | 6073 LOCAL_SET_GL_ERROR( |
| 6074 GL_INVALID_OPERATION, | 6074 GL_INVALID_OPERATION, |
| 6075 "glFramebufferRenderbuffer", "unknown renderbuffer"); | 6075 "glFramebufferRenderbuffer", "unknown renderbuffer"); |
| 6076 return; | 6076 return; |
| 6077 } | 6077 } |
| 6078 service_id = renderbuffer->service_id(); | 6078 service_id = renderbuffer->service_id(); |
| 6079 } | 6079 } |
| 6080 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer"); | 6080 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer"); |
| 6081 glFramebufferRenderbufferEXT( | 6081 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
| 6082 target, attachment, renderbuffertarget, service_id); | 6082 glFramebufferRenderbufferEXT( |
| 6083 target, GL_DEPTH_ATTACHMENT, renderbuffertarget, service_id); |
| 6084 glFramebufferRenderbufferEXT( |
| 6085 target, GL_STENCIL_ATTACHMENT, renderbuffertarget, service_id); |
| 6086 } else { |
| 6087 glFramebufferRenderbufferEXT( |
| 6088 target, attachment, renderbuffertarget, service_id); |
| 6089 } |
| 6083 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer"); | 6090 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer"); |
| 6084 if (error == GL_NO_ERROR) { | 6091 if (error == GL_NO_ERROR) { |
| 6085 framebuffer->AttachRenderbuffer(attachment, renderbuffer); | 6092 framebuffer->AttachRenderbuffer(attachment, renderbuffer); |
| 6086 } | 6093 } |
| 6087 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 6094 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
| 6088 framebuffer_state_.clear_state_dirty = true; | 6095 framebuffer_state_.clear_state_dirty = true; |
| 6089 } | 6096 } |
| 6090 OnFboChanged(); | 6097 OnFboChanged(); |
| 6091 } | 6098 } |
| 6092 | 6099 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6259 !texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) { | 6266 !texture_manager()->ValidForTarget(textarget, level, 0, 0, 1)) { |
| 6260 LOCAL_SET_GL_ERROR( | 6267 LOCAL_SET_GL_ERROR( |
| 6261 GL_INVALID_VALUE, | 6268 GL_INVALID_VALUE, |
| 6262 name, "level out of range"); | 6269 name, "level out of range"); |
| 6263 return; | 6270 return; |
| 6264 } | 6271 } |
| 6265 | 6272 |
| 6266 if (texture_ref) | 6273 if (texture_ref) |
| 6267 DoCopyTexImageIfNeeded(texture_ref->texture(), textarget); | 6274 DoCopyTexImageIfNeeded(texture_ref->texture(), textarget); |
| 6268 | 6275 |
| 6276 std::vector<GLenum> attachments; |
| 6277 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
| 6278 attachments.push_back(GL_DEPTH_ATTACHMENT); |
| 6279 attachments.push_back(GL_STENCIL_ATTACHMENT); |
| 6280 } else { |
| 6281 attachments.push_back(attachment); |
| 6282 } |
| 6269 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(name); | 6283 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(name); |
| 6270 if (0 == samples) { | 6284 for (size_t ii = 0; ii < attachments.size(); ++ii) { |
| 6271 glFramebufferTexture2DEXT(target, attachment, textarget, service_id, level); | 6285 if (0 == samples) { |
| 6272 } else { | 6286 glFramebufferTexture2DEXT( |
| 6273 if (features().use_img_for_multisampled_render_to_texture) { | 6287 target, attachments[ii], textarget, service_id, level); |
| 6274 glFramebufferTexture2DMultisampleIMG(target, attachment, textarget, | |
| 6275 service_id, level, samples); | |
| 6276 } else { | 6288 } else { |
| 6277 glFramebufferTexture2DMultisampleEXT(target, attachment, textarget, | 6289 if (features().use_img_for_multisampled_render_to_texture) { |
| 6278 service_id, level, samples); | 6290 glFramebufferTexture2DMultisampleIMG( |
| 6291 target, attachments[ii], textarget, service_id, level, samples); |
| 6292 } else { |
| 6293 glFramebufferTexture2DMultisampleEXT( |
| 6294 target, attachments[ii], textarget, service_id, level, samples); |
| 6295 } |
| 6279 } | 6296 } |
| 6280 } | 6297 } |
| 6281 GLenum error = LOCAL_PEEK_GL_ERROR(name); | 6298 GLenum error = LOCAL_PEEK_GL_ERROR(name); |
| 6282 if (error == GL_NO_ERROR) { | 6299 if (error == GL_NO_ERROR) { |
| 6283 framebuffer->AttachTexture(attachment, texture_ref, textarget, level, | 6300 framebuffer->AttachTexture(attachment, texture_ref, textarget, level, |
| 6284 samples); | 6301 samples); |
| 6285 } | 6302 } |
| 6286 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 6303 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
| 6287 framebuffer_state_.clear_state_dirty = true; | 6304 framebuffer_state_.clear_state_dirty = true; |
| 6288 } | 6305 } |
| (...skipping 3762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10051 uint32_t channels = GLES2Util::GetChannelsForFormat(format); | 10068 uint32_t channels = GLES2Util::GetChannelsForFormat(format); |
| 10052 if ((feature_info_->feature_flags().angle_depth_texture || | 10069 if ((feature_info_->feature_flags().angle_depth_texture || |
| 10053 feature_info_->IsES3Enabled()) | 10070 feature_info_->IsES3Enabled()) |
| 10054 && (channels & GLES2Util::kDepth) != 0) { | 10071 && (channels & GLES2Util::kDepth) != 0) { |
| 10055 // It's a depth format and ANGLE doesn't allow texImage2D or texSubImage2D | 10072 // It's a depth format and ANGLE doesn't allow texImage2D or texSubImage2D |
| 10056 // on depth formats. | 10073 // on depth formats. |
| 10057 GLuint fb = 0; | 10074 GLuint fb = 0; |
| 10058 glGenFramebuffersEXT(1, &fb); | 10075 glGenFramebuffersEXT(1, &fb); |
| 10059 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb); | 10076 glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, fb); |
| 10060 | 10077 |
| 10078 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT, |
| 10079 target, texture->service_id(), level); |
| 10061 bool have_stencil = (channels & GLES2Util::kStencil) != 0; | 10080 bool have_stencil = (channels & GLES2Util::kStencil) != 0; |
| 10062 GLenum attachment = have_stencil ? GL_DEPTH_STENCIL_ATTACHMENT : | 10081 if (have_stencil) { |
| 10063 GL_DEPTH_ATTACHMENT; | 10082 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT, |
| 10083 target, texture->service_id(), level); |
| 10084 } |
| 10064 | 10085 |
| 10065 glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER_EXT, attachment, target, | |
| 10066 texture->service_id(), level); | |
| 10067 // ANGLE promises a depth only attachment ok. | 10086 // ANGLE promises a depth only attachment ok. |
| 10068 if (glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT) != | 10087 if (glCheckFramebufferStatusEXT(GL_DRAW_FRAMEBUFFER_EXT) != |
| 10069 GL_FRAMEBUFFER_COMPLETE) { | 10088 GL_FRAMEBUFFER_COMPLETE) { |
| 10070 return false; | 10089 return false; |
| 10071 } | 10090 } |
| 10072 glClearStencil(0); | 10091 glClearStencil(0); |
| 10073 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); | 10092 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); |
| 10074 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); | 10093 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); |
| 10075 glClearDepth(1.0f); | 10094 glClearDepth(1.0f); |
| 10076 state_.SetDeviceDepthMask(GL_TRUE); | 10095 state_.SetDeviceDepthMask(GL_TRUE); |
| (...skipping 5513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15590 } | 15609 } |
| 15591 | 15610 |
| 15592 // Include the auto-generated part of this file. We split this because it means | 15611 // Include the auto-generated part of this file. We split this because it means |
| 15593 // we can easily edit the non-auto generated parts right here in this file | 15612 // we can easily edit the non-auto generated parts right here in this file |
| 15594 // instead of having to edit some template or the code generator. | 15613 // instead of having to edit some template or the code generator. |
| 15595 #include "base/macros.h" | 15614 #include "base/macros.h" |
| 15596 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15615 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 15597 | 15616 |
| 15598 } // namespace gles2 | 15617 } // namespace gles2 |
| 15599 } // namespace gpu | 15618 } // namespace gpu |
| OLD | NEW |