Commit 66a34ea9 authored by zmo@chromium.org's avatar zmo@chromium.org

Use macro to simplify gpu driver bug workaround defs and code.

BUG=226789
TEST=no logic change, simply code refactor, so everything stays the same
Review URL: https://codereview.chromium.org/13400003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192580 0039d316-1c4b-4281-b951-d872f2087c98
parent 41b33504
...@@ -31,38 +31,9 @@ GpuDriverBugList* GpuDriverBugList::Create() { ...@@ -31,38 +31,9 @@ GpuDriverBugList* GpuDriverBugList::Create() {
GpuDriverBugList* list = new GpuDriverBugList(); GpuDriverBugList* list = new GpuDriverBugList();
const DriverBugInfo kFeatureList[] = { const DriverBugInfo kFeatureList[] = {
{ gpu::CLEAR_ALPHA_IN_READPIXELS, "clear_alpha_in_readpixels" }, #define GPU_OP(type, name) { gpu::type, #name },
{ gpu::CLEAR_UNIFORMS_BEFORE_PROGRAM_USE, GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
"clear_uniforms_before_program_use" }, #undef GPU_OP
{ gpu::DELETE_INSTEAD_OF_RESIZE_FBO, "delete_instead_of_resize_fbo" },
{ gpu::DISABLE_ANGLE_FRAMEBUFFER_MULTISAMPLE,
"disable_angle_framebuffer_multisample" },
{ gpu::DISABLE_DEPTH_TEXTURE, "disable_depth_texture" },
{ gpu::DISABLE_EXT_OCCLUSION_QUERY, "disable_ext_occlusion_query" },
{ gpu::ENABLE_CHROMIUM_FAST_NPOT_MO8_TEXTURES,
"enable_chromium_fast_npot_mo8_textures" },
{ gpu::EXIT_ON_CONTEXT_LOST, "exit_on_context_lost" },
{ gpu::FLUSH_ON_CONTEXT_SWITCH, "flush_on_context_switch" },
{ gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024,
"max_cube_map_texture_size_limit_1024" },
{ gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_4096,
"max_cube_map_texture_size_limit_4096" },
{ gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_512,
"max_cube_map_texture_size_limit_512" },
{ gpu::MAX_TEXTURE_SIZE_LIMIT_4096, "max_texture_size_limit_4096" },
{ gpu::NEEDS_GLSL_BUILT_IN_FUNCTION_EMULATION,
"needs_glsl_built_in_function_emulation" },
{ gpu::NEEDS_OFFSCREEN_BUFFER_WORKAROUND,
"needs_offscreen_buffer_workaround" },
{ gpu::RESTORE_SCISSOR_ON_FBO_CHANGE, "restore_scissor_on_fbo_change" },
{ gpu::REVERSE_POINT_SPRITE_COORD_ORIGIN,
"reverse_point_sprite_coord_origin" },
{ gpu::SET_TEXTURE_FILTER_BEFORE_GENERATING_MIPMAP,
"set_texture_filter_before_generating_mipmap" },
{ gpu::USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS,
"use_client_side_arrays_for_stream_buffers" },
{ gpu::USE_CURRENT_PROGRAM_AFTER_SUCCESSFUL_LINK,
"use_current_program_after_successful_link" }
}; };
DCHECK_EQ(static_cast<int>(arraysize(kFeatureList)), DCHECK_EQ(static_cast<int>(arraysize(kFeatureList)),
gpu::NUMBER_OF_GPU_DRIVER_BUG_WORKAROUND_TYPES); gpu::NUMBER_OF_GPU_DRIVER_BUG_WORKAROUND_TYPES);
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "gpu/command_buffer/service/gl_utils.h" #include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/gpu_driver_bug_workaround_type.h"
#include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/command_buffer/service/gpu_switches.h"
#include "ui/gl/gl_implementation.h" #include "ui/gl/gl_implementation.h"
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
...@@ -76,78 +75,24 @@ void StringToWorkarounds( ...@@ -76,78 +75,24 @@ void StringToWorkarounds(
bool succeed = base::StringToInt(pieces[i], &number); bool succeed = base::StringToInt(pieces[i], &number);
DCHECK(succeed); DCHECK(succeed);
switch (number) { switch (number) {
case gpu::CLEAR_ALPHA_IN_READPIXELS: #define GPU_OP(type, name) \
workarounds->clear_alpha_in_readpixels = true; case gpu::type: \
break; workarounds->name = true; \
case gpu::CLEAR_UNIFORMS_BEFORE_PROGRAM_USE: break;
workarounds->clear_uniforms_before_program_use = true; GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
break; #undef GPU_OP
case gpu::DELETE_INSTEAD_OF_RESIZE_FBO:
workarounds->delete_instead_of_resize_fbo = true;
break;
case gpu::DISABLE_ANGLE_FRAMEBUFFER_MULTISAMPLE:
workarounds->disable_angle_framebuffer_multisample = true;
break;
case gpu::DISABLE_DEPTH_TEXTURE:
workarounds->disable_depth_texture = true;
break;
case gpu::DISABLE_EXT_OCCLUSION_QUERY:
workarounds->disable_ext_occlusion_query = true;
break;
case gpu::ENABLE_CHROMIUM_FAST_NPOT_MO8_TEXTURES:
workarounds->enable_chromium_fast_npot_mo8_textures = true;
break;
case gpu::EXIT_ON_CONTEXT_LOST:
workarounds->exit_on_context_lost = true;
break;
case gpu::FLUSH_ON_CONTEXT_SWITCH:
workarounds->flush_on_context_switch = true;
break;
case gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024:
if (workarounds->max_cube_map_texture_size == 0 ||
workarounds->max_cube_map_texture_size > 1024)
workarounds->max_cube_map_texture_size = 1024;
break;
case gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_4096:
if (workarounds->max_cube_map_texture_size == 0 ||
workarounds->max_cube_map_texture_size > 4096)
workarounds->max_cube_map_texture_size = 4096;
break;
case gpu::MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_512:
if (workarounds->max_cube_map_texture_size == 0 ||
workarounds->max_cube_map_texture_size > 512)
workarounds->max_cube_map_texture_size = 512;
break;
case gpu::MAX_TEXTURE_SIZE_LIMIT_4096:
if (workarounds->max_texture_size == 0 ||
workarounds->max_texture_size > 4096)
workarounds->max_texture_size = 4096;
break;
case gpu::NEEDS_GLSL_BUILT_IN_FUNCTION_EMULATION:
workarounds->needs_glsl_built_in_function_emulation = true;
break;
case gpu::NEEDS_OFFSCREEN_BUFFER_WORKAROUND:
workarounds->needs_offscreen_buffer_workaround = true;
break;
case gpu::RESTORE_SCISSOR_ON_FBO_CHANGE:
workarounds->restore_scissor_on_fbo_change = true;
break;
case REVERSE_POINT_SPRITE_COORD_ORIGIN:
workarounds->reverse_point_sprite_coord_origin = true;
break;
case gpu::SET_TEXTURE_FILTER_BEFORE_GENERATING_MIPMAP:
workarounds->set_texture_filter_before_generating_mipmap = true;
break;
case gpu::USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS:
workarounds->use_client_side_arrays_for_stream_buffers = true;
break;
case gpu::USE_CURRENT_PROGRAM_AFTER_SUCCESSFUL_LINK:
workarounds->use_current_program_after_successful_link = true;
break;
default: default:
NOTIMPLEMENTED(); 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;
} }
} // anonymous namespace. } // anonymous namespace.
...@@ -173,25 +118,12 @@ FeatureInfo::FeatureFlags::FeatureFlags() ...@@ -173,25 +118,12 @@ FeatureInfo::FeatureFlags::FeatureFlags()
ext_draw_buffers(false) { ext_draw_buffers(false) {
} }
FeatureInfo::Workarounds::Workarounds() FeatureInfo::Workarounds::Workarounds() :
: clear_alpha_in_readpixels(false), #define GPU_OP(type, name) name(false),
clear_uniforms_before_program_use(false), GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
delete_instead_of_resize_fbo(false), #undef GPU_OP
disable_angle_framebuffer_multisample(false), max_texture_size(0),
disable_depth_texture(false), max_cube_map_texture_size(0) {
disable_ext_occlusion_query(false),
enable_chromium_fast_npot_mo8_textures(false),
exit_on_context_lost(false),
flush_on_context_switch(false),
needs_glsl_built_in_function_emulation(false),
needs_offscreen_buffer_workaround(false),
restore_scissor_on_fbo_change(false),
reverse_point_sprite_coord_origin(false),
set_texture_filter_before_generating_mipmap(false),
use_client_side_arrays_for_stream_buffers(false),
use_current_program_after_successful_link(false),
max_texture_size(0),
max_cube_map_texture_size(0) {
} }
FeatureInfo::FeatureInfo() { FeatureInfo::FeatureInfo() {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/sys_info.h" #include "base/sys_info.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h" #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/gles2_cmd_validation.h" #include "gpu/command_buffer/service/gles2_cmd_validation.h"
#include "gpu/command_buffer/service/gpu_driver_bug_workaround_type.h"
#include "gpu/gpu_export.h" #include "gpu/gpu_export.h"
class CommandLine; class CommandLine;
...@@ -48,22 +49,9 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> { ...@@ -48,22 +49,9 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
struct Workarounds { struct Workarounds {
Workarounds(); Workarounds();
bool clear_alpha_in_readpixels; #define GPU_OP(type, name) bool name;
bool clear_uniforms_before_program_use; GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
bool delete_instead_of_resize_fbo; #undef GPU_OP
bool disable_angle_framebuffer_multisample;
bool disable_depth_texture;
bool disable_ext_occlusion_query;
bool enable_chromium_fast_npot_mo8_textures;
bool exit_on_context_lost;
bool flush_on_context_switch;
bool needs_glsl_built_in_function_emulation;
bool needs_offscreen_buffer_workaround;
bool restore_scissor_on_fbo_change;
bool reverse_point_sprite_coord_origin;
bool set_texture_filter_before_generating_mipmap;
bool use_client_side_arrays_for_stream_buffers;
bool use_current_program_after_successful_link;
// Note: 0 here means use driver limit. // Note: 0 here means use driver limit.
GLint max_texture_size; GLint max_texture_size;
......
...@@ -94,23 +94,9 @@ TEST_F(FeatureInfoTest, Basic) { ...@@ -94,23 +94,9 @@ TEST_F(FeatureInfoTest, Basic) {
).use_arb_occlusion_query_for_occlusion_query_boolean); ).use_arb_occlusion_query_for_occlusion_query_boolean);
EXPECT_FALSE(info_->feature_flags().native_vertex_array_object); EXPECT_FALSE(info_->feature_flags().native_vertex_array_object);
EXPECT_FALSE(info_->workarounds().clear_alpha_in_readpixels); #define GPU_OP(type, name) EXPECT_FALSE(info_->workarounds().name);
EXPECT_FALSE(info_->workarounds().clear_uniforms_before_program_use); GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
EXPECT_FALSE(info_->workarounds().delete_instead_of_resize_fbo); #undef GPU_OP
EXPECT_FALSE(info_->workarounds().disable_angle_framebuffer_multisample);
EXPECT_FALSE(info_->workarounds().disable_depth_texture);
EXPECT_FALSE(info_->workarounds().disable_ext_occlusion_query);
EXPECT_FALSE(info_->workarounds().enable_chromium_fast_npot_mo8_textures);
EXPECT_FALSE(info_->workarounds().exit_on_context_lost);
EXPECT_FALSE(info_->workarounds().flush_on_context_switch);
EXPECT_FALSE(info_->workarounds().needs_glsl_built_in_function_emulation);
EXPECT_FALSE(info_->workarounds().needs_offscreen_buffer_workaround);
EXPECT_FALSE(info_->workarounds().restore_scissor_on_fbo_change);
EXPECT_FALSE(info_->workarounds().reverse_point_sprite_coord_origin);
EXPECT_FALSE(
info_->workarounds().set_texture_filter_before_generating_mipmap);
EXPECT_FALSE(info_->workarounds().use_client_side_arrays_for_stream_buffers);
EXPECT_FALSE(info_->workarounds().use_current_program_after_successful_link);
EXPECT_EQ(0, info_->workarounds().max_texture_size); EXPECT_EQ(0, info_->workarounds().max_texture_size);
EXPECT_EQ(0, info_->workarounds().max_cube_map_texture_size); EXPECT_EQ(0, info_->workarounds().max_cube_map_texture_size);
......
...@@ -7,32 +7,55 @@ ...@@ -7,32 +7,55 @@
#include "gpu/gpu_export.h" #include "gpu/gpu_export.h"
#define GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP) \
GPU_OP(CLEAR_ALPHA_IN_READPIXELS, \
clear_alpha_in_readpixels) \
GPU_OP(CLEAR_UNIFORMS_BEFORE_PROGRAM_USE, \
clear_uniforms_before_program_use) \
GPU_OP(DELETE_INSTEAD_OF_RESIZE_FBO, \
delete_instead_of_resize_fbo) \
GPU_OP(DISABLE_ANGLE_FRAMEBUFFER_MULTISAMPLE, \
disable_angle_framebuffer_multisample) \
GPU_OP(DISABLE_DEPTH_TEXTURE, \
disable_depth_texture) \
GPU_OP(DISABLE_EXT_OCCLUSION_QUERY, \
disable_ext_occlusion_query) \
GPU_OP(ENABLE_CHROMIUM_FAST_NPOT_MO8_TEXTURES, \
enable_chromium_fast_npot_mo8_textures) \
GPU_OP(EXIT_ON_CONTEXT_LOST, \
exit_on_context_lost) \
GPU_OP(FLUSH_ON_CONTEXT_SWITCH, \
flush_on_context_switch) \
GPU_OP(MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024, \
max_cube_map_texture_size_limit_1024) \
GPU_OP(MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_4096, \
max_cube_map_texture_size_limit_4096) \
GPU_OP(MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_512, \
max_cube_map_texture_size_limit_512) \
GPU_OP(MAX_TEXTURE_SIZE_LIMIT_4096, \
max_texture_size_limit_4096) \
GPU_OP(NEEDS_GLSL_BUILT_IN_FUNCTION_EMULATION, \
needs_glsl_built_in_function_emulation) \
GPU_OP(NEEDS_OFFSCREEN_BUFFER_WORKAROUND, \
needs_offscreen_buffer_workaround) \
GPU_OP(RESTORE_SCISSOR_ON_FBO_CHANGE, \
restore_scissor_on_fbo_change) \
GPU_OP(REVERSE_POINT_SPRITE_COORD_ORIGIN, \
reverse_point_sprite_coord_origin) \
GPU_OP(SET_TEXTURE_FILTER_BEFORE_GENERATING_MIPMAP, \
set_texture_filter_before_generating_mipmap) \
GPU_OP(USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS, \
use_client_side_arrays_for_stream_buffers) \
GPU_OP(USE_CURRENT_PROGRAM_AFTER_SUCCESSFUL_LINK, \
use_current_program_after_successful_link)
namespace gpu { namespace gpu {
// Provides flags indicating which gpu features are blacklisted for the system // Provides all types of GPU driver bug workarounds.
// on which chrome is currently running.
// If a bit is set to 1, corresponding feature is blacklisted.
enum GPU_EXPORT GpuDriverBugWorkaroundType { enum GPU_EXPORT GpuDriverBugWorkaroundType {
CLEAR_ALPHA_IN_READPIXELS = 0, #define GPU_OP(type, name) type,
CLEAR_UNIFORMS_BEFORE_PROGRAM_USE, GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
DELETE_INSTEAD_OF_RESIZE_FBO, #undef GPU_OP
DISABLE_ANGLE_FRAMEBUFFER_MULTISAMPLE,
DISABLE_DEPTH_TEXTURE,
DISABLE_EXT_OCCLUSION_QUERY,
ENABLE_CHROMIUM_FAST_NPOT_MO8_TEXTURES,
EXIT_ON_CONTEXT_LOST,
FLUSH_ON_CONTEXT_SWITCH,
MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_1024,
MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_4096,
MAX_CUBE_MAP_TEXTURE_SIZE_LIMIT_512,
MAX_TEXTURE_SIZE_LIMIT_4096,
NEEDS_GLSL_BUILT_IN_FUNCTION_EMULATION,
NEEDS_OFFSCREEN_BUFFER_WORKAROUND,
RESTORE_SCISSOR_ON_FBO_CHANGE,
REVERSE_POINT_SPRITE_COORD_ORIGIN,
SET_TEXTURE_FILTER_BEFORE_GENERATING_MIPMAP,
USE_CLIENT_SIDE_ARRAYS_FOR_STREAM_BUFFERS,
USE_CURRENT_PROGRAM_AFTER_SUCCESSFUL_LINK,
NUMBER_OF_GPU_DRIVER_BUG_WORKAROUND_TYPES NUMBER_OF_GPU_DRIVER_BUG_WORKAROUND_TYPES
}; };
......
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