| Index: gpu/command_buffer/tests/gl_compressed_copy_texture_CHROMIUM_unittest.cc
|
| diff --git a/gpu/command_buffer/tests/gl_compressed_copy_texture_CHROMIUM_unittest.cc b/gpu/command_buffer/tests/gl_compressed_copy_texture_CHROMIUM_unittest.cc
|
| index b444bb9db9d91799dfadeea29399e3a3d23b3b06..333da3c72a36e2f032fb894936c17dfb12f97e7d 100644
|
| --- a/gpu/command_buffer/tests/gl_compressed_copy_texture_CHROMIUM_unittest.cc
|
| +++ b/gpu/command_buffer/tests/gl_compressed_copy_texture_CHROMIUM_unittest.cc
|
| @@ -22,12 +22,6 @@ namespace gpu {
|
|
|
| namespace {
|
|
|
| -enum CopyType { TexImage, TexSubImage };
|
| -const CopyType kCopyTypes[] = {
|
| - TexImage,
|
| - TexSubImage,
|
| -};
|
| -
|
| const uint8_t kCompressedImageColor[4] = {255u, 0u, 0u, 255u};
|
|
|
| // Single compressed ATC block of source pixels all set to:
|
| @@ -46,14 +40,6 @@ const uint8_t kCompressedImageATCIA[16] = {0xff, 0xff, 0x0, 0x0, 0x0, 0x0,
|
| const uint8_t kCompressedImageDXT1[8] = {0x00, 0xf8, 0x00, 0xf8,
|
| 0xaa, 0xaa, 0xaa, 0xaa};
|
|
|
| -// Four compressed DXT1 blocks solidly colored in red, green, blue and black:
|
| -// [R][G]
|
| -// [B][b]
|
| -const uint8_t kCompressedImageDXT1RGB[32] = {
|
| - 0x0, 0xf8, 0x0, 0xf8, 0xaa, 0xaa, 0xaa, 0xaa, 0xe0, 0x7, 0xe0,
|
| - 0x7, 0xaa, 0xaa, 0xaa, 0xaa, 0x1f, 0x0, 0x1f, 0x0, 0xaa, 0xaa,
|
| - 0xaa, 0xaa, 0x0, 0x0, 0x0, 0x0, 0xaa, 0xaa, 0xaa, 0xaa};
|
| -
|
| // Single compressed DXT5 block of source pixels all set to:
|
| // kCompressedImageColor.
|
| const uint8_t kCompressedImageDXT5[16] = {0xff, 0xff, 0x0, 0x0, 0x0, 0x0,
|
| @@ -65,16 +51,6 @@ const uint8_t kCompressedImageDXT5[16] = {0xff, 0xff, 0x0, 0x0, 0x0, 0x0,
|
| const uint8_t kCompressedImageETC1[8] = {0x0, 0x0, 0xf8, 0x2,
|
| 0xff, 0xff, 0x0, 0x0};
|
|
|
| -// Single block of zeroes, used for texture pre-allocation.
|
| -const uint8_t kInvalidCompressedImage[8] = {0x0, 0x0, 0x0, 0x0,
|
| - 0x0, 0x0, 0x0, 0x0};
|
| -
|
| -// Four blocks of zeroes, used for texture pre-allocation.
|
| -const uint8_t kInvalidCompressedImageLarge[32] = {
|
| - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
| - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
| - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
|
| -
|
| void glEnableDisable(GLint param, GLboolean value) {
|
| if (value)
|
| glEnable(param);
|
| @@ -86,8 +62,7 @@ void glEnableDisable(GLint param, GLboolean value) {
|
|
|
| // A collection of tests that exercise the GL_CHROMIUM_copy_texture extension.
|
| class GLCompressedCopyTextureCHROMIUMTest
|
| - : public testing::Test,
|
| - public ::testing::WithParamInterface<CopyType> {
|
| + : public testing::Test {
|
| protected:
|
| void SetUp() override {
|
| gl_.Initialize(GLManager::Options());
|
| @@ -125,20 +100,14 @@ class GLCompressedCopyTextureCHROMIUMTest
|
| GLuint framebuffer_id_;
|
| };
|
|
|
| -INSTANTIATE_TEST_CASE_P(CopyType,
|
| - GLCompressedCopyTextureCHROMIUMTest,
|
| - ::testing::ValuesIn(kCopyTypes));
|
| -
|
| // Test to ensure that the basic functionality of the extension works.
|
| -TEST_P(GLCompressedCopyTextureCHROMIUMTest, Basic) {
|
| +TEST_F(GLCompressedCopyTextureCHROMIUMTest, Basic) {
|
| if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) {
|
| LOG(INFO) <<
|
| "GL_EXT_texture_compression_dxt1 not supported. Skipping test...";
|
| return;
|
| }
|
|
|
| - CopyType copy_type = GetParam();
|
| -
|
| glBindTexture(GL_TEXTURE_2D, textures_[0]);
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| @@ -154,17 +123,7 @@ TEST_P(GLCompressedCopyTextureCHROMIUMTest, Basic) {
|
| 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);
|
| - if (copy_type == TexImage) {
|
| - glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]);
|
| - } else {
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
| - 4, 4, 0,
|
| - sizeof(kInvalidCompressedImage),
|
| - kInvalidCompressedImage);
|
| -
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1], 0, 0, 0, 0, 4, 4);
|
| - }
|
| + glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]);
|
| EXPECT_TRUE(glGetError() == GL_NO_ERROR);
|
|
|
| // Load shader program.
|
| @@ -193,9 +152,7 @@ TEST_P(GLCompressedCopyTextureCHROMIUMTest, Basic) {
|
| EXPECT_TRUE(GL_NO_ERROR == glGetError());
|
| }
|
|
|
| -TEST_P(GLCompressedCopyTextureCHROMIUMTest, InternalFormat) {
|
| - CopyType copy_type = GetParam();
|
| -
|
| +TEST_F(GLCompressedCopyTextureCHROMIUMTest, InternalFormat) {
|
| struct Image {
|
| const GLint format;
|
| const uint8_t* data;
|
| @@ -206,9 +163,8 @@ TEST_P(GLCompressedCopyTextureCHROMIUMTest, InternalFormat) {
|
| };
|
| std::vector<scoped_ptr<Image>> supported_formats;
|
|
|
| - if ((GLTestHelper::HasExtension("GL_AMD_compressed_ATC_texture") ||
|
| - GLTestHelper::HasExtension("GL_ATI_texture_compression_atitc")) &&
|
| - copy_type != TexSubImage) {
|
| + if (GLTestHelper::HasExtension("GL_AMD_compressed_ATC_texture") ||
|
| + GLTestHelper::HasExtension("GL_ATI_texture_compression_atitc")) {
|
| supported_formats.push_back(make_scoped_ptr(new Image(
|
| GL_ATC_RGB_AMD,
|
| kCompressedImageATC,
|
| @@ -231,8 +187,7 @@ TEST_P(GLCompressedCopyTextureCHROMIUMTest, InternalFormat) {
|
| kCompressedImageDXT5,
|
| sizeof(kCompressedImageDXT5))));
|
| }
|
| - if (GLTestHelper::HasExtension("GL_OES_compressed_ETC1_RGB8_texture") &&
|
| - copy_type != TexSubImage) {
|
| + if (GLTestHelper::HasExtension("GL_OES_compressed_ETC1_RGB8_texture")) {
|
| supported_formats.push_back(make_scoped_ptr(new Image(
|
| GL_ETC1_RGB8_OES,
|
| kCompressedImageETC1,
|
| @@ -254,30 +209,18 @@ TEST_P(GLCompressedCopyTextureCHROMIUMTest, InternalFormat) {
|
| 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);
|
| - if (copy_type == TexImage) {
|
| - glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1]);
|
| - } else {
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, image->format, 4, 4, 0,
|
| - sizeof(kInvalidCompressedImage),
|
| - kInvalidCompressedImage);
|
| -
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1], 0, 0, 0, 0, 4, 4);
|
| - }
|
| + glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]);
|
| EXPECT_TRUE(GL_NO_ERROR == glGetError());
|
| }
|
| }
|
|
|
| -TEST_P(GLCompressedCopyTextureCHROMIUMTest, InternalFormatNotSupported) {
|
| +TEST_F(GLCompressedCopyTextureCHROMIUMTest, InternalFormatNotSupported) {
|
| if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) {
|
| LOG(INFO) <<
|
| "GL_EXT_texture_compression_dxt1 not supported. Skipping test...";
|
| return;
|
| }
|
|
|
| - CopyType copy_type = GetParam();
|
| -
|
| const uint8_t kUncompressedPixels[1 * 4] = {255u, 0u, 0u, 255u};
|
|
|
| glBindTexture(GL_TEXTURE_2D, textures_[0]);
|
| @@ -296,27 +239,17 @@ TEST_P(GLCompressedCopyTextureCHROMIUMTest, InternalFormatNotSupported) {
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
|
| // Check that the GL_RGBA format reports an error.
|
| - if (copy_type == TexImage) {
|
| - glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]);
|
| - } else {
|
| - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
| - kUncompressedPixels);
|
| -
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1], 0, 0, 0, 0, 1, 1);
|
| - }
|
| + glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]);
|
| EXPECT_TRUE(GL_INVALID_OPERATION == glGetError());
|
| }
|
|
|
| -TEST_P(GLCompressedCopyTextureCHROMIUMTest, InvalidTextureIds) {
|
| +TEST_F(GLCompressedCopyTextureCHROMIUMTest, InvalidTextureIds) {
|
| if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) {
|
| LOG(INFO)
|
| << "GL_EXT_texture_compression_dxt1 not supported. Skipping test...";
|
| return;
|
| }
|
|
|
| - CopyType copy_type = GetParam();
|
| -
|
| glBindTexture(GL_TEXTURE_2D, textures_[0]);
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| @@ -332,52 +265,29 @@ TEST_P(GLCompressedCopyTextureCHROMIUMTest, InvalidTextureIds) {
|
| 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);
|
| - if (copy_type == TexImage) {
|
| - glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], 99993);
|
| - EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
|
| -
|
| - glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, 99994, textures_[1]);
|
| - EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
|
| -
|
| - glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, 99995, 99996);
|
| - EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
|
| -
|
| - glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]);
|
| - EXPECT_TRUE(glGetError() == GL_NO_ERROR);
|
| - } else {
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4,
|
| - 4, 0, sizeof(kInvalidCompressedImage),
|
| - kInvalidCompressedImage);
|
|
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], 99993, 0, 0,
|
| - 0, 0, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
|
| + glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], 99993);
|
| + EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
|
|
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, 99994, textures_[1], 0, 0,
|
| - 0, 0, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
|
| + glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, 99994, textures_[1]);
|
| + EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
|
|
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, 99995, 99996, 0, 0, 0, 0,
|
| - 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
|
| + glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, 99995, 99996);
|
| + EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
|
|
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1], 0, 0, 0, 0, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_NO_ERROR);
|
| - }
|
| + glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]);
|
| + EXPECT_TRUE(glGetError() == GL_NO_ERROR);
|
| }
|
|
|
| // Validate that some basic GL state is not touched upon execution of
|
| // the extension.
|
| -TEST_P(GLCompressedCopyTextureCHROMIUMTest, BasicStatePreservation) {
|
| +TEST_F(GLCompressedCopyTextureCHROMIUMTest, BasicStatePreservation) {
|
| if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) {
|
| LOG(INFO) <<
|
| "GL_EXT_texture_compression_dxt1 not supported. Skipping test...";
|
| return;
|
| }
|
|
|
| - CopyType copy_type = GetParam();
|
| -
|
| glBindTexture(GL_TEXTURE_2D, textures_[0]);
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| @@ -394,13 +304,6 @@ TEST_P(GLCompressedCopyTextureCHROMIUMTest, BasicStatePreservation) {
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
|
| - if (copy_type == TexSubImage) {
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
| - 4, 4, 0,
|
| - sizeof(kInvalidCompressedImage),
|
| - kInvalidCompressedImage);
|
| - }
|
| -
|
| GLboolean reference_settings[2] = { GL_TRUE, GL_FALSE };
|
| for (int x = 0; x < 2; ++x) {
|
| GLboolean setting = reference_settings[x];
|
| @@ -413,14 +316,7 @@ TEST_P(GLCompressedCopyTextureCHROMIUMTest, BasicStatePreservation) {
|
| glDepthMask(setting);
|
|
|
| glActiveTexture(GL_TEXTURE1 + x);
|
| -
|
| - if (copy_type == TexImage) {
|
| - glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1]);
|
| - } else {
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1], 0, 0, 0, 0, 4, 4);
|
| - }
|
| + glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]);
|
| EXPECT_TRUE(glGetError() == GL_NO_ERROR);
|
|
|
| EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST));
|
| @@ -450,15 +346,13 @@ TEST_P(GLCompressedCopyTextureCHROMIUMTest, BasicStatePreservation) {
|
|
|
| // Verify that invocation of the extension does not modify the bound
|
| // texture state.
|
| -TEST_P(GLCompressedCopyTextureCHROMIUMTest, TextureStatePreserved) {
|
| +TEST_F(GLCompressedCopyTextureCHROMIUMTest, TextureStatePreserved) {
|
| if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) {
|
| LOG(INFO) <<
|
| "GL_EXT_texture_compression_dxt1 not supported. Skipping test...";
|
| return;
|
| }
|
|
|
| - CopyType copy_type = GetParam();
|
| -
|
| glBindTexture(GL_TEXTURE_2D, textures_[0]);
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| @@ -475,13 +369,6 @@ TEST_P(GLCompressedCopyTextureCHROMIUMTest, TextureStatePreserved) {
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
| glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
|
| - if (copy_type == TexSubImage) {
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
| - 4, 4, 0,
|
| - sizeof(kInvalidCompressedImage),
|
| - kInvalidCompressedImage);
|
| - }
|
| -
|
| GLuint texture_ids[2];
|
| glGenTextures(2, texture_ids);
|
|
|
| @@ -491,12 +378,7 @@ TEST_P(GLCompressedCopyTextureCHROMIUMTest, TextureStatePreserved) {
|
| glActiveTexture(GL_TEXTURE1);
|
| glBindTexture(GL_TEXTURE_2D, texture_ids[1]);
|
|
|
| - if (copy_type == TexImage) {
|
| - glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]);
|
| - } else {
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1], 0, 0, 0, 0, 4, 4);
|
| - }
|
| + glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]);
|
| EXPECT_TRUE(GL_NO_ERROR == glGetError());
|
|
|
| GLint active_texture = 0;
|
| @@ -519,253 +401,4 @@ TEST_P(GLCompressedCopyTextureCHROMIUMTest, TextureStatePreserved) {
|
| EXPECT_TRUE(GL_NO_ERROR == glGetError());
|
| }
|
|
|
| -TEST_F(GLCompressedCopyTextureCHROMIUMTest, CopySubTextureDimension) {
|
| - if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) {
|
| - LOG(INFO) <<
|
| - "GL_EXT_texture_compression_dxt1 not supported. Skipping test...";
|
| - return;
|
| - }
|
| -
|
| - glBindTexture(GL_TEXTURE_2D, textures_[0]);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
| - 8, 8, 0,
|
| - sizeof(kCompressedImageDXT1RGB),
|
| - kCompressedImageDXT1RGB);
|
| - EXPECT_TRUE(glGetError() == GL_NO_ERROR);
|
| -
|
| - glBindTexture(GL_TEXTURE_2D, textures_[1]);
|
| - 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);
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
| - 8, 8, 0,
|
| - sizeof(kInvalidCompressedImageLarge),
|
| - kInvalidCompressedImageLarge);
|
| -
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1], 4, 4, 0, 0, 4, 4);
|
| - EXPECT_TRUE(GL_NO_ERROR == glGetError());
|
| -
|
| - // Reset the destination texture as it might have been converted to RGBA.
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
| - 8, 8, 0,
|
| - sizeof(kInvalidCompressedImageLarge),
|
| - kInvalidCompressedImageLarge);
|
| -
|
| - // xoffset < 0
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1],
|
| - -4, 4, 0, 0, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
|
| -
|
| - // x < 0
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1],
|
| - 4, 4, -4, 0, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
|
| -
|
| - // xoffset + width > dest_width
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1],
|
| - 8, 8, 0, 0, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
|
| -
|
| - // x + width > source_width
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1],
|
| - 0, 0, 8, 8, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_INVALID_VALUE);
|
| -
|
| - // xoffset not within block-boundary
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1],
|
| - 3, 0, 0, 0, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION);
|
| -
|
| - // x not within block-boundary
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1],
|
| - 0, 0, 3, 0, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_INVALID_OPERATION);
|
| -}
|
| -
|
| -TEST_F(GLCompressedCopyTextureCHROMIUMTest, CopySubTextureOffset) {
|
| - if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) {
|
| - LOG(INFO) <<
|
| - "GL_EXT_texture_compression_dxt1 not supported. Skipping test...";
|
| - return;
|
| - }
|
| -
|
| - glBindTexture(GL_TEXTURE_2D, textures_[0]);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
| - 8, 8, 0,
|
| - sizeof(kCompressedImageDXT1RGB),
|
| - kCompressedImageDXT1RGB);
|
| - EXPECT_TRUE(glGetError() == GL_NO_ERROR);
|
| -
|
| - glBindTexture(GL_TEXTURE_2D, textures_[1]);
|
| - 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);
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
| - 8, 8, 0,
|
| - sizeof(kInvalidCompressedImageLarge),
|
| - kInvalidCompressedImageLarge);
|
| -
|
| - // Load shader program.
|
| - GLuint program = LoadProgram();
|
| - ASSERT_NE(program, 0u);
|
| - GLint position_loc = glGetAttribLocation(program, "a_position");
|
| - GLint texture_loc = glGetUniformLocation(program, "u_texture");
|
| - ASSERT_NE(position_loc, -1);
|
| - ASSERT_NE(texture_loc, -1);
|
| - glUseProgram(program);
|
| -
|
| - // Load geometry.
|
| - GLuint vbo = GLTestHelper::SetupUnitQuad(position_loc);
|
| - ASSERT_NE(vbo, 0u);
|
| -
|
| - // Load texture.
|
| - glActiveTexture(GL_TEXTURE0);
|
| - glBindTexture(GL_TEXTURE_2D, textures_[1]);
|
| - glUniform1i(texture_loc, 0);
|
| -
|
| - const uint8_t kBlack[1 * 4] = {0u, 0u, 0u, 255u};
|
| - const uint8_t kRed[1 * 4] = {255u, 0u, 0u, 255u};
|
| - const uint8_t kGreen[1 * 4] = {0u, 255u, 0u, 255u};
|
| - const uint8_t kBlue[1 * 4] = {0u, 0u, 255u, 255u};
|
| -
|
| - // Copy each block one by one in a clockwise fashion. Note that we reset the
|
| - // destination texture after each copy operation. That's because on some
|
| - // platforms we might fallback into replacing the compressed destination
|
| - // texture with an uncompressed one.
|
| -
|
| - // Move blue block up.
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1], 0, 0, 0, 4, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_NO_ERROR);
|
| -
|
| - glDrawArrays(GL_TRIANGLES, 0, 6);
|
| - glFlush();
|
| - GLTestHelper::CheckPixels(0, 0, 2, 2, 0, kBlue);
|
| -
|
| - glBindTexture(GL_TEXTURE_2D, textures_[1]);
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
| - 8, 8, 0,
|
| - sizeof(kInvalidCompressedImageLarge),
|
| - kInvalidCompressedImageLarge);
|
| -
|
| - // Move red block right.
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1], 4, 0, 0, 0, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_NO_ERROR);
|
| -
|
| - glDrawArrays(GL_TRIANGLES, 0, 6);
|
| - glFlush();
|
| - GLTestHelper::CheckPixels(2, 0, 2, 2, 0, kRed);
|
| -
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
| - 8, 8, 0,
|
| - sizeof(kInvalidCompressedImageLarge),
|
| - kInvalidCompressedImageLarge);
|
| -
|
| - // Move green block down.
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1], 4, 4, 4, 0, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_NO_ERROR);
|
| -
|
| - glDrawArrays(GL_TRIANGLES, 0, 6);
|
| - glFlush();
|
| - GLTestHelper::CheckPixels(2, 2, 2, 2, 0, kGreen);
|
| -
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
| - 8, 8, 0,
|
| - sizeof(kInvalidCompressedImageLarge),
|
| - kInvalidCompressedImageLarge);
|
| -
|
| - // Move black block left.
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1], 0, 4, 4, 4, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_NO_ERROR);
|
| -
|
| - glDrawArrays(GL_TRIANGLES, 0, 6);
|
| - glFlush();
|
| - GLTestHelper::CheckPixels(0, 2, 2, 2, 0, kBlack);
|
| -
|
| - EXPECT_TRUE(GL_NO_ERROR == glGetError());
|
| -}
|
| -
|
| -TEST_F(GLCompressedCopyTextureCHROMIUMTest, CopySubTexturePreservation) {
|
| - if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) {
|
| - LOG(INFO) <<
|
| - "GL_EXT_texture_compression_dxt1 not supported. Skipping test...";
|
| - return;
|
| - }
|
| -
|
| - glBindTexture(GL_TEXTURE_2D, textures_[0]);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
| - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
| - 4, 4, 0,
|
| - sizeof(kCompressedImageDXT1),
|
| - kCompressedImageDXT1);
|
| - EXPECT_TRUE(glGetError() == GL_NO_ERROR);
|
| -
|
| - glBindTexture(GL_TEXTURE_2D, textures_[1]);
|
| - 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);
|
| - glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
| - 8, 8, 0,
|
| - sizeof(kCompressedImageDXT1RGB),
|
| - kCompressedImageDXT1RGB);
|
| -
|
| - // Copy entire first texture into the second, replacing the green block:
|
| - // [R][R]
|
| - // [B][b]
|
| - glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0],
|
| - textures_[1], 4, 0, 0, 0, 4, 4);
|
| - EXPECT_TRUE(glGetError() == GL_NO_ERROR);
|
| -
|
| - // Load shader program.
|
| - GLuint program = LoadProgram();
|
| - ASSERT_NE(program, 0u);
|
| - GLint position_loc = glGetAttribLocation(program, "a_position");
|
| - GLint texture_loc = glGetUniformLocation(program, "u_texture");
|
| - ASSERT_NE(position_loc, -1);
|
| - ASSERT_NE(texture_loc, -1);
|
| - glUseProgram(program);
|
| -
|
| - // Load geometry.
|
| - GLuint vbo = GLTestHelper::SetupUnitQuad(position_loc);
|
| - ASSERT_NE(vbo, 0u);
|
| -
|
| - // Load texture.
|
| - glActiveTexture(GL_TEXTURE0);
|
| - glBindTexture(GL_TEXTURE_2D, textures_[1]);
|
| - glUniform1i(texture_loc, 0);
|
| -
|
| - // Draw.
|
| - glDrawArrays(GL_TRIANGLES, 0, 6);
|
| - glFlush();
|
| -
|
| - const uint8_t kBlack[1 * 4] = {0u, 0u, 0u, 255u};
|
| - const uint8_t kRed[1 * 4] = {255u, 0u, 0u, 255u};
|
| - const uint8_t kBlue[1 * 4] = {0u, 0u, 255u, 255u};
|
| -
|
| - // Note that while destination texture is 8 x 8 pixels the viewport is only
|
| - // 4 x 4.
|
| - GLTestHelper::CheckPixels(0, 0, 4, 2, 0, kRed);
|
| - GLTestHelper::CheckPixels(0, 2, 2, 2, 0, kBlue);
|
| - GLTestHelper::CheckPixels(2, 2, 2, 2, 0, kBlack);
|
| - EXPECT_TRUE(GL_NO_ERROR == glGetError());
|
| -}
|
| -
|
| } // namespace gpu
|
|
|