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

Unified Diff: gpu/command_buffer/service/context_state.cc

Issue 118203002: During virtual context switches only restore texture units that have changed from the previous cont… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a comment Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/context_state.cc
diff --git a/gpu/command_buffer/service/context_state.cc b/gpu/command_buffer/service/context_state.cc
index e8912cfe1625b769dc0047b935c2f098aed31da3..68f3fd31a26dbecb740bdf43953a1a2f6b7086fb 100644
--- a/gpu/command_buffer/service/context_state.cc
+++ b/gpu/command_buffer/service/context_state.cc
@@ -40,6 +40,7 @@ ContextState::ContextState(FeatureInfo* feature_info, Logger* logger)
pack_reverse_row_order(false),
fbo_binding_for_scissor_workaround_dirty_(false),
feature_info_(feature_info),
+ max_active_texture_unit_(0),
error_state_(ErrorState::Create(logger)) {
Initialize();
}
@@ -101,9 +102,17 @@ void ContextState::RestoreActiveTexture() const {
glActiveTexture(GL_TEXTURE0 + active_texture_unit);
}
-void ContextState::RestoreAllTextureUnitBindings() const {
+void ContextState::RestoreAllTextureUnitBindings(
+ const ContextState* prev_state) const {
+ size_t units_to_restore = texture_units.size();
boliu 2013/12/18 19:55:11 Should this be max_active_texture_unit_?
+ if (prev_state) {
+ // Only restore units that have been modified by both contexts.
+ units_to_restore = std::max(prev_state->max_active_texture_unit_,
+ max_active_texture_unit_) + 1;
no sievers 2013/12/18 19:36:20 Do we really need |max_active_texture_unit_| which
kaanb 2013/12/18 19:43:56 Having max_active_texture_unit_ is useful as it re
boliu 2013/12/18 19:55:11 Just diffing against prev_state would be great for
Ken Russell (switch to Gerrit) 2013/12/18 20:09:44 Reducing the number of loop iterations is a premat
+ }
+
// Restore Texture state.
- for (size_t ii = 0; ii < texture_units.size(); ++ii) {
+ for (size_t ii = 0; ii < units_to_restore; ++ii) {
RestoreTextureUnitBindings(ii);
}
RestoreActiveTexture();
@@ -139,8 +148,8 @@ void ContextState::RestoreGlobalState() const {
InitState();
}
-void ContextState::RestoreState() const {
- RestoreAllTextureUnitBindings();
+void ContextState::RestoreState(const ContextState* prev_state) const {
+ RestoreAllTextureUnitBindings(prev_state);
// Restore Attrib State
// TODO: This if should not be needed. RestoreState is getting called

Powered by Google App Engine
This is Rietveld 408576698