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

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: fix comments#4 and #5 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..a5d69b0f8be98d6d8eedaec67ac2cb39593a52bc 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -1567,6 +1567,13 @@ class GLES2DecoderImpl : public GLES2Decoder,
// attached. Generates GL error if not.
bool CheckBoundReadFramebufferColorAttachment(const char* func_name);
+ // Infer color encoding from internalformat
+ GLint GetColorEncodingFromInternalFormat(GLenum internalformat);
Zhenyao Mo 2015/10/13 17:00:23 Make it static.
qiankun 2015/10/13 23:54:07 Done.
+
+ // Get the value of GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING for the
+ // framebuffer attachment corresponding to the read buffer.
+ GLint GetReadFramebufferAttachmentColorEncoding();
+
// 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 +4026,29 @@ 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;
+ }
+}
+
+GLint GLES2DecoderImpl::GetReadFramebufferAttachmentColorEncoding() {
+ GLenum target = features().chromium_framebuffer_multisample ?
+ GL_READ_FRAMEBUFFER_EXT : GL_FRAMEBUFFER_EXT;
+ GLint v = GL_NONE;
+ glGetFramebufferAttachmentParameterivEXT(
+ target, GL_COLOR_ATTACHMENT0,
+ GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, &v);
+ return v;
+}
+
bool GLES2DecoderImpl::FormsTextureCopyingFeedbackLoop(
TextureRef* texture, GLint level) {
Framebuffer* framebuffer = features().chromium_framebuffer_multisample ?
@@ -11003,6 +11033,20 @@ void GLES2DecoderImpl::DoCopyTexImage2D(
return;
}
+ if (feature_info_->IsES3Enabled()) {
+ GLint color_encoding = GetReadFramebufferAttachmentColorEncoding();
Zhenyao Mo 2015/10/13 17:00:24 Here you don't need the GetReadFramebufferAttachme
qiankun 2015/10/13 23:54:07 Done.
Zhenyao Mo 2015/10/14 18:39:20 Then please get rid of the GetReadFramebufferAttac
+ 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