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, internal_format, format; | |
5009 if (workarounds().set_zero_level_before_generating_mipmap && | |
5010 target == GL_TEXTURE_2D) { | |
5011 Texture* tex = texture_ref->texture(); | |
5012 if (tex && tex->base_level() != 0 && | |
5013 !tex->GetLevelType(target, 0, &type, &internal_format) && | |
5014 tex->GetLevelType(target, tex->base_level(), &type, &internal_format)) { | |
zmo
2015/11/23 23:14:47
nit: the last condition is unnecessary because Can
| |
5015 format = TextureManager::ExtractFormatFromStorageFormat(internal_format); | |
5016 glTexImage2D(target, 0, internal_format, 1, 1, 0, format, type, nullptr); | |
5017 texture_zero_level_set = true; | |
5018 } | |
5019 } | |
5020 | |
5002 glGenerateMipmapEXT(target); | 5021 glGenerateMipmapEXT(target); |
5022 | |
5023 if (texture_zero_level_set) { | |
5024 glTexImage2D(target, 0, internal_format, 0, 0, 0, format, type, nullptr); | |
zmo
2015/11/23 23:14:47
Could you please add a note that this might have s
| |
5025 } | |
5026 | |
5003 if (workarounds().set_texture_filter_before_generating_mipmap) { | 5027 if (workarounds().set_texture_filter_before_generating_mipmap) { |
5004 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, | 5028 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, |
5005 texture_ref->texture()->min_filter()); | 5029 texture_ref->texture()->min_filter()); |
5006 } | 5030 } |
5007 GLenum error = LOCAL_PEEK_GL_ERROR("glGenerateMipmap"); | 5031 GLenum error = LOCAL_PEEK_GL_ERROR("glGenerateMipmap"); |
5008 if (error == GL_NO_ERROR) { | 5032 if (error == GL_NO_ERROR) { |
5009 texture_manager()->MarkMipmapsGenerated(texture_ref); | 5033 texture_manager()->MarkMipmapsGenerated(texture_ref); |
5010 } | 5034 } |
5011 } | 5035 } |
5012 | 5036 |
(...skipping 10279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15292 return error::kNoError; | 15316 return error::kNoError; |
15293 } | 15317 } |
15294 | 15318 |
15295 // Include the auto-generated part of this file. We split this because it means | 15319 // 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 | 15320 // 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. | 15321 // instead of having to edit some template or the code generator. |
15298 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 15322 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
15299 | 15323 |
15300 } // namespace gles2 | 15324 } // namespace gles2 |
15301 } // namespace gpu | 15325 } // namespace gpu |
OLD | NEW |