Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc

Issue 1547873002: Allow GL_TEXTURE_RECTANGLE_ARB to be the destination target for copyTextureCHROMIUM. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from kbr. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc
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 682f0d7dbe39ff62d0d26d03822c63c4a2ffe1f9..c47474a5a5faa927b869d6d1d62a4d1049e6ef1c 100644
--- a/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc
+++ b/gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc
@@ -32,31 +32,47 @@ class GLCopyTextureCHROMIUMTest
: public testing::Test,
public ::testing::WithParamInterface<CopyType> {
protected:
- void SetUp() override {
- gl_.Initialize(GLManager::Options());
+ void CreateAndBindDestinationTextureAndFBO(GLenum target) {
glGenTextures(2, textures_);
- glBindTexture(GL_TEXTURE_2D, textures_[1]);
+ glBindTexture(target, textures_[1]);
// Some drivers (NVidia/SGX) require texture settings to be a certain way or
// they won't report FRAMEBUFFER_COMPLETE.
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glGenFramebuffers(1, &framebuffer_id_);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id_);
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target,
textures_[1], 0);
}
+ void SetUp() override {
+ gl_.Initialize(GLManager::Options());
+
+ CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
+ }
+
void TearDown() override {
glDeleteTextures(2, textures_);
glDeleteFramebuffers(1, &framebuffer_id_);
gl_.Destroy();
}
+ void CreateBackingForTexture(GLenum target, GLsizei width, GLsizei height) {
+ if (target == GL_TEXTURE_RECTANGLE_ARB) {
+ GLuint image_id = glCreateGpuMemoryBufferImageCHROMIUM(
+ width, height, GL_RGBA, GL_READ_WRITE_CHROMIUM);
+ glBindTexImage2DCHROMIUM(target, image_id);
+ } else {
+ glTexImage2D(target, 0, GL_RGBA, width, height, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, nullptr);
+ }
+ }
+
GLManager gl_;
GLuint textures_[2];
GLuint framebuffer_id_;
@@ -150,7 +166,7 @@ TEST_P(GLCopyTextureCHROMIUMTest, InternalFormat) {
CopyType copy_type = GetParam();
GLint src_formats[] = {GL_ALPHA, GL_RGB, GL_RGBA,
GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_BGRA_EXT};
- GLint dest_formats[] = {GL_RGB, GL_RGBA};
+ GLint dest_formats[] = {GL_RGB, GL_RGBA, GL_BGRA_EXT};
for (size_t src_index = 0; src_index < arraysize(src_formats); src_index++) {
for (size_t dest_index = 0; dest_index < arraysize(dest_formats);
@@ -741,4 +757,98 @@ TEST_F(GLCopyTextureCHROMIUMTest, CopySubTextureOffset) {
EXPECT_TRUE(GL_NO_ERROR == glGetError());
}
+TEST_F(GLCopyTextureCHROMIUMTest, CopyTextureBetweenTexture2DAndRectangleArb) {
+ if (!GLTestHelper::HasExtension("GL_ARB_texture_rectangle")) {
+ LOG(INFO) <<
+ "GL_ARB_texture_rectangle not supported. Skipping test...";
+ return;
+ }
+
+ GLenum src_targets[] = {GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_2D};
+ GLenum dest_targets[] = {GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_2D};
+ GLsizei src_width = 30;
+ GLsizei src_height = 14;
+ GLsizei dest_width = 15;
+ GLsizei dest_height = 13;
+ GLsizei copy_region_x = 1;
+ GLsizei copy_region_y = 1;
+ GLsizei copy_region_width = 5;
+ GLsizei copy_region_height = 3;
+ uint8_t red[1 * 4] = {255u, 0u, 0u, 255u};
+ uint8_t blue[1 * 4] = {0u, 0u, 255u, 255u};
+ uint8_t green[1 * 4] = {0u, 255u, 0, 255u};
+ uint8_t white[1 * 4] = {255u, 255u, 255u, 255u};
+ uint8_t grey[1 * 4] = {199u, 199u, 199u, 255u};
+
+ for (size_t src_index = 0; src_index < arraysize(src_targets); src_index++) {
+ GLenum src_target = src_targets[src_index];
+ for (size_t dest_index = 0; dest_index < arraysize(dest_targets);
+ dest_index++) {
+ GLenum dest_target = dest_targets[dest_index];
+
+ // SetUp() sets up textures with the wrong parameters for this test, and
+ // TearDown() expects to successfully delete textures/framebuffers, so
+ // this is the right place for the delete/create calls.
+ glDeleteTextures(2, textures_);
+ glDeleteFramebuffers(1, &framebuffer_id_);
+ CreateAndBindDestinationTextureAndFBO(dest_target);
+
+ // Allocate source and destination textures.
+ glBindTexture(src_target, textures_[0]);
+ CreateBackingForTexture(src_target, src_width, src_height);
+
+ glBindTexture(dest_target, textures_[1]);
+ CreateBackingForTexture(dest_target, dest_width, dest_height);
+
+ // The bottom left is red, bottom right is blue, top left is green, top
+ // right is white.
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, src_target,
+ textures_[0], 0);
+ glBindTexture(src_target, textures_[0]);
+ for (GLint x = 0; x < src_width; ++x) {
+ for (GLint y = 0; y < src_height; ++y) {
+ uint8_t* data;
+ if (x < src_width / 2) {
+ data = y < src_height / 2 ? red : green;
+ } else {
+ data = y < src_height / 2 ? blue : white;
+ }
+ glTexSubImage2D(src_target, 0, x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE,
+ data);
+ }
+ }
+
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, dest_target,
+ textures_[1], 0);
+ glBindTexture(dest_target, textures_[1]);
+
+ // Copy the subtexture x=[13,18) y=[6,9) to the destination.
+ glClearColor(grey[0] / 255.f, grey[1] / 255.f, grey[2] / 255.f, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glCopySubTextureCHROMIUM(textures_[0], textures_[1], copy_region_x,
+ copy_region_y, 13, 6, copy_region_width,
+ copy_region_height, false, false, false);
+ EXPECT_TRUE(GL_NO_ERROR == glGetError());
+
+ for (GLint x = 0; x < dest_width; ++x) {
+ for (GLint y = 0; y < dest_height; ++y) {
+ if (x < copy_region_x || x >= copy_region_x + copy_region_width ||
+ y < copy_region_y || y >= copy_region_y + copy_region_height) {
+ GLTestHelper::CheckPixels(x, y, 1, 1, 0, grey);
+ continue;
+ }
+
+ uint8_t* expected_color;
+ if (x < copy_region_x + 2) {
+ expected_color = y < copy_region_y + 1 ? red : green;
+ } else {
+ expected_color = y < copy_region_y + 1 ? blue : white;
+ }
+ GLTestHelper::CheckPixels(x, y, 1, 1, 0, expected_color);
+ }
+ }
+ }
+ }
+}
+
} // namespace gpu
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698