OLD | NEW |
---|---|
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 "gpu/command_buffer/service/texture_manager.h" |
12 #include "ui/gl/gl_context.h" | 12 #include "ui/gl/gl_context.h" |
13 #include "ui/gl/gl_gl_api_implementation.h" | 13 #include "ui/gl/gl_gl_api_implementation.h" |
14 #include "ui/gl/gl_version_info.h" | 14 #include "ui/gl/gl_version_info.h" |
15 | 15 |
16 #define SHADER(Src) #Src | 16 #define SHADER(Src) #Src |
17 | 17 |
18 namespace { | |
19 | |
20 bool CanUseCopyTextureCHROMIUM(GLenum internal_format) { | |
21 switch (internal_format) { | |
22 case GL_RGB: | |
23 case GL_RGBA: | |
24 case GL_RGB8: | |
25 case GL_RGBA8: | |
26 case GL_BGRA_EXT: | |
27 case GL_BGRA8_EXT: | |
28 case GL_SRGB_EXT: | |
29 case GL_SRGB_ALPHA_EXT: | |
30 case GL_R8: | |
31 case GL_R8UI: | |
32 case GL_RG8: | |
33 case GL_RG8UI: | |
34 case GL_SRGB8: | |
35 case GL_RGB565: | |
36 case GL_RGB8UI: | |
37 case GL_SRGB8_ALPHA8: | |
38 case GL_RGB5_A1: | |
39 case GL_RGBA4: | |
40 case GL_RGBA8UI: | |
41 case GL_RGB9_E5: | |
42 case GL_R16F: | |
43 case GL_R32F: | |
44 case GL_RG16F: | |
45 case GL_RG32F: | |
46 case GL_RGB16F: | |
47 case GL_RGB32F: | |
48 case GL_RGBA16F: | |
49 case GL_RGBA32F: | |
50 case GL_R11F_G11F_B10F: | |
51 return true; | |
52 default: | |
53 return false; | |
54 } | |
55 } | |
56 | |
57 } // namespace | |
58 | |
18 namespace gpu { | 59 namespace gpu { |
19 namespace gles2 { | 60 namespace gles2 { |
20 | 61 |
21 ApplyFramebufferAttachmentCMAAINTELResourceManager:: | 62 ApplyFramebufferAttachmentCMAAINTELResourceManager:: |
22 ApplyFramebufferAttachmentCMAAINTELResourceManager() | 63 ApplyFramebufferAttachmentCMAAINTELResourceManager() |
23 : initialized_(false), | 64 : initialized_(false), |
24 textures_initialized_(false), | 65 textures_initialized_(false), |
25 is_in_gamma_correct_mode_(false), | 66 is_in_gamma_correct_mode_(false), |
26 supports_usampler_(true), | 67 supports_usampler_(true), |
27 supports_r8_image_(true), | 68 supports_r8_image_(true), |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 TextureRef* texture = | 288 TextureRef* texture = |
248 texture_manager->GetTexture(attachment->object_name()); | 289 texture_manager->GetTexture(attachment->object_name()); |
249 const bool rgba_immutable = | 290 const bool rgba_immutable = |
250 texture->texture()->IsImmutable() && | 291 texture->texture()->IsImmutable() && |
251 TextureManager::ExtractFormatFromStorageFormat(internal_format) == | 292 TextureManager::ExtractFormatFromStorageFormat(internal_format) == |
252 GL_RGBA; | 293 GL_RGBA; |
253 const bool do_copy = !rgba_immutable; | 294 const bool do_copy = !rgba_immutable; |
254 | 295 |
255 // CMAA Effect | 296 // CMAA Effect |
256 if (do_copy) { | 297 if (do_copy) { |
298 if (!CanUseCopyTextureCHROMIUM(internal_format)) { | |
299 DLOG(ERROR) << "Apply CMAA on framebuffer with attachment in " | |
qiankun
2017/02/13 08:52:25
I am not sure if the format limitation should be h
Zhenyao Mo
2017/02/13 18:36:17
I think for Chrome to generate an INVALID_OPERATIO
qiankun
2017/02/14 08:08:17
Generete INVALID_OPERATION for such invalid situat
| |
300 << GLES2Util::GetStringEnum(internal_format) | |
301 << " internalformat."; | |
302 return; | |
303 } | |
257 ApplyCMAAEffectTexture(source_texture, rgba8_texture_, do_copy); | 304 ApplyCMAAEffectTexture(source_texture, rgba8_texture_, do_copy); |
258 | 305 |
259 // Source format for DoCopySubTexture is always GL_RGBA8. | 306 // Source format for DoCopySubTexture is always GL_RGBA8. |
260 CopyTextureMethod method = DIRECT_COPY; | 307 CopyTextureMethod method = DIRECT_COPY; |
261 bool copy_tex_image_format_valid = | 308 bool copy_tex_image_format_valid = |
262 !GLES2Util::IsIntegerFormat(internal_format) && | 309 !GLES2Util::IsIntegerFormat(internal_format) && |
263 GLES2Util::GetColorEncodingFromInternalFormat(internal_format) != | 310 GLES2Util::GetColorEncodingFromInternalFormat(internal_format) != |
264 GL_SRGB && | 311 GL_SRGB && |
265 internal_format != GL_BGRA_EXT && internal_format != GL_BGRA8_EXT; | 312 internal_format != GL_BGRA_EXT && internal_format != GL_BGRA8_EXT; |
266 if (GLES2Util::IsSizedColorFormat(internal_format)) { | 313 if (GLES2Util::IsSizedColorFormat(internal_format)) { |
(...skipping 1614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1881 \n#endif\n | 1928 \n#endif\n |
1882 \n#if defined DISPLAY_EDGES\n | 1929 \n#if defined DISPLAY_EDGES\n |
1883 DisplayEdges(); | 1930 DisplayEdges(); |
1884 \n#endif\n | 1931 \n#endif\n |
1885 } | 1932 } |
1886 ); | 1933 ); |
1887 /* clang-format on */ | 1934 /* clang-format on */ |
1888 | 1935 |
1889 } // namespace gles2 | 1936 } // namespace gles2 |
1890 } // namespace gpu | 1937 } // namespace gpu |
OLD | NEW |