diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-30 21:29:11 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-30 21:29:11 +0000 |
commit | 915a59a10d1a1bb008821fd4e4f2019a4c676142 (patch) | |
tree | bec2e4c963ea3f6da1e839799a144de14086945e /gpu/command_buffer/service/context_group_unittest.cc | |
parent | d15e56c68d773261b98d20b61aeeb03cfa0fb24e (diff) | |
download | chromium_src-915a59a10d1a1bb008821fd4e4f2019a4c676142.zip chromium_src-915a59a10d1a1bb008821fd4e4f2019a4c676142.tar.gz chromium_src-915a59a10d1a1bb008821fd4e4f2019a4c676142.tar.bz2 |
A step in making it possible for WebGL to request no features
and the add them in as extensions are enabled.
The idea is when WebGL inits it's context it will pass ""
to FeatureInfo::Initialize. After that it can pass various
GL extension strings to FeatureInfo::AddFeatures
to turn on more features.
It can then call glGetString(GL_EXTENSIONS) to see if the
feature was turned on.
Questions: I started this CL trying to make it possible
so each context could have it's own FeatureInfo. I decided
against that. So that brings up the question, should I
get rid of FeatureInfo and just put this stuff back on
ContextGroup or leave it as is?
If I leave it as is, should I move all the max_XXX stuff
on ContextGroup to FeatureInfo?
TEST=unit tests
BUG=none
Review URL: http://codereview.chromium.org/3413038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61114 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service/context_group_unittest.cc')
-rw-r--r-- | gpu/command_buffer/service/context_group_unittest.cc | 338 |
1 files changed, 22 insertions, 316 deletions
diff --git a/gpu/command_buffer/service/context_group_unittest.cc b/gpu/command_buffer/service/context_group_unittest.cc index 4384ea6..4cfd4c7 100644 --- a/gpu/command_buffer/service/context_group_unittest.cc +++ b/gpu/command_buffer/service/context_group_unittest.cc @@ -32,10 +32,6 @@ class ContextGroupTest : public testing::Test { ContextGroupTest() { } - void SetupInitExpectations(const char* extensions) { - TestHelper::SetupContextGroupInitExpectations(gl_.get(), extensions); - } - protected: virtual void SetUp() { gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); @@ -67,321 +63,31 @@ TEST_F(ContextGroupTest, Basic) { EXPECT_TRUE(group_.texture_manager() == NULL); EXPECT_TRUE(group_.program_manager() == NULL); EXPECT_TRUE(group_.shader_manager() == NULL); - EXPECT_FALSE(group_.extension_flags().ext_framebuffer_multisample); - EXPECT_FALSE(group_.extension_flags().oes_standard_derivatives); } TEST_F(ContextGroupTest, InitializeNoExtensions) { - SetupInitExpectations(""); - group_.Initialize(); - // Check a couple of random extensions that should not be there. - EXPECT_THAT(group_.extensions(), Not(HasSubstr("GL_OES_texture_npot"))); - EXPECT_THAT(group_.extensions(), - Not(HasSubstr("GL_EXT_texture_compression_dxt1"))); - EXPECT_FALSE(group_.texture_manager()->npot_ok()); - EXPECT_FALSE(group_.validators()->compressed_texture_format.IsValid( - GL_COMPRESSED_RGB_S3TC_DXT1_EXT)); - EXPECT_FALSE(group_.validators()->compressed_texture_format.IsValid( - GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)); - EXPECT_FALSE(group_.validators()->compressed_texture_format.IsValid( - GL_COMPRESSED_RGBA_S3TC_DXT3_EXT)); - EXPECT_FALSE(group_.validators()->compressed_texture_format.IsValid( - GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)); - EXPECT_FALSE(group_.validators()->read_pixel_format.IsValid( - GL_BGRA_EXT)); - EXPECT_FALSE(group_.validators()->texture_parameter.IsValid( - GL_TEXTURE_MAX_ANISOTROPY_EXT)); - EXPECT_FALSE(group_.validators()->g_l_state.IsValid( - GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)); - EXPECT_FALSE(group_.validators()->frame_buffer_target.IsValid( - GL_READ_FRAMEBUFFER_EXT)); - EXPECT_FALSE(group_.validators()->frame_buffer_target.IsValid( - GL_DRAW_FRAMEBUFFER_EXT)); - EXPECT_FALSE(group_.validators()->g_l_state.IsValid( - GL_READ_FRAMEBUFFER_BINDING_EXT)); - EXPECT_FALSE(group_.validators()->render_buffer_parameter.IsValid( - GL_MAX_SAMPLES_EXT)); - EXPECT_FALSE(group_.validators()->texture_internal_format.IsValid( - GL_DEPTH_COMPONENT)); - EXPECT_FALSE(group_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT)); - EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT)); - EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT)); - EXPECT_FALSE(group_.validators()->render_buffer_format.IsValid( - GL_DEPTH24_STENCIL8)); - EXPECT_FALSE(group_.validators()->texture_internal_format.IsValid( - GL_DEPTH_STENCIL)); - EXPECT_FALSE(group_.validators()->texture_format.IsValid( - GL_DEPTH_STENCIL)); - EXPECT_FALSE(group_.validators()->pixel_type.IsValid( - GL_UNSIGNED_INT_24_8)); - EXPECT_FALSE(group_.validators()->render_buffer_format.IsValid( - GL_DEPTH_COMPONENT24)); -} - -TEST_F(ContextGroupTest, InitializeNPOTExtensionGLES) { - SetupInitExpectations("GL_OES_texture_npot"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), HasSubstr("GL_OES_texture_npot")); - EXPECT_TRUE(group_.texture_manager()->npot_ok()); -} - -TEST_F(ContextGroupTest, InitializeNPOTExtensionGL) { - SetupInitExpectations("GL_ARB_texture_non_power_of_two"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), HasSubstr("GL_OES_texture_npot")); - EXPECT_TRUE(group_.texture_manager()->npot_ok()); -} - -TEST_F(ContextGroupTest, InitializeDXTExtensionGLES2) { - SetupInitExpectations("GL_EXT_texture_compression_dxt1"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_EXT_texture_compression_dxt1")); - EXPECT_TRUE(group_.validators()->compressed_texture_format.IsValid( - GL_COMPRESSED_RGB_S3TC_DXT1_EXT)); - EXPECT_TRUE(group_.validators()->compressed_texture_format.IsValid( - GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)); - EXPECT_FALSE(group_.validators()->compressed_texture_format.IsValid( - GL_COMPRESSED_RGBA_S3TC_DXT3_EXT)); - EXPECT_FALSE(group_.validators()->compressed_texture_format.IsValid( - GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)); -} - -TEST_F(ContextGroupTest, InitializeDXTExtensionGL) { - SetupInitExpectations("GL_EXT_texture_compression_s3tc"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_EXT_texture_compression_dxt1")); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_EXT_texture_compression_s3tc")); - EXPECT_TRUE(group_.validators()->compressed_texture_format.IsValid( - GL_COMPRESSED_RGB_S3TC_DXT1_EXT)); - EXPECT_TRUE(group_.validators()->compressed_texture_format.IsValid( - GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)); - EXPECT_TRUE(group_.validators()->compressed_texture_format.IsValid( - GL_COMPRESSED_RGBA_S3TC_DXT3_EXT)); - EXPECT_TRUE(group_.validators()->compressed_texture_format.IsValid( - GL_COMPRESSED_RGBA_S3TC_DXT5_EXT)); -} - -TEST_F(ContextGroupTest, InitializeEXT_texture_format_BGRA8888GLES2) { - SetupInitExpectations("GL_EXT_texture_format_BGRA8888"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_EXT_texture_format_BGRA8888")); - EXPECT_TRUE(group_.validators()->texture_format.IsValid( - GL_BGRA_EXT)); - EXPECT_TRUE(group_.validators()->texture_internal_format.IsValid( - GL_BGRA_EXT)); -} - -TEST_F(ContextGroupTest, InitializeEXT_texture_format_BGRA8888GL) { - SetupInitExpectations("GL_EXT_bgra"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_EXT_texture_format_BGRA8888")); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_EXT_read_format_bgra")); - EXPECT_TRUE(group_.validators()->texture_format.IsValid( - GL_BGRA_EXT)); - EXPECT_TRUE(group_.validators()->texture_internal_format.IsValid( - GL_BGRA_EXT)); - EXPECT_TRUE(group_.validators()->read_pixel_format.IsValid( - GL_BGRA_EXT)); -} - -TEST_F(ContextGroupTest, InitializeEXT_texture_format_BGRA8888Apple) { - SetupInitExpectations("GL_APPLE_texture_format_BGRA8888"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_EXT_texture_format_BGRA8888")); - EXPECT_TRUE(group_.validators()->texture_format.IsValid( - GL_BGRA_EXT)); - EXPECT_TRUE(group_.validators()->texture_internal_format.IsValid( - GL_BGRA_EXT)); -} - -TEST_F(ContextGroupTest, InitializeEXT_read_format_bgra) { - SetupInitExpectations("GL_EXT_read_format_bgra"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_EXT_read_format_bgra")); - EXPECT_FALSE(group_.validators()->texture_format.IsValid( - GL_BGRA_EXT)); - EXPECT_FALSE(group_.validators()->texture_internal_format.IsValid( - GL_BGRA_EXT)); - EXPECT_TRUE(group_.validators()->read_pixel_format.IsValid( - GL_BGRA_EXT)); -} - -TEST_F(ContextGroupTest, InitializeOES_texture_floatGLES2) { - SetupInitExpectations("GL_OES_texture_float"); - group_.Initialize(); - EXPECT_FALSE(group_.texture_manager()->enable_float_linear()); - EXPECT_FALSE(group_.texture_manager()->enable_half_float_linear()); - EXPECT_THAT(group_.extensions(), HasSubstr("GL_OES_texture_float")); - EXPECT_THAT(group_.extensions(), Not(HasSubstr("GL_OES_texture_half_float"))); - EXPECT_THAT(group_.extensions(), - Not(HasSubstr("GL_OES_texture_float_linear"))); - EXPECT_THAT(group_.extensions(), - Not(HasSubstr("GL_OES_texture_half_float_linear"))); - EXPECT_TRUE(group_.validators()->pixel_type.IsValid(GL_FLOAT)); - EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES)); -} - -TEST_F(ContextGroupTest, InitializeOES_texture_float_linearGLES2) { - SetupInitExpectations("GL_OES_texture_float GL_OES_texture_float_linear"); - group_.Initialize(); - EXPECT_TRUE(group_.texture_manager()->enable_float_linear()); - EXPECT_FALSE(group_.texture_manager()->enable_half_float_linear()); - EXPECT_THAT(group_.extensions(), HasSubstr("GL_OES_texture_float")); - EXPECT_THAT(group_.extensions(), Not(HasSubstr("GL_OES_texture_half_float"))); - EXPECT_THAT(group_.extensions(), HasSubstr("GL_OES_texture_float_linear")); - EXPECT_THAT(group_.extensions(), - Not(HasSubstr("GL_OES_texture_half_float_linear"))); - EXPECT_TRUE(group_.validators()->pixel_type.IsValid(GL_FLOAT)); - EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES)); -} - -TEST_F(ContextGroupTest, InitializeOES_texture_half_floatGLES2) { - SetupInitExpectations("GL_OES_texture_half_float"); - group_.Initialize(); - EXPECT_FALSE(group_.texture_manager()->enable_float_linear()); - EXPECT_FALSE(group_.texture_manager()->enable_half_float_linear()); - EXPECT_THAT(group_.extensions(), Not(HasSubstr("GL_OES_texture_float"))); - EXPECT_THAT(group_.extensions(), HasSubstr("GL_OES_texture_half_float")); - EXPECT_THAT(group_.extensions(), - Not(HasSubstr("GL_OES_texture_float_linear"))); - EXPECT_THAT(group_.extensions(), - Not(HasSubstr("GL_OES_texture_half_float_linear"))); - EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_FLOAT)); - EXPECT_TRUE(group_.validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES)); -} - -TEST_F(ContextGroupTest, InitializeOES_texture_half_float_linearGLES2) { - SetupInitExpectations( - "GL_OES_texture_half_float GL_OES_texture_half_float_linear"); - group_.Initialize(); - EXPECT_FALSE(group_.texture_manager()->enable_float_linear()); - EXPECT_TRUE(group_.texture_manager()->enable_half_float_linear()); - EXPECT_THAT(group_.extensions(), Not(HasSubstr("GL_OES_texture_float"))); - EXPECT_THAT(group_.extensions(), HasSubstr("GL_OES_texture_half_float")); - EXPECT_THAT(group_.extensions(), - Not(HasSubstr("GL_OES_texture_float_linear"))); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_OES_texture_half_float_linear")); - EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_FLOAT)); - EXPECT_TRUE(group_.validators()->pixel_type.IsValid(GL_HALF_FLOAT_OES)); -} - -TEST_F(ContextGroupTest, InitializeEXT_framebuffer_multisample) { - SetupInitExpectations("GL_EXT_framebuffer_multisample"); - group_.Initialize(); - EXPECT_TRUE(group_.extension_flags().ext_framebuffer_multisample); - EXPECT_THAT(group_.extensions(), HasSubstr("GL_EXT_framebuffer_multisample")); - EXPECT_THAT(group_.extensions(), HasSubstr("GL_EXT_framebuffer_blit")); - EXPECT_TRUE(group_.validators()->frame_buffer_target.IsValid( - GL_READ_FRAMEBUFFER_EXT)); - EXPECT_TRUE(group_.validators()->frame_buffer_target.IsValid( - GL_DRAW_FRAMEBUFFER_EXT)); - EXPECT_TRUE(group_.validators()->g_l_state.IsValid( - GL_READ_FRAMEBUFFER_BINDING_EXT)); - EXPECT_TRUE(group_.validators()->render_buffer_parameter.IsValid( - GL_MAX_SAMPLES_EXT)); -} - -TEST_F(ContextGroupTest, InitializeEXT_texture_filter_anisotropic) { - SetupInitExpectations("GL_EXT_texture_filter_anisotropic"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_EXT_texture_filter_anisotropic")); - EXPECT_TRUE(group_.validators()->texture_parameter.IsValid( - GL_TEXTURE_MAX_ANISOTROPY_EXT)); - EXPECT_TRUE(group_.validators()->g_l_state.IsValid( - GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)); -} - -TEST_F(ContextGroupTest, InitializeEXT_ARB_depth_texture) { - SetupInitExpectations("GL_ARB_depth_texture"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_GOOGLE_depth_texture")); - EXPECT_TRUE(group_.validators()->texture_internal_format.IsValid( - GL_DEPTH_COMPONENT)); - EXPECT_TRUE(group_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT)); - EXPECT_TRUE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT)); - EXPECT_TRUE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT)); -} - -TEST_F(ContextGroupTest, InitializeOES_ARB_depth_texture) { - SetupInitExpectations("GL_OES_depth_texture"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_GOOGLE_depth_texture")); - EXPECT_TRUE(group_.validators()->texture_internal_format.IsValid( - GL_DEPTH_COMPONENT)); - EXPECT_TRUE(group_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT)); - EXPECT_TRUE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT)); - EXPECT_TRUE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT)); -} - -TEST_F(ContextGroupTest, InitializeEXT_packed_depth_stencil) { - SetupInitExpectations("GL_EXT_packed_depth_stencil"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_OES_packed_depth_stencil")); - EXPECT_TRUE(group_.validators()->render_buffer_format.IsValid( - GL_DEPTH24_STENCIL8)); - EXPECT_FALSE(group_.validators()->texture_internal_format.IsValid( - GL_DEPTH_COMPONENT)); - EXPECT_FALSE(group_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT)); - EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT)); - EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT)); -} - -TEST_F(ContextGroupTest, InitializeOES_packed_depth_stencil) { - SetupInitExpectations("GL_OES_packed_depth_stencil"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_OES_packed_depth_stencil")); - EXPECT_TRUE(group_.validators()->render_buffer_format.IsValid( - GL_DEPTH24_STENCIL8)); - EXPECT_FALSE(group_.validators()->texture_internal_format.IsValid( - GL_DEPTH_COMPONENT)); - EXPECT_FALSE(group_.validators()->texture_format.IsValid(GL_DEPTH_COMPONENT)); - EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_SHORT)); - EXPECT_FALSE(group_.validators()->pixel_type.IsValid(GL_UNSIGNED_INT)); -} - -TEST_F(ContextGroupTest, - InitializeOES_packed_depth_stencil_and_GL_ARB_depth_texture) { - SetupInitExpectations("GL_OES_packed_depth_stencil GL_ARB_depth_texture"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), - HasSubstr("GL_OES_packed_depth_stencil")); - EXPECT_TRUE(group_.validators()->render_buffer_format.IsValid( - GL_DEPTH24_STENCIL8)); - EXPECT_TRUE(group_.validators()->texture_internal_format.IsValid( - GL_DEPTH_STENCIL)); - EXPECT_TRUE(group_.validators()->texture_format.IsValid( - GL_DEPTH_STENCIL)); - EXPECT_TRUE(group_.validators()->pixel_type.IsValid( - GL_UNSIGNED_INT_24_8)); -} - -TEST_F(ContextGroupTest, InitializeOES_depth24) { - SetupInitExpectations("GL_OES_depth24"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), HasSubstr("GL_OES_depth24")); - EXPECT_TRUE(group_.validators()->render_buffer_format.IsValid( - GL_DEPTH_COMPONENT24)); -} - -TEST_F(ContextGroupTest, InitializeOES_standard_derivatives) { - SetupInitExpectations("GL_OES_standard_derivatives"); - group_.Initialize(); - EXPECT_THAT(group_.extensions(), HasSubstr("GL_OES_standard_derivatives")); - EXPECT_TRUE(group_.extension_flags().oes_standard_derivatives); + TestHelper::SetupContextGroupInitExpectations(gl_.get(), ""); + group_.Initialize(""); + EXPECT_EQ(static_cast<uint32>(TestHelper::kNumVertexAttribs), + group_.max_vertex_attribs()); + EXPECT_EQ(static_cast<uint32>(TestHelper::kNumTextureUnits), + group_.max_texture_units()); + EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxTextureImageUnits), + group_.max_texture_image_units()); + EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxVertexTextureImageUnits), + group_.max_vertex_texture_image_units()); + EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxFragmentUniformVectors), + group_.max_fragment_uniform_vectors()); + EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxVaryingVectors), + group_.max_varying_vectors()); + EXPECT_EQ(static_cast<uint32>(TestHelper::kMaxVertexUniformVectors), + group_.max_vertex_uniform_vectors()); + EXPECT_TRUE(group_.buffer_manager() != NULL); + EXPECT_TRUE(group_.framebuffer_manager() != NULL); + EXPECT_TRUE(group_.renderbuffer_manager() != NULL); + EXPECT_TRUE(group_.texture_manager() != NULL); + EXPECT_TRUE(group_.program_manager() != NULL); + EXPECT_TRUE(group_.shader_manager() != NULL); } } // namespace gles2 |