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

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

Issue 1929203003: Revert of Fix ReadPixels from float fbo buffer in ES2/WebGL1. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2daf0623ffcdf37c18e95718fa24787f7dda09da..33b32821ac94495ba062e86fc657e0870b4bc0b2 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -1283,18 +1283,15 @@
bool FormsTextureCopyingFeedbackLoop(TextureRef* texture, GLint level);
// Check if a framebuffer meets our requirements.
- // Generates |gl_error| if the framebuffer is incomplete.
bool CheckFramebufferValid(
Framebuffer* framebuffer,
GLenum target,
bool clear_uncleared_images,
- GLenum gl_error,
const char* func_name);
bool CheckBoundDrawFramebufferValid(
bool clear_uncleared_images, const char* func_name);
- // Generates |gl_error| if the bound read fbo is incomplete.
- bool CheckBoundReadFramebufferValid(const char* func_name, GLenum gl_error);
+ bool CheckBoundReadFramebufferValid(const char* func_name);
// Checks if the current program exists and is valid. If not generates the
// appropriate GL error. Returns true if the current program is in a usable
@@ -3727,7 +3724,6 @@
Framebuffer* framebuffer,
GLenum target,
bool clear_uncleared_images,
- GLenum gl_error,
const char* func_name) {
if (!framebuffer) {
if (surfaceless_)
@@ -3767,7 +3763,8 @@
GLenum completeness = framebuffer->IsPossiblyComplete(feature_info_.get());
if (completeness != GL_FRAMEBUFFER_COMPLETE) {
- LOCAL_SET_GL_ERROR(gl_error, func_name, "framebuffer incomplete");
+ LOCAL_SET_GL_ERROR(
+ GL_INVALID_FRAMEBUFFER_OPERATION, func_name, "framebuffer incomplete");
return false;
}
@@ -3780,7 +3777,8 @@
if (framebuffer->GetStatus(texture_manager(), target) !=
GL_FRAMEBUFFER_COMPLETE) {
LOCAL_SET_GL_ERROR(
- gl_error, func_name, "framebuffer incomplete (clear)");
+ GL_INVALID_FRAMEBUFFER_OPERATION, func_name,
+ "framebuffer incomplete (clear)");
return false;
}
ClearUnclearedAttachments(target, framebuffer);
@@ -3791,7 +3789,8 @@
if (framebuffer->GetStatus(texture_manager(), target) !=
GL_FRAMEBUFFER_COMPLETE) {
LOCAL_SET_GL_ERROR(
- gl_error, func_name, "framebuffer incomplete (check)");
+ GL_INVALID_FRAMEBUFFER_OPERATION, func_name,
+ "framebuffer incomplete (check)");
return false;
}
framebuffer_manager()->MarkAsComplete(framebuffer);
@@ -3805,20 +3804,17 @@
GL_DRAW_FRAMEBUFFER : GL_FRAMEBUFFER;
Framebuffer* framebuffer = GetFramebufferInfoForTarget(target);
bool valid = CheckFramebufferValid(
- framebuffer, target, clear_uncleared_images,
- GL_INVALID_FRAMEBUFFER_OPERATION, func_name);
+ framebuffer, target, clear_uncleared_images, func_name);
if (valid && !features().chromium_framebuffer_multisample)
OnUseFramebuffer();
return valid;
}
-bool GLES2DecoderImpl::CheckBoundReadFramebufferValid(
- const char* func_name, GLenum gl_error) {
+bool GLES2DecoderImpl::CheckBoundReadFramebufferValid(const char* func_name) {
GLenum target = features().chromium_framebuffer_multisample ?
GL_READ_FRAMEBUFFER : GL_FRAMEBUFFER;
Framebuffer* framebuffer = GetFramebufferInfoForTarget(target);
- bool valid = CheckFramebufferValid(
- framebuffer, target, true, gl_error, func_name);
+ bool valid = CheckFramebufferValid(framebuffer, target, true, func_name);
return valid;
}
@@ -5258,52 +5254,50 @@
bool GLES2DecoderImpl::GetHelper(
GLenum pname, GLint* params, GLsizei* num_written) {
DCHECK(num_written);
- switch (pname) {
- case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
- case GL_IMPLEMENTATION_COLOR_READ_TYPE:
- // They are not supported on Desktop GL until 4.1, but could be exposed
- // through GL_OES_read_format extension. However, a conflicting extension
- // GL_ARB_ES2_compatibility specifies an error case when requested on
- // integer/floating point buffers.
- // To simpify the handling, we just query and check for GL errors. If an
- // GL error occur, we fall back to our internal implementation.
- *num_written = 1;
- if (!CheckBoundReadFramebufferValid("glGetIntegerv",
- GL_INVALID_OPERATION)) {
+ if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
+ switch (pname) {
+ case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
+ *num_written = 1;
+ // Return the GL implementation's preferred format and (see below type)
+ // if we have the GL extension that exposes this. This allows the GPU
+ // client to use the implementation's preferred format for glReadPixels
+ // for optimisation.
+ //
+ // A conflicting extension (GL_ARB_ES2_compatibility) specifies an error
+ // case when requested on integer/floating point buffers but which is
+ // acceptable on GLES2 and with the GL_OES_read_format extension.
+ //
+ // Therefore if an error occurs we swallow the error and use the
+ // internal implementation.
if (params) {
- *params = 0;
+ if (context_->HasExtension("GL_OES_read_format")) {
+ ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper",
+ GetErrorState());
+ glGetIntegerv(pname, params);
+ if (glGetError() == GL_NO_ERROR)
+ return true;
+ }
+ *params = GLES2Util::GetGLReadPixelsImplementationFormat(
+ GetBoundReadFrameBufferInternalFormat(),
+ GetBoundReadFrameBufferTextureType(),
+ feature_info_->feature_flags().ext_read_format_bgra);
}
return true;
- }
- if (params) {
- ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper",
- GetErrorState());
- glGetIntegerv(pname, params);
- if (glGetError() != GL_NO_ERROR) {
- if (pname == GL_IMPLEMENTATION_COLOR_READ_FORMAT) {
- *params = GLES2Util::GetGLReadPixelsImplementationFormat(
- GetBoundReadFrameBufferInternalFormat(),
- GetBoundReadFrameBufferTextureType(),
- feature_info_->feature_flags().ext_read_format_bgra);
- } else {
- *params = GLES2Util::GetGLReadPixelsImplementationType(
- GetBoundReadFrameBufferInternalFormat(),
- GetBoundReadFrameBufferTextureType());
+ case GL_IMPLEMENTATION_COLOR_READ_TYPE:
+ *num_written = 1;
+ if (params) {
+ if (context_->HasExtension("GL_OES_read_format")) {
+ ScopedGLErrorSuppressor suppressor("GLES2DecoderImpl::GetHelper",
+ GetErrorState());
+ glGetIntegerv(pname, params);
+ if (glGetError() == GL_NO_ERROR)
+ return true;
}
+ *params = GLES2Util::GetGLReadPixelsImplementationType(
+ GetBoundReadFrameBufferInternalFormat(),
+ GetBoundReadFrameBufferTextureType());
}
- if (*params == GL_HALF_FLOAT &&
- (feature_info_->context_type() == CONTEXT_TYPE_WEBGL1 ||
- feature_info_->context_type() == CONTEXT_TYPE_OPENGLES2)) {
- *params = GL_HALF_FLOAT_OES;
- }
- }
- return true;
- default:
- break;
- }
-
- if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
- switch (pname) {
+ return true;
case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
*num_written = 1;
if (params) {
@@ -6679,8 +6673,7 @@
DCHECK(!ShouldDeferReads() && !ShouldDeferDraws());
if (!CheckBoundDrawFramebufferValid(true, "glBlitFramebufferCHROMIUM") ||
- !CheckBoundReadFramebufferValid("glBlitFramebufferCHROMIUM",
- GL_INVALID_FRAMEBUFFER_OPERATION)) {
+ !CheckBoundReadFramebufferValid("glBlitFramebufferCHROMIUM")) {
return;
}
@@ -9470,8 +9463,7 @@
return error::kNoError;
}
- if (!CheckBoundReadFramebufferValid("glReadPixels",
- GL_INVALID_FRAMEBUFFER_OPERATION)) {
+ if (!CheckBoundReadFramebufferValid("glReadPixels")) {
return error::kNoError;
}
GLenum src_internal_format = GetBoundReadFrameBufferInternalFormat();
@@ -9525,7 +9517,11 @@
case GL_HALF_FLOAT_OES:
case GL_FLOAT:
case GL_UNSIGNED_INT_10F_11F_11F_REV:
- accepted_types.push_back(GL_FLOAT);
+ if (!feature_info_->IsES3Enabled()) {
+ accepted_types.push_back(GL_UNSIGNED_BYTE);
+ } else {
+ accepted_types.push_back(GL_FLOAT);
+ }
break;
default:
accepted_types.push_back(GL_UNSIGNED_BYTE);
@@ -9562,10 +9558,6 @@
LOCAL_SET_GL_ERROR(GL_INVALID_OPERATION, "glReadPixels",
"format and type incompatible with the current read framebuffer");
return error::kNoError;
- }
- if (type == GL_HALF_FLOAT_OES &&
- !(feature_info_->gl_version_info().is_es2)) {
- type = GL_HALF_FLOAT;
}
if (width == 0 || height == 0) {
return error::kNoError;
@@ -11687,8 +11679,7 @@
return;
}
- if (!CheckBoundReadFramebufferValid("glCopyTexImage2D",
- GL_INVALID_FRAMEBUFFER_OPERATION)) {
+ if (!CheckBoundReadFramebufferValid("glCopyTexImage2D")) {
return;
}
@@ -11887,8 +11878,7 @@
return;
}
- if (!CheckBoundReadFramebufferValid("glCopyTexImage2D",
- GL_INVALID_FRAMEBUFFER_OPERATION)) {
+ if (!CheckBoundReadFramebufferValid("glCopyTexImage2D")) {
return;
}
« 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