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 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1352 GLenum gl_error, | 1352 GLenum gl_error, |
| 1353 const char* func_name); | 1353 const char* func_name); |
| 1354 | 1354 |
| 1355 bool CheckBoundDrawFramebufferValid(const char* func_name); | 1355 bool CheckBoundDrawFramebufferValid(const char* func_name); |
| 1356 // Generates |gl_error| if the bound read fbo is incomplete. | 1356 // Generates |gl_error| if the bound read fbo is incomplete. |
| 1357 bool CheckBoundReadFramebufferValid(const char* func_name, GLenum gl_error); | 1357 bool CheckBoundReadFramebufferValid(const char* func_name, GLenum gl_error); |
| 1358 // This is only used by DoBlitFramebufferCHROMIUM which operates read/draw | 1358 // This is only used by DoBlitFramebufferCHROMIUM which operates read/draw |
| 1359 // framebuffer at the same time. | 1359 // framebuffer at the same time. |
| 1360 bool CheckBoundFramebufferValid(const char* func_name); | 1360 bool CheckBoundFramebufferValid(const char* func_name); |
| 1361 | 1361 |
| 1362 // If one or more drawBuffers have srgb color format, enable framebuffer srgb. | |
| 1363 // Otherwise, disable framebuffer srgb. | |
| 1364 void EnableDisableFramebufferSRGBForDrawBuffers(); | |
| 1365 | |
| 1362 // Checks if the current program exists and is valid. If not generates the | 1366 // Checks if the current program exists and is valid. If not generates the |
| 1363 // appropriate GL error. Returns true if the current program is in a usable | 1367 // appropriate GL error. Returns true if the current program is in a usable |
| 1364 // state. | 1368 // state. |
| 1365 bool CheckCurrentProgram(const char* function_name); | 1369 bool CheckCurrentProgram(const char* function_name); |
| 1366 | 1370 |
| 1367 // Checks if the current program exists and is valid and that location is not | 1371 // Checks if the current program exists and is valid and that location is not |
| 1368 // -1. If the current program is not valid generates the appropriate GL | 1372 // -1. If the current program is not valid generates the appropriate GL |
| 1369 // error. Returns true if the current program is in a usable state and | 1373 // error. Returns true if the current program is in a usable state and |
| 1370 // location is not -1. | 1374 // location is not -1. |
| 1371 bool CheckCurrentProgramForUniform(GLint location, const char* function_name); | 1375 bool CheckCurrentProgramForUniform(GLint location, const char* function_name); |
| (...skipping 2805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4177 } | 4181 } |
| 4178 | 4182 |
| 4179 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid(const char* func_name) { | 4183 bool GLES2DecoderImpl::CheckBoundDrawFramebufferValid(const char* func_name) { |
| 4180 GLenum target = features().chromium_framebuffer_multisample ? | 4184 GLenum target = features().chromium_framebuffer_multisample ? |
| 4181 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; | 4185 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; |
| 4182 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 4186 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
| 4183 bool valid = CheckFramebufferValid( | 4187 bool valid = CheckFramebufferValid( |
| 4184 framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); | 4188 framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); |
| 4185 if (valid && !features().chromium_framebuffer_multisample) | 4189 if (valid && !features().chromium_framebuffer_multisample) |
| 4186 OnUseFramebuffer(); | 4190 OnUseFramebuffer(); |
| 4187 if (valid && feature_info_->feature_flags().desktop_srgb_support) { | |
| 4188 // If framebuffer contains sRGB images, then enable FRAMEBUFFER_SRGB. | |
| 4189 // Otherwise, disable FRAMEBUFFER_SRGB. Assume default fbo does not have | |
| 4190 // sRGB image. | |
| 4191 // In theory, we can just leave FRAMEBUFFER_SRGB on. However, many drivers | |
| 4192 // behave incorrectly when all images are linear encoding, they still apply | |
| 4193 // the sRGB conversion, but when at least one image is sRGB, then they | |
| 4194 // behave correctly. | |
| 4195 bool enable_framebuffer_srgb = | |
| 4196 framebuffer && framebuffer->HasSRGBAttachments(); | |
|
yunchao
2016/08/24 14:08:51
This is not correct. If the fbo has srgb color buf
Zhenyao Mo
2016/08/25 00:39:37
What we found is whether the sRGB image is current
yunchao
2016/08/25 16:29:51
That's true. It can draw correctly if there is sRG
| |
| 4197 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); | |
| 4198 } | |
| 4199 return valid; | 4191 return valid; |
| 4200 } | 4192 } |
| 4201 | 4193 |
| 4202 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid( | 4194 bool GLES2DecoderImpl::CheckBoundReadFramebufferValid( |
| 4203 const char* func_name, GLenum gl_error) { | 4195 const char* func_name, GLenum gl_error) { |
| 4204 GLenum target = features().chromium_framebuffer_multisample ? | 4196 GLenum target = features().chromium_framebuffer_multisample ? |
| 4205 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; | 4197 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; |
| 4206 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); | 4198 Framebuffer* framebuffer = GetFramebufferInfoForTarget(target); |
| 4207 bool valid = CheckFramebufferValid( | 4199 bool valid = CheckFramebufferValid( |
| 4208 framebuffer, target, gl_error, func_name); | 4200 framebuffer, target, gl_error, func_name); |
| 4209 return valid; | 4201 return valid; |
| 4210 } | 4202 } |
| 4211 | 4203 |
| 4212 bool GLES2DecoderImpl::CheckBoundFramebufferValid(const char* func_name) { | 4204 bool GLES2DecoderImpl::CheckBoundFramebufferValid(const char* func_name) { |
| 4213 GLenum target = features().chromium_framebuffer_multisample ? | 4205 GLenum target = features().chromium_framebuffer_multisample ? |
| 4214 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; | 4206 GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER; |
| 4215 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target); | 4207 Framebuffer* draw_framebuffer = GetFramebufferInfoForTarget(target); |
| 4216 bool valid = CheckFramebufferValid( | 4208 bool valid = CheckFramebufferValid( |
| 4217 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); | 4209 draw_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); |
| 4218 | 4210 |
| 4219 target = features().chromium_framebuffer_multisample ? | 4211 target = features().chromium_framebuffer_multisample ? |
| 4220 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; | 4212 GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER; |
| 4221 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target); | 4213 Framebuffer* read_framebuffer = GetFramebufferInfoForTarget(target); |
| 4222 valid = valid && CheckFramebufferValid( | 4214 valid = valid && CheckFramebufferValid( |
| 4223 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); | 4215 read_framebuffer, target, GL_INVALID_FRAMEBUFFER_OPERATION, func_name); |
| 4224 | |
| 4225 if (valid && feature_info_->feature_flags().desktop_srgb_support) { | |
| 4226 bool enable_framebuffer_srgb = | |
| 4227 (draw_framebuffer && draw_framebuffer->HasSRGBAttachments()) || | |
| 4228 (read_framebuffer && read_framebuffer->HasSRGBAttachments()); | |
|
yunchao
2016/08/24 14:08:51
The same reason. If the fbo has srgb color buffer,
| |
| 4229 state_.EnableDisableFramebufferSRGB(enable_framebuffer_srgb); | |
| 4230 } | |
| 4231 | |
| 4232 return valid; | 4216 return valid; |
| 4233 } | 4217 } |
| 4234 | 4218 |
| 4219 void GLES2DecoderImpl::EnableDisableFramebufferSRGBForDrawBuffers() { | |
| 4220 bool draw_buffers_has_srgb = false; | |
| 4221 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) { | |
| 4222 GLenum dst_format = GetBoundColorDrawBufferInternalFormat( | |
| 4223 static_cast<GLint>(ii)); | |
| 4224 if (dst_format == 0) | |
| 4225 continue; | |
| 4226 if (GetColorEncodingFromInternalFormat(dst_format) == GL_SRGB) { | |
| 4227 draw_buffers_has_srgb = true; | |
| 4228 break; | |
| 4229 } | |
| 4230 } | |
| 4231 state_.EnableDisableFramebufferSRGB(draw_buffers_has_srgb); | |
| 4232 } | |
| 4233 | |
| 4235 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( | 4234 GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat( |
| 4236 GLenum internalformat) { | 4235 GLenum internalformat) { |
| 4237 switch (internalformat) { | 4236 switch (internalformat) { |
| 4238 case GL_SRGB_EXT: | 4237 case GL_SRGB_EXT: |
| 4239 case GL_SRGB_ALPHA_EXT: | 4238 case GL_SRGB_ALPHA_EXT: |
| 4240 case GL_SRGB8: | 4239 case GL_SRGB8: |
| 4241 case GL_SRGB8_ALPHA8: | 4240 case GL_SRGB8_ALPHA8: |
| 4242 return GL_SRGB; | 4241 return GL_SRGB; |
| 4243 default: | 4242 default: |
| 4244 return GL_LINEAR; | 4243 return GL_LINEAR; |
| (...skipping 2662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6907 return error::kNoError; | 6906 return error::kNoError; |
| 6908 } | 6907 } |
| 6909 if (mask & GL_COLOR_BUFFER_BIT) { | 6908 if (mask & GL_COLOR_BUFFER_BIT) { |
| 6910 Framebuffer* framebuffer = | 6909 Framebuffer* framebuffer = |
| 6911 framebuffer_state_.bound_draw_framebuffer.get(); | 6910 framebuffer_state_.bound_draw_framebuffer.get(); |
| 6912 if (framebuffer && framebuffer->ContainsActiveIntegerAttachments()) { | 6911 if (framebuffer && framebuffer->ContainsActiveIntegerAttachments()) { |
| 6913 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 6912 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 6914 "can't be called on integer buffers"); | 6913 "can't be called on integer buffers"); |
| 6915 return error::kNoError; | 6914 return error::kNoError; |
| 6916 } | 6915 } |
| 6916 if (feature_info_->feature_flags().desktop_srgb_support) { | |
| 6917 EnableDisableFramebufferSRGBForDrawBuffers(); | |
| 6918 } | |
| 6917 } | 6919 } |
| 6918 glClear(mask); | 6920 glClear(mask); |
| 6919 } | 6921 } |
| 6920 return error::kNoError; | 6922 return error::kNoError; |
| 6921 } | 6923 } |
| 6922 | 6924 |
| 6923 void GLES2DecoderImpl::DoClearBufferiv( | 6925 void GLES2DecoderImpl::DoClearBufferiv( |
| 6924 GLenum buffer, GLint drawbuffer, const GLint* value) { | 6926 GLenum buffer, GLint drawbuffer, const GLint* value) { |
| 6925 const char* func_name = "glClearBufferiv"; | 6927 const char* func_name = "glClearBufferiv"; |
| 6926 if (!CheckBoundDrawFramebufferValid(func_name)) | 6928 if (!CheckBoundDrawFramebufferValid(func_name)) |
| 6927 return; | 6929 return; |
| 6928 ApplyDirtyState(); | 6930 ApplyDirtyState(); |
| 6929 | 6931 |
| 6930 if (buffer == GL_COLOR) { | 6932 if (buffer == GL_COLOR) { |
| 6931 if (drawbuffer < 0 || | 6933 if (drawbuffer < 0 || |
| 6932 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { | 6934 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { |
| 6933 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); | 6935 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); |
| 6934 return; | 6936 return; |
| 6935 } | 6937 } |
| 6936 GLenum internal_format = | 6938 GLenum internal_format = |
| 6937 GetBoundColorDrawBufferInternalFormat(drawbuffer); | 6939 GetBoundColorDrawBufferInternalFormat(drawbuffer); |
| 6938 if (!GLES2Util::IsSignedIntegerFormat(internal_format)) { | 6940 if (!GLES2Util::IsSignedIntegerFormat(internal_format)) { |
| 6939 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 6941 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 6940 "can only be called on signed integer buffers"); | 6942 "can only be called on signed integer buffers"); |
| 6941 return; | 6943 return; |
| 6942 } | 6944 } |
| 6945 if (feature_info_->feature_flags().desktop_srgb_support) { | |
| 6946 bool draw_buffer_has_srgb = | |
| 6947 GetColorEncodingFromInternalFormat(internal_format) == GL_SRGB; | |
| 6948 state_.EnableDisableFramebufferSRGB(draw_buffer_has_srgb); | |
| 6949 } | |
| 6943 } else { | 6950 } else { |
| 6944 DCHECK(buffer == GL_STENCIL); | 6951 DCHECK(buffer == GL_STENCIL); |
| 6945 if (drawbuffer != 0) { | 6952 if (drawbuffer != 0) { |
| 6946 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); | 6953 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); |
| 6947 return; | 6954 return; |
| 6948 } | 6955 } |
| 6949 if (!BoundFramebufferHasStencilAttachment()) { | 6956 if (!BoundFramebufferHasStencilAttachment()) { |
| 6950 return; | 6957 return; |
| 6951 } | 6958 } |
| 6952 } | 6959 } |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 6966 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); | 6973 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); |
| 6967 return; | 6974 return; |
| 6968 } | 6975 } |
| 6969 GLenum internal_format = | 6976 GLenum internal_format = |
| 6970 GetBoundColorDrawBufferInternalFormat(drawbuffer); | 6977 GetBoundColorDrawBufferInternalFormat(drawbuffer); |
| 6971 if (!GLES2Util::IsUnsignedIntegerFormat(internal_format)) { | 6978 if (!GLES2Util::IsUnsignedIntegerFormat(internal_format)) { |
| 6972 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 6979 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 6973 "can only be called on unsigned integer buffers"); | 6980 "can only be called on unsigned integer buffers"); |
| 6974 return; | 6981 return; |
| 6975 } | 6982 } |
| 6983 if (feature_info_->feature_flags().desktop_srgb_support) { | |
| 6984 bool draw_buffer_has_srgb = | |
| 6985 GetColorEncodingFromInternalFormat(internal_format) == GL_SRGB; | |
| 6986 state_.EnableDisableFramebufferSRGB(draw_buffer_has_srgb); | |
| 6987 } | |
| 6976 MarkDrawBufferAsCleared(buffer, drawbuffer); | 6988 MarkDrawBufferAsCleared(buffer, drawbuffer); |
| 6977 glClearBufferuiv(buffer, drawbuffer, value); | 6989 glClearBufferuiv(buffer, drawbuffer, value); |
| 6978 } | 6990 } |
| 6979 | 6991 |
| 6980 void GLES2DecoderImpl::DoClearBufferfv( | 6992 void GLES2DecoderImpl::DoClearBufferfv( |
| 6981 GLenum buffer, GLint drawbuffer, const GLfloat* value) { | 6993 GLenum buffer, GLint drawbuffer, const GLfloat* value) { |
| 6982 const char* func_name = "glClearBufferfv"; | 6994 const char* func_name = "glClearBufferfv"; |
| 6983 if (!CheckBoundDrawFramebufferValid(func_name)) | 6995 if (!CheckBoundDrawFramebufferValid(func_name)) |
| 6984 return; | 6996 return; |
| 6985 ApplyDirtyState(); | 6997 ApplyDirtyState(); |
| 6986 | 6998 |
| 6987 if (buffer == GL_COLOR) { | 6999 if (buffer == GL_COLOR) { |
| 6988 if (drawbuffer < 0 || | 7000 if (drawbuffer < 0 || |
| 6989 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { | 7001 drawbuffer >= static_cast<GLint>(group_->max_draw_buffers())) { |
| 6990 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); | 7002 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); |
| 6991 return; | 7003 return; |
| 6992 } | 7004 } |
| 6993 GLenum internal_format = | 7005 GLenum internal_format = |
| 6994 GetBoundColorDrawBufferInternalFormat(drawbuffer); | 7006 GetBoundColorDrawBufferInternalFormat(drawbuffer); |
| 6995 if (GLES2Util::IsIntegerFormat(internal_format)) { | 7007 if (GLES2Util::IsIntegerFormat(internal_format)) { |
| 6996 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7008 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 6997 "can only be called on float buffers"); | 7009 "can only be called on float buffers"); |
| 6998 return; | 7010 return; |
| 6999 } | 7011 } |
| 7012 if (feature_info_->feature_flags().desktop_srgb_support) { | |
| 7013 bool draw_buffer_has_srgb = | |
| 7014 GetColorEncodingFromInternalFormat(internal_format) == GL_SRGB; | |
| 7015 state_.EnableDisableFramebufferSRGB(draw_buffer_has_srgb); | |
| 7016 } | |
| 7000 } else { | 7017 } else { |
| 7001 DCHECK(buffer == GL_DEPTH); | 7018 DCHECK(buffer == GL_DEPTH); |
| 7002 if (drawbuffer != 0) { | 7019 if (drawbuffer != 0) { |
| 7003 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); | 7020 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, func_name, "invalid drawBuffer"); |
| 7004 return; | 7021 return; |
| 7005 } | 7022 } |
| 7006 if (!BoundFramebufferHasDepthAttachment()) { | 7023 if (!BoundFramebufferHasDepthAttachment()) { |
| 7007 return; | 7024 return; |
| 7008 } | 7025 } |
| 7009 } | 7026 } |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7504 if (read_buffer_samples > 0 && | 7521 if (read_buffer_samples > 0 && |
| 7505 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) { | 7522 (srcX0 != dstX0 || srcY0 != dstY0 || srcX1 != dstX1 || srcY1 != dstY1)) { |
| 7506 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7523 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7507 "src framebuffer is multisampled, but src/dst regions are different"); | 7524 "src framebuffer is multisampled, but src/dst regions are different"); |
| 7508 return; | 7525 return; |
| 7509 } | 7526 } |
| 7510 | 7527 |
| 7511 GLenum src_format = GetBoundReadFrameBufferInternalFormat(); | 7528 GLenum src_format = GetBoundReadFrameBufferInternalFormat(); |
| 7512 GLenum src_type = GetBoundReadFrameBufferTextureType(); | 7529 GLenum src_type = GetBoundReadFrameBufferTextureType(); |
| 7513 | 7530 |
| 7531 bool read_buffer_has_srgb = | |
| 7532 GetColorEncodingFromInternalFormat(src_format) == GL_SRGB; | |
| 7533 bool draw_buffers_has_srgb = false; | |
| 7514 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { | 7534 if ((mask & GL_COLOR_BUFFER_BIT) != 0) { |
| 7515 bool is_src_signed_int = GLES2Util::IsSignedIntegerFormat(src_format); | 7535 bool is_src_signed_int = GLES2Util::IsSignedIntegerFormat(src_format); |
| 7516 bool is_src_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(src_format); | 7536 bool is_src_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(src_format); |
| 7517 DCHECK(!is_src_signed_int || !is_src_unsigned_int); | 7537 DCHECK(!is_src_signed_int || !is_src_unsigned_int); |
| 7518 | 7538 |
| 7519 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) { | 7539 if ((is_src_signed_int || is_src_unsigned_int) && filter == GL_LINEAR) { |
| 7520 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7540 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7521 "invalid filter for integer format"); | 7541 "invalid filter for integer format"); |
| 7522 return; | 7542 return; |
| 7523 } | 7543 } |
| 7524 | 7544 |
| 7525 GLenum src_sized_format = | 7545 GLenum src_sized_format = |
| 7526 GLES2Util::ConvertToSizedFormat(src_format, src_type); | 7546 GLES2Util::ConvertToSizedFormat(src_format, src_type); |
| 7527 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) { | 7547 for (uint32_t ii = 0; ii < group_->max_draw_buffers(); ++ii) { |
| 7528 GLenum dst_format = GetBoundColorDrawBufferInternalFormat( | 7548 GLenum dst_format = GetBoundColorDrawBufferInternalFormat( |
| 7529 static_cast<GLint>(ii)); | 7549 static_cast<GLint>(ii)); |
| 7530 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii)); | 7550 GLenum dst_type = GetBoundColorDrawBufferType(static_cast<GLint>(ii)); |
| 7531 if (dst_format == 0) | 7551 if (dst_format == 0) |
| 7532 continue; | 7552 continue; |
| 7553 if (GetColorEncodingFromInternalFormat(dst_format) == GL_SRGB) | |
| 7554 draw_buffers_has_srgb = true; | |
| 7533 if (read_buffer_samples > 0 && | 7555 if (read_buffer_samples > 0 && |
| 7534 (src_sized_format != | 7556 (src_sized_format != |
| 7535 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) { | 7557 GLES2Util::ConvertToSizedFormat(dst_format, dst_type))) { |
| 7536 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7558 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7537 "src and dst formats differ for color"); | 7559 "src and dst formats differ for color"); |
| 7538 return; | 7560 return; |
| 7539 } | 7561 } |
| 7540 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format); | 7562 bool is_dst_signed_int = GLES2Util::IsSignedIntegerFormat(dst_format); |
| 7541 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format); | 7563 bool is_dst_unsigned_int = GLES2Util::IsUnsignedIntegerFormat(dst_format); |
| 7542 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int); | 7564 DCHECK(!is_dst_signed_int || !is_dst_unsigned_int); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 7559 if ((GetBoundFrameBufferDepthFormat(GL_READ_FRAMEBUFFER) != | 7581 if ((GetBoundFrameBufferDepthFormat(GL_READ_FRAMEBUFFER) != |
| 7560 GetBoundFrameBufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || | 7582 GetBoundFrameBufferDepthFormat(GL_DRAW_FRAMEBUFFER)) || |
| 7561 (GetBoundFrameBufferStencilFormat(GL_READ_FRAMEBUFFER) != | 7583 (GetBoundFrameBufferStencilFormat(GL_READ_FRAMEBUFFER) != |
| 7562 GetBoundFrameBufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { | 7584 GetBoundFrameBufferStencilFormat(GL_DRAW_FRAMEBUFFER))) { |
| 7563 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, | 7585 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, func_name, |
| 7564 "src and dst formats differ for depth/stencil"); | 7586 "src and dst formats differ for depth/stencil"); |
| 7565 return; | 7587 return; |
| 7566 } | 7588 } |
| 7567 } | 7589 } |
| 7568 | 7590 |
| 7591 if (feature_info_->feature_flags().desktop_srgb_support) { | |
| 7592 bool enable_srgb = read_buffer_has_srgb || draw_buffers_has_srgb; | |
| 7593 state_.EnableDisableFramebufferSRGB(enable_srgb); | |
| 7594 } | |
| 7595 | |
| 7569 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); | 7596 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, false); |
| 7570 BlitFramebufferHelper( | 7597 BlitFramebufferHelper( |
| 7571 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); | 7598 srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); |
| 7572 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, | 7599 state_.SetDeviceCapabilityState(GL_SCISSOR_TEST, |
| 7573 state_.enable_flags.scissor_test); | 7600 state_.enable_flags.scissor_test); |
| 7574 } | 7601 } |
| 7575 | 7602 |
| 7576 void GLES2DecoderImpl::EnsureRenderbufferBound() { | 7603 void GLES2DecoderImpl::EnsureRenderbufferBound() { |
| 7577 if (!state_.bound_renderbuffer_valid) { | 7604 if (!state_.bound_renderbuffer_valid) { |
| 7578 state_.bound_renderbuffer_valid = true; | 7605 state_.bound_renderbuffer_valid = true; |
| (...skipping 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9187 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "count < 0"); | 9214 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "count < 0"); |
| 9188 return error::kNoError; | 9215 return error::kNoError; |
| 9189 } | 9216 } |
| 9190 if (primcount < 0) { | 9217 if (primcount < 0) { |
| 9191 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "primcount < 0"); | 9218 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "primcount < 0"); |
| 9192 return error::kNoError; | 9219 return error::kNoError; |
| 9193 } | 9220 } |
| 9194 if (!CheckBoundDrawFramebufferValid(function_name)) { | 9221 if (!CheckBoundDrawFramebufferValid(function_name)) { |
| 9195 return error::kNoError; | 9222 return error::kNoError; |
| 9196 } | 9223 } |
| 9224 | |
| 9225 if (feature_info_->feature_flags().desktop_srgb_support) { | |
| 9226 EnableDisableFramebufferSRGBForDrawBuffers(); | |
| 9227 } | |
| 9228 | |
| 9197 // We have to check this here because the prototype for glDrawArrays | 9229 // We have to check this here because the prototype for glDrawArrays |
| 9198 // is GLint not GLsizei. | 9230 // is GLint not GLsizei. |
| 9199 if (first < 0) { | 9231 if (first < 0) { |
| 9200 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "first < 0"); | 9232 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "first < 0"); |
| 9201 return error::kNoError; | 9233 return error::kNoError; |
| 9202 } | 9234 } |
| 9203 | 9235 |
| 9204 if (state_.bound_transform_feedback.get() && | 9236 if (state_.bound_transform_feedback.get() && |
| 9205 state_.bound_transform_feedback->active() && | 9237 state_.bound_transform_feedback->active() && |
| 9206 !state_.bound_transform_feedback->paused() && | 9238 !state_.bound_transform_feedback->paused() && |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9328 } | 9360 } |
| 9329 if (primcount < 0) { | 9361 if (primcount < 0) { |
| 9330 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "primcount < 0"); | 9362 LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "primcount < 0"); |
| 9331 return error::kNoError; | 9363 return error::kNoError; |
| 9332 } | 9364 } |
| 9333 | 9365 |
| 9334 if (!CheckBoundDrawFramebufferValid(function_name)) { | 9366 if (!CheckBoundDrawFramebufferValid(function_name)) { |
| 9335 return error::kNoError; | 9367 return error::kNoError; |
| 9336 } | 9368 } |
| 9337 | 9369 |
| 9370 if (feature_info_->feature_flags().desktop_srgb_support) { | |
| 9371 EnableDisableFramebufferSRGBForDrawBuffers(); | |
| 9372 } | |
| 9373 | |
| 9338 if (state_.bound_transform_feedback.get() && | 9374 if (state_.bound_transform_feedback.get() && |
| 9339 state_.bound_transform_feedback->active() && | 9375 state_.bound_transform_feedback->active() && |
| 9340 !state_.bound_transform_feedback->paused()) { | 9376 !state_.bound_transform_feedback->paused()) { |
| 9341 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, | 9377 LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, function_name, |
| 9342 "transformfeedback is active and not paused"); | 9378 "transformfeedback is active and not paused"); |
| 9343 return error::kNoError; | 9379 return error::kNoError; |
| 9344 } | 9380 } |
| 9345 | 9381 |
| 9346 if (count == 0 || primcount == 0) { | 9382 if (count == 0 || primcount == 0) { |
| 9347 return error::kNoError; | 9383 return error::kNoError; |
| (...skipping 8365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 17713 } | 17749 } |
| 17714 | 17750 |
| 17715 // Include the auto-generated part of this file. We split this because it means | 17751 // Include the auto-generated part of this file. We split this because it means |
| 17716 // we can easily edit the non-auto generated parts right here in this file | 17752 // we can easily edit the non-auto generated parts right here in this file |
| 17717 // instead of having to edit some template or the code generator. | 17753 // instead of having to edit some template or the code generator. |
| 17718 #include "base/macros.h" | 17754 #include "base/macros.h" |
| 17719 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 17755 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 17720 | 17756 |
| 17721 } // namespace gles2 | 17757 } // namespace gles2 |
| 17722 } // namespace gpu | 17758 } // namespace gpu |
| OLD | NEW |