blob: 3a583d2558fe7fe6be677364db5f8dbbb81e7fd5 [file] [log] [blame]
Jamie Madillfa05f602015-05-07 13:47:11 -04001//
2// Copyright 2015 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6// SimpleOperationTest:
7// Basic GL commands such as linking a program, initializing a buffer, etc.
8
Corentin Wallezd3970de2015-05-14 11:07:48 -04009#include "test_utils/ANGLETest.h"
Geoff Langf1e85922015-02-23 14:40:04 -050010
11#include <vector>
12
Jamie Madillcc6ac252017-01-25 12:57:21 -080013#include "random_utils.h"
14#include "test_utils/gl_raii.h"
15
Jamie Madillfa05f602015-05-07 13:47:11 -040016using namespace angle;
Geoff Langf1e85922015-02-23 14:40:04 -050017
Jamie Madillfa05f602015-05-07 13:47:11 -040018namespace
19{
20
Geoff Langf1e85922015-02-23 14:40:04 -050021class SimpleOperationTest : public ANGLETest
22{
23 protected:
Jamie Madillfa05f602015-05-07 13:47:11 -040024 SimpleOperationTest()
Geoff Langf1e85922015-02-23 14:40:04 -050025 {
26 setWindowWidth(128);
27 setWindowHeight(128);
28 setConfigRedBits(8);
29 setConfigGreenBits(8);
30 setConfigBlueBits(8);
31 setConfigAlphaBits(8);
32 }
Jamie Madillcc6ac252017-01-25 12:57:21 -080033
34 void verifyBuffer(const std::vector<uint8_t> &data, GLenum binding);
Geoff Langf1e85922015-02-23 14:40:04 -050035};
36
Jamie Madillcc6ac252017-01-25 12:57:21 -080037void SimpleOperationTest::verifyBuffer(const std::vector<uint8_t> &data, GLenum binding)
38{
39 if (!extensionEnabled("GL_EXT_map_buffer_range"))
40 {
41 return;
42 }
43
44 uint8_t *mapPointer =
45 static_cast<uint8_t *>(glMapBufferRangeEXT(GL_ARRAY_BUFFER, 0, 1024, GL_MAP_READ_BIT));
46 ASSERT_GL_NO_ERROR();
47
48 std::vector<uint8_t> readbackData(data.size());
49 memcpy(readbackData.data(), mapPointer, data.size());
50 glUnmapBufferOES(GL_ARRAY_BUFFER);
51
52 EXPECT_EQ(data, readbackData);
53}
54
Jamie Madillfa05f602015-05-07 13:47:11 -040055TEST_P(SimpleOperationTest, CompileVertexShader)
Geoff Langf1e85922015-02-23 14:40:04 -050056{
Olli Etuahoa20af6d2017-09-18 13:32:29 +030057 const std::string source =
58 R"(attribute vec4 a_input;
Geoff Langf1e85922015-02-23 14:40:04 -050059 void main()
60 {
61 gl_Position = a_input;
Olli Etuahoa20af6d2017-09-18 13:32:29 +030062 })";
Geoff Langf1e85922015-02-23 14:40:04 -050063
64 GLuint shader = CompileShader(GL_VERTEX_SHADER, source);
65 EXPECT_NE(shader, 0u);
66 glDeleteShader(shader);
67
68 EXPECT_GL_NO_ERROR();
69}
70
Jamie Madillfa05f602015-05-07 13:47:11 -040071TEST_P(SimpleOperationTest, CompileFragmentShader)
Geoff Langf1e85922015-02-23 14:40:04 -050072{
Olli Etuahoa20af6d2017-09-18 13:32:29 +030073 const std::string source =
74 R"(precision mediump float;
Geoff Langf1e85922015-02-23 14:40:04 -050075 varying vec4 v_input;
76 void main()
77 {
78 gl_FragColor = v_input;
Olli Etuahoa20af6d2017-09-18 13:32:29 +030079 })";
Geoff Langf1e85922015-02-23 14:40:04 -050080
81 GLuint shader = CompileShader(GL_FRAGMENT_SHADER, source);
82 EXPECT_NE(shader, 0u);
83 glDeleteShader(shader);
84
85 EXPECT_GL_NO_ERROR();
86}
Geoff Langb1f435e2015-02-20 10:01:01 -050087
Jamie Madillfa05f602015-05-07 13:47:11 -040088TEST_P(SimpleOperationTest, LinkProgram)
Geoff Langb1f435e2015-02-20 10:01:01 -050089{
Olli Etuahoa20af6d2017-09-18 13:32:29 +030090 const std::string vsSource =
91 R"(void main()
Geoff Langb1f435e2015-02-20 10:01:01 -050092 {
93 gl_Position = vec4(1.0, 1.0, 1.0, 1.0);
Olli Etuahoa20af6d2017-09-18 13:32:29 +030094 })";
Geoff Langb1f435e2015-02-20 10:01:01 -050095
Olli Etuahoa20af6d2017-09-18 13:32:29 +030096 const std::string fsSource =
97 R"(void main()
Geoff Langb1f435e2015-02-20 10:01:01 -050098 {
99 gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
Olli Etuahoa20af6d2017-09-18 13:32:29 +0300100 })";
Geoff Langb1f435e2015-02-20 10:01:01 -0500101
102 GLuint program = CompileProgram(vsSource, fsSource);
103 EXPECT_NE(program, 0u);
104 glDeleteProgram(program);
105
106 EXPECT_GL_NO_ERROR();
107}
108
Jamie Madillfa05f602015-05-07 13:47:11 -0400109TEST_P(SimpleOperationTest, LinkProgramWithUniforms)
Geoff Langb1f435e2015-02-20 10:01:01 -0500110{
Olli Etuahoa20af6d2017-09-18 13:32:29 +0300111 const std::string vsSource =
112 R"(void main()
Geoff Langb1f435e2015-02-20 10:01:01 -0500113 {
114 gl_Position = vec4(1.0, 1.0, 1.0, 1.0);
Olli Etuahoa20af6d2017-09-18 13:32:29 +0300115 })";
Geoff Langb1f435e2015-02-20 10:01:01 -0500116
Olli Etuahoa20af6d2017-09-18 13:32:29 +0300117 const std::string fsSource =
118 R"(precision mediump float;
Geoff Langb1f435e2015-02-20 10:01:01 -0500119 uniform vec4 u_input;
120 void main()
121 {
122 gl_FragColor = u_input;
Olli Etuahoa20af6d2017-09-18 13:32:29 +0300123 })";
Geoff Langb1f435e2015-02-20 10:01:01 -0500124
125 GLuint program = CompileProgram(vsSource, fsSource);
126 EXPECT_NE(program, 0u);
127
128 GLint uniformLoc = glGetUniformLocation(program, "u_input");
129 EXPECT_NE(-1, uniformLoc);
130
131 glDeleteProgram(program);
132
133 EXPECT_GL_NO_ERROR();
134}
135
Jamie Madillfa05f602015-05-07 13:47:11 -0400136TEST_P(SimpleOperationTest, LinkProgramWithAttributes)
Geoff Langb1f435e2015-02-20 10:01:01 -0500137{
Olli Etuahoa20af6d2017-09-18 13:32:29 +0300138 const std::string vsSource =
139 R"(attribute vec4 a_input;
Geoff Langb1f435e2015-02-20 10:01:01 -0500140 void main()
141 {
142 gl_Position = a_input;
Olli Etuahoa20af6d2017-09-18 13:32:29 +0300143 })";
Geoff Langb1f435e2015-02-20 10:01:01 -0500144
Olli Etuahoa20af6d2017-09-18 13:32:29 +0300145 const std::string fsSource =
146 R"(void main()
Geoff Langb1f435e2015-02-20 10:01:01 -0500147 {
148 gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
Olli Etuahoa20af6d2017-09-18 13:32:29 +0300149 })";
Geoff Langb1f435e2015-02-20 10:01:01 -0500150
151 GLuint program = CompileProgram(vsSource, fsSource);
152 EXPECT_NE(program, 0u);
153
154 GLint attribLoc = glGetAttribLocation(program, "a_input");
155 EXPECT_NE(-1, attribLoc);
156
157 glDeleteProgram(program);
158
159 EXPECT_GL_NO_ERROR();
160}
Geoff Lang36c79012015-02-24 11:47:20 -0500161
Jamie Madillfa05f602015-05-07 13:47:11 -0400162TEST_P(SimpleOperationTest, BufferDataWithData)
Geoff Lang36c79012015-02-24 11:47:20 -0500163{
Jamie Madillcc6ac252017-01-25 12:57:21 -0800164 GLBuffer buffer;
165 glBindBuffer(GL_ARRAY_BUFFER, buffer.get());
Geoff Lang36c79012015-02-24 11:47:20 -0500166
167 std::vector<uint8_t> data(1024);
Jamie Madillcc6ac252017-01-25 12:57:21 -0800168 FillVectorWithRandomUBytes(&data);
Geoff Lang36c79012015-02-24 11:47:20 -0500169 glBufferData(GL_ARRAY_BUFFER, data.size(), &data[0], GL_STATIC_DRAW);
170
Jamie Madillcc6ac252017-01-25 12:57:21 -0800171 verifyBuffer(data, GL_ARRAY_BUFFER);
Geoff Lang36c79012015-02-24 11:47:20 -0500172
173 EXPECT_GL_NO_ERROR();
174}
175
Jamie Madillfa05f602015-05-07 13:47:11 -0400176TEST_P(SimpleOperationTest, BufferDataWithNoData)
Geoff Lang36c79012015-02-24 11:47:20 -0500177{
Jamie Madillcc6ac252017-01-25 12:57:21 -0800178 GLBuffer buffer;
179 glBindBuffer(GL_ARRAY_BUFFER, buffer.get());
Geoff Lang36c79012015-02-24 11:47:20 -0500180 glBufferData(GL_ARRAY_BUFFER, 1024, nullptr, GL_STATIC_DRAW);
Geoff Lang36c79012015-02-24 11:47:20 -0500181
182 EXPECT_GL_NO_ERROR();
183}
184
Jamie Madillfa05f602015-05-07 13:47:11 -0400185TEST_P(SimpleOperationTest, BufferSubData)
Geoff Lang36c79012015-02-24 11:47:20 -0500186{
Jamie Madillcc6ac252017-01-25 12:57:21 -0800187 GLBuffer buffer;
188 glBindBuffer(GL_ARRAY_BUFFER, buffer.get());
Geoff Lang36c79012015-02-24 11:47:20 -0500189
Jamie Madillcc6ac252017-01-25 12:57:21 -0800190 constexpr size_t bufferSize = 1024;
191 std::vector<uint8_t> data(bufferSize);
192 FillVectorWithRandomUBytes(&data);
193
Geoff Lang36c79012015-02-24 11:47:20 -0500194 glBufferData(GL_ARRAY_BUFFER, bufferSize, nullptr, GL_STATIC_DRAW);
195
Jamie Madillcc6ac252017-01-25 12:57:21 -0800196 constexpr size_t subDataCount = 16;
197 constexpr size_t sliceSize = bufferSize / subDataCount;
Geoff Lang36c79012015-02-24 11:47:20 -0500198 for (size_t i = 0; i < subDataCount; i++)
199 {
Jamie Madillcc6ac252017-01-25 12:57:21 -0800200 size_t offset = i * sliceSize;
201 glBufferSubData(GL_ARRAY_BUFFER, offset, sliceSize, &data[offset]);
Geoff Lang36c79012015-02-24 11:47:20 -0500202 }
203
Jamie Madillcc6ac252017-01-25 12:57:21 -0800204 verifyBuffer(data, GL_ARRAY_BUFFER);
Geoff Lang36c79012015-02-24 11:47:20 -0500205
206 EXPECT_GL_NO_ERROR();
207}
Jamie Madillfa05f602015-05-07 13:47:11 -0400208
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500209// Simple quad test.
210TEST_P(SimpleOperationTest, DrawQuad)
211{
212 const std::string &vertexShader =
213 "attribute vec3 position;\n"
214 "void main()\n"
215 "{\n"
216 " gl_Position = vec4(position, 1);\n"
217 "}";
218 const std::string &fragmentShader =
219 "void main()\n"
220 "{\n"
221 " gl_FragColor = vec4(0, 1, 0, 1);\n"
222 "}";
223 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
224
225 drawQuad(program.get(), "position", 0.5f, 1.0f, true);
226
227 EXPECT_GL_NO_ERROR();
228 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
229}
230
Jamie Madilld03a8492017-10-03 15:46:06 -0400231// Simple repeated draw and swap test.
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500232TEST_P(SimpleOperationTest, DrawQuadAndSwap)
233{
Yuly Novikov47c98882018-01-08 15:01:11 -0500234 // anglebug.com/2301
235 ANGLE_SKIP_TEST_IF(IsLinux() && IsIntel() && IsVulkan());
236
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500237 const std::string &vertexShader =
238 "attribute vec3 position;\n"
239 "void main()\n"
240 "{\n"
241 " gl_Position = vec4(position, 1);\n"
242 "}";
243 const std::string &fragmentShader =
244 "void main()\n"
245 "{\n"
246 " gl_FragColor = vec4(0, 1, 0, 1);\n"
247 "}";
248 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
249
250 for (int i = 0; i < 8; ++i)
251 {
252 drawQuad(program.get(), "position", 0.5f, 1.0f, true);
253 EXPECT_GL_NO_ERROR();
Jamie Madill4c26fc22017-02-24 11:04:10 -0500254 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500255 swapBuffers();
256 }
257
258 EXPECT_GL_NO_ERROR();
259}
260
Jamie Madilld03a8492017-10-03 15:46:06 -0400261// Simple indexed quad test.
262TEST_P(SimpleOperationTest, DrawIndexedQuad)
263{
264 const std::string vertexShader =
265 "attribute vec3 position;\n"
266 "void main()\n"
267 "{\n"
268 " gl_Position = vec4(position, 1);\n"
269 "}";
270 const std::string fragmentShader =
271 "void main()\n"
272 "{\n"
273 " gl_FragColor = vec4(0, 1, 0, 1);\n"
274 "}";
275 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
276
277 drawIndexedQuad(program.get(), "position", 0.5f, 1.0f, true);
278
279 EXPECT_GL_NO_ERROR();
280 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
281}
282
Jamie Madill76e471e2017-10-21 09:56:01 -0400283// Draw with a fragment uniform.
284TEST_P(SimpleOperationTest, DrawQuadWithFragmentUniform)
285{
286 const std::string &vertexShader =
287 "attribute vec3 position;\n"
288 "void main()\n"
289 "{\n"
290 " gl_Position = vec4(position, 1);\n"
291 "}";
292 const std::string &fragmentShader =
293 "uniform mediump vec4 color;\n"
294 "void main()\n"
295 "{\n"
296 " gl_FragColor = color;\n"
297 "}";
298 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
299
300 GLint location = glGetUniformLocation(program, "color");
301 ASSERT_NE(-1, location);
302
303 glUseProgram(program);
304 glUniform4f(location, 0.0f, 1.0f, 0.0f, 1.0f);
305
306 drawQuad(program.get(), "position", 0.5f, 1.0f, true);
307
308 EXPECT_GL_NO_ERROR();
309 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
310}
311
312// Draw with a vertex uniform.
313TEST_P(SimpleOperationTest, DrawQuadWithVertexUniform)
314{
315 const std::string &vertexShader =
316 "attribute vec3 position;\n"
317 "uniform vec4 color;\n"
318 "varying vec4 vcolor;\n"
319 "void main()\n"
320 "{\n"
321 " gl_Position = vec4(position, 1);\n"
322 " vcolor = color;\n"
323 "}";
324 const std::string &fragmentShader =
325 "varying mediump vec4 vcolor;\n"
326 "void main()\n"
327 "{\n"
328 " gl_FragColor = vcolor;\n"
329 "}";
330 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
331
332 GLint location = glGetUniformLocation(program, "color");
333 ASSERT_NE(-1, location);
334
335 glUseProgram(program);
336 glUniform4f(location, 0.0f, 1.0f, 0.0f, 1.0f);
337
338 drawQuad(program.get(), "position", 0.5f, 1.0f, true);
339
340 EXPECT_GL_NO_ERROR();
341 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
342}
343
344// Draw with two uniforms.
345TEST_P(SimpleOperationTest, DrawQuadWithTwoUniforms)
346{
347 const std::string &vertexShader =
348 "attribute vec3 position;\n"
349 "uniform vec4 color1;\n"
350 "varying vec4 vcolor1;\n"
351 "void main()\n"
352 "{\n"
353 " gl_Position = vec4(position, 1);\n"
354 " vcolor1 = color1;\n"
355 "}";
356 const std::string &fragmentShader =
357 "uniform mediump vec4 color2;\n"
358 "varying mediump vec4 vcolor1;\n"
359 "void main()\n"
360 "{\n"
361 " gl_FragColor = vcolor1 + color2;\n"
362 "}";
363 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
364
365 GLint location1 = glGetUniformLocation(program, "color1");
366 ASSERT_NE(-1, location1);
367
368 GLint location2 = glGetUniformLocation(program, "color2");
369 ASSERT_NE(-1, location2);
370
371 glUseProgram(program);
372 glUniform4f(location1, 0.0f, 1.0f, 0.0f, 1.0f);
373 glUniform4f(location2, 1.0f, 0.0f, 0.0f, 1.0f);
374
375 drawQuad(program.get(), "position", 0.5f, 1.0f, true);
376
377 EXPECT_GL_NO_ERROR();
378 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::yellow);
379}
380
Jamie Madill2a9e1072017-09-22 11:31:57 -0400381// Tests a shader program with more than one vertex attribute, with vertex buffers.
382TEST_P(SimpleOperationTest, ThreeVertexAttributes)
383{
384 const std::string vertexShader =
385 R"(attribute vec2 position;
386attribute vec4 color1;
387attribute vec4 color2;
388varying vec4 color;
389void main()
390{
391 gl_Position = vec4(position, 0, 1);
392 color = color1 + color2;
393})";
394
395 const std::string fragmentShader =
396 R"(precision mediump float;
397varying vec4 color;
398void main()
399{
400 gl_FragColor = color;
401}
402)";
403
404 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
405
406 glUseProgram(program);
407
408 GLint color1Loc = glGetAttribLocation(program, "color1");
409 GLint color2Loc = glGetAttribLocation(program, "color2");
410 ASSERT_NE(-1, color1Loc);
411 ASSERT_NE(-1, color2Loc);
412
413 const auto &indices = GetQuadIndices();
414
415 // Make colored corners with red == x or 1 -x , and green = y or 1 - y.
416
417 std::array<GLColor, 4> baseColors1 = {
418 {GLColor::black, GLColor::red, GLColor::green, GLColor::yellow}};
419 std::array<GLColor, 4> baseColors2 = {
420 {GLColor::yellow, GLColor::green, GLColor::red, GLColor::black}};
421
422 std::vector<GLColor> colors1;
423 std::vector<GLColor> colors2;
424
425 for (GLushort index : indices)
426 {
427 colors1.push_back(baseColors1[index]);
428 colors2.push_back(baseColors2[index]);
429 }
430
431 GLBuffer color1Buffer;
432 glBindBuffer(GL_ARRAY_BUFFER, color1Buffer);
433 glBufferData(GL_ARRAY_BUFFER, colors1.size() * sizeof(GLColor), colors1.data(), GL_STATIC_DRAW);
434 glVertexAttribPointer(color1Loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, nullptr);
435 glEnableVertexAttribArray(color1Loc);
436
437 GLBuffer color2Buffer;
438 glBindBuffer(GL_ARRAY_BUFFER, color2Buffer);
439 glBufferData(GL_ARRAY_BUFFER, colors2.size() * sizeof(GLColor), colors2.data(), GL_STATIC_DRAW);
440 glVertexAttribPointer(color2Loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, nullptr);
441 glEnableVertexAttribArray(color2Loc);
442
443 // Draw a non-indexed quad with all vertex buffers. Should draw yellow to the entire window.
444 drawQuad(program, "position", 0.5f, 1.0f, true);
445 ASSERT_GL_NO_ERROR();
446 EXPECT_PIXEL_RECT_EQ(0, 0, getWindowWidth(), getWindowHeight(), GLColor::yellow);
447}
448
Jamie Madill035fd6b2017-10-03 15:43:22 -0400449// Creates a texture, no other operations.
450TEST_P(SimpleOperationTest, CreateTexture2DNoData)
451{
452 GLTexture texture;
453 glBindTexture(GL_TEXTURE_2D, texture);
454 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
455 ASSERT_GL_NO_ERROR();
456}
457
458// Creates a texture, no other operations.
459TEST_P(SimpleOperationTest, CreateTexture2DWithData)
460{
461 std::vector<GLColor> colors(16 * 16, GLColor::red);
462
463 GLTexture texture;
464 glBindTexture(GL_TEXTURE_2D, texture);
465 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, colors.data());
466 ASSERT_GL_NO_ERROR();
467}
468
Jamie Madillde03e002017-10-21 14:04:20 -0400469// Creates a program with a texture.
470TEST_P(SimpleOperationTest, LinkProgramWithTexture)
471{
472 ASSERT_NE(0u, get2DTexturedQuadProgram());
473 EXPECT_GL_NO_ERROR();
474}
475
Jamie Madill5547b382017-10-23 18:16:01 -0400476// Creates a program with a texture and renders with it.
477TEST_P(SimpleOperationTest, DrawWithTexture)
478{
479 std::array<GLColor, 4> colors = {
480 {GLColor::red, GLColor::green, GLColor::blue, GLColor::yellow}};
481
482 GLTexture tex;
483 glBindTexture(GL_TEXTURE_2D, tex);
484 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, colors.data());
485 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
486 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
487
488 draw2DTexturedQuad(0.5f, 1.0f, true);
489 EXPECT_GL_NO_ERROR();
490
491 int w = getWindowWidth() - 2;
492 int h = getWindowHeight() - 2;
493
494 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
495 EXPECT_PIXEL_COLOR_EQ(w, 0, GLColor::green);
496 EXPECT_PIXEL_COLOR_EQ(0, h, GLColor::blue);
497 EXPECT_PIXEL_COLOR_EQ(w, h, GLColor::yellow);
498}
499
Jamie Madillb79e7bb2017-10-24 13:55:50 -0400500// Tests rendering to a user framebuffer.
501TEST_P(SimpleOperationTest, RenderToTexture)
502{
503 constexpr int kSize = 16;
504
505 GLTexture texture;
506 glBindTexture(GL_TEXTURE_2D, texture);
507 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kSize, kSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
508 ASSERT_GL_NO_ERROR();
509
510 GLFramebuffer framebuffer;
511 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
512 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
513 ASSERT_GL_NO_ERROR();
514 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
515
516 glViewport(0, 0, kSize, kSize);
517
518 const std::string &vertexShader =
519 "attribute vec3 position;\n"
520 "void main()\n"
521 "{\n"
522 " gl_Position = vec4(position, 1);\n"
523 "}";
524 const std::string &fragmentShader =
525 "void main()\n"
526 "{\n"
527 " gl_FragColor = vec4(0, 1, 0, 1);\n"
528 "}";
529 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
530 drawQuad(program, "position", 0.5f, 1.0f, true);
531 ASSERT_GL_NO_ERROR();
532 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
533}
534
Jamie Madillfa05f602015-05-07 13:47:11 -0400535// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
Geoff Lange0cc2a42016-01-20 10:58:17 -0500536ANGLE_INSTANTIATE_TEST(SimpleOperationTest,
537 ES2_D3D9(),
Austin Kinross2a63b3f2016-02-08 12:29:08 -0800538 ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE),
539 ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE),
Geoff Lange0cc2a42016-01-20 10:58:17 -0500540 ES3_D3D11(),
541 ES2_OPENGL(),
542 ES3_OPENGL(),
543 ES2_OPENGLES(),
Jamie Madillb8353b02017-01-25 12:57:21 -0800544 ES3_OPENGLES(),
545 ES2_VULKAN());
Jamie Madillfa05f602015-05-07 13:47:11 -0400546
547} // namespace