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 | 82eda93 | 2018-07-09 15:10:22 -0400 | [diff] [blame^] | 573 | // TODO(lucferron): Fix this test and the implementation. |
| 574 | // http://anglebug.com/2673 |
| 575 | ANGLE_SKIP_TEST_IF(IsVulkan()); |
| 576 | |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 577 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 578 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 579 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 580 | |
| 581 | glDepthMask(GL_TRUE); |
| 582 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 583 | |
| 584 | glEnable(GL_DEPTH_TEST); |
| 585 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 586 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 587 | |
| 588 | EXPECT_GL_NO_ERROR(); |
| 589 | |
| 590 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 591 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 592 | |
| 593 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 594 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 595 | |
| 596 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 597 | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
| 598 | EXPECT_GL_NO_ERROR(); |
| 599 | |
| 600 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 601 | |
| 602 | // 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] | 603 | drawQuad(mBlueProgram, essl1_shaders::PositionAttrib(), 0.8f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 604 | |
| 605 | glDisable(GL_DEPTH_TEST); |
| 606 | |
| 607 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 608 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 609 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 610 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 611 | } |
| 612 | |
| 613 | // blit from system FBO to user-created framebuffer, with depth buffer. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 614 | TEST_P(BlitFramebufferANGLETest, ReverseBlitWithDepth) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 615 | { |
Luc Ferron | 82eda93 | 2018-07-09 15:10:22 -0400 | [diff] [blame^] | 616 | // TODO(lucferron): Fix this test and the implementation. |
| 617 | // http://anglebug.com/2673 |
| 618 | ANGLE_SKIP_TEST_IF(IsVulkan()); |
| 619 | |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 620 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 621 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 622 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 623 | |
| 624 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 625 | |
| 626 | glEnable(GL_DEPTH_TEST); |
| 627 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 628 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 629 | |
| 630 | EXPECT_GL_NO_ERROR(); |
| 631 | |
| 632 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mUserFBO); |
| 633 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 634 | |
| 635 | glClearColor(1.0f, 1.0f, 1.0f, 1.0f); |
| 636 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 637 | |
| 638 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 639 | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
| 640 | EXPECT_GL_NO_ERROR(); |
| 641 | |
| 642 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 643 | |
| 644 | // if blit is happening correctly, this quad will not draw, because it is behind the blitted one |
| 645 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 646 | drawQuad(mBlueProgram, essl1_shaders::PositionAttrib(), 0.8f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 647 | |
| 648 | glDisable(GL_DEPTH_TEST); |
| 649 | |
| 650 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 651 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 652 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 653 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 654 | } |
| 655 | |
| 656 | // 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] | 657 | TEST_P(BlitFramebufferANGLETest, BlitSameBufferOriginal) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 658 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 659 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 660 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 661 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 662 | |
| 663 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 664 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 665 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 666 | |
| 667 | EXPECT_GL_NO_ERROR(); |
| 668 | |
| 669 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight(), getWindowWidth() / 2, 0, getWindowWidth(), getWindowHeight(), |
| 670 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 671 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 672 | } |
| 673 | |
| 674 | // blit from one region of the system fbo to another. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 675 | TEST_P(BlitFramebufferANGLETest, BlitSameBufferUser) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 676 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 677 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 678 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 679 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 680 | |
| 681 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 682 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 683 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 684 | |
| 685 | EXPECT_GL_NO_ERROR(); |
| 686 | |
| 687 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight(), getWindowWidth() / 2, 0, getWindowWidth(), getWindowHeight(), |
| 688 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 689 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 690 | } |
| 691 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 692 | TEST_P(BlitFramebufferANGLETest, BlitPartialColor) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 693 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 694 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 695 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 696 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 697 | |
| 698 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 699 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 700 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 701 | |
| 702 | EXPECT_GL_NO_ERROR(); |
| 703 | |
| 704 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 705 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 706 | |
| 707 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 708 | glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 709 | |
| 710 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0, getWindowHeight() / 2, getWindowWidth() / 2, getWindowHeight(), |
| 711 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 712 | |
| 713 | EXPECT_GL_NO_ERROR(); |
| 714 | |
| 715 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 716 | |
| 717 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255); |
| 718 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255); |
| 719 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 255, 255, 255); |
| 720 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 721 | } |
| 722 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 723 | TEST_P(BlitFramebufferANGLETest, BlitDifferentSizes) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 724 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 725 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 726 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 727 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 728 | |
| 729 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 730 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 731 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 732 | |
| 733 | EXPECT_GL_NO_ERROR(); |
| 734 | |
| 735 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mSmallFBO); |
| 736 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 737 | |
| 738 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 739 | glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 740 | |
| 741 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 742 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 743 | |
| 744 | EXPECT_GL_NO_ERROR(); |
| 745 | |
| 746 | glBindFramebuffer(GL_FRAMEBUFFER, mSmallFBO); |
| 747 | |
| 748 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 749 | |
| 750 | EXPECT_GL_NO_ERROR(); |
| 751 | } |
| 752 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 753 | TEST_P(BlitFramebufferANGLETest, BlitWithMissingAttachments) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 754 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 755 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 756 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 757 | glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO); |
| 758 | |
| 759 | glClear(GL_COLOR_BUFFER_BIT); |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 760 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 761 | |
| 762 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 763 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mColorOnlyFBO); |
| 764 | |
| 765 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 766 | glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 767 | |
He Yunchao | 66a41a2 | 2016-12-15 16:45:05 +0800 | [diff] [blame] | 768 | // generate INVALID_OPERATION if the read FBO has no depth attachment |
| 769 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), |
| 770 | getWindowHeight(), GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, |
| 771 | GL_NEAREST); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 772 | |
He Yunchao | 66a41a2 | 2016-12-15 16:45:05 +0800 | [diff] [blame] | 773 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 774 | |
He Yunchao | 66a41a2 | 2016-12-15 16:45:05 +0800 | [diff] [blame] | 775 | // generate INVALID_OPERATION if the read FBO has no stencil attachment |
| 776 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), |
| 777 | getWindowHeight(), GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, |
| 778 | GL_NEAREST); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 779 | |
He Yunchao | 66a41a2 | 2016-12-15 16:45:05 +0800 | [diff] [blame] | 780 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 781 | |
He Yunchao | 66a41a2 | 2016-12-15 16:45:05 +0800 | [diff] [blame] | 782 | // generate INVALID_OPERATION if we read from a missing color attachment |
| 783 | glReadBuffer(GL_COLOR_ATTACHMENT1); |
| 784 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), |
| 785 | getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 786 | |
He Yunchao | 66a41a2 | 2016-12-15 16:45:05 +0800 | [diff] [blame] | 787 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 788 | } |
| 789 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 790 | TEST_P(BlitFramebufferANGLETest, BlitStencil) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 791 | { |
Luc Ferron | 82eda93 | 2018-07-09 15:10:22 -0400 | [diff] [blame^] | 792 | // TODO(lucferron): Fix this test and the implementation. |
| 793 | // http://anglebug.com/2673 |
| 794 | ANGLE_SKIP_TEST_IF(IsVulkan()); |
| 795 | |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 796 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 797 | |
Jamie Madill | 8e1936c | 2014-12-03 15:20:12 -0500 | [diff] [blame] | 798 | // TODO(jmadill): Figure out if we can fix this on D3D9. |
Yunchao He | 9550c60 | 2018-02-13 14:47:05 +0800 | [diff] [blame] | 799 | // https://code.google.com/p/angleproject/issues/detail?id=2205 |
| 800 | ANGLE_SKIP_TEST_IF(IsIntel() && IsD3D9()); |
Jamie Madill | 8e1936c | 2014-12-03 15:20:12 -0500 | [diff] [blame] | 801 | |
Luc Ferron | be30c4f | 2018-06-21 09:43:08 -0400 | [diff] [blame] | 802 | // TODO(lucferron): Diagnose and fix http://anglebug.com/2693 |
| 803 | ANGLE_SKIP_TEST_IF(IsIntel() && IsLinux() && IsVulkan()); |
| 804 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 805 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 806 | |
| 807 | glClear(GL_COLOR_BUFFER_BIT); |
| 808 | // fill the stencil buffer with 0x1 |
| 809 | glStencilFunc(GL_ALWAYS, 0x1, 0xFF); |
| 810 | glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); |
Yunchao He | 9550c60 | 2018-02-13 14:47:05 +0800 | [diff] [blame] | 811 | glEnable(GL_STENCIL_TEST); |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 812 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.3f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 813 | |
| 814 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 815 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 816 | |
| 817 | glClearColor(1.0, 1.0, 1.0, 1.0); |
| 818 | glClearStencil(0x0); |
| 819 | glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 820 | |
| 821 | // depth blit request should be silently ignored, because the read FBO has no depth attachment |
| 822 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 823 | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); |
| 824 | |
| 825 | EXPECT_GL_NO_ERROR(); |
| 826 | |
| 827 | glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO); |
| 828 | |
| 829 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 830 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 831 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 832 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 833 | |
| 834 | 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] | 835 | drawQuad(mBlueProgram, essl1_shaders::PositionAttrib(), |
| 836 | 0.8f); // blue quad will draw if stencil buffer was copied |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 837 | glDisable(GL_STENCIL_TEST); |
| 838 | |
| 839 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 0, 0, 255, 255); |
| 840 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 0, 255, 255); |
| 841 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255); |
| 842 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255); |
| 843 | } |
| 844 | |
| 845 | // 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] | 846 | TEST_P(BlitFramebufferANGLETest, BlitPartialDepthStencil) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 847 | { |
Luc Ferron | 82eda93 | 2018-07-09 15:10:22 -0400 | [diff] [blame^] | 848 | // TODO(lucferron): Fix this test and the implementation. |
| 849 | // http://anglebug.com/2673 |
| 850 | ANGLE_SKIP_TEST_IF(IsVulkan()); |
| 851 | |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 852 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 853 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 854 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 855 | |
| 856 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 857 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 858 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 859 | |
| 860 | EXPECT_GL_NO_ERROR(); |
| 861 | |
| 862 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 863 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 864 | |
| 865 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, |
| 866 | getWindowWidth() / 2, getWindowHeight() / 2, GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
| 867 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 868 | } |
| 869 | |
| 870 | // Test blit with MRT framebuffers |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 871 | TEST_P(BlitFramebufferANGLETest, BlitMRT) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 872 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 873 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 874 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 875 | if (!extensionEnabled("GL_EXT_draw_buffers")) |
| 876 | { |
| 877 | return; |
| 878 | } |
| 879 | |
| 880 | GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT }; |
| 881 | |
| 882 | glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO); |
| 883 | glDrawBuffersEXT(2, drawBuffers); |
| 884 | |
| 885 | glBindFramebuffer(GL_FRAMEBUFFER, mColorOnlyFBO); |
| 886 | |
| 887 | glClear(GL_COLOR_BUFFER_BIT); |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 888 | |
| 889 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.8f); |
| 890 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 891 | EXPECT_GL_NO_ERROR(); |
| 892 | |
| 893 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mColorOnlyFBO); |
| 894 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mMRTFBO); |
| 895 | |
| 896 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 897 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 898 | |
| 899 | EXPECT_GL_NO_ERROR(); |
| 900 | |
| 901 | glBindFramebuffer(GL_FRAMEBUFFER, mMRTFBO); |
| 902 | |
| 903 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 904 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 905 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 906 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 907 | |
| 908 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0); |
| 909 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mMRTColorBuffer0, 0); |
| 910 | |
| 911 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255); |
| 912 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255); |
| 913 | EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255); |
| 914 | EXPECT_PIXEL_EQ( getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255); |
| 915 | |
| 916 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mMRTColorBuffer0, 0); |
| 917 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, mMRTColorBuffer1, 0); |
| 918 | } |
| 919 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 920 | // Test multisampled framebuffer blits if supported |
| 921 | TEST_P(BlitFramebufferANGLETest, MultisampledRGBAToRGBA) |
| 922 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 923 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 924 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 925 | if (!checkExtension("GL_ANGLE_framebuffer_multisample")) |
| 926 | return; |
| 927 | |
| 928 | if (!checkExtension("GL_OES_rgb8_rgba8")) |
| 929 | return; |
| 930 | |
| 931 | multisampleTestHelper(mRGBAMultisampledFBO, mRGBAFBO); |
| 932 | } |
| 933 | |
| 934 | TEST_P(BlitFramebufferANGLETest, MultisampledRGBAToBGRA) |
| 935 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 936 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 937 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 938 | if (!checkExtension("GL_ANGLE_framebuffer_multisample")) |
| 939 | return; |
| 940 | |
| 941 | if (!checkExtension("GL_OES_rgb8_rgba8")) |
| 942 | return; |
| 943 | |
| 944 | if (!checkExtension("GL_EXT_texture_format_BGRA8888")) |
| 945 | return; |
| 946 | |
| 947 | multisampleTestHelper(mRGBAMultisampledFBO, mBGRAFBO); |
| 948 | } |
| 949 | |
| 950 | TEST_P(BlitFramebufferANGLETest, MultisampledBGRAToRGBA) |
| 951 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 952 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 953 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 954 | if (!checkExtension("GL_ANGLE_framebuffer_multisample")) |
| 955 | return; |
| 956 | |
| 957 | if (!checkExtension("GL_OES_rgb8_rgba8")) |
| 958 | return; |
| 959 | |
| 960 | if (!checkExtension("GL_EXT_texture_format_BGRA8888")) |
| 961 | return; |
| 962 | |
| 963 | multisampleTestHelper(mBGRAMultisampledFBO, mRGBAFBO); |
| 964 | } |
| 965 | |
| 966 | TEST_P(BlitFramebufferANGLETest, MultisampledBGRAToBGRA) |
| 967 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 968 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 969 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 970 | if (!checkExtension("GL_ANGLE_framebuffer_multisample")) |
| 971 | return; |
| 972 | |
| 973 | if (!checkExtension("GL_OES_rgb8_rgba8")) |
| 974 | return; |
| 975 | |
| 976 | if (!checkExtension("GL_EXT_texture_format_BGRA8888")) |
| 977 | return; |
| 978 | |
| 979 | multisampleTestHelper(mBGRAMultisampledFBO, mBGRAFBO); |
| 980 | } |
| 981 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 982 | // 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] | 983 | TEST_P(BlitFramebufferANGLETest, ErrorStretching) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 984 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 985 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 986 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 987 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 988 | |
| 989 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 990 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 991 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 992 | |
| 993 | EXPECT_GL_NO_ERROR(); |
| 994 | |
| 995 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 996 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 997 | |
| 998 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, |
| 999 | getWindowWidth(), getWindowHeight(), GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 1000 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 1001 | } |
| 1002 | |
| 1003 | // 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] | 1004 | TEST_P(BlitFramebufferANGLETest, ErrorFlipping) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 1005 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 1006 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 1007 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 1008 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 1009 | |
| 1010 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 1011 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 1012 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 1013 | |
| 1014 | EXPECT_GL_NO_ERROR(); |
| 1015 | |
| 1016 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 1017 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 1018 | |
| 1019 | glBlitFramebufferANGLE(0, 0, getWindowWidth() / 2, getWindowHeight() / 2, getWindowWidth() / 2, getWindowHeight() / 2, |
| 1020 | 0, 0, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 1021 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 1022 | } |
| 1023 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 1024 | TEST_P(BlitFramebufferANGLETest, Errors) |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 1025 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 1026 | ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_ANGLE_framebuffer_blit")); |
| 1027 | |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 1028 | glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO); |
| 1029 | |
| 1030 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); |
| 1031 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 1032 | drawQuad(mCheckerProgram, essl1_shaders::PositionAttrib(), 0.5f); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 1033 | |
| 1034 | EXPECT_GL_NO_ERROR(); |
| 1035 | |
| 1036 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mOriginalFBO); |
| 1037 | glBindFramebuffer(GL_READ_FRAMEBUFFER_ANGLE, mUserFBO); |
| 1038 | |
| 1039 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 1040 | GL_COLOR_BUFFER_BIT, GL_LINEAR); |
| 1041 | EXPECT_GL_ERROR(GL_INVALID_ENUM); |
| 1042 | |
| 1043 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 1044 | GL_COLOR_BUFFER_BIT | 234, GL_NEAREST); |
| 1045 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1046 | |
| 1047 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER_ANGLE, mDiffFormatFBO); |
| 1048 | |
| 1049 | glBlitFramebufferANGLE(0, 0, getWindowWidth(), getWindowHeight(), 0, 0, getWindowWidth(), getWindowHeight(), |
| 1050 | GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 1051 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
Geoff Lang | e8a1f78 | 2013-10-18 16:14:30 -0400 | [diff] [blame] | 1052 | } |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 1053 | |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 1054 | // TODO(geofflang): Fix the dependence on glBlitFramebufferANGLE without checks and assuming the |
| 1055 | // default framebuffer is BGRA to enable the GL and GLES backends. (http://anglebug.com/1289) |
| 1056 | |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1057 | class BlitFramebufferTest : public ANGLETest |
| 1058 | { |
| 1059 | protected: |
| 1060 | BlitFramebufferTest() |
| 1061 | { |
| 1062 | setWindowWidth(256); |
| 1063 | setWindowHeight(256); |
| 1064 | setConfigRedBits(8); |
| 1065 | setConfigGreenBits(8); |
| 1066 | setConfigBlueBits(8); |
| 1067 | setConfigAlphaBits(8); |
| 1068 | setConfigDepthBits(24); |
| 1069 | setConfigStencilBits(8); |
| 1070 | } |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1071 | |
| 1072 | void initColorFBO(GLFramebuffer *fbo, |
| 1073 | GLRenderbuffer *rbo, |
| 1074 | GLenum rboFormat, |
| 1075 | GLsizei width, |
| 1076 | GLsizei height) |
| 1077 | { |
| 1078 | glBindRenderbuffer(GL_RENDERBUFFER, *rbo); |
| 1079 | glRenderbufferStorage(GL_RENDERBUFFER, rboFormat, width, height); |
| 1080 | |
| 1081 | glBindFramebuffer(GL_FRAMEBUFFER, *fbo); |
| 1082 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *rbo); |
| 1083 | } |
| 1084 | |
| 1085 | void initColorFBOWithCheckerPattern(GLFramebuffer *fbo, |
| 1086 | GLRenderbuffer *rbo, |
| 1087 | GLenum rboFormat, |
| 1088 | GLsizei width, |
| 1089 | GLsizei height) |
| 1090 | { |
| 1091 | initColorFBO(fbo, rbo, rboFormat, width, height); |
| 1092 | |
| 1093 | ANGLE_GL_PROGRAM(checkerProgram, essl1_shaders::vs::Passthrough(), |
| 1094 | essl1_shaders::fs::Checkered()); |
| 1095 | glViewport(0, 0, width, height); |
| 1096 | glBindFramebuffer(GL_FRAMEBUFFER, *fbo); |
| 1097 | drawQuad(checkerProgram.get(), essl1_shaders::PositionAttrib(), 0.5f); |
| 1098 | } |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1099 | }; |
| 1100 | |
Jamie Madill | 196ca36 | 2016-07-12 10:54:04 -0400 | [diff] [blame] | 1101 | // Tests resolving a multisample depth buffer. |
| 1102 | TEST_P(BlitFramebufferTest, MultisampleDepth) |
| 1103 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 1104 | ANGLE_SKIP_TEST_IF(!extensionEnabled("EXT_framebuffer_blit")); |
| 1105 | |
Geoff Lang | f1bcd01 | 2018-04-27 14:21:55 -0400 | [diff] [blame] | 1106 | // TODO(oetuaho@nvidia.com): http://crbug.com/837717 |
| 1107 | ANGLE_SKIP_TEST_IF(IsOpenGL() && IsOSX()); |
| 1108 | |
Jamie Madill | 196ca36 | 2016-07-12 10:54:04 -0400 | [diff] [blame] | 1109 | GLRenderbuffer renderbuf; |
| 1110 | glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get()); |
| 1111 | glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_DEPTH_COMPONENT24, 256, 256); |
| 1112 | |
Jamie Madill | 196ca36 | 2016-07-12 10:54:04 -0400 | [diff] [blame] | 1113 | const std::string &fragment = |
| 1114 | "#version 300 es\n" |
| 1115 | "out mediump vec4 red;\n" |
| 1116 | "void main() {\n" |
| 1117 | " red = vec4(1.0, 0.0, 0.0, 1.0);\n" |
| 1118 | " gl_FragDepth = 0.5;\n" |
| 1119 | "}"; |
| 1120 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 1121 | ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), fragment); |
Jamie Madill | 196ca36 | 2016-07-12 10:54:04 -0400 | [diff] [blame] | 1122 | |
| 1123 | GLFramebuffer framebuffer; |
| 1124 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get()); |
| 1125 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, |
| 1126 | renderbuf.get()); |
| 1127 | |
| 1128 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 1129 | |
| 1130 | glClearDepthf(0.5f); |
| 1131 | glClear(GL_DEPTH_BUFFER_BIT); |
| 1132 | |
| 1133 | GLRenderbuffer destRenderbuf; |
| 1134 | glBindRenderbuffer(GL_RENDERBUFFER, destRenderbuf.get()); |
| 1135 | glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, 256, 256); |
| 1136 | |
| 1137 | GLFramebuffer resolved; |
| 1138 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolved.get()); |
| 1139 | glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, |
| 1140 | destRenderbuf.get()); |
| 1141 | |
| 1142 | glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer.get()); |
| 1143 | glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
| 1144 | |
| 1145 | glBindFramebuffer(GL_FRAMEBUFFER, resolved.get()); |
| 1146 | |
| 1147 | GLTexture colorbuf; |
| 1148 | glBindTexture(GL_TEXTURE_2D, colorbuf.get()); |
| 1149 | glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 256, 256); |
| 1150 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuf.get(), 0); |
| 1151 | |
| 1152 | ASSERT_GL_NO_ERROR(); |
| 1153 | |
| 1154 | // Clear to green |
| 1155 | glClearColor(0.0f, 1.0f, 0.0f, 1.0f); |
| 1156 | glClear(GL_COLOR_BUFFER_BIT); |
| 1157 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 1158 | |
| 1159 | // Draw with 0.5f test and the test should pass. |
| 1160 | glEnable(GL_DEPTH_TEST); |
| 1161 | glDepthFunc(GL_EQUAL); |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 1162 | drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f); |
Jamie Madill | 196ca36 | 2016-07-12 10:54:04 -0400 | [diff] [blame] | 1163 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red); |
| 1164 | |
| 1165 | ASSERT_GL_NO_ERROR(); |
| 1166 | } |
| 1167 | |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1168 | // Test resolving a multisampled stencil buffer. |
| 1169 | TEST_P(BlitFramebufferTest, MultisampleStencil) |
| 1170 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 1171 | ANGLE_SKIP_TEST_IF(!extensionEnabled("EXT_framebuffer_blit")); |
| 1172 | |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1173 | // Incorrect rendering results seen on AMD Windows OpenGL. http://anglebug.com/2486 |
| 1174 | ANGLE_SKIP_TEST_IF(IsAMD() && IsOpenGL() && IsWindows()); |
| 1175 | |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1176 | GLRenderbuffer renderbuf; |
| 1177 | glBindRenderbuffer(GL_RENDERBUFFER, renderbuf.get()); |
| 1178 | glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_STENCIL_INDEX8, 256, 256); |
| 1179 | |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 1180 | ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red()); |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1181 | |
| 1182 | GLFramebuffer framebuffer; |
| 1183 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get()); |
| 1184 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, |
| 1185 | renderbuf.get()); |
| 1186 | |
| 1187 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 1188 | |
| 1189 | // fill the stencil buffer with 0x1 |
| 1190 | glStencilFunc(GL_ALWAYS, 0x1, 0xFF); |
| 1191 | glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); |
| 1192 | glEnable(GL_STENCIL_TEST); |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 1193 | drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f); |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1194 | |
| 1195 | GLTexture destColorbuf; |
| 1196 | glBindTexture(GL_TEXTURE_2D, destColorbuf.get()); |
| 1197 | glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 256, 256); |
| 1198 | |
| 1199 | GLRenderbuffer destRenderbuf; |
| 1200 | glBindRenderbuffer(GL_RENDERBUFFER, destRenderbuf.get()); |
| 1201 | glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 256, 256); |
| 1202 | |
| 1203 | GLFramebuffer resolved; |
| 1204 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolved.get()); |
| 1205 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 1206 | destColorbuf.get(), 0); |
| 1207 | glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, |
| 1208 | destRenderbuf.get()); |
| 1209 | |
| 1210 | glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer.get()); |
| 1211 | glBlitFramebuffer(0, 0, 256, 256, 0, 0, 256, 256, GL_STENCIL_BUFFER_BIT, GL_NEAREST); |
| 1212 | |
| 1213 | glBindFramebuffer(GL_FRAMEBUFFER, resolved.get()); |
| 1214 | |
| 1215 | ASSERT_GL_NO_ERROR(); |
| 1216 | |
| 1217 | // Clear to green |
| 1218 | glClearColor(0.0f, 1.0f, 0.0f, 1.0f); |
| 1219 | glClear(GL_COLOR_BUFFER_BIT); |
| 1220 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 1221 | |
| 1222 | // Draw red if the stencil is 0x1, which should be true after the blit/resolve. |
| 1223 | glStencilFunc(GL_EQUAL, 0x1, 0xFF); |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 1224 | drawQuad(drawRed.get(), essl3_shaders::PositionAttrib(), 0.5f); |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1225 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red); |
| 1226 | |
| 1227 | ASSERT_GL_NO_ERROR(); |
| 1228 | } |
| 1229 | |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1230 | // Blit an SRGB framebuffer and scale it. |
| 1231 | TEST_P(BlitFramebufferTest, BlitSRGBToRGBAndScale) |
| 1232 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 1233 | ANGLE_SKIP_TEST_IF(!extensionEnabled("EXT_framebuffer_blit")); |
| 1234 | |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1235 | constexpr const GLsizei kWidth = 256; |
| 1236 | constexpr const GLsizei kHeight = 256; |
| 1237 | |
| 1238 | GLRenderbuffer sourceRBO, targetRBO; |
| 1239 | GLFramebuffer sourceFBO, targetFBO; |
| 1240 | initColorFBOWithCheckerPattern(&sourceFBO, &sourceRBO, GL_SRGB8_ALPHA8, kWidth * 2, |
| 1241 | kHeight * 2); |
| 1242 | initColorFBO(&targetFBO, &targetRBO, GL_RGBA8, kWidth, kHeight); |
| 1243 | |
| 1244 | EXPECT_GL_NO_ERROR(); |
| 1245 | |
| 1246 | glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO); |
| 1247 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO); |
| 1248 | |
| 1249 | glViewport(0, 0, kWidth, kHeight); |
| 1250 | |
| 1251 | glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 1252 | glClear(GL_COLOR_BUFFER_BIT); |
| 1253 | |
| 1254 | // Scale down without flipping. |
| 1255 | glBlitFramebuffer(0, 0, kWidth * 2, kHeight * 2, 0, 0, kWidth, 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::red); |
| 1263 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::green); |
| 1264 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::red); |
| 1265 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::green); |
| 1266 | |
| 1267 | glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO); |
| 1268 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO); |
| 1269 | |
| 1270 | glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 1271 | glClear(GL_COLOR_BUFFER_BIT); |
| 1272 | |
| 1273 | // Scale down and flip in the X direction. |
| 1274 | glBlitFramebuffer(0, 0, kWidth * 2, kHeight * 2, kWidth, 0, 0, kHeight, GL_COLOR_BUFFER_BIT, |
| 1275 | GL_NEAREST); |
| 1276 | |
| 1277 | EXPECT_GL_NO_ERROR(); |
| 1278 | |
| 1279 | glBindFramebuffer(GL_FRAMEBUFFER, targetFBO); |
| 1280 | |
| 1281 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::green); |
| 1282 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::red); |
| 1283 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::green); |
| 1284 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::red); |
| 1285 | } |
| 1286 | |
| 1287 | // Blit a subregion of an SRGB framebuffer to an RGB framebuffer. |
| 1288 | TEST_P(BlitFramebufferTest, PartialBlitSRGBToRGB) |
| 1289 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 1290 | ANGLE_SKIP_TEST_IF(!extensionEnabled("EXT_framebuffer_blit")); |
| 1291 | |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1292 | constexpr const GLsizei kWidth = 256; |
| 1293 | constexpr const GLsizei kHeight = 256; |
| 1294 | |
| 1295 | GLRenderbuffer sourceRBO, targetRBO; |
| 1296 | GLFramebuffer sourceFBO, targetFBO; |
| 1297 | initColorFBOWithCheckerPattern(&sourceFBO, &sourceRBO, GL_SRGB8_ALPHA8, kWidth * 2, |
| 1298 | kHeight * 2); |
| 1299 | initColorFBO(&targetFBO, &targetRBO, GL_RGBA8, kWidth, kHeight); |
| 1300 | |
| 1301 | EXPECT_GL_NO_ERROR(); |
| 1302 | |
| 1303 | glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO); |
| 1304 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO); |
| 1305 | |
| 1306 | glViewport(0, 0, kWidth, kHeight); |
| 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 without flipping. |
| 1312 | glBlitFramebuffer(kWidth, kHeight, kWidth * 2, kHeight * 2, 0, 0, kWidth, kHeight, |
| 1313 | GL_COLOR_BUFFER_BIT, 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::red); |
| 1320 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::red); |
| 1321 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::red); |
| 1322 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::red); |
| 1323 | |
| 1324 | glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO); |
| 1325 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO); |
| 1326 | |
| 1327 | glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
| 1328 | glClear(GL_COLOR_BUFFER_BIT); |
| 1329 | |
| 1330 | // Blit a part of the source FBO and flip in the X direction. |
| 1331 | glBlitFramebuffer(kWidth * 2, 0, kWidth, kHeight, kWidth, 0, 0, kHeight, GL_COLOR_BUFFER_BIT, |
| 1332 | GL_NEAREST); |
| 1333 | |
| 1334 | EXPECT_GL_NO_ERROR(); |
| 1335 | |
| 1336 | glBindFramebuffer(GL_FRAMEBUFFER, targetFBO); |
| 1337 | |
| 1338 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::green); |
| 1339 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::green); |
| 1340 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::green); |
| 1341 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::green); |
| 1342 | } |
| 1343 | |
| 1344 | // Blit an SRGB framebuffer with an oversized source area (parts outside the source area should be |
| 1345 | // clipped out). |
| 1346 | TEST_P(BlitFramebufferTest, BlitSRGBToRGBOversizedSourceArea) |
| 1347 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 1348 | ANGLE_SKIP_TEST_IF(!extensionEnabled("EXT_framebuffer_blit")); |
| 1349 | |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1350 | constexpr const GLsizei kWidth = 256; |
| 1351 | constexpr const GLsizei kHeight = 256; |
| 1352 | |
| 1353 | GLRenderbuffer sourceRBO, targetRBO; |
| 1354 | GLFramebuffer sourceFBO, targetFBO; |
| 1355 | initColorFBOWithCheckerPattern(&sourceFBO, &sourceRBO, GL_SRGB8_ALPHA8, kWidth, kHeight); |
| 1356 | initColorFBO(&targetFBO, &targetRBO, GL_RGBA8, kWidth, kHeight); |
| 1357 | |
| 1358 | EXPECT_GL_NO_ERROR(); |
| 1359 | |
| 1360 | glViewport(0, 0, kWidth, kHeight); |
| 1361 | |
| 1362 | glBindFramebuffer(GL_READ_FRAMEBUFFER, sourceFBO); |
| 1363 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, targetFBO); |
| 1364 | |
| 1365 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
| 1366 | glClear(GL_COLOR_BUFFER_BIT); |
| 1367 | |
| 1368 | // Blit so that the source area gets placed at the center of the target FBO. |
| 1369 | // The width of the source area is 1/4 of the width of the target FBO. |
| 1370 | glBlitFramebuffer(-3 * kWidth / 2, -3 * kHeight / 2, 5 * kWidth / 2, 5 * kHeight / 2, 0, 0, |
| 1371 | kWidth, kHeight, GL_COLOR_BUFFER_BIT, GL_NEAREST); |
| 1372 | |
| 1373 | EXPECT_GL_NO_ERROR(); |
| 1374 | |
| 1375 | glBindFramebuffer(GL_FRAMEBUFFER, targetFBO); |
| 1376 | |
| 1377 | // Source FBO colors can be found in the middle of the target FBO. |
| 1378 | EXPECT_PIXEL_COLOR_EQ(7 * kWidth / 16, 7 * kHeight / 16, GLColor::red); |
| 1379 | EXPECT_PIXEL_COLOR_EQ(9 * kWidth / 16, 7 * kHeight / 16, GLColor::green); |
| 1380 | EXPECT_PIXEL_COLOR_EQ(9 * kWidth / 16, 9 * kHeight / 16, GLColor::red); |
| 1381 | EXPECT_PIXEL_COLOR_EQ(7 * kWidth / 16, 9 * kHeight / 16, GLColor::green); |
| 1382 | |
| 1383 | // Clear color should remain around the edges of the target FBO (WebGL 2.0 spec explicitly |
| 1384 | // requires this and ANGLE is expected to follow that). |
| 1385 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, kHeight / 4, GLColor::black); |
| 1386 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, kHeight / 4, GLColor::black); |
| 1387 | EXPECT_PIXEL_COLOR_EQ(3 * kWidth / 4, 3 * kHeight / 4, GLColor::black); |
| 1388 | EXPECT_PIXEL_COLOR_EQ(kWidth / 4, 3 * kHeight / 4, GLColor::black); |
| 1389 | } |
| 1390 | |
Olli Etuaho | 9aef81c | 2018-04-30 14:56:15 +0300 | [diff] [blame] | 1391 | // Test blitFramebuffer size overflow checks. WebGL 2.0 spec section 5.41. We do validation for |
| 1392 | // overflows also in non-WebGL mode to avoid triggering driver bugs. |
| 1393 | TEST_P(BlitFramebufferTest, BlitFramebufferSizeOverflow) |
| 1394 | { |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 1395 | ANGLE_SKIP_TEST_IF(!extensionEnabled("EXT_framebuffer_blit")); |
| 1396 | |
Olli Etuaho | 9aef81c | 2018-04-30 14:56:15 +0300 | [diff] [blame] | 1397 | GLTexture textures[2]; |
| 1398 | glBindTexture(GL_TEXTURE_2D, textures[0]); |
| 1399 | glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4); |
| 1400 | glBindTexture(GL_TEXTURE_2D, textures[1]); |
| 1401 | glTexStorage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 4, 4); |
| 1402 | |
| 1403 | GLFramebuffer framebuffers[2]; |
| 1404 | glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffers[0]); |
| 1405 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffers[1]); |
| 1406 | |
| 1407 | ASSERT_GL_NO_ERROR(); |
| 1408 | |
| 1409 | glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0], |
| 1410 | 0); |
| 1411 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[1], |
| 1412 | 0); |
| 1413 | ASSERT_GL_NO_ERROR(); |
| 1414 | |
| 1415 | // srcX |
| 1416 | glBlitFramebuffer(-1, 0, std::numeric_limits<GLint>::max(), 4, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT, |
| 1417 | GL_NEAREST); |
| 1418 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1419 | glBlitFramebuffer(std::numeric_limits<GLint>::max(), 0, -1, 4, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT, |
| 1420 | GL_NEAREST); |
| 1421 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1422 | |
| 1423 | // srcY |
| 1424 | glBlitFramebuffer(0, -1, 4, std::numeric_limits<GLint>::max(), 0, 0, 4, 4, GL_COLOR_BUFFER_BIT, |
| 1425 | GL_NEAREST); |
| 1426 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1427 | glBlitFramebuffer(0, std::numeric_limits<GLint>::max(), 4, -1, 0, 0, 4, 4, GL_COLOR_BUFFER_BIT, |
| 1428 | GL_NEAREST); |
| 1429 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1430 | |
| 1431 | // dstX |
| 1432 | glBlitFramebuffer(0, 0, 4, 4, -1, 0, std::numeric_limits<GLint>::max(), 4, GL_COLOR_BUFFER_BIT, |
| 1433 | GL_NEAREST); |
| 1434 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1435 | glBlitFramebuffer(0, 0, 4, 4, std::numeric_limits<GLint>::max(), 0, -1, 4, GL_COLOR_BUFFER_BIT, |
| 1436 | GL_NEAREST); |
| 1437 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1438 | |
| 1439 | // dstY |
| 1440 | glBlitFramebuffer(0, 0, 4, 4, 0, -1, 4, std::numeric_limits<GLint>::max(), GL_COLOR_BUFFER_BIT, |
| 1441 | GL_NEAREST); |
| 1442 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1443 | glBlitFramebuffer(0, 0, 4, 4, 0, std::numeric_limits<GLint>::max(), 4, -1, GL_COLOR_BUFFER_BIT, |
| 1444 | GL_NEAREST); |
| 1445 | EXPECT_GL_ERROR(GL_INVALID_VALUE); |
| 1446 | } |
| 1447 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 1448 | // 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] | 1449 | ANGLE_INSTANTIATE_TEST(BlitFramebufferANGLETest, |
| 1450 | ES2_D3D9(), |
| 1451 | ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE), |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 1452 | ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE), |
| 1453 | ES2_OPENGL(), |
Luc Ferron | af88362 | 2018-06-08 15:57:31 -0400 | [diff] [blame] | 1454 | ES3_OPENGL(), |
| 1455 | ES2_VULKAN()); |
Jamie Madill | 78a9c73 | 2016-07-15 11:22:43 -0400 | [diff] [blame] | 1456 | |
Olli Etuaho | de27959 | 2018-04-26 12:25:13 +0300 | [diff] [blame] | 1457 | // We're specifically testing GL 4.4 and GL 4.3 since on versions earlier than 4.4 FramebufferGL |
| 1458 | // takes a different path for blitting SRGB textures. |
| 1459 | ANGLE_INSTANTIATE_TEST(BlitFramebufferTest, ES3_D3D11(), ES3_OPENGL(4, 4), ES3_OPENGL(4, 3)); |