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 <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <list> | 10 #include <list> |
(...skipping 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3092 void GLES2DecoderImpl::DeleteFramebuffersHelper( | 3092 void GLES2DecoderImpl::DeleteFramebuffersHelper( |
3093 GLsizei n, const GLuint* client_ids) { | 3093 GLsizei n, const GLuint* client_ids) { |
3094 bool supports_separate_framebuffer_binds = | 3094 bool supports_separate_framebuffer_binds = |
3095 features().chromium_framebuffer_multisample; | 3095 features().chromium_framebuffer_multisample; |
3096 | 3096 |
3097 for (GLsizei ii = 0; ii < n; ++ii) { | 3097 for (GLsizei ii = 0; ii < n; ++ii) { |
3098 Framebuffer* framebuffer = | 3098 Framebuffer* framebuffer = |
3099 GetFramebuffer(client_ids[ii]); | 3099 GetFramebuffer(client_ids[ii]); |
3100 if (framebuffer && !framebuffer->IsDeleted()) { | 3100 if (framebuffer && !framebuffer->IsDeleted()) { |
3101 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { | 3101 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { |
| 3102 framebuffer_state_.bound_draw_framebuffer = NULL; |
| 3103 framebuffer_state_.clear_state_dirty = true; |
3102 GLenum target = supports_separate_framebuffer_binds ? | 3104 GLenum target = supports_separate_framebuffer_binds ? |
3103 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; | 3105 GL_DRAW_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; |
3104 | |
3105 // Unbind attachments on FBO before deletion. | |
3106 if (workarounds().unbind_attachments_on_bound_render_fbo_delete) | |
3107 framebuffer->DoUnbindGLAttachmentsForWorkaround(target); | |
3108 | |
3109 glBindFramebufferEXT(target, GetBackbufferServiceId()); | 3106 glBindFramebufferEXT(target, GetBackbufferServiceId()); |
3110 framebuffer_state_.bound_draw_framebuffer = NULL; | |
3111 framebuffer_state_.clear_state_dirty = true; | |
3112 } | 3107 } |
3113 if (framebuffer == framebuffer_state_.bound_read_framebuffer.get()) { | 3108 if (framebuffer == framebuffer_state_.bound_read_framebuffer.get()) { |
3114 framebuffer_state_.bound_read_framebuffer = NULL; | 3109 framebuffer_state_.bound_read_framebuffer = NULL; |
3115 GLenum target = supports_separate_framebuffer_binds ? | 3110 GLenum target = supports_separate_framebuffer_binds ? |
3116 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; | 3111 GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER; |
3117 glBindFramebufferEXT(target, GetBackbufferServiceId()); | 3112 glBindFramebufferEXT(target, GetBackbufferServiceId()); |
3118 } | 3113 } |
3119 OnFboChanged(); | 3114 OnFboChanged(); |
3120 RemoveFramebuffer(client_ids[ii]); | 3115 RemoveFramebuffer(client_ids[ii]); |
3121 } | 3116 } |
(...skipping 8931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12053 Program* program = GetProgramInfoNotShader( | 12048 Program* program = GetProgramInfoNotShader( |
12054 client_id, "glUniformBlockBinding"); | 12049 client_id, "glUniformBlockBinding"); |
12055 if (!program) { | 12050 if (!program) { |
12056 return error::kNoError; | 12051 return error::kNoError; |
12057 } | 12052 } |
12058 GLuint service_id = program->service_id(); | 12053 GLuint service_id = program->service_id(); |
12059 glUniformBlockBinding(service_id, index, binding); | 12054 glUniformBlockBinding(service_id, index, binding); |
12060 return error::kNoError; | 12055 return error::kNoError; |
12061 } | 12056 } |
12062 | 12057 |
12063 error::Error GLES2DecoderImpl::HandleClientWaitSync( | |
12064 uint32_t immediate_data_size, const void* cmd_data) { | |
12065 if (!unsafe_es3_apis_enabled()) | |
12066 return error::kUnknownCommand; | |
12067 const gles2::cmds::ClientWaitSync& c = | |
12068 *static_cast<const gles2::cmds::ClientWaitSync*>(cmd_data); | |
12069 GLuint sync = static_cast<GLuint>(c.sync); | |
12070 GLbitfield flags = static_cast<GLbitfield>(c.flags); | |
12071 GLuint64 timeout = GLES2Util::MapTwoUint32ToUint64(c.timeout_0, c.timeout_1); | |
12072 typedef cmds::ClientWaitSync::Result Result; | |
12073 Result* result_dst = GetSharedMemoryAs<Result*>( | |
12074 c.result_shm_id, c.result_shm_offset, sizeof(*result_dst)); | |
12075 if (!result_dst) { | |
12076 return error::kOutOfBounds; | |
12077 } | |
12078 if (*result_dst != GL_WAIT_FAILED) { | |
12079 return error::kInvalidArguments; | |
12080 } | |
12081 GLsync service_sync = 0; | |
12082 if (!group_->GetSyncServiceId(sync, &service_sync)) { | |
12083 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "ClientWaitSync", "invalid sync"); | |
12084 return error::kNoError; | |
12085 } | |
12086 *result_dst = glClientWaitSync(service_sync, flags, timeout); | |
12087 return error::kNoError; | |
12088 } | |
12089 | |
12090 error::Error GLES2DecoderImpl::HandleWaitSync( | |
12091 uint32_t immediate_data_size, const void* cmd_data) { | |
12092 if (!unsafe_es3_apis_enabled()) | |
12093 return error::kUnknownCommand; | |
12094 const gles2::cmds::WaitSync& c = | |
12095 *static_cast<const gles2::cmds::WaitSync*>(cmd_data); | |
12096 GLuint sync = static_cast<GLuint>(c.sync); | |
12097 GLbitfield flags = static_cast<GLbitfield>(c.flags); | |
12098 GLuint64 timeout = GLES2Util::MapTwoUint32ToUint64(c.timeout_0, c.timeout_1); | |
12099 GLsync service_sync = 0; | |
12100 if (!group_->GetSyncServiceId(sync, &service_sync)) { | |
12101 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, "WaitSync", "invalid sync"); | |
12102 return error::kNoError; | |
12103 } | |
12104 glWaitSync(service_sync, flags, timeout); | |
12105 return error::kNoError; | |
12106 } | |
12107 | |
12108 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( | 12058 void GLES2DecoderImpl::OnTextureRefDetachedFromFramebuffer( |
12109 TextureRef* texture_ref) { | 12059 TextureRef* texture_ref) { |
12110 Texture* texture = texture_ref->texture(); | 12060 Texture* texture = texture_ref->texture(); |
12111 DoDidUseTexImageIfNeeded(texture, texture->target()); | 12061 DoDidUseTexImageIfNeeded(texture, texture->target()); |
12112 } | 12062 } |
12113 | 12063 |
12114 void GLES2DecoderImpl::OnContextLostError() { | 12064 void GLES2DecoderImpl::OnContextLostError() { |
12115 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); | 12065 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); |
12116 } | 12066 } |
12117 | 12067 |
12118 void GLES2DecoderImpl::OnOutOfMemoryError() { | 12068 void GLES2DecoderImpl::OnOutOfMemoryError() { |
12119 if (lose_context_when_out_of_memory_) { | 12069 if (lose_context_when_out_of_memory_) { |
12120 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); | 12070 group_->LoseContexts(GL_UNKNOWN_CONTEXT_RESET_ARB); |
12121 } | 12071 } |
12122 } | 12072 } |
12123 | 12073 |
12124 // Include the auto-generated part of this file. We split this because it means | 12074 // Include the auto-generated part of this file. We split this because it means |
12125 // we can easily edit the non-auto generated parts right here in this file | 12075 // we can easily edit the non-auto generated parts right here in this file |
12126 // instead of having to edit some template or the code generator. | 12076 // instead of having to edit some template or the code generator. |
12127 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 12077 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
12128 | 12078 |
12129 } // namespace gles2 | 12079 } // namespace gles2 |
12130 } // namespace gpu | 12080 } // namespace gpu |
OLD | NEW |