Skip to content

Commit

Permalink
Compute GpuDriverBugWorkarounds only one time in the GPU process
Browse files Browse the repository at this point in the history
Previously the extraction of "--gpu-driver-bug-workarounds" from the
command-line was done in FeatureInfo's constructor. Since a new FeatureInfo
is created for each ContextGroup this extraction was done again whereas
the result is constant.

This CL moved owner ship of Workarounds from FeatureInfo to
InProcessCommandBuffer when running in gpu process mode. But moved
to GpuChannelManager otherwise.

class GpuDriverBugWorkarounds has been added within new files
gpu_driver_bug_workarounds.h/.cc.

BUG=599964

R=kbr@chromium.org, piman@chromium.org, rjkroege@chromium.org, zmo@chromium.org
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel;tryserver.chromium.win:win_optional_gpu_tests_rel

Committed: https://crrev.com/dab49af5278797db0a8374f2a7f06c6c33b8158b
Cr-Commit-Position: refs/heads/master@{#387569}

Committed: https://crrev.com/57b96c478dda56160c512fd85ee4e0f7437b524d
Cr-Commit-Position: refs/heads/master@{#387899}

Review URL: https://codereview.chromium.org/1871613002

Cr-Commit-Position: refs/heads/master@{#388157}
  • Loading branch information
JulienIsorce authored and Commit bot committed Apr 19, 2016
1 parent 24d0d5e commit 265b2e5
Show file tree
Hide file tree
Showing 36 changed files with 272 additions and 150 deletions.
4 changes: 3 additions & 1 deletion components/mus/gles2/command_buffer_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,14 @@ bool CommandBufferDriver::Initialize(
// TODO(piman): ShaderTranslatorCache is currently per-ContextGroup but
// only needs to be per-thread.
const bool bind_generates_resource = attrib_helper.bind_generates_resource;
scoped_refptr<gpu::gles2::FeatureInfo> feature_info =
new gpu::gles2::FeatureInfo(gpu_state_->gpu_driver_bug_workarounds());
scoped_refptr<gpu::gles2::ContextGroup> context_group =
new gpu::gles2::ContextGroup(
gpu_state_->gpu_preferences(), gpu_state_->mailbox_manager(),
new GpuMemoryTracker,
new gpu::gles2::ShaderTranslatorCache(gpu_state_->gpu_preferences()),
new gpu::gles2::FramebufferCompletenessCache, nullptr, nullptr,
new gpu::gles2::FramebufferCompletenessCache, feature_info, nullptr,
nullptr, bind_generates_resource);

command_buffer_.reset(
Expand Down
1 change: 1 addition & 0 deletions components/mus/gles2/gpu_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace mus {
GpuState::GpuState()
: gpu_thread_("gpu_thread"),
control_thread_("gpu_command_buffer_control"),
gpu_driver_bug_workarounds_(base::CommandLine::ForCurrentProcess()),
hardware_rendering_available_(false) {
base::ThreadRestrictions::ScopedAllowWait allow_wait;
gpu_thread_.Start();
Expand Down
6 changes: 6 additions & 0 deletions components/mus/gles2/gpu_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "gpu/command_buffer/service/gpu_preferences.h"
#include "gpu/command_buffer/service/mailbox_manager_impl.h"
#include "gpu/command_buffer/service/sync_point_manager.h"
#include "gpu/config/gpu_driver_bug_workarounds.h"
#include "gpu/config/gpu_info.h"
#include "ui/gl/gl_share_group.h"

Expand Down Expand Up @@ -42,6 +43,10 @@ class GpuState : public base::RefCountedThreadSafe<GpuState> {
return gpu_preferences_;
}

const gpu::GpuDriverBugWorkarounds& gpu_driver_bug_workarounds() const {
return gpu_driver_bug_workarounds_;
}

CommandBufferTaskRunner* command_buffer_task_runner() const {
return command_buffer_task_runner_.get();
}
Expand Down Expand Up @@ -86,6 +91,7 @@ class GpuState : public base::RefCountedThreadSafe<GpuState> {
scoped_refptr<base::SingleThreadTaskRunner> control_thread_task_runner_;

gpu::GpuPreferences gpu_preferences_;
const gpu::GpuDriverBugWorkarounds gpu_driver_bug_workarounds_;
scoped_refptr<CommandBufferTaskRunner> command_buffer_task_runner_;
scoped_ptr<CommandBufferDriverManager> driver_manager_;
scoped_ptr<gpu::SyncPointManager> sync_point_manager_;
Expand Down
6 changes: 3 additions & 3 deletions gpu/command_buffer/service/buffer_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ class BufferManagerMemoryTrackerTest : public BufferManagerTestBase {
class BufferManagerClientSideArraysTest : public BufferManagerTestBase {
protected:
void SetUp() override {
feature_info_ = new FeatureInfo();
feature_info_->workarounds_.use_client_side_arrays_for_stream_buffers =
true;
GpuDriverBugWorkarounds gpu_driver_bug_workarounds;
gpu_driver_bug_workarounds.use_client_side_arrays_for_stream_buffers = true;
feature_info_ = new FeatureInfo(gpu_driver_bug_workarounds);
SetUpBase(NULL, feature_info_.get(), "");
}

Expand Down
3 changes: 1 addition & 2 deletions gpu/command_buffer/service/context_group.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,13 @@ ContextGroup::ContextGroup(
program_cache_(NULL),
feature_info_(feature_info) {
{
DCHECK(feature_info_);
if (!mailbox_manager_.get())
mailbox_manager_ = new MailboxManagerImpl;
if (!subscription_ref_set_.get())
subscription_ref_set_ = new SubscriptionRefSet();
if (!pending_valuebuffer_state_.get())
pending_valuebuffer_state_ = new ValueStateMap();
if (!feature_info.get())
feature_info_ = new FeatureInfo;
transfer_buffer_manager_ = new TransferBufferManager(memory_tracker_.get());
}
}
Expand Down
7 changes: 4 additions & 3 deletions gpu/command_buffer/service/context_group_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class ContextGroupTest : public GpuServiceTest {
void SetUp() override {
GpuServiceTest::SetUp();
decoder_.reset(new MockGLES2Decoder());
group_ = scoped_refptr<ContextGroup>(new ContextGroup(
gpu_preferences_, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
kBindGeneratesResource));
scoped_refptr<FeatureInfo> feature_info = new FeatureInfo;
group_ = scoped_refptr<ContextGroup>(
new ContextGroup(gpu_preferences_, NULL, NULL, NULL, NULL, feature_info,
NULL, NULL, kBindGeneratesResource));
}

GpuPreferences gpu_preferences_;
Expand Down
72 changes: 11 additions & 61 deletions gpu/command_buffer/service/feature_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,50 +80,6 @@ class StringSet {
std::set<std::string> string_set_;
};

// Process a string of wordaround type IDs (seperated by ',') and set up
// the corresponding Workaround flags.
void StringToWorkarounds(
const std::string& types, FeatureInfo::Workarounds* workarounds) {
DCHECK(workarounds);
for (const base::StringPiece& piece :
base::SplitStringPiece(
types, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
int number = 0;
bool succeed = base::StringToInt(piece, &number);
DCHECK(succeed);
switch (number) {
#define GPU_OP(type, name) \
case gpu::type: \
workarounds->name = true; \
break;
GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
#undef GPU_OP
default:
NOTIMPLEMENTED();
}
}
if (workarounds->max_texture_size_limit_4096)
workarounds->max_texture_size = 4096;
if (workarounds->max_cube_map_texture_size_limit_4096)
workarounds->max_cube_map_texture_size = 4096;
if (workarounds->max_cube_map_texture_size_limit_1024)
workarounds->max_cube_map_texture_size = 1024;
if (workarounds->max_cube_map_texture_size_limit_512)
workarounds->max_cube_map_texture_size = 512;

if (workarounds->max_fragment_uniform_vectors_32)
workarounds->max_fragment_uniform_vectors = 32;
if (workarounds->max_varying_vectors_16)
workarounds->max_varying_vectors = 16;
if (workarounds->max_vertex_uniform_vectors_256)
workarounds->max_vertex_uniform_vectors = 256;

if (workarounds->max_copy_texture_chromium_size_1048576)
workarounds->max_copy_texture_chromium_size = 1048576;
if (workarounds->max_copy_texture_chromium_size_262144)
workarounds->max_copy_texture_chromium_size = 262144;
}

} // anonymous namespace.

FeatureInfo::FeatureFlags::FeatureFlags()
Expand Down Expand Up @@ -181,37 +137,31 @@ FeatureInfo::FeatureFlags::FeatureFlags()
ext_blend_func_extended(false),
ext_read_format_bgra(false) {}

FeatureInfo::Workarounds::Workarounds() :
#define GPU_OP(type, name) name(false),
GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
#undef GPU_OP
max_texture_size(0),
max_cube_map_texture_size(0),
max_fragment_uniform_vectors(0),
max_varying_vectors(0),
max_vertex_uniform_vectors(0),
max_copy_texture_chromium_size(0) {
FeatureInfo::FeatureInfo() {
InitializeBasicState(base::CommandLine::InitializedForCurrentProcess()
? base::CommandLine::ForCurrentProcess()
: nullptr);
}

FeatureInfo::FeatureInfo() {
FeatureInfo::FeatureInfo(
const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds)
: workarounds_(gpu_driver_bug_workarounds) {
InitializeBasicState(base::CommandLine::InitializedForCurrentProcess()
? base::CommandLine::ForCurrentProcess()
: nullptr);
}

FeatureInfo::FeatureInfo(const base::CommandLine& command_line) {
FeatureInfo::FeatureInfo(
const base::CommandLine& command_line,
const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds)
: workarounds_(gpu_driver_bug_workarounds) {
InitializeBasicState(&command_line);
}

void FeatureInfo::InitializeBasicState(const base::CommandLine* command_line) {
if (!command_line)
return;

if (command_line->HasSwitch(switches::kGpuDriverBugWorkarounds)) {
std::string types = command_line->GetSwitchValueASCII(
switches::kGpuDriverBugWorkarounds);
StringToWorkarounds(types, &workarounds_);
}
feature_flags_.enable_shader_name_hashing =
!command_line->HasSwitch(switches::kDisableShaderNameHashing);

Expand Down
30 changes: 8 additions & 22 deletions gpu/command_buffer/service/feature_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "base/memory/scoped_ptr.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/gles2_cmd_validation.h"
#include "gpu/config/gpu_driver_bug_workaround_type.h"
#include "gpu/config/gpu_driver_bug_workarounds.h"
#include "gpu/gpu_export.h"

namespace base {
Expand Down Expand Up @@ -90,27 +90,15 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
bool ext_read_format_bgra;
};

struct Workarounds {
Workarounds();

#define GPU_OP(type, name) bool name;
GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
#undef GPU_OP

// Note: 0 here means use driver limit.
GLint max_texture_size;
GLint max_cube_map_texture_size;
GLint max_fragment_uniform_vectors;
GLint max_varying_vectors;
GLint max_vertex_uniform_vectors;
GLint max_copy_texture_chromium_size;
};
FeatureInfo();

// Constructor with workarounds taken from the current process's CommandLine
FeatureInfo();
explicit FeatureInfo(
const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds);

// Constructor with workarounds taken from |command_line|
FeatureInfo(const base::CommandLine& command_line);
FeatureInfo(const base::CommandLine& command_line,
const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds);

// Initializes the feature information. Needs a current GL context.
bool Initialize(ContextType context_type,
Expand All @@ -135,9 +123,7 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
return feature_flags_;
}

const Workarounds& workarounds() const {
return workarounds_;
}
const GpuDriverBugWorkarounds& workarounds() const { return workarounds_; }

const DisallowedFeatures& disallowed_features() const {
return disallowed_features_;
Expand Down Expand Up @@ -188,7 +174,7 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
FeatureFlags feature_flags_;

// Flags for Workarounds.
Workarounds workarounds_;
const GpuDriverBugWorkarounds workarounds_;

// Whether the command line switch kEnableUnsafeES3APIs is passed in.
bool enable_unsafe_es3_apis_switch_;
Expand Down
9 changes: 6 additions & 3 deletions gpu/command_buffer/service/feature_info_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,15 @@ class FeatureInfoTest
GpuServiceTest::SetUpWithGLVersion(version, extensions);
TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
gl_.get(), extensions, renderer, version);
info_ = new FeatureInfo(command_line);
GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line);
info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround);
info_->InitializeForTesting();
}

void SetupWithCommandLine(const base::CommandLine& command_line) {
GpuServiceTest::SetUp();
info_ = new FeatureInfo(command_line);
GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line);
info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround);
}

void SetupInitExpectationsWithCommandLine(
Expand All @@ -116,7 +118,8 @@ class FeatureInfoTest
GpuServiceTest::SetUpWithGLVersion("2.0", extensions);
TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(
gl_.get(), extensions, "", "");
info_ = new FeatureInfo(command_line);
GpuDriverBugWorkarounds gpu_driver_bug_workaround(&command_line);
info_ = new FeatureInfo(command_line, gpu_driver_bug_workaround);
info_->InitializeForTesting();
}

Expand Down
4 changes: 2 additions & 2 deletions gpu/command_buffer/service/gles2_cmd_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1881,7 +1881,7 @@ class GLES2DecoderImpl : public GLES2Decoder, public ErrorStateClient {
return feature_info_->feature_flags();
}

const FeatureInfo::Workarounds& workarounds() const {
const GpuDriverBugWorkarounds& workarounds() const {
return feature_info_->workarounds();
}

Expand Down Expand Up @@ -12971,7 +12971,7 @@ error::Error GLES2DecoderImpl::HandleGetRequestableExtensionsCHROMIUM(
*static_cast<const gles2::cmds::GetRequestableExtensionsCHROMIUM*>(
cmd_data);
Bucket* bucket = CreateBucket(c.bucket_id);
scoped_refptr<FeatureInfo> info(new FeatureInfo());
scoped_refptr<FeatureInfo> info(new FeatureInfo(workarounds()));
DisallowedFeatures disallowed_features = feature_info_->disallowed_features();
disallowed_features.AllowExtensions();
info->Initialize(feature_info_->context_type(), disallowed_features);
Expand Down
20 changes: 11 additions & 9 deletions gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,17 @@ void GLES2DecoderTestBase::InitDecoderWithCommandLine(

SetupMockGLBehaviors();

scoped_refptr<FeatureInfo> feature_info;
if (command_line)
feature_info = new FeatureInfo(*command_line);
group_ = scoped_refptr<ContextGroup>(
new ContextGroup(gpu_preferences_, NULL, memory_tracker_,
new ShaderTranslatorCache(gpu_preferences_),
new FramebufferCompletenessCache, feature_info.get(),
new SubscriptionRefSet, new ValueStateMap,
normalized_init.bind_generates_resource));
scoped_refptr<FeatureInfo> feature_info = new FeatureInfo;
if (command_line) {
GpuDriverBugWorkarounds gpu_driver_bug_workaround(command_line);
feature_info = new FeatureInfo(*command_line, gpu_driver_bug_workaround);
}

group_ = scoped_refptr<ContextGroup>(new ContextGroup(
gpu_preferences_, NULL, memory_tracker_,
new ShaderTranslatorCache(gpu_preferences_),
new FramebufferCompletenessCache, feature_info, new SubscriptionRefSet,
new ValueStateMap, normalized_init.bind_generates_resource));
bool use_default_textures = normalized_init.bind_generates_resource;

InSequence sequence;
Expand Down
27 changes: 18 additions & 9 deletions gpu/command_buffer/service/in_process_command_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,12 @@ scoped_refptr<InProcessCommandBuffer::Service> GetInitialService(

} // anonyous namespace

InProcessCommandBuffer::Service::Service() {}
InProcessCommandBuffer::Service::Service()
: gpu_driver_bug_workarounds_(base::CommandLine::ForCurrentProcess()) {}

InProcessCommandBuffer::Service::Service(const GpuPreferences& gpu_preferences)
: gpu_preferences_(gpu_preferences) {}
: gpu_preferences_(gpu_preferences),
gpu_driver_bug_workarounds_(base::CommandLine::ForCurrentProcess()) {}

InProcessCommandBuffer::Service::~Service() {}

Expand All @@ -159,6 +161,11 @@ InProcessCommandBuffer::Service::gpu_preferences() {
return gpu_preferences_;
}

const gpu::GpuDriverBugWorkarounds&
InProcessCommandBuffer::Service::gpu_driver_bug_workarounds() {
return gpu_driver_bug_workarounds_;
}

scoped_refptr<gfx::GLShareGroup>
InProcessCommandBuffer::Service::share_group() {
if (!share_group_.get())
Expand Down Expand Up @@ -338,16 +345,18 @@ bool InProcessCommandBuffer::InitializeOnGpuThread(
: service_->share_group();

bool bind_generates_resource = false;
scoped_refptr<gles2::FeatureInfo> feature_info =
new gles2::FeatureInfo(service_->gpu_driver_bug_workarounds());
decoder_.reset(gles2::GLES2Decoder::Create(
params.context_group
? params.context_group->decoder_->GetContextGroup()
: new gles2::ContextGroup(service_->gpu_preferences(),
service_->mailbox_manager(), NULL,
service_->shader_translator_cache(),
service_->framebuffer_completeness_cache(),
NULL, service_->subscription_ref_set(),
service_->pending_valuebuffer_state(),
bind_generates_resource)));
: new gles2::ContextGroup(
service_->gpu_preferences(), service_->mailbox_manager(), NULL,
service_->shader_translator_cache(),
service_->framebuffer_completeness_cache(), feature_info,
service_->subscription_ref_set(),
service_->pending_valuebuffer_state(),
bind_generates_resource)));

executor_.reset(new CommandExecutor(command_buffer.get(), decoder_.get(),
decoder_.get()));
Expand Down
Loading

0 comments on commit 265b2e5

Please sign in to comment.