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

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 piman's feedback: use a trivial fragment shader, don't need to explicitly convert linear … 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 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 815
815 // Deletes the TransformFeedback info for the given transformfeedback. 816 // Deletes the TransformFeedback info for the given transformfeedback.
816 void RemoveTransformFeedback(GLuint client_id) { 817 void RemoveTransformFeedback(GLuint client_id) {
817 transform_feedback_manager_->RemoveTransformFeedback(client_id); 818 transform_feedback_manager_->RemoveTransformFeedback(client_id);
818 } 819 }
819 820
820 // Get the size (in pixels) of the currently bound frame buffer (either FBO 821 // Get the size (in pixels) of the currently bound frame buffer (either FBO
821 // or regular back buffer). 822 // or regular back buffer).
822 gfx::Size GetBoundReadFramebufferSize(); 823 gfx::Size GetBoundReadFramebufferSize();
823 824
824 // Get the service side ID for the bound read frame buffer. 825 // Get the service side ID for the bound read framebuffer.
825 // If it's back buffer, 0 is returned. 826 // If it's back buffer, 0 is returned.
826 GLuint GetBoundReadFramebufferServiceId(); 827 GLuint GetBoundReadFramebufferServiceId();
827 828
829 // Get the service side ID for the bound draw framebuffer.
830 // If it's back buffer, 0 is returned.
831 GLuint GetBoundDrawFramebufferServiceId();
832
828 // Get the format/type of the currently bound frame buffer (either FBO or 833 // Get the format/type of the currently bound frame buffer (either FBO or
829 // regular back buffer). 834 // regular back buffer).
830 // If the color image is a renderbuffer, returns 0 for type. 835 // If the color image is a renderbuffer, returns 0 for type.
831 GLenum GetBoundReadFramebufferTextureType(); 836 GLenum GetBoundReadFramebufferTextureType();
832 GLenum GetBoundReadFramebufferInternalFormat(); 837 GLenum GetBoundReadFramebufferInternalFormat();
833 838
834 // Get the i-th draw buffer's internal format/type from the bound framebuffer. 839 // Get the i-th draw buffer's internal format/type from the bound framebuffer.
835 // If no framebuffer is bound, or no image is attached, or the DrawBuffers 840 // If no framebuffer is bound, or no image is attached, or the DrawBuffers
836 // setting for that image is GL_NONE, return 0. 841 // setting for that image is GL_NONE, return 0.
837 GLenum GetBoundColorDrawBufferType(GLint drawbuffer_i); 842 GLenum GetBoundColorDrawBufferType(GLint drawbuffer_i);
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 2066
2062 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and 2067 // The GL_CHROMIUM_schedule_ca_layer extension requires that SwapBuffers and
2063 // equivalent functions reset shared state. 2068 // equivalent functions reset shared state.
2064 void ClearScheduleCALayerState(); 2069 void ClearScheduleCALayerState();
2065 2070
2066 // Helper method to call glClear workaround. 2071 // Helper method to call glClear workaround.
2067 void ClearFramebufferForWorkaround(GLbitfield mask); 2072 void ClearFramebufferForWorkaround(GLbitfield mask);
2068 2073
2069 bool InitializeCopyTexImageBlitter(const char* function_name); 2074 bool InitializeCopyTexImageBlitter(const char* function_name);
2070 bool InitializeCopyTextureCHROMIUM(const char* function_name); 2075 bool InitializeCopyTextureCHROMIUM(const char* function_name);
2076 bool InitializeSRGBDecoder(const char* function_name);
2077 bool InitializeSRGBEncoder(const char* function_name);
2071 // Generate a member function prototype for each command in an automated and 2078 // Generate a member function prototype for each command in an automated and
2072 // typesafe way. 2079 // typesafe way.
2073 #define GLES2_CMD_OP(name) \ 2080 #define GLES2_CMD_OP(name) \
2074 Error Handle##name(uint32_t immediate_data_size, const volatile void* data); 2081 Error Handle##name(uint32_t immediate_data_size, const volatile void* data);
2075 2082
2076 GLES2_COMMAND_LIST(GLES2_CMD_OP) 2083 GLES2_COMMAND_LIST(GLES2_CMD_OP)
2077 2084
2078 #undef GLES2_CMD_OP 2085 #undef GLES2_CMD_OP
2079 2086
2080 // The GL context this decoder renders to on behalf of the client. 2087 // The GL context this decoder renders to on behalf of the client.
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 // Forces the backbuffer to use native GMBs rather than a TEXTURE_2D texture. 2260 // Forces the backbuffer to use native GMBs rather than a TEXTURE_2D texture.
2254 bool should_use_native_gmb_for_backbuffer_; 2261 bool should_use_native_gmb_for_backbuffer_;
2255 2262
2256 // Log extra info. 2263 // Log extra info.
2257 bool service_logging_; 2264 bool service_logging_;
2258 2265
2259 std::unique_ptr<ApplyFramebufferAttachmentCMAAINTELResourceManager> 2266 std::unique_ptr<ApplyFramebufferAttachmentCMAAINTELResourceManager>
2260 apply_framebuffer_attachment_cmaa_intel_; 2267 apply_framebuffer_attachment_cmaa_intel_;
2261 std::unique_ptr<CopyTexImageResourceManager> copy_tex_image_blit_; 2268 std::unique_ptr<CopyTexImageResourceManager> copy_tex_image_blit_;
2262 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_; 2269 std::unique_ptr<CopyTextureCHROMIUMResourceManager> copy_texture_CHROMIUM_;
2270 std::unique_ptr<SRGBConverter> srgb_converter_;
2263 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_; 2271 std::unique_ptr<ClearFramebufferResourceManager> clear_framebuffer_blit_;
2264 2272
2265 // Cached values of the currently assigned viewport dimensions. 2273 // Cached values of the currently assigned viewport dimensions.
2266 GLsizei viewport_max_width_; 2274 GLsizei viewport_max_width_;
2267 GLsizei viewport_max_height_; 2275 GLsizei viewport_max_height_;
2268 2276
2269 // Command buffer stats. 2277 // Command buffer stats.
2270 base::TimeDelta total_processing_commands_time_; 2278 base::TimeDelta total_processing_commands_time_;
2271 2279
2272 // States related to each manager. 2280 // States related to each manager.
(...skipping 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after
4228 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; 4236 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER;
4229 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target); 4237 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target);
4230 bool valid = CheckFramebufferValid( 4238 bool valid = CheckFramebufferValid(
4231 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); 4239 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name);
4232 4240
4233 target = features().chromium_framebuffer_multisample ? 4241 target = features().chromium_framebuffer_multisample ?
4234 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; 4242 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
4235 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target); 4243 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target);
4236 valid = valid && CheckFramebufferValid( 4244 valid = valid && CheckFramebufferValid(
4237 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); 4245 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name);
4238
4239 if (valid && feature_info_->feature_flags().desktop_srgb_support) {
4240 bool enable_framebuffer_srgb =
4241 (draw_framebuffer && draw_framebuffer->HasSRGBAttachments()) ||
4242 (read_framebuffer && read_framebuffer->HasSRGBAttachments());
4243 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb);
4244 }
4245
4246 return valid; 4246 return valid;
4247 } 4247 }
4248 4248
4249 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( 4249 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat(
4250 GLenum internalformat) { 4250 GLenum internalformat) {
4251 switch (internalformat) { 4251 switch (internalformat) {
4252 case GL_SRGB_EXT: 4252 case GL_SRGB_EXT:
4253 case GL_SRGB_ALPHA_EXT: 4253 case GL_SRGB_ALPHA_EXT:
4254 case GL_SRGB8: 4254 case GL_SRGB8:
4255 case GL_SRGB8_ALPHA8: 4255 case GL_SRGB8_ALPHA8:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4301 } 4301 }
4302 if (offscreen_target_frame_buffer_.get()) { 4302 if (offscreen_target_frame_buffer_.get()) {
4303 return offscreen_target_frame_buffer_->id(); 4303 return offscreen_target_frame_buffer_->id();
4304 } 4304 }
4305 if (surface_.get()) { 4305 if (surface_.get()) {
4306 return surface_->GetBackingFramebufferObject(); 4306 return surface_->GetBackingFramebufferObject();
4307 } 4307 }
4308 return 0; 4308 return 0;
4309 } 4309 }
4310 4310
4311 GLuint GLES2DecoderImpl::GetBoundDrawFramebufferServiceId() {
4312 Framebuffer* framebuffer =
4313 GetFramebufferInfoForTarget(GL_DRAW_FRAMEBUFFER_EXT);
4314 if (framebuffer) {
4315 return framebuffer->service_id();
4316 }
4317 if (offscreen_target_frame_buffer_.get()) {
4318 return offscreen_target_frame_buffer_->id();
4319 }
4320 if (surface_.get()) {
4321 return surface_->GetBackingFramebufferObject();
4322 }
4323 return 0;
4324 }
4325
4311 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() { 4326 GLenum GLES2DecoderImpl::GetBoundReadFramebufferTextureType() {
4312 Framebuffer* framebuffer = 4327 Framebuffer* framebuffer =
4313 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT); 4328 GetFramebufferInfoForTarget(GL_READ_FRAMEBUFFER_EXT);
4314 if (framebuffer) { 4329 if (framebuffer) {
4315 return framebuffer->GetReadBufferTextureType(); 4330 return framebuffer->GetReadBufferTextureType();
4316 } else { // Back buffer. 4331 } else { // Back buffer.
4317 if (back_buffer_read_buffer_ == GL_NONE) 4332 if (back_buffer_read_buffer_ == GL_NONE)
4318 return 0; 4333 return 0;
4319 return GL_UNSIGNED_BYTE; 4334 return GL_UNSIGNED_BYTE;
4320 } 4335 }
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
4537 if (copy_tex_image_blit_.get()) { 4552 if (copy_tex_image_blit_.get()) {
4538 copy_tex_image_blit_->Destroy(); 4553 copy_tex_image_blit_->Destroy();
4539 copy_tex_image_blit_.reset(); 4554 copy_tex_image_blit_.reset();
4540 } 4555 }
4541 4556
4542 if (copy_texture_CHROMIUM_.get()) { 4557 if (copy_texture_CHROMIUM_.get()) {
4543 copy_texture_CHROMIUM_->Destroy(); 4558 copy_texture_CHROMIUM_->Destroy();
4544 copy_texture_CHROMIUM_.reset(); 4559 copy_texture_CHROMIUM_.reset();
4545 } 4560 }
4546 4561
4562 if (srgb_converter_.get()) {
4563 srgb_converter_->Destroy();
4564 srgb_converter_.reset();
4565 }
4566
4547 clear_framebuffer_blit_.reset(); 4567 clear_framebuffer_blit_.reset();
4548 4568
4549 if (state_.current_program.get()) { 4569 if (state_.current_program.get()) {
4550 program_manager()->UnuseProgram(shader_manager(), 4570 program_manager()->UnuseProgram(shader_manager(),
4551 state_.current_program.get()); 4571 state_.current_program.get());
4552 } 4572 }
4553 4573
4554 if (attrib_0_buffer_id_) { 4574 if (attrib_0_buffer_id_) {
4555 glDeleteBuffersARB(1, &attrib_0_buffer_id_); 4575 glDeleteBuffersARB(1, &attrib_0_buffer_id_);
4556 } 4576 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
4634 // Current program must be cleared after calling ProgramManager::UnuseProgram. 4654 // Current program must be cleared after calling ProgramManager::UnuseProgram.
4635 // Otherwise, we can leak objects. http://crbug.com/258772. 4655 // Otherwise, we can leak objects. http://crbug.com/258772.
4636 // state_.current_program must be reset before group_ is reset because 4656 // state_.current_program must be reset before group_ is reset because
4637 // the later deletes the ProgramManager object that referred by 4657 // the later deletes the ProgramManager object that referred by
4638 // state_.current_program object. 4658 // state_.current_program object.
4639 state_.current_program = NULL; 4659 state_.current_program = NULL;
4640 4660
4641 apply_framebuffer_attachment_cmaa_intel_.reset(); 4661 apply_framebuffer_attachment_cmaa_intel_.reset();
4642 copy_tex_image_blit_.reset(); 4662 copy_tex_image_blit_.reset();
4643 copy_texture_CHROMIUM_.reset(); 4663 copy_texture_CHROMIUM_.reset();
4664 srgb_converter_.reset();
4644 clear_framebuffer_blit_.reset(); 4665 clear_framebuffer_blit_.reset();
4645 4666
4646 if (query_manager_.get()) { 4667 if (query_manager_.get()) {
4647 query_manager_->Destroy(have_context); 4668 query_manager_->Destroy(have_context);
4648 query_manager_.reset(); 4669 query_manager_.reset();
4649 } 4670 }
4650 4671
4651 if (vertex_array_manager_ .get()) { 4672 if (vertex_array_manager_ .get()) {
4652 vertex_array_manager_->Destroy(have_context); 4673 vertex_array_manager_->Destroy(have_context);
4653 vertex_array_manager_.reset(); 4674 vertex_array_manager_.reset();
(...skipping 2931 matching lines...) Expand 10 before | Expand all | Expand 10 after
7585 const Framebuffer::Attachment* stencil_buffer_read = 7606 const Framebuffer::Attachment* stencil_buffer_read =
7586 read_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT); 7607 read_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT);
7587 const Framebuffer::Attachment* stencil_buffer_draw = 7608 const Framebuffer::Attachment* stencil_buffer_draw =
7588 draw_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT); 7609 draw_framebuffer->GetAttachment(GL_STENCIL_ATTACHMENT);
7589 if (stencil_buffer_draw && 7610 if (stencil_buffer_draw &&
7590 stencil_buffer_draw->IsSameAttachment(stencil_buffer_read)) { 7611 stencil_buffer_draw->IsSameAttachment(stencil_buffer_read)) {
7591 is_feedback_loop = FeedbackLoopTrue; 7612 is_feedback_loop = FeedbackLoopTrue;
7592 } 7613 }
7593 } 7614 }
7594 7615
7595 GLenum src_format = GetBoundReadFramebufferInternalFormat(); 7616 GLenum src_internal_format = GetBoundReadFramebufferInternalFormat();
7596 GLenum src_type = GetBoundReadFramebufferTextureType(); 7617 GLenum src_type = GetBoundReadFramebufferTextureType();
7597 7618
7619 bool read_buffer_has_srgb =
7620 GetColorEncodingFromInternalFormat(src_internal_format) == GL_SRGB;
7621 bool draw_buffers_has_srgb = false;
7598 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { 7622 if ((mask & GL_COLOR_BUFFER_BIT) != 0) {
7599 bool is_src_signed_int = GLES2Util::IsSignedIntegerFormat(src_format); 7623 bool is_src_signed_int =
7600 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);
7601 DCHECK(!is_src_signed_int || !is_src_unsigned_int); 7627 DCHECK(!is_src_signed_int || !is_src_unsigned_int);
7602 7628
7603 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) {
7604 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 7630 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
7605 "invalid filter for integer format"); 7631 "invalid filter for integer format");
7606 return; 7632 return;
7607 } 7633 }
7608 7634
7609 GLenum src_sized_format = 7635 GLenum src_sized_format =
7610 GLES2Util::ConvertToSizedFormat(src_format, src_type); 7636 GLES2Util::ConvertToSizedFormat(src_internal_format, src_type);
7611 const Framebuffer::Attachment* read_buffer = 7637 const Framebuffer::Attachment* read_buffer =
7612 is_feedback_loop == FeedbackLoopUnknown ? 7638 is_feedback_loop == FeedbackLoopUnknown ?
7613 read_framebuffer->GetReadBufferAttachment() : nullptr; 7639 read_framebuffer->GetReadBufferAttachment() : nullptr;
7614 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) { 7640 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) {
7615 GLenum dst_format = GetBoundColorDrawBufferInternalFormat( 7641 GLenum dst_format = GetBoundColorDrawBufferInternalFormat(
7616 static_cast<GLint>(ii)); 7642 static_cast<GLint>(ii));
7617 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii)); 7643 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii));
7618 if (dst_format == 0) 7644 if (dst_format == 0)
7619 continue; 7645 continue;
7646 if (GetColorEncodingFromInternalFormat(dst_format) == GL_SRGB)
7647 draw_buffers_has_srgb = true;
7620 if (read_buffer_samples > 0 && 7648 if (read_buffer_samples > 0 &&
7621 (src_sized_format != 7649 (src_sized_format !=
7622 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) { 7650 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) {
7623 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 7651 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
7624 "src and dst formats differ for color"); 7652 "src and dst formats differ for color");
7625 return; 7653 return;
7626 } 7654 }
7627 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format); 7655 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format);
7628 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format); 7656 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format);
7629 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int); 7657 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
7664 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) != 7692 if ((GetBoundFramebufferDepthFormat(GL_READ_FRAMEBUFFER) !=
7665 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || 7693 GetBoundFramebufferDepthFormat(GL_DRAW_FRAMEBUFFER)) ||
7666 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) != 7694 (GetBoundFramebufferStencilFormat(GL_READ_FRAMEBUFFER) !=
7667 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { 7695 GetBoundFramebufferStencilFormat(GL_DRAW_FRAMEBUFFER))) {
7668 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, 7696 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name,
7669 "src and dst formats differ for depth/stencil"); 7697 "src and dst formats differ for depth/stencil");
7670 return; 7698 return;
7671 } 7699 }
7672 } 7700 }
7673 7701
7674 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); 7702 bool enable_srgb =
7675 BlitFramebufferHelper( 7703 (read_buffer_has_srgb || draw_buffers_has_srgb) &&
7676 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); 7704 ((mask & GL_COLOR_BUFFER_BIT) != 0);
7677 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, 7705 bool encode_srgb_only =
7706 (draw_buffers_has_srgb && !read_buffer_has_srgb) &&
7707 ((mask & GL_COLOR_BUFFER_BIT) != 0);
7708 if (!enable_srgb ||
7709 !feature_info_->feature_flags().desktop_srgb_support ||
7710 gl_version_info().IsAtLeastGL(4, 4) ||
7711 (gl_version_info().IsAtLeastGL(4, 2) && encode_srgb_only)) {
7712 if (enable_srgb && gl_version_info().IsAtLeastGL(4, 2)) {
7713 state_.EnableDisableFramebufferSRGB(enable_srgb);
7714 }
7715
7716 // TODO(yunchao) Need to revisit here. In GLES spec, blitFramebuffer
7717 // should do scissor test per fragment operation.
7718 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false);
7719 BlitFramebufferHelper(
7720 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
7721 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST,
7678 state_.enable_flags.scissor_test); 7722 state_.enable_flags.scissor_test);
7723 return;
7724 }
7725
7726 // emulate srgb for desktop core profile when GL version < 4.4
7727 // TODO(yunchao): Need to handle this situation:
7728 // There are multiple draw buffers. Some of them are srgb images.
7729 // The others are not.
7730 state_.EnableDisableFramebufferSRGB(true);
7731 if (read_buffer_has_srgb && !draw_buffers_has_srgb) {
7732 if (!InitializeSRGBDecoder(func_name)) {
7733 return;
7734 }
7735 srgb_converter_->SRGBToLinear(this, srcX0, srcY0, srcX1, srcY1,
7736 dstX0, dstY0, dstX1, dstY1,
7737 mask, filter,
7738 GetBoundReadFramebufferSize(),
7739 GetBoundReadFramebufferServiceId(),
7740 src_internal_format,
7741 GetBoundDrawFramebufferServiceId());
7742 }
7743
7744 if (draw_buffers_has_srgb && !read_buffer_has_srgb) {
7745 if (!InitializeSRGBEncoder(func_name)) {
7746 return;
7747 }
7748 GLenum src_format =
7749 TextureManager::ExtractFormatFromStorageFormat(src_internal_format);
7750 srgb_converter_->LinearToSRGB(this, srcX0, srcY0, srcX1, srcY1,
7751 dstX0, dstY0, dstX1, dstY1,
7752 mask, filter,
7753 GetBoundReadFramebufferServiceId(),
7754 src_internal_format, src_format, src_type,
7755 GetBoundDrawFramebufferServiceId());
7756 }
7757
7758 if (read_buffer_has_srgb && draw_buffers_has_srgb) {
7759 if (!InitializeSRGBDecoder(func_name) ||
7760 !InitializeSRGBEncoder(func_name)) {
7761 return;
7762 }
7763 srgb_converter_->SRGBToSRGB(this, srcX0, srcY0, srcX1, srcY1,
7764 dstX0, dstY0, dstX1, dstY1,
7765 mask, filter,
7766 GetBoundReadFramebufferSize(),
7767 GetBoundReadFramebufferServiceId(),
7768 src_internal_format,
7769 GetBoundDrawFramebufferServiceId());
7770 }
7771 }
7772
7773 bool GLES2DecoderImpl::InitializeSRGBDecoder(
7774 const char* function_name) {
7775 if (!srgb_converter_.get()) {
7776 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name);
7777 srgb_converter_.reset(
7778 new SRGBConverter(feature_info_.get()));
7779 }
7780 srgb_converter_->InitializeSRGBDecoder(this);
7781 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) {
7782 return false;
7783 }
7784 return true;
7785 }
7786
7787 bool GLES2DecoderImpl::InitializeSRGBEncoder(
7788 const char* function_name) {
7789 if (!srgb_converter_.get()) {
7790 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER(function_name);
7791 srgb_converter_.reset(
7792 new SRGBConverter(feature_info_.get()));
7793 }
7794 srgb_converter_->InitializeSRGBEncoder(this);
7795 if (LOCAL_PEEK_GL_ERROR(function_name) != GL_NO_ERROR) {
7796 return false;
7797 }
7798 return true;
7679 } 7799 }
7680 7800
7681 void GLES2DecoderImpl::EnsureRenderbufferBound() { 7801 void GLES2DecoderImpl::EnsureRenderbufferBound() {
7682 if (!state_.bound_renderbuffer_valid) { 7802 if (!state_.bound_renderbuffer_valid) {
7683 state_.bound_renderbuffer_valid = true; 7803 state_.bound_renderbuffer_valid = true;
7684 glBindRenderbufferEXT(GL_RENDERBUFFER, 7804 glBindRenderbufferEXT(GL_RENDERBUFFER,
7685 state_.bound_renderbuffer.get() 7805 state_.bound_renderbuffer.get()
7686 ? state_.bound_renderbuffer->service_id() 7806 ? state_.bound_renderbuffer->service_id()
7687 : 0); 7807 : 0);
7688 } 7808 }
(...skipping 10286 matching lines...) Expand 10 before | Expand all | Expand 10 after
17975 } 18095 }
17976 18096
17977 // Include the auto-generated part of this file. We split this because it means 18097 // Include the auto-generated part of this file. We split this because it means
17978 // we can easily edit the non-auto generated parts right here in this file 18098 // we can easily edit the non-auto generated parts right here in this file
17979 // instead of having to edit some template or the code generator. 18099 // instead of having to edit some template or the code generator.
17980 #include "base/macros.h" 18100 #include "base/macros.h"
17981 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 18101 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
17982 18102
17983 } // namespace gles2 18103 } // namespace gles2
17984 } // namespace gpu 18104 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698