blob: 7701ac4fb379f89a57485dd949334ed1dbd8ea46 [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{
234 const std::string &vertexShader =
235 "attribute vec3 position;\n"
236 "void main()\n"
237 "{\n"
238 " gl_Position = vec4(position, 1);\n"
239 "}";
240 const std::string &fragmentShader =
241 "void main()\n"
242 "{\n"
243 " gl_FragColor = vec4(0, 1, 0, 1);\n"
244 "}";
245 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
246
247 for (int i = 0; i < 8; ++i)
248 {
249 drawQuad(program.get(), "position", 0.5f, 1.0f, true);
250 EXPECT_GL_NO_ERROR();
Jamie Madill4c26fc22017-02-24 11:04:10 -0500251 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
Jamie Madilldf68a6f2017-01-13 17:29:53 -0500252 swapBuffers();
253 }
254
255 EXPECT_GL_NO_ERROR();
256}
257
Jamie Madilld03a8492017-10-03 15:46:06 -0400258// Simple indexed quad test.
259TEST_P(SimpleOperationTest, DrawIndexedQuad)
260{
261 const std::string vertexShader =
262 "attribute vec3 position;\n"
263 "void main()\n"
264 "{\n"
265 " gl_Position = vec4(position, 1);\n"
266 "}";
267 const std::string fragmentShader =
268 "void main()\n"
269 "{\n"
270 " gl_FragColor = vec4(0, 1, 0, 1);\n"
271 "}";
272 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
273
274 drawIndexedQuad(program.get(), "position", 0.5f, 1.0f, true);
275
276 EXPECT_GL_NO_ERROR();
277 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
278}
279
Jamie Madill76e471e2017-10-21 09:56:01 -0400280// Draw with a fragment uniform.
281TEST_P(SimpleOperationTest, DrawQuadWithFragmentUniform)
282{
283 const std::string &vertexShader =
284 "attribute vec3 position;\n"
285 "void main()\n"
286 "{\n"
287 " gl_Position = vec4(position, 1);\n"
288 "}";
289 const std::string &fragmentShader =
290 "uniform mediump vec4 color;\n"
291 "void main()\n"
292 "{\n"
293 " gl_FragColor = color;\n"
294 "}";
295 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
296
297 GLint location = glGetUniformLocation(program, "color");
298 ASSERT_NE(-1, location);
299
300 glUseProgram(program);
301 glUniform4f(location, 0.0f, 1.0f, 0.0f, 1.0f);
302
303 drawQuad(program.get(), "position", 0.5f, 1.0f, true);
304
305 EXPECT_GL_NO_ERROR();
306 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
307}
308
309// Draw with a vertex uniform.
310TEST_P(SimpleOperationTest, DrawQuadWithVertexUniform)
311{
312 const std::string &vertexShader =
313 "attribute vec3 position;\n"
314 "uniform vec4 color;\n"
315 "varying vec4 vcolor;\n"
316 "void main()\n"
317 "{\n"
318 " gl_Position = vec4(position, 1);\n"
319 " vcolor = color;\n"
320 "}";
321 const std::string &fragmentShader =
322 "varying mediump vec4 vcolor;\n"
323 "void main()\n"
324 "{\n"
325 " gl_FragColor = vcolor;\n"
326 "}";
327 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
328
329 GLint location = glGetUniformLocation(program, "color");
330 ASSERT_NE(-1, location);
331
332 glUseProgram(program);
333 glUniform4f(location, 0.0f, 1.0f, 0.0f, 1.0f);
334
335 drawQuad(program.get(), "position", 0.5f, 1.0f, true);
336
337 EXPECT_GL_NO_ERROR();
338 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
339}
340
341// Draw with two uniforms.
342TEST_P(SimpleOperationTest, DrawQuadWithTwoUniforms)
343{
344 const std::string &vertexShader =
345 "attribute vec3 position;\n"
346 "uniform vec4 color1;\n"
347 "varying vec4 vcolor1;\n"
348 "void main()\n"
349 "{\n"
350 " gl_Position = vec4(position, 1);\n"
351 " vcolor1 = color1;\n"
352 "}";
353 const std::string &fragmentShader =
354 "uniform mediump vec4 color2;\n"
355 "varying mediump vec4 vcolor1;\n"
356 "void main()\n"
357 "{\n"
358 " gl_FragColor = vcolor1 + color2;\n"
359 "}";
360 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
361
362 GLint location1 = glGetUniformLocation(program, "color1");
363 ASSERT_NE(-1, location1);
364
365 GLint location2 = glGetUniformLocation(program, "color2");
366 ASSERT_NE(-1, location2);
367
368 glUseProgram(program);
369 glUniform4f(location1, 0.0f, 1.0f, 0.0f, 1.0f);
370 glUniform4f(location2, 1.0f, 0.0f, 0.0f, 1.0f);
371
372 drawQuad(program.get(), "position", 0.5f, 1.0f, true);
373
374 EXPECT_GL_NO_ERROR();
375 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::yellow);
376}
377
Jamie Madill2a9e1072017-09-22 11:31:57 -0400378// Tests a shader program with more than one vertex attribute, with vertex buffers.
379TEST_P(SimpleOperationTest, ThreeVertexAttributes)
380{
381 const std::string vertexShader =
382 R"(attribute vec2 position;
383attribute vec4 color1;
384attribute vec4 color2;
385varying vec4 color;
386void main()
387{
388 gl_Position = vec4(position, 0, 1);
389 color = color1 + color2;
390})";
391
392 const std::string fragmentShader =
393 R"(precision mediump float;
394varying vec4 color;
395void main()
396{
397 gl_FragColor = color;
398}
399)";
400
401 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
402
403 glUseProgram(program);
404
405 GLint color1Loc = glGetAttribLocation(program, "color1");
406 GLint color2Loc = glGetAttribLocation(program, "color2");
407 ASSERT_NE(-1, color1Loc);
408 ASSERT_NE(-1, color2Loc);
409
410 const auto &indices = GetQuadIndices();
411
412 // Make colored corners with red == x or 1 -x , and green = y or 1 - y.
413
414 std::array<GLColor, 4> baseColors1 = {
415 {GLColor::black, GLColor::red, GLColor::green, GLColor::yellow}};
416 std::array<GLColor, 4> baseColors2 = {
417 {GLColor::yellow, GLColor::green, GLColor::red, GLColor::black}};
418
419 std::vector<GLColor> colors1;
420 std::vector<GLColor> colors2;
421
422 for (GLushort index : indices)
423 {
424 colors1.push_back(baseColors1[index]);
425 colors2.push_back(baseColors2[index]);
426 }
427
428 GLBuffer color1Buffer;
429 glBindBuffer(GL_ARRAY_BUFFER, color1Buffer);
430 glBufferData(GL_ARRAY_BUFFER, colors1.size() * sizeof(GLColor), colors1.data(), GL_STATIC_DRAW);
431 glVertexAttribPointer(color1Loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, nullptr);
432 glEnableVertexAttribArray(color1Loc);
433
434 GLBuffer color2Buffer;
435 glBindBuffer(GL_ARRAY_BUFFER, color2Buffer);
436 glBufferData(GL_ARRAY_BUFFER, colors2.size() * sizeof(GLColor), colors2.data(), GL_STATIC_DRAW);
437 glVertexAttribPointer(color2Loc, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, nullptr);
438 glEnableVertexAttribArray(color2Loc);
439
440 // Draw a non-indexed quad with all vertex buffers. Should draw yellow to the entire window.
441 drawQuad(program, "position", 0.5f, 1.0f, true);
442 ASSERT_GL_NO_ERROR();
443 EXPECT_PIXEL_RECT_EQ(0, 0, getWindowWidth(), getWindowHeight(), GLColor::yellow);
444}
445
Jamie Madill035fd6b2017-10-03 15:43:22 -0400446// Creates a texture, no other operations.
447TEST_P(SimpleOperationTest, CreateTexture2DNoData)
448{
449 GLTexture texture;
450 glBindTexture(GL_TEXTURE_2D, texture);
451 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
452 ASSERT_GL_NO_ERROR();
453}
454
455// Creates a texture, no other operations.
456TEST_P(SimpleOperationTest, CreateTexture2DWithData)
457{
458 std::vector<GLColor> colors(16 * 16, GLColor::red);
459
460 GLTexture texture;
461 glBindTexture(GL_TEXTURE_2D, texture);
462 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, colors.data());
463 ASSERT_GL_NO_ERROR();
464}
465
Jamie Madillde03e002017-10-21 14:04:20 -0400466// Creates a program with a texture.
467TEST_P(SimpleOperationTest, LinkProgramWithTexture)
468{
469 ASSERT_NE(0u, get2DTexturedQuadProgram());
470 EXPECT_GL_NO_ERROR();
471}
472
Jamie Madill5547b382017-10-23 18:16:01 -0400473// Creates a program with a texture and renders with it.
474TEST_P(SimpleOperationTest, DrawWithTexture)
475{
476 std::array<GLColor, 4> colors = {
477 {GLColor::red, GLColor::green, GLColor::blue, GLColor::yellow}};
478
479 GLTexture tex;
480 glBindTexture(GL_TEXTURE_2D, tex);
481 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, colors.data());
482 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
483 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
484
485 draw2DTexturedQuad(0.5f, 1.0f, true);
486 EXPECT_GL_NO_ERROR();
487
488 int w = getWindowWidth() - 2;
489 int h = getWindowHeight() - 2;
490
491 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
492 EXPECT_PIXEL_COLOR_EQ(w, 0, GLColor::green);
493 EXPECT_PIXEL_COLOR_EQ(0, h, GLColor::blue);
494 EXPECT_PIXEL_COLOR_EQ(w, h, GLColor::yellow);
495}
496
Jamie Madillb79e7bb2017-10-24 13:55:50 -0400497// Tests rendering to a user framebuffer.
498TEST_P(SimpleOperationTest, RenderToTexture)
499{
500 constexpr int kSize = 16;
501
502 GLTexture texture;
503 glBindTexture(GL_TEXTURE_2D, texture);
504 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, kSize, kSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
505 ASSERT_GL_NO_ERROR();
506
507 GLFramebuffer framebuffer;
508 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
509 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
510 ASSERT_GL_NO_ERROR();
511 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
512
513 glViewport(0, 0, kSize, kSize);
514
515 const std::string &vertexShader =
516 "attribute vec3 position;\n"
517 "void main()\n"
518 "{\n"
519 " gl_Position = vec4(position, 1);\n"
520 "}";
521 const std::string &fragmentShader =
522 "void main()\n"
523 "{\n"
524 " gl_FragColor = vec4(0, 1, 0, 1);\n"
525 "}";
526 ANGLE_GL_PROGRAM(program, vertexShader, fragmentShader);
527 drawQuad(program, "position", 0.5f, 1.0f, true);
528 ASSERT_GL_NO_ERROR();
529 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
530}
531
Jamie Madillfa05f602015-05-07 13:47:11 -0400532// 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 -0500533ANGLE_INSTANTIATE_TEST(SimpleOperationTest,
534 ES2_D3D9(),
Austin Kinross2a63b3f2016-02-08 12:29:08 -0800535 ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE),
536 ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE),
Geoff Lange0cc2a42016-01-20 10:58:17 -0500537 ES3_D3D11(),
538 ES2_OPENGL(),
539 ES3_OPENGL(),
540 ES2_OPENGLES(),
Jamie Madillb8353b02017-01-25 12:57:21 -0800541 ES3_OPENGLES(),
542 ES2_VULKAN());
Jamie Madillfa05f602015-05-07 13:47:11 -0400543
544} // namespace