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

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

Issue 2686043002: Refactor CopyTextureCHROMIUM internalformat validation (Closed)
Patch Set: rebase only Created 3 years, 10 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
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 80d7234db1a14a553dffb18d6158a0b66afbb85b..c823faa86045760849505492ca0eb3fc9f753288 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -2028,8 +2028,11 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient {
bool CanUseCopyTextureCHROMIUMInternalFormat(GLenum dest_internal_format);
CopyTextureMethod ValidateCopyTextureCHROMIUMInternalFormats(
const char* function_name,
- TextureRef* source_texture_ref,
GLint source_level,
+ GLenum source_internal_format,
+ GLenum source_type,
+ GLenum dest_target,
+ GLint dest_level,
GLenum dest_internal_format);
bool ValidateCompressedCopyTextureCHROMIUM(const char* function_name,
TextureRef* source_texture_ref,
@@ -16270,15 +16273,12 @@ bool GLES2DecoderImpl::CanUseCopyTextureCHROMIUMInternalFormat(
CopyTextureMethod GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats(
const char* function_name,
- TextureRef* source_texture_ref,
GLint source_level,
+ GLenum source_internal_format,
+ GLenum source_type,
+ GLenum dest_target,
+ GLint dest_level,
GLenum dest_internal_format) {
- GLenum source_type = 0;
- GLenum source_internal_format = 0;
- Texture* source_texture = source_texture_ref->texture();
- source_texture->GetLevelType(source_texture->target(), source_level,
- &source_type, &source_internal_format);
-
bool valid_dest_format = false;
// TODO(qiankun.miao@intel.com): ALPHA, LUMINANCE and LUMINANCE_ALPHA formats
// are not supported on GL core profile. See crbug.com/577144. Enable the
@@ -16372,12 +16372,26 @@ CopyTextureMethod GLES2DecoderImpl::ValidateCopyTextureCHROMIUMInternalFormats(
dest_internal_format != GL_BGRA8_EXT &&
ValidateCopyTexFormatHelper(dest_internal_format, source_internal_format,
source_type, &output_error_msg);
- if (source_format_color_renderable && copy_tex_image_format_valid)
- return DIRECT_COPY;
- if (dest_format_color_renderable)
+ // TODO(qiankun.miao@intel.com): for WebGL 2.0 or OpenGL ES 3.0, both
+ // DIRECT_DRAW path for dest_level > 0 and DIRECT_COPY path for source_level >
+ // 0 are not available due to a framebuffer completeness bug:
+ // crbug.com/678526. Once the bug is fixed, the limitation for WebGL 2.0 and
+ // OpenGL ES 3.0 can be lifted.
+ // For WebGL 1.0 or OpenGL ES 2.0, DIRECT_DRAW path isn't available for
+ // dest_level > 0 due to level > 0 isn't supported by glFramebufferTexture2D
+ // in ES2 context. DIRECT_DRAW path isn't available for cube map dest texture
+ // either due to it may be cube map incomplete. Go to DRAW_AND_COPY path in
+ // these cases.
+ if (source_format_color_renderable && copy_tex_image_format_valid &&
+ source_level == 0)
+ return DIRECT_COPY;
+ if (dest_format_color_renderable && dest_level == 0 &&
+ dest_target != GL_TEXTURE_CUBE_MAP)
return DIRECT_DRAW;
+ // Draw to a fbo attaching level 0 of an intermediate texture,
+ // then copy from the fbo to dest texture level with glCopyTexImage2D.
return DRAW_AND_COPY;
}
@@ -16475,31 +16489,14 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM(
}
CopyTextureMethod method = ValidateCopyTextureCHROMIUMInternalFormats(
- kFunctionName, source_texture_ref, source_level, internal_format);
+ kFunctionName, source_level, source_internal_format, source_type,
+ dest_binding_target, dest_level, internal_format);
// INVALID_OPERATION is already generated by
// ValidateCopyTextureCHROMIUMInternalFormats.
if (method == NOT_COPYABLE) {
return;
}
- // Draw to a fbo attaching level 0 of an intermediate texture,
- // then copy from the fbo to dest texture level with glCopyTexImage2D.
- // For WebGL 1.0 or OpenGL ES 2.0, DIRECT_DRAW path isn't available for
- // dest_level > 0 due to level > 0 isn't supported by glFramebufferTexture2D
- // in ES2 context. DIRECT_DRAW path isn't available for cube map dest texture
- // either due to it may be cube map incomplete. Go to DRAW_AND_COPY path in
- // these cases.
- // TODO(qiankun.miao@intel.com): for WebGL 2.0 or OpenGL ES 3.0, both
- // DIRECT_DRAW path for dest_level > 0 and DIRECT_COPY path for source_level >
- // 0 are not available due to a framebuffer completeness bug:
- // crbug.com/678526. Once the bug is fixed, the limitation for WebGL 2.0 and
- // OpenGL ES 3.0 can be lifted.
- if (((dest_level > 0 || dest_binding_target == GL_TEXTURE_CUBE_MAP) &&
- method == DIRECT_DRAW) ||
- (source_level > 0 && method == DIRECT_COPY)) {
- method = DRAW_AND_COPY;
- }
-
if (feature_info_->feature_flags().desktop_srgb_support) {
bool enable_framebuffer_srgb =
GLES2Util::GetColorEncodingFromInternalFormat(source_internal_format) ==
@@ -16744,7 +16741,8 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
}
CopyTextureMethod method = ValidateCopyTextureCHROMIUMInternalFormats(
- kFunctionName, source_texture_ref, source_level, dest_internal_format);
+ kFunctionName, source_level, source_internal_format, source_type,
+ dest_binding_target, dest_level, dest_internal_format);
// INVALID_OPERATION is already generated by
// ValidateCopyTextureCHROMIUMInternalFormats.
if (method == NOT_COPYABLE) {
@@ -16763,24 +16761,6 @@ void GLES2DecoderImpl::DoCopySubTextureCHROMIUM(
}
#endif
- // Draw to a fbo attaching level 0 of an intermediate texture,
- // then copy from the fbo to dest texture level with glCopyTexImage2D.
- // For WebGL 1.0 or OpenGL ES 2.0, DIRECT_DRAW path isn't available for
- // dest_level > 0 due to level > 0 isn't supported by glFramebufferTexture2D
- // in ES2 context. DIRECT_DRAW path isn't available for cube map dest texture
- // either due to it may be cube map incomplete. Go to DRAW_AND_COPY path in
- // these cases.
- // TODO(qiankun.miao@intel.com): for WebGL 2.0 or OpenGL ES 3.0, both
- // DIRECT_DRAW path for dest_level > 0 and DIRECT_COPY path for source_level >
- // 0 are not available due to a framebuffer completeness bug:
- // crbug.com/678526. Once the bug is fixed, the limitation for WebGL 2.0 and
- // OpenGL ES 3.0 can be lifted.
- if (((dest_level > 0 || dest_binding_target == GL_TEXTURE_CUBE_MAP) &&
- method == DIRECT_DRAW) ||
- (source_level > 0 && method == DIRECT_COPY)) {
- method = DRAW_AND_COPY;
- }
-
if (feature_info_->feature_flags().desktop_srgb_support) {
bool enable_framebuffer_srgb =
GLES2Util::GetColorEncodingFromInternalFormat(source_internal_format) ==
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698