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" |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 8 | #include "test_utils/gl_raii.h" |
| 9 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 10 | using namespace angle; |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 11 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 12 | class BlitFramebufferANGLETest : public ANGLETest |
| 13 | { |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 14 | protected: |
| 15 | BlitFramebufferANGLETest() |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 16 | { |
| 17 | setWindowWidth(256); |
| 18 | setWindowHeight(256); |
Geoff Lang | efc551f | 2013-10-31 10:20:28 -0400 | [diff] [blame] | 19 | setConfigRedBits(8); |
| 20 | setConfigGreenBits(8); |
| 21 | setConfigBlueBits(8); |
| 22 | setConfigAlphaBits(8); |
| 23 | setConfigDepthBits(24); |
Geoff Lang | 784cc8f | 2015-02-05 09:00:54 -0500 | [diff] [blame] | 24 | setConfigStencilBits(8); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 25 | |
| 26 | mCheckerProgram = 0; |
| 27 | mBlueProgram = 0; |
| 28 | |
| 29 | mOriginalFBO = 0; |
| 30 | |
| 31 | mUserFBO = 0; |
| 32 | mUserColorBuffer = 0; |
| 33 | mUserDepthStencilBuffer = 0; |
| 34 | |
| 35 | mSmallFBO = 0; |
| 36 | mSmallColorBuffer = 0; |
| 37 | mSmallDepthStencilBuffer = 0; |
| 38 | |
| 39 | mColorOnlyFBO = 0; |
| 40 | mColorOnlyColorBuffer = 0; |
| 41 | |
| 42 | mDiffFormatFBO = 0; |
| 43 | mDiffFormatColorBuffer = 0; |
| 44 | |
| 45 | mDiffSizeFBO = 0; |
| 46 | mDiffSizeColorBuffer = 0; |
| 47 | |
| 48 | mMRTFBO = 0; |
| 49 | mMRTColorBuffer0 = 0; |
| 50 | mMRTColorBuffer1 = 0; |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 51 | |
| 52 | mRGBAColorbuffer = 0; |
| 53 | mRGBAFBO = 0; |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 54 | mRGBAMultisampledRenderbuffer = 0; |
| 55 | mRGBAMultisampledFBO = 0; |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 56 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 57 | mBGRAColorbuffer = 0; |
| 58 | mBGRAFBO = 0; |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 59 | mBGRAMultisampledRenderbuffer = 0; |
| 60 | mBGRAMultisampledFBO = 0; |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | virtual void SetUp() |
| 64 | { |
| 65 | ANGLETest::SetUp(); |
| 66 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 67 | mCheckerProgram = |
| 68 | CompileProgram(essl1_shaders::vs::Passthrough(), essl1_shaders::fs::Checkered()); |
| 69 | mBlueProgram = CompileProgram(essl1_shaders::vs::Simple(), essl1_shaders::fs::Blue()); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 70 | if (mCheckerProgram == 0 || mBlueProgram == 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 | |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 84 | GLenum format = GL_BGRA_EXT; |
| 85 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 86 | glGenFramebuffers(1, &mUserFBO); |
| 87 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 88 | glGenTextures(1, &mUserColorBuffer); |
| 89 | glGenRenderbuffers(1, &mUserDepthStencilBuffer); |
| 90 | glBindTexture(GL_TEXTURE_2D, mUserColorBuffer); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 91 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mUserColorBuffer, 0); |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 92 | glTexImage2D(GL_TEXTURE_2D, 0, format, getWindowWidth(), getWindowHeight(), 0, format, |
| 93 | GL_UNSIGNED_BYTE, nullptr); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 94 | glBindRenderbuffer(GL_RENDERBUFFER, mUserDepthStencilBuffer); |
| 95 | glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, getWindowWidth(), getWindowHeight()); |
| 96 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mUserDepthStencilBuffer); |
| 97 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mUserDepthStencilBuffer); |
| 98 | |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 99 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 100 | ASSERT_GL_NO_ERROR(); |
| 101 | |
| 102 | glGenFramebuffers(1, &mSmallFBO); |
| 103 | glBindFramebuffer(GL_FRAMEBUFFER, mSmallFBO); |
| 104 | glGenTextures(1, &mSmallColorBuffer); |
| 105 | glGenRenderbuffers(1, &mSmallDepthStencilBuffer); |
| 106 | glBindTexture(GL_TEXTURE_2D, mSmallColorBuffer); |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 107 | glTexImage2D(GL_TEXTURE_2D, 0, format, getWindowWidth() / 2, getWindowHeight() / 2, 0, |
| 108 | format, GL_UNSIGNED_BYTE, nullptr); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 109 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mSmallColorBuffer, 0); |
| 110 | glBindRenderbuffer(GL_RENDERBUFFER, mSmallDepthStencilBuffer); |
| 111 | glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, getWindowWidth() / 2, getWindowHeight() / 2); |
| 112 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, mSmallDepthStencilBuffer); |
| 113 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mSmallDepthStencilBuffer); |
| 114 | |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 115 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 116 | ASSERT_GL_NO_ERROR(); |
| 117 | |
| 118 | glGenFramebuffers(1, &mColorOnlyFBO); |
| 119 | glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO); |
| 120 | glGenTextures(1, &mColorOnlyColorBuffer); |
| 121 | glBindTexture(GL_TEXTURE_2D, mColorOnlyColorBuffer); |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 122 | glTexImage2D(GL_TEXTURE_2D, 0, format, getWindowWidth(), getWindowHeight(), 0, format, |
| 123 | GL_UNSIGNED_BYTE, nullptr); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 124 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mColorOnlyColorBuffer, 0); |
| 125 | |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 126 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 127 | ASSERT_GL_NO_ERROR(); |
| 128 | |
| 129 | glGenFramebuffers(1, &mDiffFormatFBO); |
| 130 | glBindFramebuffer(GL_FRAMEBUFFER, mDiffFormatFBO); |
| 131 | glGenTextures(1, &mDiffFormatColorBuffer); |
| 132 | glBindTexture(GL_TEXTURE_2D, mDiffFormatColorBuffer); |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 133 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, getWindowWidth(), getWindowHeight(), 0, GL_RGB, |
| 134 | GL_UNSIGNED_SHORT_5_6_5, nullptr); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 135 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mDiffFormatColorBuffer, 0); |
| 136 | |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 137 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 138 | ASSERT_GL_NO_ERROR(); |
| 139 | |
| 140 | glGenFramebuffers(1, &mDiffSizeFBO); |
| 141 | glBindFramebuffer(GL_FRAMEBUFFER, mDiffSizeFBO); |
| 142 | glGenTextures(1, &mDiffSizeColorBuffer); |
| 143 | glBindTexture(GL_TEXTURE_2D, mDiffSizeColorBuffer); |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 144 | glTexImage2D(GL_TEXTURE_2D, 0, format, getWindowWidth() * 2, getWindowHeight() * 2, 0, |
| 145 | format, GL_UNSIGNED_BYTE, nullptr); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 146 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mDiffSizeColorBuffer, 0); |
| 147 | |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 148 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 149 | ASSERT_GL_NO_ERROR(); |
| 150 | |
| 151 | if (extensionEnabled("GL_EXT_draw_buffers")) |
| 152 | { |
| 153 | glGenFramebuffers(1, &mMRTFBO); |
| 154 | glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO); |
| 155 | glGenTextures(1, &mMRTColorBuffer0); |
| 156 | glGenTextures(1, &mMRTColorBuffer1); |
| 157 | glBindTexture(GL_TEXTURE_2D, mMRTColorBuffer0); |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 158 | glTexImage2D(GL_TEXTURE_2D, 0, format, getWindowWidth(), getWindowHeight(), 0, format, |
| 159 | GL_UNSIGNED_BYTE, nullptr); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 160 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, mMRTColorBuffer0, 0); |
| 161 | glBindTexture(GL_TEXTURE_2D, mMRTColorBuffer1); |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 162 | glTexImage2D(GL_TEXTURE_2D, 0, format, getWindowWidth(), getWindowHeight(), 0, format, |
| 163 | GL_UNSIGNED_BYTE, nullptr); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 164 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, mMRTColorBuffer1, 0); |
| 165 | |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 166 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 167 | ASSERT_GL_NO_ERROR(); |
| 168 | } |
| 169 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 170 | if (extensionEnabled("GL_ANGLE_framebuffer_multisample") && |
| 171 | extensionEnabled("GL_OES_rgb8_rgba8")) |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 172 | { |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 173 | // RGBA single-sampled framebuffer |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 174 | glGenTextures(1, &mRGBAColorbuffer); |
| 175 | glBindTexture(GL_TEXTURE_2D, mRGBAColorbuffer); |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 176 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA, |
| 177 | GL_UNSIGNED_BYTE, nullptr); |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 178 | |
| 179 | glGenFramebuffers(1, &mRGBAFBO); |
| 180 | glBindFramebuffer(GL_FRAMEBUFFER, mRGBAFBO); |
| 181 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mRGBAColorbuffer, 0); |
| 182 | |
| 183 | ASSERT_GL_NO_ERROR(); |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 184 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 185 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 186 | // RGBA multisampled framebuffer |
| 187 | glGenRenderbuffers(1, &mRGBAMultisampledRenderbuffer); |
| 188 | glBindRenderbuffer(GL_RENDERBUFFER, mRGBAMultisampledRenderbuffer); |
| 189 | glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, 1, GL_RGBA8, getWindowWidth(), |
| 190 | getWindowHeight()); |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 191 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 192 | glGenFramebuffers(1, &mRGBAMultisampledFBO); |
| 193 | glBindFramebuffer(GL_FRAMEBUFFER, mRGBAMultisampledFBO); |
| 194 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, |
| 195 | mRGBAMultisampledRenderbuffer); |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 196 | |
| 197 | ASSERT_GL_NO_ERROR(); |
Corentin Wallez | 322653b | 2015-06-17 18:33:56 +0200 | [diff] [blame] | 198 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 199 | |
| 200 | if (extensionEnabled("GL_EXT_texture_format_BGRA8888")) |
| 201 | { |
| 202 | // BGRA single-sampled framebuffer |
| 203 | glGenTextures(1, &mBGRAColorbuffer); |
| 204 | glBindTexture(GL_TEXTURE_2D, mBGRAColorbuffer); |
| 205 | glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, getWindowWidth(), getWindowHeight(), 0, |
| 206 | GL_BGRA_EXT, GL_UNSIGNED_BYTE, nullptr); |
| 207 | |
| 208 | glGenFramebuffers(1, &mBGRAFBO); |
| 209 | glBindFramebuffer(GL_FRAMEBUFFER, mBGRAFBO); |
| 210 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 211 | mBGRAColorbuffer, 0); |
| 212 | |
| 213 | ASSERT_GL_NO_ERROR(); |
| 214 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 215 | |
| 216 | // BGRA multisampled framebuffer |
| 217 | glGenRenderbuffers(1, &mBGRAMultisampledRenderbuffer); |
| 218 | glBindRenderbuffer(GL_RENDERBUFFER, mBGRAMultisampledRenderbuffer); |
| 219 | glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, 1, GL_BGRA8_EXT, |
| 220 | getWindowWidth(), getWindowHeight()); |
| 221 | |
| 222 | glGenFramebuffers(1, &mBGRAMultisampledFBO); |
| 223 | glBindFramebuffer(GL_FRAMEBUFFER, mBGRAMultisampledFBO); |
| 224 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, |
| 225 | mBGRAMultisampledRenderbuffer); |
| 226 | |
| 227 | ASSERT_GL_NO_ERROR(); |
| 228 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 229 | } |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 230 | } |
| 231 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 232 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 233 | } |
| 234 | |
| 235 | virtual void TearDown() |
| 236 | { |
| 237 | glDeleteProgram(mCheckerProgram); |
| 238 | glDeleteProgram(mBlueProgram); |
| 239 | |
| 240 | glDeleteFramebuffers(1, &mUserFBO); |
| 241 | glDeleteTextures(1, &mUserColorBuffer); |
| 242 | glDeleteRenderbuffers(1, &mUserDepthStencilBuffer); |
| 243 | |
| 244 | glDeleteFramebuffers(1, &mSmallFBO); |
| 245 | glDeleteTextures(1, &mSmallColorBuffer); |
| 246 | glDeleteRenderbuffers(1, &mSmallDepthStencilBuffer); |
| 247 | |
| 248 | glDeleteFramebuffers(1, &mColorOnlyFBO); |
| 249 | glDeleteTextures(1, &mSmallDepthStencilBuffer); |
| 250 | |
| 251 | glDeleteFramebuffers(1, &mDiffFormatFBO); |
| 252 | glDeleteTextures(1, &mDiffFormatColorBuffer); |
| 253 | |
| 254 | glDeleteFramebuffers(1, &mDiffSizeFBO); |
| 255 | glDeleteTextures(1, &mDiffSizeColorBuffer); |
| 256 | |
| 257 | if (extensionEnabled("GL_EXT_draw_buffers")) |
| 258 | { |
| 259 | glDeleteFramebuffers(1, &mMRTFBO); |
| 260 | glDeleteTextures(1, &mMRTColorBuffer0); |
| 261 | glDeleteTextures(1, &mMRTColorBuffer1); |
| 262 | } |
| 263 | |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 264 | if (mRGBAColorbuffer != 0) |
| 265 | { |
| 266 | glDeleteTextures(1, &mRGBAColorbuffer); |
| 267 | } |
| 268 | |
| 269 | if (mRGBAFBO != 0) |
| 270 | { |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 271 | glDeleteFramebuffers(1, &mRGBAFBO); |
| 272 | } |
| 273 | |
| 274 | if (mRGBAMultisampledRenderbuffer != 0) |
| 275 | { |
| 276 | glDeleteRenderbuffers(1, &mRGBAMultisampledRenderbuffer); |
| 277 | } |
| 278 | |
| 279 | if (mRGBAMultisampledFBO != 0) |
| 280 | { |
| 281 | glDeleteFramebuffers(1, &mRGBAMultisampledFBO); |
| 282 | } |
| 283 | |
| 284 | if (mBGRAColorbuffer != 0) |
| 285 | { |
| 286 | glDeleteTextures(1, &mBGRAColorbuffer); |
| 287 | } |
| 288 | |
| 289 | if (mBGRAFBO != 0) |
| 290 | { |
| 291 | glDeleteFramebuffers(1, &mBGRAFBO); |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | if (mBGRAMultisampledRenderbuffer != 0) |
| 295 | { |
| 296 | glDeleteRenderbuffers(1, &mBGRAMultisampledRenderbuffer); |
| 297 | } |
| 298 | |
| 299 | if (mBGRAMultisampledFBO != 0) |
| 300 | { |
| 301 | glDeleteFramebuffers(1, &mBGRAMultisampledFBO); |
| 302 | } |
| 303 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 304 | ANGLETest::TearDown(); |
| 305 | } |
| 306 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 307 | void multisampleTestHelper(GLuint readFramebuffer, GLuint drawFramebuffer) |
| 308 | { |
| 309 | glClearColor(0.0, 1.0, 0.0, 1.0); |
| 310 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, readFramebuffer); |
| 311 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 312 | EXPECT_GL_NO_ERROR(); |
| 313 | |
| 314 | glBindFramebuffer(GL_READ_FRAMEBUFFER, readFramebuffer); |
| 315 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFramebuffer); |
| 316 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), |
| 317 | getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 318 | EXPECT_GL_NO_ERROR(); |
| 319 | |
| 320 | glBindFramebuffer(GL_READ_FRAMEBUFFER, drawFramebuffer); |
| 321 | EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 322 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 323 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 324 | EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 325 | } |
| 326 | |
| 327 | bool checkExtension(const std::string &extension) |
| 328 | { |
| 329 | if (!extensionEnabled(extension)) |
| 330 | { |
| 331 | std::cout << "Test skipped because " << extension << " not supported." << std::endl; |
| 332 | return false; |
| 333 | } |
| 334 | |
| 335 | return true; |
| 336 | } |
| 337 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 338 | GLuint mCheckerProgram; |
| 339 | GLuint mBlueProgram; |
| 340 | |
| 341 | GLuint mOriginalFBO; |
| 342 | |
| 343 | GLuint mUserFBO; |
| 344 | GLuint mUserColorBuffer; |
| 345 | GLuint mUserDepthStencilBuffer; |
| 346 | |
| 347 | GLuint mSmallFBO; |
| 348 | GLuint mSmallColorBuffer; |
| 349 | GLuint mSmallDepthStencilBuffer; |
| 350 | |
| 351 | GLuint mColorOnlyFBO; |
| 352 | GLuint mColorOnlyColorBuffer; |
| 353 | |
| 354 | GLuint mDiffFormatFBO; |
| 355 | GLuint mDiffFormatColorBuffer; |
| 356 | |
| 357 | GLuint mDiffSizeFBO; |
| 358 | GLuint mDiffSizeColorBuffer; |
| 359 | |
| 360 | GLuint mMRTFBO; |
| 361 | GLuint mMRTColorBuffer0; |
| 362 | GLuint mMRTColorBuffer1; |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 363 | |
| 364 | GLuint mRGBAColorbuffer; |
| 365 | GLuint mRGBAFBO; |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 366 | GLuint mRGBAMultisampledRenderbuffer; |
| 367 | GLuint mRGBAMultisampledFBO; |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 368 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 369 | GLuint mBGRAColorbuffer; |
| 370 | GLuint mBGRAFBO; |
Jamie Madill | c93d6f3 | 2014-04-15 16:12:41 -0400 | [diff] [blame] | 371 | GLuint mBGRAMultisampledRenderbuffer; |
| 372 | GLuint mBGRAMultisampledFBO; |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 373 | }; |
| 374 | |
| 375 | // Draw to user-created framebuffer, blit whole-buffer color to original framebuffer. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 376 | TEST_P(BlitFramebufferANGLETest, BlitColorToDefault) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 377 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 378 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 379 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 380 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 381 | |
| 382 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 383 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 384 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 385 | |
| 386 | EXPECT_GL_NO_ERROR(); |
| 387 | |
| 388 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 389 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 390 | |
| 391 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 392 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 393 | |
| 394 | EXPECT_GL_NO_ERROR(); |
| 395 | |
| 396 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 397 | |
| 398 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 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, 0, 255, 0, 255); |
| 402 | } |
| 403 | |
| 404 | // Draw to system framebuffer, blit whole-buffer color to user-created framebuffer. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 405 | TEST_P(BlitFramebufferANGLETest, ReverseColorBlit) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 406 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 407 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 408 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 409 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 410 | |
| 411 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 412 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 413 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 414 | |
| 415 | EXPECT_GL_NO_ERROR(); |
| 416 | |
| 417 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 418 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO); |
| 419 | |
| 420 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 421 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 422 | |
| 423 | EXPECT_GL_NO_ERROR(); |
| 424 | |
| 425 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 426 | |
| 427 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 428 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 429 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 430 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 431 | } |
| 432 | |
| 433 | // 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] | 434 | TEST_P(BlitFramebufferANGLETest, ScissoredBlit) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 435 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 436 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 437 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 438 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 439 | |
| 440 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 441 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 442 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 443 | |
| 444 | EXPECT_GL_NO_ERROR(); |
| 445 | |
| 446 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 447 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 448 | |
| 449 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 450 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 451 | |
| 452 | glScissor(getWindowWidth() / 2, 0, getWindowWidth() / 2, getWindowHeight()); |
| 453 | glEnable(GL_SCISSOR_TEST); |
| 454 | |
| 455 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 456 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 457 | |
| 458 | EXPECT_GL_NO_ERROR(); |
| 459 | |
| 460 | glDisable(GL_SCISSOR_TEST); |
| 461 | |
| 462 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 463 | |
| 464 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255); |
| 465 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 466 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 467 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 255, 255, 255); |
| 468 | } |
| 469 | |
| 470 | // 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] | 471 | TEST_P(BlitFramebufferANGLETest, ReverseScissoredBlit) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 472 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 473 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 474 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 475 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 476 | |
| 477 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 478 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 479 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 480 | |
| 481 | EXPECT_GL_NO_ERROR(); |
| 482 | |
| 483 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO); |
| 484 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 485 | |
| 486 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 487 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 488 | |
| 489 | glScissor(getWindowWidth() / 2, 0, getWindowWidth() / 2, getWindowHeight()); |
| 490 | glEnable(GL_SCISSOR_TEST); |
| 491 | |
| 492 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 493 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 494 | |
| 495 | EXPECT_GL_NO_ERROR(); |
| 496 | |
| 497 | glDisable(GL_SCISSOR_TEST); |
| 498 | |
| 499 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 500 | |
| 501 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255); |
| 502 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 503 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 504 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 255, 255, 255); |
| 505 | } |
| 506 | |
| 507 | // 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] | 508 | TEST_P(BlitFramebufferANGLETest, OversizedBlit) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 509 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 510 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 511 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 512 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 513 | |
| 514 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 515 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 516 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 517 | |
| 518 | EXPECT_GL_NO_ERROR(); |
| 519 | |
| 520 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 521 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 522 | |
| 523 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 524 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 525 | |
| 526 | glBlitFramebufferANGLE(0, 0, getWindowWidth() * 2, getWindowHeight() * 2, 0, 0, getWindowWidth() * 2, getWindowHeight() * 2, |
| 527 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 528 | |
| 529 | EXPECT_GL_NO_ERROR(); |
| 530 | |
| 531 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 532 | |
| 533 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 534 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 535 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 536 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 537 | } |
| 538 | |
| 539 | // 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] | 540 | TEST_P(BlitFramebufferANGLETest, ReverseOversizedBlit) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 541 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 542 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 543 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 544 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 545 | |
| 546 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 547 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 548 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 549 | |
| 550 | EXPECT_GL_NO_ERROR(); |
| 551 | |
| 552 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO); |
| 553 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 554 | |
| 555 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 556 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 557 | |
| 558 | glBlitFramebufferANGLE(0, 0, getWindowWidth() * 2, getWindowHeight() * 2, 0, 0, getWindowWidth() * 2, getWindowHeight() * 2, |
| 559 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 560 | EXPECT_GL_NO_ERROR(); |
| 561 | |
| 562 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 563 | |
| 564 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 565 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 566 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 567 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 568 | } |
| 569 | |
| 570 | // blit from user-created FBO to system framebuffer, with depth buffer. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 571 | TEST_P(BlitFramebufferANGLETest, BlitWithDepth) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 572 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 573 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 574 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 575 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 576 | |
| 577 | glDepthMask(GL_TRUE); |
| 578 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 579 | |
| 580 | glEnable(GL_DEPTH_TEST); |
| 581 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 582 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 583 | |
| 584 | EXPECT_GL_NO_ERROR(); |
| 585 | |
| 586 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 587 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 588 | |
| 589 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 590 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 591 | |
| 592 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 593 | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
| 594 | EXPECT_GL_NO_ERROR(); |
| 595 | |
| 596 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 597 | |
| 598 | // if blit is happening correctly, this quad will not draw, because it is behind the blitted one |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 599 | drawQuad(mBlueProgram, essl1_shaders::PositionAttrib(), 0.8f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 600 | |
| 601 | glDisable(GL_DEPTH_TEST); |
| 602 | |
| 603 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 604 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 605 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 606 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 607 | } |
| 608 | |
| 609 | // blit from system FBO to user-created framebuffer, with depth buffer. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 610 | TEST_P(BlitFramebufferANGLETest, ReverseBlitWithDepth) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 611 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 612 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 613 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 614 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 615 | |
| 616 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 617 | |
| 618 | glEnable(GL_DEPTH_TEST); |
| 619 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 620 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 621 | |
| 622 | EXPECT_GL_NO_ERROR(); |
| 623 | |
| 624 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO); |
| 625 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 626 | |
| 627 | glClearColor(1.0f, 1.0f, 1.0f, 1.0f); |
| 628 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 629 | |
| 630 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 631 | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
| 632 | EXPECT_GL_NO_ERROR(); |
| 633 | |
| 634 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 635 | |
| 636 | // if blit is happening correctly, this quad will not draw, because it is behind the blitted one |
| 637 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 638 | drawQuad(mBlueProgram, essl1_shaders::PositionAttrib(), 0.8f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 639 | |
| 640 | glDisable(GL_DEPTH_TEST); |
| 641 | |
| 642 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 643 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 644 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 645 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 646 | } |
| 647 | |
| 648 | // 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] | 649 | TEST_P(BlitFramebufferANGLETest, BlitSameBufferOriginal) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 650 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 651 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 652 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 653 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 654 | |
| 655 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 656 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 657 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 658 | |
| 659 | EXPECT_GL_NO_ERROR(); |
| 660 | |
| 661 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight(), getWindowWidth() / 2, 0, getWindowWidth(), getWindowHeight(), |
| 662 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 663 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 664 | } |
| 665 | |
| 666 | // blit from one region of the system fbo to another. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 667 | TEST_P(BlitFramebufferANGLETest, BlitSameBufferUser) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 668 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 669 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 670 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 671 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 672 | |
| 673 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 674 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 675 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 676 | |
| 677 | EXPECT_GL_NO_ERROR(); |
| 678 | |
| 679 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight(), getWindowWidth() / 2, 0, getWindowWidth(), getWindowHeight(), |
| 680 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 681 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 682 | } |
| 683 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 684 | TEST_P(BlitFramebufferANGLETest, BlitPartialColor) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 685 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 686 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 687 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 688 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 689 | |
| 690 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 691 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 692 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 693 | |
| 694 | EXPECT_GL_NO_ERROR(); |
| 695 | |
| 696 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 697 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 698 | |
| 699 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 700 | glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 701 | |
| 702 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0, getWindowHeight() / 2, getWindowWidth() / 2, getWindowHeight(), |
| 703 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 704 | |
| 705 | EXPECT_GL_NO_ERROR(); |
| 706 | |
| 707 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 708 | |
| 709 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255); |
| 710 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255); |
| 711 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 255, 255, 255); |
| 712 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 713 | } |
| 714 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 715 | TEST_P(BlitFramebufferANGLETest, BlitDifferentSizes) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 716 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 717 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 718 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 719 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 720 | |
| 721 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 722 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 723 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 724 | |
| 725 | EXPECT_GL_NO_ERROR(); |
| 726 | |
| 727 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mSmallFBO); |
| 728 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 729 | |
| 730 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 731 | glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 732 | |
| 733 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 734 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 735 | |
| 736 | EXPECT_GL_NO_ERROR(); |
| 737 | |
| 738 | glBindFramebuffer(GL_FRAMEBUFFER, mSmallFBO); |
| 739 | |
| 740 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 741 | |
| 742 | EXPECT_GL_NO_ERROR(); |
| 743 | } |
| 744 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 745 | TEST_P(BlitFramebufferANGLETest, BlitWithMissingAttachments) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 746 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 747 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 748 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 749 | glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO); |
| 750 | |
| 751 | glClear(GL_COLOR_BUFFER_BIT); |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 752 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 753 | |
| 754 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 755 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mColorOnlyFBO); |
| 756 | |
| 757 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 758 | glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 759 | |
He Yunchao | 66a41a2 | 2016-12-15 16:45:05 +0800 | [diff] [blame] | 760 | // generate INVALID_OPERATION if the read FBO has no depth attachment |
| 761 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), |
| 762 | getWindowHeight(), GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, |
| 763 | GL_NEAREST); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 764 | |
He Yunchao | 66a41a2 | 2016-12-15 16:45:05 +0800 | [diff] [blame] | 765 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 766 | |
He Yunchao | 66a41a2 | 2016-12-15 16:45:05 +0800 | [diff] [blame] | 767 | // generate INVALID_OPERATION if the read FBO has no stencil attachment |
| 768 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), |
| 769 | getWindowHeight(), GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, |
| 770 | GL_NEAREST); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 771 | |
He Yunchao | 66a41a2 | 2016-12-15 16:45:05 +0800 | [diff] [blame] | 772 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 773 | |
He Yunchao | 66a41a2 | 2016-12-15 16:45:05 +0800 | [diff] [blame] | 774 | // generate INVALID_OPERATION if we read from a missing color attachment |
| 775 | glReadBuffer(GL_COLOR_ATTACHMENT1); |
| 776 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), |
| 777 | getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 778 | |
He Yunchao | 66a41a2 | 2016-12-15 16:45:05 +0800 | [diff] [blame] | 779 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 780 | } |
| 781 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 782 | TEST_P(BlitFramebufferANGLETest, BlitStencil) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 783 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 784 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 785 | |
Jamie Madill | 8e1936c | 2014-12-03 15:20:12 -0500 | [diff] [blame] | 786 | // TODO(jmadill): Figure out if we can fix this on D3D9. |
Yunchao He | 9550c60 | 2018-02-13 14:47:05 +0800 | [diff] [blame] | 787 | // https://code.google.com/p/angleproject/issues/detail?id=2205 |
| 788 | ANGLE_SKIP_TEST_IF(IsIntel() && IsD3D9()); |
Jamie Madill | 8e1936c | 2014-12-03 15:20:12 -0500 | [diff] [blame] | 789 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 790 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 791 | |
| 792 | glClear(GL_COLOR_BUFFER_BIT); |
| 793 | // fill the stencil buffer with 0x1 |
| 794 | glStencilFunc(GL_ALWAYS, 0x1, 0xFF); |
| 795 | glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); |
Yunchao He | 9550c60 | 2018-02-13 14:47:05 +0800 | [diff] [blame] | 796 | glEnable(GL_STENCIL_TEST); |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 797 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 798 | |
| 799 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 800 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 801 | |
| 802 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 803 | glClearStencil(0x0); |
| 804 | glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 805 | |
| 806 | // depth blit request should be silently ignored, because the read FBO has no depth attachment |
| 807 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 808 | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); |
| 809 | |
| 810 | EXPECT_GL_NO_ERROR(); |
| 811 | |
| 812 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 813 | |
| 814 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 815 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 816 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 817 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 818 | |
| 819 | glStencilFunc(GL_EQUAL, 0x1, 0xFF); // only pass if stencil buffer at pixel reads 0x1 |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 820 | drawQuad(mBlueProgram, essl1_shaders::PositionAttrib(), |
| 821 | 0.8f); // blue quad will draw if stencil buffer was copied |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 822 | glDisable(GL_STENCIL_TEST); |
| 823 | |
| 824 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 0, 0, 255, 255); |
| 825 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 0, 255, 255); |
| 826 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255); |
| 827 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255); |
| 828 | } |
| 829 | |
| 830 | // 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] | 831 | TEST_P(BlitFramebufferANGLETest, BlitPartialDepthStencil) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 832 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 833 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 834 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 835 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 836 | |
| 837 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 838 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 839 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 840 | |
| 841 | EXPECT_GL_NO_ERROR(); |
| 842 | |
| 843 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 844 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 845 | |
| 846 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, |
| 847 | getWindowWidth() / 2, getWindowHeight() / 2, GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
| 848 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 849 | } |
| 850 | |
| 851 | // Test blit with MRT framebuffers |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 852 | TEST_P(BlitFramebufferANGLETest, BlitMRT) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 853 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 854 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 855 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 856 | if (!extensionEnabled("GL_EXT_draw_buffers")) |
| 857 | { |
| 858 | return; |
| 859 | } |
| 860 | |
| 861 | GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT }; |
| 862 | |
| 863 | glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO); |
| 864 | glDrawBuffersEXT(2, drawBuffers); |
| 865 | |
| 866 | glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO); |
| 867 | |
| 868 | glClear(GL_COLOR_BUFFER_BIT); |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 869 | |
| 870 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f); |
| 871 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 872 | EXPECT_GL_NO_ERROR(); |
| 873 | |
| 874 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mColorOnlyFBO); |
| 875 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mMRTFBO); |
| 876 | |
| 877 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 878 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 879 | |
| 880 | EXPECT_GL_NO_ERROR(); |
| 881 | |
| 882 | glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO); |
| 883 | |
| 884 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 885 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 886 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 887 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 888 | |
| 889 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0); |
| 890 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mMRTColorBuffer0, 0); |
| 891 | |
| 892 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 893 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 894 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 895 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 896 | |
| 897 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mMRTColorBuffer0, 0); |
| 898 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, mMRTColorBuffer1, 0); |
| 899 | } |
| 900 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 901 | // Test multisampled framebuffer blits if supported |
| 902 | TEST_P(BlitFramebufferANGLETest, MultisampledRGBAToRGBA) |
| 903 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 904 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 905 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 906 | if (!checkExtension("GL_ANGLE_framebuffer_multisample")) |
| 907 | return; |
| 908 | |
| 909 | if (!checkExtension("GL_OES_rgb8_rgba8")) |
| 910 | return; |
| 911 | |
| 912 | multisampleTestHelper(mRGBAMultisampledFBO, mRGBAFBO); |
| 913 | } |
| 914 | |
| 915 | TEST_P(BlitFramebufferANGLETest, MultisampledRGBAToBGRA) |
| 916 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 917 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 918 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 919 | if (!checkExtension("GL_ANGLE_framebuffer_multisample")) |
| 920 | return; |
| 921 | |
| 922 | if (!checkExtension("GL_OES_rgb8_rgba8")) |
| 923 | return; |
| 924 | |
| 925 | if (!checkExtension("GL_EXT_texture_format_BGRA8888")) |
| 926 | return; |
| 927 | |
| 928 | multisampleTestHelper(mRGBAMultisampledFBO, mBGRAFBO); |
| 929 | } |
| 930 | |
| 931 | TEST_P(BlitFramebufferANGLETest, MultisampledBGRAToRGBA) |
| 932 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 933 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 934 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 935 | if (!checkExtension("GL_ANGLE_framebuffer_multisample")) |
| 936 | return; |
| 937 | |
| 938 | if (!checkExtension("GL_OES_rgb8_rgba8")) |
| 939 | return; |
| 940 | |
| 941 | if (!checkExtension("GL_EXT_texture_format_BGRA8888")) |
| 942 | return; |
| 943 | |
| 944 | multisampleTestHelper(mBGRAMultisampledFBO, mRGBAFBO); |
| 945 | } |
| 946 | |
| 947 | TEST_P(BlitFramebufferANGLETest, MultisampledBGRAToBGRA) |
| 948 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 949 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 950 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 951 | if (!checkExtension("GL_ANGLE_framebuffer_multisample")) |
| 952 | return; |
| 953 | |
| 954 | if (!checkExtension("GL_OES_rgb8_rgba8")) |
| 955 | return; |
| 956 | |
| 957 | if (!checkExtension("GL_EXT_texture_format_BGRA8888")) |
| 958 | return; |
| 959 | |
| 960 | multisampleTestHelper(mBGRAMultisampledFBO, mBGRAFBO); |
| 961 | } |
| 962 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 963 | // 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] | 964 | TEST_P(BlitFramebufferANGLETest, ErrorStretching) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 965 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 966 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 967 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 968 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 969 | |
| 970 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 971 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 972 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 973 | |
| 974 | EXPECT_GL_NO_ERROR(); |
| 975 | |
| 976 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 977 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 978 | |
| 979 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, |
| 980 | getWindowWidth(), getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 981 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 982 | } |
| 983 | |
| 984 | // 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] | 985 | TEST_P(BlitFramebufferANGLETest, ErrorFlipping) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 986 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 987 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 988 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 989 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 990 | |
| 991 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 992 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 993 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 994 | |
| 995 | EXPECT_GL_NO_ERROR(); |
| 996 | |
| 997 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 998 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 999 | |
| 1000 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, getWindowWidth() / 2, getWindowHeight() / 2, |
| 1001 | 0, 0, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 1002 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 1003 | } |
| 1004 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 1005 | TEST_P(BlitFramebufferANGLETest, Errors) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 1006 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 1007 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 1008 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 1009 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 1010 | |
| 1011 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 1012 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 1013 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 1014 | |
| 1015 | EXPECT_GL_NO_ERROR(); |
| 1016 | |
| 1017 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 1018 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 1019 | |
| 1020 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 1021 | GL_COLOR_BUFFER_BIT, GL_LINEAR); |
| 1022 | EXPECT_GL_ERROR(GL_INVALID_ENUM); |
| 1023 | |
| 1024 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 1025 | GL_COLOR_BUFFER_BIT | 234, GL_NEAREST); |
| 1026 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1027 | |
| 1028 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mDiffFormatFBO); |
| 1029 | |
| 1030 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 1031 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 1032 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 1033 | } |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 1034 | |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 1035 | // TODO(geofflang): Fix the dependence on glBlitFramebufferANGLE without checks and assuming the |
| 1036 | // default framebuffer is BGRA to enable the GL and GLES backends. (http://anglebug.com/1289) |
| 1037 | |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1038 | class BlitFramebufferTest : public ANGLETest |
| 1039 | { |
| 1040 | protected: |
| 1041 | BlitFramebufferTest() |
| 1042 | { |
| 1043 | setWindowWidth(256); |
| 1044 | setWindowHeight(256); |
| 1045 | setConfigRedBits(8); |
| 1046 | setConfigGreenBits(8); |
| 1047 | setConfigBlueBits(8); |
| 1048 | setConfigAlphaBits(8); |
| 1049 | setConfigDepthBits(24); |
| 1050 | setConfigStencilBits(8); |
| 1051 | } |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1052 | |
| 1053 | void initColorFBO(GLFramebuffer *fbo, |
| 1054 | GLRenderbuffer *rbo, |
| 1055 | GLenum rboFormat, |
| 1056 | GLsizei width, |
| 1057 | GLsizei height) |
| 1058 | { |
| 1059 | glBindRenderbuffer(GL_RENDERBUFFER, *rbo); |
| 1060 | glRenderbufferStorage(GL_RENDERBUFFER, rboFormat, width, height); |
| 1061 | |
| 1062 | glBindFramebuffer(GL_FRAMEBUFFER, *fbo); |
| 1063 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *rbo); |
| 1064 | } |
| 1065 | |
| 1066 | void initColorFBOWithCheckerPattern(GLFramebuffer *fbo, |
| 1067 | GLRenderbuffer *rbo, |
| 1068 | GLenum rboFormat, |
| 1069 | GLsizei width, |
| 1070 | GLsizei height) |
| 1071 | { |
| 1072 | initColorFBO(fbo, rbo, rboFormat, width, height); |
| 1073 | |
| 1074 | ANGLE_GL_PROGRAM(checkerProgram, essl1_shaders::vs::Passthrough(), |
| 1075 | essl1_shaders::fs::Checkered()); |
| 1076 | glViewport(0, 0, width, height); |
| 1077 | glBindFramebuffer(GL_FRAMEBUFFER, *fbo); |
| 1078 | drawQuad(checkerProgram.get(), essl1_shaders::PositionAttrib(), 0.5f); |
| 1079 | } |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1080 | }; |
| 1081 | |
Jamie Madill | 196ca36 | 2016-07-12 10:54:04 -0400 | [diff] [blame] | 1082 | // Tests resolving a multisample depth buffer. |
| 1083 | TEST_P(BlitFramebufferTest, MultisampleDepth) |
| 1084 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 1085 | ANGLE_SKIP_TEST_IF(!extensionEnabled("EXT_framebuffer_blit")); |
| 1086 | |
Geoff Lang | f1bcd01 | 2018-04-27 14:21:55 -0400 | [diff] [blame] | 1087 | // TODO(oetuaho@nvidia.com): http://crbug.com/837717 |
| 1088 | ANGLE_SKIP_TEST_IF(IsOpenGL() && IsOSX()); |
| 1089 | |
Jamie Madill | 196ca36 | 2016-07-12 10:54:04 -0400 | [diff] [blame] | 1090 | GLRenderbuffer renderbuf; |
| 1091 | glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get()); |
| 1092 | glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_DEPTH_COMPONENT24, 256, 256); |
| 1093 | |
Jamie Madill | 196ca36 | 2016-07-12 10:54:04 -0400 | [diff] [blame] | 1094 | const std::string &fragment = |
| 1095 | "#version 300 es\n" |
| 1096 | "out mediump vec4 red;\n" |
| 1097 | "void main() {\n" |
| 1098 | " red = vec4(1.0, 0.0, 0.0, 1.0);\n" |
| 1099 | " gl_FragDepth = 0.5;\n" |
| 1100 | "}"; |
| 1101 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 1102 | ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), fragment); |
Jamie Madill | 196ca36 | 2016-07-12 10:54:04 -0400 | [diff] [blame] | 1103 | |
| 1104 | GLFramebuffer framebuffer; |
| 1105 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get()); |
| 1106 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, |
| 1107 | renderbuf.get()); |
| 1108 | |
| 1109 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 1110 | |
| 1111 | glClearDepthf(0.5f); |
| 1112 | glClear(GL_DEPTH_BUFFER_BIT); |
| 1113 | |
| 1114 | GLRenderbuffer destRenderbuf; |
| 1115 | glBindRenderbuffer(GL_RENDERBUFFER, destRenderbuf.get()); |
| 1116 | glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, 256, 256); |
| 1117 | |
| 1118 | GLFramebuffer resolved; |
| 1119 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolved.get()); |
| 1120 | glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, |
| 1121 | destRenderbuf.get()); |
| 1122 | |
| 1123 | glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer.get()); |
| 1124 | glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
| 1125 | |
| 1126 | glBindFramebuffer(GL_FRAMEBUFFER, resolved.get()); |
| 1127 | |
| 1128 | GLTexture colorbuf; |
| 1129 | glBindTexture(GL_TEXTURE_2D, colorbuf.get()); |
| 1130 | glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 256, 256); |
| 1131 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuf.get(), 0); |
| 1132 | |
| 1133 | ASSERT_GL_NO_ERROR(); |
| 1134 | |
| 1135 | // Clear to green |
| 1136 | glClearColor(0.0f, 1.0f, 0.0f, 1.0f); |
| 1137 | glClear(GL_COLOR_BUFFER_BIT); |
| 1138 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 1139 | |
| 1140 | // Draw with 0.5f test and the test should pass. |
| 1141 | glEnable(GL_DEPTH_TEST); |
| 1142 | glDepthFunc(GL_EQUAL); |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 1143 | drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f); |
Jamie Madill | 196ca36 | 2016-07-12 10:54:04 -0400 | [diff] [blame] | 1144 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red); |
| 1145 | |
| 1146 | ASSERT_GL_NO_ERROR(); |
| 1147 | } |
| 1148 | |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1149 | // Test resolving a multisampled stencil buffer. |
| 1150 | TEST_P(BlitFramebufferTest, MultisampleStencil) |
| 1151 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 1152 | ANGLE_SKIP_TEST_IF(!extensionEnabled("EXT_framebuffer_blit")); |
| 1153 | |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1154 | // Incorrect rendering results seen on AMD Windows OpenGL. http://anglebug.com/2486 |
| 1155 | ANGLE_SKIP_TEST_IF(IsAMD() && IsOpenGL() && IsWindows()); |
| 1156 | |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1157 | GLRenderbuffer renderbuf; |
| 1158 | glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get()); |
| 1159 | glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_STENCIL_INDEX8, 256, 256); |
| 1160 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 1161 | ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red()); |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1162 | |
| 1163 | GLFramebuffer framebuffer; |
| 1164 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get()); |
| 1165 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, |
| 1166 | renderbuf.get()); |
| 1167 | |
| 1168 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 1169 | |
| 1170 | // fill the stencil buffer with 0x1 |
| 1171 | glStencilFunc(GL_ALWAYS, 0x1, 0xFF); |
| 1172 | glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); |
| 1173 | glEnable(GL_STENCIL_TEST); |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 1174 | drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f); |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1175 | |
| 1176 | GLTexture destColorbuf; |
| 1177 | glBindTexture(GL_TEXTURE_2D, destColorbuf.get()); |
| 1178 | glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 256, 256); |
| 1179 | |
| 1180 | GLRenderbuffer destRenderbuf; |
| 1181 | glBindRenderbuffer(GL_RENDERBUFFER, destRenderbuf.get()); |
| 1182 | glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 256, 256); |
| 1183 | |
| 1184 | GLFramebuffer resolved; |
| 1185 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolved.get()); |
| 1186 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 1187 | destColorbuf.get(), 0); |
| 1188 | glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, |
| 1189 | destRenderbuf.get()); |
| 1190 | |
| 1191 | glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer.get()); |
| 1192 | glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_STENCIL_BUFFER_BIT, GL_NEAREST); |
| 1193 | |
| 1194 | glBindFramebuffer(GL_FRAMEBUFFER, resolved.get()); |
| 1195 | |
| 1196 | ASSERT_GL_NO_ERROR(); |
| 1197 | |
| 1198 | // Clear to green |
| 1199 | glClearColor(0.0f, 1.0f, 0.0f, 1.0f); |
| 1200 | glClear(GL_COLOR_BUFFER_BIT); |
| 1201 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 1202 | |
| 1203 | // Draw red if the stencil is 0x1, which should be true after the blit/resolve. |
| 1204 | glStencilFunc(GL_EQUAL, 0x1, 0xFF); |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 1205 | drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f); |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1206 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red); |
| 1207 | |
| 1208 | ASSERT_GL_NO_ERROR(); |
| 1209 | } |
| 1210 | |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1211 | // Blit an SRGB framebuffer and scale it. |
| 1212 | TEST_P(BlitFramebufferTest, BlitSRGBToRGBAndScale) |
| 1213 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 1214 | ANGLE_SKIP_TEST_IF(!extensionEnabled("EXT_framebuffer_blit")); |
| 1215 | |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1216 | constexpr const GLsizei kWidth = 256; |
| 1217 | constexpr const GLsizei kHeight = 256; |
| 1218 | |
| 1219 | GLRenderbuffer sourceRBO, targetRBO; |
| 1220 | GLFramebuffer sourceFBO, targetFBO; |
| 1221 | initColorFBOWithCheckerPattern(&sourceFBO, &sourceRBO, GL_SRGB8_ALPHA8, kWidth * 2, |
| 1222 | kHeight * 2); |
| 1223 | initColorFBO(&targetFBO, &targetRBO, GL_RGBA8, kWidth, kHeight); |
| 1224 | |
| 1225 | EXPECT_GL_NO_ERROR(); |
| 1226 | |
| 1227 | glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO); |
| 1228 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO); |
| 1229 | |
| 1230 | glViewport(0, 0, kWidth, kHeight); |
| 1231 | |
| 1232 | glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 1233 | glClear(GL_COLOR_BUFFER_BIT); |
| 1234 | |
| 1235 | // Scale down without flipping. |
| 1236 | glBlitFramebuffer(0, 0, kWidth * 2, kHeight * 2, 0, 0, kWidth, kHeight, GL_COLOR_BUFFER_BIT, |
| 1237 | GL_NEAREST); |
| 1238 | |
| 1239 | EXPECT_GL_NO_ERROR(); |
| 1240 | |
| 1241 | glBindFramebuffer(GL_FRAMEBUFFER, targetFBO); |
| 1242 | |
| 1243 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::red); |
| 1244 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::green); |
| 1245 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::red); |
| 1246 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::green); |
| 1247 | |
| 1248 | glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO); |
| 1249 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO); |
| 1250 | |
| 1251 | glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 1252 | glClear(GL_COLOR_BUFFER_BIT); |
| 1253 | |
| 1254 | // Scale down and flip in the X direction. |
| 1255 | glBlitFramebuffer(0, 0, kWidth * 2, kHeight * 2, kWidth, 0, 0, kHeight, GL_COLOR_BUFFER_BIT, |
| 1256 | GL_NEAREST); |
| 1257 | |
| 1258 | EXPECT_GL_NO_ERROR(); |
| 1259 | |
| 1260 | glBindFramebuffer(GL_FRAMEBUFFER, targetFBO); |
| 1261 | |
| 1262 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::green); |
| 1263 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::red); |
| 1264 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::green); |
| 1265 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::red); |
| 1266 | } |
| 1267 | |
| 1268 | // Blit a subregion of an SRGB framebuffer to an RGB framebuffer. |
| 1269 | TEST_P(BlitFramebufferTest, PartialBlitSRGBToRGB) |
| 1270 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 1271 | ANGLE_SKIP_TEST_IF(!extensionEnabled("EXT_framebuffer_blit")); |
| 1272 | |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1273 | constexpr const GLsizei kWidth = 256; |
| 1274 | constexpr const GLsizei kHeight = 256; |
| 1275 | |
| 1276 | GLRenderbuffer sourceRBO, targetRBO; |
| 1277 | GLFramebuffer sourceFBO, targetFBO; |
| 1278 | initColorFBOWithCheckerPattern(&sourceFBO, &sourceRBO, GL_SRGB8_ALPHA8, kWidth * 2, |
| 1279 | kHeight * 2); |
| 1280 | initColorFBO(&targetFBO, &targetRBO, GL_RGBA8, kWidth, kHeight); |
| 1281 | |
| 1282 | EXPECT_GL_NO_ERROR(); |
| 1283 | |
| 1284 | glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO); |
| 1285 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO); |
| 1286 | |
| 1287 | glViewport(0, 0, kWidth, kHeight); |
| 1288 | |
| 1289 | glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 1290 | glClear(GL_COLOR_BUFFER_BIT); |
| 1291 | |
| 1292 | // Blit a part of the source FBO without flipping. |
| 1293 | glBlitFramebuffer(kWidth, kHeight, kWidth * 2, kHeight * 2, 0, 0, kWidth, kHeight, |
| 1294 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 1295 | |
| 1296 | EXPECT_GL_NO_ERROR(); |
| 1297 | |
| 1298 | glBindFramebuffer(GL_FRAMEBUFFER, targetFBO); |
| 1299 | |
| 1300 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::red); |
| 1301 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::red); |
| 1302 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::red); |
| 1303 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::red); |
| 1304 | |
| 1305 | glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO); |
| 1306 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO); |
| 1307 | |
| 1308 | glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 1309 | glClear(GL_COLOR_BUFFER_BIT); |
| 1310 | |
| 1311 | // Blit a part of the source FBO and flip in the X direction. |
| 1312 | glBlitFramebuffer(kWidth * 2, 0, kWidth, kHeight, kWidth, 0, 0, kHeight, GL_COLOR_BUFFER_BIT, |
| 1313 | GL_NEAREST); |
| 1314 | |
| 1315 | EXPECT_GL_NO_ERROR(); |
| 1316 | |
| 1317 | glBindFramebuffer(GL_FRAMEBUFFER, targetFBO); |
| 1318 | |
| 1319 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::green); |
| 1320 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::green); |
| 1321 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::green); |
| 1322 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::green); |
| 1323 | } |
| 1324 | |
| 1325 | // Blit an SRGB framebuffer with an oversized source area (parts outside the source area should be |
| 1326 | // clipped out). |
| 1327 | TEST_P(BlitFramebufferTest, BlitSRGBToRGBOversizedSourceArea) |
| 1328 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 1329 | ANGLE_SKIP_TEST_IF(!extensionEnabled("EXT_framebuffer_blit")); |
| 1330 | |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1331 | constexpr const GLsizei kWidth = 256; |
| 1332 | constexpr const GLsizei kHeight = 256; |
| 1333 | |
| 1334 | GLRenderbuffer sourceRBO, targetRBO; |
| 1335 | GLFramebuffer sourceFBO, targetFBO; |
| 1336 | initColorFBOWithCheckerPattern(&sourceFBO, &sourceRBO, GL_SRGB8_ALPHA8, kWidth, kHeight); |
| 1337 | initColorFBO(&targetFBO, &targetRBO, GL_RGBA8, kWidth, kHeight); |
| 1338 | |
| 1339 | EXPECT_GL_NO_ERROR(); |
| 1340 | |
| 1341 | glViewport(0, 0, kWidth, kHeight); |
| 1342 | |
| 1343 | glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO); |
| 1344 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO); |
| 1345 | |
| 1346 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
| 1347 | glClear(GL_COLOR_BUFFER_BIT); |
| 1348 | |
| 1349 | // Blit so that the source area gets placed at the center of the target FBO. |
| 1350 | // The width of the source area is 1/4 of the width of the target FBO. |
| 1351 | glBlitFramebuffer(-3 * kWidth / 2, -3 * kHeight / 2, 5 * kWidth / 2, 5 * kHeight / 2, 0, 0, |
| 1352 | kWidth, kHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 1353 | |
| 1354 | EXPECT_GL_NO_ERROR(); |
| 1355 | |
| 1356 | glBindFramebuffer(GL_FRAMEBUFFER, targetFBO); |
| 1357 | |
| 1358 | // Source FBO colors can be found in the middle of the target FBO. |
| 1359 | EXPECT_PIXEL_COLOR_EQ(7 * kWidth / 16, 7 * kHeight / 16, GLColor::red); |
| 1360 | EXPECT_PIXEL_COLOR_EQ(9 * kWidth / 16, 7 * kHeight / 16, GLColor::green); |
| 1361 | EXPECT_PIXEL_COLOR_EQ(9 * kWidth / 16, 9 * kHeight / 16, GLColor::red); |
| 1362 | EXPECT_PIXEL_COLOR_EQ(7 * kWidth / 16, 9 * kHeight / 16, GLColor::green); |
| 1363 | |
| 1364 | // Clear color should remain around the edges of the target FBO (WebGL 2.0 spec explicitly |
| 1365 | // requires this and ANGLE is expected to follow that). |
| 1366 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::black); |
| 1367 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::black); |
| 1368 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::black); |
| 1369 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::black); |
| 1370 | } |
| 1371 | |
Olli Etuaho | 9aef81c | 2018-04-30 14:56:15 +0300 | [diff] [blame] | 1372 | // Test blitFramebuffer size overflow checks. WebGL 2.0 spec section 5.41. We do validation for |
| 1373 | // overflows also in non-WebGL mode to avoid triggering driver bugs. |
| 1374 | TEST_P(BlitFramebufferTest, BlitFramebufferSizeOverflow) |
| 1375 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 1376 | ANGLE_SKIP_TEST_IF(!extensionEnabled("EXT_framebuffer_blit")); |
| 1377 | |
Olli Etuaho | 9aef81c | 2018-04-30 14:56:15 +0300 | [diff] [blame] | 1378 | GLTexture textures[2]; |
| 1379 | glBindTexture(GL_TEXTURE_2D, textures[0]); |
| 1380 | glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4); |
| 1381 | glBindTexture(GL_TEXTURE_2D, textures[1]); |
| 1382 | glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4); |
| 1383 | |
| 1384 | GLFramebuffer framebuffers[2]; |
| 1385 | glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffers[0]); |
| 1386 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffers[1]); |
| 1387 | |
| 1388 | ASSERT_GL_NO_ERROR(); |
| 1389 | |
| 1390 | glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0], |
| 1391 | 0); |
| 1392 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1], |
| 1393 | 0); |
| 1394 | ASSERT_GL_NO_ERROR(); |
| 1395 | |
| 1396 | // srcX |
| 1397 | glBlitFramebuffer(-1, 0, std::numeric_limits<GLint>::max(), 4, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT, |
| 1398 | GL_NEAREST); |
| 1399 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1400 | glBlitFramebuffer(std::numeric_limits<GLint>::max(), 0, -1, 4, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT, |
| 1401 | GL_NEAREST); |
| 1402 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1403 | |
| 1404 | // srcY |
| 1405 | glBlitFramebuffer(0, -1, 4, std::numeric_limits<GLint>::max(), 0, 0, 4, 4, GL_COLOR_BUFFER_BIT, |
| 1406 | GL_NEAREST); |
| 1407 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1408 | glBlitFramebuffer(0, std::numeric_limits<GLint>::max(), 4, -1, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT, |
| 1409 | GL_NEAREST); |
| 1410 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1411 | |
| 1412 | // dstX |
| 1413 | glBlitFramebuffer(0, 0, 4, 4, -1, 0, std::numeric_limits<GLint>::max(), 4, GL_COLOR_BUFFER_BIT, |
| 1414 | GL_NEAREST); |
| 1415 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1416 | glBlitFramebuffer(0, 0, 4, 4, std::numeric_limits<GLint>::max(), 0, -1, 4, GL_COLOR_BUFFER_BIT, |
| 1417 | GL_NEAREST); |
| 1418 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1419 | |
| 1420 | // dstY |
| 1421 | glBlitFramebuffer(0, 0, 4, 4, 0, -1, 4, std::numeric_limits<GLint>::max(), GL_COLOR_BUFFER_BIT, |
| 1422 | GL_NEAREST); |
| 1423 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1424 | glBlitFramebuffer(0, 0, 4, 4, 0, std::numeric_limits<GLint>::max(), 4, -1, GL_COLOR_BUFFER_BIT, |
| 1425 | GL_NEAREST); |
| 1426 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1427 | } |
| 1428 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 1429 | // 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] | 1430 | ANGLE_INSTANTIATE_TEST(BlitFramebufferANGLETest, |
| 1431 | ES2_D3D9(), |
| 1432 | ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE), |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 1433 | ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE), |
| 1434 | ES2_OPENGL(), |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame^] | 1435 | ES3_OPENGL(), |
| 1436 | ES2_VULKAN()); |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1437 | |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1438 | // We're specifically testing GL 4.4 and GL 4.3 since on versions earlier than 4.4 FramebufferGL |
| 1439 | // takes a different path for blitting SRGB textures. |
| 1440 | ANGLE_INSTANTIATE_TEST(BlitFramebufferTest, ES3_D3D11(), ES3_OPENGL(4, 4), ES3_OPENGL(4, 3)); |