Skip to content

Commit

Permalink
Disable automatic extension requesting for unittests.
Browse files Browse the repository at this point in the history
Due to a bug in the RequestExtension API, extensions were being enabled
without backend support in some cases.  Correctly test this in the
gpu_unittests by not requesting any extensions at initialization and
only enabling the ones to be tested in the tests.

BUG=602737

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: I2cac0d493abaa96e523e2d63e173d881650b4928
Reviewed-on: https://chromium-review.googlesource.com/726942
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#510324}
  • Loading branch information
vonture authored and Commit Bot committed Oct 20, 2017
1 parent 2b058a4 commit 1eb616c
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 48 deletions.
109 changes: 64 additions & 45 deletions gpu/command_buffer/service/gles2_cmd_decoder_passthrough.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ void ResizeRenderbuffer(GLuint renderbuffer,
}
}

void RequestExtensions(const gl::ExtensionSet& requestable_extensions,
const char* const* extensions_to_request,
size_t count) {
for (size_t i = 0; i < count; i++) {
if (gl::HasExtension(requestable_extensions, extensions_to_request[i])) {
// Request the intersection of the two sets
glRequestExtensionANGLE(extensions_to_request[i]);
}
}
}

} // anonymous namespace

PassthroughResources::PassthroughResources() {}
Expand Down Expand Up @@ -568,55 +579,58 @@ gpu::ContextResult GLES2DecoderPassthroughImpl::Initialize(
// Extensions that are enabled via emulation on the client side or needed for
// basic command buffer functionality. Make sure they are always enabled.
if (IsWebGLContextType(attrib_helper.context_type)) {
static constexpr const char* kEnableByDefaultExtensions[] = {
"GL_ANGLE_depth_texture",
"GL_ANGLE_framebuffer_blit",
"GL_ANGLE_framebuffer_multisample",
"GL_ANGLE_instanced_arrays",
"GL_ANGLE_pack_reverse_row_order",
"GL_ANGLE_texture_compression_dxt3",
"GL_ANGLE_texture_compression_dxt5",
"GL_ANGLE_texture_usage",
"GL_ANGLE_translated_shader_source",
"GL_CHROMIUM_bind_uniform_location",
"GL_CHROMIUM_framebuffer_mixed_samples",
"GL_CHROMIUM_path_rendering",
"GL_CHROMIUM_sync_query",
"GL_EXT_blend_minmax",
"GL_EXT_debug_marker",
"GL_EXT_discard_framebuffer",
"GL_EXT_disjoint_timer_query",
"GL_EXT_occlusion_query_boolean",
"GL_EXT_sRGB",
"GL_EXT_sRGB_write_control",
"GL_EXT_texture_compression_dxt1",
"GL_EXT_texture_compression_s3tc_srgb",
"GL_EXT_texture_norm16",
"GL_EXT_texture_rg",
"GL_EXT_texture_sRGB_decode",
"GL_EXT_texture_storage",
"GL_EXT_unpack_subimage",
"GL_KHR_texture_compression_astc_hdr",
"GL_KHR_texture_compression_astc_ldr",
"GL_NV_fence",
"GL_NV_pack_subimage",
"GL_OES_compressed_ETC1_RGB8_texture",
"GL_OES_depth32",
"GL_OES_fbo_render_mipmap",
"GL_OES_packed_depth_stencil",
"GL_OES_rgb8_rgba8",
"GL_OES_vertex_array_object",
};

// Grab the extensions that are requestable
gl::ExtensionSet requestable_extensions(
gl::GetRequestableGLExtensionsFromCurrentContext());
for (const char* default_extension : kEnableByDefaultExtensions) {
if (gl::HasExtension(requestable_extensions, default_extension)) {
// Request the intersection of the two sets
glRequestExtensionANGLE(default_extension);
}

static constexpr const char* kRequiredFunctionalityExtensions[] = {
"GL_CHROMIUM_bind_uniform_location", "GL_CHROMIUM_sync_query",
"GL_EXT_debug_marker", "GL_NV_fence",
};
RequestExtensions(requestable_extensions, kRequiredFunctionalityExtensions,
arraysize(kRequiredFunctionalityExtensions));

if (request_optional_extensions_) {
static constexpr const char* kOptionalFunctionalityExtensions[] = {
"GL_ANGLE_depth_texture",
"GL_ANGLE_texture_usage",
"GL_ANGLE_framebuffer_blit",
"GL_ANGLE_framebuffer_multisample",
"GL_ANGLE_instanced_arrays",
"GL_ANGLE_pack_reverse_row_order",
"GL_ANGLE_texture_compression_dxt3",
"GL_ANGLE_texture_compression_dxt5",
"GL_ANGLE_translated_shader_source",
"GL_CHROMIUM_framebuffer_mixed_samples",
"GL_CHROMIUM_path_rendering",
"GL_EXT_blend_minmax",
"GL_EXT_discard_framebuffer",
"GL_EXT_disjoint_timer_query",
"GL_EXT_occlusion_query_boolean",
"GL_EXT_sRGB",
"GL_EXT_sRGB_write_control",
"GL_EXT_texture_compression_dxt1",
"GL_EXT_texture_compression_s3tc_srgb",
"GL_EXT_texture_norm16",
"GL_EXT_texture_rg",
"GL_EXT_texture_sRGB_decode",
"GL_EXT_texture_storage",
"GL_EXT_unpack_subimage",
"GL_KHR_texture_compression_astc_hdr",
"GL_KHR_texture_compression_astc_ldr",
"GL_NV_pack_subimage",
"GL_OES_compressed_ETC1_RGB8_texture",
"GL_OES_depth32",
"GL_OES_fbo_render_mipmap",
"GL_OES_packed_depth_stencil",
"GL_OES_rgb8_rgba8",
"GL_OES_vertex_array_object",
};
RequestExtensions(requestable_extensions,
kOptionalFunctionalityExtensions,
arraysize(kOptionalFunctionalityExtensions));
}

context->ReinitializeDynamicBindings();
}

Expand Down Expand Up @@ -1399,6 +1413,11 @@ const char* GLES2DecoderPassthroughImpl::GetCommandName(
return GetCommonCommandName(static_cast<cmd::CommandId>(command_id));
}

void GLES2DecoderPassthroughImpl::SetOptionalExtensionsRequestedForTesting(
bool request_extensions) {
request_optional_extensions_ = request_extensions;
}

void* GLES2DecoderPassthroughImpl::GetScratchMemory(size_t size) {
if (scratch_memory_.size() < size) {
scratch_memory_.resize(size, 0);
Expand Down
6 changes: 6 additions & 0 deletions gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ class GPU_EXPORT GLES2DecoderPassthroughImpl : public GLES2Decoder {

const char* GetCommandName(unsigned int command_id) const;

void SetOptionalExtensionsRequestedForTesting(bool request_extensions);

void* GetScratchMemory(size_t size);

template <typename T>
Expand Down Expand Up @@ -410,6 +412,10 @@ class GPU_EXPORT GLES2DecoderPassthroughImpl : public GLES2Decoder {
scoped_refptr<ContextGroup> group_;
scoped_refptr<FeatureInfo> feature_info_;

// By default, all requestable extensions should be loaded at initialization
// time. Can be disabled for testing with only specific extensions enabled.
bool request_optional_extensions_ = true;

// Some objects may generate resources when they are bound even if they were
// not generated yet: texture, buffer, renderbuffer, framebuffer, transform
// feedback, vertex array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace gles2 {

using namespace cmds;

TEST_F(GLES2DecoderPassthroughTest, DrawArraysInstancedANGLEEnablement) {
TEST_F(GLES2WebGLDecoderPassthroughTest, DrawArraysInstancedANGLEEnablement) {
DrawArraysInstancedANGLE cmd;
cmd.Init(GL_TRIANGLES, 0, 3, 1);
EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
Expand All @@ -19,7 +19,7 @@ TEST_F(GLES2DecoderPassthroughTest, DrawArraysInstancedANGLEEnablement) {
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
}

TEST_F(GLES2DecoderPassthroughTest, VertexAttribDivisorANGLEEnablement) {
TEST_F(GLES2WebGLDecoderPassthroughTest, VertexAttribDivisorANGLEEnablement) {
VertexAttribDivisorANGLE cmd;
cmd.Init(0, 1);
EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
Expand All @@ -28,7 +28,7 @@ TEST_F(GLES2DecoderPassthroughTest, VertexAttribDivisorANGLEEnablement) {
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
}

TEST_F(GLES2DecoderPassthroughTest, DrawElementsInstancedANGLEEnablement) {
TEST_F(GLES2WebGLDecoderPassthroughTest, DrawElementsInstancedANGLEEnablement) {
DrawElementsInstancedANGLE cmd;
cmd.Init(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0, 1);
EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
Expand Down
7 changes: 7 additions & 0 deletions gpu/command_buffer/service/gles2_cmd_decoder_unittest.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ class GLES2DecoderPassthroughTest : public GLES2DecoderPassthroughTestBase {
: GLES2DecoderPassthroughTestBase(CONTEXT_TYPE_OPENGLES2) {}
};

class GLES2WebGLDecoderPassthroughTest
: public GLES2DecoderPassthroughTestBase {
public:
GLES2WebGLDecoderPassthroughTest()
: GLES2DecoderPassthroughTestBase(CONTEXT_TYPE_WEBGL1) {}
};

class GLES3DecoderPassthroughTest : public GLES2DecoderPassthroughTestBase {
public:
GLES3DecoderPassthroughTest()
Expand Down
5 changes: 5 additions & 0 deletions gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2275,6 +2275,11 @@ void GLES2DecoderPassthroughTestBase::SetUp() {

decoder_.reset(new GLES2DecoderPassthroughImpl(
this, command_buffer_service_.get(), &outputter_, group_.get()));

// Don't request any optional extensions at startup, individual tests will
// request what they need.
decoder_->SetOptionalExtensionsRequestedForTesting(false);

ASSERT_EQ(
group_->Initialize(decoder_.get(), context_creation_attribs_.context_type,
DisallowedFeatures()),
Expand Down

0 comments on commit 1eb616c

Please sign in to comment.