OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 4981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4992 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glGenerateMipmap"); | 4992 LOCAL_COPY_REAL_GL_ERRORS_TO_WRAPPER("glGenerateMipmap"); |
4993 // Workaround for Mac driver bug. In the large scheme of things setting | 4993 // Workaround for Mac driver bug. In the large scheme of things setting |
4994 // glTexParamter twice for glGenerateMipmap is probably not a lage performance | 4994 // glTexParamter twice for glGenerateMipmap is probably not a lage performance |
4995 // hit so there's probably no need to make this conditional. The bug appears | 4995 // hit so there's probably no need to make this conditional. The bug appears |
4996 // to be that if the filtering mode is set to something that doesn't require | 4996 // to be that if the filtering mode is set to something that doesn't require |
4997 // mipmaps for rendering, or is never set to something other than the default, | 4997 // mipmaps for rendering, or is never set to something other than the default, |
4998 // then glGenerateMipmap misbehaves. | 4998 // then glGenerateMipmap misbehaves. |
4999 if (workarounds().set_texture_filter_before_generating_mipmap) { | 4999 if (workarounds().set_texture_filter_before_generating_mipmap) { |
5000 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); | 5000 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); |
5001 } | 5001 } |
| 5002 |
| 5003 // Workaround for Mac driver bug. If the base level is non-zero but the zero |
| 5004 // level of a texture has not been set glGenerateMipmaps sets the entire mip |
| 5005 // chain to opaque black. If the zero level is set at all, however, the mip |
| 5006 // chain is properly generated from the base level. |
| 5007 bool texture_zero_level_set = false; |
| 5008 GLenum type = 0; |
| 5009 GLenum internal_format = 0; |
| 5010 GLenum format = 0; |
| 5011 if (workarounds().set_zero_level_before_generating_mipmap && |
| 5012 target == GL_TEXTURE_2D) { |
| 5013 Texture* tex = texture_ref->texture(); |
| 5014 if (tex && tex->base_level() != 0 && |
| 5015 !tex->GetLevelType(target, 0, &type, &internal_format) && |
| 5016 tex->GetLevelType(target, tex->base_level(), &type, &internal_format)) { |
| 5017 format = TextureManager::ExtractFormatFromStorageFormat(internal_format); |
| 5018 glTexImage2D(target, 0, internal_format, 1, 1, 0, format, type, nullptr); |
| 5019 texture_zero_level_set = true; |
| 5020 } |
| 5021 } |
| 5022 |
5002 glGenerateMipmapEXT(target); | 5023 glGenerateMipmapEXT(target); |
| 5024 |
| 5025 if (texture_zero_level_set) { |
| 5026 // This may have some unwanted side effects, but we expect command buffer |
| 5027 // validation to prevent you from doing anything weird with the texture |
| 5028 // after this, like calling texSubImage2D sucessfully. |
| 5029 glTexImage2D(target, 0, internal_format, 0, 0, 0, format, type, nullptr); |
| 5030 } |
| 5031 |
5003 if (workarounds().set_texture_filter_before_generating_mipmap) { | 5032 if (workarounds().set_texture_filter_before_generating_mipmap) { |
5004 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, | 5033 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, |
5005 texture_ref->texture()->min_filter()); | 5034 texture_ref->texture()->min_filter()); |
5006 } | 5035 } |
5007 GLenum error = LOCAL_PEEK_GL_ERROR("glGenerateMipmap"); | 5036 GLenum error = LOCAL_PEEK_GL_ERROR("glGenerateMipmap"); |
5008 if (error == GL_NO_ERROR) { | 5037 if (error == GL_NO_ERROR) { |
5009 texture_manager()->MarkMipmapsGenerated(texture_ref); | 5038 texture_manager()->MarkMipmapsGenerated(texture_ref); |
5010 } | 5039 } |
5011 } | 5040 } |
5012 | 5041 |
(...skipping 10279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15292 return error::kNoError; | 15321 return error::kNoError; |
15293 } | 15322 } |
15294 | 15323 |
15295 // Include the auto-generated part of this file. We split this because it means | 15324 // Include the auto-generated part of this file. We split this because it means |
15296 // we can easily edit the non-auto generated parts right here in this file | 15325 // we can easily edit the non-auto generated parts right here in this file |
15297 // instead of having to edit some template or the code generator. | 15326 // instead of having to edit some template or the code generator. |
15298 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15327 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15299 | 15328 |
15300 } // namespace gles2 | 15329 } // namespace gles2 |
15301 } // namespace gpu | 15330 } // namespace gpu |
OLD | NEW |