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 3184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3195 if (!initialized()) | 3195 if (!initialized()) |
3196 return; | 3196 return; |
3197 | 3197 |
3198 DCHECK(!have_context || context_->IsCurrent(NULL)); | 3198 DCHECK(!have_context || context_->IsCurrent(NULL)); |
3199 | 3199 |
3200 // Unbind everything. | 3200 // Unbind everything. |
3201 state_.vertex_attrib_manager = NULL; | 3201 state_.vertex_attrib_manager = NULL; |
3202 default_vertex_attrib_manager_ = NULL; | 3202 default_vertex_attrib_manager_ = NULL; |
3203 state_.texture_units.clear(); | 3203 state_.texture_units.clear(); |
3204 state_.bound_array_buffer = NULL; | 3204 state_.bound_array_buffer = NULL; |
3205 state_.current_query = NULL; | 3205 state_.current_queries.clear(); |
3206 framebuffer_state_.bound_read_framebuffer = NULL; | 3206 framebuffer_state_.bound_read_framebuffer = NULL; |
3207 framebuffer_state_.bound_draw_framebuffer = NULL; | 3207 framebuffer_state_.bound_draw_framebuffer = NULL; |
3208 state_.bound_renderbuffer = NULL; | 3208 state_.bound_renderbuffer = NULL; |
3209 | 3209 |
3210 if (offscreen_saved_color_texture_info_.get()) { | 3210 if (offscreen_saved_color_texture_info_.get()) { |
3211 DCHECK(offscreen_target_color_texture_); | 3211 DCHECK(offscreen_target_color_texture_); |
3212 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), | 3212 DCHECK_EQ(offscreen_saved_color_texture_info_->service_id(), |
3213 offscreen_saved_color_texture_->id()); | 3213 offscreen_saved_color_texture_->id()); |
3214 offscreen_saved_color_texture_->Invalidate(); | 3214 offscreen_saved_color_texture_->Invalidate(); |
3215 offscreen_saved_color_texture_info_ = NULL; | 3215 offscreen_saved_color_texture_info_ = NULL; |
(...skipping 6126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9342 } | 9342 } |
9343 // NOTE: We don't generate Query objects here. Only in BeginQueryEXT | 9343 // NOTE: We don't generate Query objects here. Only in BeginQueryEXT |
9344 return true; | 9344 return true; |
9345 } | 9345 } |
9346 | 9346 |
9347 void GLES2DecoderImpl::DeleteQueriesEXTHelper( | 9347 void GLES2DecoderImpl::DeleteQueriesEXTHelper( |
9348 GLsizei n, const GLuint* client_ids) { | 9348 GLsizei n, const GLuint* client_ids) { |
9349 for (GLsizei ii = 0; ii < n; ++ii) { | 9349 for (GLsizei ii = 0; ii < n; ++ii) { |
9350 QueryManager::Query* query = query_manager_->GetQuery(client_ids[ii]); | 9350 QueryManager::Query* query = query_manager_->GetQuery(client_ids[ii]); |
9351 if (query && !query->IsDeleted()) { | 9351 if (query && !query->IsDeleted()) { |
9352 if (query == state_.current_query.get()) { | 9352 ContextState::QueryMap::iterator it = |
9353 state_.current_query = NULL; | 9353 state_.current_queries.find(query->target()); |
9354 } | 9354 if (it != state_.current_queries.end()) |
| 9355 state_.current_queries.erase(it); |
| 9356 |
9355 query->Destroy(true); | 9357 query->Destroy(true); |
9356 query_manager_->RemoveQuery(client_ids[ii]); | 9358 query_manager_->RemoveQuery(client_ids[ii]); |
9357 } | 9359 } |
9358 } | 9360 } |
9359 } | 9361 } |
9360 | 9362 |
9361 bool GLES2DecoderImpl::ProcessPendingQueries() { | 9363 bool GLES2DecoderImpl::ProcessPendingQueries() { |
9362 if (query_manager_.get() == NULL) { | 9364 if (query_manager_.get() == NULL) { |
9363 return false; | 9365 return false; |
9364 } | 9366 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9420 default: | 9422 default: |
9421 if (!features().occlusion_query_boolean) { | 9423 if (!features().occlusion_query_boolean) { |
9422 LOCAL_SET_GL_ERROR( | 9424 LOCAL_SET_GL_ERROR( |
9423 GL_INVALID_OPERATION, "glBeginQueryEXT", | 9425 GL_INVALID_OPERATION, "glBeginQueryEXT", |
9424 "not enabled for occlusion queries"); | 9426 "not enabled for occlusion queries"); |
9425 return error::kNoError; | 9427 return error::kNoError; |
9426 } | 9428 } |
9427 break; | 9429 break; |
9428 } | 9430 } |
9429 | 9431 |
9430 // TODO(hubbe): Make it possible to have one query per type running at the | 9432 if (state_.current_queries.find(target) != state_.current_queries.end()) { |
9431 // same time. | |
9432 if (state_.current_query.get()) { | |
9433 LOCAL_SET_GL_ERROR( | 9433 LOCAL_SET_GL_ERROR( |
9434 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress"); | 9434 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress"); |
9435 return error::kNoError; | 9435 return error::kNoError; |
9436 } | 9436 } |
9437 | 9437 |
9438 if (client_id == 0) { | 9438 if (client_id == 0) { |
9439 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0"); | 9439 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0"); |
9440 return error::kNoError; | 9440 return error::kNoError; |
9441 } | 9441 } |
9442 | 9442 |
(...skipping 28 matching lines...) Expand all Loading... |
9471 } else if (query->shm_id() != sync_shm_id || | 9471 } else if (query->shm_id() != sync_shm_id || |
9472 query->shm_offset() != sync_shm_offset) { | 9472 query->shm_offset() != sync_shm_offset) { |
9473 DLOG(ERROR) << "Shared memory used by query not the same as before"; | 9473 DLOG(ERROR) << "Shared memory used by query not the same as before"; |
9474 return error::kInvalidArguments; | 9474 return error::kInvalidArguments; |
9475 } | 9475 } |
9476 | 9476 |
9477 if (!query_manager_->BeginQuery(query)) { | 9477 if (!query_manager_->BeginQuery(query)) { |
9478 return error::kOutOfBounds; | 9478 return error::kOutOfBounds; |
9479 } | 9479 } |
9480 | 9480 |
9481 state_.current_query = query; | 9481 state_.current_queries[target] = query; |
9482 return error::kNoError; | 9482 return error::kNoError; |
9483 } | 9483 } |
9484 | 9484 |
9485 error::Error GLES2DecoderImpl::HandleEndQueryEXT( | 9485 error::Error GLES2DecoderImpl::HandleEndQueryEXT( |
9486 uint32 immediate_data_size, const cmds::EndQueryEXT& c) { | 9486 uint32 immediate_data_size, const cmds::EndQueryEXT& c) { |
9487 GLenum target = static_cast<GLenum>(c.target); | 9487 GLenum target = static_cast<GLenum>(c.target); |
9488 uint32 submit_count = static_cast<GLuint>(c.submit_count); | 9488 uint32 submit_count = static_cast<GLuint>(c.submit_count); |
| 9489 ContextState::QueryMap::iterator it = state_.current_queries.find(target); |
9489 | 9490 |
9490 if (!state_.current_query.get()) { | 9491 if (it == state_.current_queries.end()) { |
9491 LOCAL_SET_GL_ERROR( | 9492 LOCAL_SET_GL_ERROR( |
9492 GL_INVALID_OPERATION, "glEndQueryEXT", "No active query"); | 9493 GL_INVALID_OPERATION, "glEndQueryEXT", "No active query"); |
9493 return error::kNoError; | 9494 return error::kNoError; |
9494 } | 9495 } |
9495 if (state_.current_query->target() != target) { | |
9496 LOCAL_SET_GL_ERROR( | |
9497 GL_INVALID_OPERATION, | |
9498 "glEndQueryEXT", "target does not match active query"); | |
9499 return error::kNoError; | |
9500 } | |
9501 | 9496 |
9502 if (!query_manager_->EndQuery(state_.current_query.get(), submit_count)) { | 9497 QueryManager::Query* query = it->second.get(); |
| 9498 if (!query_manager_->EndQuery(query, submit_count)) { |
9503 return error::kOutOfBounds; | 9499 return error::kOutOfBounds; |
9504 } | 9500 } |
9505 | 9501 |
9506 query_manager_->ProcessPendingTransferQueries(); | 9502 query_manager_->ProcessPendingTransferQueries(); |
9507 | 9503 |
9508 state_.current_query = NULL; | 9504 state_.current_queries.erase(it); |
9509 return error::kNoError; | 9505 return error::kNoError; |
9510 } | 9506 } |
9511 | 9507 |
9512 bool GLES2DecoderImpl::GenVertexArraysOESHelper( | 9508 bool GLES2DecoderImpl::GenVertexArraysOESHelper( |
9513 GLsizei n, const GLuint* client_ids) { | 9509 GLsizei n, const GLuint* client_ids) { |
9514 for (GLsizei ii = 0; ii < n; ++ii) { | 9510 for (GLsizei ii = 0; ii < n; ++ii) { |
9515 if (GetVertexAttribManager(client_ids[ii])) { | 9511 if (GetVertexAttribManager(client_ids[ii])) { |
9516 return false; | 9512 return false; |
9517 } | 9513 } |
9518 } | 9514 } |
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10641 DoDidUseTexImageIfNeeded(texture, texture->target()); | 10637 DoDidUseTexImageIfNeeded(texture, texture->target()); |
10642 } | 10638 } |
10643 | 10639 |
10644 // Include the auto-generated part of this file. We split this because it means | 10640 // Include the auto-generated part of this file. We split this because it means |
10645 // we can easily edit the non-auto generated parts right here in this file | 10641 // we can easily edit the non-auto generated parts right here in this file |
10646 // instead of having to edit some template or the code generator. | 10642 // instead of having to edit some template or the code generator. |
10647 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10643 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10648 | 10644 |
10649 } // namespace gles2 | 10645 } // namespace gles2 |
10650 } // namespace gpu | 10646 } // namespace gpu |
OLD | NEW |