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 26 matching lines...) Expand all Loading... | |
| 37 #include "gpu/command_buffer/service/error_state.h" | 37 #include "gpu/command_buffer/service/error_state.h" |
| 38 #include "gpu/command_buffer/service/feature_info.h" | 38 #include "gpu/command_buffer/service/feature_info.h" |
| 39 #include "gpu/command_buffer/service/framebuffer_manager.h" | 39 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| 40 #include "gpu/command_buffer/service/gl_stream_texture_image.h" | 40 #include "gpu/command_buffer/service/gl_stream_texture_image.h" |
| 41 #include "gpu/command_buffer/service/gl_utils.h" | 41 #include "gpu/command_buffer/service/gl_utils.h" |
| 42 #include "gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa _intel.h" | 42 #include "gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa _intel.h" |
| 43 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h" | 43 #include "gpu/command_buffer/service/gles2_cmd_clear_framebuffer.h" |
| 44 #include "gpu/command_buffer/service/gles2_cmd_copy_tex_image.h" | 44 #include "gpu/command_buffer/service/gles2_cmd_copy_tex_image.h" |
| 45 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 45 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
| 46 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" | 46 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" |
| 47 #include "gpu/command_buffer/service/gles2_cmd_srgb_converter.h" | |
| 47 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 48 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
| 48 #include "gpu/command_buffer/service/gpu_preferences.h" | 49 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 49 #include "gpu/command_buffer/service/gpu_state_tracer.h" | 50 #include "gpu/command_buffer/service/gpu_state_tracer.h" |
| 50 #include "gpu/command_buffer/service/gpu_tracer.h" | 51 #include "gpu/command_buffer/service/gpu_tracer.h" |
| 51 #include "gpu/command_buffer/service/image_factory.h" | 52 #include "gpu/command_buffer/service/image_factory.h" |
| 52 #include "gpu/command_buffer/service/image_manager.h" | 53 #include "gpu/command_buffer/service/image_manager.h" |
| 53 #include "gpu/command_buffer/service/logger.h" | 54 #include "gpu/command_buffer/service/logger.h" |
| 54 #include "gpu/command_buffer/service/mailbox_manager.h" | 55 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 55 #include "gpu/command_buffer/service/memory_tracking.h" | 56 #include "gpu/command_buffer/service/memory_tracking.h" |
| 56 #include "gpu/command_buffer/service/path_manager.h" | 57 #include "gpu/command_buffer/service/path_manager.h" |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 877 | 878 |
| 878 // Deletes the TransformFeedback info for the given transformfeedback. | 879 // Deletes the TransformFeedback info for the given transformfeedback. |
| 879 void RemoveTransformFeedback(GLuint client_id) { | 880 void RemoveTransformFeedback(GLuint client_id) { |
| 880 transform_feedback_manager_->RemoveTransformFeedback(client_id); | 881 transform_feedback_manager_->RemoveTransformFeedback(client_id); |
| 881 } | 882 } |
| 882 | 883 |
| 883 // Get the size (in pixels) of the currently bound frame buffer (either FBO | 884 // Get the size (in pixels) of the currently bound frame buffer (either FBO |
| 884 // or regular back buffer). | 885 // or regular back buffer). |
| 885 gfx::Size GetBoundReadFramebufferSize(); | 886 gfx::Size GetBoundReadFramebufferSize(); |
| 886 | 887 |
| 887 // Get the service side ID for the bound read frame buffer. | 888 // Get the service side ID for the bound read framebuffer. |
| 888 // If it's back buffer, 0 is returned. | 889 // If it's back buffer, 0 is returned. |
| 889 GLuint GetBoundReadFramebufferServiceId(); | 890 GLuint GetBoundReadFramebufferServiceId(); |
| 890 | 891 |
| 892 // Get the service side ID for the bound draw framebuffer. | |
| 893 // If it's back buffer, 0 is returned. | |
| 894 GLuint GetBoundDrawFramebufferServiceId(); | |
| 895 | |
| 891 // Get the format/type of the currently bound frame buffer (either FBO or | 896 // Get the format/type of the currently bound frame buffer (either FBO or |
| 892 // regular back buffer). | 897 // regular back buffer). |
| 893 // If the color image is a renderbuffer, returns 0 for type. | 898 // If the color image is a renderbuffer, returns 0 for type. |
| 894 GLenum GetBoundReadFramebufferTextureType(); | 899 GLenum GetBoundReadFramebufferTextureType(); |
| 895 GLenum GetBoundReadFramebufferInternalFormat(); | 900 GLenum GetBoundReadFramebufferInternalFormat(); |
| 896 | 901 |
| 897 // Get the i-th draw buffer's internal format/type from the bound framebuffer. | 902 // Get the i-th draw buffer's internal format/type from the bound framebuffer. |
| 898 // If no framebuffer is bound, or no image is attached, or the DrawBuffers | 903 // If no framebuffer is bound, or no image is attached, or the DrawBuffers |
| 899 // setting for that image is GL_NONE, return 0. | 904 // setting for that image is GL_NONE, return 0. |
| 900 GLenum GetBoundColorDrawBufferType(GLint drawbuffer_i); | 905 GLenum GetBoundColorDrawBufferType(GLint drawbuffer_i); |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2124 | 2129 |
| 2125 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and | 2130 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and |
| 2126 // equivalent functions reset shared state. | 2131 // equivalent functions reset shared state. |
| 2127 void ClearScheduleCALayerState(); | 2132 void ClearScheduleCALayerState(); |
| 2128 | 2133 |
| 2129 // Helper method to call glClear workaround. | 2134 // Helper method to call glClear workaround. |
| 2130 void ClearFramebufferForWorkaround(GLbitfield mask); | 2135 void ClearFramebufferForWorkaround(GLbitfield mask); |
| 2131 | 2136 |
| 2132 bool InitializeCopyTexImageBlitter(const char* function_name); | 2137 bool InitializeCopyTexImageBlitter(const char* function_name); |
| 2133 bool InitializeCopyTextureCHROMIUM(const char* function_name); | 2138 bool InitializeCopyTextureCHROMIUM(const char* function_name); |
| 2139 bool InitializeSRGBDecoder(const char* function_name); | |
| 2140 bool InitializeSRGBEncoder(const char* function_name); | |
| 2134 // Generate a member function prototype for each command in an automated and | 2141 // Generate a member function prototype for each command in an automated and |
| 2135 // typesafe way. | 2142 // typesafe way. |
| 2136 #define GLES2_CMD_OP(name) \ | 2143 #define GLES2_CMD_OP(name) \ |
| 2137 Error Handle##name(uint32_t immediate_data_size, const volatile void* data); | 2144 Error Handle##name(uint32_t immediate_data_size, const volatile void* data); |
| 2138 | 2145 |
| 2139 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 2146 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
| 2140 | 2147 |
| 2141 #undef GLES2_CMD_OP | 2148 #undef GLES2_CMD_OP |
| 2142 | 2149 |
| 2143 // The GL context this decoder renders to on behalf of the client. | 2150 // The GL context this decoder renders to on behalf of the client. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2315 // Forces the backbuffer to use native GMBs rather than a TEXTURE_2D texture. | 2322 // Forces the backbuffer to use native GMBs rather than a TEXTURE_2D texture. |
| 2316 bool should_use_native_gmb_for_backbuffer_; | 2323 bool should_use_native_gmb_for_backbuffer_; |
| 2317 | 2324 |
| 2318 // Log extra info. | 2325 // Log extra info. |
| 2319 bool service_logging_; | 2326 bool service_logging_; |
| 2320 | 2327 |
| 2321 std::unique_ptr<ApplyFramebufferAttachmentCMAAINTELResourceManager> | 2328 std::unique_ptr<ApplyFramebufferAttachmentCMAAINTELResourceManager> |
| 2322 apply_framebuffer_attachment_cmaa_intel_; | 2329 apply_framebuffer_attachment_cmaa_intel_; |
| 2323 std::unique_ptr<CopyTexImageResourceManager> copy_tex_image_blit_; | 2330 std::unique_ptr<CopyTexImageResourceManager> copy_tex_image_blit_; |
| 2324 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; | 2331 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; |
| 2332 std::unique_ptr<SRGBConverter> srgb_converter_; | |
| 2325 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_; | 2333 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_; |
| 2326 | 2334 |
| 2327 // Cached values of the currently assigned viewport dimensions. | 2335 // Cached values of the currently assigned viewport dimensions. |
| 2328 GLsizei viewport_max_width_; | 2336 GLsizei viewport_max_width_; |
| 2329 GLsizei viewport_max_height_; | 2337 GLsizei viewport_max_height_; |
| 2330 | 2338 |
| 2331 // Command buffer stats. | 2339 // Command buffer stats. |
| 2332 base::TimeDelta total_processing_commands_time_; | 2340 base::TimeDelta total_processing_commands_time_; |
| 2333 | 2341 |
| 2334 // States related to each manager. | 2342 // States related to each manager. |
| (...skipping 1952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4287 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; | 4295 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; |
| 4288 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target); | 4296 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target); |
| 4289 bool valid = CheckFramebufferValid( | 4297 bool valid = CheckFramebufferValid( |
| 4290 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); | 4298 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); |
| 4291 | 4299 |
| 4292 target = features().chromium_framebuffer_multisample ? | 4300 target = features().chromium_framebuffer_multisample ? |
| 4293 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; | 4301 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; |
| 4294 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target); | 4302 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target); |
| 4295 valid = valid && CheckFramebufferValid( | 4303 valid = valid && CheckFramebufferValid( |
| 4296 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); | 4304 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); |
| 4297 | |
| 4298 if (valid && feature_info_->feature_flags().desktop_srgb_support) { | |
| 4299 bool enable_framebuffer_srgb = | |
| 4300 (draw_framebuffer && draw_framebuffer->HasSRGBAttachments()) || | |
| 4301 (read_framebuffer && read_framebuffer->HasSRGBAttachments()); | |
| 4302 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); | |
| 4303 } | |
| 4304 | |
| 4305 return valid; | 4305 return valid; |
| 4306 } | 4306 } |
| 4307 | 4307 |
| 4308 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( | 4308 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( |
| 4309 GLenum internalformat) { | 4309 GLenum internalformat) { |
| 4310 switch (internalformat) { | 4310 switch (internalformat) { |
| 4311 case GL_SRGB_EXT: | 4311 case GL_SRGB_EXT: |
| 4312 case GL_SRGB_ALPHA_EXT: | 4312 case GL_SRGB_ALPHA_EXT: |
| 4313 case GL_SRGB8: | 4313 case GL_SRGB8: |
| 4314 case GL_SRGB8_ALPHA8: | 4314 case GL_SRGB8_ALPHA8: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4360 } | 4360 } |
| 4361 if (offscreen_target_frame_buffer_.get()) { | 4361 if (offscreen_target_frame_buffer_.get()) { |
| 4362 return offscreen_target_frame_buffer_->id(); | 4362 return offscreen_target_frame_buffer_->id(); |
| 4363 } | 4363 } |
| 4364 if (surface_.get()) { | 4364 if (surface_.get()) { |
| 4365 return surface_->GetBackingFramebufferObject(); | 4365 return surface_->GetBackingFramebufferObject(); |
| 4366 } | 4366 } |
| 4367 return 0; | 4367 return 0; |
| 4368 } | 4368 } |
| 4369 | 4369 |
| 4370 GLuint GLES2DecoderImpl::GetBoundDrawFramebufferServiceId() { | |
| 4371 Framebuffer* framebuffer = | |
| 4372 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | |
| 4373 if (framebuffer) { | |
| 4374 return framebuffer->service_id(); | |
| 4375 } | |
| 4376 if (offscreen_target_frame_buffer_.get()) { | |
| 4377 return offscreen_target_frame_buffer_->id(); | |
| 4378 } | |
| 4379 if (surface_.get()) { | |
| 4380 return surface_->GetBackingFramebufferObject(); | |
| 4381 } | |
| 4382 return 0; | |
| 4383 } | |
| 4384 | |
| 4370 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() { | 4385 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() { |
| 4371 Framebuffer* framebuffer = | 4386 Framebuffer* framebuffer = |
| 4372 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); | 4387 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); |
| 4373 if (framebuffer) { | 4388 if (framebuffer) { |
| 4374 return framebuffer->GetReadBufferTextureType(); | 4389 return framebuffer->GetReadBufferTextureType(); |
| 4375 } else { // Back buffer. | 4390 } else { // Back buffer. |
| 4376 if (back_buffer_read_buffer_ == GL_NONE) | 4391 if (back_buffer_read_buffer_ == GL_NONE) |
| 4377 return 0; | 4392 return 0; |
| 4378 return GL_UNSIGNED_BYTE; | 4393 return GL_UNSIGNED_BYTE; |
| 4379 } | 4394 } |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4596 if (copy_tex_image_blit_.get()) { | 4611 if (copy_tex_image_blit_.get()) { |
| 4597 copy_tex_image_blit_->Destroy(); | 4612 copy_tex_image_blit_->Destroy(); |
| 4598 copy_tex_image_blit_.reset(); | 4613 copy_tex_image_blit_.reset(); |
| 4599 } | 4614 } |
| 4600 | 4615 |
| 4601 if (copy_texture_CHROMIUM_.get()) { | 4616 if (copy_texture_CHROMIUM_.get()) { |
| 4602 copy_texture_CHROMIUM_->Destroy(); | 4617 copy_texture_CHROMIUM_->Destroy(); |
| 4603 copy_texture_CHROMIUM_.reset(); | 4618 copy_texture_CHROMIUM_.reset(); |
| 4604 } | 4619 } |
| 4605 | 4620 |
| 4621 if (srgb_converter_.get()) { | |
| 4622 srgb_converter_->Destroy(); | |
| 4623 srgb_converter_.reset(); | |
| 4624 } | |
| 4625 | |
| 4606 clear_framebuffer_blit_.reset(); | 4626 clear_framebuffer_blit_.reset(); |
| 4607 | 4627 |
| 4608 if (state_.current_program.get()) { | 4628 if (state_.current_program.get()) { |
| 4609 program_manager()->UnuseProgram(shader_manager(), | 4629 program_manager()->UnuseProgram(shader_manager(), |
| 4610 state_.current_program.get()); | 4630 state_.current_program.get()); |
| 4611 } | 4631 } |
| 4612 | 4632 |
| 4613 if (attrib_0_buffer_id_) { | 4633 if (attrib_0_buffer_id_) { |
| 4614 glDeleteBuffersARB(1, &attrib_0_buffer_id_); | 4634 glDeleteBuffersARB(1, &attrib_0_buffer_id_); |
| 4615 } | 4635 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4688 // Current program must be cleared after calling ProgramManager::UnuseProgram. | 4708 // Current program must be cleared after calling ProgramManager::UnuseProgram. |
| 4689 // Otherwise, we can leak objects. http://crbug.com/258772. | 4709 // Otherwise, we can leak objects. http://crbug.com/258772. |
| 4690 // state_.current_program must be reset before group_ is reset because | 4710 // state_.current_program must be reset before group_ is reset because |
| 4691 // the later deletes the ProgramManager object that referred by | 4711 // the later deletes the ProgramManager object that referred by |
| 4692 // state_.current_program object. | 4712 // state_.current_program object. |
| 4693 state_.current_program = NULL; | 4713 state_.current_program = NULL; |
| 4694 | 4714 |
| 4695 apply_framebuffer_attachment_cmaa_intel_.reset(); | 4715 apply_framebuffer_attachment_cmaa_intel_.reset(); |
| 4696 copy_tex_image_blit_.reset(); | 4716 copy_tex_image_blit_.reset(); |
| 4697 copy_texture_CHROMIUM_.reset(); | 4717 copy_texture_CHROMIUM_.reset(); |
| 4718 srgb_converter_.reset(); | |
| 4698 clear_framebuffer_blit_.reset(); | 4719 clear_framebuffer_blit_.reset(); |
| 4699 | 4720 |
| 4700 if (query_manager_.get()) { | 4721 if (query_manager_.get()) { |
| 4701 query_manager_->Destroy(have_context); | 4722 query_manager_->Destroy(have_context); |
| 4702 query_manager_.reset(); | 4723 query_manager_.reset(); |
| 4703 } | 4724 } |
| 4704 | 4725 |
| 4705 if (vertex_array_manager_ .get()) { | 4726 if (vertex_array_manager_ .get()) { |
| 4706 vertex_array_manager_->Destroy(have_context); | 4727 vertex_array_manager_->Destroy(have_context); |
| 4707 vertex_array_manager_.reset(); | 4728 vertex_array_manager_.reset(); |
| (...skipping 2886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7594 } | 7615 } |
| 7595 | 7616 |
| 7596 GLsizei read_buffer_samples = GetBoundFramebufferSamples(GL_READ_FRAMEBUFFER); | 7617 GLsizei read_buffer_samples = GetBoundFramebufferSamples(GL_READ_FRAMEBUFFER); |
| 7597 if (read_buffer_samples > 0 && | 7618 if (read_buffer_samples > 0 && |
| 7598 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) { | 7619 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) { |
| 7599 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7620 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7600 "src framebuffer is multisampled, but src/dst regions are different"); | 7621 "src framebuffer is multisampled, but src/dst regions are different"); |
| 7601 return; | 7622 return; |
| 7602 } | 7623 } |
| 7603 | 7624 |
| 7604 GLenum src_format = GetBoundReadFramebufferInternalFormat(); | 7625 GLenum src_internal_format = GetBoundReadFramebufferInternalFormat(); |
| 7605 GLenum src_type = GetBoundReadFramebufferTextureType(); | 7626 GLenum src_type = GetBoundReadFramebufferTextureType(); |
| 7606 | 7627 |
| 7628 bool read_buffer_has_srgb = | |
| 7629 GetColorEncodingFromInternalFormat(src_internal_format) == GL_SRGB; | |
| 7630 bool draw_buffers_has_srgb = false; | |
| 7607 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { | 7631 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { |
| 7608 bool is_src_signed_int = GLES2Util::IsSignedIntegerFormat(src_format); | 7632 bool is_src_signed_int = |
| 7609 bool is_src_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(src_format); | 7633 GLES2Util::IsSignedIntegerFormat(src_internal_format); |
| 7634 bool is_src_unsigned_int = | |
| 7635 GLES2Util::IsUnsignedIntegerFormat(src_internal_format); | |
| 7610 DCHECK(!is_src_signed_int || !is_src_unsigned_int); | 7636 DCHECK(!is_src_signed_int || !is_src_unsigned_int); |
| 7611 | 7637 |
| 7612 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) { | 7638 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) { |
| 7613 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7639 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7614 "invalid filter for integer format"); | 7640 "invalid filter for integer format"); |
| 7615 return; | 7641 return; |
| 7616 } | 7642 } |
| 7617 | 7643 |
| 7618 GLenum src_sized_format = | 7644 GLenum src_sized_format = |
| 7619 GLES2Util::ConvertToSizedFormat(src_format, src_type); | 7645 GLES2Util::ConvertToSizedFormat(src_internal_format, src_type); |
| 7620 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) { | 7646 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) { |
| 7621 GLenum dst_format = GetBoundColorDrawBufferInternalFormat( | 7647 GLenum dst_format = GetBoundColorDrawBufferInternalFormat( |
| 7622 static_cast<GLint>(ii)); | 7648 static_cast<GLint>(ii)); |
| 7623 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii)); | 7649 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii)); |
| 7624 if (dst_format == 0) | 7650 if (dst_format == 0) |
| 7625 continue; | 7651 continue; |
| 7652 if (GetColorEncodingFromInternalFormat(dst_format) == GL_SRGB) | |
| 7653 draw_buffers_has_srgb = true; | |
| 7626 if (read_buffer_samples > 0 && | 7654 if (read_buffer_samples > 0 && |
| 7627 (src_sized_format != | 7655 (src_sized_format != |
| 7628 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) { | 7656 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) { |
| 7629 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7657 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7630 "src and dst formats differ for color"); | 7658 "src and dst formats differ for color"); |
| 7631 return; | 7659 return; |
| 7632 } | 7660 } |
| 7633 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format); | 7661 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format); |
| 7634 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format); | 7662 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format); |
| 7635 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int); | 7663 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 7652 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) != | 7680 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) != |
| 7653 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || | 7681 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || |
| 7654 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) != | 7682 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) != |
| 7655 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { | 7683 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { |
| 7656 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7684 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7657 "src and dst formats differ for depth/stencil"); | 7685 "src and dst formats differ for depth/stencil"); |
| 7658 return; | 7686 return; |
| 7659 } | 7687 } |
| 7660 } | 7688 } |
| 7661 | 7689 |
| 7662 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 7690 bool enable_srgb = read_buffer_has_srgb || draw_buffers_has_srgb; |
| 7663 BlitFramebufferHelper( | 7691 if (!enable_srgb || |
| 7664 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 7692 !feature_info_->feature_flags().desktop_srgb_support || |
| 7665 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, | 7693 gl_version_info().IsAtLeastGL(4, 4)) { |
| 7694 if (enable_srgb && gl_version_info().IsAtLeastGL(4, 4)) { | |
| 7695 state_.EnableDisableFramebufferSRGB(enable_srgb); | |
| 7696 } | |
| 7697 | |
| 7698 // TODO(yunchao) Need to revisit here. In GLES spec, blitFramebuffer | |
| 7699 // should do scissor test per fragment operation. | |
| 7700 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | |
| 7701 BlitFramebufferHelper( | |
| 7702 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | |
| 7703 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, | |
| 7666 state_.enable_flags.scissor_test); | 7704 state_.enable_flags.scissor_test); |
| 7705 return; | |
| 7706 } | |
| 7707 | |
| 7708 // emulate srgb for desktop core profile when GL version < 4.4 | |
| 7709 // TODO(yunchao): Need to handle this situation: | |
| 7710 // There are multiple draw buffers. Some of them are srgb images. | |
| 7711 // The others are not. | |
| 7712 if (read_buffer_has_srgb && !draw_buffers_has_srgb) { | |
| 7713 state_.EnableDisableFramebufferSRGB(false); | |
| 7714 if (!InitializeSRGBDecoder(func_name)) { | |
| 7715 return; | |
| 7716 } | |
| 7717 srgb_converter_->SRGBToLinear(this, srcX0, srcY0, srcX1, srcY1, | |
| 7718 dstX0, dstY0, dstX1, dstY1, | |
| 7719 mask, filter, | |
| 7720 GetBoundReadFramebufferSize(), | |
| 7721 GetBoundReadFramebufferServiceId(), | |
| 7722 src_internal_format, | |
| 7723 GetBoundDrawFramebufferServiceId()); | |
| 7724 } | |
| 7725 | |
| 7726 if (draw_buffers_has_srgb && !read_buffer_has_srgb) { | |
| 7727 state_.EnableDisableFramebufferSRGB(false); | |
|
piman
2016/09/13 00:39:23
Once more. Why do you do disable GL_FRAMEBUFFER_SR
yunchao
2016/09/13 08:37:17
I am not sure whether I understand you correctly.
| |
| 7728 if (!InitializeSRGBEncoder(func_name)) { | |
| 7729 return; | |
| 7730 } | |
| 7731 GLenum src_format = | |
| 7732 TextureManager::ExtractFormatFromStorageFormat(src_internal_format); | |
| 7733 srgb_converter_->LinearToSRGB(this, srcX0, srcY0, srcX1, srcY1, | |
| 7734 dstX0, dstY0, dstX1, dstY1, | |
| 7735 mask, filter, | |
| 7736 GetBoundReadFramebufferServiceId(), | |
| 7737 src_internal_format, src_format, src_type, | |
| 7738 GetBoundDrawFramebufferServiceId()); | |
| 7739 } | |
| 7740 | |
| 7741 if (read_buffer_has_srgb && draw_buffers_has_srgb) { | |
| 7742 state_.EnableDisableFramebufferSRGB(false); | |
| 7743 if (!InitializeSRGBDecoder(func_name) || | |
| 7744 !InitializeSRGBEncoder(func_name)) { | |
| 7745 return; | |
| 7746 } | |
| 7747 srgb_converter_->SRGBToSRGB(this, srcX0, srcY0, srcX1, srcY1, | |
| 7748 dstX0, dstY0, dstX1, dstY1, | |
| 7749 mask, filter, | |
| 7750 GetBoundReadFramebufferSize(), | |
| 7751 GetBoundReadFramebufferServiceId(), | |
| 7752 src_internal_format, | |
| 7753 GetBoundDrawFramebufferServiceId()); | |
| 7754 } | |
| 7755 } | |
| 7756 | |
| 7757 bool GLES2DecoderImpl::InitializeSRGBDecoder( | |
| 7758 const char* function_name) { | |
| 7759 if (!srgb_converter_.get()) { | |
| 7760 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); | |
| 7761 srgb_converter_.reset( | |
| 7762 new SRGBConverter(feature_info_.get())); | |
| 7763 } | |
| 7764 srgb_converter_->InitializeSRGBDecoder(this); | |
| 7765 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) { | |
| 7766 return false; | |
| 7767 } | |
| 7768 return true; | |
| 7769 } | |
| 7770 | |
| 7771 bool GLES2DecoderImpl::InitializeSRGBEncoder( | |
| 7772 const char* function_name) { | |
| 7773 if (!srgb_converter_.get()) { | |
| 7774 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); | |
| 7775 srgb_converter_.reset( | |
| 7776 new SRGBConverter(feature_info_.get())); | |
| 7777 } | |
| 7778 srgb_converter_->InitializeSRGBEncoder(this); | |
| 7779 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) { | |
| 7780 return false; | |
| 7781 } | |
| 7782 return true; | |
| 7667 } | 7783 } |
| 7668 | 7784 |
| 7669 void GLES2DecoderImpl::EnsureRenderbufferBound() { | 7785 void GLES2DecoderImpl::EnsureRenderbufferBound() { |
| 7670 if (!state_.bound_renderbuffer_valid) { | 7786 if (!state_.bound_renderbuffer_valid) { |
| 7671 state_.bound_renderbuffer_valid = true; | 7787 state_.bound_renderbuffer_valid = true; |
| 7672 glBindRenderbufferEXT(GL_RENDERBUFFER, | 7788 glBindRenderbufferEXT(GL_RENDERBUFFER, |
| 7673 state_.bound_renderbuffer.get() | 7789 state_.bound_renderbuffer.get() |
| 7674 ? state_.bound_renderbuffer->service_id() | 7790 ? state_.bound_renderbuffer->service_id() |
| 7675 : 0); | 7791 : 0); |
| 7676 } | 7792 } |
| (...skipping 10257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17934 } | 18050 } |
| 17935 | 18051 |
| 17936 // Include the auto-generated part of this file. We split this because it means | 18052 // Include the auto-generated part of this file. We split this because it means |
| 17937 // we can easily edit the non-auto generated parts right here in this file | 18053 // we can easily edit the non-auto generated parts right here in this file |
| 17938 // instead of having to edit some template or the code generator. | 18054 // instead of having to edit some template or the code generator. |
| 17939 #include "base/macros.h" | 18055 #include "base/macros.h" |
| 17940 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 18056 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 17941 | 18057 |
| 17942 } // namespace gles2 | 18058 } // namespace gles2 |
| 17943 } // namespace gpu | 18059 } // namespace gpu |
| OLD | NEW |