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 6953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6964 return; | 6964 return; |
6965 } | 6965 } |
6966 MarkDrawBufferAsCleared(GL_DEPTH, drawbuffer); | 6966 MarkDrawBufferAsCleared(GL_DEPTH, drawbuffer); |
6967 MarkDrawBufferAsCleared(GL_STENCIL, drawbuffer); | 6967 MarkDrawBufferAsCleared(GL_STENCIL, drawbuffer); |
6968 glClearBufferfi(buffer, drawbuffer, depth, stencil); | 6968 glClearBufferfi(buffer, drawbuffer, depth, stencil); |
6969 } | 6969 } |
6970 | 6970 |
6971 void GLES2DecoderImpl::DoFramebufferRenderbuffer( | 6971 void GLES2DecoderImpl::DoFramebufferRenderbuffer( |
6972 GLenum target, GLenum attachment, GLenum renderbuffertarget, | 6972 GLenum target, GLenum attachment, GLenum renderbuffertarget, |
6973 GLuint client_renderbuffer_id) { | 6973 GLuint client_renderbuffer_id) { |
| 6974 const char* func_name = "glFramebufferRenderbuffer"; |
6974 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 6975 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
6975 if (!framebuffer) { | 6976 if (!framebuffer) { |
6976 LOCAL_SET_GL_ERROR( | 6977 LOCAL_SET_GL_ERROR( |
6977 GL_INVALID_OPERATION, | 6978 GL_INVALID_OPERATION, func_name, "no framebuffer bound"); |
6978 "glFramebufferRenderbuffer", "no framebuffer bound"); | |
6979 return; | 6979 return; |
6980 } | 6980 } |
6981 GLuint service_id = 0; | 6981 GLuint service_id = 0; |
6982 Renderbuffer* renderbuffer = NULL; | 6982 Renderbuffer* renderbuffer = NULL; |
6983 if (client_renderbuffer_id) { | 6983 if (client_renderbuffer_id) { |
6984 renderbuffer = GetRenderbuffer(client_renderbuffer_id); | 6984 renderbuffer = GetRenderbuffer(client_renderbuffer_id); |
6985 if (!renderbuffer) { | 6985 if (!renderbuffer) { |
6986 LOCAL_SET_GL_ERROR( | 6986 LOCAL_SET_GL_ERROR( |
6987 GL_INVALID_OPERATION, | 6987 GL_INVALID_OPERATION, |
6988 "glFramebufferRenderbuffer", "unknown renderbuffer"); | 6988 func_name, "unknown renderbuffer"); |
6989 return; | 6989 return; |
6990 } | 6990 } |
6991 service_id = renderbuffer->service_id(); | 6991 service_id = renderbuffer->service_id(); |
6992 } | 6992 } |
6993 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer"); | 6993 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(func_name); |
6994 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { | 6994 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
6995 glFramebufferRenderbufferEXT( | 6995 glFramebufferRenderbufferEXT( |
6996 target, GL_DEPTH_ATTACHMENT, renderbuffertarget, service_id); | 6996 target, GL_DEPTH_ATTACHMENT, renderbuffertarget, service_id); |
6997 glFramebufferRenderbufferEXT( | 6997 glFramebufferRenderbufferEXT( |
6998 target, GL_STENCIL_ATTACHMENT, renderbuffertarget, service_id); | 6998 target, GL_STENCIL_ATTACHMENT, renderbuffertarget, service_id); |
6999 } else { | 6999 } else { |
7000 glFramebufferRenderbufferEXT( | 7000 glFramebufferRenderbufferEXT( |
7001 target, attachment, renderbuffertarget, service_id); | 7001 target, attachment, renderbuffertarget, service_id); |
7002 } | 7002 } |
7003 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer"); | 7003 GLenum error = LOCAL_PEEK_GL_ERROR(func_name); |
7004 if (error == GL_NO_ERROR) { | 7004 if (error == GL_NO_ERROR) { |
7005 framebuffer->AttachRenderbuffer(attachment, renderbuffer); | 7005 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
| 7006 framebuffer->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, renderbuffer); |
| 7007 framebuffer->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, renderbuffer); |
| 7008 } else { |
| 7009 framebuffer->AttachRenderbuffer(attachment, renderbuffer); |
| 7010 } |
7006 } | 7011 } |
7007 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 7012 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
7008 framebuffer_state_.clear_state_dirty = true; | 7013 framebuffer_state_.clear_state_dirty = true; |
7009 } | 7014 } |
7010 OnFboChanged(); | 7015 OnFboChanged(); |
7011 } | 7016 } |
7012 | 7017 |
7013 void GLES2DecoderImpl::DoDisable(GLenum cap) { | 7018 void GLES2DecoderImpl::DoDisable(GLenum cap) { |
7014 if (SetCapabilityState(cap, false)) { | 7019 if (SetCapabilityState(cap, false)) { |
7015 if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX && | 7020 if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX && |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7083 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); | 7088 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
7084 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); | 7089 state_.SetDeviceColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
7085 clear_bits |= GL_COLOR_BUFFER_BIT; | 7090 clear_bits |= GL_COLOR_BUFFER_BIT; |
7086 | 7091 |
7087 if (SupportsDrawBuffers()) { | 7092 if (SupportsDrawBuffers()) { |
7088 reset_draw_buffers = | 7093 reset_draw_buffers = |
7089 framebuffer->PrepareDrawBuffersForClearingUninitializedAttachments(); | 7094 framebuffer->PrepareDrawBuffersForClearingUninitializedAttachments(); |
7090 } | 7095 } |
7091 } | 7096 } |
7092 | 7097 |
7093 if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT) || | 7098 if (framebuffer->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)) { |
7094 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { | |
7095 glClearStencil(0); | 7099 glClearStencil(0); |
7096 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); | 7100 state_.SetDeviceStencilMaskSeparate(GL_FRONT, kDefaultStencilMask); |
7097 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); | 7101 state_.SetDeviceStencilMaskSeparate(GL_BACK, kDefaultStencilMask); |
7098 clear_bits |= GL_STENCIL_BUFFER_BIT; | 7102 clear_bits |= GL_STENCIL_BUFFER_BIT; |
7099 } | 7103 } |
7100 | 7104 |
7101 if (framebuffer->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT) || | 7105 if (framebuffer->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)) { |
7102 framebuffer->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)) { | |
7103 glClearDepth(1.0f); | 7106 glClearDepth(1.0f); |
7104 state_.SetDeviceDepthMask(GL_TRUE); | 7107 state_.SetDeviceDepthMask(GL_TRUE); |
7105 clear_bits |= GL_DEPTH_BUFFER_BIT; | 7108 clear_bits |= GL_DEPTH_BUFFER_BIT; |
7106 } | 7109 } |
7107 | 7110 |
7108 if (clear_bits) { | 7111 if (clear_bits) { |
7109 if (!cleared_int_renderbuffers && | 7112 if (!cleared_int_renderbuffers && |
7110 target == GL_READ_FRAMEBUFFER && draw_framebuffer != framebuffer) { | 7113 target == GL_READ_FRAMEBUFFER && draw_framebuffer != framebuffer) { |
7111 // TODO(zmo): There is no guarantee that an FBO that is complete on the | 7114 // TODO(zmo): There is no guarantee that an FBO that is complete on the |
7112 // READ attachment will be complete as a DRAW attachment. | 7115 // READ attachment will be complete as a DRAW attachment. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7237 glFramebufferTexture2DMultisampleIMG( | 7240 glFramebufferTexture2DMultisampleIMG( |
7238 target, attachments[ii], textarget, service_id, level, samples); | 7241 target, attachments[ii], textarget, service_id, level, samples); |
7239 } else { | 7242 } else { |
7240 glFramebufferTexture2DMultisampleEXT( | 7243 glFramebufferTexture2DMultisampleEXT( |
7241 target, attachments[ii], textarget, service_id, level, samples); | 7244 target, attachments[ii], textarget, service_id, level, samples); |
7242 } | 7245 } |
7243 } | 7246 } |
7244 } | 7247 } |
7245 GLenum error = LOCAL_PEEK_GL_ERROR(name); | 7248 GLenum error = LOCAL_PEEK_GL_ERROR(name); |
7246 if (error == GL_NO_ERROR) { | 7249 if (error == GL_NO_ERROR) { |
7247 framebuffer->AttachTexture(attachment, texture_ref, textarget, level, | 7250 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
7248 samples); | 7251 framebuffer->AttachTexture( |
| 7252 GL_DEPTH_ATTACHMENT, texture_ref, textarget, level, samples); |
| 7253 framebuffer->AttachTexture( |
| 7254 GL_STENCIL_ATTACHMENT, texture_ref, textarget, level, samples); |
| 7255 } else { |
| 7256 framebuffer->AttachTexture( |
| 7257 attachment, texture_ref, textarget, level, samples); |
| 7258 } |
7249 } | 7259 } |
7250 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 7260 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
7251 framebuffer_state_.clear_state_dirty = true; | 7261 framebuffer_state_.clear_state_dirty = true; |
7252 } | 7262 } |
7253 | 7263 |
7254 OnFboChanged(); | 7264 OnFboChanged(); |
7255 } | 7265 } |
7256 | 7266 |
7257 void GLES2DecoderImpl::DoFramebufferTextureLayer( | 7267 void GLES2DecoderImpl::DoFramebufferTextureLayer( |
7258 GLenum target, GLenum attachment, GLuint client_texture_id, | 7268 GLenum target, GLenum attachment, GLuint client_texture_id, |
(...skipping 28 matching lines...) Expand all Loading... |
7287 "texture is neither TEXTURE_3D nor TEXTURE_2D_ARRAY"); | 7297 "texture is neither TEXTURE_3D nor TEXTURE_2D_ARRAY"); |
7288 return; | 7298 return; |
7289 } | 7299 } |
7290 if (!texture_manager()->ValidForTarget(texture_target, level, | 7300 if (!texture_manager()->ValidForTarget(texture_target, level, |
7291 0, 0, layer)) { | 7301 0, 0, layer)) { |
7292 LOCAL_SET_GL_ERROR( | 7302 LOCAL_SET_GL_ERROR( |
7293 GL_INVALID_VALUE, function_name, "invalid level or layer"); | 7303 GL_INVALID_VALUE, function_name, "invalid level or layer"); |
7294 return; | 7304 return; |
7295 } | 7305 } |
7296 } | 7306 } |
7297 glFramebufferTextureLayer(target, attachment, service_id, level, layer); | 7307 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); |
7298 framebuffer->AttachTextureLayer( | 7308 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
7299 attachment, texture_ref, texture_target, level, layer); | 7309 glFramebufferTextureLayer( |
| 7310 target, GL_DEPTH_ATTACHMENT, service_id, level, layer); |
| 7311 glFramebufferTextureLayer( |
| 7312 target, GL_STENCIL_ATTACHMENT, service_id, level, layer); |
| 7313 } else { |
| 7314 glFramebufferTextureLayer(target, attachment, service_id, level, layer); |
| 7315 } |
| 7316 GLenum error = LOCAL_PEEK_GL_ERROR(function_name); |
| 7317 if (error == GL_NO_ERROR) { |
| 7318 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { |
| 7319 framebuffer->AttachTextureLayer( |
| 7320 GL_DEPTH_ATTACHMENT, texture_ref, texture_target, level, layer); |
| 7321 framebuffer->AttachTextureLayer( |
| 7322 GL_STENCIL_ATTACHMENT, texture_ref, texture_target, level, layer); |
| 7323 } else { |
| 7324 framebuffer->AttachTextureLayer( |
| 7325 attachment, texture_ref, texture_target, level, layer); |
| 7326 } |
| 7327 } |
7300 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 7328 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
7301 framebuffer_state_.clear_state_dirty = true; | 7329 framebuffer_state_.clear_state_dirty = true; |
7302 } | 7330 } |
7303 } | 7331 } |
7304 | 7332 |
7305 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( | 7333 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( |
7306 GLenum target, GLenum attachment, GLenum pname, GLint* params) { | 7334 GLenum target, GLenum attachment, GLenum pname, GLint* params) { |
7307 const char kFunctionName[] = "glGetFramebufferAttachmentParameteriv"; | 7335 const char kFunctionName[] = "glGetFramebufferAttachmentParameteriv"; |
7308 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 7336 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
7309 if (!framebuffer) { | 7337 if (!framebuffer) { |
(...skipping 10145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17455 } | 17483 } |
17456 | 17484 |
17457 // Include the auto-generated part of this file. We split this because it means | 17485 // Include the auto-generated part of this file. We split this because it means |
17458 // we can easily edit the non-auto generated parts right here in this file | 17486 // we can easily edit the non-auto generated parts right here in this file |
17459 // instead of having to edit some template or the code generator. | 17487 // instead of having to edit some template or the code generator. |
17460 #include "base/macros.h" | 17488 #include "base/macros.h" |
17461 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17489 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
17462 | 17490 |
17463 } // namespace gles2 | 17491 } // namespace gles2 |
17464 } // namespace gpu | 17492 } // namespace gpu |
OLD | NEW |