Commit 57241698 authored by zmo@chromium.org's avatar zmo@chromium.org

Hookup driver_bug_workarounds with gl_tests properly.

Get rid of the code duplication of driver_bug_workarounds, i.e., get rid of the hardwired workarounds.

Then apply the workarounds from json file to gl_tests.

BUG=
TEST=gl_tests,gpu_unittests
R=gman@chromium.org

Review URL: https://chromiumcodereview.appspot.com/16159004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202682 0039d316-1c4b-4281-b951-d872f2087c98
parent f4193889
......@@ -180,78 +180,6 @@ void FeatureInfo::AddFeatures(const CommandLine& command_line) {
StringSet extensions(
reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)));
// This is a temporary fix to turn gl_tests green on Linux and Android bots.
// Once we migrate blacklisting stuff from src/content to src/gpu, we can
// get the workarounds from json file. Then we should remove this block.
// See crbug.com/228979.
bool is_intel = false;
bool is_nvidia = false;
bool is_amd = false;
bool is_mesa = false;
bool is_qualcomm = false;
bool is_imagination = false;
bool is_arm = false;
bool is_vivante = false;
const char* gl_strings[2];
gl_strings[0] = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
gl_strings[1] = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
if (!command_line.HasSwitch(switches::kGpuDriverBugWorkarounds) &&
!command_line.HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) {
for (size_t ii = 0; ii < arraysize(gl_strings); ++ii) {
const char* str = gl_strings[ii];
if (str) {
std::string lstr(StringToLowerASCII(std::string(str)));
StringSet string_set(lstr);
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");
is_qualcomm |= string_set.Contains("qualcomm");
is_imagination |= string_set.Contains("imagination");
is_arm |= string_set.Contains("arm");
}
}
if (extensions.Contains("GL_VIV_shader_binary"))
is_vivante = true;
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 (is_qualcomm) {
workarounds_.restore_scissor_on_fbo_change = true;
workarounds_.flush_on_context_switch = true;
workarounds_.delete_instead_of_resize_fbo = true;
}
if (is_vivante || is_imagination) {
workarounds_.unbind_fbo_on_context_switch = 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;
}
if (is_intel) {
workarounds_.max_texture_size = 4096;
workarounds_.max_cube_map_texture_size = 1024;
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
}
if (command_line.HasSwitch(switches::kGpuDriverBugWorkarounds)) {
std::string types = command_line.GetSwitchValueASCII(
switches::kGpuDriverBugWorkarounds);
......@@ -282,8 +210,7 @@ void FeatureInfo::AddFeatures(const CommandLine& command_line) {
AddExtensionString("GL_CHROMIUM_texture_mailbox");
AddExtensionString("GL_EXT_debug_marker");
if (workarounds_.enable_chromium_fast_npot_mo8_textures ||
is_imagination)
if (workarounds_.enable_chromium_fast_npot_mo8_textures)
AddExtensionString("GL_CHROMIUM_fast_NPOT_MO8_textures");
feature_flags_.chromium_stream_texture = true;
......@@ -368,7 +295,7 @@ void FeatureInfo::AddFeatures(const CommandLine& command_line) {
// get rid of it.
//
bool enable_depth_texture = false;
if ((!workarounds_.disable_depth_texture && !is_qualcomm) &&
if (!workarounds_.disable_depth_texture &&
(extensions.Contains("GL_ARB_depth_texture") ||
extensions.Contains("GL_OES_depth_texture") ||
extensions.Contains("GL_ANGLE_depth_texture"))) {
......@@ -405,10 +332,6 @@ void FeatureInfo::AddFeatures(const CommandLine& command_line) {
feature_flags_.native_vertex_array_object = true;
}
if (is_arm || is_imagination) {
workarounds_.use_client_side_arrays_for_stream_buffers = true;
}
// If we're using client_side_arrays we have to emulate
// vertex array objects since vertex array objects do not work
// with client side arrays.
......@@ -529,7 +452,7 @@ void FeatureInfo::AddFeatures(const CommandLine& command_line) {
// Check for multisample support
bool ext_has_multisample =
extensions.Contains("GL_EXT_framebuffer_multisample");
if (!is_qualcomm && !workarounds_.disable_angle_framebuffer_multisample) {
if (!workarounds_.disable_angle_framebuffer_multisample) {
ext_has_multisample |=
extensions.Contains("GL_ANGLE_framebuffer_multisample");
}
......@@ -648,9 +571,6 @@ void FeatureInfo::AddFeatures(const CommandLine& command_line) {
extensions.Contains("GL_ARB_occlusion_query");
if (!workarounds_.disable_ext_occlusion_query &&
#if defined(OS_LINUX)
!is_intel &&
#endif
(have_ext_occlusion_query_boolean ||
have_arb_occlusion_query2 ||
have_arb_occlusion_query)) {
......
......@@ -285,12 +285,6 @@ void TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
EXPECT_CALL(*gl, GetString(GL_EXTENSIONS))
.WillOnce(Return(reinterpret_cast<const uint8*>(extensions)))
.RetiresOnSaturation();
EXPECT_CALL(*gl, GetString(GL_VENDOR))
.WillOnce(Return(reinterpret_cast<const uint8*>("")))
.RetiresOnSaturation();
EXPECT_CALL(*gl, GetString(GL_RENDERER))
.WillOnce(Return(reinterpret_cast<const uint8*>("")))
.RetiresOnSaturation();
EXPECT_CALL(*gl, GetString(GL_VERSION))
.WillOnce(Return(reinterpret_cast<const uint8*>(version)))
.RetiresOnSaturation();
......
......@@ -10,6 +10,7 @@
#endif
#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/command_buffer/tests/gl_test_utils.h"
#include "gpu/config/gpu_util.h"
#include "ui/gl/gl_surface.h"
#if defined(OS_ANDROID)
......@@ -36,6 +37,7 @@ int main(int argc, char** argv) {
#endif
gfx::GLSurface::InitializeOneOff();
::gles2::Initialize();
gpu::ApplyGpuDriverBugWorkarounds(CommandLine::ForCurrentProcess());
base::MessageLoop::Type message_loop_type = base::MessageLoop::TYPE_UI;
base::MessageLoop main_message_loop(message_loop_type);
return GLTestHelper::RunTests(argc, argv);
......
......@@ -6,11 +6,33 @@
#include <vector>
#include "base/command_line.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "gpu/command_buffer/service/gpu_switches.h"
#include "gpu/config/gpu_control_list_jsons.h"
#include "gpu/config/gpu_driver_bug_list.h"
#include "gpu/config/gpu_info_collector.h"
#include "ui/gl/gl_switches.h"
namespace gpu {
namespace {
// Combine the integers into a string, seperated by ','.
std::string IntSetToString(const std::set<int>& list) {
std::string rt;
for (std::set<int>::const_iterator it = list.begin();
it != list.end(); ++it) {
if (!rt.empty())
rt += ",";
rt += base::IntToString(*it);
}
return rt;
}
} // namespace anonymous
GpuSwitchingOption StringToGpuSwitchingOption(
const std::string& switching_string) {
if (switching_string == switches::kGpuSwitchingOptionNameAutomatic)
......@@ -42,4 +64,19 @@ void MergeFeatureSets(std::set<int>* dst, const std::set<int>& src) {
dst->insert(src.begin(), src.end());
}
void ApplyGpuDriverBugWorkarounds(CommandLine* command_line) {
GPUInfo gpu_info;
CollectBasicGraphicsInfo(&gpu_info);
GpuDriverBugList* list = GpuDriverBugList::Create();
list->LoadList("0", kGpuDriverBugListJson,
GpuControlList::kCurrentOsOnly);
std::set<int> workarounds = list->MakeDecision(
GpuControlList::kOsAny, std::string(), gpu_info);
if (!workarounds.empty()) {
command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds,
IntSetToString(workarounds));
}
}
} // namespace gpu
......@@ -12,6 +12,8 @@
#include "gpu/config/gpu_switching_option.h"
#include "gpu/gpu_export.h"
class CommandLine;
namespace gpu {
// Maps string to GpuSwitchingOption; returns GPU_SWITCHING_UNKNOWN if an
......@@ -26,6 +28,10 @@ GPU_EXPORT std::string GpuSwitchingOptionToString(GpuSwitchingOption option);
GPU_EXPORT void MergeFeatureSets(
std::set<int>* dst, const std::set<int>& src);
// Collect basic GPUInfo, compute the driver bug workarounds for the current
// system, and append the |command_line|.
GPU_EXPORT void ApplyGpuDriverBugWorkarounds(CommandLine* command_line);
} // namespace gpu
#endif // GPU_CONFIG_GPU_UTIL_H_
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment