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

Side by Side Diff: gpu/command_buffer/tests/gl_copy_texture_CHROMIUM_unittest.cc

Issue 2656563002: Support cube map dest target for CopyTextureCHROMIUM extension (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include <GLES3/gl3.h> 12 #include <GLES3/gl3.h>
13 #include <stddef.h> 13 #include <stddef.h>
14 #include <stdint.h> 14 #include <stdint.h>
15 15
16 #include "base/command_line.h"
17 #include "base/strings/string_number_conversions.h"
16 #include "gpu/command_buffer/tests/gl_manager.h" 18 #include "gpu/command_buffer/tests/gl_manager.h"
17 #include "gpu/command_buffer/tests/gl_test_utils.h" 19 #include "gpu/command_buffer/tests/gl_test_utils.h"
20 #include "gpu/config/gpu_switches.h"
18 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
20 #include "ui/gl/gl_version_info.h" 23 #include "ui/gl/gl_version_info.h"
21 24
22 namespace gpu { 25 namespace gpu {
23 26
24 namespace { 27 namespace {
25 28
26 enum CopyType { TexImage, TexSubImage }; 29 enum CopyType { TexImage, TexSubImage };
27 const CopyType kCopyTypes[] = { 30 const CopyType kCopyTypes[] = {
(...skipping 17 matching lines...) Expand all
45 48
46 static const char* kSimpleVertexShaderES3 = 49 static const char* kSimpleVertexShaderES3 =
47 "#version 300 es\n" 50 "#version 300 es\n"
48 "in vec2 a_position;\n" 51 "in vec2 a_position;\n"
49 "out vec2 v_texCoord;\n" 52 "out vec2 v_texCoord;\n"
50 "void main() {\n" 53 "void main() {\n"
51 " gl_Position = vec4(a_position.x, a_position.y, 0.0, 1.0);\n" 54 " gl_Position = vec4(a_position.x, a_position.y, 0.0, 1.0);\n"
52 " v_texCoord = (a_position + vec2(1.0, 1.0)) * 0.5;\n" 55 " v_texCoord = (a_position + vec2(1.0, 1.0)) * 0.5;\n"
53 "}\n"; 56 "}\n";
54 57
55 std::string GetFragmentShaderSource(GLenum format, bool is_es3) { 58 std::string GetFragmentShaderSource(GLenum target, GLenum format, bool is_es3) {
56 std::string source; 59 std::string source;
57 if (is_es3) { 60 if (is_es3) {
58 source += 61 source +=
59 "#version 300 es\n" 62 "#version 300 es\n"
60 "#define VARYING in\n" 63 "#define VARYING in\n"
61 "#define FRAGCOLOR frag_color\n" 64 "#define FRAGCOLOR frag_color\n"
62 "#define TextureLookup texture\n"; 65 "#define TextureLookup texture\n";
63 } else { 66 } else {
64 source += 67 source +=
65 "#define VARYING varying\n" 68 "#define VARYING varying\n"
66 "#define FRAGCOLOR gl_FragColor\n" 69 "#define FRAGCOLOR gl_FragColor\n";
67 "#define TextureLookup texture2D\n"; 70 if (target == GL_TEXTURE_CUBE_MAP) {
71 source += "#define TextureLookup textureCube\n";
72 } else {
73 source += "#define TextureLookup texture2D\n";
74 }
68 } 75 }
69 source += "precision mediump float;\n"; 76 source += "precision mediump float;\n";
70 77
71 if (gles2::GLES2Util::IsSignedIntegerFormat(format)) { 78 if (gles2::GLES2Util::IsSignedIntegerFormat(format)) {
72 source += std::string("#define SamplerType isampler2D\n"); 79 if (target == GL_TEXTURE_CUBE_MAP) {
73 source += std::string("#define TextureType ivec4\n"); 80 source += "#define SamplerType isamplerCube\n";
74 source += std::string("#define ScaleValue 255.0\n"); 81 } else {
82 source += "#define SamplerType isampler2D\n";
83 }
84 source += "#define TextureType ivec4\n";
85 source += "#define ScaleValue 255.0\n";
75 } else if (gles2::GLES2Util::IsUnsignedIntegerFormat(format)) { 86 } else if (gles2::GLES2Util::IsUnsignedIntegerFormat(format)) {
76 source += std::string("#define SamplerType usampler2D\n"); 87 if (target == GL_TEXTURE_CUBE_MAP) {
77 source += std::string("#define TextureType uvec4\n"); 88 source += "#define SamplerType usamplerCube\n";
78 source += std::string("#define ScaleValue 255.0\n"); 89 } else {
90 source += "#define SamplerType usampler2D\n";
91 }
92 source += "#define TextureType uvec4\n";
93 source += "#define ScaleValue 255.0\n";
79 } else { 94 } else {
80 source += std::string("#define SamplerType sampler2D\n"); 95 if (target == GL_TEXTURE_CUBE_MAP) {
81 source += std::string("#define TextureType vec4\n"); 96 source += "#define SamplerType samplerCube\n";
82 source += std::string("#define ScaleValue 1.0\n"); 97 } else {
98 source += "#define SamplerType sampler2D\n";
99 }
100 source += "#define TextureType vec4\n";
101 source += "#define ScaleValue 1.0\n";
83 } 102 }
84 103
85 if (is_es3) 104 if (is_es3)
86 source += "out vec4 frag_color;\n"; 105 source += "out vec4 frag_color;\n";
87 106
88 source += std::string( 107 if (target == GL_TEXTURE_CUBE_MAP)
108 source += "uniform highp int u_face;\n";
109
110 source +=
89 "uniform mediump SamplerType u_texture;\n" 111 "uniform mediump SamplerType u_texture;\n"
90 "VARYING vec2 v_texCoord;\n" 112 "VARYING vec2 v_texCoord;\n"
91 "void main() {\n" 113 "void main() {\n";
92 " TextureType color = TextureLookup(u_texture, v_texCoord);\n" 114
115 if (target == GL_TEXTURE_CUBE_MAP) {
116 source +=
117 " vec3 texCube;\n"
118 // Transform [0, 1] to [-1, 1].
119 " vec2 texCoord = (v_texCoord * 2.0) - 1.0;\n"
120 // Transform 2d tex coord to each face of TEXTURE_CUBE_MAP coord.
121 // TEXTURE_CUBE_MAP_POSITIVE_X
122 " if (u_face == 34069) {\n"
123 " texCube = vec3(1.0, -texCoord.y, -texCoord.x);\n"
124 // TEXTURE_CUBE_MAP_NEGATIVE_X
125 " } else if (u_face == 34070) {\n"
126 " texCube = vec3(-1.0, -texCoord.y, texCoord.x);\n"
127 // TEXTURE_CUBE_MAP_POSITIVE_Y
128 " } else if (u_face == 34071) {\n"
129 " texCube = vec3(texCoord.x, 1.0, texCoord.y);\n"
130 // TEXTURE_CUBE_MAP_NEGATIVE_Y
131 " } else if (u_face == 34072) {\n"
132 " texCube = vec3(texCoord.x, -1.0, -texCoord.y);\n"
133 // TEXTURE_CUBE_MAP_POSITIVE_Z
134 " } else if (u_face == 34073) {\n"
135 " texCube = vec3(texCoord.x, -texCoord.y, 1.0);\n"
136 // TEXTURE_CUBE_MAP_NEGATIVE_Z
137 " } else if (u_face == 34074) {\n"
138 " texCube = vec3(-texCoord.x, -texCoord.y, -1.0);\n"
139 " }\n"
140 " TextureType color = TextureLookup(u_texture, texCube);\n";
141 } else {
142 source += " TextureType color = TextureLookup(u_texture, v_texCoord);\n";
143 }
144
145 source +=
93 " FRAGCOLOR = vec4(color) / ScaleValue;\n" 146 " FRAGCOLOR = vec4(color) / ScaleValue;\n"
94 "}\n"); 147 "}\n";
95 return source; 148 return source;
96 } 149 }
97 150
98 void setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a, uint8_t* color) { 151 void setColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a, uint8_t* color) {
99 color[0] = r; 152 color[0] = r;
100 color[1] = g; 153 color[1] = g;
101 color[2] = b; 154 color[2] = b;
102 color[3] = a; 155 color[3] = a;
103 } 156 }
104 157
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 GL_UNSIGNED_BYTE, nullptr); 308 GL_UNSIGNED_BYTE, nullptr);
256 } 309 }
257 } 310 }
258 311
259 GLuint CreateDrawingTexture(GLenum target, GLsizei width, GLsizei height) { 312 GLuint CreateDrawingTexture(GLenum target, GLsizei width, GLsizei height) {
260 GLuint texture = 0; 313 GLuint texture = 0;
261 glGenTextures(1, &texture); 314 glGenTextures(1, &texture);
262 glBindTexture(target, texture); 315 glBindTexture(target, texture);
263 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 316 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
264 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 317 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
265 CreateBackingForTexture(GL_TEXTURE_2D, width, height); 318 CreateBackingForTexture(target, width, height);
266 return texture; 319 return texture;
267 } 320 }
268 321
269 GLuint CreateDrawingFBO(GLenum target, GLuint texture) { 322 GLuint CreateDrawingFBO(GLenum target, GLuint texture) {
270 GLuint framebuffer = 0; 323 GLuint framebuffer = 0;
271 glGenFramebuffers(1, &framebuffer); 324 glGenFramebuffers(1, &framebuffer);
272 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); 325 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
273 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, 326 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target,
274 texture, 0); 327 texture, 0);
275 return framebuffer; 328 return framebuffer;
276 } 329 }
277 330
278 GLenum ExtractFormatFrom(GLenum internalformat) { 331 GLenum ExtractFormatFrom(GLenum internalformat) {
279 switch (internalformat) { 332 switch (internalformat) {
280 case GL_RGBA8_OES: 333 case GL_RGBA8_OES:
281 return GL_RGBA; 334 return GL_RGBA;
282 case GL_RGB8_OES: 335 case GL_RGB8_OES:
283 return GL_RGB; 336 return GL_RGB;
284 case GL_BGRA8_EXT: 337 case GL_BGRA8_EXT:
285 return GL_BGRA_EXT; 338 return GL_BGRA_EXT;
286 default: 339 default:
287 NOTREACHED(); 340 NOTREACHED();
288 return GL_NONE; 341 return GL_NONE;
289 } 342 }
290 } 343 }
291 344
292 void RunCopyTexture(GLenum target, 345 void RunCopyTexture(GLenum dest_target,
293 CopyType copy_type, 346 CopyType copy_type,
294 FormatType src_format_type, 347 FormatType src_format_type,
295 GLint source_level, 348 GLint source_level,
296 FormatType dest_format_type, 349 FormatType dest_format_type,
297 GLint dest_level, 350 GLint dest_level,
298 bool is_es3) { 351 bool is_es3) {
299 const int src_channel_count = gles2::GLES2Util::ElementsPerGroup( 352 const int src_channel_count = gles2::GLES2Util::ElementsPerGroup(
300 src_format_type.format, src_format_type.type); 353 src_format_type.format, src_format_type.type);
301 uint8_t color[4] = {1u, 63u, 127u, 255u}; 354 uint8_t color[4] = {1u, 63u, 127u, 255u};
302 std::unique_ptr<uint8_t[]> pixels(new uint8_t[width_ * height_ * 4]); 355 std::unique_ptr<uint8_t[]> pixels(new uint8_t[width_ * height_ * 4]);
303 for (int i = 0; i < width_ * height_ * src_channel_count; 356 for (int i = 0; i < width_ * height_ * src_channel_count;
304 i += src_channel_count) 357 i += src_channel_count)
305 for (int j = 0; j < src_channel_count; ++j) 358 for (int j = 0; j < src_channel_count; ++j)
306 pixels[i + j] = color[j]; 359 pixels[i + j] = color[j];
307 uint8_t expected_color[4]; 360 uint8_t expected_color[4];
308 uint8_t mask[4]; 361 uint8_t mask[4];
309 getExpectedColor(src_format_type.internal_format, 362 getExpectedColor(src_format_type.internal_format,
310 dest_format_type.internal_format, color, expected_color, 363 dest_format_type.internal_format, color, expected_color,
311 mask); 364 mask);
312 365
366 GLenum source_target = GL_TEXTURE_2D;
313 glGenTextures(2, textures_); 367 glGenTextures(2, textures_);
314 glBindTexture(target, textures_[0]); 368 glBindTexture(source_target, textures_[0]);
315 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 369 glTexParameteri(source_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
316 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 370 glTexParameteri(source_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
317 #if defined(OS_MACOSX) 371 #if defined(OS_MACOSX)
318 // TODO(qiankun.miao@intel.com): Remove this workaround for Mac OSX, once 372 // TODO(qiankun.miao@intel.com): Remove this workaround for Mac OSX, once
319 // integer texture rendering bug is fixed on Mac OSX: crbug.com/679639. 373 // integer texture rendering bug is fixed on Mac OSX: crbug.com/679639.
320 glTexImage2D(target, 0, src_format_type.internal_format, 374 glTexImage2D(source_target, 0, src_format_type.internal_format,
321 width_ << source_level, height_ << source_level, 0, 375 width_ << source_level, height_ << source_level, 0,
322 src_format_type.format, src_format_type.type, nullptr); 376 src_format_type.format, src_format_type.type, nullptr);
323 #endif 377 #endif
324 glTexImage2D(target, source_level, src_format_type.internal_format, width_, 378 glTexImage2D(source_target, source_level, src_format_type.internal_format,
325 height_, 0, src_format_type.format, src_format_type.type, 379 width_, height_, 0, src_format_type.format,
326 pixels.get()); 380 src_format_type.type, pixels.get());
327 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 381 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
328 glBindTexture(target, textures_[1]); 382 GLenum dest_binding_target =
329 glTexParameterf(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 383 gles2::GLES2Util::GLFaceTargetToTextureTarget(dest_target);
330 glTexParameterf(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 384 glBindTexture(dest_binding_target, textures_[1]);
331 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 385 glTexParameterf(dest_binding_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
386 glTexParameterf(dest_binding_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
387 glTexParameteri(dest_binding_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
332 // This hack makes dest texture complete in ES2 and ES3 context 388 // This hack makes dest texture complete in ES2 and ES3 context
333 // respectively. With this, sampling from the dest texture is correct. 389 // respectively. With this, sampling from the dest texture is correct.
334 if (is_es3) { 390 if (is_es3) {
335 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 391 glTexParameteri(dest_binding_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
336 glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, dest_level); 392 glTexParameteri(dest_binding_target, GL_TEXTURE_BASE_LEVEL, dest_level);
393 // For cube map textures, make the texture is cube complete.
394 if (dest_binding_target == GL_TEXTURE_CUBE_MAP) {
395 for (int i = 0; i < 6; ++i) {
396 GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
397 glTexImage2D(face, dest_level, dest_format_type.internal_format,
398 width_, height_, 0, dest_format_type.format,
399 dest_format_type.type, nullptr);
400 }
401 }
337 #if defined(OS_MACOSX) 402 #if defined(OS_MACOSX)
338 // TODO(qiankun.miao@intel.com): Remove this workaround for Mac OSX, once 403 // TODO(qiankun.miao@intel.com): Remove this workaround for Mac OSX, once
339 // framebuffer complete bug is fixed on Mac OSX: crbug.com/678526. 404 // framebuffer complete bug is fixed on Mac OSX: crbug.com/678526.
340 glTexImage2D(target, 0, dest_format_type.internal_format, 405 glTexImage2D(dest_target, 0, dest_format_type.internal_format,
341 width_ << dest_level, height_ << dest_level, 0, 406 width_ << dest_level, height_ << dest_level, 0,
342 dest_format_type.format, dest_format_type.type, nullptr); 407 dest_format_type.format, dest_format_type.type, nullptr);
343 #endif 408 #endif
344 } else { 409 } else {
345 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); 410 glTexParameteri(dest_binding_target, GL_TEXTURE_MIN_FILTER,
346 glTexImage2D(target, 0, dest_format_type.internal_format, 411 GL_NEAREST_MIPMAP_NEAREST);
347 width_ << dest_level, height_ << dest_level, 0, 412 // For cube map textures, make the texture is cube complete.
Zhenyao Mo 2017/01/27 00:10:17 nit: remove is.
qiankun 2017/01/29 15:39:31 Done.
348 dest_format_type.format, dest_format_type.type, nullptr); 413 if (dest_binding_target == GL_TEXTURE_CUBE_MAP) {
349 glGenerateMipmap(target); 414 for (int i = 0; i < 6; ++i) {
415 GLenum face = GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
416 glTexImage2D(face, 0, dest_format_type.internal_format,
417 width_ << dest_level, height_ << dest_level, 0,
418 dest_format_type.format, dest_format_type.type, nullptr);
419 }
420 } else {
421 glTexImage2D(dest_target, 0, dest_format_type.internal_format,
422 width_ << dest_level, height_ << dest_level, 0,
423 dest_format_type.format, dest_format_type.type, nullptr);
424 }
425 glGenerateMipmap(dest_binding_target);
350 } 426 }
351 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 427 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
352 428
353 if (copy_type == TexImage) { 429 if (copy_type == TexImage) {
354 glCopyTextureCHROMIUM(textures_[0], source_level, target, textures_[1], 430 glCopyTextureCHROMIUM(textures_[0], source_level, dest_target,
355 dest_level, dest_format_type.internal_format, 431 textures_[1], dest_level,
432 dest_format_type.internal_format,
356 dest_format_type.type, false, false, false); 433 dest_format_type.type, false, false, false);
357 } else { 434 } else {
358 glBindTexture(target, textures_[1]); 435 glBindTexture(dest_binding_target, textures_[1]);
359 glTexImage2D(target, dest_level, dest_format_type.internal_format, width_, 436 glTexImage2D(dest_target, dest_level, dest_format_type.internal_format,
360 height_, 0, dest_format_type.format, dest_format_type.type, 437 width_, height_, 0, dest_format_type.format,
361 nullptr); 438 dest_format_type.type, nullptr);
362 439
363 glCopySubTextureCHROMIUM(textures_[0], source_level, target, textures_[1], 440 glCopySubTextureCHROMIUM(textures_[0], source_level, dest_target,
364 dest_level, 0, 0, 0, 0, width_, height_, false, 441 textures_[1], dest_level, 0, 0, 0, 0, width_,
365 false, false); 442 height_, false, false, false);
366 } 443 }
367 EXPECT_TRUE(glGetError() == GL_NO_ERROR); 444 EXPECT_TRUE(glGetError() == GL_NO_ERROR);
368 445
369 // Draw destination texture to a fbo with a texture attachment in RGBA 446 // Draw destination texture to a fbo with a TEXTURE_2D texture attachment
370 // format. 447 // in RGBA format.
371 GLuint texture = CreateDrawingTexture(target, width_, height_); 448 GLuint texture = CreateDrawingTexture(GL_TEXTURE_2D, width_, height_);
372 GLuint framebuffer = CreateDrawingFBO(target, texture); 449 GLuint framebuffer = CreateDrawingFBO(GL_TEXTURE_2D, texture);
373 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 450 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
374 glCheckFramebufferStatus(GL_FRAMEBUFFER)); 451 glCheckFramebufferStatus(GL_FRAMEBUFFER));
375 glViewport(0, 0, width_, height_); 452 glViewport(0, 0, width_, height_);
376 453
377 glBindTexture(target, textures_[1]); 454 glBindTexture(dest_binding_target, textures_[1]);
378 std::string fragment_shader_source = 455 std::string fragment_shader_source = GetFragmentShaderSource(
379 GetFragmentShaderSource(dest_format_type.internal_format, is_es3); 456 dest_binding_target, dest_format_type.internal_format, is_es3);
380 GLTestHelper::DrawTextureQuad( 457 GLTestHelper::DrawTextureQuad(
381 is_es3 ? kSimpleVertexShaderES3 : kSimpleVertexShaderES2, 458 dest_target, is_es3 ? kSimpleVertexShaderES3 : kSimpleVertexShaderES2,
382 fragment_shader_source.c_str(), "a_position", "u_texture"); 459 fragment_shader_source.c_str(), "a_position", "u_texture", "u_face");
383 EXPECT_TRUE(GL_NO_ERROR == glGetError()); 460 EXPECT_TRUE(GL_NO_ERROR == glGetError());
384 461
385 uint8_t tolerance = dest_format_type.internal_format == GL_RGBA4 ? 20 : 7; 462 uint8_t tolerance = dest_format_type.internal_format == GL_RGBA4 ? 20 : 7;
386 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, width_, height_, tolerance, 463 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, width_, height_, tolerance,
387 expected_color, mask)) 464 expected_color, mask))
465 << " dest_target : " << gles2::GLES2Util::GetStringEnum(dest_target)
388 << " src_internal_format: " 466 << " src_internal_format: "
389 << gles2::GLES2Util::GetStringEnum(src_format_type.internal_format) 467 << gles2::GLES2Util::GetStringEnum(src_format_type.internal_format)
390 << " source_level: " << source_level 468 << " source_level: " << source_level << " dest_internal_format: "
391 << " dest_internal_format: "
392 << gles2::GLES2Util::GetStringEnum(dest_format_type.internal_format) 469 << gles2::GLES2Util::GetStringEnum(dest_format_type.internal_format)
393 << " dest_level: " << dest_level; 470 << " dest_level: " << dest_level;
394 471
395 glDeleteTextures(1, &texture); 472 glDeleteTextures(1, &texture);
396 glDeleteFramebuffers(1, &framebuffer); 473 glDeleteFramebuffers(1, &framebuffer);
397 glDeleteTextures(2, textures_); 474 glDeleteTextures(2, textures_);
398 } 475 }
399 476
400 GLManager gl_; 477 GLManager gl_;
401 GLuint textures_[2]; 478 GLuint textures_[2];
402 GLsizei width_; 479 GLsizei width_;
403 GLsizei height_; 480 GLsizei height_;
404 GLuint framebuffer_id_; 481 GLuint framebuffer_id_;
405 }; 482 };
406 483
407 class GLCopyTextureCHROMIUMES3Test : public GLCopyTextureCHROMIUMTest { 484 class GLCopyTextureCHROMIUMES3Test : public GLCopyTextureCHROMIUMTest {
408 protected: 485 protected:
409 void SetUp() override { 486 void SetUp() override {
410 GLManager::Options options; 487 GLManager::Options options;
411 options.context_type = gles2::CONTEXT_TYPE_OPENGLES3; 488 options.context_type = gles2::CONTEXT_TYPE_OPENGLES3;
412 options.size = gfx::Size(64, 64); 489 options.size = gfx::Size(64, 64);
413 gl_.Initialize(options); 490 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess());
491 #if defined(OS_MACOSX)
492 // Sampling of seamless integer cube map texture has bug on Intel GEN7 gpus
493 // on Mac OSX, see crbug.com/658930.
494 command_line.AppendSwitchASCII(
495 switches::kGpuDriverBugWorkarounds,
496 base::IntToString(gpu::DISABLE_TEXTURE_CUBE_MAP_SEAMLESS));
497 #endif
498 gl_.InitializeWithCommandLine(options, command_line);
414 499
415 width_ = 8; 500 width_ = 8;
416 height_ = 8; 501 height_ = 8;
417 } 502 }
418 503
419 // If a driver isn't capable of supporting ES3 context, creating 504 // If a driver isn't capable of supporting ES3 context, creating
420 // ContextGroup will fail. Just skip the test. 505 // ContextGroup will fail. Just skip the test.
421 bool ShouldSkipTest() const { 506 bool ShouldSkipTest() const {
422 return (!gl_.decoder() || !gl_.decoder()->GetContextGroup()); 507 return (!gl_.decoder() || !gl_.decoder()->GetContextGroup());
423 } 508 }
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 if (dest_level > 0) 872 if (dest_level > 0)
788 continue; 873 continue;
789 #endif 874 #endif
790 RunCopyTexture(GL_TEXTURE_2D, copy_type, src_format_type, source_level, 875 RunCopyTexture(GL_TEXTURE_2D, copy_type, src_format_type, source_level,
791 dest_format_type, dest_level, true); 876 dest_format_type, dest_level, true);
792 } 877 }
793 } 878 }
794 } 879 }
795 } 880 }
796 881
882 TEST_P(GLCopyTextureCHROMIUMTest, CopyTextureCubeMap) {
883 CopyType copy_type = GetParam();
884
885 GLenum dest_targets[] = {
886 GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
887 GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
888 GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z};
889 FormatType src_format_type = {GL_RGB, GL_RGB, GL_UNSIGNED_BYTE};
890 FormatType dest_format_types[] = {
891 {GL_RGB, GL_RGB, GL_UNSIGNED_BYTE}, {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE},
892 };
893 GLint source_level = 0;
894 GLint dest_level = 0;
895
896 for (auto dest_format_type : dest_format_types) {
897 for (auto dest_target : dest_targets) {
898 RunCopyTexture(dest_target, copy_type, src_format_type, source_level,
899 dest_format_type, dest_level, false);
900 }
901 }
902 }
903
904 TEST_P(GLCopyTextureCHROMIUMES3Test, CopyTextureCubeMap) {
905 if (ShouldSkipTest())
906 return;
907 CopyType copy_type = GetParam();
908
909 GLenum dest_targets[] = {
910 GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
911 GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
912 GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z};
913 FormatType src_format_type = {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE};
914 FormatType dest_format_types[] = {
915 {GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE},
916 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE},
917 {GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE},
918 };
919 GLint source_level = 0;
920 GLint dest_level = 0;
921
922 for (auto dest_format_type : dest_format_types) {
923 for (auto dest_target : dest_targets) {
924 RunCopyTexture(dest_target, copy_type, src_format_type, source_level,
925 dest_format_type, dest_level, true);
926 }
927 }
928 }
929
797 // Test to ensure that the destination texture is redefined if the properties 930 // Test to ensure that the destination texture is redefined if the properties
798 // are different. 931 // are different.
799 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) { 932 TEST_F(GLCopyTextureCHROMIUMTest, RedefineDestinationTexture) {
800 uint8_t pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u, 933 uint8_t pixels[4 * 4] = {255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u,
801 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u}; 934 255u, 0u, 0u, 255u, 255u, 0u, 0u, 255u};
802 935
803 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D); 936 CreateAndBindDestinationTextureAndFBO(GL_TEXTURE_2D);
804 glBindTexture(GL_TEXTURE_2D, textures_[0]); 937 glBindTexture(GL_TEXTURE_2D, textures_[0]);
805 glTexImage2D( 938 glTexImage2D(
806 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); 939 GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 } 1584 }
1452 } 1585 }
1453 1586
1454 glDeleteTextures(2, textures_); 1587 glDeleteTextures(2, textures_);
1455 glDeleteFramebuffers(1, &framebuffer_id_); 1588 glDeleteFramebuffers(1, &framebuffer_id_);
1456 } 1589 }
1457 } 1590 }
1458 } 1591 }
1459 1592
1460 } // namespace gpu 1593 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_copy_tex_image_2d_workaround_unittest.cc ('k') | gpu/command_buffer/tests/gl_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698