Skip to content

Commit

Permalink
Wire GpuFeatureInfo correctly for gles2_conform.
Browse files Browse the repository at this point in the history
This is the last use case of ApplyGpuDriverBugWorkarounds(), so get rid of it.

BUG=744658
TEST=gles2_conform,gpu_unittests
R=piman@chromium.org

Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I43a158c7fa7703cceb745336a0d27a119d75772c
Reviewed-on: https://chromium-review.googlesource.com/636348
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#497624}
  • Loading branch information
zhenyao authored and Commit Bot committed Aug 26, 2017
1 parent 06e534e commit 339b065
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 75 deletions.
39 changes: 0 additions & 39 deletions gpu/config/gpu_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,45 +92,6 @@ std::string IntSetToString(const std::set<int>& list, char divider) {
return rt;
}

void ApplyGpuDriverBugWorkarounds(const GPUInfo& gpu_info,
base::CommandLine* command_line) {
std::unique_ptr<GpuDriverBugList> list(GpuDriverBugList::Create());
std::set<int> workarounds = list->MakeDecision(
GpuControlList::kOsAny, std::string(), gpu_info);
GpuDriverBugList::AppendWorkaroundsFromCommandLine(
&workarounds, *command_line);
if (!workarounds.empty()) {
command_line->AppendSwitchASCII(switches::kGpuDriverBugWorkarounds,
IntSetToString(workarounds, ','));
}

std::vector<std::string> buglist_disabled_extensions =
list->GetDisabledExtensions();
std::set<base::StringPiece> disabled_extensions(
buglist_disabled_extensions.begin(), buglist_disabled_extensions.end());

// Must be outside if statement to remain in scope (referenced by
// |disabled_extensions|).
std::string command_line_disable_gl_extensions;
if (command_line->HasSwitch(switches::kDisableGLExtensions)) {
command_line_disable_gl_extensions =
command_line->GetSwitchValueASCII(switches::kDisableGLExtensions);
std::vector<base::StringPiece> existing_disabled_extensions =
base::SplitStringPiece(command_line_disable_gl_extensions, " ",
base::TRIM_WHITESPACE,
base::SPLIT_WANT_NONEMPTY);
disabled_extensions.insert(existing_disabled_extensions.begin(),
existing_disabled_extensions.end());
}

if (!disabled_extensions.empty()) {
std::vector<base::StringPiece> v(disabled_extensions.begin(),
disabled_extensions.end());
command_line->AppendSwitchASCII(switches::kDisableGLExtensions,
base::JoinString(v, " "));
}
}

