Chromium Code Reviews| Index: gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc |
| diff --git a/gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc b/gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc |
| index 6f411353803a30ed09f163944d7355ab204c54ae..4e53cc8d0c338aac0bce2e3d24d62d865ea47421 100644 |
| --- a/gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc |
| +++ b/gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc |
| @@ -185,6 +185,8 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::Initialize( |
| process_and_apply_shader_result_rgba_texture_slot1_ = glGetUniformLocation( |
| process_and_apply_shader_, "g_resultRGBATextureSlot1"); |
| + copy_to_framebuffer_shader_ = CreateProgram("", vert_str_, copy_frag_str_); |
| + |
| initialized_ = true; |
| } |
| @@ -194,6 +196,7 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::Destroy() { |
| ReleaseTextures(); |
| + glDeleteProgram(copy_to_framebuffer_shader_); |
| glDeleteProgram(process_and_apply_shader_); |
| glDeleteProgram(edges_combine_shader_); |
| glDeleteProgram(edges1_shader_); |
| @@ -245,16 +248,11 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager:: |
| // CMAA Effect |
| if (do_copy) { |
| ApplyCMAAEffectTexture(source_texture, rgba8_texture_, do_copy); |
| + CopyTexture(rgba8_texture_, source_texture); |
| } else { |
| ApplyCMAAEffectTexture(source_texture, source_texture, do_copy); |
| } |
| - // Copy rgba8_texture_ to source_texture |
| - if (do_copy) { |
| - // copy_framebuffer_ always binds rgba8_texture_ |
| - glBindFramebufferEXT(GL_FRAMEBUFFER, copy_framebuffer_); |
| - CopyTexture(source_texture); |
| - } |
| decoder->RestoreTextureState(source_texture); |
| } |
| } |
| @@ -551,15 +549,42 @@ void ApplyFramebufferAttachmentCMAAINTELResourceManager::ReleaseTextures() { |
| } |
| void ApplyFramebufferAttachmentCMAAINTELResourceManager::CopyTexture( |
|
piman
2016/10/28 21:51:12
We already have a facility to copy a texture using
|
| + GLint source, |
| GLint dest) { |
| - glActiveTexture(GL_TEXTURE0); |
| - glBindTexture(GL_TEXTURE_2D, dest); |
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| + // glDrawArrays is faster than glCopyTexSubImage2D on IA Mesa driver, |
| + // although opposite in Android. Currently, only IA ChromeOS uses this code. |
| + const bool draw = true; |
|
dshwang
2016/10/28 18:13:24
Mesa may will fix it or future Intel Chromebook ma
|
| + if (draw) { |
| + glBindFramebufferEXT(GL_FRAMEBUFFER, copy_framebuffer_); |
| + glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
| + GL_TEXTURE_2D, dest, 0); |
| + glViewport(0, 0, width_, height_); |
| - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, width_, height_); |
| + glActiveTexture(GL_TEXTURE0); |
| + glBindTexture(GL_TEXTURE_2D, source); |
| + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| + |
| + glDisable(GL_DEPTH_TEST); |
| + glDisable(GL_STENCIL_TEST); |
| + glDisable(GL_CULL_FACE); |
| + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); |
| + glDepthMask(GL_FALSE); |
| + glDisable(GL_BLEND); |
| + glUseProgram(copy_to_framebuffer_shader_); |
| + |
| + glDrawArrays(GL_TRIANGLES, 0, 3); |
| + glUseProgram(0); |
| + glBindTexture(GL_TEXTURE_2D, 0); |
| + } else { |
| + // copy_framebuffer_ always binds rgba8_texture_ |
| + glBindFramebufferEXT(GL_FRAMEBUFFER, copy_framebuffer_); |
| + glActiveTexture(GL_TEXTURE0); |
| + glBindTexture(GL_TEXTURE_2D, dest); |
| + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, width_, height_); |
| + } |
| } |
| GLuint ApplyFramebufferAttachmentCMAAINTELResourceManager::CreateProgram( |
| @@ -1861,6 +1886,19 @@ const char ApplyFramebufferAttachmentCMAAINTELResourceManager::cmaa_frag_s2_[] = |
| \n#endif\n |
| } |
| ); |
| + |
| +const char |
| + ApplyFramebufferAttachmentCMAAINTELResourceManager::copy_frag_str_[] = |
| + SHADER( |
| + precision highp float; |
| + layout(binding = 0) uniform highp sampler2D inTexture; |
| + layout(location = 0) out vec4 outColor; |
| + void main() { |
| + ivec2 screenPosI = ivec2( gl_FragCoord.xy ); |
| + vec4 pixel = texelFetch(inTexture, screenPosI, 0); |
| + outColor = pixel; |
| + } |
| + ); |
| /* clang-format on */ |
| } // namespace gles2 |