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

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

Issue 2762833003: gpu: Use decoder state restoration for scoped_binders (Closed)
Patch Set: Created 3 years, 9 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/context_state.h" 5 #include "gpu/command_buffer/service/context_state.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 10
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 glVertexAttribI4uiv(attrib, v); 410 glVertexAttribI4uiv(attrib, v);
411 } 411 }
412 break; 412 break;
413 default: 413 default:
414 NOTREACHED(); 414 NOTREACHED();
415 break; 415 break;
416 } 416 }
417 } 417 }
418 } 418 }
419 419
420 void ContextState::RestoreVertexAttribArray(unsigned attrib_index) const {
421 const VertexAttrib* attrib =
422 vertex_attrib_manager->GetVertexAttrib(attrib_index);
423
424 // Restore vertex array.
425 Buffer* buffer = attrib->buffer();
426 GLuint buffer_service_id = buffer ? buffer->service_id() : 0;
427 glBindBuffer(GL_ARRAY_BUFFER, buffer_service_id);
428 const void* ptr = reinterpret_cast<const void*>(attrib->offset());
429 glVertexAttribPointer(attrib_index, attrib->size(), attrib->type(),
430 attrib->normalized(), attrib->gl_stride(), ptr);
431
432 // Restore attrib divisor if supported.
433 if (feature_info_->feature_flags().angle_instanced_arrays)
434 glVertexAttribDivisorANGLE(attrib_index, attrib->divisor());
435
436 // Never touch vertex attribute 0's state (in particular, never
437 // disable it) when running on desktop GL with compatibility profile
438 // because it will never be re-enabled.
439 if (attrib_index != 0 || feature_info_->gl_version_info().BehavesLikeGLES()) {
440 if (attrib->enabled()) {
441 glEnableVertexAttribArray(attrib_index);
442 } else {
443 glDisableVertexAttribArray(attrib_index);
444 }
445 }
446 }
447
420 void ContextState::RestoreVertexAttribArrays( 448 void ContextState::RestoreVertexAttribArrays(
421 const scoped_refptr<VertexAttribManager> attrib_manager) const { 449 const scoped_refptr<VertexAttribManager> attrib_manager) const {
422 // This is expected to be called only for VAO with service_id 0, 450 // This is expected to be called only for VAO with service_id 0,
423 // either to restore the default VAO or a virtual VAO with service_id 0. 451 // either to restore the default VAO or a virtual VAO with service_id 0.
424 GLuint vao_service_id = attrib_manager->service_id(); 452 GLuint vao_service_id = attrib_manager->service_id();
425 DCHECK(vao_service_id == 0); 453 DCHECK(vao_service_id == 0);
426 454
427 // Bind VAO if supported. 455 // Bind VAO if supported.
428 if (feature_info_->feature_flags().native_vertex_array_object) 456 if (feature_info_->feature_flags().native_vertex_array_object)
429 glBindVertexArrayOES(vao_service_id); 457 glBindVertexArrayOES(vao_service_id);
430 458
431 // Restore vertex attrib arrays. 459 // Restore vertex attrib arrays.
432 for (size_t attrib_index = 0; attrib_index < attrib_manager->num_attribs(); 460 for (size_t attrib_index = 0; attrib_index < attrib_manager->num_attribs();
433 ++attrib_index) { 461 ++attrib_index)
434 const VertexAttrib* attrib = attrib_manager->GetVertexAttrib(attrib_index); 462 RestoreVertexAttribArray(attrib_index);
piman 2017/03/22 21:28:26 This needs to pass in |attrib_manager|. RestoreVer
Chandan 2017/03/23 09:19:39 Have removed these changes in context_state.cc in
435
436 // Restore vertex array.
437 Buffer* buffer = attrib->buffer();
438 GLuint buffer_service_id = buffer ? buffer->service_id() : 0;
439 glBindBuffer(GL_ARRAY_BUFFER, buffer_service_id);
440 const void* ptr = reinterpret_cast<const void*>(attrib->offset());
441 glVertexAttribPointer(attrib_index,
442 attrib->size(),
443 attrib->type(),
444 attrib->normalized(),
445 attrib->gl_stride(),
446 ptr);
447
448 // Restore attrib divisor if supported.
449 if (feature_info_->feature_flags().angle_instanced_arrays)
450 glVertexAttribDivisorANGLE(attrib_index, attrib->divisor());
451
452 // Never touch vertex attribute 0's state (in particular, never
453 // disable it) when running on desktop GL with compatibility profile
454 // because it will never be re-enabled.
455 if (attrib_index != 0 ||
456 feature_info_->gl_version_info().BehavesLikeGLES()) {
457 if (attrib->enabled()) {
458 glEnableVertexAttribArray(attrib_index);
459 } else {
460 glDisableVertexAttribArray(attrib_index);
461 }
462 }
463 }
464 } 463 }
465 464
466 void ContextState::RestoreVertexAttribs() const { 465 void ContextState::RestoreVertexAttribs() const {
467 // Restore Vertex Attrib Arrays 466 // Restore Vertex Attrib Arrays
468 DCHECK(vertex_attrib_manager.get()); 467 DCHECK(vertex_attrib_manager.get());
469 // Restore VAOs. 468 // Restore VAOs.
470 if (feature_info_->feature_flags().native_vertex_array_object) { 469 if (feature_info_->feature_flags().native_vertex_array_object) {
471 // If default VAO is still using shared id 0 instead of unique ids 470 // If default VAO is still using shared id 0 instead of unique ids
472 // per-context, default VAO state must be restored. 471 // per-context, default VAO state must be restored.
473 GLuint default_vao_service_id = 472 GLuint default_vao_service_id =
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 UpdateUnpackParameters(); 712 UpdateUnpackParameters();
714 } 713 }
715 714
716 // Include the auto-generated part of this file. We split this because it means 715 // Include the auto-generated part of this file. We split this because it means
717 // we can easily edit the non-auto generated parts right here in this file 716 // we can easily edit the non-auto generated parts right here in this file
718 // instead of having to edit some template or the code generator. 717 // instead of having to edit some template or the code generator.
719 #include "gpu/command_buffer/service/context_state_impl_autogen.h" 718 #include "gpu/command_buffer/service/context_state_impl_autogen.h"
720 719
721 } // namespace gles2 720 } // namespace gles2
722 } // namespace gpu 721 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698