OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GL_GLEXT_PROTOTYPES | 5 #ifndef GL_GLEXT_PROTOTYPES |
6 #define GL_GLEXT_PROTOTYPES | 6 #define GL_GLEXT_PROTOTYPES |
7 #endif | 7 #endif |
8 | 8 |
9 #include <GLES2/gl2.h> | 9 #include <GLES2/gl2.h> |
10 #include <GLES2/gl2ext.h> | 10 #include <GLES2/gl2ext.h> |
11 #include <GLES2/gl2extchromium.h> | 11 #include <GLES2/gl2extchromium.h> |
12 | 12 |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "gpu/command_buffer/tests/gl_manager.h" | 14 #include "gpu/command_buffer/tests/gl_manager.h" |
15 #include "gpu/command_buffer/tests/gl_test_utils.h" | 15 #include "gpu/command_buffer/tests/gl_test_utils.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 #define SHADER(src) #src | 19 #define SHADER(src) #src |
20 | 20 |
21 namespace gpu { | 21 namespace gpu { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
| 25 enum CopyType { TexImage, TexSubImage }; |
| 26 const CopyType kCopyTypes[] = { |
| 27 TexImage, |
| 28 TexSubImage, |
| 29 }; |
| 30 |
25 const uint8 kCompressedImageColor[4] = { 255u, 0u, 0u, 255u }; | 31 const uint8 kCompressedImageColor[4] = { 255u, 0u, 0u, 255u }; |
26 | 32 |
27 // Single compressed ATC block of source pixels all set to: | 33 // Single compressed ATC block of source pixels all set to: |
28 // kCompressedImageColor. | 34 // kCompressedImageColor. |
29 const uint8 kCompressedImageATC[8] = { | 35 const uint8 kCompressedImageATC[8] = { |
30 0x0, 0x7c, 0x0, 0xf8, 0x55, 0x55, 0x55, 0x55 }; | 36 0x0, 0x7c, 0x0, 0xf8, 0x55, 0x55, 0x55, 0x55 }; |
31 | 37 |
32 // Single compressed ATCIA block of source pixels all set to: | 38 // Single compressed ATCIA block of source pixels all set to: |
33 // kCompressedImageColor. | 39 // kCompressedImageColor. |
34 const uint8 kCompressedImageATCIA[16] = { | 40 const uint8 kCompressedImageATCIA[16] = { |
35 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, | 41 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, |
36 0x7c, 0x0, 0xf8, 0x55, 0x55, 0x55, 0x55 }; | 42 0x7c, 0x0, 0xf8, 0x55, 0x55, 0x55, 0x55 }; |
37 | 43 |
38 // Single compressed DXT1 block of source pixels all set to: | 44 // Single compressed DXT1 block of source pixels all set to: |
39 // kCompressedImageColor. | 45 // kCompressedImageColor. |
40 const uint8 kCompressedImageDXT1[8] = { | 46 const uint8 kCompressedImageDXT1[8] = { |
41 0x00, 0xf8, 0x00, 0xf8, 0xaa, 0xaa, 0xaa, 0xaa }; | 47 0x00, 0xf8, 0x00, 0xf8, 0xaa, 0xaa, 0xaa, 0xaa }; |
42 | 48 |
43 // Single compressed DXT5 block of source pixels all set to: | 49 // Single compressed DXT5 block of source pixels all set to: |
44 // kCompressedImageColor. | 50 // kCompressedImageColor. |
45 const uint8 kCompressedImageDXT5[16] = { | 51 const uint8 kCompressedImageDXT5[16] = { |
46 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, | 52 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, |
47 0xf8, 0x0, 0xf8, 0xaa, 0xaa, 0xaa, 0xaa }; | 53 0xf8, 0x0, 0xf8, 0xaa, 0xaa, 0xaa, 0xaa }; |
48 | 54 |
49 // Single compressed DXT1 block of source pixels all set to: | 55 // Single compressed DXT1 block of source pixels all set to: |
50 // kCompressedImageColor. | 56 // kCompressedImageColor. |
51 const uint8 kCompressedImageETC1[8] = { | 57 const uint8 kCompressedImageETC1[8] = { |
52 0x0, 0x0, 0xf8, 0x2, 0xff, 0xff, 0x0, 0x0 }; | 58 0x0, 0x0, 0xf8, 0x2, 0xff, 0xff, 0x0, 0x0 }; |
53 | 59 |
| 60 // Single block of zeroes, used for texture pre-allocation. |
| 61 const uint8 kInvalidCompressedImage[8] = { |
| 62 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; |
| 63 |
| 64 // Four blocks of zeroes, used for texture pre-allocation. |
| 65 const uint8 kInvalidCompressedImageLarge[32] = { |
| 66 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, |
| 67 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, |
| 68 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, |
| 69 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; |
| 70 |
54 void glEnableDisable(GLint param, GLboolean value) { | 71 void glEnableDisable(GLint param, GLboolean value) { |
55 if (value) | 72 if (value) |
56 glEnable(param); | 73 glEnable(param); |
57 else | 74 else |
58 glDisable(param); | 75 glDisable(param); |
59 } | 76 } |
60 | 77 |
61 } // unnamed namespace | 78 } // unnamed namespace |
62 | 79 |
63 // A collection of tests that exercise the GL_CHROMIUM_copy_texture extension. | 80 // A collection of tests that exercise the GL_CHROMIUM_copy_texture extension. |
64 class GLCompressedCopyTextureCHROMIUMTest | 81 class GLCompressedCopyTextureCHROMIUMTest |
65 : public testing::Test { | 82 : public testing::Test, |
| 83 public ::testing::WithParamInterface<CopyType> { |
66 protected: | 84 protected: |
67 void SetUp() override { | 85 void SetUp() override { |
68 gl_.Initialize(GLManager::Options()); | 86 gl_.Initialize(GLManager::Options()); |
69 | 87 |
70 glGenTextures(2, textures_); | 88 glGenTextures(2, textures_); |
71 } | 89 } |
72 | 90 |
73 void TearDown() override { | 91 void TearDown() override { |
74 glDeleteTextures(2, textures_); | 92 glDeleteTextures(2, textures_); |
75 gl_.Destroy(); | 93 gl_.Destroy(); |
(...skipping 17 matching lines...) Expand all Loading... |
93 } | 111 } |
94 ); | 112 ); |
95 return GLTestHelper::LoadProgram(v_shader_src, f_shader_src); | 113 return GLTestHelper::LoadProgram(v_shader_src, f_shader_src); |
96 } | 114 } |
97 | 115 |
98 GLManager gl_; | 116 GLManager gl_; |
99 GLuint textures_[2]; | 117 GLuint textures_[2]; |
100 GLuint framebuffer_id_; | 118 GLuint framebuffer_id_; |
101 }; | 119 }; |
102 | 120 |
| 121 INSTANTIATE_TEST_CASE_P(CopyType, |
| 122 GLCompressedCopyTextureCHROMIUMTest, |
| 123 ::testing::ValuesIn(kCopyTypes)); |
| 124 |
103 // Test to ensure that the basic functionality of the extension works. | 125 // Test to ensure that the basic functionality of the extension works. |
104 TEST_F(GLCompressedCopyTextureCHROMIUMTest, Basic) { | 126 TEST_P(GLCompressedCopyTextureCHROMIUMTest, Basic) { |
105 if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { | 127 if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { |
106 LOG(INFO) << | 128 LOG(INFO) << |
107 "GL_EXT_texture_compression_dxt1 not supported. Skipping test..."; | 129 "GL_EXT_texture_compression_dxt1 not supported. Skipping test..."; |
108 return; | 130 return; |
109 } | 131 } |
110 | 132 |
| 133 CopyType copy_type = GetParam(); |
| 134 |
111 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 135 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
112 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 136 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
113 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 137 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
114 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 138 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
115 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 139 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
116 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, | 140 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, |
117 4, 4, 0, | 141 4, 4, 0, |
118 sizeof(kCompressedImageDXT1), kCompressedImageDXT1); | 142 sizeof(kCompressedImageDXT1), kCompressedImageDXT1); |
119 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 143 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
120 | 144 |
121 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 145 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
122 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 146 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
123 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 147 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
124 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 148 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
125 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 149 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
126 glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]); | 150 if (copy_type == TexImage) { |
| 151 glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]); |
| 152 } else { |
| 153 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, |
| 154 4, 4, 0, |
| 155 sizeof(kInvalidCompressedImage), |
| 156 kInvalidCompressedImage); |
| 157 |
| 158 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], |
| 159 textures_[1], 0, 0, 0, 0, 4, 4); |
| 160 } |
127 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 161 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
128 | 162 |
129 // Load shader program. | 163 // Load shader program. |
130 GLuint program = LoadProgram(); | 164 GLuint program = LoadProgram(); |
131 ASSERT_NE(program, 0u); | 165 ASSERT_NE(program, 0u); |
132 GLint position_loc = glGetAttribLocation(program, "a_position"); | 166 GLint position_loc = glGetAttribLocation(program, "a_position"); |
133 GLint texture_loc = glGetUniformLocation(program, "u_texture"); | 167 GLint texture_loc = glGetUniformLocation(program, "u_texture"); |
134 ASSERT_NE(position_loc, -1); | 168 ASSERT_NE(position_loc, -1); |
135 ASSERT_NE(texture_loc, -1); | 169 ASSERT_NE(texture_loc, -1); |
136 glUseProgram(program); | 170 glUseProgram(program); |
137 | 171 |
138 // Load geometry. | 172 // Load geometry. |
139 GLuint vbo = GLTestHelper::SetupUnitQuad(position_loc); | 173 GLuint vbo = GLTestHelper::SetupUnitQuad(position_loc); |
140 ASSERT_NE(vbo, 0u); | 174 ASSERT_NE(vbo, 0u); |
141 | 175 |
142 // Load texture. | 176 // Load texture. |
143 glActiveTexture(GL_TEXTURE0); | 177 glActiveTexture(GL_TEXTURE0); |
144 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 178 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
145 glUniform1i(texture_loc, 0); | 179 glUniform1i(texture_loc, 0); |
146 | 180 |
147 // Draw. | 181 // Draw. |
148 glDrawArrays(GL_TRIANGLES, 0, 6); | 182 glDrawArrays(GL_TRIANGLES, 0, 6); |
149 glFlush(); | 183 glFlush(); |
150 | 184 |
151 GLTestHelper::CheckPixels(0, 0, 4, 4, 0, kCompressedImageColor); | 185 GLTestHelper::CheckPixels(0, 0, 4, 4, 0, kCompressedImageColor); |
152 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 186 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
153 } | 187 } |
154 | 188 |
155 TEST_F(GLCompressedCopyTextureCHROMIUMTest, InternalFormat) { | 189 TEST_P(GLCompressedCopyTextureCHROMIUMTest, InternalFormat) { |
| 190 CopyType copy_type = GetParam(); |
| 191 |
156 struct Image { | 192 struct Image { |
157 const GLint format; | 193 const GLint format; |
158 const uint8* data; | 194 const uint8* data; |
159 const GLsizei data_size; | 195 const GLsizei data_size; |
160 | 196 |
161 Image(const GLint format, const uint8* data, const GLsizei data_size) : | 197 Image(const GLint format, const uint8* data, const GLsizei data_size) : |
162 format(format), data(data), data_size(data_size) {} | 198 format(format), data(data), data_size(data_size) {} |
163 }; | 199 }; |
164 ScopedVector<Image> supported_formats; | 200 ScopedVector<Image> supported_formats; |
165 | 201 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 238 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
203 glCompressedTexImage2D(GL_TEXTURE_2D, 0, image->format, | 239 glCompressedTexImage2D(GL_TEXTURE_2D, 0, image->format, |
204 4, 4, 0, image->data_size, image->data); | 240 4, 4, 0, image->data_size, image->data); |
205 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 241 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
206 | 242 |
207 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 243 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
208 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 244 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
209 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 245 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
210 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 246 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
211 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 247 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
212 glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]); | 248 if (copy_type == TexImage) { |
| 249 glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], |
| 250 textures_[1]); |
| 251 } else { |
| 252 glCompressedTexImage2D(GL_TEXTURE_2D, 0, image->format, 4, 4, 0, |
| 253 sizeof(kInvalidCompressedImage), |
| 254 kInvalidCompressedImage); |
| 255 |
| 256 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], |
| 257 textures_[1], 0, 0, 0, 0, 4, 4); |
| 258 } |
213 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 259 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
214 } | 260 } |
215 } | 261 } |
216 | 262 |
217 TEST_F(GLCompressedCopyTextureCHROMIUMTest, InternalFormatNotSupported) { | 263 TEST_P(GLCompressedCopyTextureCHROMIUMTest, InternalFormatNotSupported) { |
218 if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { | 264 if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { |
219 LOG(INFO) << | 265 LOG(INFO) << |
220 "GL_EXT_texture_compression_dxt1 not supported. Skipping test..."; | 266 "GL_EXT_texture_compression_dxt1 not supported. Skipping test..."; |
221 return; | 267 return; |
222 } | 268 } |
223 | 269 |
| 270 CopyType copy_type = GetParam(); |
| 271 |
224 const uint8 kUncompressedPixels[1 * 4] = { 255u, 0u, 0u, 255u }; | 272 const uint8 kUncompressedPixels[1 * 4] = { 255u, 0u, 0u, 255u }; |
225 | 273 |
226 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 274 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
227 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 275 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
228 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 276 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
229 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 277 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
230 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 278 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
231 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, | 279 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
232 kUncompressedPixels); | 280 kUncompressedPixels); |
233 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 281 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
234 | 282 |
235 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 283 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
236 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 284 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
237 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 285 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
238 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 286 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
239 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 287 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
240 | 288 |
241 // Check that the GL_RGBA format reports an error. | 289 // Check that the GL_RGBA format reports an error. |
242 glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]); | 290 if (copy_type == TexImage) { |
| 291 glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]); |
| 292 } else { |
| 293 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 294 kUncompressedPixels); |
| 295 |
| 296 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], |
| 297 textures_[1], 0, 0, 0, 0, 1, 1); |
| 298 } |
243 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()); | 299 EXPECT_TRUE(GL_INVALID_OPERATION == glGetError()); |
244 } | 300 } |
245 | 301 |
246 // Validate that some basic GL state is not touched upon execution of | 302 // Validate that some basic GL state is not touched upon execution of |
247 // the extension. | 303 // the extension. |
248 TEST_F(GLCompressedCopyTextureCHROMIUMTest, BasicStatePreservation) { | 304 TEST_P(GLCompressedCopyTextureCHROMIUMTest, BasicStatePreservation) { |
249 if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { | 305 if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { |
250 LOG(INFO) << | 306 LOG(INFO) << |
251 "GL_EXT_texture_compression_dxt1 not supported. Skipping test..."; | 307 "GL_EXT_texture_compression_dxt1 not supported. Skipping test..."; |
252 return; | 308 return; |
253 } | 309 } |
254 | 310 |
| 311 CopyType copy_type = GetParam(); |
| 312 |
255 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 313 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
256 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 314 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
257 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 315 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
258 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 316 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
259 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 317 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
260 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, | 318 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, |
261 4, 4, 0, | 319 4, 4, 0, |
262 sizeof(kCompressedImageDXT1), kCompressedImageDXT1); | 320 sizeof(kCompressedImageDXT1), kCompressedImageDXT1); |
263 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 321 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
264 | 322 |
265 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 323 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
266 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 324 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
267 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 325 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
268 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 326 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
269 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 327 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
270 | 328 |
| 329 if (copy_type == TexSubImage) { |
| 330 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, |
| 331 4, 4, 0, |
| 332 sizeof(kInvalidCompressedImage), |
| 333 kInvalidCompressedImage); |
| 334 } |
| 335 |
271 GLboolean reference_settings[2] = { GL_TRUE, GL_FALSE }; | 336 GLboolean reference_settings[2] = { GL_TRUE, GL_FALSE }; |
272 for (int x = 0; x < 2; ++x) { | 337 for (int x = 0; x < 2; ++x) { |
273 GLboolean setting = reference_settings[x]; | 338 GLboolean setting = reference_settings[x]; |
274 glEnableDisable(GL_DEPTH_TEST, setting); | 339 glEnableDisable(GL_DEPTH_TEST, setting); |
275 glEnableDisable(GL_SCISSOR_TEST, setting); | 340 glEnableDisable(GL_SCISSOR_TEST, setting); |
276 glEnableDisable(GL_STENCIL_TEST, setting); | 341 glEnableDisable(GL_STENCIL_TEST, setting); |
277 glEnableDisable(GL_CULL_FACE, setting); | 342 glEnableDisable(GL_CULL_FACE, setting); |
278 glEnableDisable(GL_BLEND, setting); | 343 glEnableDisable(GL_BLEND, setting); |
279 glColorMask(setting, setting, setting, setting); | 344 glColorMask(setting, setting, setting, setting); |
280 glDepthMask(setting); | 345 glDepthMask(setting); |
281 | 346 |
282 glActiveTexture(GL_TEXTURE1 + x); | 347 glActiveTexture(GL_TEXTURE1 + x); |
283 | 348 |
284 glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]); | 349 if (copy_type == TexImage) { |
| 350 glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], |
| 351 textures_[1]); |
| 352 } else { |
| 353 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], |
| 354 textures_[1], 0, 0, 0, 0, 4, 4); |
| 355 } |
285 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 356 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
286 | 357 |
287 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST)); | 358 EXPECT_EQ(setting, glIsEnabled(GL_DEPTH_TEST)); |
288 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST)); | 359 EXPECT_EQ(setting, glIsEnabled(GL_SCISSOR_TEST)); |
289 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST)); | 360 EXPECT_EQ(setting, glIsEnabled(GL_STENCIL_TEST)); |
290 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE)); | 361 EXPECT_EQ(setting, glIsEnabled(GL_CULL_FACE)); |
291 EXPECT_EQ(setting, glIsEnabled(GL_BLEND)); | 362 EXPECT_EQ(setting, glIsEnabled(GL_BLEND)); |
292 | 363 |
293 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; | 364 GLboolean bool_array[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE }; |
294 glGetBooleanv(GL_DEPTH_WRITEMASK, bool_array); | 365 glGetBooleanv(GL_DEPTH_WRITEMASK, bool_array); |
295 EXPECT_EQ(setting, bool_array[0]); | 366 EXPECT_EQ(setting, bool_array[0]); |
296 | 367 |
297 bool_array[0] = GL_FALSE; | 368 bool_array[0] = GL_FALSE; |
298 glGetBooleanv(GL_COLOR_WRITEMASK, bool_array); | 369 glGetBooleanv(GL_COLOR_WRITEMASK, bool_array); |
299 EXPECT_EQ(setting, bool_array[0]); | 370 EXPECT_EQ(setting, bool_array[0]); |
300 EXPECT_EQ(setting, bool_array[1]); | 371 EXPECT_EQ(setting, bool_array[1]); |
301 EXPECT_EQ(setting, bool_array[2]); | 372 EXPECT_EQ(setting, bool_array[2]); |
302 EXPECT_EQ(setting, bool_array[3]); | 373 EXPECT_EQ(setting, bool_array[3]); |
303 | 374 |
304 GLint active_texture = 0; | 375 GLint active_texture = 0; |
305 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); | 376 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); |
306 EXPECT_EQ(GL_TEXTURE1 + x, active_texture); | 377 EXPECT_EQ(GL_TEXTURE1 + x, active_texture); |
307 } | 378 } |
308 | 379 |
309 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 380 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
310 }; | 381 }; |
311 | 382 |
312 // Verify that invocation of the extension does not modify the bound | 383 // Verify that invocation of the extension does not modify the bound |
313 // texture state. | 384 // texture state. |
314 TEST_F(GLCompressedCopyTextureCHROMIUMTest, TextureStatePreserved) { | 385 TEST_P(GLCompressedCopyTextureCHROMIUMTest, TextureStatePreserved) { |
315 if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { | 386 if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { |
316 LOG(INFO) << | 387 LOG(INFO) << |
317 "GL_EXT_texture_compression_dxt1 not supported. Skipping test..."; | 388 "GL_EXT_texture_compression_dxt1 not supported. Skipping test..."; |
318 return; | 389 return; |
319 } | 390 } |
320 | 391 |
| 392 CopyType copy_type = GetParam(); |
| 393 |
321 glBindTexture(GL_TEXTURE_2D, textures_[0]); | 394 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
322 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 395 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
323 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 396 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
324 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 397 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
325 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 398 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
326 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, | 399 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, |
327 4, 4, 0, | 400 4, 4, 0, |
328 sizeof(kCompressedImageDXT1), kCompressedImageDXT1); | 401 sizeof(kCompressedImageDXT1), kCompressedImageDXT1); |
329 EXPECT_TRUE(glGetError() == GL_NO_ERROR); | 402 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
330 | 403 |
331 glBindTexture(GL_TEXTURE_2D, textures_[1]); | 404 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
332 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 405 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
333 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 406 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
334 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 407 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
335 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 408 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
336 | 409 |
| 410 if (copy_type == TexSubImage) { |
| 411 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, |
| 412 4, 4, 0, |
| 413 sizeof(kInvalidCompressedImage), |
| 414 kInvalidCompressedImage); |
| 415 } |
| 416 |
337 GLuint texture_ids[2]; | 417 GLuint texture_ids[2]; |
338 glGenTextures(2, texture_ids); | 418 glGenTextures(2, texture_ids); |
339 | 419 |
340 glActiveTexture(GL_TEXTURE0); | 420 glActiveTexture(GL_TEXTURE0); |
341 glBindTexture(GL_TEXTURE_2D, texture_ids[0]); | 421 glBindTexture(GL_TEXTURE_2D, texture_ids[0]); |
342 | 422 |
343 glActiveTexture(GL_TEXTURE1); | 423 glActiveTexture(GL_TEXTURE1); |
344 glBindTexture(GL_TEXTURE_2D, texture_ids[1]); | 424 glBindTexture(GL_TEXTURE_2D, texture_ids[1]); |
345 | 425 |
346 glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]); | 426 if (copy_type == TexImage) { |
| 427 glCompressedCopyTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1]); |
| 428 } else { |
| 429 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], |
| 430 textures_[1], 0, 0, 0, 0, 4, 4); |
| 431 } |
347 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 432 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
348 | 433 |
349 GLint active_texture = 0; | 434 GLint active_texture = 0; |
350 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); | 435 glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); |
351 EXPECT_EQ(GL_TEXTURE1, active_texture); | 436 EXPECT_EQ(GL_TEXTURE1, active_texture); |
352 | 437 |
353 GLint bound_texture = 0; | 438 GLint bound_texture = 0; |
354 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 439 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
355 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); | 440 EXPECT_EQ(texture_ids[1], static_cast<GLuint>(bound_texture)); |
356 glBindTexture(GL_TEXTURE_2D, 0); | 441 glBindTexture(GL_TEXTURE_2D, 0); |
357 | 442 |
358 bound_texture = 0; | 443 bound_texture = 0; |
359 glActiveTexture(GL_TEXTURE0); | 444 glActiveTexture(GL_TEXTURE0); |
360 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); | 445 glGetIntegerv(GL_TEXTURE_BINDING_2D, &bound_texture); |
361 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); | 446 EXPECT_EQ(texture_ids[0], static_cast<GLuint>(bound_texture)); |
362 glBindTexture(GL_TEXTURE_2D, 0); | 447 glBindTexture(GL_TEXTURE_2D, 0); |
363 | 448 |
364 glDeleteTextures(2, texture_ids); | 449 glDeleteTextures(2, texture_ids); |
365 | 450 |
366 EXPECT_TRUE(GL_NO_ERROR == glGetError()); | 451 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
367 } | 452 } |
368 | 453 |
| 454 TEST_F(GLCompressedCopyTextureCHROMIUMTest, CopySubTextureDimension) { |
| 455 if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { |
| 456 LOG(INFO) << |
| 457 "GL_EXT_texture_compression_dxt1 not supported. Skipping test..."; |
| 458 return; |
| 459 } |
| 460 |
| 461 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 462 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 463 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 464 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 465 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 466 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, |
| 467 4, 4, 0, |
| 468 sizeof(kCompressedImageDXT1), kCompressedImageDXT1); |
| 469 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 470 |
| 471 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 472 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 473 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 474 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 475 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 476 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, |
| 477 8, 8, 0, |
| 478 sizeof(kInvalidCompressedImageLarge), |
| 479 kInvalidCompressedImageLarge); |
| 480 |
| 481 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], |
| 482 textures_[1], 1, 1, 0, 0, 1, 1); |
| 483 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 484 |
| 485 // xoffset < 0 |
| 486 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], |
| 487 -1, 1, 0, 0, 1, 1); |
| 488 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); |
| 489 |
| 490 // x < 0 |
| 491 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], |
| 492 1, 1, -1, 0, 1, 1); |
| 493 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); |
| 494 |
| 495 // xoffset + width > dest_width |
| 496 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], |
| 497 7, 7, 0, 0, 2, 2); |
| 498 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); |
| 499 |
| 500 // x + width > source_width |
| 501 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], textures_[1], |
| 502 0, 0, 3, 3, 2, 2); |
| 503 EXPECT_TRUE(glGetError() == GL_INVALID_VALUE); |
| 504 } |
| 505 |
| 506 TEST_F(GLCompressedCopyTextureCHROMIUMTest, CopySubTextureOffset) { |
| 507 if (!GLTestHelper::HasExtension("GL_EXT_texture_compression_dxt1")) { |
| 508 LOG(INFO) << |
| 509 "GL_EXT_texture_compression_dxt1 not supported. Skipping test..."; |
| 510 return; |
| 511 } |
| 512 |
| 513 // Four compressed DXT1 blocks solidly colored in red, green, blue and black: |
| 514 // [R][G] |
| 515 // [B][b] |
| 516 const uint8 kRGBImage[32] = { |
| 517 0x0, 0xf8, 0x0, 0xf8, 0xaa, 0xaa, 0xaa, 0xaa, |
| 518 0xe0, 0x7, 0xe0, 0x7, 0xaa, 0xaa, 0xaa, 0xaa, |
| 519 0x1f, 0x0, 0x1f, 0x0, 0xaa, 0xaa, 0xaa, 0xaa, |
| 520 0x0, 0x0, 0x0, 0x0, 0xaa, 0xaa, 0xaa, 0xaa }; |
| 521 |
| 522 glBindTexture(GL_TEXTURE_2D, textures_[0]); |
| 523 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 524 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 525 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 526 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 527 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, |
| 528 8, 8, 0, |
| 529 sizeof(kRGBImage), |
| 530 kRGBImage); |
| 531 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 532 |
| 533 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 534 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 535 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 536 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 537 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 538 glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, |
| 539 8, 8, 0, |
| 540 sizeof(kInvalidCompressedImageLarge), |
| 541 kInvalidCompressedImageLarge); |
| 542 |
| 543 // Copy each block in a clockwise fashion, producing an image like this: |
| 544 // [B][R] |
| 545 // [b][G] |
| 546 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], |
| 547 textures_[1], 0, 0, 0, 4, 4, 4); |
| 548 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 549 |
| 550 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], |
| 551 textures_[1], 4, 0, 0, 0, 4, 4); |
| 552 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 553 |
| 554 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], |
| 555 textures_[1], 4, 4, 4, 0, 4, 4); |
| 556 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 557 |
| 558 glCompressedCopySubTextureCHROMIUM(GL_TEXTURE_2D, textures_[0], |
| 559 textures_[1], 0, 4, 4, 4, 4, 4); |
| 560 EXPECT_TRUE(glGetError() == GL_NO_ERROR); |
| 561 |
| 562 // Load shader program. |
| 563 GLuint program = LoadProgram(); |
| 564 ASSERT_NE(program, 0u); |
| 565 GLint position_loc = glGetAttribLocation(program, "a_position"); |
| 566 GLint texture_loc = glGetUniformLocation(program, "u_texture"); |
| 567 ASSERT_NE(position_loc, -1); |
| 568 ASSERT_NE(texture_loc, -1); |
| 569 glUseProgram(program); |
| 570 |
| 571 // Load geometry. |
| 572 GLuint vbo = GLTestHelper::SetupUnitQuad(position_loc); |
| 573 ASSERT_NE(vbo, 0u); |
| 574 |
| 575 // Load texture. |
| 576 glActiveTexture(GL_TEXTURE0); |
| 577 glBindTexture(GL_TEXTURE_2D, textures_[1]); |
| 578 glUniform1i(texture_loc, 0); |
| 579 |
| 580 // Draw. |
| 581 glDrawArrays(GL_TRIANGLES, 0, 6); |
| 582 glFlush(); |
| 583 |
| 584 const uint8 kBlack[1 * 4] = {0u, 0u, 0u, 255u}; |
| 585 const uint8 kRed[1 * 4] = {255u, 0u, 0u, 255u}; |
| 586 const uint8 kGreen[1 * 4] = {0u, 255u, 0u, 255u}; |
| 587 const uint8 kBlue[1 * 4] = {0u, 0u, 255u, 255u}; |
| 588 |
| 589 // Note that while destination texture is 8 x 8 pixels the viewport is only |
| 590 // 4 x 4. |
| 591 GLTestHelper::CheckPixels(0, 0, 2, 2, 0, kBlue); |
| 592 GLTestHelper::CheckPixels(2, 0, 2, 2, 0, kRed); |
| 593 GLTestHelper::CheckPixels(0, 2, 2, 2, 0, kBlack); |
| 594 GLTestHelper::CheckPixels(2, 2, 2, 2, 0, kGreen); |
| 595 EXPECT_TRUE(GL_NO_ERROR == glGetError()); |
| 596 } |
| 597 |
369 } // namespace gpu | 598 } // namespace gpu |
OLD | NEW |