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

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

Issue 2837213003: Restore samplers' state across virtualized GL contexts. (Closed)
Patch Set: Add unit tests covering restoration of sampler state. Created 3 years, 7 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 glBindTexture(GL_TEXTURE_CUBE_MAP, service_id_cube); 274 glBindTexture(GL_TEXTURE_CUBE_MAP, service_id_cube);
275 } 275 }
276 if (bind_texture_oes) { 276 if (bind_texture_oes) {
277 glBindTexture(GL_TEXTURE_EXTERNAL_OES, service_id_oes); 277 glBindTexture(GL_TEXTURE_EXTERNAL_OES, service_id_oes);
278 } 278 }
279 if (bind_texture_arb) { 279 if (bind_texture_arb) {
280 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, service_id_arb); 280 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, service_id_arb);
281 } 281 }
282 } 282 }
283 283
284 void ContextState::RestoreSamplerBinding(GLuint unit,
285 const ContextState* prev_state) const {
286 if (!feature_info_->IsES3Capable())
287 return;
288 const scoped_refptr<Sampler>& cur_sampler = sampler_units[unit];
289 GLuint cur_id = cur_sampler ? cur_sampler->service_id() : 0;
290 GLuint prev_id = 0;
291 if (prev_state) {
292 const scoped_refptr<Sampler>& prev_sampler =
293 prev_state->sampler_units[unit];
294 prev_id = prev_sampler ? prev_sampler->service_id() : 0;
295 }
296 if (!prev_state || cur_id != prev_id) {
297 glBindSampler(unit, cur_id);
298 }
299 }
300
284 void ContextState::PushTextureDecompressionUnpackState() const { 301 void ContextState::PushTextureDecompressionUnpackState() const {
285 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 302 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
286 303
287 if (bound_pixel_unpack_buffer.get()) { 304 if (bound_pixel_unpack_buffer.get()) {
288 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); 305 glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
289 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 306 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
290 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0); 307 glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
291 } 308 }
292 } 309 }
293 310
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (!feature_info_->IsES3Capable()) 379 if (!feature_info_->IsES3Capable())
363 return; 380 return;
364 indexed_uniform_buffer_bindings->RestoreBindings( 381 indexed_uniform_buffer_bindings->RestoreBindings(
365 prev_state ? prev_state->indexed_uniform_buffer_bindings.get() : nullptr); 382 prev_state ? prev_state->indexed_uniform_buffer_bindings.get() : nullptr);
366 } 383 }
367 384
368 void ContextState::RestoreActiveTexture() const { 385 void ContextState::RestoreActiveTexture() const {
369 glActiveTexture(GL_TEXTURE0 + active_texture_unit); 386 glActiveTexture(GL_TEXTURE0 + active_texture_unit);
370 } 387 }
371 388
372 void ContextState::RestoreAllTextureUnitBindings( 389 void ContextState::RestoreAllTextureUnitAndSamplerBindings(
373 const ContextState* prev_state) const { 390 const ContextState* prev_state) const {
374 // Restore Texture state. 391 // Restore Texture state.
375 for (size_t ii = 0; ii < texture_units.size(); ++ii) { 392 for (size_t ii = 0; ii < texture_units.size(); ++ii) {
376 RestoreTextureUnitBindings(ii, prev_state); 393 RestoreTextureUnitBindings(ii, prev_state);
394 RestoreSamplerBinding(ii, prev_state);
377 } 395 }
378 RestoreActiveTexture(); 396 RestoreActiveTexture();
379 } 397 }
380 398
381 void ContextState::RestoreActiveTextureUnitBinding(unsigned int target) const { 399 void ContextState::RestoreActiveTextureUnitBinding(unsigned int target) const {
382 DCHECK_LT(active_texture_unit, texture_units.size()); 400 DCHECK_LT(active_texture_unit, texture_units.size());
383 const TextureUnit& texture_unit = texture_units[active_texture_unit]; 401 const TextureUnit& texture_unit = texture_units[active_texture_unit];
384 if (TargetIsSupported(feature_info_, target)) 402 if (TargetIsSupported(feature_info_, target))
385 glBindTexture(target, GetServiceId(texture_unit, target)); 403 glBindTexture(target, GetServiceId(texture_unit, target));
386 } 404 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 // glVertexAttrib4fv aren't part of VAO state and must be restored. 507 // glVertexAttrib4fv aren't part of VAO state and must be restored.
490 RestoreVertexAttribValues(); 508 RestoreVertexAttribValues();
491 } 509 }
492 510
493 void ContextState::RestoreGlobalState(const ContextState* prev_state) const { 511 void ContextState::RestoreGlobalState(const ContextState* prev_state) const {
494 InitCapabilities(prev_state); 512 InitCapabilities(prev_state);
495 InitState(prev_state); 513 InitState(prev_state);
496 } 514 }
497 515
498 void ContextState::RestoreState(const ContextState* prev_state) { 516 void ContextState::RestoreState(const ContextState* prev_state) {
499 RestoreAllTextureUnitBindings(prev_state); 517 RestoreAllTextureUnitAndSamplerBindings(prev_state);
500 RestoreVertexAttribs(); 518 RestoreVertexAttribs();
501 RestoreBufferBindings(); 519 RestoreBufferBindings();
502 RestoreRenderbufferBindings(); 520 RestoreRenderbufferBindings();
503 RestoreProgramSettings(prev_state, true); 521 RestoreProgramSettings(prev_state, true);
504 RestoreIndexedUniformBufferBindings(prev_state); 522 RestoreIndexedUniformBufferBindings(prev_state);
505 RestoreGlobalState(prev_state); 523 RestoreGlobalState(prev_state);
506 524
507 // FRAMEBUFFER_SRGB will be restored lazily at render time. 525 // FRAMEBUFFER_SRGB will be restored lazily at render time.
508 framebuffer_srgb_valid_ = false; 526 framebuffer_srgb_valid_ = false;
509 } 527 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 UpdateUnpackParameters(); 731 UpdateUnpackParameters();
714 } 732 }
715 733
716 // Include the auto-generated part of this file. We split this because it means 734 // 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 735 // 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. 736 // instead of having to edit some template or the code generator.
719 #include "gpu/command_buffer/service/context_state_impl_autogen.h" 737 #include "gpu/command_buffer/service/context_state_impl_autogen.h"
720 738
721 } // namespace gles2 739 } // namespace gles2
722 } // namespace gpu 740 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/context_state.h ('k') | gpu/command_buffer/service/gl_state_restorer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698