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

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

Issue 2286593002: [Command Buffer] emulate SRGB color format for BlitFramebuffer in OpenGL (Closed)
Patch Set: addressed feedbacks from piman and kbr Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/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
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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 807
807 // Deletes the TransformFeedback info for the given transformfeedback. 808 // Deletes the TransformFeedback info for the given transformfeedback.
808 void RemoveTransformFeedback(GLuint client_id) { 809 void RemoveTransformFeedback(GLuint client_id) {
809 transform_feedback_manager_->RemoveTransformFeedback(client_id); 810 transform_feedback_manager_->RemoveTransformFeedback(client_id);
810 } 811 }
811 812
812 // Get the size (in pixels) of the currently bound frame buffer (either FBO 813 // Get the size (in pixels) of the currently bound frame buffer (either FBO
813 // or regular back buffer). 814 // or regular back buffer).
814 gfx::Size GetBoundReadFramebufferSize(); 815 gfx::Size GetBoundReadFramebufferSize();
815 816
816 // Get the service side ID for the bound read frame buffer. 817 // Get the service side ID for the bound read framebuffer.
817 // If it's back buffer, 0 is returned. 818 // If it's back buffer, 0 is returned.
818 GLuint GetBoundReadFramebufferServiceId(); 819 GLuint GetBoundReadFramebufferServiceId();
819 820
821 // Get the service side ID for the bound draw framebuffer.
822 // If it's back buffer, 0 is returned.
823 GLuint GetBoundDrawFramebufferServiceId();
824
820 // Get the format/type of the currently bound frame buffer (either FBO or 825 // Get the format/type of the currently bound frame buffer (either FBO or
821 // regular back buffer). 826 // regular back buffer).
822 // If the color image is a renderbuffer, returns 0 for type. 827 // If the color image is a renderbuffer, returns 0 for type.
823 GLenum GetBoundReadFramebufferTextureType(); 828 GLenum GetBoundReadFramebufferTextureType();
824 GLenum GetBoundReadFramebufferInternalFormat(); 829 GLenum GetBoundReadFramebufferInternalFormat();
825 830
826 // Get the i-th draw buffer's internal format/type from the bound framebuffer. 831 // Get the i-th draw buffer's internal format/type from the bound framebuffer.
827 // If no framebuffer is bound, or no image is attached, or the DrawBuffers 832 // If no framebuffer is bound, or no image is attached, or the DrawBuffers
828 // setting for that image is GL_NONE, return 0. 833 // setting for that image is GL_NONE, return 0.
829 GLenum GetBoundColorDrawBufferType(GLint drawbuffer_i); 834 GLenum GetBoundColorDrawBufferType(GLint drawbuffer_i);
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2053 2058
2054 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and 2059 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and
2055 // equivalent functions reset shared state. 2060 // equivalent functions reset shared state.
2056 void ClearScheduleCALayerState(); 2061 void ClearScheduleCALayerState();
2057 2062
2058 // Helper method to call glClear workaround. 2063 // Helper method to call glClear workaround.
2059 void ClearFramebufferForWorkaround(GLbitfield mask); 2064 void ClearFramebufferForWorkaround(GLbitfield mask);
2060 2065
2061 bool InitializeCopyTexImageBlitter(const char* function_name); 2066 bool InitializeCopyTexImageBlitter(const char* function_name);
2062 bool InitializeCopyTextureCHROMIUM(const char* function_name); 2067 bool InitializeCopyTextureCHROMIUM(const char* function_name);
2068 bool InitializeSRGBConverter(const char* function_name);
2063 // Generate a member function prototype for each command in an automated and 2069 // Generate a member function prototype for each command in an automated and
2064 // typesafe way. 2070 // typesafe way.
2065 #define GLES2_CMD_OP(name) \ 2071 #define GLES2_CMD_OP(name) \
2066 Error Handle##name(uint32_t immediate_data_size, const volatile void* data); 2072 Error Handle##name(uint32_t immediate_data_size, const volatile void* data);
2067 2073
2068 GLES2_COMMAND_LIST(GLES2_CMD_OP) 2074 GLES2_COMMAND_LIST(GLES2_CMD_OP)
2069 2075
2070 #undef GLES2_CMD_OP 2076 #undef GLES2_CMD_OP
2071 2077
2072 // The GL context this decoder renders to on behalf of the client. 2078 // The GL context this decoder renders to on behalf of the client.
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 // Forces the backbuffer to use native GMBs rather than a TEXTURE_2D texture. 2251 // Forces the backbuffer to use native GMBs rather than a TEXTURE_2D texture.
2246 bool should_use_native_gmb_for_backbuffer_; 2252 bool should_use_native_gmb_for_backbuffer_;
2247 2253
2248 // Log extra info. 2254 // Log extra info.
2249 bool service_logging_; 2255 bool service_logging_;
2250 2256
2251 std::unique_ptr<ApplyFramebufferAttachmentCMAAINTELResourceManager> 2257 std::unique_ptr<ApplyFramebufferAttachmentCMAAINTELResourceManager>
2252 apply_framebuffer_attachment_cmaa_intel_; 2258 apply_framebuffer_attachment_cmaa_intel_;
2253 std::unique_ptr<CopyTexImageResourceManager> copy_tex_image_blit_; 2259 std::unique_ptr<CopyTexImageResourceManager> copy_tex_image_blit_;
2254 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; 2260 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_;
2261 std::unique_ptr<SRGBConverter> srgb_converter_;
2255 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_; 2262 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_;
2256 2263
2257 // Cached values of the currently assigned viewport dimensions. 2264 // Cached values of the currently assigned viewport dimensions.
2258 GLsizei viewport_max_width_; 2265 GLsizei viewport_max_width_;
2259 GLsizei viewport_max_height_; 2266 GLsizei viewport_max_height_;
2260 2267
2261 // Command buffer stats. 2268 // Command buffer stats.
2262 base::TimeDelta total_processing_commands_time_; 2269 base::TimeDelta total_processing_commands_time_;
2263 2270
2264 // States related to each manager. 2271 // States related to each manager.
(...skipping 1962 matching lines...) Expand 10 before | Expand all | Expand 10 after
4227 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; 4234 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER;
4228 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target); 4235 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target);
4229 bool valid = CheckFramebufferValid( 4236 bool valid = CheckFramebufferValid(
4230 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); 4237 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name);
4231 4238
4232 target = features().chromium_framebuffer_multisample ? 4239 target = features().chromium_framebuffer_multisample ?
4233 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; 4240 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
4234 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target); 4241 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target);
4235 valid = valid && CheckFramebufferValid( 4242 valid = valid && CheckFramebufferValid(
4236 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); 4243 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name);
4237
4238 if (valid && feature_info_->feature_flags().desktop_srgb_support) {
4239 bool enable_framebuffer_srgb =
4240 (draw_framebuffer && draw_framebuffer->HasSRGBAttachments()) ||
4241 (read_framebuffer && read_framebuffer->HasSRGBAttachments());
4242 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb);
4243 }
4244
4245 return valid; 4244 return valid;
4246 } 4245 }
4247 4246
4248 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( 4247 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat(
4249 GLenum internalformat) { 4248 GLenum internalformat) {
4250 switch (internalformat) { 4249 switch (internalformat) {
4251 case GL_SRGB_EXT: 4250 case GL_SRGB_EXT:
4252 case GL_SRGB_ALPHA_EXT: 4251 case GL_SRGB_ALPHA_EXT:
4253 case GL_SRGB8: 4252 case GL_SRGB8:
4254 case GL_SRGB8_ALPHA8: 4253 case GL_SRGB8_ALPHA8:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4300 } 4299 }
4301 if (offscreen_target_frame_buffer_.get()) { 4300 if (offscreen_target_frame_buffer_.get()) {
4302 return offscreen_target_frame_buffer_->id(); 4301 return offscreen_target_frame_buffer_->id();
4303 } 4302 }
4304 if (surface_.get()) { 4303 if (surface_.get()) {
4305 return surface_->GetBackingFramebufferObject(); 4304 return surface_->GetBackingFramebufferObject();
4306 } 4305 }
4307 return 0; 4306 return 0;
4308 } 4307 }
4309 4308
4309 GLuint GLES2DecoderImpl::GetBoundDrawFramebufferServiceId() {
4310 Framebuffer* framebuffer =
4311 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
4312 if (framebuffer) {
4313 return framebuffer->service_id();
4314 }
4315 if (offscreen_target_frame_buffer_.get()) {
4316 return offscreen_target_frame_buffer_->id();
4317 }
4318 if (surface_.get()) {
4319 return surface_->GetBackingFramebufferObject();
4320 }
4321 return 0;
4322 }
4323
4310 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() { 4324 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() {
4311 Framebuffer* framebuffer = 4325 Framebuffer* framebuffer =
4312 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); 4326 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
4313 if (framebuffer) { 4327 if (framebuffer) {
4314 return framebuffer->GetReadBufferTextureType(); 4328 return framebuffer->GetReadBufferTextureType();
4315 } else { // Back buffer. 4329 } else { // Back buffer.
4316 if (back_buffer_read_buffer_ == GL_NONE) 4330 if (back_buffer_read_buffer_ == GL_NONE)
4317 return 0; 4331 return 0;
4318 return GL_UNSIGNED_BYTE; 4332 return GL_UNSIGNED_BYTE;
4319 } 4333 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
4536 if (copy_tex_image_blit_.get()) { 4550 if (copy_tex_image_blit_.get()) {
4537 copy_tex_image_blit_->Destroy(); 4551 copy_tex_image_blit_->Destroy();
4538 copy_tex_image_blit_.reset(); 4552 copy_tex_image_blit_.reset();
4539 } 4553 }
4540 4554
4541 if (copy_texture_CHROMIUM_.get()) { 4555 if (copy_texture_CHROMIUM_.get()) {
4542 copy_texture_CHROMIUM_->Destroy(); 4556 copy_texture_CHROMIUM_->Destroy();
4543 copy_texture_CHROMIUM_.reset(); 4557 copy_texture_CHROMIUM_.reset();
4544 } 4558 }
4545 4559
4560 if (srgb_converter_.get()) {
4561 srgb_converter_->Destroy();
4562 srgb_converter_.reset();
4563 }
4564
4546 clear_framebuffer_blit_.reset(); 4565 clear_framebuffer_blit_.reset();
4547 4566
4548 if (state_.current_program.get()) { 4567 if (state_.current_program.get()) {
4549 program_manager()->UnuseProgram(shader_manager(), 4568 program_manager()->UnuseProgram(shader_manager(),
4550 state_.current_program.get()); 4569 state_.current_program.get());
4551 } 4570 }
4552 4571
4553 if (attrib_0_buffer_id_) { 4572 if (attrib_0_buffer_id_) {
4554 glDeleteBuffersARB(1, &attrib_0_buffer_id_); 4573 glDeleteBuffersARB(1, &attrib_0_buffer_id_);
4555 } 4574 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
4633 // Current program must be cleared after calling ProgramManager::UnuseProgram. 4652 // Current program must be cleared after calling ProgramManager::UnuseProgram.
4634 // Otherwise, we can leak objects. http://crbug.com/258772. 4653 // Otherwise, we can leak objects. http://crbug.com/258772.
4635 // state_.current_program must be reset before group_ is reset because 4654 // state_.current_program must be reset before group_ is reset because
4636 // the later deletes the ProgramManager object that referred by 4655 // the later deletes the ProgramManager object that referred by
4637 // state_.current_program object. 4656 // state_.current_program object.
4638 state_.current_program = NULL; 4657 state_.current_program = NULL;
4639 4658
4640 apply_framebuffer_attachment_cmaa_intel_.reset(); 4659 apply_framebuffer_attachment_cmaa_intel_.reset();
4641 copy_tex_image_blit_.reset(); 4660 copy_tex_image_blit_.reset();
4642 copy_texture_CHROMIUM_.reset(); 4661 copy_texture_CHROMIUM_.reset();
4662 srgb_converter_.reset();
4643 clear_framebuffer_blit_.reset(); 4663 clear_framebuffer_blit_.reset();
4644 4664
4645 if (query_manager_.get()) { 4665 if (query_manager_.get()) {
4646 query_manager_->Destroy(have_context); 4666 query_manager_->Destroy(have_context);
4647 query_manager_.reset(); 4667 query_manager_.reset();
4648 } 4668 }
4649 4669
4650 if (vertex_array_manager_ .get()) { 4670 if (vertex_array_manager_ .get()) {
4651 vertex_array_manager_->Destroy(have_context); 4671 vertex_array_manager_->Destroy(have_context);
4652 vertex_array_manager_.reset(); 4672 vertex_array_manager_.reset();
(...skipping 2933 matching lines...) Expand 10 before | Expand all | Expand 10 after
7586 read_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT); 7606 read_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT);
7587 const Framebuffer::Attachment* stencil_buffer_draw = 7607 const Framebuffer::Attachment* stencil_buffer_draw =
7588 draw_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT); 7608 draw_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT);
7589 if (stencil_buffer_draw && 7609 if (stencil_buffer_draw &&
7590 stencil_buffer_draw->IsSameAttachment(stencil_buffer_read)) { 7610 stencil_buffer_draw->IsSameAttachment(stencil_buffer_read)) {
7591 is_feedback_loop = FeedbackLoopTrue; 7611 is_feedback_loop = FeedbackLoopTrue;
7592 } 7612 }
7593 } 7613 }
7594 } 7614 }
7595 7615
7596 GLenum src_format = GetBoundReadFramebufferInternalFormat(); 7616 GLenum src_internal_format = GetBoundReadFramebufferInternalFormat();
7597 GLenum src_type = GetBoundReadFramebufferTextureType(); 7617 GLenum src_type = GetBoundReadFramebufferTextureType();
7598 7618
7619 bool read_buffer_has_srgb =
7620 GetColorEncodingFromInternalFormat(src_internal_format) == GL_SRGB;
7621 bool draw_buffers_has_srgb = false;
7599 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { 7622 if ((mask & GL_COLOR_BUFFER_BIT) != 0) {
7600 bool is_src_signed_int = GLES2Util::IsSignedIntegerFormat(src_format); 7623 bool is_src_signed_int =
7601 bool is_src_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(src_format); 7624 GLES2Util::IsSignedIntegerFormat(src_internal_format);
7625 bool is_src_unsigned_int =
7626 GLES2Util::IsUnsignedIntegerFormat(src_internal_format);
7602 DCHECK(!is_src_signed_int || !is_src_unsigned_int); 7627 DCHECK(!is_src_signed_int || !is_src_unsigned_int);
7603 7628
7604 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) { 7629 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) {
7605 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 7630 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
7606 "invalid filter for integer format"); 7631 "invalid filter for integer format");
7607 return; 7632 return;
7608 } 7633 }
7609 7634
7610 GLenum src_sized_format = 7635 GLenum src_sized_format =
7611 GLES2Util::ConvertToSizedFormat(src_format, src_type); 7636 GLES2Util::ConvertToSizedFormat(src_internal_format, src_type);
7612 DCHECK(read_framebuffer || (is_feedback_loop != FeedbackLoopUnknown)); 7637 DCHECK(read_framebuffer || (is_feedback_loop != FeedbackLoopUnknown));
7613 const Framebuffer::Attachment* read_buffer = 7638 const Framebuffer::Attachment* read_buffer =
7614 is_feedback_loop == FeedbackLoopUnknown ? 7639 is_feedback_loop == FeedbackLoopUnknown ?
7615 read_framebuffer->GetReadBufferAttachment() : nullptr; 7640 read_framebuffer->GetReadBufferAttachment() : nullptr;
7616 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) { 7641 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) {
7617 GLenum dst_format = GetBoundColorDrawBufferInternalFormat( 7642 GLenum dst_format = GetBoundColorDrawBufferInternalFormat(
7618 static_cast<GLint>(ii)); 7643 static_cast<GLint>(ii));
7619 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii)); 7644 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii));
7620 if (dst_format == 0) 7645 if (dst_format == 0)
7621 continue; 7646 continue;
7647 if (GetColorEncodingFromInternalFormat(dst_format) == GL_SRGB)
7648 draw_buffers_has_srgb = true;
7622 if (read_buffer_samples > 0 && 7649 if (read_buffer_samples > 0 &&
7623 (src_sized_format != 7650 (src_sized_format !=
7624 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) { 7651 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) {
7625 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 7652 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
7626 "src and dst formats differ for color"); 7653 "src and dst formats differ for color");
7627 return; 7654 return;
7628 } 7655 }
7629 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format); 7656 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format);
7630 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format); 7657 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format);
7631 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int); 7658 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
7667 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) != 7694 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) !=
7668 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || 7695 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) ||
7669 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) != 7696 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) !=
7670 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { 7697 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) {
7671 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 7698 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
7672 "src and dst formats differ for depth/stencil"); 7699 "src and dst formats differ for depth/stencil");
7673 return; 7700 return;
7674 } 7701 }
7675 } 7702 }
7676 7703
7677 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 7704 bool enable_srgb =
7678 BlitFramebufferHelper( 7705 (read_buffer_has_srgb || draw_buffers_has_srgb) &&
7679 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 7706 ((mask & GL_COLOR_BUFFER_BIT) != 0);
7680 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, 7707 bool encode_srgb_only =
7708 (draw_buffers_has_srgb && !read_buffer_has_srgb) &&
7709 ((mask & GL_COLOR_BUFFER_BIT) != 0);
7710 // TODO(yunchao) Need to revisit here if the read buffer is a multi-sampled
7711 // renderbuffer.
7712 if (!enable_srgb ||
7713 read_buffer_samples > 0 ||
7714 !feature_info_->feature_flags().desktop_srgb_support ||
7715 gl_version_info().IsAtLeastGL(4, 4) ||
7716 (gl_version_info().IsAtLeastGL(4, 2) && encode_srgb_only)) {
7717 if (enable_srgb && gl_version_info().IsAtLeastGL(4, 2)) {
7718 state_.EnableDisableFramebufferSRGB(enable_srgb);
7719 }
7720
7721 // TODO(yunchao) Need to revisit here. In GLES spec, blitFramebuffer
7722 // should do scissor test per fragment operation.
7723 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
7724 BlitFramebufferHelper(
7725 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
7726 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST,
7681 state_.enable_flags.scissor_test); 7727 state_.enable_flags.scissor_test);
7728 return;
7729 }
7730
7731 // emulate srgb for desktop core profile when GL version < 4.4
7732 // TODO(yunchao): Need to handle this situation:
7733 // There are multiple draw buffers. Some of them are srgb images.
7734 // The others are not.
7735 state_.EnableDisableFramebufferSRGB(true);
7736 if (!InitializeSRGBConverter(func_name)) {
7737 return;
7738 }
7739 GLenum src_format =
7740 TextureManager::ExtractFormatFromStorageFormat(src_internal_format);
7741 srgb_converter_->Blit(this, srcX0, srcY0, srcX1, srcY1,
7742 dstX0, dstY0, dstX1, dstY1,
7743 mask, filter,
7744 GetBoundReadFramebufferSize(),
7745 GetBoundReadFramebufferServiceId(),
7746 src_internal_format, src_format, src_type,
7747 GetBoundDrawFramebufferServiceId(),
7748 read_buffer_has_srgb, draw_buffers_has_srgb);
7749 }
7750
7751 bool GLES2DecoderImpl::InitializeSRGBConverter(
7752 const char* function_name) {
7753 if (!srgb_converter_.get()) {
7754 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name);
7755 srgb_converter_.reset(
7756 new SRGBConverter(feature_info_.get()));
7757 srgb_converter_->InitializeSRGBConverter(this);
7758 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) {
7759 return false;
7760 }
7761 }
7762 return true;
7682 } 7763 }
7683 7764
7684 void GLES2DecoderImpl::EnsureRenderbufferBound() { 7765 void GLES2DecoderImpl::EnsureRenderbufferBound() {
7685 if (!state_.bound_renderbuffer_valid) { 7766 if (!state_.bound_renderbuffer_valid) {
7686 state_.bound_renderbuffer_valid = true; 7767 state_.bound_renderbuffer_valid = true;
7687 glBindRenderbufferEXT(GL_RENDERBUFFER, 7768 glBindRenderbufferEXT(GL_RENDERBUFFER,
7688 state_.bound_renderbuffer.get() 7769 state_.bound_renderbuffer.get()
7689 ? state_.bound_renderbuffer->service_id() 7770 ? state_.bound_renderbuffer->service_id()
7690 : 0); 7771 : 0);
7691 } 7772 }
(...skipping 10284 matching lines...) Expand 10 before | Expand all | Expand 10 after
17976 } 18057 }
17977 18058
17978 // Include the auto-generated part of this file. We split this because it means 18059 // Include the auto-generated part of this file. We split this because it means
17979 // we can easily edit the non-auto generated parts right here in this file 18060 // we can easily edit the non-auto generated parts right here in this file
17980 // instead of having to edit some template or the code generator. 18061 // instead of having to edit some template or the code generator.
17981 #include "base/macros.h" 18062 #include "base/macros.h"
17982 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18063 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
17983 18064
17984 } // namespace gles2 18065 } // namespace gles2
17985 } // namespace gpu 18066 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_copy_tex_image.cc ('k') | gpu/command_buffer/service/gles2_cmd_srgb_converter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698