Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 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 | |
Corentin Wallez | d3970de | 2015-05-14 11:07:48 -0400 | [diff] [blame] | 7 | #include "test_utils/ANGLETest.h" |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 8 | |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame^] | 9 | #include "test_utils/gl_raii.h" |
| 10 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 11 | using namespace angle; |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 12 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 13 | class BlitFramebufferANGLETest : public ANGLETest |
| 14 | { |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 15 | protected: |
| 16 | BlitFramebufferANGLETest() |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 17 | { |
| 18 | setWindowWidth(256); |
| 19 | setWindowHeight(256); |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 20 | setConfigRedBits(8); |
| 21 | setConfigGreenBits(8); |
| 22 | setConfigBlueBits(8); |
| 23 | setConfigAlphaBits(8); |
| 24 | setConfigDepthBits(24); |
Geoff Lang | 784cc8f | 2015-02-05 09:00:54 -0500 | [diff] [blame] | 25 | setConfigStencilBits(8); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 26 | |
| 27 | mCheckerProgram = 0; |
| 28 | mBlueProgram = 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; |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 52 | |
| 53 | mRGBAColorbuffer = 0; |
| 54 | mRGBAFBO = 0; |
| 55 | |
| 56 | mBGRAMultisampledRenderbuffer = 0; |
| 57 | mBGRAMultisampledFBO = 0; |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | virtual void SetUp() |
| 61 | { |
| 62 | ANGLETest::SetUp(); |
| 63 | |
| 64 | const std::string passthroughVS = SHADER_SOURCE |
| 65 | ( |
| 66 | precision highp float; |
| 67 | attribute vec4 position; |
| 68 | varying vec4 pos; |
| 69 | |
| 70 | void main() |
| 71 | { |
| 72 | gl_Position = position; |
| 73 | pos = position; |
| 74 | } |
| 75 | ); |
| 76 | |
| 77 | const std::string checkeredFS = SHADER_SOURCE |
| 78 | ( |
| 79 | precision highp float; |
| 80 | varying vec4 pos; |
| 81 | |
| 82 | void main() |
| 83 | { |
| 84 | if (pos.x * pos.y > 0.0) |
| 85 | { |
| 86 | gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); |
| 87 | } |
| 88 | else |
| 89 | { |
| 90 | gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); |
| 91 | } |
| 92 | } |
| 93 | ); |
| 94 | |
| 95 | const std::string blueFS = SHADER_SOURCE |
| 96 | ( |
| 97 | precision highp float; |
| 98 | varying vec4 pos; |
| 99 | |
| 100 | void main() |
| 101 | { |
| 102 | gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0); |
| 103 | } |
| 104 | ); |
| 105 | |
Jamie Madill | 5599c8f | 2014-08-26 13:16:39 -0400 | [diff] [blame] | 106 | mCheckerProgram = CompileProgram(passthroughVS, checkeredFS); |
| 107 | mBlueProgram = CompileProgram(passthroughVS, blueFS); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 108 | if (mCheckerProgram == 0 || mBlueProgram == 0) |
| 109 | { |
| 110 | FAIL() << "shader compilation failed."; |
| 111 | } |
| 112 | |
| 113 | EXPECT_GL_NO_ERROR(); |
| 114 | |
| 115 | GLint originalFBO; |
| 116 | glGetIntegerv(GL_FRAMEBUFFER_BINDING, &originalFBO); |
| 117 | if (originalFBO >= 0) |
| 118 | { |
| 119 | mOriginalFBO = (GLuint)originalFBO; |
| 120 | } |
| 121 | |
| 122 | GLenum format = GL_BGRA8_EXT; |
| 123 | |
| 124 | glGenFramebuffers(1, &mUserFBO); |
| 125 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 126 | glGenTextures(1, &mUserColorBuffer); |
| 127 | glGenRenderbuffers(1, &mUserDepthStencilBuffer); |
| 128 | glBindTexture(GL_TEXTURE_2D, mUserColorBuffer); |
| 129 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, format, getWindowWidth(), getWindowHeight()); |
| 130 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mUserColorBuffer, 0); |
| 131 | glBindRenderbuffer(GL_RENDERBUFFER, mUserDepthStencilBuffer); |
| 132 | glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, getWindowWidth(), getWindowHeight()); |
| 133 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mUserDepthStencilBuffer); |
| 134 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mUserDepthStencilBuffer); |
| 135 | |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 136 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 137 | ASSERT_GL_NO_ERROR(); |
| 138 | |
| 139 | glGenFramebuffers(1, &mSmallFBO); |
| 140 | glBindFramebuffer(GL_FRAMEBUFFER, mSmallFBO); |
| 141 | glGenTextures(1, &mSmallColorBuffer); |
| 142 | glGenRenderbuffers(1, &mSmallDepthStencilBuffer); |
| 143 | glBindTexture(GL_TEXTURE_2D, mSmallColorBuffer); |
| 144 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, format, getWindowWidth() / 2, getWindowHeight() / 2); |
| 145 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mSmallColorBuffer, 0); |
| 146 | glBindRenderbuffer(GL_RENDERBUFFER, mSmallDepthStencilBuffer); |
| 147 | glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, getWindowWidth() / 2, getWindowHeight() / 2); |
| 148 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mSmallDepthStencilBuffer); |
| 149 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mSmallDepthStencilBuffer); |
| 150 | |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 151 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 152 | ASSERT_GL_NO_ERROR(); |
| 153 | |
| 154 | glGenFramebuffers(1, &mColorOnlyFBO); |
| 155 | glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO); |
| 156 | glGenTextures(1, &mColorOnlyColorBuffer); |
| 157 | glBindTexture(GL_TEXTURE_2D, mColorOnlyColorBuffer); |
| 158 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, format, getWindowWidth(), getWindowHeight()); |
| 159 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mColorOnlyColorBuffer, 0); |
| 160 | |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 161 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 162 | ASSERT_GL_NO_ERROR(); |
| 163 | |
| 164 | glGenFramebuffers(1, &mDiffFormatFBO); |
| 165 | glBindFramebuffer(GL_FRAMEBUFFER, mDiffFormatFBO); |
| 166 | glGenTextures(1, &mDiffFormatColorBuffer); |
| 167 | glBindTexture(GL_TEXTURE_2D, mDiffFormatColorBuffer); |
| 168 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGB565, getWindowWidth(), getWindowHeight()); |
| 169 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mDiffFormatColorBuffer, 0); |
| 170 | |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 171 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 172 | ASSERT_GL_NO_ERROR(); |
| 173 | |
| 174 | glGenFramebuffers(1, &mDiffSizeFBO); |
| 175 | glBindFramebuffer(GL_FRAMEBUFFER, mDiffSizeFBO); |
| 176 | glGenTextures(1, &mDiffSizeColorBuffer); |
| 177 | glBindTexture(GL_TEXTURE_2D, mDiffSizeColorBuffer); |
| 178 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, format, getWindowWidth()*2, getWindowHeight()*2); |
| 179 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mDiffSizeColorBuffer, 0); |
| 180 | |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 181 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 182 | ASSERT_GL_NO_ERROR(); |
| 183 | |
| 184 | if (extensionEnabled("GL_EXT_draw_buffers")) |
| 185 | { |
| 186 | glGenFramebuffers(1, &mMRTFBO); |
| 187 | glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO); |
| 188 | glGenTextures(1, &mMRTColorBuffer0); |
| 189 | glGenTextures(1, &mMRTColorBuffer1); |
| 190 | glBindTexture(GL_TEXTURE_2D, mMRTColorBuffer0); |
| 191 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, format, getWindowWidth(), getWindowHeight()); |
| 192 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, mMRTColorBuffer0, 0); |
| 193 | glBindTexture(GL_TEXTURE_2D, mMRTColorBuffer1); |
| 194 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, format, getWindowWidth(), getWindowHeight()); |
| 195 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, mMRTColorBuffer1, 0); |
| 196 | |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 197 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 198 | ASSERT_GL_NO_ERROR(); |
| 199 | } |
| 200 | |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 201 | if (extensionEnabled("GL_ANGLE_framebuffer_multisample")) |
| 202 | { |
| 203 | // Test blit between RGBA and multisampled BGRA |
| 204 | glGenTextures(1, &mRGBAColorbuffer); |
| 205 | glBindTexture(GL_TEXTURE_2D, mRGBAColorbuffer); |
| 206 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, GL_RGBA8_OES, getWindowWidth(), getWindowHeight()); |
| 207 | |
| 208 | glGenFramebuffers(1, &mRGBAFBO); |
| 209 | glBindFramebuffer(GL_FRAMEBUFFER, mRGBAFBO); |
| 210 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mRGBAColorbuffer, 0); |
| 211 | |
| 212 | ASSERT_GL_NO_ERROR(); |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 213 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 214 | |
| 215 | glGenRenderbuffers(1, &mBGRAMultisampledRenderbuffer); |
| 216 | glBindRenderbuffer(GL_RENDERBUFFER, mBGRAMultisampledRenderbuffer); |
| 217 | glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, 1, GL_BGRA8_EXT, getWindowWidth(), getWindowHeight()); |
| 218 | |
| 219 | glGenFramebuffers(1, &mBGRAMultisampledFBO); |
| 220 | glBindFramebuffer(GL_FRAMEBUFFER, mBGRAMultisampledFBO); |
| 221 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, mBGRAMultisampledRenderbuffer); |
| 222 | |
| 223 | ASSERT_GL_NO_ERROR(); |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 224 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 225 | } |
| 226 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 227 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 228 | } |
| 229 | |
| 230 | virtual void TearDown() |
| 231 | { |
| 232 | glDeleteProgram(mCheckerProgram); |
| 233 | glDeleteProgram(mBlueProgram); |
| 234 | |
| 235 | glDeleteFramebuffers(1, &mUserFBO); |
| 236 | glDeleteTextures(1, &mUserColorBuffer); |
| 237 | glDeleteRenderbuffers(1, &mUserDepthStencilBuffer); |
| 238 | |
| 239 | glDeleteFramebuffers(1, &mSmallFBO); |
| 240 | glDeleteTextures(1, &mSmallColorBuffer); |
| 241 | glDeleteRenderbuffers(1, &mSmallDepthStencilBuffer); |
| 242 | |
| 243 | glDeleteFramebuffers(1, &mColorOnlyFBO); |
| 244 | glDeleteTextures(1, &mSmallDepthStencilBuffer); |
| 245 | |
| 246 | glDeleteFramebuffers(1, &mDiffFormatFBO); |
| 247 | glDeleteTextures(1, &mDiffFormatColorBuffer); |
| 248 | |
| 249 | glDeleteFramebuffers(1, &mDiffSizeFBO); |
| 250 | glDeleteTextures(1, &mDiffSizeColorBuffer); |
| 251 | |
| 252 | if (extensionEnabled("GL_EXT_draw_buffers")) |
| 253 | { |
| 254 | glDeleteFramebuffers(1, &mMRTFBO); |
| 255 | glDeleteTextures(1, &mMRTColorBuffer0); |
| 256 | glDeleteTextures(1, &mMRTColorBuffer1); |
| 257 | } |
| 258 | |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 259 | if (mRGBAColorbuffer != 0) |
| 260 | { |
| 261 | glDeleteTextures(1, &mRGBAColorbuffer); |
| 262 | } |
| 263 | |
| 264 | if (mRGBAFBO != 0) |
| 265 | { |
| 266 | glDeleteFramebuffers(1, &mBGRAMultisampledFBO); |
| 267 | } |
| 268 | |
| 269 | if (mBGRAMultisampledRenderbuffer != 0) |
| 270 | { |
| 271 | glDeleteRenderbuffers(1, &mBGRAMultisampledRenderbuffer); |
| 272 | } |
| 273 | |
| 274 | if (mBGRAMultisampledFBO != 0) |
| 275 | { |
| 276 | glDeleteFramebuffers(1, &mBGRAMultisampledFBO); |
| 277 | } |
| 278 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 279 | ANGLETest::TearDown(); |
| 280 | } |
| 281 | |
| 282 | GLuint mCheckerProgram; |
| 283 | GLuint mBlueProgram; |
| 284 | |
| 285 | GLuint mOriginalFBO; |
| 286 | |
| 287 | GLuint mUserFBO; |
| 288 | GLuint mUserColorBuffer; |
| 289 | GLuint mUserDepthStencilBuffer; |
| 290 | |
| 291 | GLuint mSmallFBO; |
| 292 | GLuint mSmallColorBuffer; |
| 293 | GLuint mSmallDepthStencilBuffer; |
| 294 | |
| 295 | GLuint mColorOnlyFBO; |
| 296 | GLuint mColorOnlyColorBuffer; |
| 297 | |
| 298 | GLuint mDiffFormatFBO; |
| 299 | GLuint mDiffFormatColorBuffer; |
| 300 | |
| 301 | GLuint mDiffSizeFBO; |
| 302 | GLuint mDiffSizeColorBuffer; |
| 303 | |
| 304 | GLuint mMRTFBO; |
| 305 | GLuint mMRTColorBuffer0; |
| 306 | GLuint mMRTColorBuffer1; |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 307 | |
| 308 | GLuint mRGBAColorbuffer; |
| 309 | GLuint mRGBAFBO; |
| 310 | |
| 311 | GLuint mBGRAMultisampledRenderbuffer; |
| 312 | GLuint mBGRAMultisampledFBO; |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 313 | }; |
| 314 | |
| 315 | // Draw to user-created framebuffer, blit whole-buffer color to original framebuffer. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 316 | TEST_P(BlitFramebufferANGLETest, BlitColorToDefault) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 317 | { |
| 318 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 319 | |
| 320 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 321 | |
| 322 | drawQuad(mCheckerProgram, "position", 0.8f); |
| 323 | |
| 324 | EXPECT_GL_NO_ERROR(); |
| 325 | |
| 326 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 327 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 328 | |
| 329 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 330 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 331 | |
| 332 | EXPECT_GL_NO_ERROR(); |
| 333 | |
| 334 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 335 | |
| 336 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 337 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 338 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 339 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 340 | } |
| 341 | |
| 342 | // Draw to system framebuffer, blit whole-buffer color to user-created framebuffer. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 343 | TEST_P(BlitFramebufferANGLETest, ReverseColorBlit) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 344 | { |
| 345 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 346 | |
| 347 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 348 | |
| 349 | drawQuad(mCheckerProgram, "position", 0.8f); |
| 350 | |
| 351 | EXPECT_GL_NO_ERROR(); |
| 352 | |
| 353 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 354 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO); |
| 355 | |
| 356 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 357 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 358 | |
| 359 | EXPECT_GL_NO_ERROR(); |
| 360 | |
| 361 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 362 | |
| 363 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 364 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 365 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 366 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 367 | } |
| 368 | |
| 369 | // blit from user-created FBO to system framebuffer, with the scissor test enabled. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 370 | TEST_P(BlitFramebufferANGLETest, ScissoredBlit) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 371 | { |
| 372 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 373 | |
| 374 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 375 | |
| 376 | drawQuad(mCheckerProgram, "position", 0.8f); |
| 377 | |
| 378 | EXPECT_GL_NO_ERROR(); |
| 379 | |
| 380 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 381 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 382 | |
| 383 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 384 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 385 | |
| 386 | glScissor(getWindowWidth() / 2, 0, getWindowWidth() / 2, getWindowHeight()); |
| 387 | glEnable(GL_SCISSOR_TEST); |
| 388 | |
| 389 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 390 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 391 | |
| 392 | EXPECT_GL_NO_ERROR(); |
| 393 | |
| 394 | glDisable(GL_SCISSOR_TEST); |
| 395 | |
| 396 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 397 | |
| 398 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255); |
| 399 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 400 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 401 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 255, 255, 255); |
| 402 | } |
| 403 | |
| 404 | // blit from system FBO to user-created framebuffer, with the scissor test enabled. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 405 | TEST_P(BlitFramebufferANGLETest, ReverseScissoredBlit) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 406 | { |
| 407 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 408 | |
| 409 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 410 | |
| 411 | drawQuad(mCheckerProgram, "position", 0.8f); |
| 412 | |
| 413 | EXPECT_GL_NO_ERROR(); |
| 414 | |
| 415 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO); |
| 416 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 417 | |
| 418 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 419 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 420 | |
| 421 | glScissor(getWindowWidth() / 2, 0, getWindowWidth() / 2, getWindowHeight()); |
| 422 | glEnable(GL_SCISSOR_TEST); |
| 423 | |
| 424 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 425 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 426 | |
| 427 | EXPECT_GL_NO_ERROR(); |
| 428 | |
| 429 | glDisable(GL_SCISSOR_TEST); |
| 430 | |
| 431 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 432 | |
| 433 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255); |
| 434 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 435 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 436 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 255, 255, 255); |
| 437 | } |
| 438 | |
| 439 | // blit from user-created FBO to system framebuffer, using region larger than buffer. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 440 | TEST_P(BlitFramebufferANGLETest, OversizedBlit) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 441 | { |
| 442 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 443 | |
| 444 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 445 | |
| 446 | drawQuad(mCheckerProgram, "position", 0.8f); |
| 447 | |
| 448 | EXPECT_GL_NO_ERROR(); |
| 449 | |
| 450 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 451 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 452 | |
| 453 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 454 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 455 | |
| 456 | glBlitFramebufferANGLE(0, 0, getWindowWidth() * 2, getWindowHeight() * 2, 0, 0, getWindowWidth() * 2, getWindowHeight() * 2, |
| 457 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 458 | |
| 459 | EXPECT_GL_NO_ERROR(); |
| 460 | |
| 461 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 462 | |
| 463 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 464 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 465 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 466 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 467 | } |
| 468 | |
| 469 | // blit from system FBO to user-created framebuffer, using region larger than buffer. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 470 | TEST_P(BlitFramebufferANGLETest, ReverseOversizedBlit) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 471 | { |
| 472 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 473 | |
| 474 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 475 | |
| 476 | drawQuad(mCheckerProgram, "position", 0.8f); |
| 477 | |
| 478 | EXPECT_GL_NO_ERROR(); |
| 479 | |
| 480 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO); |
| 481 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 482 | |
| 483 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 484 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 485 | |
| 486 | glBlitFramebufferANGLE(0, 0, getWindowWidth() * 2, getWindowHeight() * 2, 0, 0, getWindowWidth() * 2, getWindowHeight() * 2, |
| 487 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 488 | EXPECT_GL_NO_ERROR(); |
| 489 | |
| 490 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 491 | |
| 492 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 493 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 494 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 495 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 496 | } |
| 497 | |
| 498 | // blit from user-created FBO to system framebuffer, with depth buffer. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 499 | TEST_P(BlitFramebufferANGLETest, BlitWithDepth) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 500 | { |
| 501 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 502 | |
| 503 | glDepthMask(GL_TRUE); |
| 504 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 505 | |
| 506 | glEnable(GL_DEPTH_TEST); |
| 507 | |
| 508 | drawQuad(mCheckerProgram, "position", 0.3f); |
| 509 | |
| 510 | EXPECT_GL_NO_ERROR(); |
| 511 | |
| 512 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 513 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 514 | |
| 515 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 516 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 517 | |
| 518 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 519 | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
| 520 | EXPECT_GL_NO_ERROR(); |
| 521 | |
| 522 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 523 | |
| 524 | // if blit is happening correctly, this quad will not draw, because it is behind the blitted one |
| 525 | drawQuad(mBlueProgram, "position", 0.8f); |
| 526 | |
| 527 | glDisable(GL_DEPTH_TEST); |
| 528 | |
| 529 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 530 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 531 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 532 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 533 | } |
| 534 | |
| 535 | // blit from system FBO to user-created framebuffer, with depth buffer. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 536 | TEST_P(BlitFramebufferANGLETest, ReverseBlitWithDepth) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 537 | { |
| 538 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 539 | |
| 540 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 541 | |
| 542 | glEnable(GL_DEPTH_TEST); |
| 543 | |
| 544 | drawQuad(mCheckerProgram, "position", 0.3f); |
| 545 | |
| 546 | EXPECT_GL_NO_ERROR(); |
| 547 | |
| 548 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO); |
| 549 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 550 | |
| 551 | glClearColor(1.0f, 1.0f, 1.0f, 1.0f); |
| 552 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 553 | |
| 554 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 555 | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
| 556 | EXPECT_GL_NO_ERROR(); |
| 557 | |
| 558 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 559 | |
| 560 | // if blit is happening correctly, this quad will not draw, because it is behind the blitted one |
| 561 | |
| 562 | drawQuad(mBlueProgram, "position", 0.8f); |
| 563 | |
| 564 | glDisable(GL_DEPTH_TEST); |
| 565 | |
| 566 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 567 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 568 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 569 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 570 | } |
| 571 | |
| 572 | // blit from one region of the system fbo to another-- this should fail. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 573 | TEST_P(BlitFramebufferANGLETest, BlitSameBufferOriginal) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 574 | { |
| 575 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 576 | |
| 577 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 578 | |
| 579 | drawQuad(mCheckerProgram, "position", 0.3f); |
| 580 | |
| 581 | EXPECT_GL_NO_ERROR(); |
| 582 | |
| 583 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight(), getWindowWidth() / 2, 0, getWindowWidth(), getWindowHeight(), |
| 584 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 585 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 586 | } |
| 587 | |
| 588 | // blit from one region of the system fbo to another. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 589 | TEST_P(BlitFramebufferANGLETest, BlitSameBufferUser) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 590 | { |
| 591 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 592 | |
| 593 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 594 | |
| 595 | drawQuad(mCheckerProgram, "position", 0.3f); |
| 596 | |
| 597 | EXPECT_GL_NO_ERROR(); |
| 598 | |
| 599 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight(), getWindowWidth() / 2, 0, getWindowWidth(), getWindowHeight(), |
| 600 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 601 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 602 | } |
| 603 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 604 | TEST_P(BlitFramebufferANGLETest, BlitPartialColor) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 605 | { |
| 606 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 607 | |
| 608 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 609 | |
| 610 | drawQuad(mCheckerProgram, "position", 0.5f); |
| 611 | |
| 612 | EXPECT_GL_NO_ERROR(); |
| 613 | |
| 614 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 615 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 616 | |
| 617 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 618 | glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 619 | |
| 620 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0, getWindowHeight() / 2, getWindowWidth() / 2, getWindowHeight(), |
| 621 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 622 | |
| 623 | EXPECT_GL_NO_ERROR(); |
| 624 | |
| 625 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 626 | |
| 627 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255); |
| 628 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255); |
| 629 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 255, 255, 255); |
| 630 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 631 | } |
| 632 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 633 | TEST_P(BlitFramebufferANGLETest, BlitDifferentSizes) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 634 | { |
| 635 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 636 | |
| 637 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 638 | |
| 639 | drawQuad(mCheckerProgram, "position", 0.5f); |
| 640 | |
| 641 | EXPECT_GL_NO_ERROR(); |
| 642 | |
| 643 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mSmallFBO); |
| 644 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 645 | |
| 646 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 647 | glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 648 | |
| 649 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 650 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 651 | |
| 652 | EXPECT_GL_NO_ERROR(); |
| 653 | |
| 654 | glBindFramebuffer(GL_FRAMEBUFFER, mSmallFBO); |
| 655 | |
| 656 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 657 | |
| 658 | EXPECT_GL_NO_ERROR(); |
| 659 | } |
| 660 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 661 | TEST_P(BlitFramebufferANGLETest, BlitWithMissingAttachments) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 662 | { |
| 663 | glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO); |
| 664 | |
| 665 | glClear(GL_COLOR_BUFFER_BIT); |
| 666 | drawQuad(mCheckerProgram, "position", 0.3f); |
| 667 | |
| 668 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 669 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mColorOnlyFBO); |
| 670 | |
| 671 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 672 | glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 673 | |
| 674 | // depth blit request should be silently ignored, because the read FBO has no depth attachment |
| 675 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 676 | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
| 677 | |
| 678 | EXPECT_GL_NO_ERROR(); |
| 679 | |
| 680 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 681 | |
| 682 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 683 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 684 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 685 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 686 | |
| 687 | // unlike in the depth blit tests, this *should* draw a blue quad, because depth info |
| 688 | // has not been copied |
| 689 | glEnable(GL_DEPTH_TEST); |
| 690 | drawQuad(mBlueProgram, "position", 0.8f); |
| 691 | glDisable(GL_DEPTH_TEST); |
| 692 | |
| 693 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 0, 0, 255, 255); |
| 694 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 0, 255, 255); |
| 695 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255); |
| 696 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255); |
| 697 | } |
| 698 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 699 | TEST_P(BlitFramebufferANGLETest, BlitStencil) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 700 | { |
Jamie Madill | 8e1936c | 2014-12-03 15:20:12 -0500 | [diff] [blame] | 701 | // TODO(jmadill): Figure out if we can fix this on D3D9. |
| 702 | // https://code.google.com/p/angleproject/issues/detail?id=809 |
Jamie Madill | 518b9fa | 2016-03-02 11:26:02 -0500 | [diff] [blame] | 703 | if (IsIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE) |
Jamie Madill | 8e1936c | 2014-12-03 15:20:12 -0500 | [diff] [blame] | 704 | { |
Jamie Madill | c3b9b26 | 2015-01-30 14:00:51 -0500 | [diff] [blame] | 705 | std::cout << "Test skipped on Intel D3D9." << std::endl; |
Jamie Madill | 8e1936c | 2014-12-03 15:20:12 -0500 | [diff] [blame] | 706 | return; |
| 707 | } |
| 708 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 709 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 710 | |
| 711 | glClear(GL_COLOR_BUFFER_BIT); |
| 712 | // fill the stencil buffer with 0x1 |
| 713 | glStencilFunc(GL_ALWAYS, 0x1, 0xFF); |
| 714 | glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); |
| 715 | glEnable(GL_STENCIL_TEST); |
| 716 | drawQuad(mCheckerProgram, "position", 0.3f); |
| 717 | |
| 718 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 719 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 720 | |
| 721 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 722 | glClearStencil(0x0); |
| 723 | glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 724 | |
| 725 | // depth blit request should be silently ignored, because the read FBO has no depth attachment |
| 726 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 727 | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); |
| 728 | |
| 729 | EXPECT_GL_NO_ERROR(); |
| 730 | |
| 731 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 732 | |
| 733 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 734 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 735 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 736 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 737 | |
| 738 | glStencilFunc(GL_EQUAL, 0x1, 0xFF); // only pass if stencil buffer at pixel reads 0x1 |
| 739 | drawQuad(mBlueProgram, "position", 0.8f); // blue quad will draw if stencil buffer was copied |
| 740 | glDisable(GL_STENCIL_TEST); |
| 741 | |
| 742 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 0, 0, 255, 255); |
| 743 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 0, 255, 255); |
| 744 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255); |
| 745 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255); |
| 746 | } |
| 747 | |
| 748 | // make sure that attempting to blit a partial depth buffer issues an error |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 749 | TEST_P(BlitFramebufferANGLETest, BlitPartialDepthStencil) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 750 | { |
| 751 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 752 | |
| 753 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 754 | |
| 755 | drawQuad(mCheckerProgram, "position", 0.5f); |
| 756 | |
| 757 | EXPECT_GL_NO_ERROR(); |
| 758 | |
| 759 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 760 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 761 | |
| 762 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, |
| 763 | getWindowWidth() / 2, getWindowHeight() / 2, GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
| 764 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 765 | } |
| 766 | |
| 767 | // Test blit with MRT framebuffers |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 768 | TEST_P(BlitFramebufferANGLETest, BlitMRT) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 769 | { |
| 770 | if (!extensionEnabled("GL_EXT_draw_buffers")) |
| 771 | { |
| 772 | return; |
| 773 | } |
| 774 | |
| 775 | GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT }; |
| 776 | |
| 777 | glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO); |
| 778 | glDrawBuffersEXT(2, drawBuffers); |
| 779 | |
| 780 | glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO); |
| 781 | |
| 782 | glClear(GL_COLOR_BUFFER_BIT); |
| 783 | |
| 784 | drawQuad(mCheckerProgram, "position", 0.8f); |
| 785 | |
| 786 | EXPECT_GL_NO_ERROR(); |
| 787 | |
| 788 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mColorOnlyFBO); |
| 789 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mMRTFBO); |
| 790 | |
| 791 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 792 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 793 | |
| 794 | EXPECT_GL_NO_ERROR(); |
| 795 | |
| 796 | glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO); |
| 797 | |
| 798 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 799 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 800 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 801 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 802 | |
| 803 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0); |
| 804 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mMRTColorBuffer0, 0); |
| 805 | |
| 806 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 807 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 808 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 809 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 810 | |
| 811 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mMRTColorBuffer0, 0); |
| 812 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, mMRTColorBuffer1, 0); |
| 813 | } |
| 814 | |
| 815 | // Make sure that attempts to stretch in a blit call issue an error |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 816 | TEST_P(BlitFramebufferANGLETest, ErrorStretching) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 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, 0, 0, |
| 830 | getWindowWidth(), getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 831 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 832 | } |
| 833 | |
| 834 | // Make sure that attempts to flip in a blit call issue an error |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 835 | TEST_P(BlitFramebufferANGLETest, ErrorFlipping) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 836 | { |
| 837 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 838 | |
| 839 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 840 | |
| 841 | drawQuad(mCheckerProgram, "position", 0.5f); |
| 842 | |
| 843 | EXPECT_GL_NO_ERROR(); |
| 844 | |
| 845 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 846 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 847 | |
| 848 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, getWindowWidth() / 2, getWindowHeight() / 2, |
| 849 | 0, 0, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 850 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 851 | } |
| 852 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 853 | TEST_P(BlitFramebufferANGLETest, Errors) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 854 | { |
| 855 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 856 | |
| 857 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 858 | |
| 859 | drawQuad(mCheckerProgram, "position", 0.5f); |
| 860 | |
| 861 | EXPECT_GL_NO_ERROR(); |
| 862 | |
| 863 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 864 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 865 | |
| 866 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 867 | GL_COLOR_BUFFER_BIT, GL_LINEAR); |
| 868 | EXPECT_GL_ERROR(GL_INVALID_ENUM); |
| 869 | |
| 870 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 871 | GL_COLOR_BUFFER_BIT | 234, GL_NEAREST); |
| 872 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 873 | |
| 874 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mDiffFormatFBO); |
| 875 | |
| 876 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 877 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 878 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 879 | |
| 880 | if (extensionEnabled("GL_ANGLE_framebuffer_multisample")) |
| 881 | { |
| 882 | glBindFramebuffer(GL_READ_FRAMEBUFFER, mBGRAMultisampledFBO); |
| 883 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mRGBAFBO); |
| 884 | EXPECT_GL_NO_ERROR(); |
| 885 | |
| 886 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 887 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 888 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 889 | } |
| 890 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 891 | } |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 892 | |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 893 | // TODO(geofflang): Fix the dependence on glBlitFramebufferANGLE without checks and assuming the |
| 894 | // default framebuffer is BGRA to enable the GL and GLES backends. (http://anglebug.com/1289) |
| 895 | |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame^] | 896 | class BlitFramebufferTest : public ANGLETest |
| 897 | { |
| 898 | protected: |
| 899 | BlitFramebufferTest() |
| 900 | { |
| 901 | setWindowWidth(256); |
| 902 | setWindowHeight(256); |
| 903 | setConfigRedBits(8); |
| 904 | setConfigGreenBits(8); |
| 905 | setConfigBlueBits(8); |
| 906 | setConfigAlphaBits(8); |
| 907 | setConfigDepthBits(24); |
| 908 | setConfigStencilBits(8); |
| 909 | } |
| 910 | }; |
| 911 | |
| 912 | // Test resolving a multisampled stencil buffer. |
| 913 | TEST_P(BlitFramebufferTest, MultisampleStencil) |
| 914 | { |
| 915 | GLRenderbuffer renderbuf; |
| 916 | glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get()); |
| 917 | glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_STENCIL_INDEX8, 256, 256); |
| 918 | |
| 919 | const std::string &vertex = |
| 920 | "#version 300 es\n" |
| 921 | "in vec2 position;\n" |
| 922 | "void main() {\n" |
| 923 | " gl_Position = vec4(position, 0.0, 1.0);\n" |
| 924 | "}"; |
| 925 | const std::string &fragment = |
| 926 | "#version 300 es\n" |
| 927 | "out mediump vec4 red;\n" |
| 928 | "void main() {\n" |
| 929 | " red = vec4(1.0, 0.0, 0.0, 1.0);\n" |
| 930 | "}"; |
| 931 | |
| 932 | ANGLE_GL_PROGRAM(drawRed, vertex, fragment); |
| 933 | |
| 934 | GLFramebuffer framebuffer; |
| 935 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get()); |
| 936 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, |
| 937 | renderbuf.get()); |
| 938 | |
| 939 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 940 | |
| 941 | // fill the stencil buffer with 0x1 |
| 942 | glStencilFunc(GL_ALWAYS, 0x1, 0xFF); |
| 943 | glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); |
| 944 | glEnable(GL_STENCIL_TEST); |
| 945 | drawQuad(drawRed.get(), "position", 0.5f); |
| 946 | |
| 947 | GLTexture destColorbuf; |
| 948 | glBindTexture(GL_TEXTURE_2D, destColorbuf.get()); |
| 949 | glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 256, 256); |
| 950 | |
| 951 | GLRenderbuffer destRenderbuf; |
| 952 | glBindRenderbuffer(GL_RENDERBUFFER, destRenderbuf.get()); |
| 953 | glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 256, 256); |
| 954 | |
| 955 | GLFramebuffer resolved; |
| 956 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolved.get()); |
| 957 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 958 | destColorbuf.get(), 0); |
| 959 | glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, |
| 960 | destRenderbuf.get()); |
| 961 | |
| 962 | glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer.get()); |
| 963 | glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_STENCIL_BUFFER_BIT, GL_NEAREST); |
| 964 | |
| 965 | glBindFramebuffer(GL_FRAMEBUFFER, resolved.get()); |
| 966 | |
| 967 | ASSERT_GL_NO_ERROR(); |
| 968 | |
| 969 | // Clear to green |
| 970 | glClearColor(0.0f, 1.0f, 0.0f, 1.0f); |
| 971 | glClear(GL_COLOR_BUFFER_BIT); |
| 972 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 973 | |
| 974 | // Draw red if the stencil is 0x1, which should be true after the blit/resolve. |
| 975 | glStencilFunc(GL_EQUAL, 0x1, 0xFF); |
| 976 | drawQuad(drawRed.get(), "position", 0.5f); |
| 977 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red); |
| 978 | |
| 979 | ASSERT_GL_NO_ERROR(); |
| 980 | } |
| 981 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 982 | // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. |
Austin Kinross | 2a63b3f | 2016-02-08 12:29:08 -0800 | [diff] [blame] | 983 | ANGLE_INSTANTIATE_TEST(BlitFramebufferANGLETest, |
| 984 | ES2_D3D9(), |
| 985 | ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE), |
| 986 | ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE)); |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame^] | 987 | |
| 988 | ANGLE_INSTANTIATE_TEST(BlitFramebufferTest, ES3_D3D11()); |