summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-04 20:53:40 +0000
committerjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-04 20:53:40 +0000
commitf0e6a34f89c98db4bafd7b8610db12e475d91b84 (patch)
tree23b882a9289e34030a90718c80ac7867dbf4c503 /gpu
parent301278f160dc56d58e202d8a3c7f67427933efdb (diff)
downloadchromium_src-f0e6a34f89c98db4bafd7b8610db12e475d91b84.zip
chromium_src-f0e6a34f89c98db4bafd7b8610db12e475d91b84.tar.gz
chromium_src-f0e6a34f89c98db4bafd7b8610db12e475d91b84.tar.bz2
Undo GL_EXT_texture_storage disable, fixup internal format for non-GLES2.
Desktop GL does not support BGRA as an internal format for glTexStorage, but GLES2 does. Since we provide an ES2 implementation to client code, we need to convert BGRA to RGBA when running on top of non-ES2 GL implementations. BUG=107782 TEST=see bug for manual test Review URL: http://codereview.chromium.org/9008071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116378 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/feature_info.cc31
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc35
-rw-r--r--gpu/command_buffer/service/test_helper.cc7
3 files changed, 24 insertions, 49 deletions
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc
index 0d836d9..c85c252 100644
--- a/gpu/command_buffer/service/feature_info.cc
+++ b/gpu/command_buffer/service/feature_info.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -413,34 +413,7 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
validators_.texture_parameter.AddValue(GL_TEXTURE_USAGE_ANGLE);
}
- bool allow_texture_storage = true;
-#if defined(OS_LINUX)
- if (!disallowed_features_.driver_bug_workarounds) {
- // Disable GL_EXT_texture_storage on Linux, newer Nvidia drivers
- // don't support our implementation. See crbug.com/107782. The bug is
- // present on 285.x.x but not on 280.x.x so we will disable this feature
- // on driver versions greater than 280.
- const char* vendor_str =
- reinterpret_cast<const char*>(glGetString(GL_VENDOR));
- bool is_nvidia = vendor_str &&
- (strcmp(vendor_str, "NVIDIA Corporation") == 0);
- if (is_nvidia) {
- base::StringPiece version =
- reinterpret_cast<const char*>(glGetString(GL_VERSION));
- int version_num = 0;
- size_t begin_version = version.find_last_of(' ') + 1;
- size_t size_version = version.find_first_of('.', begin_version) -
- begin_version;
- if (base::StringToInt(version.substr(begin_version, size_version),
- &version_num))
- allow_texture_storage = (version_num <= 280);
- else
- allow_texture_storage = false;
- }
- }
-#endif
-
- if (allow_texture_storage && ext.HaveAndDesire("GL_EXT_texture_storage")) {
+ if (ext.HaveAndDesire("GL_EXT_texture_storage")) {
AddExtensionString("GL_EXT_texture_storage");
validators_.texture_parameter.AddValue(GL_TEXTURE_IMMUTABLE_FORMAT_EXT);
if (enable_texture_format_bgra8888)
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 814e454..23e9bbc 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -168,6 +168,14 @@ static bool StringIsValidForGLES(const char* str) {
return true;
}
+static inline GLenum GetTexInternalFormat(GLenum internal_format) {
+ if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
+ if (internal_format == GL_BGRA_EXT || internal_format == GL_BGRA8_EXT)
+ return GL_RGBA8;
+ }
+ return internal_format;
+}
+
static void WrappedTexImage2D(
GLenum target,
GLint level,
@@ -178,11 +186,9 @@ static void WrappedTexImage2D(
GLenum format,
GLenum type,
const void* pixels) {
- GLenum gl_internal_format = internal_format;
+ GLenum gl_internal_format = GetTexInternalFormat(internal_format);
if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
- if (format == GL_BGRA_EXT && internal_format == GL_BGRA_EXT) {
- gl_internal_format = GL_RGBA;
- } else if (type == GL_FLOAT) {
+ if (type == GL_FLOAT) {
if (format == GL_RGBA) {
gl_internal_format = GL_RGBA32F_ARB;
} else if (format == GL_RGB) {
@@ -1649,15 +1655,15 @@ bool Texture::AllocateStorage(const gfx::Size& size, GLenum format) {
ScopedGLErrorSuppressor suppressor(decoder_);
ScopedTexture2DBinder binder(decoder_, id_);
- glTexImage2D(GL_TEXTURE_2D,
- 0, // mip level
- format,
- size.width(),
- size.height(),
- 0, // border
- format,
- GL_UNSIGNED_BYTE,
- NULL);
+ WrappedTexImage2D(GL_TEXTURE_2D,
+ 0, // mip level
+ format,
+ size.width(),
+ size.height(),
+ 0, // border
+ format,
+ GL_UNSIGNED_BYTE,
+ NULL);
size_ = size;
@@ -7965,7 +7971,8 @@ void GLES2DecoderImpl::DoTexStorage2DEXT(
return;
}
CopyRealGLErrorsToWrapper();
- glTexStorage2DEXT(target, levels, internal_format, width, height);
+ glTexStorage2DEXT(target, levels, GetTexInternalFormat(internal_format),
+ width, height);
GLenum error = PeekGLError();
if (error == GL_NO_ERROR) {
GLenum format = ExtractFormatFromStorageFormat(internal_format);
diff --git a/gpu/command_buffer/service/test_helper.cc b/gpu/command_buffer/service/test_helper.cc
index d4628a9..926eda5 100644
--- a/gpu/command_buffer/service/test_helper.cc
+++ b/gpu/command_buffer/service/test_helper.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -221,11 +221,6 @@ void TestHelper::SetupFeatureInfoInitExpectations(
EXPECT_CALL(*gl, GetString(GL_EXTENSIONS))
.WillOnce(Return(reinterpret_cast<const uint8*>(extensions)))
.RetiresOnSaturation();
-#if defined(OS_LINUX)
- EXPECT_CALL(*gl, GetString(GL_VENDOR))
- .WillOnce(Return(reinterpret_cast<const uint8*>(extensions)))
- .RetiresOnSaturation();
-#endif
}
} // namespace gles2