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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa_intel.cc

Issue 2543123003: gpu, cmaa: improve |do_copy| condition logic (Closed)
Patch Set: use existing attachment->object_name() Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa _intel.h" 5 #include "gpu/command_buffer/service/gles2_cmd_apply_framebuffer_attachment_cmaa _intel.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "gpu/command_buffer/service/framebuffer_manager.h" 8 #include "gpu/command_buffer/service/framebuffer_manager.h"
9 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" 9 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h"
10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
11 #include "gpu/command_buffer/service/texture_manager.h"
11 #include "ui/gl/gl_context.h" 12 #include "ui/gl/gl_context.h"
12 #include "ui/gl/gl_gl_api_implementation.h" 13 #include "ui/gl/gl_gl_api_implementation.h"
13 #include "ui/gl/gl_version_info.h" 14 #include "ui/gl/gl_version_info.h"
14 15
15 #define SHADER(Src) #Src 16 #define SHADER(Src) #Src
16 17
17 namespace gpu { 18 namespace gpu {
18 namespace gles2 { 19 namespace gles2 {
19 20
20 ApplyFramebufferAttachmentCMAAINTELResourceManager:: 21 ApplyFramebufferAttachmentCMAAINTELResourceManager::
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 glDeleteProgram(debug_display_edges_shader_); 201 glDeleteProgram(debug_display_edges_shader_);
201 202
202 initialized_ = false; 203 initialized_ = false;
203 } 204 }
204 205
205 // Apply CMAA(Conservative Morphological Anti-Aliasing) algorithm to the 206 // Apply CMAA(Conservative Morphological Anti-Aliasing) algorithm to the
206 // color attachments of currently bound draw framebuffer. 207 // color attachments of currently bound draw framebuffer.
207 // Reference GL_INTEL_framebuffer_CMAA for details. 208 // Reference GL_INTEL_framebuffer_CMAA for details.
208 void ApplyFramebufferAttachmentCMAAINTELResourceManager:: 209 void ApplyFramebufferAttachmentCMAAINTELResourceManager::
209 ApplyFramebufferAttachmentCMAAINTEL( 210 ApplyFramebufferAttachmentCMAAINTEL(
210 gles2::GLES2Decoder* decoder, 211 GLES2Decoder* decoder,
211 gles2::Framebuffer* framebuffer, 212 Framebuffer* framebuffer,
212 gles2::CopyTextureCHROMIUMResourceManager* copier) { 213 CopyTextureCHROMIUMResourceManager* copier,
214 TextureManager* texture_manager) {
213 DCHECK(decoder); 215 DCHECK(decoder);
214 DCHECK(initialized_); 216 DCHECK(initialized_);
215 if (!framebuffer) 217 if (!framebuffer)
216 return; 218 return;
217 219
218 glDisable(GL_SCISSOR_TEST); 220 glDisable(GL_SCISSOR_TEST);
219 glDisable(GL_STENCIL_TEST); 221 glDisable(GL_STENCIL_TEST);
220 glDisable(GL_CULL_FACE); 222 glDisable(GL_CULL_FACE);
221 glDisable(GL_BLEND); 223 glDisable(GL_BLEND);
222 224
(...skipping 11 matching lines...) Expand all
234 continue; 236 continue;
235 GLsizei width = attachment->width(); 237 GLsizei width = attachment->width();
236 GLsizei height = attachment->height(); 238 GLsizei height = attachment->height();
237 GLenum internal_format = attachment->internal_format(); 239 GLenum internal_format = attachment->internal_format();
238 240
239 // Resize internal structures - only if needed. 241 // Resize internal structures - only if needed.
240 OnSize(width, height); 242 OnSize(width, height);
241 243
242 // CMAA internally expects GL_RGBA8 textures. 244 // CMAA internally expects GL_RGBA8 textures.
243 // Process using a GL_RGBA8 copy if this is not the case. 245 // Process using a GL_RGBA8 copy if this is not the case.
244 bool do_copy = internal_format != GL_RGBA8; 246 DCHECK(attachment->object_name());
247 TextureRef* texture =
248 texture_manager->GetTexture(attachment->object_name());
249 const bool rgba_immutable =
250 texture->texture()->IsImmutable() &&
251 TextureManager::ExtractFormatFromStorageFormat(internal_format) ==
252 GL_RGBA;
253 const bool do_copy = !rgba_immutable;
245 254
246 // CMAA Effect 255 // CMAA Effect
247 if (do_copy) { 256 if (do_copy) {
248 ApplyCMAAEffectTexture(source_texture, rgba8_texture_, do_copy); 257 ApplyCMAAEffectTexture(source_texture, rgba8_texture_, do_copy);
249 258
250 copier->DoCopySubTexture( 259 copier->DoCopySubTexture(
qiankun 2017/02/08 03:19:56 Hi DS, DoCopySubTexture only supported GLES2 form
dshwang 2017/02/10 01:13:38 Hi Qiankun, CMAA requires only RGB, RGBA, and pro
251 decoder, GL_TEXTURE_2D, rgba8_texture_, GL_RGBA8, GL_TEXTURE_2D, 260 decoder, GL_TEXTURE_2D, rgba8_texture_, GL_RGBA8, GL_TEXTURE_2D,
252 source_texture, internal_format, 0, 0, 0, 0, width_, height_, 261 source_texture, internal_format, 0, 0, 0, 0, width_, height_,
253 width_, height_, width_, height_, false, false, false); 262 width_, height_, width_, height_, false, false, false);
254 } else { 263 } else {
255 ApplyCMAAEffectTexture(source_texture, source_texture, do_copy); 264 ApplyCMAAEffectTexture(source_texture, source_texture, do_copy);
256 } 265 }
257 266
258 decoder->RestoreTextureState(source_texture); 267 decoder->RestoreTextureState(source_texture);
259 } 268 }
260 } 269 }
(...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 \n#endif\n 1850 \n#endif\n
1842 \n#if defined DISPLAY_EDGES\n 1851 \n#if defined DISPLAY_EDGES\n
1843 DisplayEdges(); 1852 DisplayEdges();
1844 \n#endif\n 1853 \n#endif\n
1845 } 1854 }
1846 ); 1855 );
1847 /* clang-format on */ 1856 /* clang-format on */
1848 1857
1849 } // namespace gles2 1858 } // namespace gles2
1850 } // namespace gpu 1859 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698