summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 07:03:47 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-14 07:03:47 +0000
commitd97590a48186b654dc37b7939222c8ea04877f02 (patch)
tree8ea8472b76a43535a4534986fdc8a167750df03c /gpu
parent98c549ec406f943a024aead6d2923fe95dccae22 (diff)
downloadchromium_src-d97590a48186b654dc37b7939222c8ea04877f02.zip
chromium_src-d97590a48186b654dc37b7939222c8ea04877f02.tar.gz
chromium_src-d97590a48186b654dc37b7939222c8ea04877f02.tar.bz2
add shared resource test
I was hoping to uncover a bug here but no luck. BUG=160247 Review URL: https://chromiumcodereview.appspot.com/11358179 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167618 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc4
-rw-r--r--gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc7
-rw-r--r--gpu/command_buffer/tests/gl_depth_texture_unittest.cc4
-rw-r--r--gpu/command_buffer/tests/gl_manager.cc92
-rw-r--r--gpu/command_buffer/tests/gl_manager.h25
-rw-r--r--gpu/command_buffer/tests/gl_pointcoord_unittest.cc4
-rw-r--r--gpu/command_buffer/tests/gl_program_unittests.cc2
-rw-r--r--gpu/command_buffer/tests/gl_query_unittests.cc2
-rw-r--r--gpu/command_buffer/tests/gl_shared_resources_unittests.cc58
-rw-r--r--gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc6
-rw-r--r--gpu/command_buffer/tests/gl_unittests.cc2
-rw-r--r--gpu/command_buffer/tests/gl_virtual_contexts_unittests.cc13
-rw-r--r--gpu/command_buffer/tests/occlusion_query_unittests.cc4
-rw-r--r--gpu/gpu.gyp1
14 files changed, 146 insertions, 78 deletions
diff --git a/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc b/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc
index 23f09d1..0c564b1 100644
--- a/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc
+++ b/gpu/command_buffer/tests/gl_bind_uniform_location_unittest.cc
@@ -18,7 +18,9 @@ class BindUniformLocationTest : public testing::Test {
protected:
static const GLsizei kResolution = 4;
virtual void SetUp() {
- gl_.Initialize(gfx::Size(kResolution, kResolution));
+ GLManager::Options options;
+ options.size = gfx::Size(kResolution, kResolution);
+ gl_.Initialize(options);
}
virtual void TearDown() {
diff --git a/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc b/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc
index bd53e51..17f9ebf 100644
--- a/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc
+++ b/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc
@@ -20,7 +20,7 @@ namespace gpu {
class GLCopyTextureCHROMIUMTest : public testing::Test {
protected:
virtual void SetUp() {
- gl_.Initialize(gfx::Size(4, 4));
+ gl_.Initialize(GLManager::Options());
glGenTextures(2, textures_);
glBindTexture(GL_TEXTURE_2D, textures_[1]);
@@ -406,7 +406,10 @@ TEST_F(GLCopyTextureCHROMIUMTest, ProgramStatePreservation) {
glBindTexture(GL_TEXTURE_2D, 0);
GLManager gl2;
- gl2.InitializeShared(gfx::Size(16, 16), &gl_);
+ GLManager::Options options;
+ options.size = gfx::Size(16, 16);
+ options.share_group_manager = &gl_;
+ gl2.Initialize(options);
gl_.MakeCurrent();
static const char* v_shader_str =
diff --git a/gpu/command_buffer/tests/gl_depth_texture_unittest.cc b/gpu/command_buffer/tests/gl_depth_texture_unittest.cc
index e7a01aae..d13104a 100644
--- a/gpu/command_buffer/tests/gl_depth_texture_unittest.cc
+++ b/gpu/command_buffer/tests/gl_depth_texture_unittest.cc
@@ -18,7 +18,9 @@ class DepthTextureTest : public testing::Test {
protected:
static const GLsizei kResolution = 64;
virtual void SetUp() {
- gl_.Initialize(gfx::Size(kResolution, kResolution));
+ GLManager::Options options;
+ options.size = gfx::Size(kResolution, kResolution);
+ gl_.Initialize(options);
}
virtual void TearDown() {
diff --git a/gpu/command_buffer/tests/gl_manager.cc b/gpu/command_buffer/tests/gl_manager.cc
index e96050e..3b0dee7 100644
--- a/gpu/command_buffer/tests/gl_manager.cc
+++ b/gpu/command_buffer/tests/gl_manager.cc
@@ -24,66 +24,54 @@
namespace gpu {
-GLManager::GLManager() {
+GLManager::Options::Options()
+ : size(4, 4),
+ share_group_manager(NULL),
+ share_mailbox_manager(NULL),
+ virtual_manager(NULL),
+ bind_generates_resource(false) {
}
-GLManager::~GLManager() {
-}
-
-void GLManager::Initialize(const gfx::Size& size) {
- Setup(size, NULL, NULL, NULL, NULL, NULL);
-}
-
-void GLManager::InitializeShared(
- const gfx::Size& size, GLManager* gl_manager) {
- DCHECK(gl_manager);
- Setup(
- size,
- gl_manager->mailbox_manager(),
- gl_manager->share_group(),
- gl_manager->decoder_->GetContextGroup(),
- gl_manager->gles2_implementation()->share_group(),
- NULL);
-}
-
-void GLManager::InitializeSharedMailbox(
- const gfx::Size& size, GLManager* gl_manager) {
- DCHECK(gl_manager);
- Setup(
- size,
- gl_manager->mailbox_manager(),
- gl_manager->share_group(),
- NULL,
- NULL,
- NULL);
+GLManager::GLManager() {
}
-void GLManager::InitializeVirtual(
- const gfx::Size& size, GLManager* real_gl_manager) {
- DCHECK(real_gl_manager);
- Setup(
- size,
- NULL,
- NULL,
- NULL,
- NULL,
- real_gl_manager->context());
+GLManager::~GLManager() {
}
-void GLManager::Setup(
- const gfx::Size& size,
- gles2::MailboxManager* mailbox_manager,
- gfx::GLShareGroup* share_group,
- gles2::ContextGroup* context_group,
- gles2::ShareGroup* client_share_group,
- gfx::GLContext* real_gl_context) {
+void GLManager::Initialize(const GLManager::Options& options) {
const int32 kCommandBufferSize = 1024 * 1024;
const size_t kStartTransferBufferSize = 4 * 1024 * 1024;
const size_t kMinTransferBufferSize = 1 * 256 * 1024;
const size_t kMaxTransferBufferSize = 16 * 1024 * 1024;
- const bool kBindGeneratesResource = false;
const bool kShareResources = true;
+ gles2::MailboxManager* mailbox_manager = NULL;
+ if (options.share_mailbox_manager) {
+ mailbox_manager = options.share_mailbox_manager->mailbox_manager();
+ } else if (options.share_group_manager) {
+ mailbox_manager = options.share_group_manager->mailbox_manager();
+ }
+
+ gfx::GLShareGroup* share_group = NULL;
+ if (options.share_group_manager) {
+ share_group = options.share_group_manager->share_group();
+ } else if (options.share_mailbox_manager) {
+ share_group = options.share_mailbox_manager->share_group();
+ }
+
+ gles2::ContextGroup* context_group = NULL;
+ gles2::ShareGroup* client_share_group = NULL;
+ if (options.share_group_manager) {
+ context_group = options.share_group_manager->decoder_->GetContextGroup();
+ client_share_group =
+ options.share_group_manager->gles2_implementation()->share_group();
+ }
+
+ gfx::GLContext* real_gl_context = NULL;
+ if (options.virtual_manager) {
+ options.virtual_manager->context();
+ }
+
// From <EGL/egl.h>.
const int32 EGL_ALPHA_SIZE = 0x3021;
const int32 EGL_BLUE_SIZE = 0x3022;
@@ -116,7 +104,7 @@ void GLManager::Setup(
context_group = new gles2::ContextGroup(mailbox_manager_.get(),
NULL,
NULL,
- kBindGeneratesResource);
+ options.bind_generates_resource);
}
decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group));
@@ -132,7 +120,7 @@ void GLManager::Setup(
decoder_->set_engine(gpu_scheduler_.get());
- surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, size);
+ surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, options.size);
ASSERT_TRUE(surface_.get() != NULL) << "could not create offscreen surface";
if (real_gl_context) {
@@ -153,7 +141,7 @@ void GLManager::Setup(
surface_.get(),
context_.get(),
true,
- size,
+ options.size,
::gpu::gles2::DisallowedFeatures(),
allowed_extensions,
attribs)) << "could not initialize decoder";
@@ -176,7 +164,7 @@ void GLManager::Setup(
client_share_group,
transfer_buffer_.get(),
kShareResources,
- kBindGeneratesResource));
+ options.bind_generates_resource));
ASSERT_TRUE(gles2_implementation_->Initialize(
kStartTransferBufferSize,
diff --git a/gpu/command_buffer/tests/gl_manager.h b/gpu/command_buffer/tests/gl_manager.h
index 31dd46c..5f42a36 100644
--- a/gpu/command_buffer/tests/gl_manager.h
+++ b/gpu/command_buffer/tests/gl_manager.h
@@ -36,13 +36,23 @@ class ShareGroup;
class GLManager {
public:
+ struct Options {
+ Options();
+ // The size of the backbuffer.
+ gfx::Size size;
+ // If not null will share resources with this context.
+ GLManager* share_group_manager;
+ // If not null will share a mailbox manager with this context.
+ GLManager* share_mailbox_manager;
+ // If not null will create a virtual manager based on this context.
+ GLManager* virtual_manager;
+ // Whether or not glBindXXX generates a resource.
+ bool bind_generates_resource;
+ };
GLManager();
~GLManager();
- void Initialize(const gfx::Size& size);
- void InitializeVirtual(const gfx::Size& size, GLManager* real_gl_manager);
- void InitializeShared(const gfx::Size& size, GLManager* gl_manager);
- void InitializeSharedMailbox(const gfx::Size& size, GLManager* gl_manager);
+ void Initialize(const Options& options);
void Destroy();
void MakeCurrent();
@@ -64,13 +74,6 @@ class GLManager {
}
private:
- void Setup(
- const gfx::Size& size,
- gles2::MailboxManager* mailbox_manager,
- gfx::GLShareGroup* share_group,
- gles2::ContextGroup* context_group,
- gles2::ShareGroup* client_share_group,
- gfx::GLContext* real_gl_context);
void PumpCommands();
bool GetBufferChanged(int32 transfer_buffer_id);
diff --git a/gpu/command_buffer/tests/gl_pointcoord_unittest.cc b/gpu/command_buffer/tests/gl_pointcoord_unittest.cc
index 41e7045..1c799e6 100644
--- a/gpu/command_buffer/tests/gl_pointcoord_unittest.cc
+++ b/gpu/command_buffer/tests/gl_pointcoord_unittest.cc
@@ -20,7 +20,9 @@ class PointCoordTest : public testing::Test {
protected:
virtual void SetUp() {
- gl_.Initialize(gfx::Size(kResolution, kResolution));
+ GLManager::Options options;
+ options.size = gfx::Size(kResolution, kResolution);
+ gl_.Initialize(options);
}
virtual void TearDown() {
diff --git a/gpu/command_buffer/tests/gl_program_unittests.cc b/gpu/command_buffer/tests/gl_program_unittests.cc
index 620987b..0314960 100644
--- a/gpu/command_buffer/tests/gl_program_unittests.cc
+++ b/gpu/command_buffer/tests/gl_program_unittests.cc
@@ -17,7 +17,7 @@ namespace gpu {
class GLProgramTest : public testing::Test {
protected:
virtual void SetUp() {
- gl_.Initialize(gfx::Size(4, 4));
+ gl_.Initialize(GLManager::Options());
}
virtual void TearDown() {
diff --git a/gpu/command_buffer/tests/gl_query_unittests.cc b/gpu/command_buffer/tests/gl_query_unittests.cc
index 9c169ed..90d3568 100644
--- a/gpu/command_buffer/tests/gl_query_unittests.cc
+++ b/gpu/command_buffer/tests/gl_query_unittests.cc
@@ -16,7 +16,7 @@ namespace gpu {
class QueryTest : public testing::Test {
protected:
virtual void SetUp() {
- gl_.Initialize(gfx::Size(2, 2));
+ gl_.Initialize(GLManager::Options());
}
virtual void TearDown() {
diff --git a/gpu/command_buffer/tests/gl_shared_resources_unittests.cc b/gpu/command_buffer/tests/gl_shared_resources_unittests.cc
new file mode 100644
index 0000000..e78a83e
--- /dev/null
+++ b/gpu/command_buffer/tests/gl_shared_resources_unittests.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+#include "base/logging.h"
+#include "gpu/command_buffer/tests/gl_manager.h"
+#include "gpu/command_buffer/tests/gl_test_utils.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace gpu {
+
+class GLSharedResources : public testing::Test {
+ protected:
+ virtual void SetUp() {
+ GLManager::Options options;
+#if ENABLE_DCHECK
+ // This can't be false if DCHECK is enabled because a DCHECK in
+ // gpu/command_buffer/client/share_group.h will trigger.
+ // The test below is making sure things don't break in release.
+ options.bind_generates_resource = false;
+#else
+ options.bind_generates_resource = true;
+#endif
+ gl1_.Initialize(options);
+ options.share_group_manager = &gl1_;
+ gl2_.Initialize(options);
+ }
+
+ virtual void TearDown() {
+ gl1_.Destroy();
+ gl2_.Destroy();
+ }
+
+ GLManager gl1_;
+ GLManager gl2_;
+};
+
+// Test that GL creating/deleting works across context.
+TEST_F(GLSharedResources, CreateDelete) {
+ gl1_.MakeCurrent();
+ GLuint tex = 0;
+ glGenTextures(1, &tex);
+ gl2_.MakeCurrent();
+ glBindTexture(GL_TEXTURE_2D, tex);
+ glDeleteTextures(1, &tex);
+ gl1_.MakeCurrent();
+ glBindTexture(GL_TEXTURE_2D,tex);
+ GLTestHelper::CheckGLError("no errors", __LINE__);
+ gl2_.MakeCurrent();
+ GLTestHelper::CheckGLError("no errors", __LINE__);
+}
+
+} // namespace gpu
+
diff --git a/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc b/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc
index f79f221..3ba05ba 100644
--- a/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc
+++ b/gpu/command_buffer/tests/gl_texture_mailbox_unittests.cc
@@ -43,8 +43,10 @@ uint32 ReadTexel(GLuint id, GLint x, GLint y) {
class GLTextureMailboxTest : public testing::Test {
protected:
virtual void SetUp() {
- gl1_.Initialize(gfx::Size(4, 4));
- gl2_.InitializeSharedMailbox(gfx::Size(4, 4), &gl1_);
+ gl1_.Initialize(GLManager::Options());
+ GLManager::Options options;
+ options.share_mailbox_manager = &gl1_;
+ gl2_.Initialize(options);
}
virtual void TearDown() {
diff --git a/gpu/command_buffer/tests/gl_unittests.cc b/gpu/command_buffer/tests/gl_unittests.cc
index de5e5d7..c585f97 100644
--- a/gpu/command_buffer/tests/gl_unittests.cc
+++ b/gpu/command_buffer/tests/gl_unittests.cc
@@ -15,7 +15,7 @@ namespace gpu {
class GLTest : public testing::Test {
protected:
virtual void SetUp() {
- gl_.Initialize(gfx::Size(4, 4));
+ gl_.Initialize(GLManager::Options());
}
virtual void TearDown() {
diff --git a/gpu/command_buffer/tests/gl_virtual_contexts_unittests.cc b/gpu/command_buffer/tests/gl_virtual_contexts_unittests.cc
index 8d89c06..29c69e6 100644
--- a/gpu/command_buffer/tests/gl_virtual_contexts_unittests.cc
+++ b/gpu/command_buffer/tests/gl_virtual_contexts_unittests.cc
@@ -22,10 +22,15 @@ class GLVirtualContextsTest : public testing::Test {
static const int kSize2 = 16;
virtual void SetUp() {
- gl_real_.Initialize(gfx::Size(kSize0, kSize0));
- gl_real_shared_.Initialize(gfx::Size(kSize0, kSize0));
- gl1_.InitializeVirtual(gfx::Size(kSize1, kSize1), &gl_real_shared_);
- gl2_.InitializeVirtual(gfx::Size(kSize2, kSize2), &gl_real_shared_);
+ GLManager::Options options;
+ options.size = gfx::Size(kSize0, kSize0);
+ gl_real_.Initialize(options);
+ gl_real_shared_.Initialize(options);
+ options.virtual_manager = &gl_real_shared_;
+ options.size = gfx::Size(kSize1, kSize1);
+ gl1_.Initialize(options);
+ options.size = gfx::Size(kSize2, kSize2);
+ gl2_.Initialize(options);
}
virtual void TearDown() {
diff --git a/gpu/command_buffer/tests/occlusion_query_unittests.cc b/gpu/command_buffer/tests/occlusion_query_unittests.cc
index 29ab481..88e3049 100644
--- a/gpu/command_buffer/tests/occlusion_query_unittests.cc
+++ b/gpu/command_buffer/tests/occlusion_query_unittests.cc
@@ -15,7 +15,9 @@ namespace gpu {
class OcclusionQueryTest : public testing::Test {
protected:
virtual void SetUp() {
- gl_.Initialize(gfx::Size(512, 512));
+ GLManager::Options options;
+ options.size = gfx::Size(512, 512);
+ gl_.Initialize(options);
}
virtual void TearDown() {
diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp
index c62f20f..437ce51 100644
--- a/gpu/gpu.gyp
+++ b/gpu/gpu.gyp
@@ -252,6 +252,7 @@
'command_buffer/tests/gl_manager.h',
'command_buffer/tests/gl_pointcoord_unittest.cc',
'command_buffer/tests/gl_program_unittests.cc',
+ 'command_buffer/tests/gl_shared_resources_unittests.cc',
'command_buffer/tests/gl_tests_main.cc',
'command_buffer/tests/gl_test_utils.cc',
'command_buffer/tests/gl_test_utils.h',