Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 116863003: gpu: Reuse transfer buffers more aggresively (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: [RFC] gpu: Reuse transfer buffers more aggressively Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 if (it != state_.current_queries.end()) {
9355 state_.current_queries.erase(it);
9354 } 9356 }
9357
9355 query->Destroy(true); 9358 query->Destroy(true);
9356 query_manager_->RemoveQuery(client_ids[ii]); 9359 query_manager_->RemoveQuery(client_ids[ii]);
9357 } 9360 }
9358 } 9361 }
9359 } 9362 }
9360 9363
9361 bool GLES2DecoderImpl::ProcessPendingQueries() { 9364 bool GLES2DecoderImpl::ProcessPendingQueries() {
9362 if (query_manager_.get() == NULL) { 9365 if (query_manager_.get() == NULL) {
9363 return false; 9366 return false;
9364 } 9367 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
9407 uint32 immediate_data_size, const cmds::BeginQueryEXT& c) { 9410 uint32 immediate_data_size, const cmds::BeginQueryEXT& c) {
9408 GLenum target = static_cast<GLenum>(c.target); 9411 GLenum target = static_cast<GLenum>(c.target);
9409 GLuint client_id = static_cast<GLuint>(c.id); 9412 GLuint client_id = static_cast<GLuint>(c.id);
9410 int32 sync_shm_id = static_cast<int32>(c.sync_data_shm_id); 9413 int32 sync_shm_id = static_cast<int32>(c.sync_data_shm_id);
9411 uint32 sync_shm_offset = static_cast<uint32>(c.sync_data_shm_offset); 9414 uint32 sync_shm_offset = static_cast<uint32>(c.sync_data_shm_offset);
9412 9415
9413 switch (target) { 9416 switch (target) {
9414 case GL_COMMANDS_ISSUED_CHROMIUM: 9417 case GL_COMMANDS_ISSUED_CHROMIUM:
9415 case GL_LATENCY_QUERY_CHROMIUM: 9418 case GL_LATENCY_QUERY_CHROMIUM:
9416 case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM: 9419 case GL_ASYNC_PIXEL_UNPACK_COMPLETED_CHROMIUM:
9420 case GL_ASYNC_PIXEL_UNPACK_COMPLETED_PRIVATE_CHROMIUM:
9417 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: 9421 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM:
9418 case GL_GET_ERROR_QUERY_CHROMIUM: 9422 case GL_GET_ERROR_QUERY_CHROMIUM:
9419 break; 9423 break;
9420 default: 9424 default:
9421 if (!features().occlusion_query_boolean) { 9425 if (!features().occlusion_query_boolean) {
9422 LOCAL_SET_GL_ERROR( 9426 LOCAL_SET_GL_ERROR(
9423 GL_INVALID_OPERATION, "glBeginQueryEXT", 9427 GL_INVALID_OPERATION, "glBeginQueryEXT",
9424 "not enabled for occlusion queries"); 9428 "not enabled for occlusion queries");
9425 return error::kNoError; 9429 return error::kNoError;
9426 } 9430 }
9427 break; 9431 break;
9428 } 9432 }
9429 9433
9430 // TODO(hubbe): Make it possible to have one query per type running at the 9434 if (state_.current_queries.find(target) != state_.current_queries.end()) {
9431 // same time.
9432 if (state_.current_query.get()) {
9433 LOCAL_SET_GL_ERROR( 9435 LOCAL_SET_GL_ERROR(
9434 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress"); 9436 GL_INVALID_OPERATION, "glBeginQueryEXT", "query already in progress");
9435 return error::kNoError; 9437 return error::kNoError;
9436 } 9438 }
9437 9439
9438 if (client_id == 0) { 9440 if (client_id == 0) {
9439 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0"); 9441 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glBeginQueryEXT", "id is 0");
9440 return error::kNoError; 9442 return error::kNoError;
9441 } 9443 }
9442 9444
(...skipping 28 matching lines...) Expand all
9471 } else if (query->shm_id() != sync_shm_id || 9473 } else if (query->shm_id() != sync_shm_id ||
9472 query->shm_offset() != sync_shm_offset) { 9474 query->shm_offset() != sync_shm_offset) {
9473 DLOG(ERROR) << "Shared memory used by query not the same as before"; 9475 DLOG(ERROR) << "Shared memory used by query not the same as before";
9474 return error::kInvalidArguments; 9476 return error::kInvalidArguments;
9475 } 9477 }
9476 9478
9477 if (!query_manager_->BeginQuery(query)) { 9479 if (!query_manager_->BeginQuery(query)) {
9478 return error::kOutOfBounds; 9480 return error::kOutOfBounds;
9479 } 9481 }
9480 9482
9481 state_.current_query = query; 9483 state_.current_queries[target] = query;
9482 return error::kNoError; 9484 return error::kNoError;
9483 } 9485 }
9484 9486
9485 error::Error GLES2DecoderImpl::HandleEndQueryEXT( 9487 error::Error GLES2DecoderImpl::HandleEndQueryEXT(
9486 uint32 immediate_data_size, const cmds::EndQueryEXT& c) { 9488 uint32 immediate_data_size, const cmds::EndQueryEXT& c) {
9487 GLenum target = static_cast<GLenum>(c.target); 9489 GLenum target = static_cast<GLenum>(c.target);
9488 uint32 submit_count = static_cast<GLuint>(c.submit_count); 9490 uint32 submit_count = static_cast<GLuint>(c.submit_count);
9491 ContextState::QueryMap::iterator it = state_.current_queries.find(target);
9489 9492
9490 if (!state_.current_query.get()) { 9493 if (it == state_.current_queries.end()) {
9491 LOCAL_SET_GL_ERROR( 9494 LOCAL_SET_GL_ERROR(
9492 GL_INVALID_OPERATION, "glEndQueryEXT", "No active query"); 9495 GL_INVALID_OPERATION, "glEndQueryEXT", "No active query");
9493 return error::kNoError; 9496 return error::kNoError;
9494 } 9497 }
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 9498
9502 if (!query_manager_->EndQuery(state_.current_query.get(), submit_count)) { 9499 QueryManager::Query* query = it->second.get();
9500 if (!query_manager_->EndQuery(query, submit_count)) {
9503 return error::kOutOfBounds; 9501 return error::kOutOfBounds;
9504 } 9502 }
9505 9503
9506 query_manager_->ProcessPendingTransferQueries(); 9504 query_manager_->ProcessPendingTransferQueries();
9507 9505
9508 state_.current_query = NULL; 9506 state_.current_queries.erase(it);
9509 return error::kNoError; 9507 return error::kNoError;
9510 } 9508 }
9511 9509
9512 bool GLES2DecoderImpl::GenVertexArraysOESHelper( 9510 bool GLES2DecoderImpl::GenVertexArraysOESHelper(
9513 GLsizei n, const GLuint* client_ids) { 9511 GLsizei n, const GLuint* client_ids) {
9514 for (GLsizei ii = 0; ii < n; ++ii) { 9512 for (GLsizei ii = 0; ii < n; ++ii) {
9515 if (GetVertexAttribManager(client_ids[ii])) { 9513 if (GetVertexAttribManager(client_ids[ii])) {
9516 return false; 9514 return false;
9517 } 9515 }
9518 } 9516 }
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after
10641 DoDidUseTexImageIfNeeded(texture, texture->target()); 10639 DoDidUseTexImageIfNeeded(texture, texture->target());
10642 } 10640 }
10643 10641
10644 // Include the auto-generated part of this file. We split this because it means 10642 // 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 10643 // 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. 10644 // instead of having to edit some template or the code generator.
10647 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10645 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10648 10646
10649 } // namespace gles2 10647 } // namespace gles2
10650 } // namespace gpu 10648 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698