1 //
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
7 #include "test_utils/ANGLETest.h"
8 #include "test_utils/gl_raii.h"
9
10 using namespace angle;
11
12 class BlitFramebufferANGLETest : public ANGLETest
13 {
14 protected:
BlitFramebufferANGLETest()15 BlitFramebufferANGLETest()
16 {
17 setWindowWidth(32);
18 setWindowHeight(32);
19 setConfigRedBits(8);
20 setConfigGreenBits(8);
21 setConfigBlueBits(8);
22 setConfigAlphaBits(8);
23 setConfigDepthBits(24);
24 setConfigStencilBits(8);
25
26 mCheckerProgram = 0;
27 mBlueProgram = 0;
28 mRedProgram = 0;
29
30 mOriginalFBO = 0;
31
32 mUserFBO = 0;
33 mUserColorBuffer = 0;
34 mUserDepthStencilBuffer = 0;
35
36 mSmallFBO = 0;
37 mSmallColorBuffer = 0;
38 mSmallDepthStencilBuffer = 0;
39
40 mColorOnlyFBO = 0;
41 mColorOnlyColorBuffer = 0;
42
43 mDiffFormatFBO = 0;
44 mDiffFormatColorBuffer = 0;
45
46 mDiffSizeFBO = 0;
47 mDiffSizeColorBuffer = 0;
48
49 mMRTFBO = 0;
50 mMRTColorBuffer0 = 0;
51 mMRTColorBuffer1 = 0;
52
53 mRGBAColorbuffer = 0;
54 mRGBAFBO = 0;
55 mRGBAMultisampledRenderbuffer = 0;
56 mRGBAMultisampledFBO = 0;
57
58 mBGRAColorbuffer = 0;
59 mBGRAFBO = 0;
60 mBGRAMultisampledRenderbuffer = 0;
61 mBGRAMultisampledFBO = 0;
62 }
63
testSetUp()64 void testSetUp() override
65 {
66 mCheckerProgram =
67 CompileProgram(essl1_shaders::vs::Passthrough(), essl1_shaders::fs::Checkered());
68 mBlueProgram = CompileProgram(essl1_shaders::vs::Simple(), essl1_shaders::fs::Blue());
69 mRedProgram = CompileProgram(essl1_shaders::vs::Simple(), essl1_shaders::fs::Red());
70 if (mCheckerProgram == 0 || mBlueProgram == 0 || mRedProgram == 0)
71 {
72 FAIL() << "shader compilation failed.";
73 }
74
75 EXPECT_GL_NO_ERROR();
76
77 GLint originalFBO;
78 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &originalFBO);
79 if (originalFBO >= 0)
80 {
81 mOriginalFBO = (GLuint)originalFBO;
82 }
83
84 GLenum format = GL_BGRA_EXT;
85
86 glGenFramebuffers(1, &mUserFBO);
87 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
88 glGenTextures(1, &mUserColorBuffer);
89 glGenRenderbuffers(1, &mUserDepthStencilBuffer);
90 glBindTexture(GL_TEXTURE_2D, mUserColorBuffer);
91 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
92 mUserColorBuffer, 0);
93 glTexImage2D(GL_TEXTURE_2D, 0, format, getWindowWidth(), getWindowHeight(), 0, format,
94 GL_UNSIGNED_BYTE, nullptr);
95 glBindRenderbuffer(GL_RENDERBUFFER, mUserDepthStencilBuffer);
96 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, getWindowWidth(),
97 getWindowHeight());
98 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
99 mUserDepthStencilBuffer);
100 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
101 mUserDepthStencilBuffer);
102
103 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
104 ASSERT_GL_NO_ERROR();
105
106 glGenFramebuffers(1, &mSmallFBO);
107 glBindFramebuffer(GL_FRAMEBUFFER, mSmallFBO);
108 glGenTextures(1, &mSmallColorBuffer);
109 glGenRenderbuffers(1, &mSmallDepthStencilBuffer);
110 glBindTexture(GL_TEXTURE_2D, mSmallColorBuffer);
111 glTexImage2D(GL_TEXTURE_2D, 0, format, getWindowWidth() / 2, getWindowHeight() / 2, 0,
112 format, GL_UNSIGNED_BYTE, nullptr);
113 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
114 mSmallColorBuffer, 0);
115 glBindRenderbuffer(GL_RENDERBUFFER, mSmallDepthStencilBuffer);
116 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, getWindowWidth() / 2,
117 getWindowHeight() / 2);
118 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
119 mSmallDepthStencilBuffer);
120 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
121 mSmallDepthStencilBuffer);
122
123 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
124 ASSERT_GL_NO_ERROR();
125
126 glGenFramebuffers(1, &mColorOnlyFBO);
127 glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO);
128 glGenTextures(1, &mColorOnlyColorBuffer);
129 glBindTexture(GL_TEXTURE_2D, mColorOnlyColorBuffer);
130 glTexImage2D(GL_TEXTURE_2D, 0, format, getWindowWidth(), getWindowHeight(), 0, format,
131 GL_UNSIGNED_BYTE, nullptr);
132 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
133 mColorOnlyColorBuffer, 0);
134
135 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
136 ASSERT_GL_NO_ERROR();
137
138 glGenFramebuffers(1, &mDiffFormatFBO);
139 glBindFramebuffer(GL_FRAMEBUFFER, mDiffFormatFBO);
140 glGenTextures(1, &mDiffFormatColorBuffer);
141 glBindTexture(GL_TEXTURE_2D, mDiffFormatColorBuffer);
142 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, getWindowWidth(), getWindowHeight(), 0, GL_RGB,
143 GL_UNSIGNED_SHORT_5_6_5, nullptr);
144 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
145 mDiffFormatColorBuffer, 0);
146
147 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
148 ASSERT_GL_NO_ERROR();
149
150 glGenFramebuffers(1, &mDiffSizeFBO);
151 glBindFramebuffer(GL_FRAMEBUFFER, mDiffSizeFBO);
152 glGenTextures(1, &mDiffSizeColorBuffer);
153 glBindTexture(GL_TEXTURE_2D, mDiffSizeColorBuffer);
154 glTexImage2D(GL_TEXTURE_2D, 0, format, getWindowWidth() * 2, getWindowHeight() * 2, 0,
155 format, GL_UNSIGNED_BYTE, nullptr);
156 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
157 mDiffSizeColorBuffer, 0);
158
159 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
160 ASSERT_GL_NO_ERROR();
161
162 if (IsGLExtensionEnabled("GL_EXT_draw_buffers"))
163 {
164 glGenFramebuffers(1, &mMRTFBO);
165 glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO);
166 glGenTextures(1, &mMRTColorBuffer0);
167 glGenTextures(1, &mMRTColorBuffer1);
168 glBindTexture(GL_TEXTURE_2D, mMRTColorBuffer0);
169 glTexImage2D(GL_TEXTURE_2D, 0, format, getWindowWidth(), getWindowHeight(), 0, format,
170 GL_UNSIGNED_BYTE, nullptr);
171 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
172 mMRTColorBuffer0, 0);
173 glBindTexture(GL_TEXTURE_2D, mMRTColorBuffer1);
174 glTexImage2D(GL_TEXTURE_2D, 0, format, getWindowWidth(), getWindowHeight(), 0, format,
175 GL_UNSIGNED_BYTE, nullptr);
176 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D,
177 mMRTColorBuffer1, 0);
178
179 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
180 ASSERT_GL_NO_ERROR();
181 }
182
183 if (IsGLExtensionEnabled("GL_ANGLE_framebuffer_multisample") &&
184 IsGLExtensionEnabled("GL_OES_rgb8_rgba8"))
185 {
186 // RGBA single-sampled framebuffer
187 glGenTextures(1, &mRGBAColorbuffer);
188 glBindTexture(GL_TEXTURE_2D, mRGBAColorbuffer);
189 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA,
190 GL_UNSIGNED_BYTE, nullptr);
191
192 glGenFramebuffers(1, &mRGBAFBO);
193 glBindFramebuffer(GL_FRAMEBUFFER, mRGBAFBO);
194 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
195 mRGBAColorbuffer, 0);
196
197 ASSERT_GL_NO_ERROR();
198 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
199
200 // RGBA multisampled framebuffer
201 glGenRenderbuffers(1, &mRGBAMultisampledRenderbuffer);
202 glBindRenderbuffer(GL_RENDERBUFFER, mRGBAMultisampledRenderbuffer);
203 glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, 1, GL_RGBA8, getWindowWidth(),
204 getWindowHeight());
205
206 glGenFramebuffers(1, &mRGBAMultisampledFBO);
207 glBindFramebuffer(GL_FRAMEBUFFER, mRGBAMultisampledFBO);
208 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
209 mRGBAMultisampledRenderbuffer);
210
211 ASSERT_GL_NO_ERROR();
212 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
213
214 if (IsGLExtensionEnabled("GL_EXT_texture_format_BGRA8888"))
215 {
216 // BGRA single-sampled framebuffer
217 glGenTextures(1, &mBGRAColorbuffer);
218 glBindTexture(GL_TEXTURE_2D, mBGRAColorbuffer);
219 glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, getWindowWidth(), getWindowHeight(), 0,
220 GL_BGRA_EXT, GL_UNSIGNED_BYTE, nullptr);
221
222 glGenFramebuffers(1, &mBGRAFBO);
223 glBindFramebuffer(GL_FRAMEBUFFER, mBGRAFBO);
224 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
225 mBGRAColorbuffer, 0);
226
227 ASSERT_GL_NO_ERROR();
228 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
229
230 // BGRA multisampled framebuffer
231 glGenRenderbuffers(1, &mBGRAMultisampledRenderbuffer);
232 glBindRenderbuffer(GL_RENDERBUFFER, mBGRAMultisampledRenderbuffer);
233 glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, 1, GL_BGRA8_EXT,
234 getWindowWidth(), getWindowHeight());
235
236 glGenFramebuffers(1, &mBGRAMultisampledFBO);
237 glBindFramebuffer(GL_FRAMEBUFFER, mBGRAMultisampledFBO);
238 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
239 mBGRAMultisampledRenderbuffer);
240
241 ASSERT_GL_NO_ERROR();
242 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
243 }
244 }
245
246 glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
247 }
248
testTearDown()249 void testTearDown() override
250 {
251 glDeleteProgram(mCheckerProgram);
252 glDeleteProgram(mBlueProgram);
253 glDeleteProgram(mRedProgram);
254
255 glDeleteFramebuffers(1, &mUserFBO);
256 glDeleteTextures(1, &mUserColorBuffer);
257 glDeleteRenderbuffers(1, &mUserDepthStencilBuffer);
258
259 glDeleteFramebuffers(1, &mSmallFBO);
260 glDeleteTextures(1, &mSmallColorBuffer);
261 glDeleteRenderbuffers(1, &mSmallDepthStencilBuffer);
262
263 glDeleteFramebuffers(1, &mColorOnlyFBO);
264 glDeleteTextures(1, &mSmallDepthStencilBuffer);
265
266 glDeleteFramebuffers(1, &mDiffFormatFBO);
267 glDeleteTextures(1, &mDiffFormatColorBuffer);
268
269 glDeleteFramebuffers(1, &mDiffSizeFBO);
270 glDeleteTextures(1, &mDiffSizeColorBuffer);
271
272 if (IsGLExtensionEnabled("GL_EXT_draw_buffers"))
273 {
274 glDeleteFramebuffers(1, &mMRTFBO);
275 glDeleteTextures(1, &mMRTColorBuffer0);
276 glDeleteTextures(1, &mMRTColorBuffer1);
277 }
278
279 if (mRGBAColorbuffer != 0)
280 {
281 glDeleteTextures(1, &mRGBAColorbuffer);
282 }
283
284 if (mRGBAFBO != 0)
285 {
286 glDeleteFramebuffers(1, &mRGBAFBO);
287 }
288
289 if (mRGBAMultisampledRenderbuffer != 0)
290 {
291 glDeleteRenderbuffers(1, &mRGBAMultisampledRenderbuffer);
292 }
293
294 if (mRGBAMultisampledFBO != 0)
295 {
296 glDeleteFramebuffers(1, &mRGBAMultisampledFBO);
297 }
298
299 if (mBGRAColorbuffer != 0)
300 {
301 glDeleteTextures(1, &mBGRAColorbuffer);
302 }
303
304 if (mBGRAFBO != 0)
305 {
306 glDeleteFramebuffers(1, &mBGRAFBO);
307 }
308
309 if (mBGRAMultisampledRenderbuffer != 0)
310 {
311 glDeleteRenderbuffers(1, &mBGRAMultisampledRenderbuffer);
312 }
313
314 if (mBGRAMultisampledFBO != 0)
315 {
316 glDeleteFramebuffers(1, &mBGRAMultisampledFBO);
317 }
318 }
319
multisampleTestHelper(GLuint readFramebuffer,GLuint drawFramebuffer)320 void multisampleTestHelper(GLuint readFramebuffer, GLuint drawFramebuffer)
321 {
322 glClearColor(0.0, 1.0, 0.0, 1.0);
323 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, readFramebuffer);
324 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
325 EXPECT_GL_NO_ERROR();
326
327 glBindFramebuffer(GL_READ_FRAMEBUFFER, readFramebuffer);
328 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFramebuffer);
329 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
330 getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
331 EXPECT_GL_NO_ERROR();
332
333 glBindFramebuffer(GL_READ_FRAMEBUFFER, drawFramebuffer);
334 EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255);
335 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255);
336 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255);
337 EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255);
338 }
339
checkExtension(const std::string & extension)340 bool checkExtension(const std::string &extension)
341 {
342 if (!IsGLExtensionEnabled(extension))
343 {
344 std::cout << "Test skipped because " << extension << " not supported." << std::endl;
345 return false;
346 }
347
348 return true;
349 }
350
351 GLuint mCheckerProgram;
352 GLuint mBlueProgram;
353 GLuint mRedProgram;
354
355 GLuint mOriginalFBO;
356
357 GLuint mUserFBO;
358 GLuint mUserColorBuffer;
359 GLuint mUserDepthStencilBuffer;
360
361 GLuint mSmallFBO;
362 GLuint mSmallColorBuffer;
363 GLuint mSmallDepthStencilBuffer;
364
365 GLuint mColorOnlyFBO;
366 GLuint mColorOnlyColorBuffer;
367
368 GLuint mDiffFormatFBO;
369 GLuint mDiffFormatColorBuffer;
370
371 GLuint mDiffSizeFBO;
372 GLuint mDiffSizeColorBuffer;
373
374 GLuint mMRTFBO;
375 GLuint mMRTColorBuffer0;
376 GLuint mMRTColorBuffer1;
377
378 GLuint mRGBAColorbuffer;
379 GLuint mRGBAFBO;
380 GLuint mRGBAMultisampledRenderbuffer;
381 GLuint mRGBAMultisampledFBO;
382
383 GLuint mBGRAColorbuffer;
384 GLuint mBGRAFBO;
385 GLuint mBGRAMultisampledRenderbuffer;
386 GLuint mBGRAMultisampledFBO;
387 };
388
389 // Draw to user-created framebuffer, blit whole-buffer color to original framebuffer.
TEST_P(BlitFramebufferANGLETest,BlitColorToDefault)390 TEST_P(BlitFramebufferANGLETest, BlitColorToDefault)
391 {
392 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
393
394 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
395
396 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
397
398 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f);
399
400 EXPECT_GL_NO_ERROR();
401
402 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
403 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
404
405 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
406 getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
407
408 EXPECT_GL_NO_ERROR();
409
410 glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
411
412 EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, getWindowHeight() / 4, GLColor::red);
413 EXPECT_PIXEL_COLOR_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, GLColor::green);
414 EXPECT_PIXEL_COLOR_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, GLColor::red);
415 EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, GLColor::green);
416 }
417
418 // Draw to system framebuffer, blit whole-buffer color to user-created framebuffer.
TEST_P(BlitFramebufferANGLETest,ReverseColorBlit)419 TEST_P(BlitFramebufferANGLETest, ReverseColorBlit)
420 {
421 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
422
423 // TODO(jmadill): Fix this. http://anglebug.com/2743
424 ANGLE_SKIP_TEST_IF(IsVulkan() && IsAndroid());
425
426 glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
427
428 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
429
430 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f);
431
432 EXPECT_GL_NO_ERROR();
433
434 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO);
435 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO);
436
437 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
438 getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
439
440 EXPECT_GL_NO_ERROR();
441
442 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
443
444 EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
445 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255);
446 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255);
447 EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255);
448 }
449
450 // blit from user-created FBO to system framebuffer, with the scissor test enabled.
TEST_P(BlitFramebufferANGLETest,ScissoredBlit)451 TEST_P(BlitFramebufferANGLETest, ScissoredBlit)
452 {
453 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
454
455 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
456
457 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
458
459 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f);
460
461 EXPECT_GL_NO_ERROR();
462
463 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
464 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
465
466 glClearColor(1.0, 1.0, 1.0, 1.0);
467 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
468
469 glScissor(getWindowWidth() / 2, 0, getWindowWidth() / 2, getWindowHeight());
470 glEnable(GL_SCISSOR_TEST);
471
472 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
473 getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
474
475 EXPECT_GL_NO_ERROR();
476
477 glDisable(GL_SCISSOR_TEST);
478
479 glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
480
481 EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255);
482 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255);
483 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255);
484 EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 255, 255, 255);
485 }
486
487 // blit from system FBO to user-created framebuffer, with the scissor test enabled.
TEST_P(BlitFramebufferANGLETest,ReverseScissoredBlit)488 TEST_P(BlitFramebufferANGLETest, ReverseScissoredBlit)
489 {
490 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
491
492 glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
493
494 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
495
496 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f);
497
498 EXPECT_GL_NO_ERROR();
499
500 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO);
501 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO);
502
503 glClearColor(1.0, 1.0, 1.0, 1.0);
504 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
505
506 glScissor(getWindowWidth() / 2, 0, getWindowWidth() / 2, getWindowHeight());
507 glEnable(GL_SCISSOR_TEST);
508
509 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
510 getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
511
512 EXPECT_GL_NO_ERROR();
513
514 glDisable(GL_SCISSOR_TEST);
515
516 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
517
518 EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255);
519 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255);
520 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255);
521 EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 255, 255, 255);
522 }
523
524 // blit from user-created FBO to system framebuffer, using region larger than buffer.
TEST_P(BlitFramebufferANGLETest,OversizedBlit)525 TEST_P(BlitFramebufferANGLETest, OversizedBlit)
526 {
527 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
528
529 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
530
531 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
532
533 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f);
534
535 EXPECT_GL_NO_ERROR();
536
537 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
538 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
539
540 glClearColor(1.0, 1.0, 1.0, 1.0);
541 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
542
543 glBlitFramebufferANGLE(0, 0, getWindowWidth() * 2, getWindowHeight() * 2, 0, 0,
544 getWindowWidth() * 2, getWindowHeight() * 2, GL_COLOR_BUFFER_BIT,
545 GL_NEAREST);
546
547 EXPECT_GL_NO_ERROR();
548
549 glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
550
551 EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
552 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255);
553 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255);
554 EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255);
555 }
556
557 // blit from system FBO to user-created framebuffer, using region larger than buffer.
TEST_P(BlitFramebufferANGLETest,ReverseOversizedBlit)558 TEST_P(BlitFramebufferANGLETest, ReverseOversizedBlit)
559 {
560 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
561
562 glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
563
564 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
565
566 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f);
567
568 EXPECT_GL_NO_ERROR();
569
570 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO);
571 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO);
572
573 glClearColor(1.0, 1.0, 1.0, 1.0);
574 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
575
576 glBlitFramebufferANGLE(0, 0, getWindowWidth() * 2, getWindowHeight() * 2, 0, 0,
577 getWindowWidth() * 2, getWindowHeight() * 2, GL_COLOR_BUFFER_BIT,
578 GL_NEAREST);
579 EXPECT_GL_NO_ERROR();
580
581 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
582
583 EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
584 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255);
585 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255);
586 EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255);
587 }
588
589 // blit from user-created FBO to system framebuffer, with depth buffer.
TEST_P(BlitFramebufferANGLETest,BlitWithDepthUserToDefault)590 TEST_P(BlitFramebufferANGLETest, BlitWithDepthUserToDefault)
591 {
592 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
593
594 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
595
596 glDepthMask(GL_TRUE);
597 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
598
599 glEnable(GL_DEPTH_TEST);
600
601 EXPECT_GL_NO_ERROR();
602
603 // Clear the first half of the screen
604 glEnable(GL_SCISSOR_TEST);
605 glScissor(0, 0, getWindowWidth(), getWindowHeight() / 2);
606
607 glClearDepthf(0.1f);
608 glClearColor(1.0, 0.0, 0.0, 1.0);
609 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
610
611 // Scissor the second half of the screen
612 glScissor(0, getWindowHeight() / 2, getWindowWidth(), getWindowHeight() / 2);
613
614 glClearDepthf(0.9f);
615 glClearColor(0.0, 1.0, 0.0, 1.0);
616 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
617
618 glDisable(GL_SCISSOR_TEST);
619
620 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
621 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
622
623 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
624 getWindowHeight(), GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
625 GL_NEAREST);
626 EXPECT_GL_NO_ERROR();
627
628 glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
629
630 // if blit is happening correctly, this quad will draw only on the bottom half since it will
631 // be behind on the first half and in front on the second half.
632 drawQuad(mBlueProgram, essl1_shaders::PositionAttrib(), 0.5f);
633
634 glDisable(GL_DEPTH_TEST);
635
636 EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, getWindowHeight() / 4, GLColor::red);
637 EXPECT_PIXEL_COLOR_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, GLColor::red);
638 EXPECT_PIXEL_COLOR_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, GLColor::blue);
639 EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, GLColor::blue);
640 }
641
642 // blit from system FBO to user-created framebuffer, with depth buffer.
TEST_P(BlitFramebufferANGLETest,BlitWithDepthDefaultToUser)643 TEST_P(BlitFramebufferANGLETest, BlitWithDepthDefaultToUser)
644 {
645 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
646
647 glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
648
649 glDepthMask(GL_TRUE);
650 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
651
652 glEnable(GL_DEPTH_TEST);
653
654 EXPECT_GL_NO_ERROR();
655
656 // Clear the first half of the screen
657 glEnable(GL_SCISSOR_TEST);
658 glScissor(0, 0, getWindowWidth(), getWindowHeight() / 2);
659
660 glClearDepthf(0.1f);
661 glClearColor(1.0, 0.0, 0.0, 1.0);
662 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
663
664 // Scissor the second half of the screen
665 glScissor(0, getWindowHeight() / 2, getWindowWidth(), getWindowHeight() / 2);
666
667 glClearDepthf(0.9f);
668 glClearColor(0.0, 1.0, 0.0, 1.0);
669 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
670
671 glDisable(GL_SCISSOR_TEST);
672
673 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO);
674 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO);
675
676 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
677 getWindowHeight(), GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
678 GL_NEAREST);
679 EXPECT_GL_NO_ERROR();
680
681 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
682
683 // if blit is happening correctly, this quad will draw only on the bottom half since it will be
684 // behind on the first half and in front on the second half.
685 drawQuad(mBlueProgram, essl1_shaders::PositionAttrib(), 0.5f);
686
687 glDisable(GL_DEPTH_TEST);
688
689 EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
690 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
691 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255);
692 EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255);
693 }
694
695 // blit from one region of the system fbo to another-- this should fail.
TEST_P(BlitFramebufferANGLETest,BlitSameBufferOriginal)696 TEST_P(BlitFramebufferANGLETest, BlitSameBufferOriginal)
697 {
698 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
699
700 glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
701
702 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
703
704 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f);
705
706 EXPECT_GL_NO_ERROR();
707
708 glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight(), getWindowWidth() / 2, 0,
709 getWindowWidth(), getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
710 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
711 }
712
713 // blit from one region of the system fbo to another.
TEST_P(BlitFramebufferANGLETest,BlitSameBufferUser)714 TEST_P(BlitFramebufferANGLETest, BlitSameBufferUser)
715 {
716 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
717
718 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
719
720 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
721
722 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f);
723
724 EXPECT_GL_NO_ERROR();
725
726 glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight(), getWindowWidth() / 2, 0,
727 getWindowWidth(), getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
728 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
729 }
730
TEST_P(BlitFramebufferANGLETest,BlitPartialColor)731 TEST_P(BlitFramebufferANGLETest, BlitPartialColor)
732 {
733 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
734
735 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
736
737 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
738
739 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f);
740
741 EXPECT_GL_NO_ERROR();
742
743 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
744 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
745
746 glClearColor(1.0, 1.0, 1.0, 1.0);
747 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
748
749 glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0,
750 getWindowHeight() / 2, getWindowWidth() / 2, getWindowHeight(),
751 GL_COLOR_BUFFER_BIT, GL_NEAREST);
752
753 EXPECT_GL_NO_ERROR();
754
755 glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
756
757 EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, getWindowHeight() / 4, GLColor::white);
758 EXPECT_PIXEL_COLOR_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, GLColor::white);
759 EXPECT_PIXEL_COLOR_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, GLColor::white);
760 EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, GLColor::red);
761 }
762
TEST_P(BlitFramebufferANGLETest,BlitDifferentSizes)763 TEST_P(BlitFramebufferANGLETest, BlitDifferentSizes)
764 {
765 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
766
767 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
768
769 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
770
771 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f);
772
773 EXPECT_GL_NO_ERROR();
774
775 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mSmallFBO);
776 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
777
778 glClearColor(1.0, 1.0, 1.0, 1.0);
779 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
780
781 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
782 getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
783
784 EXPECT_GL_NO_ERROR();
785
786 glBindFramebuffer(GL_FRAMEBUFFER, mSmallFBO);
787
788 EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
789
790 EXPECT_GL_NO_ERROR();
791 }
792
TEST_P(BlitFramebufferANGLETest,BlitWithMissingAttachments)793 TEST_P(BlitFramebufferANGLETest, BlitWithMissingAttachments)
794 {
795 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
796
797 glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO);
798
799 glClear(GL_COLOR_BUFFER_BIT);
800 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f);
801
802 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
803 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mColorOnlyFBO);
804
805 glClearColor(1.0, 1.0, 1.0, 1.0);
806 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
807
808 // generate INVALID_OPERATION if the read FBO has no depth attachment
809 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
810 getWindowHeight(), GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
811 GL_NEAREST);
812
813 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
814
815 // generate INVALID_OPERATION if the read FBO has no stencil attachment
816 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
817 getWindowHeight(), GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
818 GL_NEAREST);
819
820 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
821
822 // generate INVALID_OPERATION if we read from a missing color attachment
823 glReadBuffer(GL_COLOR_ATTACHMENT1);
824 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
825 getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
826
827 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
828 }
829
TEST_P(BlitFramebufferANGLETest,BlitStencil)830 TEST_P(BlitFramebufferANGLETest, BlitStencil)
831 {
832 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
833
834 // http://anglebug.com/2205
835 ANGLE_SKIP_TEST_IF(IsIntel() && IsD3D9());
836
837 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
838
839 glClearColor(0.0, 1.0, 0.0, 1.0);
840 glClearStencil(0x0);
841 glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
842
843 // Scissor half the screen so we fill the stencil only halfway
844 glScissor(0, 0, getWindowWidth(), getWindowHeight() / 2);
845 glEnable(GL_SCISSOR_TEST);
846
847 // fill the stencil buffer with 0x1
848 glStencilFunc(GL_ALWAYS, 0x1, 0xFF);
849 glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
850 glEnable(GL_STENCIL_TEST);
851 drawQuad(mRedProgram, essl1_shaders::PositionAttrib(), 0.3f);
852
853 glDisable(GL_SCISSOR_TEST);
854
855 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
856 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
857
858 // These clears are not useful in theory because we're copying over them, but its
859 // helpful in debugging if we see white in any result.
860 glClearColor(1.0, 1.0, 1.0, 1.0);
861 glClearStencil(0x0);
862 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
863
864 // depth blit request should be silently ignored, because the read FBO has no depth attachment
865 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
866 getWindowHeight(), GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
867 GL_NEAREST);
868
869 EXPECT_GL_NO_ERROR();
870
871 glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
872
873 EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
874 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
875 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255);
876 EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255);
877
878 glStencilFunc(GL_EQUAL, 0x1, 0xFF); // only pass if stencil buffer at pixel reads 0x1
879
880 drawQuad(mBlueProgram, essl1_shaders::PositionAttrib(),
881 0.8f); // blue quad will draw if stencil buffer was copied
882
883 glDisable(GL_STENCIL_TEST);
884
885 EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 0, 0, 255, 255);
886 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 0, 255, 255);
887 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255);
888 EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255);
889 }
890
891 // make sure that attempting to blit a partial depth buffer issues an error
TEST_P(BlitFramebufferANGLETest,BlitPartialDepthStencil)892 TEST_P(BlitFramebufferANGLETest, BlitPartialDepthStencil)
893 {
894 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
895
896 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
897
898 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
899
900 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f);
901
902 EXPECT_GL_NO_ERROR();
903
904 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
905 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
906
907 glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0, 0,
908 getWindowWidth() / 2, getWindowHeight() / 2, GL_DEPTH_BUFFER_BIT,
909 GL_NEAREST);
910 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
911 }
912
913 // Test blit with MRT framebuffers
TEST_P(BlitFramebufferANGLETest,BlitMRT)914 TEST_P(BlitFramebufferANGLETest, BlitMRT)
915 {
916 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
917
918 if (!IsGLExtensionEnabled("GL_EXT_draw_buffers"))
919 {
920 return;
921 }
922
923 GLenum drawBuffers[] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT};
924
925 glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO);
926 glDrawBuffersEXT(2, drawBuffers);
927
928 glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO);
929
930 glClear(GL_COLOR_BUFFER_BIT);
931
932 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f);
933
934 EXPECT_GL_NO_ERROR();
935
936 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mColorOnlyFBO);
937 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mMRTFBO);
938
939 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
940 getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
941
942 EXPECT_GL_NO_ERROR();
943
944 glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO);
945
946 EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
947 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255);
948 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255);
949 EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255);
950
951 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0);
952 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mMRTColorBuffer0,
953 0);
954
955 EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
956 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255);
957 EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255);
958 EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255);
959
960 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mMRTColorBuffer0,
961 0);
962 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D,
963 mMRTColorBuffer1, 0);
964 }
965
966 // Test multisampled framebuffer blits if supported
TEST_P(BlitFramebufferANGLETest,MultisampledRGBAToRGBA)967 TEST_P(BlitFramebufferANGLETest, MultisampledRGBAToRGBA)
968 {
969 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
970
971 if (!checkExtension("GL_ANGLE_framebuffer_multisample"))
972 return;
973
974 if (!checkExtension("GL_OES_rgb8_rgba8"))
975 return;
976
977 multisampleTestHelper(mRGBAMultisampledFBO, mRGBAFBO);
978 }
979
TEST_P(BlitFramebufferANGLETest,MultisampledRGBAToBGRA)980 TEST_P(BlitFramebufferANGLETest, MultisampledRGBAToBGRA)
981 {
982 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
983
984 if (!checkExtension("GL_ANGLE_framebuffer_multisample"))
985 return;
986
987 if (!checkExtension("GL_OES_rgb8_rgba8"))
988 return;
989
990 if (!checkExtension("GL_EXT_texture_format_BGRA8888"))
991 return;
992
993 multisampleTestHelper(mRGBAMultisampledFBO, mBGRAFBO);
994 }
995
TEST_P(BlitFramebufferANGLETest,MultisampledBGRAToRGBA)996 TEST_P(BlitFramebufferANGLETest, MultisampledBGRAToRGBA)
997 {
998 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
999
1000 if (!checkExtension("GL_ANGLE_framebuffer_multisample"))
1001 return;
1002
1003 if (!checkExtension("GL_OES_rgb8_rgba8"))
1004 return;
1005
1006 if (!checkExtension("GL_EXT_texture_format_BGRA8888"))
1007 return;
1008
1009 multisampleTestHelper(mBGRAMultisampledFBO, mRGBAFBO);
1010 }
1011
TEST_P(BlitFramebufferANGLETest,MultisampledBGRAToBGRA)1012 TEST_P(BlitFramebufferANGLETest, MultisampledBGRAToBGRA)
1013 {
1014 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
1015
1016 if (!checkExtension("GL_ANGLE_framebuffer_multisample"))
1017 return;
1018
1019 if (!checkExtension("GL_OES_rgb8_rgba8"))
1020 return;
1021
1022 if (!checkExtension("GL_EXT_texture_format_BGRA8888"))
1023 return;
1024
1025 multisampleTestHelper(mBGRAMultisampledFBO, mBGRAFBO);
1026 }
1027
1028 // Make sure that attempts to stretch in a blit call issue an error
TEST_P(BlitFramebufferANGLETest,ErrorStretching)1029 TEST_P(BlitFramebufferANGLETest, ErrorStretching)
1030 {
1031 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
1032
1033 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
1034
1035 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1036
1037 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f);
1038
1039 EXPECT_GL_NO_ERROR();
1040
1041 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
1042 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
1043
1044 glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0, 0,
1045 getWindowWidth(), getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
1046 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1047 }
1048
1049 // Make sure that attempts to flip in a blit call issue an error
TEST_P(BlitFramebufferANGLETest,ErrorFlipping)1050 TEST_P(BlitFramebufferANGLETest, ErrorFlipping)
1051 {
1052 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
1053
1054 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
1055
1056 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1057
1058 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f);
1059
1060 EXPECT_GL_NO_ERROR();
1061
1062 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
1063 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
1064
1065 glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, getWindowWidth() / 2,
1066 getWindowHeight() / 2, 0, 0, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1067 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1068 }
1069
TEST_P(BlitFramebufferANGLETest,Errors)1070 TEST_P(BlitFramebufferANGLETest, Errors)
1071 {
1072 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
1073
1074 glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
1075
1076 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1077
1078 drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f);
1079
1080 EXPECT_GL_NO_ERROR();
1081
1082 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
1083 glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
1084
1085 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
1086 getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_LINEAR);
1087 EXPECT_GL_ERROR(GL_INVALID_ENUM);
1088
1089 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
1090 getWindowHeight(), GL_COLOR_BUFFER_BIT | 234, GL_NEAREST);
1091 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1092
1093 glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mDiffFormatFBO);
1094
1095 glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(),
1096 getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
1097 EXPECT_GL_ERROR(GL_INVALID_OPERATION);
1098 }
1099
1100 // TODO(geofflang): Fix the dependence on glBlitFramebufferANGLE without checks and assuming the
1101 // default framebuffer is BGRA to enable the GL and GLES backends. (http://anglebug.com/1289)
1102
1103 class BlitFramebufferTest : public ANGLETest
1104 {
1105 protected:
BlitFramebufferTest()1106 BlitFramebufferTest()
1107 {
1108 setWindowWidth(256);
1109 setWindowHeight(256);
1110 setConfigRedBits(8);
1111 setConfigGreenBits(8);
1112 setConfigBlueBits(8);
1113 setConfigAlphaBits(8);
1114 setConfigDepthBits(24);
1115 setConfigStencilBits(8);
1116 }
1117
initColorFBO(GLFramebuffer * fbo,GLRenderbuffer * rbo,GLenum rboFormat,GLsizei width,GLsizei height)1118 void initColorFBO(GLFramebuffer *fbo,
1119 GLRenderbuffer *rbo,
1120 GLenum rboFormat,
1121 GLsizei width,
1122 GLsizei height)
1123 {
1124 glBindRenderbuffer(GL_RENDERBUFFER, *rbo);
1125 glRenderbufferStorage(GL_RENDERBUFFER, rboFormat, width, height);
1126
1127 glBindFramebuffer(GL_FRAMEBUFFER, *fbo);
1128 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *rbo);
1129 }
1130
initColorFBOWithCheckerPattern(GLFramebuffer * fbo,GLRenderbuffer * rbo,GLenum rboFormat,GLsizei width,GLsizei height)1131 void initColorFBOWithCheckerPattern(GLFramebuffer *fbo,
1132 GLRenderbuffer *rbo,
1133 GLenum rboFormat,
1134 GLsizei width,
1135 GLsizei height)
1136 {
1137 initColorFBO(fbo, rbo, rboFormat, width, height);
1138
1139 ANGLE_GL_PROGRAM(checkerProgram, essl1_shaders::vs::Passthrough(),
1140 essl1_shaders::fs::Checkered());
1141 glViewport(0, 0, width, height);
1142 glBindFramebuffer(GL_FRAMEBUFFER, *fbo);
1143 drawQuad(checkerProgram.get(), essl1_shaders::PositionAttrib(), 0.5f);
1144 }
1145 };
1146
1147 // Tests resolving a multisample depth buffer.
TEST_P(BlitFramebufferTest,MultisampleDepth)1148 TEST_P(BlitFramebufferTest, MultisampleDepth)
1149 {
1150 // TODO(oetuaho@nvidia.com): http://crbug.com/837717
1151 ANGLE_SKIP_TEST_IF(IsOpenGL() && IsOSX());
1152
1153 GLRenderbuffer renderbuf;
1154 glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get());
1155 glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_DEPTH_COMPONENT24, 256, 256);
1156
1157 GLFramebuffer framebuffer;
1158 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
1159 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
1160 renderbuf.get());
1161
1162 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
1163
1164 glClearDepthf(0.5f);
1165 glClear(GL_DEPTH_BUFFER_BIT);
1166
1167 GLRenderbuffer destRenderbuf;
1168 glBindRenderbuffer(GL_RENDERBUFFER, destRenderbuf.get());
1169 glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, 256, 256);
1170
1171 GLFramebuffer resolved;
1172 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolved.get());
1173 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
1174 destRenderbuf.get());
1175
1176 glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer.get());
1177 glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
1178
1179 glBindFramebuffer(GL_FRAMEBUFFER, resolved.get());
1180
1181 GLTexture colorbuf;
1182 glBindTexture(GL_TEXTURE_2D, colorbuf.get());
1183 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 256, 256);
1184 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuf.get(), 0);
1185
1186 ASSERT_GL_NO_ERROR();
1187
1188 // Clear to green
1189 glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
1190 glClear(GL_COLOR_BUFFER_BIT);
1191 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
1192
1193 // Make sure resulting depth is near 0.5f.
1194 ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red());
1195 glEnable(GL_DEPTH_TEST);
1196 glDepthMask(false);
1197 glDepthFunc(GL_LESS);
1198 drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), -0.01f);
1199 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
1200 EXPECT_PIXEL_COLOR_EQ(255, 0, GLColor::red);
1201 EXPECT_PIXEL_COLOR_EQ(0, 255, GLColor::red);
1202 EXPECT_PIXEL_COLOR_EQ(255, 255, GLColor::red);
1203 EXPECT_PIXEL_COLOR_EQ(127, 127, GLColor::red);
1204
1205 ANGLE_GL_PROGRAM(drawBlue, essl3_shaders::vs::Simple(), essl3_shaders::fs::Blue());
1206 glEnable(GL_DEPTH_TEST);
1207 glDepthMask(false);
1208 glDepthFunc(GL_GREATER);
1209 drawQuad(drawBlue.get(), essl3_shaders::PositionAttrib(), 0.01f);
1210 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue);
1211 EXPECT_PIXEL_COLOR_EQ(255, 0, GLColor::blue);
1212 EXPECT_PIXEL_COLOR_EQ(0, 255, GLColor::blue);
1213 EXPECT_PIXEL_COLOR_EQ(255, 255, GLColor::blue);
1214 EXPECT_PIXEL_COLOR_EQ(127, 127, GLColor::blue);
1215
1216 ASSERT_GL_NO_ERROR();
1217 }
1218
1219 // Tests clearing a multisampled depth buffer.
TEST_P(BlitFramebufferTest,MultisampleDepthClear)1220 TEST_P(BlitFramebufferTest, MultisampleDepthClear)
1221 {
1222 // clearDepth && !maskDepth fails on Intel Ubuntu 19.04 Mesa 19.0.2 GL. http://anglebug.com/3614
1223 ANGLE_SKIP_TEST_IF(IsLinux() && IsIntel() && IsDesktopOpenGL());
1224
1225 // http://anglebug.com/4092
1226 ANGLE_SKIP_TEST_IF(IsAndroid() && IsOpenGLES());
1227
1228 GLRenderbuffer depthMS;
1229 glBindRenderbuffer(GL_RENDERBUFFER, depthMS.get());
1230 glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_DEPTH_COMPONENT24, 256, 256);
1231
1232 GLRenderbuffer colorMS;
1233 glBindRenderbuffer(GL_RENDERBUFFER, colorMS.get());
1234 glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_RGBA8, 256, 256);
1235
1236 GLRenderbuffer colorResolved;
1237 glBindRenderbuffer(GL_RENDERBUFFER, colorResolved.get());
1238 glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 256, 256);
1239
1240 GLFramebuffer framebufferMS;
1241 glBindFramebuffer(GL_FRAMEBUFFER, framebufferMS.get());
1242 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthMS.get());
1243 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorMS.get());
1244
1245 // Clear depth buffer to 0.5 and color to green.
1246 glClearDepthf(0.5f);
1247 glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
1248 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
1249
1250 glFlush();
1251
1252 // Draw red into the multisampled color buffer.
1253 ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red());
1254 glEnable(GL_DEPTH_TEST);
1255 glDepthFunc(GL_EQUAL);
1256 drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.0f);
1257
1258 // Resolve the color buffer to make sure the above draw worked correctly, which in turn implies
1259 // that the multisampled depth clear worked.
1260 GLFramebuffer framebufferResolved;
1261 glBindFramebuffer(GL_FRAMEBUFFER, framebufferResolved.get());
1262 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
1263 colorResolved.get());
1264 glBindFramebuffer(GL_READ_FRAMEBUFFER, framebufferMS.get());
1265 glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1266
1267 glBindFramebuffer(GL_FRAMEBUFFER, framebufferResolved.get());
1268
1269 ASSERT_GL_NO_ERROR();
1270
1271 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
1272 EXPECT_PIXEL_COLOR_EQ(255, 0, GLColor::red);
1273 EXPECT_PIXEL_COLOR_EQ(0, 255, GLColor::red);
1274 EXPECT_PIXEL_COLOR_EQ(255, 255, GLColor::red);
1275 EXPECT_PIXEL_COLOR_EQ(127, 127, GLColor::red);
1276
1277 ASSERT_GL_NO_ERROR();
1278 }
1279
1280 // Test resolving a multisampled stencil buffer.
TEST_P(BlitFramebufferTest,MultisampleStencil)1281 TEST_P(BlitFramebufferTest, MultisampleStencil)
1282 {
1283 // Incorrect rendering results seen on AMD Windows OpenGL. http://anglebug.com/2486
1284 ANGLE_SKIP_TEST_IF(IsAMD() && IsOpenGL() && IsWindows());
1285
1286 GLRenderbuffer renderbuf;
1287 glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get());
1288 glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_STENCIL_INDEX8, 256, 256);
1289
1290 ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red());
1291
1292 GLFramebuffer framebuffer;
1293 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
1294 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
1295 renderbuf.get());
1296
1297 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
1298
1299 // fill the stencil buffer with 0x1
1300 glStencilFunc(GL_ALWAYS, 0x1, 0xFF);
1301 glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
1302 glEnable(GL_STENCIL_TEST);
1303 drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f);
1304
1305 GLTexture destColorbuf;
1306 glBindTexture(GL_TEXTURE_2D, destColorbuf.get());
1307 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 256, 256);
1308
1309 GLRenderbuffer destRenderbuf;
1310 glBindRenderbuffer(GL_RENDERBUFFER, destRenderbuf.get());
1311 glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 256, 256);
1312
1313 GLFramebuffer resolved;
1314 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolved.get());
1315 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
1316 destColorbuf.get(), 0);
1317 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
1318 destRenderbuf.get());
1319
1320 glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer.get());
1321 glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
1322
1323 glBindFramebuffer(GL_FRAMEBUFFER, resolved.get());
1324
1325 ASSERT_GL_NO_ERROR();
1326
1327 // Clear to green
1328 glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
1329 glClear(GL_COLOR_BUFFER_BIT);
1330 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
1331
1332 // Draw red if the stencil is 0x1, which should be true after the resolve.
1333 glStencilFunc(GL_EQUAL, 0x1, 0xFF);
1334 drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f);
1335 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
1336
1337 ASSERT_GL_NO_ERROR();
1338 }
1339
1340 // Test resolving a multisampled stencil buffer with scissor.
TEST_P(BlitFramebufferTest,ScissoredMultisampleStencil)1341 TEST_P(BlitFramebufferTest, ScissoredMultisampleStencil)
1342 {
1343 // Incorrect rendering results seen on AMD Windows OpenGL. http://anglebug.com/2486
1344 ANGLE_SKIP_TEST_IF(IsAMD() && IsOpenGL() && IsWindows());
1345
1346 // Fails verifying that the middle pixel is red. http://anglebug.com/3496
1347 ANGLE_SKIP_TEST_IF((IsIntel() || IsAMD()) && IsOSX());
1348
1349 constexpr GLuint kSize = 256;
1350
1351 // Create the resolve framebuffer.
1352 GLTexture destColorbuf;
1353 glBindTexture(GL_TEXTURE_2D, destColorbuf.get());
1354 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, kSize, kSize);
1355
1356 GLRenderbuffer destRenderbuf;
1357 glBindRenderbuffer(GL_RENDERBUFFER, destRenderbuf.get());
1358 glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, kSize, kSize);
1359
1360 GLFramebuffer resolved;
1361 glBindFramebuffer(GL_FRAMEBUFFER, resolved.get());
1362 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
1363 destColorbuf.get(), 0);
1364 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
1365 destRenderbuf.get());
1366
1367 // Clear the resolved buffer with gray and 0x10 stencil.
1368 GLColor gray(127, 127, 127, 255);
1369 glClearStencil(0x10);
1370 glClearColor(0.499f, 0.499f, 0.499f, 1.0f);
1371 glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1372 EXPECT_PIXEL_COLOR_EQ(0, 0, gray);
1373 EXPECT_PIXEL_COLOR_EQ(kSize / 2, kSize / 2, gray);
1374
1375 // Create the multisampled framebuffer.
1376 GLRenderbuffer renderbuf;
1377 glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get());
1378 glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_STENCIL_INDEX8, kSize, kSize);
1379
1380 ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red());
1381 ANGLE_GL_PROGRAM(drawGreen, essl3_shaders::vs::Simple(), essl3_shaders::fs::Green());
1382 ANGLE_GL_PROGRAM(drawBlue, essl3_shaders::vs::Simple(), essl3_shaders::fs::Blue());
1383
1384 GLFramebuffer framebuffer;
1385 glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get());
1386 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
1387 renderbuf.get());
1388
1389 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
1390
1391 // Fill the stencil buffer with 0x1.
1392 glClearStencil(0x1);
1393 glClear(GL_STENCIL_BUFFER_BIT);
1394
1395 // Fill a smaller region of the buffer with 0x2.
1396 glEnable(GL_SCISSOR_TEST);
1397 glEnable(GL_STENCIL_TEST);
1398 glScissor(kSize / 4, kSize / 4, kSize / 2, kSize / 2);
1399 glStencilFunc(GL_ALWAYS, 0x2, 0xFF);
1400 glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
1401 drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f);
1402
1403 // Blit into the resolved framebuffer (with scissor still enabled).
1404 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolved.get());
1405 glBlitFramebuffer(0, 0, kSize, kSize, 0, 0, kSize, kSize, GL_STENCIL_BUFFER_BIT, GL_NEAREST);
1406
1407 glBindFramebuffer(GL_FRAMEBUFFER, resolved.get());
1408
1409 ASSERT_GL_NO_ERROR();
1410
1411 // Draw blue if the stencil is 0x1, which should never be true.
1412 glDisable(GL_SCISSOR_TEST);
1413 glStencilMask(0);
1414 glStencilFunc(GL_EQUAL, 0x1, 0xFF);
1415 drawQuad(drawBlue.get(), essl3_shaders::PositionAttrib(), 0.5f);
1416 EXPECT_PIXEL_COLOR_EQ(0, 0, gray);
1417 EXPECT_PIXEL_COLOR_EQ(kSize - 1, 0, gray);
1418 EXPECT_PIXEL_COLOR_EQ(0, kSize - 1, gray);
1419 EXPECT_PIXEL_COLOR_EQ(kSize - 1, kSize - 1, gray);
1420 EXPECT_PIXEL_COLOR_EQ(kSize / 2, kSize / 2, gray);
1421
1422 // Draw red if the stencil is 0x2, which should be true in the middle after the blit/resolve.
1423 glStencilFunc(GL_EQUAL, 0x2, 0xFF);
1424 drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f);
1425 EXPECT_PIXEL_COLOR_EQ(0, 0, gray);
1426 EXPECT_PIXEL_COLOR_EQ(kSize - 1, 0, gray);
1427 EXPECT_PIXEL_COLOR_EQ(0, kSize - 1, gray);
1428 EXPECT_PIXEL_COLOR_EQ(kSize - 1, kSize - 1, gray);
1429 EXPECT_PIXEL_COLOR_EQ(kSize / 2, kSize / 2, GLColor::red);
1430
1431 // Draw green if the stencil is 0x10, which should be left untouched in the outer regions.
1432 glStencilFunc(GL_EQUAL, 0x10, 0xFF);
1433 drawQuad(drawGreen.get(), essl3_shaders::PositionAttrib(), 0.5f);
1434 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
1435 EXPECT_PIXEL_COLOR_EQ(kSize - 1, 0, GLColor::green);
1436 EXPECT_PIXEL_COLOR_EQ(0, kSize - 1, GLColor::green);
1437 EXPECT_PIXEL_COLOR_EQ(kSize - 1, kSize - 1, GLColor::green);
1438 EXPECT_PIXEL_COLOR_EQ(kSize / 2, kSize / 2, GLColor::red);
1439
1440 ASSERT_GL_NO_ERROR();
1441 }
1442
1443 // Blit an SRGB framebuffer and scale it.
TEST_P(BlitFramebufferTest,BlitSRGBToRGBAndScale)1444 TEST_P(BlitFramebufferTest, BlitSRGBToRGBAndScale)
1445 {
1446 constexpr const GLsizei kWidth = 256;
1447 constexpr const GLsizei kHeight = 256;
1448
1449 GLRenderbuffer sourceRBO, targetRBO;
1450 GLFramebuffer sourceFBO, targetFBO;
1451 initColorFBOWithCheckerPattern(&sourceFBO, &sourceRBO, GL_SRGB8_ALPHA8, kWidth * 2,
1452 kHeight * 2);
1453 initColorFBO(&targetFBO, &targetRBO, GL_RGBA8, kWidth, kHeight);
1454
1455 EXPECT_GL_NO_ERROR();
1456
1457 glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO);
1458 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO);
1459
1460 glViewport(0, 0, kWidth, kHeight);
1461
1462 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
1463 glClear(GL_COLOR_BUFFER_BIT);
1464
1465 // Scale down without flipping.
1466 glBlitFramebuffer(0, 0, kWidth * 2, kHeight * 2, 0, 0, kWidth, kHeight, GL_COLOR_BUFFER_BIT,
1467 GL_NEAREST);
1468
1469 EXPECT_GL_NO_ERROR();
1470
1471 glBindFramebuffer(GL_FRAMEBUFFER, targetFBO);
1472
1473 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::red);
1474 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::green);
1475 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::red);
1476 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::green);
1477
1478 glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO);
1479 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO);
1480
1481 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
1482 glClear(GL_COLOR_BUFFER_BIT);
1483
1484 // Scale down and flip in the X direction.
1485 glBlitFramebuffer(0, 0, kWidth * 2, kHeight * 2, kWidth, 0, 0, kHeight, GL_COLOR_BUFFER_BIT,
1486 GL_NEAREST);
1487
1488 EXPECT_GL_NO_ERROR();
1489
1490 glBindFramebuffer(GL_FRAMEBUFFER, targetFBO);
1491
1492 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::green);
1493 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::red);
1494 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::green);
1495 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::red);
1496 }
1497
1498 // Blit stencil, with scissor and scale it.
TEST_P(BlitFramebufferTest,BlitStencilScissoredScaled)1499 TEST_P(BlitFramebufferTest, BlitStencilScissoredScaled)
1500 {
1501 constexpr GLint kSize = 256;
1502
1503 // Create the destination framebuffer.
1504 GLTexture destColorbuf;
1505 glBindTexture(GL_TEXTURE_2D, destColorbuf.get());
1506 glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, kSize, kSize);
1507
1508 GLRenderbuffer destRenderbuf;
1509 glBindRenderbuffer(GL_RENDERBUFFER, destRenderbuf.get());
1510 glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, kSize, kSize);
1511
1512 GLFramebuffer destFBO;
1513 glBindFramebuffer(GL_FRAMEBUFFER, destFBO.get());
1514 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
1515 destColorbuf.get(), 0);
1516 glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
1517 destRenderbuf.get());
1518
1519 // Clear the destination buffer with gray and 0x10 stencil.
1520 GLColor gray(127, 127, 127, 255);
1521 glClearStencil(0x10);
1522 glClearColor(0.499f, 0.499f, 0.499f, 1.0f);
1523 glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
1524 EXPECT_PIXEL_COLOR_EQ(0, 0, gray);
1525 EXPECT_PIXEL_COLOR_EQ(kSize / 2, kSize / 2, gray);
1526
1527 // Create the source framebuffer.
1528 GLRenderbuffer renderbuf;
1529 glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get());
1530 glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, kSize, kSize);
1531
1532 ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red());
1533 ANGLE_GL_PROGRAM(drawGreen, essl3_shaders::vs::Simple(), essl3_shaders::fs::Green());
1534 ANGLE_GL_PROGRAM(drawBlue, essl3_shaders::vs::Simple(), essl3_shaders::fs::Blue());
1535
1536 GLFramebuffer sourceFBO;
1537 glBindFramebuffer(GL_FRAMEBUFFER, sourceFBO.get());
1538 glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
1539 renderbuf.get());
1540
1541 ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
1542
1543 // Fill the stencil buffer with 0x1.
1544 glClearStencil(0x1);
1545 glClear(GL_STENCIL_BUFFER_BIT);
1546
1547 // Fill a smaller region of the buffer with 0x2.
1548 glEnable(GL_SCISSOR_TEST);
1549 glEnable(GL_STENCIL_TEST);
1550 glScissor(kSize / 4, kSize / 4, kSize / 2, kSize / 2);
1551 glStencilFunc(GL_ALWAYS, 0x2, 0xFF);
1552 glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
1553 drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f);
1554
1555 // Blit and scale down into the destination framebuffer (with scissor still enabled).
1556 //
1557 // Source looks like this:
1558 //
1559 // +----|----|----|----+
1560 // | |
1561 // | 0x1 |
1562 // - +---------+ -
1563 // | | | |
1564 // | | | |
1565 // - | 0x2 | -
1566 // | | | |
1567 // | | | |
1568 // - +---------+ -
1569 // | |
1570 // | |
1571 // +----|----|----|----+
1572 //
1573 // We want the destination to look like this:
1574 //
1575 // +----|----|----|----+
1576 // | |
1577 // | 0x10 |
1578 // - +---------+ -
1579 // | | 0x1 | |
1580 // | | +------+ |
1581 // - | | | -
1582 // | | | 0x2 | |
1583 // | | | | |
1584 // - +--+------+ -
1585 // | |
1586 // | |
1587 // +----|----|----|----+
1588 //
1589 // The corresponding blit would be: (0, 0, 3/4, 3/4) -> (1/4, 1/4, 3/4, 3/4). For testing, we
1590 // would like to avoid having the destination area and scissor to match. Using destination
1591 // area as (0, 0, 1, 1), and keeping the same scaling, the source area should be
1592 // (-3/8, -3/8, 9/8, 9/8).
1593 //
1594 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, destFBO.get());
1595 constexpr GLint kBlitSrc[2] = {-3 * kSize / 8, 9 * kSize / 8};
1596 glBlitFramebuffer(kBlitSrc[0], kBlitSrc[0], kBlitSrc[1], kBlitSrc[1], 0, 0, kSize, kSize,
1597 GL_STENCIL_BUFFER_BIT, GL_NEAREST);
1598
1599 glBindFramebuffer(GL_FRAMEBUFFER, destFBO.get());
1600
1601 ASSERT_GL_NO_ERROR();
1602
1603 // Draw blue if the stencil is 0x1, which should be true only in the top and left of the inner
1604 // square.
1605 glDisable(GL_SCISSOR_TEST);
1606 glStencilMask(0);
1607 glStencilFunc(GL_EQUAL, 0x1, 0xFF);
1608 drawQuad(drawBlue.get(), essl3_shaders::PositionAttrib(), 0.5f);
1609 EXPECT_PIXEL_COLOR_EQ(0, 0, gray);
1610 EXPECT_PIXEL_COLOR_EQ(kSize - 1, 0, gray);
1611 EXPECT_PIXEL_COLOR_EQ(0, kSize - 1, gray);
1612 EXPECT_PIXEL_COLOR_EQ(kSize - 1, kSize - 1, gray);
1613
1614 EXPECT_PIXEL_COLOR_EQ(kSize / 4, kSize / 4, GLColor::blue);
1615 EXPECT_PIXEL_COLOR_EQ(kSize / 4, 3 * kSize / 4 - 1, GLColor::blue);
1616 EXPECT_PIXEL_COLOR_EQ(3 * kSize / 4 - 1, kSize / 4, GLColor::blue);
1617
1618 EXPECT_PIXEL_COLOR_EQ(kSize / 2, kSize / 2, gray);
1619 EXPECT_PIXEL_COLOR_EQ(3 * kSize / 4 - 1, 3 * kSize / 4 - 1, gray);
1620
1621 // Draw red if the stencil is 0x2, which should be true in the bottom/right of the middle
1622 // square after the blit.
1623 glStencilFunc(GL_EQUAL, 0x2, 0xFF);
1624 drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f);
1625 EXPECT_PIXEL_COLOR_EQ(0, 0, gray);
1626 EXPECT_PIXEL_COLOR_EQ(kSize - 1, 0, gray);
1627 EXPECT_PIXEL_COLOR_EQ(0, kSize - 1, gray);
1628 EXPECT_PIXEL_COLOR_EQ(kSize - 1, kSize - 1, gray);
1629
1630 EXPECT_PIXEL_COLOR_EQ(kSize / 4, kSize / 4, GLColor::blue);
1631 EXPECT_PIXEL_COLOR_EQ(kSize / 4, 3 * kSize / 4 - 1, GLColor::blue);
1632 EXPECT_PIXEL_COLOR_EQ(3 * kSize / 4 - 1, kSize / 4, GLColor::blue);
1633
1634 EXPECT_PIXEL_COLOR_EQ(kSize / 2, kSize / 2, GLColor::red);
1635 EXPECT_PIXEL_COLOR_EQ(3 * kSize / 4 - 1, 3 * kSize / 4 - 1, GLColor::red);
1636
1637 // Draw green if the stencil is 0x10, which should be left untouched in the outer regions.
1638 glStencilFunc(GL_EQUAL, 0x10, 0xFF);
1639 drawQuad(drawGreen.get(), essl3_shaders::PositionAttrib(), 0.5f);
1640 EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
1641 EXPECT_PIXEL_COLOR_EQ(kSize - 1, 0, GLColor::green);
1642 EXPECT_PIXEL_COLOR_EQ(0, kSize - 1, GLColor::green);
1643 EXPECT_PIXEL_COLOR_EQ(kSize - 1, kSize - 1, GLColor::green);
1644
1645 EXPECT_PIXEL_COLOR_EQ(kSize / 4, kSize / 4, GLColor::blue);
1646 EXPECT_PIXEL_COLOR_EQ(kSize / 4, 3 * kSize / 4 - 1, GLColor::blue);
1647 EXPECT_PIXEL_COLOR_EQ(3 * kSize / 4 - 1, kSize / 4, GLColor::blue);
1648
1649 EXPECT_PIXEL_COLOR_EQ(kSize / 2, kSize / 2, GLColor::red);
1650 EXPECT_PIXEL_COLOR_EQ(3 * kSize / 4 - 1, 3 * kSize / 4 - 1, GLColor::red);
1651
1652 ASSERT_GL_NO_ERROR();
1653 }
1654
1655 // Blit a subregion of an SRGB framebuffer to an RGB framebuffer.
TEST_P(BlitFramebufferTest,PartialBlitSRGBToRGB)1656 TEST_P(BlitFramebufferTest, PartialBlitSRGBToRGB)
1657 {
1658 constexpr const GLsizei kWidth = 256;
1659 constexpr const GLsizei kHeight = 256;
1660
1661 GLRenderbuffer sourceRBO, targetRBO;
1662 GLFramebuffer sourceFBO, targetFBO;
1663 initColorFBOWithCheckerPattern(&sourceFBO, &sourceRBO, GL_SRGB8_ALPHA8, kWidth * 2,
1664 kHeight * 2);
1665 initColorFBO(&targetFBO, &targetRBO, GL_RGBA8, kWidth, kHeight);
1666
1667 EXPECT_GL_NO_ERROR();
1668
1669 glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO);
1670 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO);
1671
1672 glViewport(0, 0, kWidth, kHeight);
1673
1674 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
1675 glClear(GL_COLOR_BUFFER_BIT);
1676
1677 // Blit a part of the source FBO without flipping.
1678 glBlitFramebuffer(kWidth, kHeight, kWidth * 2, kHeight * 2, 0, 0, kWidth, kHeight,
1679 GL_COLOR_BUFFER_BIT, GL_NEAREST);
1680
1681 EXPECT_GL_NO_ERROR();
1682
1683 glBindFramebuffer(GL_FRAMEBUFFER, targetFBO);
1684
1685 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::red);
1686 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::red);
1687 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::red);
1688 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::red);
1689
1690 glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO);
1691 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO);
1692
1693 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
1694 glClear(GL_COLOR_BUFFER_BIT);
1695
1696 // Blit a part of the source FBO and flip in the X direction.
1697 glBlitFramebuffer(kWidth * 2, 0, kWidth, kHeight, kWidth, 0, 0, kHeight, GL_COLOR_BUFFER_BIT,
1698 GL_NEAREST);
1699
1700 EXPECT_GL_NO_ERROR();
1701
1702 glBindFramebuffer(GL_FRAMEBUFFER, targetFBO);
1703
1704 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::green);
1705 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::green);
1706 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::green);
1707 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::green);
1708 }
1709
1710 // Blit an SRGB framebuffer with an oversized source area (parts outside the source area should be
1711 // clipped out).
TEST_P(BlitFramebufferTest,BlitSRGBToRGBOversizedSourceArea)1712 TEST_P(BlitFramebufferTest, BlitSRGBToRGBOversizedSourceArea)
1713 {
1714 constexpr const GLsizei kWidth = 256;
1715 constexpr const GLsizei kHeight = 256;
1716
1717 GLRenderbuffer sourceRBO, targetRBO;
1718 GLFramebuffer sourceFBO, targetFBO;
1719 initColorFBOWithCheckerPattern(&sourceFBO, &sourceRBO, GL_SRGB8_ALPHA8, kWidth, kHeight);
1720 initColorFBO(&targetFBO, &targetRBO, GL_RGBA8, kWidth, kHeight);
1721
1722 EXPECT_GL_NO_ERROR();
1723
1724 glViewport(0, 0, kWidth, kHeight);
1725
1726 glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO);
1727 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO);
1728
1729 glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
1730 glClear(GL_COLOR_BUFFER_BIT);
1731
1732 // Blit so that the source area gets placed at the center of the target FBO.
1733 // The width of the source area is 1/4 of the width of the target FBO.
1734 glBlitFramebuffer(-3 * kWidth / 2, -3 * kHeight / 2, 5 * kWidth / 2, 5 * kHeight / 2, 0, 0,
1735 kWidth, kHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1736
1737 EXPECT_GL_NO_ERROR();
1738
1739 glBindFramebuffer(GL_FRAMEBUFFER, targetFBO);
1740
1741 // Source FBO colors can be found in the middle of the target FBO.
1742 EXPECT_PIXEL_COLOR_EQ(7 * kWidth / 16, 7 * kHeight / 16, GLColor::red);
1743 EXPECT_PIXEL_COLOR_EQ(9 * kWidth / 16, 7 * kHeight / 16, GLColor::green);
1744 EXPECT_PIXEL_COLOR_EQ(9 * kWidth / 16, 9 * kHeight / 16, GLColor::red);
1745 EXPECT_PIXEL_COLOR_EQ(7 * kWidth / 16, 9 * kHeight / 16, GLColor::green);
1746
1747 // Clear color should remain around the edges of the target FBO (WebGL 2.0 spec explicitly
1748 // requires this and ANGLE is expected to follow that).
1749 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::blue);
1750 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::blue);
1751 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::blue);
1752 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::blue);
1753 }
1754
1755 // Blit an SRGB framebuffer with an oversized dest area (even though the result is clipped, it
1756 // should be scaled as if the whole dest area was used).
TEST_P(BlitFramebufferTest,BlitSRGBToRGBOversizedDestArea)1757 TEST_P(BlitFramebufferTest, BlitSRGBToRGBOversizedDestArea)
1758 {
1759 constexpr const GLsizei kWidth = 256;
1760 constexpr const GLsizei kHeight = 256;
1761
1762 GLRenderbuffer sourceRBO, targetRBO;
1763 GLFramebuffer sourceFBO, targetFBO;
1764 initColorFBOWithCheckerPattern(&sourceFBO, &sourceRBO, GL_SRGB8_ALPHA8, kWidth, kHeight);
1765 initColorFBO(&targetFBO, &targetRBO, GL_RGBA8, kWidth, kHeight);
1766
1767 EXPECT_GL_NO_ERROR();
1768
1769 glViewport(0, 0, kWidth, kHeight);
1770
1771 glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
1772 glClear(GL_COLOR_BUFFER_BIT);
1773
1774 // Dest is oversized but centered the same as source
1775 glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO);
1776 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO);
1777
1778 glBlitFramebuffer(0, 0, kWidth, kHeight, -kWidth / 2, -kHeight / 2, 3 * kWidth / 2,
1779 3 * kHeight / 2, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1780
1781 EXPECT_GL_NO_ERROR();
1782
1783 glBindFramebuffer(GL_FRAMEBUFFER, targetFBO);
1784
1785 EXPECT_PIXEL_COLOR_EQ(1, 1, GLColor::red);
1786 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::red);
1787 EXPECT_PIXEL_COLOR_EQ(kWidth / 2 - 1, kHeight / 2 - 1, GLColor::red);
1788
1789 EXPECT_PIXEL_COLOR_EQ(1, kWidth - 1, GLColor::green);
1790 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::green);
1791 EXPECT_PIXEL_COLOR_EQ(kWidth / 2 - 1, kHeight / 2 + 1, GLColor::green);
1792
1793 EXPECT_PIXEL_COLOR_EQ(kWidth - 1, 1, GLColor::green);
1794 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::green);
1795 EXPECT_PIXEL_COLOR_EQ(kWidth / 2 + 1, kHeight / 2 - 1, GLColor::green);
1796
1797 EXPECT_PIXEL_COLOR_EQ(kWidth - 1, kHeight - 1, GLColor::red);
1798 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::red);
1799 EXPECT_PIXEL_COLOR_EQ(kWidth / 2 + 1, kHeight / 2 + 1, GLColor::red);
1800
1801 // Dest is oversized in the negative direction
1802 glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO);
1803 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO);
1804
1805 glBlitFramebuffer(0, 0, kWidth, kHeight, -kWidth / 2, -kHeight / 2, kWidth, kHeight,
1806 GL_COLOR_BUFFER_BIT, GL_NEAREST);
1807
1808 EXPECT_GL_NO_ERROR();
1809
1810 glBindFramebuffer(GL_FRAMEBUFFER, targetFBO);
1811
1812 EXPECT_PIXEL_COLOR_EQ(1, 1, GLColor::red);
1813 EXPECT_PIXEL_COLOR_EQ(kWidth / 2 - 1, kHeight / 2 - 1, GLColor::red);
1814
1815 EXPECT_PIXEL_COLOR_EQ(1, kWidth - 1, GLColor::green);
1816 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::red);
1817 EXPECT_PIXEL_COLOR_EQ(kWidth / 2 - 1, kHeight / 2 + 1, GLColor::red);
1818
1819 EXPECT_PIXEL_COLOR_EQ(kWidth - 1, 1, GLColor::green);
1820 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::red);
1821 EXPECT_PIXEL_COLOR_EQ(kWidth / 2 + 1, kHeight / 2 - 1, GLColor::red);
1822
1823 EXPECT_PIXEL_COLOR_EQ(kWidth - 1, kHeight - 1, GLColor::red);
1824 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::red);
1825 EXPECT_PIXEL_COLOR_EQ(kWidth / 2 + 1, kHeight / 2 + 1, GLColor::red);
1826
1827 // Dest is oversized in the positive direction
1828 glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO);
1829 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO);
1830
1831 glBlitFramebuffer(0, 0, kWidth, kHeight, 0, 0, 3 * kWidth / 2, 3 * kHeight / 2,
1832 GL_COLOR_BUFFER_BIT, GL_NEAREST);
1833
1834 EXPECT_GL_NO_ERROR();
1835
1836 glBindFramebuffer(GL_FRAMEBUFFER, targetFBO);
1837
1838 EXPECT_PIXEL_COLOR_EQ(1, 1, GLColor::red);
1839 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::red);
1840 EXPECT_PIXEL_COLOR_EQ(kWidth / 2 - 1, kHeight / 2 - 1, GLColor::red);
1841
1842 EXPECT_PIXEL_COLOR_EQ(1, kWidth - 1, GLColor::green);
1843 EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::green);
1844 EXPECT_PIXEL_COLOR_EQ(kWidth / 2 - 1, kHeight / 2 + 1, GLColor::red);
1845
1846 EXPECT_PIXEL_COLOR_EQ(kWidth - 1, 1, GLColor::green);
1847 EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::green);
1848 EXPECT_PIXEL_COLOR_EQ(kWidth / 2 + 1, kHeight / 2 - 1, GLColor::red);
1849
1850 EXPECT_PIXEL_COLOR_EQ(kWidth - 1, kHeight - 1, GLColor::red);
1851 EXPECT_PIXEL_COLOR_EQ(kWidth / 2 + 1, kHeight / 2 + 1, GLColor::red);
1852 }
1853
1854 // Test blitFramebuffer size overflow checks. WebGL 2.0 spec section 5.41. We do validation for
1855 // overflows also in non-WebGL mode to avoid triggering driver bugs.
TEST_P(BlitFramebufferTest,BlitFramebufferSizeOverflow)1856 TEST_P(BlitFramebufferTest, BlitFramebufferSizeOverflow)
1857 {
1858 GLTexture textures[2];
1859 glBindTexture(GL_TEXTURE_2D, textures[0]);
1860 glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4);
1861 glBindTexture(GL_TEXTURE_2D, textures[1]);
1862 glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4);
1863
1864 GLFramebuffer framebuffers[2];
1865 glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffers[0]);
1866 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffers[1]);
1867
1868 ASSERT_GL_NO_ERROR();
1869
1870 glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0],
1871 0);
1872 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1],
1873 0);
1874 ASSERT_GL_NO_ERROR();
1875
1876 // srcX
1877 glBlitFramebuffer(-1, 0, std::numeric_limits<GLint>::max(), 4, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT,
1878 GL_NEAREST);
1879 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1880 glBlitFramebuffer(std::numeric_limits<GLint>::max(), 0, -1, 4, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT,
1881 GL_NEAREST);
1882 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1883
1884 // srcY
1885 glBlitFramebuffer(0, -1, 4, std::numeric_limits<GLint>::max(), 0, 0, 4, 4, GL_COLOR_BUFFER_BIT,
1886 GL_NEAREST);
1887 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1888 glBlitFramebuffer(0, std::numeric_limits<GLint>::max(), 4, -1, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT,
1889 GL_NEAREST);
1890 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1891
1892 // dstX
1893 glBlitFramebuffer(0, 0, 4, 4, -1, 0, std::numeric_limits<GLint>::max(), 4, GL_COLOR_BUFFER_BIT,
1894 GL_NEAREST);
1895 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1896 glBlitFramebuffer(0, 0, 4, 4, std::numeric_limits<GLint>::max(), 0, -1, 4, GL_COLOR_BUFFER_BIT,
1897 GL_NEAREST);
1898 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1899
1900 // dstY
1901 glBlitFramebuffer(0, 0, 4, 4, 0, -1, 4, std::numeric_limits<GLint>::max(), GL_COLOR_BUFFER_BIT,
1902 GL_NEAREST);
1903 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1904 glBlitFramebuffer(0, 0, 4, 4, 0, std::numeric_limits<GLint>::max(), 4, -1, GL_COLOR_BUFFER_BIT,
1905 GL_NEAREST);
1906 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1907 }
1908
1909 // Test blitFramebuffer size overflow checks. WebGL 2.0 spec section 5.41. Similar to above test,
1910 // but this test more accurately duplicates the behavior of the WebGL test
1911 // conformance2/rendering/blitframebuffer-size-overflow.html, which covers a few more edge cases.
TEST_P(BlitFramebufferTest,BlitFramebufferSizeOverflow2)1912 TEST_P(BlitFramebufferTest, BlitFramebufferSizeOverflow2)
1913 {
1914 GLTexture textures[2];
1915 glBindTexture(GL_TEXTURE_2D, textures[0]);
1916 glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4);
1917 glBindTexture(GL_TEXTURE_2D, textures[1]);
1918 glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4);
1919
1920 GLFramebuffer framebuffers[2];
1921 glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffers[0]);
1922 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffers[1]);
1923
1924 ASSERT_GL_NO_ERROR();
1925
1926 glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0],
1927 0);
1928 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1],
1929 0);
1930 ASSERT_GL_NO_ERROR();
1931
1932 GLint width = 8;
1933 GLint height = 8;
1934
1935 GLTexture tex0;
1936 glBindTexture(GL_TEXTURE_2D, tex0);
1937 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1938
1939 GLFramebuffer fb0;
1940 glBindFramebuffer(GL_READ_FRAMEBUFFER, fb0);
1941 glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex0, 0);
1942
1943 GLTexture tex1;
1944 glBindTexture(GL_TEXTURE_2D, tex1);
1945 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
1946
1947 GLFramebuffer fb1;
1948 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb1);
1949 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex1, 0);
1950
1951 GLint max = std::numeric_limits<GLint>::max();
1952 // Using max 32-bit integer as blitFramebuffer parameter should succeed.
1953 glBlitFramebuffer(0, 0, max, max, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1954 glBlitFramebuffer(0, 0, width, height, 0, 0, max, max, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1955 glBlitFramebuffer(0, 0, max, max, 0, 0, max, max, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1956 EXPECT_GL_NO_ERROR();
1957
1958 // Using blitFramebuffer parameters where calculated width/height matches max 32-bit integer
1959 // should succeed
1960 glBlitFramebuffer(-1, -1, max - 1, max - 1, 0, 0, width, height, GL_COLOR_BUFFER_BIT,
1961 GL_NEAREST);
1962 glBlitFramebuffer(0, 0, width, height, -1, -1, max - 1, max - 1, GL_COLOR_BUFFER_BIT,
1963 GL_NEAREST);
1964 glBlitFramebuffer(-1, -1, max - 1, max - 1, -1, -1, max - 1, max - 1, GL_COLOR_BUFFER_BIT,
1965 GL_NEAREST);
1966 EXPECT_GL_NO_ERROR();
1967
1968 // Using source width/height greater than max 32-bit integer should fail.
1969 glBlitFramebuffer(-1, -1, max, max, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1970 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1971
1972 // Using source width/height greater than max 32-bit integer should fail.
1973 glBlitFramebuffer(max, max, -1, -1, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1974 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1975
1976 // Using destination width/height greater than max 32-bit integer should fail.
1977 glBlitFramebuffer(0, 0, width, height, -1, -1, max, max, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1978 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1979
1980 // Using destination width/height greater than max 32-bit integer should fail.
1981 glBlitFramebuffer(0, 0, width, height, max, max, -1, -1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1982 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1983
1984 // Using both source and destination width/height greater than max 32-bit integer should fail.
1985 glBlitFramebuffer(-1, -1, max, max, -1, -1, max, max, GL_COLOR_BUFFER_BIT, GL_NEAREST);
1986 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1987
1988 // Using minimum and maximum integers for all boundaries should fail.
1989 glBlitFramebuffer(-max - 1, -max - 1, max, max, -max - 1, -max - 1, max, max,
1990 GL_COLOR_BUFFER_BIT, GL_NEAREST);
1991 EXPECT_GL_ERROR(GL_INVALID_VALUE);
1992 }
1993
1994 // Use this to select which configurations (e.g. which renderer, which GLES major version) these
1995 // tests should be run against.
1996 ANGLE_INSTANTIATE_TEST(BlitFramebufferANGLETest,
1997 ES2_D3D9(),
1998 ES2_D3D11(),
1999 ES2_D3D11_PRESENT_PATH_FAST(),
2000 ES2_OPENGL(),
2001 ES3_OPENGL(),
2002 ES2_VULKAN(),
2003 ES3_VULKAN());
2004
2005 ANGLE_INSTANTIATE_TEST_ES3(BlitFramebufferTest);
2006