Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 832 // Get the size (in pixels) of the currently bound frame buffer (either FBO | 832 // Get the size (in pixels) of the currently bound frame buffer (either FBO |
| 833 // or regular back buffer). | 833 // or regular back buffer). |
| 834 gfx::Size GetBoundReadFramebufferSize(); | 834 gfx::Size GetBoundReadFramebufferSize(); |
| 835 | 835 |
| 836 // Get the service side ID for the bound read framebuffer. | 836 // Get the service side ID for the bound read framebuffer. |
| 837 // If it's back buffer, 0 is returned. | 837 // If it's back buffer, 0 is returned. |
| 838 GLuint GetBoundReadFramebufferServiceId(); | 838 GLuint GetBoundReadFramebufferServiceId(); |
| 839 | 839 |
| 840 // Get the service side ID for the bound draw framebuffer. | 840 // Get the service side ID for the bound draw framebuffer. |
| 841 // If it's back buffer, 0 is returned. | 841 // If it's back buffer, 0 is returned. |
| 842 GLuint GetBoundDrawFramebufferServiceId(); | 842 GLuint GetBoundDrawFramebufferServiceId() const; |
| 843 | 843 |
| 844 // Get the format/type of the currently bound frame buffer (either FBO or | 844 // Get the format/type of the currently bound frame buffer (either FBO or |
| 845 // regular back buffer). | 845 // regular back buffer). |
| 846 // If the color image is a renderbuffer, returns 0 for type. | 846 // If the color image is a renderbuffer, returns 0 for type. |
| 847 GLenum GetBoundReadFramebufferTextureType(); | 847 GLenum GetBoundReadFramebufferTextureType(); |
| 848 GLenum GetBoundReadFramebufferInternalFormat(); | 848 GLenum GetBoundReadFramebufferInternalFormat(); |
| 849 | 849 |
| 850 // Get the i-th draw buffer's internal format/type from the bound framebuffer. | 850 // Get the i-th draw buffer's internal format/type from the bound framebuffer. |
| 851 // If no framebuffer is bound, or no image is attached, or the DrawBuffers | 851 // If no framebuffer is bound, or no image is attached, or the DrawBuffers |
| 852 // setting for that image is GL_NONE, return 0. | 852 // setting for that image is GL_NONE, return 0. |
| (...skipping 3597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4450 } | 4450 } |
| 4451 if (offscreen_target_frame_buffer_.get()) { | 4451 if (offscreen_target_frame_buffer_.get()) { |
| 4452 return offscreen_target_frame_buffer_->id(); | 4452 return offscreen_target_frame_buffer_->id(); |
| 4453 } | 4453 } |
| 4454 if (surface_.get()) { | 4454 if (surface_.get()) { |
| 4455 return surface_->GetBackingFramebufferObject(); | 4455 return surface_->GetBackingFramebufferObject(); |
| 4456 } | 4456 } |
| 4457 return 0; | 4457 return 0; |
| 4458 } | 4458 } |
| 4459 | 4459 |
| 4460 GLuint GLES2DecoderImpl::GetBoundDrawFramebufferServiceId() { | 4460 GLuint GLES2DecoderImpl::GetBoundDrawFramebufferServiceId() const { |
| 4461 Framebuffer* framebuffer = GetBoundDrawFramebuffer(); | 4461 Framebuffer* framebuffer = GetBoundDrawFramebuffer(); |
| 4462 if (framebuffer) { | 4462 if (framebuffer) { |
| 4463 return framebuffer->service_id(); | 4463 return framebuffer->service_id(); |
| 4464 } | 4464 } |
| 4465 if (offscreen_target_frame_buffer_.get()) { | 4465 if (offscreen_target_frame_buffer_.get()) { |
| 4466 return offscreen_target_frame_buffer_->id(); | 4466 return offscreen_target_frame_buffer_->id(); |
| 4467 } | 4467 } |
| 4468 if (surface_.get()) { | 4468 if (surface_.get()) { |
| 4469 return surface_->GetBackingFramebufferObject(); | 4469 return surface_->GetBackingFramebufferObject(); |
| 4470 } | 4470 } |
| (...skipping 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5606 } | 5606 } |
| 5607 | 5607 |
| 5608 // Added specifically for testing backbuffer_needs_clear_bits unittests. | 5608 // Added specifically for testing backbuffer_needs_clear_bits unittests. |
| 5609 uint32_t GLES2DecoderImpl::GetAndClearBackbufferClearBitsForTest() { | 5609 uint32_t GLES2DecoderImpl::GetAndClearBackbufferClearBitsForTest() { |
| 5610 uint32_t clear_bits = backbuffer_needs_clear_bits_; | 5610 uint32_t clear_bits = backbuffer_needs_clear_bits_; |
| 5611 backbuffer_needs_clear_bits_ = 0; | 5611 backbuffer_needs_clear_bits_ = 0; |
| 5612 return clear_bits; | 5612 return clear_bits; |
| 5613 } | 5613 } |
| 5614 | 5614 |
| 5615 void GLES2DecoderImpl::OnFboChanged() const { | 5615 void GLES2DecoderImpl::OnFboChanged() const { |
| 5616 if (workarounds().restore_scissor_on_fbo_change) | 5616 state_.fbo_binding_for_scissor_workaround_dirty = true; |
| 5617 state_.fbo_binding_for_scissor_workaround_dirty = true; | |
| 5618 } | 5617 } |
| 5619 | 5618 |
| 5620 // Called after the FBO is checked for completeness. | 5619 // Called after the FBO is checked for completeness. |
| 5621 void GLES2DecoderImpl::OnUseFramebuffer() const { | 5620 void GLES2DecoderImpl::OnUseFramebuffer() const { |
| 5622 if (state_.fbo_binding_for_scissor_workaround_dirty) { | 5621 if (!state_.fbo_binding_for_scissor_workaround_dirty) |
| 5623 state_.fbo_binding_for_scissor_workaround_dirty = false; | 5622 return; |
| 5623 state_.fbo_binding_for_scissor_workaround_dirty = false; | |
| 5624 | |
| 5625 if (workarounds().restore_scissor_on_fbo_change) { | |
| 5624 // The driver forgets the correct scissor when modifying the FBO binding. | 5626 // The driver forgets the correct scissor when modifying the FBO binding. |
| 5625 glScissor(state_.scissor_x, | 5627 glScissor(state_.scissor_x, |
| 5626 state_.scissor_y, | 5628 state_.scissor_y, |
| 5627 state_.scissor_width, | 5629 state_.scissor_width, |
| 5628 state_.scissor_height); | 5630 state_.scissor_height); |
| 5629 | 5631 |
| 5630 // crbug.com/222018 - Also on QualComm, the flush here avoids flicker, | 5632 // crbug.com/222018 - Also on QualComm, the flush here avoids flicker, |
| 5631 // it's unclear how this bug works. | 5633 // it's unclear how this bug works. |
| 5632 glFlush(); | 5634 glFlush(); |
| 5633 } | 5635 } |
| 5636 | |
| 5637 if (workarounds().force_update_scissor_state_when_binding_fbo0 && | |
| 5638 !GetBoundDrawFramebufferServiceId()) { | |
|
brianderson
2017/01/27 08:07:56
...Id() == 0
| |
| 5639 // The theory is that FBO0 keeps some internal (in HW regs maybe?) scissor | |
| 5640 // test state, but the driver forgets to update it with GL_SCISSOR_TEST | |
| 5641 // when FBO0 gets bound. (So it stuck with whatever state we last switched | |
| 5642 // from it.) | |
| 5643 // If the internal scissor test state was enabled, it does update its | |
| 5644 // internal scissor rect with GL_SCISSOR_BOX though. | |
| 5645 if (state_.enable_flags.cached_scissor_test) { | |
| 5646 // The driver early outs if the new state matches previous state so some | |
| 5647 // shake up is needed. | |
| 5648 glDisable(GL_SCISSOR_TEST); | |
| 5649 glEnable(GL_SCISSOR_TEST); | |
| 5650 } else { | |
| 5651 // Ditto. | |
| 5652 glEnable(GL_SCISSOR_TEST); | |
| 5653 glDisable(GL_SCISSOR_TEST); | |
| 5654 } | |
| 5655 } | |
| 5634 } | 5656 } |
| 5635 | 5657 |
| 5636 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { | 5658 void GLES2DecoderImpl::DoBindFramebuffer(GLenum target, GLuint client_id) { |
| 5637 Framebuffer* framebuffer = NULL; | 5659 Framebuffer* framebuffer = NULL; |
| 5638 GLuint service_id = 0; | 5660 GLuint service_id = 0; |
| 5639 if (client_id != 0) { | 5661 if (client_id != 0) { |
| 5640 framebuffer = GetFramebuffer(client_id); | 5662 framebuffer = GetFramebuffer(client_id); |
| 5641 if (!framebuffer) { | 5663 if (!framebuffer) { |
| 5642 if (!group_->bind_generates_resource()) { | 5664 if (!group_->bind_generates_resource()) { |
| 5643 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, | 5665 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, |
| (...skipping 13553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 19197 } | 19219 } |
| 19198 | 19220 |
| 19199 // Include the auto-generated part of this file. We split this because it means | 19221 // Include the auto-generated part of this file. We split this because it means |
| 19200 // we can easily edit the non-auto generated parts right here in this file | 19222 // we can easily edit the non-auto generated parts right here in this file |
| 19201 // instead of having to edit some template or the code generator. | 19223 // instead of having to edit some template or the code generator. |
| 19202 #include "base/macros.h" | 19224 #include "base/macros.h" |
| 19203 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 19225 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 19204 | 19226 |
| 19205 } // namespace gles2 | 19227 } // namespace gles2 |
| 19206 } // namespace gpu | 19228 } // namespace gpu |
| OLD | NEW |