| 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 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 Destroy(); | 2016 Destroy(); |
| 2017 return false; | 2017 return false; |
| 2018 } | 2018 } |
| 2019 | 2019 |
| 2020 CHECK_GL_ERROR(); | 2020 CHECK_GL_ERROR(); |
| 2021 disallowed_features_ = disallowed_features; | 2021 disallowed_features_ = disallowed_features; |
| 2022 | 2022 |
| 2023 vertex_attrib_manager_.reset(new VertexAttribManager()); | 2023 vertex_attrib_manager_.reset(new VertexAttribManager()); |
| 2024 vertex_attrib_manager_->Initialize(group_->max_vertex_attribs()); | 2024 vertex_attrib_manager_->Initialize(group_->max_vertex_attribs()); |
| 2025 | 2025 |
| 2026 query_manager_.reset(new QueryManager()); | 2026 query_manager_.reset(new QueryManager(this, feature_info_->feature_flags( |
| 2027 ).use_arb_occlusion_query2_for_occlusion_query_boolean)); |
| 2027 | 2028 |
| 2028 util_.set_num_compressed_texture_formats( | 2029 util_.set_num_compressed_texture_formats( |
| 2029 validators_->compressed_texture_format.GetValues().size()); | 2030 validators_->compressed_texture_format.GetValues().size()); |
| 2030 | 2031 |
| 2031 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { | 2032 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { |
| 2032 // We have to enable vertex array 0 on OpenGL or it won't render. Note that | 2033 // We have to enable vertex array 0 on OpenGL or it won't render. Note that |
| 2033 // OpenGL ES 2.0 does not have this issue. | 2034 // OpenGL ES 2.0 does not have this issue. |
| 2034 glEnableVertexAttribArray(0); | 2035 glEnableVertexAttribArray(0); |
| 2035 } | 2036 } |
| 2036 glGenBuffersARB(1, &attrib_0_buffer_id_); | 2037 glGenBuffersARB(1, &attrib_0_buffer_id_); |
| (...skipping 5887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7924 return false; | 7925 return false; |
| 7925 } | 7926 } |
| 7926 | 7927 |
| 7927 bool GLES2DecoderImpl::GenQueriesEXTHelper( | 7928 bool GLES2DecoderImpl::GenQueriesEXTHelper( |
| 7928 GLsizei n, const GLuint* client_ids) { | 7929 GLsizei n, const GLuint* client_ids) { |
| 7929 for (GLsizei ii = 0; ii < n; ++ii) { | 7930 for (GLsizei ii = 0; ii < n; ++ii) { |
| 7930 if (query_manager_->GetQuery(client_ids[ii])) { | 7931 if (query_manager_->GetQuery(client_ids[ii])) { |
| 7931 return false; | 7932 return false; |
| 7932 } | 7933 } |
| 7933 } | 7934 } |
| 7934 scoped_array<GLuint> service_ids(new GLuint[n]); | 7935 // NOTE: We don't generate Query objects here. Only in BeginQueryEXT |
| 7935 glGenQueriesARB(n, service_ids.get()); | |
| 7936 for (GLsizei ii = 0; ii < n; ++ii) { | |
| 7937 query_manager_->CreateQuery(client_ids[ii], service_ids[ii]); | |
| 7938 } | |
| 7939 return true; | 7936 return true; |
| 7940 } | 7937 } |
| 7941 | 7938 |
| 7942 void GLES2DecoderImpl::DeleteQueriesEXTHelper( | 7939 void GLES2DecoderImpl::DeleteQueriesEXTHelper( |
| 7943 GLsizei n, const GLuint* client_ids) { | 7940 GLsizei n, const GLuint* client_ids) { |
| 7944 for (GLsizei ii = 0; ii < n; ++ii) { | 7941 for (GLsizei ii = 0; ii < n; ++ii) { |
| 7945 QueryManager::Query* query = query_manager_->GetQuery(client_ids[ii]); | 7942 QueryManager::Query* query = query_manager_->GetQuery(client_ids[ii]); |
| 7946 if (query && !query->IsDeleted()) { | 7943 if (query && !query->IsDeleted()) { |
| 7947 if (query == current_query_) { | 7944 if (query == current_query_) { |
| 7948 current_query_ = NULL; | 7945 current_query_ = NULL; |
| 7949 } | 7946 } |
| 7950 GLuint service_id = query->service_id(); | 7947 query->Destroy(true); |
| 7951 glDeleteQueriesARB(1, &service_id); | |
| 7952 query_manager_->RemoveQuery(client_ids[ii]); | 7948 query_manager_->RemoveQuery(client_ids[ii]); |
| 7953 } | 7949 } |
| 7954 } | 7950 } |
| 7955 } | 7951 } |
| 7956 | 7952 |
| 7957 bool GLES2DecoderImpl::ProcessPendingQueries() { | 7953 bool GLES2DecoderImpl::ProcessPendingQueries() { |
| 7958 if (query_manager_.get() == NULL) { | 7954 if (query_manager_.get() == NULL) { |
| 7959 return false; | 7955 return false; |
| 7960 } | 7956 } |
| 7961 if (!query_manager_->ProcessPendingQueries(this)) { | 7957 if (!query_manager_->ProcessPendingQueries()) { |
| 7962 current_decoder_error_ = error::kOutOfBounds; | 7958 current_decoder_error_ = error::kOutOfBounds; |
| 7963 } | 7959 } |
| 7964 return query_manager_->HavePendingQueries(); | 7960 return query_manager_->HavePendingQueries(); |
| 7965 } | 7961 } |
| 7966 | 7962 |
| 7967 error::Error GLES2DecoderImpl::HandleBeginQueryEXT( | 7963 error::Error GLES2DecoderImpl::HandleBeginQueryEXT( |
| 7968 uint32 immediate_data_size, const gles2::BeginQueryEXT& c) { | 7964 uint32 immediate_data_size, const gles2::BeginQueryEXT& c) { |
| 7969 GLenum target = static_cast<GLenum>(c.target); | 7965 GLenum target = static_cast<GLenum>(c.target); |
| 7970 GLuint client_id = static_cast<GLuint>(c.id); | 7966 GLuint client_id = static_cast<GLuint>(c.id); |
| 7971 int32 sync_shm_id = static_cast<int32>(c.sync_data_shm_id); | 7967 int32 sync_shm_id = static_cast<int32>(c.sync_data_shm_id); |
| 7972 uint32 sync_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); | 7968 uint32 sync_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); |
| 7973 | 7969 |
| 7974 if (!feature_info_->feature_flags().occlusion_query_boolean) { | 7970 switch (target) { |
| 7975 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: not enabled"); | 7971 case GL_COMMANDS_ISSUED_CHROMIUM: |
| 7976 return error::kNoError; | 7972 break; |
| 7973 default: |
| 7974 if (!feature_info_->feature_flags().occlusion_query_boolean) { |
| 7975 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: not enabled"); |
| 7976 return error::kNoError; |
| 7977 } |
| 7978 break; |
| 7977 } | 7979 } |
| 7978 | 7980 |
| 7979 if (current_query_) { | 7981 if (current_query_) { |
| 7980 SetGLError( | 7982 SetGLError( |
| 7981 GL_INVALID_OPERATION, "glBeginQueryEXT: query already in progress"); | 7983 GL_INVALID_OPERATION, "glBeginQueryEXT: query already in progress"); |
| 7982 return error::kNoError; | 7984 return error::kNoError; |
| 7983 } | 7985 } |
| 7984 | 7986 |
| 7985 if (client_id == 0) { | 7987 if (client_id == 0) { |
| 7986 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: id is 0"); | 7988 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: id is 0"); |
| 7987 return error::kNoError; | 7989 return error::kNoError; |
| 7988 } | 7990 } |
| 7989 | 7991 |
| 7990 QueryManager::Query* query = query_manager_->GetQuery(client_id); | 7992 QueryManager::Query* query = query_manager_->GetQuery(client_id); |
| 7991 if (!query) { | 7993 if (!query) { |
| 7994 // TODO(gman): Decide if we need this check. |
| 7995 // |
| 7992 // Checks id was made by glGenQueries | 7996 // Checks id was made by glGenQueries |
| 7993 IdAllocatorInterface* id_allocator = | 7997 // |
| 7994 group_->GetIdAllocator(id_namespaces::kQueries); | 7998 // From the POV of OpenGL ES 2.0 you need to call glGenQueriesEXT |
| 7995 if (!id_allocator->InUse(client_id)) { | 7999 // for all Query ids but from the POV of the command buffer service maybe |
| 7996 SetGLError(GL_INVALID_OPERATION, | 8000 // you don't. |
| 7997 "glBeginQueryEXT: id not made by glGenQueriesEXT"); | 8001 // |
| 7998 return error::kNoError; | 8002 // The client can enforce this. I don't think the service cares. |
| 7999 } | 8003 // |
| 8000 // Makes object and assoicates with memory. | 8004 // IdAllocatorInterface* id_allocator = |
| 8001 GLuint service_id = 0; | 8005 // group_->GetIdAllocator(id_namespaces::kQueries); |
| 8002 glGenQueriesARB(1, &service_id); | 8006 // if (!id_allocator->InUse(client_id)) { |
| 8003 DCHECK_NE(0u, service_id); | 8007 // SetGLError(GL_INVALID_OPERATION, |
| 8004 query = query_manager_->CreateQuery(client_id, service_id); | 8008 // "glBeginQueryEXT: id not made by glGenQueriesEXT"); |
| 8009 // return error::kNoError; |
| 8010 // } |
| 8011 query = query_manager_->CreateQuery( |
| 8012 target, client_id, sync_shm_id, sync_shm_offset); |
| 8005 } | 8013 } |
| 8006 | 8014 |
| 8007 QuerySync* sync = GetSharedMemoryAs<QuerySync*>( | 8015 if (query->target() != target) { |
| 8008 sync_shm_id, sync_shm_offset, sizeof(*sync)); | |
| 8009 if (!sync) { | |
| 8010 DLOG(ERROR) << "Invalid shared memory referenced by query"; | |
| 8011 return error::kOutOfBounds; | |
| 8012 } | |
| 8013 | |
| 8014 if (!query->IsInitialized()) { | |
| 8015 query->Initialize(target, sync_shm_id, sync_shm_offset); | |
| 8016 } else if (query->target() != target) { | |
| 8017 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: target does not match"); | 8016 SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT: target does not match"); |
| 8018 return error::kNoError; | 8017 return error::kNoError; |
| 8019 } else if (query->shm_id() != sync_shm_id || | 8018 } else if (query->shm_id() != sync_shm_id || |
| 8020 query->shm_offset() != sync_shm_offset) { | 8019 query->shm_offset() != sync_shm_offset) { |
| 8021 DLOG(ERROR) << "Shared memory used by query not the same as before"; | 8020 DLOG(ERROR) << "Shared memory used by query not the same as before"; |
| 8022 return error::kInvalidArguments; | 8021 return error::kInvalidArguments; |
| 8023 } | 8022 } |
| 8024 | 8023 |
| 8025 query_manager_->RemovePendingQuery(query); | 8024 if (!query_manager_->BeginQuery(query)) { |
| 8025 return error::kOutOfBounds; |
| 8026 } |
| 8026 | 8027 |
| 8027 glBeginQueryARB(target, query->service_id()); | |
| 8028 current_query_ = query; | 8028 current_query_ = query; |
| 8029 | |
| 8030 return error::kNoError; | 8029 return error::kNoError; |
| 8031 } | 8030 } |
| 8032 | 8031 |
| 8033 error::Error GLES2DecoderImpl::HandleEndQueryEXT( | 8032 error::Error GLES2DecoderImpl::HandleEndQueryEXT( |
| 8034 uint32 immediate_data_size, const gles2::EndQueryEXT& c) { | 8033 uint32 immediate_data_size, const gles2::EndQueryEXT& c) { |
| 8035 GLenum target = static_cast<GLenum>(c.target); | 8034 GLenum target = static_cast<GLenum>(c.target); |
| 8036 uint32 submit_count = static_cast<GLuint>(c.submit_count); | 8035 uint32 submit_count = static_cast<GLuint>(c.submit_count); |
| 8037 | 8036 |
| 8038 if (!current_query_) { | 8037 if (!current_query_) { |
| 8039 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT: No active query"); | 8038 SetGLError(GL_INVALID_OPERATION, "glEndQueryEXT: No active query"); |
| 8040 return error::kNoError; | 8039 return error::kNoError; |
| 8041 } | 8040 } |
| 8042 if (current_query_->target() != target) { | 8041 if (current_query_->target() != target) { |
| 8043 SetGLError(GL_INVALID_OPERATION, | 8042 SetGLError(GL_INVALID_OPERATION, |
| 8044 "glEndQueryEXT: target does not match active query"); | 8043 "glEndQueryEXT: target does not match active query"); |
| 8045 return error::kNoError; | 8044 return error::kNoError; |
| 8046 } | 8045 } |
| 8047 glEndQueryARB(target); | 8046 |
| 8048 query_manager_->AddPendingQuery(current_query_, submit_count); | 8047 if (!query_manager_->EndQuery(current_query_, submit_count)) { |
| 8048 return error::kOutOfBounds; |
| 8049 } |
| 8050 |
| 8049 current_query_ = NULL; | 8051 current_query_ = NULL; |
| 8050 | |
| 8051 return error::kNoError; | 8052 return error::kNoError; |
| 8052 } | 8053 } |
| 8053 | 8054 |
| 8054 error::Error GLES2DecoderImpl::HandleCreateStreamTextureCHROMIUM( | 8055 error::Error GLES2DecoderImpl::HandleCreateStreamTextureCHROMIUM( |
| 8055 uint32 immediate_data_size, | 8056 uint32 immediate_data_size, |
| 8056 const gles2::CreateStreamTextureCHROMIUM& c) { | 8057 const gles2::CreateStreamTextureCHROMIUM& c) { |
| 8057 if (!feature_info_->feature_flags().chromium_stream_texture) { | 8058 if (!feature_info_->feature_flags().chromium_stream_texture) { |
| 8058 SetGLError(GL_INVALID_OPERATION, | 8059 SetGLError(GL_INVALID_OPERATION, |
| 8059 "glOpenStreamTextureCHROMIUM: " | 8060 "glOpenStreamTextureCHROMIUM: " |
| 8060 "not supported."); | 8061 "not supported."); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8370 } | 8371 } |
| 8371 } | 8372 } |
| 8372 | 8373 |
| 8373 // Include the auto-generated part of this file. We split this because it means | 8374 // Include the auto-generated part of this file. We split this because it means |
| 8374 // we can easily edit the non-auto generated parts right here in this file | 8375 // we can easily edit the non-auto generated parts right here in this file |
| 8375 // instead of having to edit some template or the code generator. | 8376 // instead of having to edit some template or the code generator. |
| 8376 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 8377 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 8377 | 8378 |
| 8378 } // namespace gles2 | 8379 } // namespace gles2 |
| 8379 } // namespace gpu | 8380 } // namespace gpu |
| OLD | NEW |