summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 22:43:15 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-23 22:43:15 +0000
commit62e155e92cfb165405fb3e6bc6c8dc5f2e9a95ac (patch)
treec880a8e1f73d8ed4d0da13299460d2f2559c885c /gpu
parente4de4d19d22ee0fd320b2f275858acdf3d44694d (diff)
downloadchromium_src-62e155e92cfb165405fb3e6bc6c8dc5f2e9a95ac.zip
chromium_src-62e155e92cfb165405fb3e6bc6c8dc5f2e9a95ac.tar.gz
chromium_src-62e155e92cfb165405fb3e6bc6c8dc5f2e9a95ac.tar.bz2
Move workarounds to one spot.
I felt like all the platform checks should only be in one place and the workarounds should work on flags rather than specific platforms. BUG=none Review URL: https://chromiumcodereview.appspot.com/11250002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163709 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/context_group.cc36
-rw-r--r--gpu/command_buffer/service/feature_info.cc77
-rw-r--r--gpu/command_buffer/service/feature_info.h30
-rw-r--r--gpu/command_buffer/service/feature_info_unittest.cc117
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc106
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc6
6 files changed, 155 insertions, 217 deletions
diff --git a/gpu/command_buffer/service/context_group.cc b/gpu/command_buffer/service/context_group.cc
index aca6002..d8487c7 100644
--- a/gpu/command_buffer/service/context_group.cc
+++ b/gpu/command_buffer/service/context_group.cc
@@ -139,34 +139,16 @@ bool ContextGroup::Initialize(const DisallowedFeatures& disallowed_features,
return false;
}
- // Limit Intel on Mac to 4096 max tex size and 1024 max cube map tex size.
- // Limit AMD on Mac to 4096 max tex size and max cube map tex size.
- // TODO(gman): Update this code to check for a specific version of
- // the drivers above which we no longer need this fix.
-#if defined(OS_MACOSX)
- if (!feature_info_->feature_flags().disable_workarounds) {
- if (feature_info_->feature_flags().is_intel) {
- max_texture_size = std::min(
- static_cast<GLint>(4096), max_texture_size);
-
- GLint cubemap_size_limit = 1024;
- // Cubemaps > 512 in size were broken before 10.7.3.
- int32 major, minor, bugfix;
- base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
- if (major < 10 ||
- (major == 10 && ((minor == 7 && bugfix < 3) || (minor < 7))))
- cubemap_size_limit = 512;
- max_cube_map_texture_size = std::min(
- cubemap_size_limit, max_cube_map_texture_size);
- }
- if (feature_info_->feature_flags().is_amd) {
- max_texture_size = std::min(
- static_cast<GLint>(4096), max_texture_size);
- max_cube_map_texture_size = std::min(
- static_cast<GLint>(4096), max_cube_map_texture_size);
- }
+ if (feature_info_->workarounds().max_texture_size) {
+ max_texture_size = std::min(
+ max_texture_size, feature_info_->workarounds().max_texture_size);
}
-#endif
+ if (feature_info_->workarounds().max_cube_map_texture_size) {
+ max_cube_map_texture_size = std::min(
+ max_cube_map_texture_size,
+ feature_info_->workarounds().max_cube_map_texture_size);
+ }
+
texture_manager_.reset(new TextureManager(memory_tracker_,
feature_info_.get(),
max_texture_size,
diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc
index f06c920..0873f0f 100644
--- a/gpu/command_buffer/service/feature_info.cc
+++ b/gpu/command_buffer/service/feature_info.cc
@@ -80,12 +80,19 @@ FeatureInfo::FeatureFlags::FeatureFlags()
occlusion_query_boolean(false),
use_arb_occlusion_query2_for_occlusion_query_boolean(false),
use_arb_occlusion_query_for_occlusion_query_boolean(false),
- native_vertex_array_object_(false),
- disable_workarounds(false),
- is_intel(false),
- is_nvidia(false),
- is_amd(false),
- is_mesa(false) {
+ native_vertex_array_object(false),
+ disable_workarounds(false) {
+}
+
+FeatureInfo::Workarounds::Workarounds()
+ : clear_alpha_in_readpixels(false),
+ needs_glsl_built_in_function_emulation(false),
+ needs_offscreen_buffer_workaround(false),
+ reverse_point_sprite_coord_origin(false),
+ set_texture_filter_before_generating_mipmap(false),
+ use_current_program_after_successful_link(false),
+ max_texture_size(0),
+ max_cube_map_texture_size(0) {
}
FeatureInfo::FeatureInfo() {
@@ -198,17 +205,20 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
GL_VENDOR,
GL_RENDERER,
};
+ bool is_intel = false;
+ bool is_nvidia = false;
+ bool is_amd = false;
+ bool is_mesa = false;
for (size_t ii = 0; ii < arraysize(string_ids); ++ii) {
const char* str = reinterpret_cast<const char*>(
glGetString(string_ids[ii]));
if (str) {
std::string lstr(StringToLowerASCII(std::string(str)));
StringSet string_set(lstr);
- feature_flags_.is_intel |= string_set.Contains("intel");
- feature_flags_.is_nvidia |= string_set.Contains("nvidia");
- feature_flags_.is_amd |=
- string_set.Contains("amd") || string_set.Contains("ati");
- feature_flags_.is_mesa |= string_set.Contains("mesa");
+ is_intel |= string_set.Contains("intel");
+ is_nvidia |= string_set.Contains("nvidia");
+ is_amd |= string_set.Contains("amd") || string_set.Contains("ati");
+ is_mesa |= string_set.Contains("mesa");
}
}
@@ -351,7 +361,7 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
if (ext.Have("GL_OES_vertex_array_object") ||
ext.Have("GL_ARB_vertex_array_object") ||
ext.Have("GL_APPLE_vertex_array_object")) {
- feature_flags_.native_vertex_array_object_ = true;
+ feature_flags_.native_vertex_array_object = true;
}
// OES_vertex_array_object is emulated if not present natively,
@@ -607,7 +617,7 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
#if defined(OS_LINUX)
if (!feature_flags_.disable_workarounds) {
// Intel drivers on Linux appear to be buggy.
- ext_occlusion_query_disallowed = feature_flags_.is_intel;
+ ext_occlusion_query_disallowed = is_intel;
}
#endif
@@ -636,6 +646,47 @@ void FeatureInfo::AddFeatures(const char* desired_features) {
if (!disallowed_features_.swap_buffer_complete_callback)
AddExtensionString("GL_CHROMIUM_swapbuffers_complete_callback");
+
+ if (!feature_flags_.disable_workarounds) {
+ workarounds_.set_texture_filter_before_generating_mipmap = true;
+ workarounds_.clear_alpha_in_readpixels = true;
+
+ if (is_nvidia) {
+ workarounds_.use_current_program_after_successful_link = true;
+ }
+
+#if defined(OS_MACOSX)
+ workarounds_.needs_offscreen_buffer_workaround = is_nvidia;
+ workarounds_.needs_glsl_built_in_function_emulation = is_amd;
+
+ if ((is_amd || is_intel) &&
+ gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGL) {
+ workarounds_.reverse_point_sprite_coord_origin = true;
+ }
+
+ // Limit Intel on Mac to 4096 max tex size and 1024 max cube map tex size.
+ // Limit AMD on Mac to 4096 max tex size and max cube map tex size.
+ // TODO(gman): Update this code to check for a specific version of
+ // the drivers above which we no longer need this fix.
+ if (is_intel) {
+ workarounds_.max_texture_size = 4096;
+ workarounds_.max_cube_map_texture_size = 1024;
+ // Cubemaps > 512 in size were broken before 10.7.3.
+ int32 major = 0;
+ int32 minor = 0;
+ int32 bugfix = 0;
+ base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix);
+ if (major < 10 ||
+ (major == 10 && ((minor == 7 && bugfix < 3) || (minor < 7))))
+ workarounds_.max_cube_map_texture_size = 512;
+ }
+
+ if (is_amd) {
+ workarounds_.max_texture_size = 4096;
+ workarounds_.max_cube_map_texture_size = 4096;
+ }
+#endif
+ }
}
void FeatureInfo::AddExtensionString(const std::string& str) {
diff --git a/gpu/command_buffer/service/feature_info.h b/gpu/command_buffer/service/feature_info.h
index 2f3268d..076264e 100644
--- a/gpu/command_buffer/service/feature_info.h
+++ b/gpu/command_buffer/service/feature_info.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/hash_tables.h"
#include "base/memory/ref_counted.h"
+#include "base/sys_info.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/gles2_cmd_validation.h"
#include "gpu/gpu_export.h"
@@ -38,12 +39,24 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
bool occlusion_query_boolean;
bool use_arb_occlusion_query2_for_occlusion_query_boolean;
bool use_arb_occlusion_query_for_occlusion_query_boolean;
- bool native_vertex_array_object_;
+ bool native_vertex_array_object;
bool disable_workarounds;
- bool is_intel;
- bool is_nvidia;
- bool is_amd;
- bool is_mesa;
+ };
+
+ struct Workarounds {
+ Workarounds();
+
+ bool clear_alpha_in_readpixels;
+ bool clear_uniforms_before_program_use;
+ bool needs_glsl_built_in_function_emulation;
+ bool needs_offscreen_buffer_workaround;
+ bool reverse_point_sprite_coord_origin;
+ bool set_texture_filter_before_generating_mipmap;
+ bool use_current_program_after_successful_link;
+
+ // Note: 0 here means use driver limit.
+ GLint max_texture_size;
+ GLint max_cube_map_texture_size;
};
FeatureInfo();
@@ -74,6 +87,10 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
return feature_flags_;
}
+ const Workarounds& workarounds() const {
+ return workarounds_;
+ }
+
private:
friend class base::RefCounted<FeatureInfo>;
@@ -94,6 +111,9 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
// Flags for some features
FeatureFlags feature_flags_;
+ // Flags for Workarounds.
+ Workarounds workarounds_;
+
DISALLOW_COPY_AND_ASSIGN(FeatureInfo);
};
diff --git a/gpu/command_buffer/service/feature_info_unittest.cc b/gpu/command_buffer/service/feature_info_unittest.cc
index 3510c70..3ec10c0 100644
--- a/gpu/command_buffer/service/feature_info_unittest.cc
+++ b/gpu/command_buffer/service/feature_info_unittest.cc
@@ -89,11 +89,13 @@ TEST_F(FeatureInfoTest, Basic) {
).use_arb_occlusion_query2_for_occlusion_query_boolean);
EXPECT_FALSE(info_->feature_flags(
).use_arb_occlusion_query_for_occlusion_query_boolean);
- EXPECT_FALSE(info_->feature_flags().native_vertex_array_object_);
- EXPECT_FALSE(info_->feature_flags().is_intel);
- EXPECT_FALSE(info_->feature_flags().is_nvidia);
- EXPECT_FALSE(info_->feature_flags().is_amd);
- EXPECT_FALSE(info_->feature_flags().is_mesa);
+ EXPECT_FALSE(info_->feature_flags().native_vertex_array_object);
+ EXPECT_FALSE(info_->workarounds().reverse_point_sprite_coord_origin);
+ EXPECT_FALSE(
+ info_->workarounds().set_texture_filter_before_generating_mipmap);
+ EXPECT_FALSE(info_->workarounds().clear_alpha_in_readpixels);
+ EXPECT_EQ(0, info_->workarounds().max_texture_size);
+ EXPECT_EQ(0, info_->workarounds().max_cube_map_texture_size);
// Test good types.
{
@@ -769,7 +771,7 @@ TEST_F(FeatureInfoTest, InitializeOES_vertex_array_object) {
info_->Initialize(NULL);
EXPECT_THAT(info_->extensions(),
HasSubstr("GL_OES_vertex_array_object"));
- EXPECT_TRUE(info_->feature_flags().native_vertex_array_object_);
+ EXPECT_TRUE(info_->feature_flags().native_vertex_array_object);
}
TEST_F(FeatureInfoTest, InitializeARB_vertex_array_object) {
@@ -777,7 +779,7 @@ TEST_F(FeatureInfoTest, InitializeARB_vertex_array_object) {
info_->Initialize(NULL);
EXPECT_THAT(info_->extensions(),
HasSubstr("GL_OES_vertex_array_object"));
- EXPECT_TRUE(info_->feature_flags().native_vertex_array_object_);
+ EXPECT_TRUE(info_->feature_flags().native_vertex_array_object);
}
TEST_F(FeatureInfoTest, InitializeAPPLE_vertex_array_object) {
@@ -785,7 +787,7 @@ TEST_F(FeatureInfoTest, InitializeAPPLE_vertex_array_object) {
info_->Initialize(NULL);
EXPECT_THAT(info_->extensions(),
HasSubstr("GL_OES_vertex_array_object"));
- EXPECT_TRUE(info_->feature_flags().native_vertex_array_object_);
+ EXPECT_TRUE(info_->feature_flags().native_vertex_array_object);
}
TEST_F(FeatureInfoTest, InitializeNo_vertex_array_object) {
@@ -796,7 +798,7 @@ TEST_F(FeatureInfoTest, InitializeNo_vertex_array_object) {
// scenario native_vertex_array_object must be false.
EXPECT_THAT(info_->extensions(),
HasSubstr("GL_OES_vertex_array_object"));
- EXPECT_FALSE(info_->feature_flags().native_vertex_array_object_);
+ EXPECT_FALSE(info_->feature_flags().native_vertex_array_object);
}
TEST_F(FeatureInfoTest, InitializeOES_element_index_uint) {
@@ -807,102 +809,5 @@ TEST_F(FeatureInfoTest, InitializeOES_element_index_uint) {
EXPECT_TRUE(info_->validators()->index_type.IsValid(GL_UNSIGNED_INT));
}
-TEST_F(FeatureInfoTest, IsIntel) {
- SetupInitExpectationsWithVendor("", "iNTel", "");
- info_->Initialize(NULL);
- EXPECT_TRUE(info_->feature_flags().is_intel);
- EXPECT_FALSE(info_->feature_flags().is_nvidia);
- EXPECT_FALSE(info_->feature_flags().is_amd);
- EXPECT_FALSE(info_->feature_flags().is_mesa);
-
- SetupInitExpectationsWithVendor("", "", "IntEl");
- FeatureInfo::Ref feature_info(new FeatureInfo());
- feature_info->Initialize(NULL);
- EXPECT_TRUE(feature_info->feature_flags().is_intel);
- EXPECT_FALSE(feature_info->feature_flags().is_nvidia);
- EXPECT_FALSE(feature_info->feature_flags().is_amd);
- EXPECT_FALSE(info_->feature_flags().is_mesa);
-}
-
-TEST_F(FeatureInfoTest, IsNvidia) {
- SetupInitExpectationsWithVendor("", "nvIdIa", "");
- info_->Initialize(NULL);
- EXPECT_FALSE(info_->feature_flags().is_intel);
- EXPECT_TRUE(info_->feature_flags().is_nvidia);
- EXPECT_FALSE(info_->feature_flags().is_amd);
- EXPECT_FALSE(info_->feature_flags().is_mesa);
-
- SetupInitExpectationsWithVendor("", "", "NViDiA");
- {
- FeatureInfo::Ref feature_info(new FeatureInfo());
- feature_info->Initialize(NULL);
- EXPECT_FALSE(feature_info->feature_flags().is_intel);
- EXPECT_TRUE(feature_info->feature_flags().is_nvidia);
- EXPECT_FALSE(feature_info->feature_flags().is_amd);
- EXPECT_FALSE(feature_info->feature_flags().is_mesa);
- }
-
- SetupInitExpectationsWithVendor("", "NVIDIA Corporation", "");
- {
- FeatureInfo::Ref feature_info(new FeatureInfo());
- feature_info->Initialize(NULL);
- EXPECT_FALSE(feature_info->feature_flags().is_intel);
- EXPECT_TRUE(feature_info->feature_flags().is_nvidia);
- EXPECT_FALSE(feature_info->feature_flags().is_amd);
- EXPECT_FALSE(feature_info->feature_flags().is_mesa);
- }
-}
-
-TEST_F(FeatureInfoTest, IsAMD) {
- SetupInitExpectationsWithVendor("", "aMd", "");
- info_->Initialize(NULL);
- EXPECT_FALSE(info_->feature_flags().is_intel);
- EXPECT_FALSE(info_->feature_flags().is_nvidia);
- EXPECT_TRUE(info_->feature_flags().is_amd);
- EXPECT_FALSE(info_->feature_flags().is_mesa);
-
- SetupInitExpectationsWithVendor("", "", "AmD");
- FeatureInfo::Ref feature_info(new FeatureInfo());
- feature_info->Initialize(NULL);
- EXPECT_FALSE(feature_info->feature_flags().is_intel);
- EXPECT_FALSE(feature_info->feature_flags().is_nvidia);
- EXPECT_TRUE(feature_info->feature_flags().is_amd);
- EXPECT_FALSE(feature_info->feature_flags().is_mesa);
-}
-
-TEST_F(FeatureInfoTest, IsAMDATI) {
- SetupInitExpectationsWithVendor("", "aTI", "");
- info_->Initialize(NULL);
- EXPECT_FALSE(info_->feature_flags().is_intel);
- EXPECT_FALSE(info_->feature_flags().is_nvidia);
- EXPECT_TRUE(info_->feature_flags().is_amd);
- EXPECT_FALSE(info_->feature_flags().is_mesa);
-
- SetupInitExpectationsWithVendor("", "", "AtI");
- FeatureInfo::Ref feature_info(new FeatureInfo());
- feature_info->Initialize(NULL);
- EXPECT_FALSE(feature_info->feature_flags().is_intel);
- EXPECT_FALSE(feature_info->feature_flags().is_nvidia);
- EXPECT_TRUE(feature_info->feature_flags().is_amd);
- EXPECT_FALSE(feature_info->feature_flags().is_mesa);
-}
-
-TEST_F(FeatureInfoTest, IsMesa) {
- SetupInitExpectationsWithVendor("", "MesA", "");
- info_->Initialize(NULL);
- EXPECT_FALSE(info_->feature_flags().is_intel);
- EXPECT_FALSE(info_->feature_flags().is_nvidia);
- EXPECT_FALSE(info_->feature_flags().is_amd);
- EXPECT_TRUE(info_->feature_flags().is_mesa);
-
- SetupInitExpectationsWithVendor("", "", "meSa");
- FeatureInfo::Ref feature_info(new FeatureInfo());
- feature_info->Initialize(NULL);
- EXPECT_FALSE(feature_info->feature_flags().is_intel);
- EXPECT_FALSE(feature_info->feature_flags().is_nvidia);
- EXPECT_FALSE(feature_info->feature_flags().is_amd);
- EXPECT_TRUE(feature_info->feature_flags().is_mesa);
-}
-
} // namespace gles2
} // namespace gpu
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 3504c8c..63bf1cc 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -1386,6 +1386,14 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
void PerformanceWarning(const std::string& msg);
const std::string& GetLogPrefix() const;
+ const FeatureInfo::FeatureFlags& features() const {
+ return feature_info_->feature_flags();
+ }
+
+ const FeatureInfo::Workarounds& workarounds() const {
+ return feature_info_->workarounds();
+ }
+
bool ShouldDeferDraws() {
return !offscreen_target_frame_buffer_.get() &&
state_.bound_draw_framebuffer == NULL &&
@@ -1532,9 +1540,6 @@ class GLES2DecoderImpl : public base::SupportsWeakPtr<GLES2DecoderImpl>,
bool has_robustness_extension_;
GLenum reset_status_;
- bool needs_mac_nvidia_driver_workaround_;
- bool needs_glsl_built_in_function_emulation_;
-
// These flags are used to override the state of the shared feature_info_
// member. Because the same FeatureInfo instance may be shared among many
// contexts, the assumptions on the availablity of extensions in WebGL
@@ -1937,8 +1942,6 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
frame_number_(0),
has_robustness_extension_(false),
reset_status_(GL_NO_ERROR),
- needs_mac_nvidia_driver_workaround_(false),
- needs_glsl_built_in_function_emulation_(false),
force_webgl_glsl_validation_(false),
derivatives_explicitly_enabled_(false),
compile_shader_always_succeeds_(false),
@@ -1961,8 +1964,7 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group)
// empty string to CompileShader and this is not a valid shader.
// TODO(apatrick): fix this test.
if ((gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 &&
- !feature_info_->feature_flags().chromium_webglsl &&
- !force_webgl_glsl_validation_) ||
+ !features().chromium_webglsl && !force_webgl_glsl_validation_) ||
gfx::GetGLImplementation() == gfx::kGLImplementationMockGL ||
CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableGLSLTranslator)) {
@@ -2049,12 +2051,12 @@ bool GLES2DecoderImpl::Initialize(
glActiveTexture(GL_TEXTURE0 + tt);
// We want the last bind to be 2D.
TextureManager::TextureInfo* info;
- if (feature_info_->feature_flags().oes_egl_image_external) {
+ if (features().oes_egl_image_external) {
info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_EXTERNAL_OES);
state_.texture_units[tt].bound_texture_external_oes = info;
glBindTexture(GL_TEXTURE_EXTERNAL_OES, info->service_id());
}
- if (feature_info_->feature_flags().arb_texture_rectangle) {
+ if (features().arb_texture_rectangle) {
info = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_RECTANGLE_ARB);
state_.texture_units[tt].bound_texture_rectangle_arb = info;
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, info->service_id());
@@ -2227,15 +2229,6 @@ bool GLES2DecoderImpl::Initialize(
context->HasExtension("GL_ARB_robustness") ||
context->HasExtension("GL_EXT_robustness");
- if (!feature_info_->feature_flags().disable_workarounds) {
-#if defined(OS_MACOSX)
- needs_mac_nvidia_driver_workaround_ =
- feature_info_->feature_flags().is_nvidia;
- needs_glsl_built_in_function_emulation_ =
- feature_info_->feature_flags().is_amd;
-#endif
- }
-
if (!InitializeShaderTranslator()) {
return false;
}
@@ -2299,14 +2292,9 @@ bool GLES2DecoderImpl::Initialize(
// AMD and Intel drivers on Mac OS apparently get gl_PointCoord
// backward from the spec and this setting makes them work
// correctly. rdar://problem/11883495
-#if defined(OS_MACOSX)
- if (!feature_info_->feature_flags().disable_workarounds &&
- (feature_info_->feature_flags().is_amd ||
- feature_info_->feature_flags().is_intel) &&
- gfx::GetGLImplementation() == gfx::kGLImplementationDesktopGL) {
+ if (feature_info_->workarounds().reverse_point_sprite_coord_origin) {
glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT);
}
-#endif
return true;
}
@@ -2323,8 +2311,7 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() {
// Re-check the state of use_shader_translator_ each time this is called.
if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 &&
- (feature_info_->feature_flags().chromium_webglsl ||
- force_webgl_glsl_validation_) &&
+ (features().chromium_webglsl || force_webgl_glsl_validation_) &&
!use_shader_translator_) {
use_shader_translator_ = true;
}
@@ -2349,21 +2336,20 @@ bool GLES2DecoderImpl::InitializeShaderTranslator() {
resources.OES_standard_derivatives = derivatives_explicitly_enabled_;
} else {
resources.OES_standard_derivatives =
- feature_info_->feature_flags().oes_standard_derivatives ? 1 : 0;
+ features().oes_standard_derivatives ? 1 : 0;
resources.ARB_texture_rectangle =
- feature_info_->feature_flags().arb_texture_rectangle ? 1 : 0;
+ features().arb_texture_rectangle ? 1 : 0;
resources.OES_EGL_image_external =
- feature_info_->feature_flags().oes_egl_image_external ? 1 : 0;
+ features().oes_egl_image_external ? 1 : 0;
}
ShShaderSpec shader_spec = force_webgl_glsl_validation_ ||
- feature_info_->feature_flags().chromium_webglsl ?
- SH_WEBGL_SPEC : SH_GLES2_SPEC;
+ features().chromium_webglsl ? SH_WEBGL_SPEC : SH_GLES2_SPEC;
ShaderTranslatorInterface::GlslImplementationType implementation_type =
gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ?
ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl;
ShaderTranslatorInterface::GlslBuiltInFunctionBehavior function_behavior =
- needs_glsl_built_in_function_emulation_ ?
+ workarounds().needs_glsl_built_in_function_emulation ?
ShaderTranslatorInterface::kGlslBuiltInFunctionEmulated :
ShaderTranslatorInterface::kGlslBuiltInFunctionOriginal;
@@ -2463,7 +2449,7 @@ void GLES2DecoderImpl::DeleteBuffersHelper(
void GLES2DecoderImpl::DeleteFramebuffersHelper(
GLsizei n, const GLuint* client_ids) {
bool supports_separate_framebuffer_binds =
- feature_info_->feature_flags().chromium_framebuffer_multisample;
+ features().chromium_framebuffer_multisample;
for (GLsizei ii = 0; ii < n; ++ii) {
FramebufferManager::FramebufferInfo* framebuffer =
@@ -2490,7 +2476,7 @@ void GLES2DecoderImpl::DeleteFramebuffersHelper(
void GLES2DecoderImpl::DeleteRenderbuffersHelper(
GLsizei n, const GLuint* client_ids) {
bool supports_separate_framebuffer_binds =
- feature_info_->feature_flags().chromium_framebuffer_multisample;
+ features().chromium_framebuffer_multisample;
for (GLsizei ii = 0; ii < n; ++ii) {
RenderbufferManager::RenderbufferInfo* renderbuffer =
GetRenderbufferInfo(client_ids[ii]);
@@ -2523,7 +2509,7 @@ void GLES2DecoderImpl::DeleteRenderbuffersHelper(
void GLES2DecoderImpl::DeleteTexturesHelper(
GLsizei n, const GLuint* client_ids) {
bool supports_separate_framebuffer_binds =
- feature_info_->feature_flags().chromium_framebuffer_multisample;
+ features().chromium_framebuffer_multisample;
for (GLsizei ii = 0; ii < n; ++ii) {
TextureManager::TextureInfo* texture = GetTextureInfo(client_ids[ii]);
if (texture && !texture->IsDeleted()) {
@@ -2605,7 +2591,7 @@ static void RebindCurrentFramebuffer(
void GLES2DecoderImpl::RestoreCurrentFramebufferBindings() {
state_dirty_ = true;
- if (!feature_info_->feature_flags().chromium_framebuffer_multisample) {
+ if (!features().chromium_framebuffer_multisample) {
RebindCurrentFramebuffer(
GL_FRAMEBUFFER,
state_.bound_draw_framebuffer.get(),
@@ -2684,7 +2670,7 @@ bool GLES2DecoderImpl::CheckFramebufferValid(
}
bool GLES2DecoderImpl::CheckBoundFramebuffersValid(const char* func_name) {
- if (!feature_info_->feature_flags().chromium_framebuffer_multisample) {
+ if (!features().chromium_framebuffer_multisample) {
return CheckFramebufferValid(
state_.bound_draw_framebuffer, GL_FRAMEBUFFER_EXT, func_name);
}
@@ -3586,11 +3572,11 @@ void GLES2DecoderImpl::DoGenerateMipmap(GLenum target) {
// to be that if the filtering mode is set to something that doesn't require
// mipmaps for rendering, or is never set to something other than the default,
// then glGenerateMipmap misbehaves.
- if (!feature_info_->feature_flags().disable_workarounds) {
+ if (workarounds().set_texture_filter_before_generating_mipmap) {
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
}
glGenerateMipmapEXT(target);
- if (!feature_info_->feature_flags().disable_workarounds) {
+ if (workarounds().set_texture_filter_before_generating_mipmap) {
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, info->min_filter());
}
GLenum error = PeekGLError();
@@ -4605,7 +4591,7 @@ void GLES2DecoderImpl::DoBlitFramebufferEXT(
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter) {
- if (!feature_info_->feature_flags().chromium_framebuffer_multisample) {
+ if (!features().chromium_framebuffer_multisample) {
SetGLError(GL_INVALID_OPERATION,
"glBlitFramebufferEXT", "function not available");
}
@@ -4622,7 +4608,7 @@ void GLES2DecoderImpl::DoBlitFramebufferEXT(
void GLES2DecoderImpl::DoRenderbufferStorageMultisample(
GLenum target, GLsizei samples, GLenum internalformat,
GLsizei width, GLsizei height) {
- if (!feature_info_->feature_flags().chromium_framebuffer_multisample) {
+ if (!features().chromium_framebuffer_multisample) {
SetGLError(GL_INVALID_OPERATION,
"glRenderbufferStorageMultisampleEXT", "function not available");
return;
@@ -4747,12 +4733,10 @@ void GLES2DecoderImpl::DoLinkProgram(GLuint program) {
fragment_translator,
feature_info_)) {
if (info == state_.current_program.get()) {
- if (!feature_info_->feature_flags().disable_workarounds) {
- if (feature_info_->feature_flags().is_nvidia) {
- glUseProgram(info->service_id());
- }
- program_manager()->ClearUniforms(info);
+ if (workarounds().use_current_program_after_successful_link) {
+ glUseProgram(info->service_id());
}
+ program_manager()->ClearUniforms(info);
}
}
};
@@ -5663,7 +5647,7 @@ error::Error GLES2DecoderImpl::HandleDrawArrays(
error::Error GLES2DecoderImpl::HandleDrawArraysInstancedANGLE(
uint32 immediate_data_size, const gles2::DrawArraysInstancedANGLE& c) {
- if (!feature_info_->feature_flags().angle_instanced_arrays) {
+ if (!features().angle_instanced_arrays) {
SetGLError(GL_INVALID_OPERATION,
"glDrawArraysInstancedANGLE", "function not available");
return error::kNoError;
@@ -5783,7 +5767,7 @@ error::Error GLES2DecoderImpl::HandleDrawElements(
error::Error GLES2DecoderImpl::HandleDrawElementsInstancedANGLE(
uint32 immediate_data_size, const gles2::DrawElementsInstancedANGLE& c) {
- if (!feature_info_->feature_flags().angle_instanced_arrays) {
+ if (!features().angle_instanced_arrays) {
SetGLError(GL_INVALID_OPERATION,
"glDrawElementsInstancedANGLE", "function not available");
return error::kNoError;
@@ -6376,7 +6360,7 @@ void GLES2DecoderImpl::DoViewport(GLint x, GLint y, GLsizei width,
error::Error GLES2DecoderImpl::HandleVertexAttribDivisorANGLE(
uint32 immediate_data_size, const gles2::VertexAttribDivisorANGLE& c) {
- if (!feature_info_->feature_flags().angle_instanced_arrays) {
+ if (!features().angle_instanced_arrays) {
SetGLError(GL_INVALID_OPERATION,
"glVertexAttribDivisorANGLE", "function not available");
}
@@ -6502,7 +6486,7 @@ error::Error GLES2DecoderImpl::HandleReadPixels(
GLenum read_format = GetBoundReadFrameBufferInternalFormat();
uint32 channels_exist = GLES2Util::GetChannelsForFormat(read_format);
if ((channels_exist & 0x0008) == 0 &&
- !feature_info_->feature_flags().disable_workarounds) {
+ workarounds().clear_alpha_in_readpixels) {
// Set the alpha to 255 because some drivers are buggy in this regard.
uint32 temp_size;
@@ -8303,7 +8287,7 @@ error::Error GLES2DecoderImpl::HandleSwapBuffers(
// Workaround for NVIDIA driver bug on OS X; crbug.com/89557,
// crbug.com/94163. TODO(kbr): figure out reproduction so Apple will
// fix this.
- if (needs_mac_nvidia_driver_workaround_) {
+ if (workarounds().needs_offscreen_buffer_workaround) {
offscreen_saved_frame_buffer_->Create();
glFinish();
}
@@ -8451,10 +8435,8 @@ error::Error GLES2DecoderImpl::HandleRequestExtensionCHROMIUM(
return error::kInvalidArguments;
}
- bool std_derivatives_enabled =
- feature_info_->feature_flags().oes_standard_derivatives;
- bool webglsl_enabled =
- feature_info_->feature_flags().chromium_webglsl;
+ bool std_derivatives_enabled = features().oes_standard_derivatives;
+ bool webglsl_enabled = features().chromium_webglsl;
feature_info_->AddFeatures(feature_str.c_str());
@@ -8469,10 +8451,8 @@ error::Error GLES2DecoderImpl::HandleRequestExtensionCHROMIUM(
// If we just enabled a feature which affects the shader translator,
// we may need to re-initialize it.
- if (std_derivatives_enabled !=
- feature_info_->feature_flags().oes_standard_derivatives ||
- webglsl_enabled !=
- feature_info_->feature_flags().chromium_webglsl ||
+ if (std_derivatives_enabled != features().oes_standard_derivatives ||
+ webglsl_enabled != features().chromium_webglsl ||
initialization_required) {
InitializeShaderTranslator();
}
@@ -8655,7 +8635,7 @@ error::Error GLES2DecoderImpl::HandleBeginQueryEXT(
case GL_LATENCY_QUERY_CHROMIUM:
break;
default:
- if (!feature_info_->feature_flags().occlusion_query_boolean) {
+ if (!features().occlusion_query_boolean) {
SetGLError(GL_INVALID_OPERATION, "glBeginQueryEXT", "not enabled");
return error::kNoError;
}
@@ -8745,7 +8725,7 @@ bool GLES2DecoderImpl::GenVertexArraysOESHelper(
}
}
- if (!feature_info_->feature_flags().native_vertex_array_object_) {
+ if (!features().native_vertex_array_object) {
// Emulated VAO
for (GLsizei ii = 0; ii < n; ++ii) {
CreateVertexAttribManager(client_ids[ii], 0);
@@ -8800,7 +8780,7 @@ void GLES2DecoderImpl::DoBindVertexArrayOES(GLuint client_id) {
// Only set the VAO state if it's changed
if (state_.vertex_attrib_manager != vao) {
state_.vertex_attrib_manager = vao;
- if (!feature_info_->feature_flags().native_vertex_array_object_) {
+ if (!features().native_vertex_array_object) {
EmulateVertexArrayState();
} else {
glBindVertexArrayOES(service_id);
@@ -8831,7 +8811,7 @@ bool GLES2DecoderImpl::DoIsVertexArrayOES(GLuint client_id) {
error::Error GLES2DecoderImpl::HandleCreateStreamTextureCHROMIUM(
uint32 immediate_data_size,
const gles2::CreateStreamTextureCHROMIUM& c) {
- if (!feature_info_->feature_flags().chromium_stream_texture) {
+ if (!features().chromium_stream_texture) {
SetGLError(GL_INVALID_OPERATION,
"glOpenStreamTextureCHROMIUM", ""
"not supported.");
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
index f8a77d1..34e8eb6 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
@@ -986,7 +986,7 @@ void GLES2DecoderTestBase::DoVertexAttribDivisorANGLE(
}
void GLES2DecoderTestBase::AddExpectationsForGenVertexArraysOES(){
- if (group_->feature_info()->feature_flags().native_vertex_array_object_) {
+ if (group_->feature_info()->feature_flags().native_vertex_array_object) {
EXPECT_CALL(*gl_, GenVertexArraysOES(1, _))
.WillOnce(SetArgumentPointee<1>(kServiceVertexArrayId))
.RetiresOnSaturation();
@@ -994,7 +994,7 @@ void GLES2DecoderTestBase::AddExpectationsForGenVertexArraysOES(){
}
void GLES2DecoderTestBase::AddExpectationsForDeleteVertexArraysOES(){
- if (group_->feature_info()->feature_flags().native_vertex_array_object_) {
+ if (group_->feature_info()->feature_flags().native_vertex_array_object) {
EXPECT_CALL(*gl_, DeleteVertexArraysOES(1, _))
.Times(1)
.RetiresOnSaturation();
@@ -1002,7 +1002,7 @@ void GLES2DecoderTestBase::AddExpectationsForDeleteVertexArraysOES(){
}
void GLES2DecoderTestBase::AddExpectationsForBindVertexArrayOES() {
- if (group_->feature_info()->feature_flags().native_vertex_array_object_) {
+ if (group_->feature_info()->feature_flags().native_vertex_array_object) {
EXPECT_CALL(*gl_, BindVertexArrayOES(_))
.Times(1)
.RetiresOnSaturation();