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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
875 | 876 |
876 // Deletes the TransformFeedback info for the given transformfeedback. | 877 // Deletes the TransformFeedback info for the given transformfeedback. |
877 void RemoveTransformFeedback(GLuint client_id) { | 878 void RemoveTransformFeedback(GLuint client_id) { |
878 transform_feedback_manager_->RemoveTransformFeedback(client_id); | 879 transform_feedback_manager_->RemoveTransformFeedback(client_id); |
879 } | 880 } |
880 | 881 |
881 // Get the size (in pixels) of the currently bound frame buffer (either FBO | 882 // Get the size (in pixels) of the currently bound frame buffer (either FBO |
882 // or regular back buffer). | 883 // or regular back buffer). |
883 gfx::Size GetBoundReadFramebufferSize(); | 884 gfx::Size GetBoundReadFramebufferSize(); |
884 | 885 |
885 // Get the service side ID for the bound read frame buffer. | 886 // Get the service side ID for the bound read framebuffer. |
886 // If it's back buffer, 0 is returned. | 887 // If it's back buffer, 0 is returned. |
887 GLuint GetBoundReadFramebufferServiceId(); | 888 GLuint GetBoundReadFramebufferServiceId(); |
888 | 889 |
890 // Get the service side ID for the bound draw framebuffer. | |
891 // If it's back buffer, 0 is returned. | |
892 GLuint GetBoundDrawFramebufferServiceId(); | |
893 | |
889 // Get the format/type of the currently bound frame buffer (either FBO or | 894 // Get the format/type of the currently bound frame buffer (either FBO or |
890 // regular back buffer). | 895 // regular back buffer). |
891 // If the color image is a renderbuffer, returns 0 for type. | 896 // If the color image is a renderbuffer, returns 0 for type. |
892 GLenum GetBoundReadFramebufferTextureType(); | 897 GLenum GetBoundReadFramebufferTextureType(); |
893 GLenum GetBoundReadFramebufferInternalFormat(); | 898 GLenum GetBoundReadFramebufferInternalFormat(); |
894 | 899 |
895 // Get the i-th draw buffer's internal format/type from the bound framebuffer. | 900 // Get the i-th draw buffer's internal format/type from the bound framebuffer. |
896 // If no framebuffer is bound, or no image is attached, or the DrawBuffers | 901 // If no framebuffer is bound, or no image is attached, or the DrawBuffers |
897 // setting for that image is GL_NONE, return 0. | 902 // setting for that image is GL_NONE, return 0. |
898 GLenum GetBoundColorDrawBufferType(GLint drawbuffer_i); | 903 GLenum GetBoundColorDrawBufferType(GLint drawbuffer_i); |
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2064 // Whether a texture backed by a Chromium Image needs to emulate GL_RGB format | 2069 // Whether a texture backed by a Chromium Image needs to emulate GL_RGB format |
2065 // using GL_RGBA and glColorMask. | 2070 // using GL_RGBA and glColorMask. |
2066 bool ChromiumImageNeedsRGBEmulation(); | 2071 bool ChromiumImageNeedsRGBEmulation(); |
2067 | 2072 |
2068 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and | 2073 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and |
2069 // equivalent functions reset shared state. | 2074 // equivalent functions reset shared state. |
2070 void ClearScheduleCALayerState(); | 2075 void ClearScheduleCALayerState(); |
2071 | 2076 |
2072 bool InitializeCopyTexImageBlitter(const char* function_name); | 2077 bool InitializeCopyTexImageBlitter(const char* function_name); |
2073 bool InitializeCopyTextureCHROMIUM(const char* function_name); | 2078 bool InitializeCopyTextureCHROMIUM(const char* function_name); |
2079 bool InitializeSRGBDecoder(const char* function_name); | |
2080 bool InitializeSRGBEncoder(const char* function_name); | |
2074 // Generate a member function prototype for each command in an automated and | 2081 // Generate a member function prototype for each command in an automated and |
2075 // typesafe way. | 2082 // typesafe way. |
2076 #define GLES2_CMD_OP(name) \ | 2083 #define GLES2_CMD_OP(name) \ |
2077 Error Handle##name(uint32_t immediate_data_size, const void* data); | 2084 Error Handle##name(uint32_t immediate_data_size, const void* data); |
2078 | 2085 |
2079 GLES2_COMMAND_LIST(GLES2_CMD_OP) | 2086 GLES2_COMMAND_LIST(GLES2_CMD_OP) |
2080 | 2087 |
2081 #undef GLES2_CMD_OP | 2088 #undef GLES2_CMD_OP |
2082 | 2089 |
2083 // The GL context this decoder renders to on behalf of the client. | 2090 // 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... | |
2255 // Forces the backbuffer to use native GMBs rather than a TEXTURE_2D texture. | 2262 // Forces the backbuffer to use native GMBs rather than a TEXTURE_2D texture. |
2256 bool should_use_native_gmb_for_backbuffer_; | 2263 bool should_use_native_gmb_for_backbuffer_; |
2257 | 2264 |
2258 // Log extra info. | 2265 // Log extra info. |
2259 bool service_logging_; | 2266 bool service_logging_; |
2260 | 2267 |
2261 std::unique_ptr<ApplyFramebufferAttachmentCMAAINTELResourceManager> | 2268 std::unique_ptr<ApplyFramebufferAttachmentCMAAINTELResourceManager> |
2262 apply_framebuffer_attachment_cmaa_intel_; | 2269 apply_framebuffer_attachment_cmaa_intel_; |
2263 std::unique_ptr<CopyTexImageResourceManager> copy_tex_image_blit_; | 2270 std::unique_ptr<CopyTexImageResourceManager> copy_tex_image_blit_; |
2264 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; | 2271 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; |
2272 std::unique_ptr<SRGBConverter> srgb_converter_; | |
2265 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_; | 2273 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_; |
2266 | 2274 |
2267 // Cached values of the currently assigned viewport dimensions. | 2275 // Cached values of the currently assigned viewport dimensions. |
2268 GLsizei viewport_max_width_; | 2276 GLsizei viewport_max_width_; |
2269 GLsizei viewport_max_height_; | 2277 GLsizei viewport_max_height_; |
2270 | 2278 |
2271 // Command buffer stats. | 2279 // Command buffer stats. |
2272 base::TimeDelta total_processing_commands_time_; | 2280 base::TimeDelta total_processing_commands_time_; |
2273 | 2281 |
2274 // States related to each manager. | 2282 // States related to each manager. |
(...skipping 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4219 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; | 4227 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; |
4220 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target); | 4228 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target); |
4221 bool valid = CheckFramebufferValid( | 4229 bool valid = CheckFramebufferValid( |
4222 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); | 4230 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); |
4223 | 4231 |
4224 target = features().chromium_framebuffer_multisample ? | 4232 target = features().chromium_framebuffer_multisample ? |
4225 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; | 4233 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; |
4226 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target); | 4234 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target); |
4227 valid = valid && CheckFramebufferValid( | 4235 valid = valid && CheckFramebufferValid( |
4228 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); | 4236 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); |
4229 | |
4230 if (valid && feature_info_->feature_flags().desktop_srgb_support) { | |
4231 bool enable_framebuffer_srgb = | |
4232 (draw_framebuffer && draw_framebuffer->HasSRGBAttachments()) || | |
4233 (read_framebuffer && read_framebuffer->HasSRGBAttachments()); | |
4234 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); | |
4235 } | |
4236 | |
4237 return valid; | 4237 return valid; |
4238 } | 4238 } |
4239 | 4239 |
4240 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( | 4240 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( |
4241 GLenum internalformat) { | 4241 GLenum internalformat) { |
4242 switch (internalformat) { | 4242 switch (internalformat) { |
4243 case GL_SRGB_EXT: | 4243 case GL_SRGB_EXT: |
4244 case GL_SRGB_ALPHA_EXT: | 4244 case GL_SRGB_ALPHA_EXT: |
4245 case GL_SRGB8: | 4245 case GL_SRGB8: |
4246 case GL_SRGB8_ALPHA8: | 4246 case GL_SRGB8_ALPHA8: |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4292 } | 4292 } |
4293 if (offscreen_target_frame_buffer_.get()) { | 4293 if (offscreen_target_frame_buffer_.get()) { |
4294 return offscreen_target_frame_buffer_->id(); | 4294 return offscreen_target_frame_buffer_->id(); |
4295 } | 4295 } |
4296 if (surface_.get()) { | 4296 if (surface_.get()) { |
4297 return surface_->GetBackingFramebufferObject(); | 4297 return surface_->GetBackingFramebufferObject(); |
4298 } | 4298 } |
4299 return 0; | 4299 return 0; |
4300 } | 4300 } |
4301 | 4301 |
4302 GLuint GLES2DecoderImpl::GetBoundDrawFramebufferServiceId() { | |
4303 Framebuffer* framebuffer = | |
4304 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT); | |
4305 if (framebuffer) { | |
4306 return framebuffer->service_id(); | |
4307 } | |
4308 if (offscreen_target_frame_buffer_.get()) { | |
4309 return offscreen_target_frame_buffer_->id(); | |
4310 } | |
4311 if (surface_.get()) { | |
4312 return surface_->GetBackingFramebufferObject(); | |
4313 } | |
4314 return 0; | |
4315 } | |
4316 | |
4302 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() { | 4317 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() { |
4303 Framebuffer* framebuffer = | 4318 Framebuffer* framebuffer = |
4304 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); | 4319 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); |
4305 if (framebuffer) { | 4320 if (framebuffer) { |
4306 return framebuffer->GetReadBufferTextureType(); | 4321 return framebuffer->GetReadBufferTextureType(); |
4307 } else { // Back buffer. | 4322 } else { // Back buffer. |
4308 if (back_buffer_read_buffer_ == GL_NONE) | 4323 if (back_buffer_read_buffer_ == GL_NONE) |
4309 return 0; | 4324 return 0; |
4310 return GL_UNSIGNED_BYTE; | 4325 return GL_UNSIGNED_BYTE; |
4311 } | 4326 } |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4528 if (copy_tex_image_blit_.get()) { | 4543 if (copy_tex_image_blit_.get()) { |
4529 copy_tex_image_blit_->Destroy(); | 4544 copy_tex_image_blit_->Destroy(); |
4530 copy_tex_image_blit_.reset(); | 4545 copy_tex_image_blit_.reset(); |
4531 } | 4546 } |
4532 | 4547 |
4533 if (copy_texture_CHROMIUM_.get()) { | 4548 if (copy_texture_CHROMIUM_.get()) { |
4534 copy_texture_CHROMIUM_->Destroy(); | 4549 copy_texture_CHROMIUM_->Destroy(); |
4535 copy_texture_CHROMIUM_.reset(); | 4550 copy_texture_CHROMIUM_.reset(); |
4536 } | 4551 } |
4537 | 4552 |
4553 if (srgb_converter_.get()) { | |
4554 srgb_converter_->Destroy(); | |
4555 srgb_converter_.reset(); | |
4556 } | |
4557 | |
4538 clear_framebuffer_blit_.reset(); | 4558 clear_framebuffer_blit_.reset(); |
4539 | 4559 |
4540 if (state_.current_program.get()) { | 4560 if (state_.current_program.get()) { |
4541 program_manager()->UnuseProgram(shader_manager(), | 4561 program_manager()->UnuseProgram(shader_manager(), |
4542 state_.current_program.get()); | 4562 state_.current_program.get()); |
4543 } | 4563 } |
4544 | 4564 |
4545 if (attrib_0_buffer_id_) { | 4565 if (attrib_0_buffer_id_) { |
4546 glDeleteBuffersARB(1, &attrib_0_buffer_id_); | 4566 glDeleteBuffersARB(1, &attrib_0_buffer_id_); |
4547 } | 4567 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4620 // Current program must be cleared after calling ProgramManager::UnuseProgram. | 4640 // Current program must be cleared after calling ProgramManager::UnuseProgram. |
4621 // Otherwise, we can leak objects. http://crbug.com/258772. | 4641 // Otherwise, we can leak objects. http://crbug.com/258772. |
4622 // state_.current_program must be reset before group_ is reset because | 4642 // state_.current_program must be reset before group_ is reset because |
4623 // the later deletes the ProgramManager object that referred by | 4643 // the later deletes the ProgramManager object that referred by |
4624 // state_.current_program object. | 4644 // state_.current_program object. |
4625 state_.current_program = NULL; | 4645 state_.current_program = NULL; |
4626 | 4646 |
4627 apply_framebuffer_attachment_cmaa_intel_.reset(); | 4647 apply_framebuffer_attachment_cmaa_intel_.reset(); |
4628 copy_tex_image_blit_.reset(); | 4648 copy_tex_image_blit_.reset(); |
4629 copy_texture_CHROMIUM_.reset(); | 4649 copy_texture_CHROMIUM_.reset(); |
4650 srgb_converter_.reset(); | |
4630 clear_framebuffer_blit_.reset(); | 4651 clear_framebuffer_blit_.reset(); |
4631 | 4652 |
4632 if (query_manager_.get()) { | 4653 if (query_manager_.get()) { |
4633 query_manager_->Destroy(have_context); | 4654 query_manager_->Destroy(have_context); |
4634 query_manager_.reset(); | 4655 query_manager_.reset(); |
4635 } | 4656 } |
4636 | 4657 |
4637 if (vertex_array_manager_ .get()) { | 4658 if (vertex_array_manager_ .get()) { |
4638 vertex_array_manager_->Destroy(have_context); | 4659 vertex_array_manager_->Destroy(have_context); |
4639 vertex_array_manager_.reset(); | 4660 vertex_array_manager_.reset(); |
(...skipping 2877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7517 } | 7538 } |
7518 | 7539 |
7519 GLsizei read_buffer_samples = GetBoundFramebufferSamples(GL_READ_FRAMEBUFFER); | 7540 GLsizei read_buffer_samples = GetBoundFramebufferSamples(GL_READ_FRAMEBUFFER); |
7520 if (read_buffer_samples > 0 && | 7541 if (read_buffer_samples > 0 && |
7521 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) { | 7542 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) { |
7522 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7543 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
7523 "src framebuffer is multisampled, but src/dst regions are different"); | 7544 "src framebuffer is multisampled, but src/dst regions are different"); |
7524 return; | 7545 return; |
7525 } | 7546 } |
7526 | 7547 |
7527 GLenum src_format = GetBoundReadFramebufferInternalFormat(); | 7548 GLenum src_internal_format = GetBoundReadFramebufferInternalFormat(); |
7528 GLenum src_type = GetBoundReadFramebufferTextureType(); | 7549 GLenum src_type = GetBoundReadFramebufferTextureType(); |
7529 | 7550 |
7551 bool read_buffer_has_srgb = | |
7552 GetColorEncodingFromInternalFormat(src_internal_format) == GL_SRGB; | |
7553 bool draw_buffers_has_srgb = false; | |
7530 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { | 7554 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { |
7531 bool is_src_signed_int = GLES2Util::IsSignedIntegerFormat(src_format); | 7555 bool is_src_signed_int = |
7532 bool is_src_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(src_format); | 7556 GLES2Util::IsSignedIntegerFormat(src_internal_format); |
7557 bool is_src_unsigned_int = | |
7558 GLES2Util::IsUnsignedIntegerFormat(src_internal_format); | |
7533 DCHECK(!is_src_signed_int || !is_src_unsigned_int); | 7559 DCHECK(!is_src_signed_int || !is_src_unsigned_int); |
7534 | 7560 |
7535 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) { | 7561 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) { |
7536 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7562 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
7537 "invalid filter for integer format"); | 7563 "invalid filter for integer format"); |
7538 return; | 7564 return; |
7539 } | 7565 } |
7540 | 7566 |
7541 GLenum src_sized_format = | 7567 GLenum src_sized_format = |
7542 GLES2Util::ConvertToSizedFormat(src_format, src_type); | 7568 GLES2Util::ConvertToSizedFormat(src_internal_format, src_type); |
7543 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) { | 7569 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) { |
7544 GLenum dst_format = GetBoundColorDrawBufferInternalFormat( | 7570 GLenum dst_format = GetBoundColorDrawBufferInternalFormat( |
7545 static_cast<GLint>(ii)); | 7571 static_cast<GLint>(ii)); |
7546 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii)); | 7572 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii)); |
7547 if (dst_format == 0) | 7573 if (dst_format == 0) |
7548 continue; | 7574 continue; |
7575 if (GetColorEncodingFromInternalFormat(dst_format) == GL_SRGB) | |
7576 draw_buffers_has_srgb = true; | |
7549 if (read_buffer_samples > 0 && | 7577 if (read_buffer_samples > 0 && |
7550 (src_sized_format != | 7578 (src_sized_format != |
7551 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) { | 7579 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) { |
7552 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7580 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
7553 "src and dst formats differ for color"); | 7581 "src and dst formats differ for color"); |
7554 return; | 7582 return; |
7555 } | 7583 } |
7556 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format); | 7584 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format); |
7557 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format); | 7585 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format); |
7558 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int); | 7586 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int); |
(...skipping 16 matching lines...) Expand all Loading... | |
7575 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) != | 7603 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) != |
7576 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || | 7604 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || |
7577 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) != | 7605 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) != |
7578 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { | 7606 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { |
7579 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7607 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
7580 "src and dst formats differ for depth/stencil"); | 7608 "src and dst formats differ for depth/stencil"); |
7581 return; | 7609 return; |
7582 } | 7610 } |
7583 } | 7611 } |
7584 | 7612 |
7585 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 7613 bool enable_srgb = read_buffer_has_srgb || draw_buffers_has_srgb; |
7586 BlitFramebufferHelper( | 7614 if (!enable_srgb || |
7587 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 7615 !feature_info_->feature_flags().desktop_srgb_support || |
7588 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, | 7616 gl_version_info().IsAtLeastGL(4, 4)) { |
7617 if (enable_srgb && gl_version_info().IsAtLeastGL(4, 4)) { | |
7618 state_.EnableDisableFramebufferSRGB(enable_srgb); | |
7619 } | |
7620 | |
7621 // TODO(yunchao) Need to revisit here. In GLES spec, blitFramebuffer | |
7622 // should do scissor test per fragment operation. | |
7623 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | |
7624 BlitFramebufferHelper( | |
7625 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | |
7626 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, | |
7589 state_.enable_flags.scissor_test); | 7627 state_.enable_flags.scissor_test); |
7628 return; | |
7629 } | |
7630 | |
7631 // emulate srgb for desktop core profile when GL version < 4.4 | |
7632 // TODO(yunchao): Need to handle this situation: | |
7633 // There are multiple draw buffers. Some of them are srgb image. | |
7634 // The others are not. | |
7635 | |
7636 if (read_buffer_has_srgb) { | |
7637 state_.EnableDisableFramebufferSRGB(false); | |
7638 if (!InitializeSRGBDecoder(func_name)) { | |
7639 return; | |
7640 } | |
7641 srgb_converter_->SRGBToLinear(this, srcX0, srcY0, srcX1, srcY1, | |
7642 dstX0, dstY0, dstX1, dstY1, | |
7643 mask, filter, | |
7644 GetBoundReadFramebufferSize(), | |
7645 GetBoundReadFramebufferServiceId(), | |
7646 src_internal_format, | |
7647 GetBoundDrawFramebufferServiceId(), | |
7648 GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE); | |
7649 } | |
7650 | |
7651 if (draw_buffers_has_srgb) { | |
piman
2016/09/07 23:08:32
What if both read and draw buffers have srgb?
yunchao
2016/09/08 18:32:49
I would do this in follow-up changes.
If both re
piman
2016/09/08 19:39:17
How does that work? SRGBToLinear blits from the re
yunchao
2016/09/08 23:16:49
Yes, the current implementation is not correct her
| |
7652 state_.EnableDisableFramebufferSRGB(false); | |
7653 if (!InitializeSRGBEncoder(func_name)) { | |
7654 return; | |
7655 } | |
7656 srgb_converter_->LinearToSRGB(this, srcX0, srcY0, srcX1, srcY1, | |
7657 dstX0, dstY0, dstX1, dstY1, | |
7658 mask, filter, | |
7659 GetBoundReadFramebufferSize(), | |
7660 GetBoundReadFramebufferServiceId(), | |
7661 src_internal_format, | |
7662 GetBoundDrawFramebufferServiceId(), | |
7663 GL_SRGB8_ALPHA8, | |
7664 GL_RGBA, GL_UNSIGNED_BYTE); | |
7665 } | |
7666 } | |
7667 | |
7668 bool GLES2DecoderImpl::InitializeSRGBDecoder( | |
7669 const char* function_name) { | |
7670 if (!srgb_converter_.get()) { | |
7671 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); | |
7672 srgb_converter_.reset( | |
7673 new SRGBConverter(feature_info_.get())); | |
7674 } | |
7675 srgb_converter_->InitializeSRGBDecoder(this); | |
7676 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) { | |
7677 return false; | |
7678 } | |
7679 return true; | |
7680 } | |
7681 | |
7682 bool GLES2DecoderImpl::InitializeSRGBEncoder( | |
7683 const char* function_name) { | |
7684 if (!srgb_converter_.get()) { | |
7685 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name); | |
7686 srgb_converter_.reset( | |
7687 new SRGBConverter(feature_info_.get())); | |
7688 } | |
7689 srgb_converter_->InitializeSRGBEncoder(this); | |
7690 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) { | |
7691 return false; | |
7692 } | |
7693 return true; | |
7590 } | 7694 } |
7591 | 7695 |
7592 void GLES2DecoderImpl::EnsureRenderbufferBound() { | 7696 void GLES2DecoderImpl::EnsureRenderbufferBound() { |
7593 if (!state_.bound_renderbuffer_valid) { | 7697 if (!state_.bound_renderbuffer_valid) { |
7594 state_.bound_renderbuffer_valid = true; | 7698 state_.bound_renderbuffer_valid = true; |
7595 glBindRenderbufferEXT(GL_RENDERBUFFER, | 7699 glBindRenderbufferEXT(GL_RENDERBUFFER, |
7596 state_.bound_renderbuffer.get() | 7700 state_.bound_renderbuffer.get() |
7597 ? state_.bound_renderbuffer->service_id() | 7701 ? state_.bound_renderbuffer->service_id() |
7598 : 0); | 7702 : 0); |
7599 } | 7703 } |
(...skipping 10134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
17734 } | 17838 } |
17735 | 17839 |
17736 // Include the auto-generated part of this file. We split this because it means | 17840 // Include the auto-generated part of this file. We split this because it means |
17737 // we can easily edit the non-auto generated parts right here in this file | 17841 // we can easily edit the non-auto generated parts right here in this file |
17738 // instead of having to edit some template or the code generator. | 17842 // instead of having to edit some template or the code generator. |
17739 #include "base/macros.h" | 17843 #include "base/macros.h" |
17740 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17844 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
17741 | 17845 |
17742 } // namespace gles2 | 17846 } // namespace gles2 |
17743 } // namespace gpu | 17847 } // namespace gpu |
OLD | NEW |