1#include "ANGLETest.h"
2
3class BlitFramebufferANGLETest : public ANGLETest
4{
5protected:
6    BlitFramebufferANGLETest()
7    {
8        setWindowWidth(256);
9        setWindowHeight(256);
10        setConfigRedBits(8);
11        setConfigGreenBits(8);
12        setConfigBlueBits(8);
13        setConfigAlphaBits(8);
14        setConfigDepthBits(24);
15
16        mCheckerProgram = 0;
17        mBlueProgram = 0;
18
19        mOriginalFBO = 0;
20
21        mUserFBO = 0;
22        mUserColorBuffer = 0;
23        mUserDepthStencilBuffer = 0;
24
25        mSmallFBO = 0;
26        mSmallColorBuffer = 0;
27        mSmallDepthStencilBuffer = 0;
28
29        mColorOnlyFBO = 0;
30        mColorOnlyColorBuffer = 0;
31
32        mDiffFormatFBO = 0;
33        mDiffFormatColorBuffer = 0;
34
35        mDiffSizeFBO = 0;
36        mDiffSizeColorBuffer = 0;
37
38        mMRTFBO = 0;
39        mMRTColorBuffer0 = 0;
40        mMRTColorBuffer1 = 0;
41
42        mRGBAColorbuffer = 0;
43        mRGBAFBO = 0;
44
45        mBGRAMultisampledRenderbuffer = 0;
46        mBGRAMultisampledFBO = 0;
47    }
48
49    virtual void SetUp()
50    {
51        ANGLETest::SetUp();
52
53        const std::string passthroughVS = SHADER_SOURCE
54        (
55            precision highp float;
56            attribute vec4 position;
57            varying vec4 pos;
58
59            void main()
60            {
61                gl_Position = position;
62                pos = position;
63            }
64        );
65
66        const std::string checkeredFS = SHADER_SOURCE
67        (
68            precision highp float;
69            varying vec4 pos;
70
71            void main()
72            {
73                if (pos.x * pos.y > 0.0)
74                {
75                    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
76                }
77                else
78                {
79                    gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
80                }
81            }
82        );
83
84        const std::string blueFS = SHADER_SOURCE
85        (
86            precision highp float;
87            varying vec4 pos;
88
89            void main()
90            {
91                gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);
92            }
93        );
94
95        mCheckerProgram = compileProgram(passthroughVS, checkeredFS);
96        mBlueProgram = compileProgram(passthroughVS, blueFS);
97        if (mCheckerProgram == 0 || mBlueProgram == 0)
98        {
99            FAIL() << "shader compilation failed.";
100        }
101
102        EXPECT_GL_NO_ERROR();
103
104        GLint originalFBO;
105        glGetIntegerv(GL_FRAMEBUFFER_BINDING, &originalFBO);
106        if (originalFBO >= 0)
107        {
108            mOriginalFBO = (GLuint)originalFBO;
109        }
110
111        GLenum format = GL_BGRA8_EXT;
112
113        glGenFramebuffers(1, &mUserFBO);
114        glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
115        glGenTextures(1, &mUserColorBuffer);
116        glGenRenderbuffers(1, &mUserDepthStencilBuffer);
117        glBindTexture(GL_TEXTURE_2D, mUserColorBuffer);
118        glTexStorage2DEXT(GL_TEXTURE_2D, 1, format, getWindowWidth(), getWindowHeight());
119        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mUserColorBuffer, 0);
120        glBindRenderbuffer(GL_RENDERBUFFER, mUserDepthStencilBuffer);
121        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, getWindowWidth(), getWindowHeight());
122        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mUserDepthStencilBuffer);
123        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mUserDepthStencilBuffer);
124
125        ASSERT_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
126        ASSERT_GL_NO_ERROR();
127
128        glGenFramebuffers(1, &mSmallFBO);
129        glBindFramebuffer(GL_FRAMEBUFFER, mSmallFBO);
130        glGenTextures(1, &mSmallColorBuffer);
131        glGenRenderbuffers(1, &mSmallDepthStencilBuffer);
132        glBindTexture(GL_TEXTURE_2D, mSmallColorBuffer);
133        glTexStorage2DEXT(GL_TEXTURE_2D, 1, format, getWindowWidth() / 2, getWindowHeight() / 2);
134        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mSmallColorBuffer, 0);
135        glBindRenderbuffer(GL_RENDERBUFFER, mSmallDepthStencilBuffer);
136        glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, getWindowWidth() / 2, getWindowHeight() / 2);
137        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mSmallDepthStencilBuffer);
138        glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mSmallDepthStencilBuffer);
139
140        ASSERT_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
141        ASSERT_GL_NO_ERROR();
142
143        glGenFramebuffers(1, &mColorOnlyFBO);
144        glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO);
145        glGenTextures(1, &mColorOnlyColorBuffer);
146        glBindTexture(GL_TEXTURE_2D, mColorOnlyColorBuffer);
147        glTexStorage2DEXT(GL_TEXTURE_2D, 1, format, getWindowWidth(), getWindowHeight());
148        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mColorOnlyColorBuffer, 0);
149
150        ASSERT_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
151        ASSERT_GL_NO_ERROR();
152
153        glGenFramebuffers(1, &mDiffFormatFBO);
154        glBindFramebuffer(GL_FRAMEBUFFER, mDiffFormatFBO);
155        glGenTextures(1, &mDiffFormatColorBuffer);
156        glBindTexture(GL_TEXTURE_2D, mDiffFormatColorBuffer);
157        glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGB565, getWindowWidth(), getWindowHeight());
158        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mDiffFormatColorBuffer, 0);
159
160        ASSERT_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
161        ASSERT_GL_NO_ERROR();
162
163        glGenFramebuffers(1, &mDiffSizeFBO);
164        glBindFramebuffer(GL_FRAMEBUFFER, mDiffSizeFBO);
165        glGenTextures(1, &mDiffSizeColorBuffer);
166        glBindTexture(GL_TEXTURE_2D, mDiffSizeColorBuffer);
167        glTexStorage2DEXT(GL_TEXTURE_2D, 1, format, getWindowWidth()*2, getWindowHeight()*2);
168        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mDiffSizeColorBuffer, 0);
169
170        ASSERT_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
171        ASSERT_GL_NO_ERROR();
172
173        if (extensionEnabled("GL_EXT_draw_buffers"))
174        {
175            glGenFramebuffers(1, &mMRTFBO);
176            glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO);
177            glGenTextures(1, &mMRTColorBuffer0);
178            glGenTextures(1, &mMRTColorBuffer1);
179            glBindTexture(GL_TEXTURE_2D, mMRTColorBuffer0);
180            glTexStorage2DEXT(GL_TEXTURE_2D, 1, format, getWindowWidth(), getWindowHeight());
181            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, mMRTColorBuffer0, 0);
182            glBindTexture(GL_TEXTURE_2D, mMRTColorBuffer1);
183            glTexStorage2DEXT(GL_TEXTURE_2D, 1, format, getWindowWidth(), getWindowHeight());
184            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, mMRTColorBuffer1, 0);
185
186            ASSERT_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
187            ASSERT_GL_NO_ERROR();
188        }
189
190        if (extensionEnabled("GL_ANGLE_framebuffer_multisample"))
191        {
192            // Test blit between RGBA and multisampled BGRA
193            glGenTextures(1, &mRGBAColorbuffer);
194            glBindTexture(GL_TEXTURE_2D, mRGBAColorbuffer);
195            glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, getWindowWidth(), getWindowHeight());
196
197            glGenFramebuffers(1, &mRGBAFBO);
198            glBindFramebuffer(GL_FRAMEBUFFER, mRGBAFBO);
199            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mRGBAColorbuffer, 0);
200
201            ASSERT_GL_NO_ERROR();
202            ASSERT_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
203
204            glGenRenderbuffers(1, &mBGRAMultisampledRenderbuffer);
205            glBindRenderbuffer(GL_RENDERBUFFER, mBGRAMultisampledRenderbuffer);
206            glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, 1, GL_BGRA8_EXT, getWindowWidth(), getWindowHeight());
207
208            glGenFramebuffers(1, &mBGRAMultisampledFBO);
209            glBindFramebuffer(GL_FRAMEBUFFER, mBGRAMultisampledFBO);
210            glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, mBGRAMultisampledRenderbuffer);
211
212            ASSERT_GL_NO_ERROR();
213            ASSERT_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
214        }
215
216        glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
217    }
218
219    virtual void TearDown()
220    {
221        glDeleteProgram(mCheckerProgram);
222        glDeleteProgram(mBlueProgram);
223
224        glDeleteFramebuffers(1, &mUserFBO);
225        glDeleteTextures(1, &mUserColorBuffer);
226        glDeleteRenderbuffers(1, &mUserDepthStencilBuffer);
227
228        glDeleteFramebuffers(1, &mSmallFBO);
229        glDeleteTextures(1, &mSmallColorBuffer);
230        glDeleteRenderbuffers(1, &mSmallDepthStencilBuffer);
231
232        glDeleteFramebuffers(1, &mColorOnlyFBO);
233        glDeleteTextures(1, &mSmallDepthStencilBuffer);
234
235        glDeleteFramebuffers(1, &mDiffFormatFBO);
236        glDeleteTextures(1, &mDiffFormatColorBuffer);
237
238        glDeleteFramebuffers(1, &mDiffSizeFBO);
239        glDeleteTextures(1, &mDiffSizeColorBuffer);
240
241        if (extensionEnabled("GL_EXT_draw_buffers"))
242        {
243            glDeleteFramebuffers(1, &mMRTFBO);
244            glDeleteTextures(1, &mMRTColorBuffer0);
245            glDeleteTextures(1, &mMRTColorBuffer1);
246        }
247
248        if (mRGBAColorbuffer != 0)
249        {
250            glDeleteTextures(1, &mRGBAColorbuffer);
251        }
252
253        if (mRGBAFBO != 0)
254        {
255            glDeleteFramebuffers(1, &mBGRAMultisampledFBO);
256        }
257
258        if (mBGRAMultisampledRenderbuffer != 0)
259        {
260            glDeleteRenderbuffers(1, &mBGRAMultisampledRenderbuffer);
261        }
262
263        if (mBGRAMultisampledFBO != 0)
264        {
265            glDeleteFramebuffers(1, &mBGRAMultisampledFBO);
266        }
267
268        ANGLETest::TearDown();
269    }
270
271    GLuint mCheckerProgram;
272    GLuint mBlueProgram;
273
274    GLuint mOriginalFBO;
275
276    GLuint mUserFBO;
277    GLuint mUserColorBuffer;
278    GLuint mUserDepthStencilBuffer;
279
280    GLuint mSmallFBO;
281    GLuint mSmallColorBuffer;
282    GLuint mSmallDepthStencilBuffer;
283
284    GLuint mColorOnlyFBO;
285    GLuint mColorOnlyColorBuffer;
286
287    GLuint mDiffFormatFBO;
288    GLuint mDiffFormatColorBuffer;
289
290    GLuint mDiffSizeFBO;
291    GLuint mDiffSizeColorBuffer;
292
293    GLuint mMRTFBO;
294    GLuint mMRTColorBuffer0;
295    GLuint mMRTColorBuffer1;
296
297    GLuint mRGBAColorbuffer;
298    GLuint mRGBAFBO;
299
300    GLuint mBGRAMultisampledRenderbuffer;
301    GLuint mBGRAMultisampledFBO;
302};
303
304// Draw to user-created framebuffer, blit whole-buffer color to original framebuffer.
305TEST_F(BlitFramebufferANGLETest, blit_color_to_default)
306{
307    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
308
309    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
310
311    drawQuad(mCheckerProgram, "position", 0.8f);
312
313    EXPECT_GL_NO_ERROR();
314
315    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
316    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
317
318    glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
319                           GL_COLOR_BUFFER_BIT, GL_NEAREST);
320
321    EXPECT_GL_NO_ERROR();
322
323    glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
324
325    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255,   0,   0, 255);
326    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4,     getWindowHeight() / 4,   0, 255,   0, 255);
327    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255,   0,   0, 255);
328    EXPECT_PIXEL_EQ(    getWindowWidth() / 4, 3 * getWindowHeight() / 4,   0, 255,   0, 255);
329}
330
331// Draw to system framebuffer, blit whole-buffer color to user-created framebuffer.
332TEST_F(BlitFramebufferANGLETest, reverse_color_blit)
333{
334    glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
335
336    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
337
338    drawQuad(mCheckerProgram, "position", 0.8f);
339
340    EXPECT_GL_NO_ERROR();
341
342    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO);
343    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO);
344
345    glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
346                           GL_COLOR_BUFFER_BIT, GL_NEAREST);
347
348    EXPECT_GL_NO_ERROR();
349
350    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
351
352    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255,   0,   0, 255);
353    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4,     getWindowHeight() / 4,   0, 255,   0, 255);
354    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255,   0,   0, 255);
355    EXPECT_PIXEL_EQ(    getWindowWidth() / 4, 3 * getWindowHeight() / 4,   0, 255,   0, 255);
356}
357
358// blit from user-created FBO to system framebuffer, with the scissor test enabled.
359TEST_F(BlitFramebufferANGLETest, scissored_blit)
360{
361    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
362
363    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
364
365    drawQuad(mCheckerProgram, "position", 0.8f);
366
367    EXPECT_GL_NO_ERROR();
368
369    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
370    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
371
372    glClearColor(1.0, 1.0, 1.0, 1.0);
373    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
374
375    glScissor(getWindowWidth() / 2, 0, getWindowWidth() / 2, getWindowHeight());
376    glEnable(GL_SCISSOR_TEST);
377
378    glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
379                           GL_COLOR_BUFFER_BIT, GL_NEAREST);
380
381    EXPECT_GL_NO_ERROR();
382
383    glDisable(GL_SCISSOR_TEST);
384
385    glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
386
387    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255, 255, 255, 255);
388    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4,     getWindowHeight() / 4,   0, 255,   0, 255);
389    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255,   0,   0, 255);
390    EXPECT_PIXEL_EQ(    getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 255, 255, 255);
391}
392
393// blit from system FBO to user-created framebuffer, with the scissor test enabled.
394TEST_F(BlitFramebufferANGLETest, reverse_scissored_blit)
395{
396    glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
397
398    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
399
400    drawQuad(mCheckerProgram, "position", 0.8f);
401
402    EXPECT_GL_NO_ERROR();
403
404    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO);
405    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO);
406
407    glClearColor(1.0, 1.0, 1.0, 1.0);
408    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
409
410    glScissor(getWindowWidth() / 2, 0, getWindowWidth() / 2, getWindowHeight());
411    glEnable(GL_SCISSOR_TEST);
412
413    glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
414                           GL_COLOR_BUFFER_BIT, GL_NEAREST);
415
416    EXPECT_GL_NO_ERROR();
417
418    glDisable(GL_SCISSOR_TEST);
419
420    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
421
422    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255, 255, 255, 255);
423    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4,     getWindowHeight() / 4,   0, 255,   0, 255);
424    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255,   0,   0, 255);
425    EXPECT_PIXEL_EQ(    getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 255, 255, 255);
426}
427
428// blit from user-created FBO to system framebuffer, using region larger than buffer.
429TEST_F(BlitFramebufferANGLETest, oversized_blit)
430{
431    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
432
433    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
434
435    drawQuad(mCheckerProgram, "position", 0.8f);
436
437    EXPECT_GL_NO_ERROR();
438
439    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
440    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
441
442    glClearColor(1.0, 1.0, 1.0, 1.0);
443    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
444
445    glBlitFramebufferANGLE(0, 0, getWindowWidth() * 2, getWindowHeight() * 2, 0, 0, getWindowWidth() * 2, getWindowHeight() * 2,
446                           GL_COLOR_BUFFER_BIT, GL_NEAREST);
447
448    EXPECT_GL_NO_ERROR();
449
450    glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
451
452    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255,   0,   0, 255);
453    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4,     getWindowHeight() / 4,   0, 255,   0, 255);
454    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255,   0,   0, 255);
455    EXPECT_PIXEL_EQ(    getWindowWidth() / 4, 3 * getWindowHeight() / 4,   0, 255,   0, 255);
456}
457
458// blit from system FBO to user-created framebuffer, using region larger than buffer.
459TEST_F(BlitFramebufferANGLETest, reverse_oversized_blit)
460{
461    glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
462
463    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
464
465    drawQuad(mCheckerProgram, "position", 0.8f);
466
467    EXPECT_GL_NO_ERROR();
468
469    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO);
470    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO);
471
472    glClearColor(1.0, 1.0, 1.0, 1.0);
473    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
474
475    glBlitFramebufferANGLE(0, 0, getWindowWidth() * 2, getWindowHeight() * 2, 0, 0, getWindowWidth() * 2, getWindowHeight() * 2,
476                           GL_COLOR_BUFFER_BIT, GL_NEAREST);
477    EXPECT_GL_NO_ERROR();
478
479    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
480
481    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255,   0,   0, 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,   0, 255,   0, 255);
485}
486
487// blit from user-created FBO to system framebuffer, with depth buffer.
488TEST_F(BlitFramebufferANGLETest, blit_with_depth)
489{
490    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
491
492    glDepthMask(GL_TRUE);
493    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
494
495    glEnable(GL_DEPTH_TEST);
496
497    drawQuad(mCheckerProgram, "position", 0.3f);
498
499    EXPECT_GL_NO_ERROR();
500
501    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
502    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
503
504    glClearColor(1.0, 1.0, 1.0, 1.0);
505    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
506
507    glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
508                           GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
509    EXPECT_GL_NO_ERROR();
510
511    glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
512
513    // if blit is happening correctly, this quad will not draw, because it is behind the blitted one
514    drawQuad(mBlueProgram, "position", 0.8f);
515
516    glDisable(GL_DEPTH_TEST);
517
518    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255,   0,   0, 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,   0, 255,   0, 255);
522}
523
524// blit from system FBO to user-created framebuffer, with depth buffer.
525TEST_F(BlitFramebufferANGLETest, reverse_blit_with_depth)
526{
527    glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
528
529    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
530
531    glEnable(GL_DEPTH_TEST);
532
533    drawQuad(mCheckerProgram, "position", 0.3f);
534
535    EXPECT_GL_NO_ERROR();
536
537    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO);
538    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO);
539
540    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
541    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
542
543    glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
544                           GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
545    EXPECT_GL_NO_ERROR();
546
547    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
548
549    // if blit is happening correctly, this quad will not draw, because it is behind the blitted one
550
551    drawQuad(mBlueProgram, "position", 0.8f);
552
553    glDisable(GL_DEPTH_TEST);
554
555    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255,   0,   0, 255);
556    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4,     getWindowHeight() / 4,   0, 255,   0, 255);
557    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255,   0,   0, 255);
558    EXPECT_PIXEL_EQ(    getWindowWidth() / 4, 3 * getWindowHeight() / 4,   0, 255,   0, 255);
559}
560
561// blit from one region of the system fbo to another-- this should fail.
562TEST_F(BlitFramebufferANGLETest, blit_same_buffer_original)
563{
564    glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
565
566    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
567
568    drawQuad(mCheckerProgram, "position", 0.3f);
569
570    EXPECT_GL_NO_ERROR();
571
572    glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight(), getWindowWidth() / 2, 0, getWindowWidth(), getWindowHeight(),
573                           GL_COLOR_BUFFER_BIT, GL_NEAREST);
574    EXPECT_GL_ERROR(GL_INVALID_OPERATION);
575}
576
577// blit from one region of the system fbo to another.
578TEST_F(BlitFramebufferANGLETest, blit_same_buffer_user)
579{
580    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
581
582    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
583
584    drawQuad(mCheckerProgram, "position", 0.3f);
585
586    EXPECT_GL_NO_ERROR();
587
588    glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight(), getWindowWidth() / 2, 0, getWindowWidth(), getWindowHeight(),
589                           GL_COLOR_BUFFER_BIT, GL_NEAREST);
590    EXPECT_GL_ERROR(GL_INVALID_OPERATION);
591}
592
593TEST_F(BlitFramebufferANGLETest, blit_partial_color)
594{
595    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
596
597    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
598
599    drawQuad(mCheckerProgram, "position", 0.5f);
600
601    EXPECT_GL_NO_ERROR();
602
603    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
604    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
605
606    glClearColor(1.0, 1.0, 1.0, 1.0);
607    glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
608
609    glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0, getWindowHeight() / 2, getWindowWidth() / 2, getWindowHeight(),
610                           GL_COLOR_BUFFER_BIT, GL_NEAREST);
611
612    EXPECT_GL_NO_ERROR();
613
614    glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
615
616    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255, 255, 255, 255);
617    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4,     getWindowHeight() / 4, 255, 255, 255, 255);
618    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 255, 255, 255);
619    EXPECT_PIXEL_EQ(    getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255,   0,   0, 255);
620}
621
622TEST_F(BlitFramebufferANGLETest, blit_different_sizes)
623{
624    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
625
626    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
627
628    drawQuad(mCheckerProgram, "position", 0.5f);
629
630    EXPECT_GL_NO_ERROR();
631
632    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mSmallFBO);
633    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
634
635    glClearColor(1.0, 1.0, 1.0, 1.0);
636    glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
637
638    glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
639                           GL_COLOR_BUFFER_BIT, GL_NEAREST);
640
641    EXPECT_GL_NO_ERROR();
642
643    glBindFramebuffer(GL_FRAMEBUFFER, mSmallFBO);
644
645    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255,   0,   0, 255);
646
647    EXPECT_GL_NO_ERROR();
648}
649
650TEST_F(BlitFramebufferANGLETest, blit_with_missing_attachments)
651{
652    glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO);
653
654    glClear(GL_COLOR_BUFFER_BIT);
655    drawQuad(mCheckerProgram, "position", 0.3f);
656
657    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
658    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mColorOnlyFBO);
659
660    glClearColor(1.0, 1.0, 1.0, 1.0);
661    glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
662
663    // depth blit request should be silently ignored, because the read FBO has no depth attachment
664    glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
665                           GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
666
667    EXPECT_GL_NO_ERROR();
668
669    glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
670
671    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255,   0,   0, 255);
672    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4,     getWindowHeight() / 4,   0, 255,   0, 255);
673    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255,   0,   0, 255);
674    EXPECT_PIXEL_EQ(    getWindowWidth() / 4, 3 * getWindowHeight() / 4,   0, 255,   0, 255);
675
676    // unlike in the depth blit tests, this *should* draw a blue quad, because depth info
677    // has not been copied
678    glEnable(GL_DEPTH_TEST);
679    drawQuad(mBlueProgram, "position", 0.8f);
680    glDisable(GL_DEPTH_TEST);
681
682    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4,   0,   0, 255, 255);
683    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4,     getWindowHeight() / 4,   0,   0, 255, 255);
684    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4,   0,   0, 255, 255);
685    EXPECT_PIXEL_EQ(    getWindowWidth() / 4, 3 * getWindowHeight() / 4,   0,   0, 255, 255);
686}
687
688TEST_F(BlitFramebufferANGLETest, blit_stencil)
689{
690    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
691
692    glClear(GL_COLOR_BUFFER_BIT);
693    // fill the stencil buffer with 0x1
694    glStencilFunc(GL_ALWAYS, 0x1, 0xFF);
695    glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
696    glEnable(GL_STENCIL_TEST);
697    drawQuad(mCheckerProgram, "position", 0.3f);
698
699    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
700    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
701
702    glClearColor(1.0, 1.0, 1.0, 1.0);
703    glClearStencil(0x0);
704    glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
705
706    // depth blit request should be silently ignored, because the read FBO has no depth attachment
707    glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
708                           GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
709
710    EXPECT_GL_NO_ERROR();
711
712    glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
713
714    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255,   0,   0, 255);
715    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4,     getWindowHeight() / 4,   0, 255,   0, 255);
716    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255,   0,   0, 255);
717    EXPECT_PIXEL_EQ(    getWindowWidth() / 4, 3 * getWindowHeight() / 4,   0, 255,   0, 255);
718
719    glStencilFunc(GL_EQUAL, 0x1, 0xFF); // only pass if stencil buffer at pixel reads 0x1
720    drawQuad(mBlueProgram, "position", 0.8f); // blue quad will draw if stencil buffer was copied
721    glDisable(GL_STENCIL_TEST);
722
723    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4,   0,   0, 255, 255);
724    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4,     getWindowHeight() / 4,   0,   0, 255, 255);
725    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4,   0,   0, 255, 255);
726    EXPECT_PIXEL_EQ(    getWindowWidth() / 4, 3 * getWindowHeight() / 4,   0,   0, 255, 255);
727}
728
729// make sure that attempting to blit a partial depth buffer issues an error
730TEST_F(BlitFramebufferANGLETest, blit_partial_depth_stencil)
731{
732    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
733
734    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
735
736    drawQuad(mCheckerProgram, "position", 0.5f);
737
738    EXPECT_GL_NO_ERROR();
739
740    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
741    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
742
743    glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0, 0,
744                           getWindowWidth() / 2, getWindowHeight() / 2, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
745    EXPECT_GL_ERROR(GL_INVALID_OPERATION);
746}
747
748// Test blit with MRT framebuffers
749TEST_F(BlitFramebufferANGLETest, blit_mrt)
750{
751    if (!extensionEnabled("GL_EXT_draw_buffers"))
752    {
753        return;
754    }
755
756    GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT };
757
758    glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO);
759    glDrawBuffersEXT(2, drawBuffers);
760
761    glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO);
762
763    glClear(GL_COLOR_BUFFER_BIT);
764
765    drawQuad(mCheckerProgram, "position", 0.8f);
766
767    EXPECT_GL_NO_ERROR();
768
769    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mColorOnlyFBO);
770    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mMRTFBO);
771
772    glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
773                           GL_COLOR_BUFFER_BIT, GL_NEAREST);
774
775    EXPECT_GL_NO_ERROR();
776
777    glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO);
778
779    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255,   0,   0, 255);
780    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4,     getWindowHeight() / 4,   0, 255,   0, 255);
781    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255,   0,   0, 255);
782    EXPECT_PIXEL_EQ(    getWindowWidth() / 4, 3 * getWindowHeight() / 4,   0, 255,   0, 255);
783
784    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0);
785    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mMRTColorBuffer0, 0);
786
787    EXPECT_PIXEL_EQ(    getWindowWidth() / 4,     getWindowHeight() / 4, 255,   0,   0, 255);
788    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4,     getWindowHeight() / 4,   0, 255,   0, 255);
789    EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255,   0,   0, 255);
790    EXPECT_PIXEL_EQ(    getWindowWidth() / 4, 3 * getWindowHeight() / 4,   0, 255,   0, 255);
791
792    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mMRTColorBuffer0, 0);
793    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, mMRTColorBuffer1, 0);
794}
795
796// Make sure that attempts to stretch in a blit call issue an error
797TEST_F(BlitFramebufferANGLETest, error_stretching)
798{
799    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
800
801    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
802
803    drawQuad(mCheckerProgram, "position", 0.5f);
804
805    EXPECT_GL_NO_ERROR();
806
807    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
808    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
809
810    glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0, 0,
811                           getWindowWidth(), getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST);
812    EXPECT_GL_ERROR(GL_INVALID_OPERATION);
813}
814
815// Make sure that attempts to flip in a blit call issue an error
816TEST_F(BlitFramebufferANGLETest, error_flipping)
817{
818    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
819
820    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
821
822    drawQuad(mCheckerProgram, "position", 0.5f);
823
824    EXPECT_GL_NO_ERROR();
825
826    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
827    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
828
829    glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, getWindowWidth() / 2, getWindowHeight() / 2,
830                           0, 0, GL_COLOR_BUFFER_BIT, GL_NEAREST);
831    EXPECT_GL_ERROR(GL_INVALID_OPERATION);
832}
833
834TEST_F(BlitFramebufferANGLETest, errors)
835{
836    glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
837
838    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
839
840    drawQuad(mCheckerProgram, "position", 0.5f);
841
842    EXPECT_GL_NO_ERROR();
843
844    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO);
845    glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO);
846
847    glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
848                           GL_COLOR_BUFFER_BIT, GL_LINEAR);
849    EXPECT_GL_ERROR(GL_INVALID_ENUM);
850
851    glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
852                           GL_COLOR_BUFFER_BIT | 234, GL_NEAREST);
853    EXPECT_GL_ERROR(GL_INVALID_VALUE);
854
855    glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mDiffFormatFBO);
856
857    glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
858                           GL_COLOR_BUFFER_BIT, GL_NEAREST);
859    EXPECT_GL_ERROR(GL_INVALID_OPERATION);
860
861    if (extensionEnabled("GL_ANGLE_framebuffer_multisample"))
862    {
863        glBindFramebuffer(GL_READ_FRAMEBUFFER, mBGRAMultisampledFBO);
864        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mRGBAFBO);
865        EXPECT_GL_NO_ERROR();
866
867        glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(),
868                               GL_COLOR_BUFFER_BIT, GL_NEAREST);
869        EXPECT_GL_ERROR(GL_INVALID_OPERATION);
870    }
871
872}
873