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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 1403483002: Update CopyTexImage2D to do internal format validation in ES3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unused function Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index a555557a96e6859dde37b5d94e1558de7b50f297..72c6fa1ab02b10f8cf1871980357fa0d101786cf 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -1567,6 +1567,9 @@ class GLES2DecoderImpl : public GLES2Decoder,
// attached. Generates GL error if not.
bool CheckBoundReadFramebufferColorAttachment(const char* func_name);
+ // Infer color encoding from internalformat
+ static GLint GetColorEncodingFromInternalFormat(GLenum internalformat);
+
// Check that the currently bound read framebuffer's color image
// isn't the target texture of the glCopyTex{Sub}Image2D.
bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level);
@@ -4019,6 +4022,19 @@ bool GLES2DecoderImpl::CheckBoundReadFramebufferColorAttachment(
return true;
}
+GLint GLES2DecoderImpl::GetColorEncodingFromInternalFormat(
+ GLenum internalformat) {
+ switch (internalformat) {
+ case GL_SRGB_EXT:
+ case GL_SRGB_ALPHA_EXT:
+ case GL_SRGB8:
+ case GL_SRGB8_ALPHA8:
+ return GL_SRGB;
+ default:
+ return GL_LINEAR;
+ }
+}
+
bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop(
TextureRef* texture, GLint level) {
Framebuffer* framebuffer = features().chromium_framebuffer_multisample ?
@@ -11003,6 +11019,20 @@ void GLES2DecoderImpl::DoCopyTexImage2D(
return;
}
+ if (feature_info_->IsES3Enabled()) {
+ GLint color_encoding = GetColorEncodingFromInternalFormat(read_format);
+ if (color_encoding != GetColorEncodingFromInternalFormat(internal_format) ||
+ GLES2Util::IsFloatFormat(internal_format) ||
+ (GLES2Util::IsSignedIntegerFormat(internal_format) !=
+ GLES2Util::IsSignedIntegerFormat(read_format)) ||
+ (GLES2Util::IsUnsignedIntegerFormat(internal_format) !=
+ GLES2Util::IsUnsignedIntegerFormat(read_format))) {
+ LOCAL_SET_GL_ERROR(
+ GL_INVALID_OPERATION, "glCopyTexImage2D", "incompatible format");
+ return;
+ }
+ }
+
if ((channels_needed & (GLES2Util::kDepth | GLES2Util::kStencil)) != 0) {
LOCAL_SET_GL_ERROR(
GL_INVALID_OPERATION,
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.cc ('k') | gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698