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

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

Issue 2612523003: [WIP] Remove unnecessary clear_state_dirty
Patch Set: code rebase Created 3 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
« no previous file with comments | « gpu/command_buffer/service/context_state.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 4031 matching lines...) Expand 10 before | Expand all | Expand 10 after
4042 if (framebuffer && !framebuffer->IsDeleted()) { 4042 if (framebuffer && !framebuffer->IsDeleted()) {
4043 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { 4043 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) {
4044 GLenum target = GetDrawFramebufferTarget(); 4044 GLenum target = GetDrawFramebufferTarget();
4045 4045
4046 // Unbind attachments on FBO before deletion. 4046 // Unbind attachments on FBO before deletion.
4047 if (workarounds().unbind_attachments_on_bound_render_fbo_delete) 4047 if (workarounds().unbind_attachments_on_bound_render_fbo_delete)
4048 framebuffer->DoUnbindGLAttachmentsForWorkaround(target); 4048 framebuffer->DoUnbindGLAttachmentsForWorkaround(target);
4049 4049
4050 glBindFramebufferEXT(target, GetBackbufferServiceId()); 4050 glBindFramebufferEXT(target, GetBackbufferServiceId());
4051 framebuffer_state_.bound_draw_framebuffer = NULL; 4051 framebuffer_state_.bound_draw_framebuffer = NULL;
4052 framebuffer_state_.clear_state_dirty = true; 4052 // framebuffer_state_.clear_state_dirty = true;
4053 } 4053 }
4054 if (framebuffer == framebuffer_state_.bound_read_framebuffer.get()) { 4054 if (framebuffer == framebuffer_state_.bound_read_framebuffer.get()) {
4055 framebuffer_state_.bound_read_framebuffer = NULL; 4055 framebuffer_state_.bound_read_framebuffer = NULL;
4056 GLenum target = GetReadFramebufferTarget(); 4056 GLenum target = GetReadFramebufferTarget();
4057 glBindFramebufferEXT(target, GetBackbufferServiceId()); 4057 glBindFramebufferEXT(target, GetBackbufferServiceId());
4058 } 4058 }
4059 OnFboChanged(); 4059 OnFboChanged();
4060 RemoveFramebuffer(client_id); 4060 RemoveFramebuffer(client_id);
4061 } 4061 }
4062 } 4062 }
(...skipping 20 matching lines...) Expand all
4083 if (framebuffer_state_.bound_draw_framebuffer.get()) { 4083 if (framebuffer_state_.bound_draw_framebuffer.get()) {
4084 framebuffer_state_.bound_draw_framebuffer 4084 framebuffer_state_.bound_draw_framebuffer
4085 ->UnbindRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, renderbuffer); 4085 ->UnbindRenderbuffer(GL_DRAW_FRAMEBUFFER_EXT, renderbuffer);
4086 } 4086 }
4087 } else { 4087 } else {
4088 if (framebuffer_state_.bound_draw_framebuffer.get()) { 4088 if (framebuffer_state_.bound_draw_framebuffer.get()) {
4089 framebuffer_state_.bound_draw_framebuffer 4089 framebuffer_state_.bound_draw_framebuffer
4090 ->UnbindRenderbuffer(GL_FRAMEBUFFER, renderbuffer); 4090 ->UnbindRenderbuffer(GL_FRAMEBUFFER, renderbuffer);
4091 } 4091 }
4092 } 4092 }
4093 framebuffer_state_.clear_state_dirty = true; 4093 // framebuffer_state_.clear_state_dirty = true;
4094 RemoveRenderbuffer(client_id); 4094 RemoveRenderbuffer(client_id);
4095 } 4095 }
4096 } 4096 }
4097 } 4097 }
4098 4098
4099 void GLES2DecoderImpl::DeleteTexturesHelper(GLsizei n, 4099 void GLES2DecoderImpl::DeleteTexturesHelper(GLsizei n,
4100 const volatile GLuint* client_ids) { 4100 const volatile GLuint* client_ids) {
4101 bool supports_separate_framebuffer_binds = SupportsSeparateFramebufferBinds(); 4101 bool supports_separate_framebuffer_binds = SupportsSeparateFramebufferBinds();
4102 for (GLsizei ii = 0; ii < n; ++ii) { 4102 for (GLsizei ii = 0; ii < n; ++ii) {
4103 GLuint client_id = client_ids[ii]; 4103 GLuint client_id = client_ids[ii];
4104 TextureRef* texture_ref = GetTexture(client_id); 4104 TextureRef* texture_ref = GetTexture(client_id);
4105 if (texture_ref) { 4105 if (texture_ref) {
4106 Texture* texture = texture_ref->texture(); 4106 Texture* texture = texture_ref->texture();
4107 if (texture->IsAttachedToFramebuffer()) { 4107 if (texture->IsAttachedToFramebuffer()) {
4108 framebuffer_state_.clear_state_dirty = true; 4108 // framebuffer_state_.clear_state_dirty = true;
4109 } 4109 }
4110 // Unbind texture_ref from texture_ref units. 4110 // Unbind texture_ref from texture_ref units.
4111 state_.UnbindTexture(texture_ref); 4111 state_.UnbindTexture(texture_ref);
4112 4112
4113 // Unbind from current framebuffers. 4113 // Unbind from current framebuffers.
4114 if (supports_separate_framebuffer_binds) { 4114 if (supports_separate_framebuffer_binds) {
4115 if (framebuffer_state_.bound_read_framebuffer.get()) { 4115 if (framebuffer_state_.bound_read_framebuffer.get()) {
4116 framebuffer_state_.bound_read_framebuffer 4116 framebuffer_state_.bound_read_framebuffer
4117 ->UnbindTexture(GL_READ_FRAMEBUFFER_EXT, texture_ref); 4117 ->UnbindTexture(GL_READ_FRAMEBUFFER_EXT, texture_ref);
4118 } 4118 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
4231 GLuint framebuffer_id = framebuffer ? framebuffer->service_id() : 0; 4231 GLuint framebuffer_id = framebuffer ? framebuffer->service_id() : 0;
4232 4232
4233 if (framebuffer_id == 0) { 4233 if (framebuffer_id == 0) {
4234 framebuffer_id = back_buffer_service_id; 4234 framebuffer_id = back_buffer_service_id;
4235 } 4235 }
4236 4236
4237 glBindFramebufferEXT(target, framebuffer_id); 4237 glBindFramebufferEXT(target, framebuffer_id);
4238 } 4238 }
4239 4239
4240 void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() { 4240 void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() {
4241 framebuffer_state_.clear_state_dirty = true; 4241 // framebuffer_state_.clear_state_dirty = true;
4242 4242
4243 if (!SupportsSeparateFramebufferBinds()) { 4243 if (!SupportsSeparateFramebufferBinds()) {
4244 RebindCurrentFramebuffer( 4244 RebindCurrentFramebuffer(
4245 GL_FRAMEBUFFER, 4245 GL_FRAMEBUFFER,
4246 framebuffer_state_.bound_draw_framebuffer.get(), 4246 framebuffer_state_.bound_draw_framebuffer.get(),
4247 GetBackbufferServiceId()); 4247 GetBackbufferServiceId());
4248 } else { 4248 } else {
4249 RebindCurrentFramebuffer( 4249 RebindCurrentFramebuffer(
4250 GL_READ_FRAMEBUFFER_EXT, 4250 GL_READ_FRAMEBUFFER_EXT,
4251 framebuffer_state_.bound_read_framebuffer.get(), 4251 framebuffer_state_.bound_read_framebuffer.get(),
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
5481 if (framebuffer) { 5481 if (framebuffer) {
5482 return framebuffer->HasStencilAttachment(); 5482 return framebuffer->HasStencilAttachment();
5483 } 5483 }
5484 if (offscreen_target_frame_buffer_.get()) { 5484 if (offscreen_target_frame_buffer_.get()) {
5485 return offscreen_target_stencil_format_ != 0 || 5485 return offscreen_target_stencil_format_ != 0 ||
5486 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8; 5486 offscreen_target_depth_format_ == GL_DEPTH24_STENCIL8;
5487 } 5487 }
5488 return back_buffer_has_stencil_; 5488 return back_buffer_has_stencil_;
5489 } 5489 }
5490 5490
5491 void GLES2DecoderImpl::ApplyDirtyState() { 5491 /* void GLES2DecoderImpl::ApplyDirtyState() {
5492 if (framebuffer_state_.clear_state_dirty) { 5492 if (framebuffer_state_.clear_state_dirty) {
5493 // print("**** enter ApplyDirtyState ****\n");
5493 bool allows_alpha_change = BoundFramebufferAllowsChangesToAlphaChannel(); 5494 bool allows_alpha_change = BoundFramebufferAllowsChangesToAlphaChannel();
5494 state_.SetDeviceColorMask(state_.color_mask_red, state_.color_mask_green, 5495 state_.SetDeviceColorMask(state_.color_mask_red, state_.color_mask_green,
5495 state_.color_mask_blue, 5496 state_.color_mask_blue,
5496 state_.color_mask_alpha && allows_alpha_change); 5497 state_.color_mask_alpha && allows_alpha_change);
5497 5498
5498 bool have_depth = BoundFramebufferHasDepthAttachment(); 5499 bool have_depth = BoundFramebufferHasDepthAttachment();
5499 state_.SetDeviceDepthMask(state_.depth_mask && have_depth); 5500 state_.SetDeviceDepthMask(state_.depth_mask && have_depth);
5500 5501
5501 bool have_stencil = BoundFramebufferHasStencilAttachment(); 5502 bool have_stencil = BoundFramebufferHasStencilAttachment();
5502 state_.SetDeviceStencilMaskSeparate( 5503 state_.SetDeviceStencilMaskSeparate(
5503 GL_FRONT, have_stencil ? state_.stencil_front_writemask : 0); 5504 GL_FRONT, have_stencil ? state_.stencil_front_writemask : 0);
5504 state_.SetDeviceStencilMaskSeparate( 5505 state_.SetDeviceStencilMaskSeparate(
5505 GL_BACK, have_stencil ? state_.stencil_back_writemask : 0); 5506 GL_BACK, have_stencil ? state_.stencil_back_writemask : 0);
5506 5507
5507 state_.SetDeviceCapabilityState( 5508 state_.SetDeviceCapabilityState(
5508 GL_DEPTH_TEST, state_.enable_flags.depth_test && have_depth); 5509 GL_DEPTH_TEST, state_.enable_flags.depth_test && have_depth);
5509 state_.SetDeviceCapabilityState( 5510 state_.SetDeviceCapabilityState(
5510 GL_STENCIL_TEST, state_.enable_flags.stencil_test && have_stencil); 5511 GL_STENCIL_TEST, state_.enable_flags.stencil_test && have_stencil);
5511 framebuffer_state_.clear_state_dirty = false; 5512 framebuffer_state_.clear_state_dirty = false;
5512 } 5513 }
5513 } 5514 }
5515 */
5516 void GLES2DecoderImpl::ApplyDirtyState() {
5517 if (framebuffer_state_.clear_state_dirty) {
5518 // print("**** enter ApplyDirtyState ****\n");
5519 // bool allows_alpha_change = BoundFramebufferAllowsChangesToAlphaChannel();
5520 state_.SetDeviceColorMask(state_.color_mask_red, state_.color_mask_green,
5521 state_.color_mask_blue,
5522 // state_.color_mask_alpha && allows_alpha_change) ;
5523 state_.color_mask_alpha);
5524
5525 // bool have_depth = BoundFramebufferHasDepthAttachment();
5526 // state_.SetDeviceDepthMask(state_.depth_mask && have_depth);
5527 state_.SetDeviceDepthMask(state_.depth_mask);
5528
5529 // bool have_stencil = BoundFramebufferHasStencilAttachment();
5530 state_.SetDeviceStencilMaskSeparate(
5531 // GL_FRONT, have_stencil ? state_.stencil_front_writemask : 0);
5532 GL_FRONT, state_.stencil_front_writemask);
5533 state_.SetDeviceStencilMaskSeparate(
5534 // GL_BACK, have_stencil ? state_.stencil_back_writemask : 0);
5535 GL_BACK, state_.stencil_back_writemask);
5536
5537 state_.SetDeviceCapabilityState(
5538 // GL_DEPTH_TEST, state_.enable_flags.depth_test && have_depth);
5539 GL_DEPTH_TEST, state_.enable_flags.depth_test);
5540 state_.SetDeviceCapabilityState(
5541 // GL_STENCIL_TEST, state_.enable_flags.stencil_test && have_stencil);
5542 GL_STENCIL_TEST, state_.enable_flags.stencil_test);
5543 framebuffer_state_.clear_state_dirty = false;
5544 }
5545 }
5514 5546
5515 GLuint GLES2DecoderImpl::GetBackbufferServiceId() const { 5547 GLuint GLES2DecoderImpl::GetBackbufferServiceId() const {
5516 return (offscreen_target_frame_buffer_.get()) 5548 return (offscreen_target_frame_buffer_.get())
5517 ? offscreen_target_frame_buffer_->id() 5549 ? offscreen_target_frame_buffer_->id()
5518 : (surface_.get() ? surface_->GetBackingFramebufferObject() : 0); 5550 : (surface_.get() ? surface_->GetBackingFramebufferObject() : 0);
5519 } 5551 }
5520 5552
5521 void GLES2DecoderImpl::RestoreState(const ContextState* prev_state) { 5553 void GLES2DecoderImpl::RestoreState(const ContextState* prev_state) {
5522 TRACE_EVENT1("gpu", "GLES2DecoderImpl::RestoreState", 5554 TRACE_EVENT1("gpu", "GLES2DecoderImpl::RestoreState",
5523 "context", logger_.GetLogPrefix()); 5555 "context", logger_.GetLogPrefix());
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
5646 5678
5647 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER_EXT) { 5679 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER_EXT) {
5648 framebuffer_state_.bound_draw_framebuffer = framebuffer; 5680 framebuffer_state_.bound_draw_framebuffer = framebuffer;
5649 } 5681 }
5650 5682
5651 // vmiura: This looks like dup code 5683 // vmiura: This looks like dup code
5652 if (target == GL_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER_EXT) { 5684 if (target == GL_FRAMEBUFFER || target == GL_READ_FRAMEBUFFER_EXT) {
5653 framebuffer_state_.bound_read_framebuffer = framebuffer; 5685 framebuffer_state_.bound_read_framebuffer = framebuffer;
5654 } 5686 }
5655 5687
5656 framebuffer_state_.clear_state_dirty = true; 5688 // framebuffer_state_.clear_state_dirty = true;
5657 5689
5658 // If we are rendering to the backbuffer get the FBO id for any simulated 5690 // If we are rendering to the backbuffer get the FBO id for any simulated
5659 // backbuffer. 5691 // backbuffer.
5660 if (framebuffer == NULL) { 5692 if (framebuffer == NULL) {
5661 service_id = GetBackbufferServiceId(); 5693 service_id = GetBackbufferServiceId();
5662 } 5694 }
5663 5695
5664 glBindFramebufferEXT(target, service_id); 5696 glBindFramebufferEXT(target, service_id);
5665 OnFboChanged(); 5697 OnFboChanged();
5666 } 5698 }
(...skipping 1772 matching lines...) Expand 10 before | Expand all | Expand 10 after
7439 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer"); 7471 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glFramebufferRenderbuffer");
7440 for (GLenum attachment_point : attachments) { 7472 for (GLenum attachment_point : attachments) {
7441 glFramebufferRenderbufferEXT( 7473 glFramebufferRenderbufferEXT(
7442 target, attachment_point, renderbuffertarget, service_id); 7474 target, attachment_point, renderbuffertarget, service_id);
7443 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer"); 7475 GLenum error = LOCAL_PEEK_GL_ERROR("glFramebufferRenderbuffer");
7444 if (error == GL_NO_ERROR) { 7476 if (error == GL_NO_ERROR) {
7445 framebuffer->AttachRenderbuffer(attachment_point, renderbuffer); 7477 framebuffer->AttachRenderbuffer(attachment_point, renderbuffer);
7446 } 7478 }
7447 } 7479 }
7448 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { 7480 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) {
7449 framebuffer_state_.clear_state_dirty = true; 7481 // framebuffer_state_.clear_state_dirty = true;
7450 } 7482 }
7451 OnFboChanged(); 7483 OnFboChanged();
7452 } 7484 }
7453 7485
7454 void GLES2DecoderImpl::DoDisable(GLenum cap) { 7486 void GLES2DecoderImpl::DoDisable(GLenum cap) {
7455 if (SetCapabilityState(cap, false)) { 7487 if (SetCapabilityState(cap, false)) {
7456 if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX && 7488 if (cap == GL_PRIMITIVE_RESTART_FIXED_INDEX &&
7457 feature_info_->feature_flags().emulate_primitive_restart_fixed_index) { 7489 feature_info_->feature_flags().emulate_primitive_restart_fixed_index) {
7458 // Enable and Disable PRIMITIVE_RESTART only before and after 7490 // Enable and Disable PRIMITIVE_RESTART only before and after
7459 // DrawElements* for old desktop GL. 7491 // DrawElements* for old desktop GL.
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
7693 target, attachments[ii], textarget, service_id, level, samples); 7725 target, attachments[ii], textarget, service_id, level, samples);
7694 } 7726 }
7695 } 7727 }
7696 GLenum error = LOCAL_PEEK_GL_ERROR(name); 7728 GLenum error = LOCAL_PEEK_GL_ERROR(name);
7697 if (error == GL_NO_ERROR) { 7729 if (error == GL_NO_ERROR) {
7698 framebuffer->AttachTexture(attachments[ii], texture_ref, textarget, level, 7730 framebuffer->AttachTexture(attachments[ii], texture_ref, textarget, level,
7699 samples); 7731 samples);
7700 } 7732 }
7701 } 7733 }
7702 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { 7734 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) {
7703 framebuffer_state_.clear_state_dirty = true; 7735 // framebuffer_state_.clear_state_dirty = true;
7704 } 7736 }
7705 7737
7706 OnFboChanged(); 7738 OnFboChanged();
7707 } 7739 }
7708 7740
7709 void GLES2DecoderImpl::DoFramebufferTextureLayer( 7741 void GLES2DecoderImpl::DoFramebufferTextureLayer(
7710 GLenum target, GLenum attachment, GLuint client_texture_id, 7742 GLenum target, GLenum attachment, GLuint client_texture_id,
7711 GLint level, GLint layer) { 7743 GLint level, GLint layer) {
7712 const char* function_name = "glFramebufferTextureLayer"; 7744 const char* function_name = "glFramebufferTextureLayer";
7713 7745
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
7750 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { 7782 if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
7751 framebuffer->AttachTextureLayer( 7783 framebuffer->AttachTextureLayer(
7752 GL_DEPTH_ATTACHMENT, texture_ref, texture_target, level, layer); 7784 GL_DEPTH_ATTACHMENT, texture_ref, texture_target, level, layer);
7753 framebuffer->AttachTextureLayer( 7785 framebuffer->AttachTextureLayer(
7754 GL_STENCIL_ATTACHMENT, texture_ref, texture_target, level, layer); 7786 GL_STENCIL_ATTACHMENT, texture_ref, texture_target, level, layer);
7755 } else { 7787 } else {
7756 framebuffer->AttachTextureLayer( 7788 framebuffer->AttachTextureLayer(
7757 attachment, texture_ref, texture_target, level, layer); 7789 attachment, texture_ref, texture_target, level, layer);
7758 } 7790 }
7759 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) { 7791 if (framebuffer == framebuffer_state_.bound_draw_framebuffer.get()) {
7760 framebuffer_state_.clear_state_dirty = true; 7792 // framebuffer_state_.clear_state_dirty = true;
7761 } 7793 }
7762 } 7794 }
7763 7795
7764 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv( 7796 void GLES2DecoderImpl::DoGetFramebufferAttachmentParameteriv(
7765 GLenum target, 7797 GLenum target,
7766 GLenum attachment, 7798 GLenum attachment,
7767 GLenum pname, 7799 GLenum pname,
7768 GLint* params, 7800 GLint* params,
7769 GLsizei params_size) { 7801 GLsizei params_size) {
7770 const char kFunctionName[] = "glGetFramebufferAttachmentParameteriv"; 7802 const char kFunctionName[] = "glGetFramebufferAttachmentParameteriv";
(...skipping 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
9586 continue; 9618 continue;
9587 } 9619 }
9588 } 9620 }
9589 } 9621 }
9590 } 9622 }
9591 // Set the active texture back to whatever the user had it as. 9623 // Set the active texture back to whatever the user had it as.
9592 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit); 9624 glActiveTexture(GL_TEXTURE0 + state_.active_texture_unit);
9593 } 9625 }
9594 9626
9595 bool GLES2DecoderImpl::ClearUnclearedTextures() { 9627 bool GLES2DecoderImpl::ClearUnclearedTextures() {
9628 // print("**** enter ClearUnclearedTextures ****\n");
9596 // Only check if there are some uncleared textures. 9629 // Only check if there are some uncleared textures.
9597 if (!texture_manager()->HaveUnsafeTextures()) { 9630 if (!texture_manager()->HaveUnsafeTextures()) {
9598 return true; 9631 return true;
9599 } 9632 }
9600 9633
9601 // 1: Check all textures we are about to render with. 9634 // 1: Check all textures we are about to render with.
9602 if (state_.current_program.get()) { 9635 if (state_.current_program.get()) {
9603 const Program::SamplerIndices& sampler_indices = 9636 const Program::SamplerIndices& sampler_indices =
9604 state_.current_program->sampler_indices(); 9637 state_.current_program->sampler_indices();
9605 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) { 9638 for (size_t ii = 0; ii < sampler_indices.size(); ++ii) {
9606 const Program::UniformInfo* uniform_info = 9639 const Program::UniformInfo* uniform_info =
9607 state_.current_program->GetUniformInfo(sampler_indices[ii]); 9640 state_.current_program->GetUniformInfo(sampler_indices[ii]);
9608 DCHECK(uniform_info); 9641 DCHECK(uniform_info);
9609 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) { 9642 for (size_t jj = 0; jj < uniform_info->texture_units.size(); ++jj) {
9610 GLuint texture_unit_index = uniform_info->texture_units[jj]; 9643 GLuint texture_unit_index = uniform_info->texture_units[jj];
9611 if (texture_unit_index < state_.texture_units.size()) { 9644 if (texture_unit_index < state_.texture_units.size()) {
9612 TextureUnit& texture_unit = state_.texture_units[texture_unit_index]; 9645 TextureUnit& texture_unit = state_.texture_units[texture_unit_index];
9613 TextureRef* texture_ref = 9646 TextureRef* texture_ref =
9614 texture_unit.GetInfoForSamplerType(uniform_info->type).get(); 9647 texture_unit.GetInfoForSamplerType(uniform_info->type).get();
9615 if (texture_ref && !texture_ref->texture()->SafeToRenderFrom()) { 9648 if (texture_ref && !texture_ref->texture()->SafeToRenderFrom()) {
9616 if (!texture_manager()->ClearRenderableLevels(this, texture_ref)) { 9649 if (!texture_manager()->ClearRenderableLevels(this, texture_ref)) {
9617 return false; 9650 return false;
9618 } 9651 }
9619 } 9652 }
9620 } 9653 }
9621 } 9654 }
9622 } 9655 }
9623 } 9656 }
9657 // RestoreClearState();
9624 return true; 9658 return true;
9625 } 9659 }
9626 9660
9627 bool GLES2DecoderImpl::IsDrawValid( 9661 bool GLES2DecoderImpl::IsDrawValid(
9628 const char* function_name, GLuint max_vertex_accessed, bool instanced, 9662 const char* function_name, GLuint max_vertex_accessed, bool instanced,
9629 GLsizei primcount) { 9663 GLsizei primcount) {
9630 DCHECK(instanced || primcount == 1); 9664 DCHECK(instanced || primcount == 1);
9631 9665
9632 // NOTE: We specifically do not check current_program->IsValid() because 9666 // NOTE: We specifically do not check current_program->IsValid() because
9633 // it could never be invalid since glUseProgram would have failed. While 9667 // it could never be invalid since glUseProgram would have failed. While
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
10152 bool simulated_attrib_0 = false; 10186 bool simulated_attrib_0 = false;
10153 if (!SimulateAttrib0( 10187 if (!SimulateAttrib0(
10154 function_name, max_vertex_accessed, &simulated_attrib_0)) { 10188 function_name, max_vertex_accessed, &simulated_attrib_0)) {
10155 return error::kNoError; 10189 return error::kNoError;
10156 } 10190 }
10157 bool simulated_fixed_attribs = false; 10191 bool simulated_fixed_attribs = false;
10158 if (SimulateFixedAttribs( 10192 if (SimulateFixedAttribs(
10159 function_name, max_vertex_accessed, &simulated_fixed_attribs, 10193 function_name, max_vertex_accessed, &simulated_fixed_attribs,
10160 primcount)) { 10194 primcount)) {
10161 bool textures_set = !PrepareTexturesForRender(); 10195 bool textures_set = !PrepareTexturesForRender();
10196 // print("#### may enter ApplyDirtyState ****\n");
10162 ApplyDirtyState(); 10197 ApplyDirtyState();
10163 // TODO(gman): Refactor to hide these details in BufferManager or 10198 // TODO(gman): Refactor to hide these details in BufferManager or
10164 // VertexAttribManager. 10199 // VertexAttribManager.
10165 const GLvoid* indices = reinterpret_cast<const GLvoid*>(offset); 10200 const GLvoid* indices = reinterpret_cast<const GLvoid*>(offset);
10166 bool used_client_side_array = false; 10201 bool used_client_side_array = false;
10167 if (element_array_buffer->IsClientSideArray()) { 10202 if (element_array_buffer->IsClientSideArray()) {
10168 used_client_side_array = true; 10203 used_client_side_array = true;
10169 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); 10204 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
10170 indices = element_array_buffer->GetRange(offset, 0); 10205 indices = element_array_buffer->GetRange(offset, 0);
10171 } 10206 }
10172 if (!ValidateAndAdjustDrawBuffers(function_name)) { 10207 if (!ValidateAndAdjustDrawBuffers(function_name)) {
10173 return error::kNoError; 10208 return error::kNoError;
10174 } 10209 }
10175 if (state_.enable_flags.primitive_restart_fixed_index && 10210 if (state_.enable_flags.primitive_restart_fixed_index &&
10176 feature_info_->feature_flags(). 10211 feature_info_->feature_flags().
10177 emulate_primitive_restart_fixed_index) { 10212 emulate_primitive_restart_fixed_index) {
10178 glEnable(GL_PRIMITIVE_RESTART); 10213 glEnable(GL_PRIMITIVE_RESTART);
10179 buffer_manager()->SetPrimitiveRestartFixedIndexIfNecessary(type); 10214 buffer_manager()->SetPrimitiveRestartFixedIndexIfNecessary(type);
10180 } 10215 }
10216 // RestoreClearState();
10181 if (!instanced) { 10217 if (!instanced) {
10182 glDrawElements(mode, count, type, indices); 10218 glDrawElements(mode, count, type, indices);
10183 } else { 10219 } else {
10184 glDrawElementsInstancedANGLE(mode, count, type, indices, primcount); 10220 glDrawElementsInstancedANGLE(mode, count, type, indices, primcount);
10185 } 10221 }
10186 if (state_.enable_flags.primitive_restart_fixed_index && 10222 if (state_.enable_flags.primitive_restart_fixed_index &&
10187 feature_info_->feature_flags(). 10223 feature_info_->feature_flags().
10188 emulate_primitive_restart_fixed_index) { 10224 emulate_primitive_restart_fixed_index) {
10189 glDisable(GL_PRIMITIVE_RESTART); 10225 glDisable(GL_PRIMITIVE_RESTART);
10190 } 10226 }
(...skipping 3273 matching lines...) Expand 10 before | Expand all | Expand 10 after
13464 internal_format, image_size, data)) { 13500 internal_format, image_size, data)) {
13465 return error::kNoError; 13501 return error::kNoError;
13466 } 13502 }
13467 13503
13468 if (!EnsureGPUMemoryAvailable(image_size)) { 13504 if (!EnsureGPUMemoryAvailable(image_size)) {
13469 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "out of memory"); 13505 LOCAL_SET_GL_ERROR(GL_OUT_OF_MEMORY, func_name, "out of memory");
13470 return error::kNoError; 13506 return error::kNoError;
13471 } 13507 }
13472 13508
13473 if (texture->IsAttachedToFramebuffer()) { 13509 if (texture->IsAttachedToFramebuffer()) {
13474 framebuffer_state_.clear_state_dirty = true; 13510 // framebuffer_state_.clear_state_dirty = true;
13475 } 13511 }
13476 13512
13477 std::unique_ptr<int8_t[]> zero; 13513 std::unique_ptr<int8_t[]> zero;
13478 if (!state_.bound_pixel_unpack_buffer && !data) { 13514 if (!state_.bound_pixel_unpack_buffer && !data) {
13479 zero.reset(new int8_t[image_size]); 13515 zero.reset(new int8_t[image_size]);
13480 memset(zero.get(), 0, image_size); 13516 memset(zero.get(), 0, image_size);
13481 data = zero.get(); 13517 data = zero.get();
13482 } 13518 }
13483 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(func_name); 13519 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(func_name);
13484 const CompressedFormatInfo* format_info = 13520 const CompressedFormatInfo* format_info =
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
14071 GL_INVALID_OPERATION, 14107 GL_INVALID_OPERATION,
14072 func_name, "source and destination textures are the same"); 14108 func_name, "source and destination textures are the same");
14073 return; 14109 return;
14074 } 14110 }
14075 14111
14076 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(func_name); 14112 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(func_name);
14077 ScopedResolvedFramebufferBinder binder(this, false, true); 14113 ScopedResolvedFramebufferBinder binder(this, false, true);
14078 gfx::Size size = GetBoundReadFramebufferSize(); 14114 gfx::Size size = GetBoundReadFramebufferSize();
14079 14115
14080 if (texture->IsAttachedToFramebuffer()) { 14116 if (texture->IsAttachedToFramebuffer()) {
14081 framebuffer_state_.clear_state_dirty = true; 14117 // framebuffer_state_.clear_state_dirty = true;
14082 } 14118 }
14083 14119
14084 bool requires_luma_blit = 14120 bool requires_luma_blit =
14085 CopyTexImageResourceManager::CopyTexImageRequiresBlit(feature_info_.get(), 14121 CopyTexImageResourceManager::CopyTexImageRequiresBlit(feature_info_.get(),
14086 format); 14122 format);
14087 if (requires_luma_blit && 14123 if (requires_luma_blit &&
14088 !InitializeCopyTexImageBlitter(func_name)) { 14124 !InitializeCopyTexImageBlitter(func_name)) {
14089 return; 14125 return;
14090 } 14126 }
14091 14127
(...skipping 2811 matching lines...) Expand 10 before | Expand all | Expand 10 after
16903 } 16939 }
16904 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget( 16940 TextureRef* texture_ref = texture_manager()->GetTextureInfoForTarget(
16905 &state_, target); 16941 &state_, target);
16906 if (!texture_ref) { 16942 if (!texture_ref) {
16907 LOCAL_SET_GL_ERROR( 16943 LOCAL_SET_GL_ERROR(
16908 GL_INVALID_OPERATION, function_name, "unknown texture for target"); 16944 GL_INVALID_OPERATION, function_name, "unknown texture for target");
16909 return; 16945 return;
16910 } 16946 }
16911 Texture* texture = texture_ref->texture(); 16947 Texture* texture = texture_ref->texture();
16912 if (texture->IsAttachedToFramebuffer()) { 16948 if (texture->IsAttachedToFramebuffer()) {
16913 framebuffer_state_.clear_state_dirty = true; 16949 // framebuffer_state_.clear_state_dirty = true;
16914 } 16950 }
16915 if (texture->IsImmutable()) { 16951 if (texture->IsImmutable()) {
16916 LOCAL_SET_GL_ERROR( 16952 LOCAL_SET_GL_ERROR(
16917 GL_INVALID_OPERATION, function_name, "texture is immutable"); 16953 GL_INVALID_OPERATION, function_name, "texture is immutable");
16918 return; 16954 return;
16919 } 16955 }
16920 16956
16921 GLenum format = TextureManager::ExtractFormatFromStorageFormat( 16957 GLenum format = TextureManager::ExtractFormatFromStorageFormat(
16922 internal_format); 16958 internal_format);
16923 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format); 16959 GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format);
(...skipping 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after
19118 } 19154 }
19119 19155
19120 // Include the auto-generated part of this file. We split this because it means 19156 // Include the auto-generated part of this file. We split this because it means
19121 // we can easily edit the non-auto generated parts right here in this file 19157 // we can easily edit the non-auto generated parts right here in this file
19122 // instead of having to edit some template or the code generator. 19158 // instead of having to edit some template or the code generator.
19123 #include "base/macros.h" 19159 #include "base/macros.h"
19124 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 19160 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
19125 19161
19126 } // namespace gles2 19162 } // namespace gles2
19127 } // namespace gpu 19163 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/context_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698