void StringToFeatureSet(
const std::string& str, std::set<int>* feature_set) {
StringToIntSet(str, feature_set);
Expand Down
6 changes: 0 additions & 6 deletions gpu/config/gpu_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ namespace gpu {

struct GPUInfo;

// With provided GPUInfo, compute the driver bug workarounds and disabled
// extensions for the current system, and append the |command_line|.
GPU_EXPORT void ApplyGpuDriverBugWorkarounds(
const GPUInfo& gpu_info,
base::CommandLine* command_line);

// |str| is in the format of "feature1,feature2,...,featureN".
GPU_EXPORT void StringToFeatureSet(
const std::string& str, std::set<int>* feature_set);
Expand Down
28 changes: 1 addition & 27 deletions gpu/config/gpu_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@

#include "gpu/config/gpu_util.h"

#include <memory>

#include "base/strings/string_split.h"
#include "base/command_line.h"
#include "base/strings/stringprintf.h"
#include "gpu/config/gpu_driver_bug_list.h"
#include "gpu/config/gpu_info.h"
#include "gpu/config/gpu_info_collector.h"
#include "gpu/config/gpu_switches.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_switches.h"

namespace gpu {

Expand All @@ -38,27 +33,6 @@ TEST(GpuUtilTest, StringToFeatureSet) {
}
}

TEST(GpuUtilTest,
ApplyGpuDriverBugWorkarounds_DisabledExtensions) {
GPUInfo gpu_info;
CollectBasicGraphicsInfo(&gpu_info);
std::unique_ptr<GpuDriverBugList> list(GpuDriverBugList::Create());
list->MakeDecision(GpuControlList::kOsAny, std::string(), gpu_info);
std::vector<std::string> expected_disabled_extensions =
list->GetDisabledExtensions();
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
ApplyGpuDriverBugWorkarounds(gpu_info, &command_line);

std::vector<std::string> actual_disabled_extensions = base::SplitString(
command_line.GetSwitchValueASCII(switches::kDisableGLExtensions), ", ;",
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
sort(expected_disabled_extensions.begin(),
expected_disabled_extensions.end());
sort(actual_disabled_extensions.begin(), actual_disabled_extensions.end());

EXPECT_EQ(expected_disabled_extensions, actual_disabled_extensions);
}

TEST(GpuUtilTest, ParseSecondaryGpuDevicesFromCommandLine_Simple) {
base::CommandLine command_line(base::CommandLine::NO_PROGRAM);
command_line.AppendSwitchASCII(switches::kGpuSecondaryVendorIDs, "0x10de");
Expand Down
13 changes: 12 additions & 1 deletion gpu/gles2_conform_support/egl/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,22 @@ const bool kSupportClientSideArrays = true;
}

namespace egl {
// static
gpu::GpuFeatureInfo Context::platform_gpu_feature_info_;

// static
void Context::SetPlatformGpuFeatureInfo(
const gpu::GpuFeatureInfo& gpu_feature_info) {
platform_gpu_feature_info_ = gpu_feature_info;
}

Context::Context(Display* display, const Config* config)
: display_(display),
config_(config),
is_current_in_some_thread_(false),
is_destroyed_(false),
gpu_driver_bug_workarounds_(base::CommandLine::ForCurrentProcess()),
gpu_driver_bug_workarounds_(
platform_gpu_feature_info_.enabled_gpu_driver_bug_workarounds),
translator_cache_(gpu::GpuPreferences()) {}

Context::~Context() {
Expand Down Expand Up @@ -276,6 +286,7 @@ bool Context::CreateService(gl::GLSurface* gl_surface) {
gl::init::CreateGLContext(nullptr, gl_surface, context_attribs));
if (!gl_context)
return false;
platform_gpu_feature_info_.ApplyToGLContext(gl_context.get());

gl_context->MakeCurrent(gl_surface);

Expand Down
5 changes: 5 additions & 0 deletions gpu/gles2_conform_support/egl/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ class Context : public base::RefCountedThreadSafe<Context>,
void ApplyCurrentContext(gl::GLSurface* current_surface);
static void ApplyContextReleased();

static void SetPlatformGpuFeatureInfo(
const gpu::GpuFeatureInfo& gpu_feature_info);

private:
friend class base::RefCountedThreadSafe<Context>;
~Context() override;
Expand All @@ -100,6 +103,8 @@ class Context : public base::RefCountedThreadSafe<Context>,
bool IsCompatibleSurface(Surface* surface) const;
bool Flush(gl::GLSurface* gl_surface);

static gpu::GpuFeatureInfo platform_gpu_feature_info_;

Display* display_;
const Config* config_;
bool is_current_in_some_thread_;
Expand Down
9 changes: 7 additions & 2 deletions gpu/gles2_conform_support/egl/thread_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,18 @@ egl::ThreadState* ThreadState::Get() {
// Need to call both Init and InitFromArgv, since Windows does not use
// argc, argv in CommandLine::Init(argc, argv).
command_line->InitFromArgv(argv);
gpu::GpuFeatureInfo gpu_feature_info;
if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) {
gpu::GPUInfo gpu_info;
gpu::CollectBasicGraphicsInfo(&gpu_info);
gpu::ApplyGpuDriverBugWorkarounds(gpu_info, command_line);
gpu_feature_info = gpu::GetGpuFeatureInfo(gpu_info, *command_line);
Context::SetPlatformGpuFeatureInfo(gpu_feature_info);
}

gl::init::InitializeGLOneOff();
gl::init::InitializeGLNoExtensionsOneOff();
gl::init::SetDisabledExtensionsPlatform(
gpu_feature_info.disabled_extensions);
gl::init::InitializeExtensionSettingsOneOffPlatform();
}

g_egl_default_display = new egl::Display();
Expand Down

0 comments on commit 339b065

Please sign in to comment.