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 | // |
Jamie Madill | 1fbc59f | 2016-02-24 15:25:51 -0500 | [diff] [blame] | 6 | // Framebuffer tests: |
| 7 | // Various tests related for Frambuffers. |
| 8 | // |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 9 | |
Jonah Ryan-Davis | beb0eb2 | 2019-06-14 15:10:33 -0400 | [diff] [blame] | 10 | #include "platform/FeaturesD3D.h" |
Corentin Wallez | d3970de | 2015-05-14 11:07:48 -0400 | [diff] [blame] | 11 | #include "test_utils/ANGLETest.h" |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 12 | #include "test_utils/gl_raii.h" |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 13 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 14 | using namespace angle; |
Austin Kinross | 18b931d | 2014-09-29 12:58:31 -0700 | [diff] [blame] | 15 | |
Geoff Lang | 857c09d | 2017-05-16 15:55:04 -0400 | [diff] [blame] | 16 | namespace |
| 17 | { |
| 18 | |
| 19 | void ExpectFramebufferCompleteOrUnsupported(GLenum binding) |
| 20 | { |
| 21 | GLenum status = glCheckFramebufferStatus(binding); |
| 22 | EXPECT_TRUE(status == GL_FRAMEBUFFER_COMPLETE || status == GL_FRAMEBUFFER_UNSUPPORTED); |
| 23 | } |
| 24 | |
| 25 | } // anonymous namespace |
| 26 | |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 27 | class FramebufferFormatsTest : public ANGLETest |
| 28 | { |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 29 | protected: |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 30 | FramebufferFormatsTest() : mFramebuffer(0), mTexture(0), mRenderbuffer(0), mProgram(0) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 31 | { |
| 32 | setWindowWidth(128); |
| 33 | setWindowHeight(128); |
| 34 | setConfigRedBits(8); |
| 35 | setConfigGreenBits(8); |
| 36 | setConfigBlueBits(8); |
| 37 | setConfigAlphaBits(8); |
| 38 | } |
| 39 | |
| 40 | void checkBitCount(GLuint fbo, GLenum channel, GLint minBits) |
| 41 | { |
| 42 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 43 | |
| 44 | GLint bits = 0; |
| 45 | glGetIntegerv(channel, &bits); |
| 46 | |
| 47 | if (minBits == 0) |
| 48 | { |
| 49 | EXPECT_EQ(minBits, bits); |
| 50 | } |
| 51 | else |
| 52 | { |
| 53 | EXPECT_GE(bits, minBits); |
| 54 | } |
| 55 | } |
| 56 | |
Jamie Madill | 1fbc59f | 2016-02-24 15:25:51 -0500 | [diff] [blame] | 57 | void testBitCounts(GLuint fbo, |
| 58 | GLint minRedBits, |
| 59 | GLint minGreenBits, |
| 60 | GLint minBlueBits, |
| 61 | GLint minAlphaBits, |
| 62 | GLint minDepthBits, |
| 63 | GLint minStencilBits) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 64 | { |
| 65 | checkBitCount(fbo, GL_RED_BITS, minRedBits); |
| 66 | checkBitCount(fbo, GL_GREEN_BITS, minGreenBits); |
| 67 | checkBitCount(fbo, GL_BLUE_BITS, minBlueBits); |
| 68 | checkBitCount(fbo, GL_ALPHA_BITS, minAlphaBits); |
| 69 | checkBitCount(fbo, GL_DEPTH_BITS, minDepthBits); |
| 70 | checkBitCount(fbo, GL_STENCIL_BITS, minStencilBits); |
| 71 | } |
| 72 | |
Jamie Madill | 1fbc59f | 2016-02-24 15:25:51 -0500 | [diff] [blame] | 73 | void testTextureFormat(GLenum internalFormat, |
| 74 | GLint minRedBits, |
| 75 | GLint minGreenBits, |
| 76 | GLint minBlueBits, |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 77 | GLint minAlphaBits) |
| 78 | { |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 79 | glGenTextures(1, &mTexture); |
| 80 | glBindTexture(GL_TEXTURE_2D, mTexture); |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 81 | |
| 82 | if (getClientMajorVersion() >= 3) |
| 83 | { |
| 84 | glTexStorage2D(GL_TEXTURE_2D, 1, internalFormat, 1, 1); |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | glTexStorage2DEXT(GL_TEXTURE_2D, 1, internalFormat, 1, 1); |
| 89 | } |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 90 | |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 91 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mTexture, 0); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 92 | |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 93 | testBitCounts(mFramebuffer, minRedBits, minGreenBits, minBlueBits, minAlphaBits, 0, 0); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 94 | } |
| 95 | |
Jamie Madill | 1fbc59f | 2016-02-24 15:25:51 -0500 | [diff] [blame] | 96 | void testRenderbufferMultisampleFormat(int minESVersion, |
| 97 | GLenum attachmentType, |
| 98 | GLenum internalFormat) |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 99 | { |
Martin Radev | 1be913c | 2016-07-11 17:59:16 +0300 | [diff] [blame] | 100 | int clientVersion = getClientMajorVersion(); |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 101 | if (clientVersion < minESVersion) |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 102 | { |
| 103 | return; |
| 104 | } |
| 105 | |
| 106 | // Check that multisample is supported with at least two samples (minimum required is 1) |
| 107 | bool supports2Samples = false; |
| 108 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 109 | if (clientVersion == 2) |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 110 | { |
Jamie Madill | b814907 | 2019-04-30 16:14:44 -0400 | [diff] [blame] | 111 | if (IsGLExtensionEnabled("ANGLE_framebuffer_multisample")) |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 112 | { |
| 113 | int maxSamples; |
| 114 | glGetIntegerv(GL_MAX_SAMPLES_ANGLE, &maxSamples); |
| 115 | supports2Samples = maxSamples >= 2; |
| 116 | } |
| 117 | } |
| 118 | else |
| 119 | { |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 120 | assert(clientVersion >= 3); |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 121 | int maxSamples; |
| 122 | glGetIntegerv(GL_MAX_SAMPLES, &maxSamples); |
| 123 | supports2Samples = maxSamples >= 2; |
| 124 | } |
| 125 | |
| 126 | if (!supports2Samples) |
| 127 | { |
| 128 | return; |
| 129 | } |
| 130 | |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 131 | glGenRenderbuffers(1, &mRenderbuffer); |
| 132 | glBindRenderbuffer(GL_RENDERBUFFER, mRenderbuffer); |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 133 | |
| 134 | EXPECT_GL_NO_ERROR(); |
| 135 | glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, 2, internalFormat, 128, 128); |
| 136 | EXPECT_GL_NO_ERROR(); |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 137 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachmentType, GL_RENDERBUFFER, mRenderbuffer); |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 138 | EXPECT_GL_NO_ERROR(); |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 139 | } |
| 140 | |
Olli Etuaho | bc21e18 | 2016-02-23 16:04:57 +0200 | [diff] [blame] | 141 | void testZeroHeightRenderbuffer() |
| 142 | { |
| 143 | glGenRenderbuffers(1, &mRenderbuffer); |
| 144 | glBindRenderbuffer(GL_RENDERBUFFER, mRenderbuffer); |
| 145 | glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 0); |
| 146 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, |
| 147 | mRenderbuffer); |
| 148 | EXPECT_GL_NO_ERROR(); |
| 149 | } |
| 150 | |
Jamie Madill | 5cbaa3f | 2019-05-07 15:49:22 -0400 | [diff] [blame] | 151 | void testSetUp() override |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 152 | { |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 153 | glGenFramebuffers(1, &mFramebuffer); |
| 154 | glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer); |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 155 | } |
| 156 | |
Jamie Madill | 5cbaa3f | 2019-05-07 15:49:22 -0400 | [diff] [blame] | 157 | void testTearDown() override |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 158 | { |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 159 | if (mTexture != 0) |
| 160 | { |
| 161 | glDeleteTextures(1, &mTexture); |
| 162 | mTexture = 0; |
| 163 | } |
| 164 | |
| 165 | if (mRenderbuffer != 0) |
| 166 | { |
| 167 | glDeleteRenderbuffers(1, &mRenderbuffer); |
| 168 | mRenderbuffer = 0; |
| 169 | } |
| 170 | |
| 171 | if (mFramebuffer != 0) |
| 172 | { |
| 173 | glDeleteFramebuffers(1, &mFramebuffer); |
| 174 | mFramebuffer = 0; |
| 175 | } |
| 176 | |
| 177 | if (mProgram != 0) |
| 178 | { |
| 179 | glDeleteProgram(mProgram); |
| 180 | mProgram = 0; |
| 181 | } |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 182 | } |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 183 | |
| 184 | GLuint mFramebuffer; |
| 185 | GLuint mTexture; |
| 186 | GLuint mRenderbuffer; |
| 187 | GLuint mProgram; |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 188 | }; |
| 189 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 190 | TEST_P(FramebufferFormatsTest, RGBA4) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 191 | { |
Jamie Madill | b814907 | 2019-04-30 16:14:44 -0400 | [diff] [blame] | 192 | ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && |
| 193 | !IsGLExtensionEnabled("GL_EXT_texture_storage")); |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 194 | |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 195 | testTextureFormat(GL_RGBA4, 4, 4, 4, 4); |
| 196 | } |
| 197 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 198 | TEST_P(FramebufferFormatsTest, RGB565) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 199 | { |
Jamie Madill | b814907 | 2019-04-30 16:14:44 -0400 | [diff] [blame] | 200 | ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && |
| 201 | !IsGLExtensionEnabled("GL_EXT_texture_storage")); |
Geoff Lang | c4e9366 | 2017-05-01 10:45:59 -0400 | [diff] [blame] | 202 | |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 203 | testTextureFormat(GL_RGB565, 5, 6, 5, 0); |
| 204 | } |
| 205 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 206 | TEST_P(FramebufferFormatsTest, RGB8) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 207 | { |
Jamie Madill | b814907 | 2019-04-30 16:14:44 -0400 | [diff] [blame] | 208 | ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && |
| 209 | (!IsGLExtensionEnabled("GL_OES_rgb8_rgba8") || |
| 210 | !IsGLExtensionEnabled("GL_EXT_texture_storage"))); |
Geoff Lang | f34d1db | 2015-05-20 14:10:46 -0400 | [diff] [blame] | 211 | |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 212 | testTextureFormat(GL_RGB8_OES, 8, 8, 8, 0); |
| 213 | } |
| 214 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 215 | TEST_P(FramebufferFormatsTest, BGRA8) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 216 | { |
Yunchao He | 9550c60 | 2018-02-13 14:47:05 +0800 | [diff] [blame] | 217 | ANGLE_SKIP_TEST_IF( |
Jamie Madill | b814907 | 2019-04-30 16:14:44 -0400 | [diff] [blame] | 218 | !IsGLExtensionEnabled("GL_EXT_texture_format_BGRA8888") || |
| 219 | (getClientMajorVersion() < 3 && !IsGLExtensionEnabled("GL_EXT_texture_storage"))); |
Geoff Lang | f34d1db | 2015-05-20 14:10:46 -0400 | [diff] [blame] | 220 | |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 221 | testTextureFormat(GL_BGRA8_EXT, 8, 8, 8, 8); |
| 222 | } |
| 223 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 224 | TEST_P(FramebufferFormatsTest, RGBA8) |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 225 | { |
Jamie Madill | b814907 | 2019-04-30 16:14:44 -0400 | [diff] [blame] | 226 | ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3 && |
| 227 | (!IsGLExtensionEnabled("GL_OES_rgb8_rgba8") || |
| 228 | !IsGLExtensionEnabled("GL_EXT_texture_storage"))); |
Geoff Lang | f34d1db | 2015-05-20 14:10:46 -0400 | [diff] [blame] | 229 | |
Geoff Lang | b6a673a | 2014-06-05 14:19:16 -0400 | [diff] [blame] | 230 | testTextureFormat(GL_RGBA8_OES, 8, 8, 8, 8); |
| 231 | } |
| 232 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 233 | TEST_P(FramebufferFormatsTest, RenderbufferMultisample_DEPTH16) |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 234 | { |
| 235 | testRenderbufferMultisampleFormat(2, GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT16); |
| 236 | } |
| 237 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 238 | TEST_P(FramebufferFormatsTest, RenderbufferMultisample_DEPTH24) |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 239 | { |
| 240 | testRenderbufferMultisampleFormat(3, GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT24); |
| 241 | } |
| 242 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 243 | TEST_P(FramebufferFormatsTest, RenderbufferMultisample_DEPTH32F) |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 244 | { |
Yunchao He | 9550c60 | 2018-02-13 14:47:05 +0800 | [diff] [blame] | 245 | ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3); |
Geoff Lang | f34d1db | 2015-05-20 14:10:46 -0400 | [diff] [blame] | 246 | |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 247 | testRenderbufferMultisampleFormat(3, GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT32F); |
| 248 | } |
| 249 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 250 | TEST_P(FramebufferFormatsTest, RenderbufferMultisample_DEPTH24_STENCIL8) |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 251 | { |
| 252 | testRenderbufferMultisampleFormat(3, GL_DEPTH_STENCIL_ATTACHMENT, GL_DEPTH24_STENCIL8); |
| 253 | } |
| 254 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 255 | TEST_P(FramebufferFormatsTest, RenderbufferMultisample_DEPTH32F_STENCIL8) |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 256 | { |
Yunchao He | 9550c60 | 2018-02-13 14:47:05 +0800 | [diff] [blame] | 257 | ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3); |
Geoff Lang | f34d1db | 2015-05-20 14:10:46 -0400 | [diff] [blame] | 258 | |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 259 | testRenderbufferMultisampleFormat(3, GL_DEPTH_STENCIL_ATTACHMENT, GL_DEPTH32F_STENCIL8); |
| 260 | } |
| 261 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 262 | TEST_P(FramebufferFormatsTest, RenderbufferMultisample_STENCIL_INDEX8) |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 263 | { |
Geoff Lang | f34d1db | 2015-05-20 14:10:46 -0400 | [diff] [blame] | 264 | // TODO(geofflang): Figure out how to support GLSTENCIL_INDEX8 on desktop GL |
Yunchao He | 9550c60 | 2018-02-13 14:47:05 +0800 | [diff] [blame] | 265 | ANGLE_SKIP_TEST_IF(IsDesktopOpenGL()); |
Geoff Lang | f34d1db | 2015-05-20 14:10:46 -0400 | [diff] [blame] | 266 | |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 267 | testRenderbufferMultisampleFormat(2, GL_STENCIL_ATTACHMENT, GL_STENCIL_INDEX8); |
| 268 | } |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 269 | |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 270 | // Test that binding an incomplete cube map is rejected by ANGLE. |
| 271 | TEST_P(FramebufferFormatsTest, IncompleteCubeMap) |
| 272 | { |
Michael Spang | d8506c7 | 2019-01-29 15:35:09 -0500 | [diff] [blame] | 273 | // http://anglebug.com/3145 |
| 274 | ANGLE_SKIP_TEST_IF(IsFuchsia() && IsIntel() && IsVulkan()); |
| 275 | |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 276 | // First make a complete CubeMap. |
| 277 | glGenTextures(1, &mTexture); |
| 278 | glBindTexture(GL_TEXTURE_CUBE_MAP, mTexture); |
| 279 | glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 280 | nullptr); |
| 281 | glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 282 | nullptr); |
| 283 | glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 284 | nullptr); |
| 285 | glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 286 | nullptr); |
| 287 | glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 288 | nullptr); |
| 289 | glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 290 | nullptr); |
| 291 | glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 292 | glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 293 | |
| 294 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
| 295 | mTexture, 0); |
| 296 | |
| 297 | // Verify the framebuffer is complete. |
| 298 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 299 | |
| 300 | // Make the CubeMap cube-incomplete. |
| 301 | glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 302 | nullptr); |
| 303 | |
| 304 | // Verify the framebuffer is incomplete. |
| 305 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT, |
| 306 | glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 307 | |
Jamie Madill | d84b673 | 2018-09-06 15:54:35 -0400 | [diff] [blame] | 308 | ASSERT_GL_NO_ERROR(); |
| 309 | |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 310 | // Verify drawing with the incomplete framebuffer produces a GL error |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 311 | mProgram = CompileProgram(essl1_shaders::vs::Simple(), essl1_shaders::fs::Red()); |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 312 | ASSERT_NE(0u, mProgram); |
Olli Etuaho | 5804dc8 | 2018-04-13 14:11:46 +0300 | [diff] [blame] | 313 | drawQuad(mProgram, essl1_shaders::PositionAttrib(), 0.5f); |
Jamie Madill | 3215b20 | 2015-12-15 16:41:39 -0500 | [diff] [blame] | 314 | ASSERT_GL_ERROR(GL_INVALID_FRAMEBUFFER_OPERATION); |
| 315 | } |
| 316 | |
Olli Etuaho | bc21e18 | 2016-02-23 16:04:57 +0200 | [diff] [blame] | 317 | // Test that a renderbuffer with zero height but nonzero width is handled without crashes/asserts. |
| 318 | TEST_P(FramebufferFormatsTest, ZeroHeightRenderbuffer) |
| 319 | { |
Yunchao He | 9550c60 | 2018-02-13 14:47:05 +0800 | [diff] [blame] | 320 | ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3); |
Olli Etuaho | bc21e18 | 2016-02-23 16:04:57 +0200 | [diff] [blame] | 321 | |
| 322 | testZeroHeightRenderbuffer(); |
| 323 | } |
| 324 | |
Geoff Lang | 9bf86f0 | 2018-07-26 11:46:34 -0400 | [diff] [blame] | 325 | // Test to cover a bug where the read framebuffer affects the completeness of the draw framebuffer. |
| 326 | TEST_P(FramebufferFormatsTest, ReadDrawCompleteness) |
| 327 | { |
| 328 | ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3); |
| 329 | |
| 330 | GLTexture incompleteTexture; |
| 331 | glBindTexture(GL_TEXTURE_2D, incompleteTexture); |
| 332 | |
| 333 | GLFramebuffer incompleteFBO; |
| 334 | glBindFramebuffer(GL_FRAMEBUFFER, incompleteFBO); |
| 335 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, incompleteTexture, |
| 336 | 0); |
| 337 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT, |
| 338 | glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 339 | |
| 340 | GLTexture completeTexture; |
| 341 | glBindTexture(GL_TEXTURE_2D, completeTexture); |
| 342 | glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, getWindowWidth(), getWindowHeight()); |
| 343 | |
| 344 | GLFramebuffer completeFBO; |
| 345 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, completeFBO); |
| 346 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 347 | completeTexture, 0); |
| 348 | |
| 349 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT, |
| 350 | glCheckFramebufferStatus(GL_READ_FRAMEBUFFER)); |
| 351 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER)); |
| 352 | |
| 353 | ASSERT_GL_NO_ERROR(); |
| 354 | |
| 355 | // Simple draw program. |
| 356 | ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Simple(), essl1_shaders::fs::Red()); |
| 357 | |
| 358 | drawQuad(program, essl1_shaders::PositionAttrib(), 0.5f, 1.0f, true); |
| 359 | EXPECT_GL_NO_ERROR(); |
| 360 | |
| 361 | glBindFramebuffer(GL_READ_FRAMEBUFFER, completeFBO); |
| 362 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red); |
| 363 | } |
| 364 | |
Corentin Wallez | 57e6d50 | 2016-12-09 14:46:39 -0500 | [diff] [blame] | 365 | class FramebufferTest_ES3 : public ANGLETest |
Jamie Madill | b980c56 | 2018-11-27 11:34:27 -0500 | [diff] [blame] | 366 | {}; |
Jamie Madill | 1fbc59f | 2016-02-24 15:25:51 -0500 | [diff] [blame] | 367 | |
| 368 | // Covers invalidating an incomplete framebuffer. This should be a no-op, but should not error. |
Corentin Wallez | 57e6d50 | 2016-12-09 14:46:39 -0500 | [diff] [blame] | 369 | TEST_P(FramebufferTest_ES3, InvalidateIncomplete) |
Jamie Madill | 1fbc59f | 2016-02-24 15:25:51 -0500 | [diff] [blame] | 370 | { |
Geoff Lang | 857c09d | 2017-05-16 15:55:04 -0400 | [diff] [blame] | 371 | GLFramebuffer framebuffer; |
| 372 | GLRenderbuffer renderbuffer; |
| 373 | |
| 374 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
| 375 | glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer); |
| 376 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer); |
Jamie Madill | 1fbc59f | 2016-02-24 15:25:51 -0500 | [diff] [blame] | 377 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT, |
| 378 | glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 379 | |
| 380 | std::vector<GLenum> attachments; |
| 381 | attachments.push_back(GL_COLOR_ATTACHMENT0); |
| 382 | |
| 383 | glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, attachments.data()); |
| 384 | EXPECT_GL_NO_ERROR(); |
| 385 | } |
| 386 | |
Corentin Wallez | 57e6d50 | 2016-12-09 14:46:39 -0500 | [diff] [blame] | 387 | // Test that the framebuffer state tracking robustly handles a depth-only attachment being set |
| 388 | // as a depth-stencil attachment. It is equivalent to detaching the depth-stencil attachment. |
| 389 | TEST_P(FramebufferTest_ES3, DepthOnlyAsDepthStencil) |
| 390 | { |
Geoff Lang | 857c09d | 2017-05-16 15:55:04 -0400 | [diff] [blame] | 391 | GLFramebuffer framebuffer; |
| 392 | GLRenderbuffer renderbuffer; |
| 393 | |
| 394 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
| 395 | glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer); |
Corentin Wallez | 57e6d50 | 2016-12-09 14:46:39 -0500 | [diff] [blame] | 396 | glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 4, 4); |
| 397 | |
| 398 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, |
Geoff Lang | 857c09d | 2017-05-16 15:55:04 -0400 | [diff] [blame] | 399 | renderbuffer); |
Corentin Wallez | 57e6d50 | 2016-12-09 14:46:39 -0500 | [diff] [blame] | 400 | EXPECT_GLENUM_NE(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 401 | } |
| 402 | |
Geoff Lang | 857c09d | 2017-05-16 15:55:04 -0400 | [diff] [blame] | 403 | // Test that the framebuffer correctly returns that it is not complete if invalid texture mip levels |
| 404 | // are bound |
| 405 | TEST_P(FramebufferTest_ES3, TextureAttachmentMipLevels) |
| 406 | { |
| 407 | GLFramebuffer framebuffer; |
| 408 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
| 409 | |
| 410 | GLTexture texture; |
| 411 | glBindTexture(GL_TEXTURE_2D, texture); |
| 412 | |
| 413 | // Create a complete mip chain in mips 1 to 3 |
| 414 | glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 415 | glTexImage2D(GL_TEXTURE_2D, 2, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 416 | glTexImage2D(GL_TEXTURE_2D, 3, GL_RGBA8, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 417 | |
| 418 | // Create another complete mip chain in mips 4 to 5 |
| 419 | glTexImage2D(GL_TEXTURE_2D, 4, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 420 | glTexImage2D(GL_TEXTURE_2D, 5, GL_RGBA8, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 421 | |
| 422 | // Create a non-complete mip chain in mip 6 |
| 423 | glTexImage2D(GL_TEXTURE_2D, 6, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 424 | |
| 425 | // Incomplete, mipLevel != baseLevel and texture is not mip complete |
| 426 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 1); |
| 427 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT, |
| 428 | glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 429 | |
| 430 | // Complete, mipLevel == baseLevel |
| 431 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1); |
| 432 | ExpectFramebufferCompleteOrUnsupported(GL_FRAMEBUFFER); |
| 433 | |
| 434 | // Complete, mipLevel != baseLevel but texture is now mip complete |
| 435 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 2); |
| 436 | ExpectFramebufferCompleteOrUnsupported(GL_FRAMEBUFFER); |
| 437 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 3); |
| 438 | ExpectFramebufferCompleteOrUnsupported(GL_FRAMEBUFFER); |
| 439 | |
| 440 | // Incomplete, attached level below the base level |
| 441 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 2); |
| 442 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 1); |
| 443 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT, |
| 444 | glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 445 | |
| 446 | // Incomplete, attached level is beyond effective max level |
| 447 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 4); |
| 448 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT, |
| 449 | glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 450 | |
| 451 | // Complete, mipLevel == baseLevel |
| 452 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 4); |
| 453 | ExpectFramebufferCompleteOrUnsupported(GL_FRAMEBUFFER); |
| 454 | |
| 455 | // Complete, mipLevel != baseLevel but texture is now mip complete |
| 456 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 5); |
| 457 | ExpectFramebufferCompleteOrUnsupported(GL_FRAMEBUFFER); |
| 458 | |
| 459 | // Complete, mipLevel == baseLevel |
| 460 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 6); |
| 461 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 6); |
| 462 | ExpectFramebufferCompleteOrUnsupported(GL_FRAMEBUFFER); |
| 463 | } |
| 464 | |
Shahbaz Youssefi | dbb18b5 | 2020-06-05 15:23:17 -0400 | [diff] [blame] | 465 | TEST_P(FramebufferTest_ES3, TextureAttachmentMipLevelsReadBack) |
| 466 | { |
Shahbaz Youssefi | dbb18b5 | 2020-06-05 15:23:17 -0400 | [diff] [blame] | 467 | GLFramebuffer framebuffer; |
| 468 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
| 469 | |
| 470 | GLTexture texture; |
| 471 | glBindTexture(GL_TEXTURE_2D, texture); |
| 472 | |
| 473 | const std::array<GLColor, 2 * 2> mip0Data = {GLColor::red, GLColor::red, GLColor::red, |
| 474 | GLColor::red}; |
| 475 | const std::array<GLColor, 1 * 1> mip1Data = {GLColor::green}; |
| 476 | |
| 477 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, mip0Data.data()); |
| 478 | glTexImage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, mip1Data.data()); |
| 479 | |
| 480 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 1); |
| 481 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 1); |
| 482 | EXPECT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER); |
| 483 | |
| 484 | glClearColor(0, 0, 1.0f, 1.0f); |
| 485 | glClear(GL_COLOR_BUFFER_BIT); |
| 486 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue); |
| 487 | } |
| 488 | |
Martin Radev | d178aa4 | 2017-07-13 14:03:22 +0300 | [diff] [blame] | 489 | // Test that passing an attachment COLOR_ATTACHMENTm where m is equal to MAX_COLOR_ATTACHMENTS |
| 490 | // generates an INVALID_OPERATION. |
| 491 | // OpenGL ES Version 3.0.5 (November 3, 2016), 4.4.2.4 Attaching Texture Images to a Framebuffer, p. |
| 492 | // 208 |
| 493 | TEST_P(FramebufferTest_ES3, ColorAttachmentIndexOutOfBounds) |
| 494 | { |
| 495 | GLFramebuffer framebuffer; |
| 496 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get()); |
| 497 | |
| 498 | GLint maxColorAttachments = 0; |
| 499 | glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments); |
| 500 | GLenum attachment = static_cast<GLenum>(maxColorAttachments + GL_COLOR_ATTACHMENT0); |
| 501 | |
| 502 | GLTexture texture; |
| 503 | glBindTexture(GL_TEXTURE_2D, texture.get()); |
| 504 | glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, 1, 1); |
| 505 | glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, texture.get(), 0); |
| 506 | EXPECT_GL_ERROR(GL_INVALID_OPERATION); |
| 507 | } |
| 508 | |
Jamie Madill | a0016b7 | 2017-07-14 14:30:46 -0400 | [diff] [blame] | 509 | // Check that depth-only attachments report the correct number of samples. |
| 510 | TEST_P(FramebufferTest_ES3, MultisampleDepthOnly) |
| 511 | { |
| 512 | GLRenderbuffer renderbuffer; |
| 513 | glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer); |
| 514 | glRenderbufferStorageMultisample(GL_RENDERBUFFER, 2, GL_DEPTH_COMPONENT24, 32, 32); |
| 515 | |
| 516 | GLFramebuffer framebuffer; |
| 517 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
| 518 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbuffer); |
| 519 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 520 | EXPECT_GL_NO_ERROR(); |
| 521 | |
| 522 | GLint samples = 0; |
| 523 | glGetIntegerv(GL_SAMPLES, &samples); |
| 524 | EXPECT_GL_NO_ERROR(); |
| 525 | EXPECT_GE(samples, 2); |
| 526 | } |
| 527 | |
Jeff Gilbert | 8f8edd6 | 2017-10-31 14:26:30 -0700 | [diff] [blame] | 528 | // Check that we only compare width and height of attachments, not depth. |
| 529 | TEST_P(FramebufferTest_ES3, AttachmentWith3DLayers) |
| 530 | { |
| 531 | GLTexture texA; |
| 532 | glBindTexture(GL_TEXTURE_2D, texA); |
| 533 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 4, 4, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 534 | |
| 535 | GLTexture texB; |
| 536 | glBindTexture(GL_TEXTURE_3D, texB); |
| 537 | glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA8, 4, 4, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 538 | |
| 539 | GLFramebuffer framebuffer; |
| 540 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
| 541 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texA, 0); |
| 542 | glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, texB, 0, 0); |
| 543 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 544 | EXPECT_GL_NO_ERROR(); |
| 545 | } |
| 546 | |
Olli Etuaho | dbce1f8 | 2018-09-19 15:32:17 +0300 | [diff] [blame] | 547 | // Test that clearing the stencil buffer when the framebuffer only has a color attachment does not |
| 548 | // crash. |
| 549 | TEST_P(FramebufferTest_ES3, ClearNonexistentStencil) |
| 550 | { |
| 551 | GLRenderbuffer rbo; |
| 552 | glBindRenderbuffer(GL_RENDERBUFFER, rbo); |
| 553 | glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 1); |
| 554 | |
| 555 | GLFramebuffer fbo; |
| 556 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 557 | glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); |
| 558 | |
| 559 | GLint clearValue = 0; |
| 560 | glClearBufferiv(GL_STENCIL, 0, &clearValue); |
| 561 | |
| 562 | // There's no error specified for clearing nonexistent buffers, it's simply a no-op. |
| 563 | EXPECT_GL_NO_ERROR(); |
| 564 | } |
| 565 | |
| 566 | // Test that clearing the depth buffer when the framebuffer only has a color attachment does not |
| 567 | // crash. |
| 568 | TEST_P(FramebufferTest_ES3, ClearNonexistentDepth) |
| 569 | { |
| 570 | GLRenderbuffer rbo; |
| 571 | glBindRenderbuffer(GL_RENDERBUFFER, rbo); |
| 572 | glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 1); |
| 573 | |
| 574 | GLFramebuffer fbo; |
| 575 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 576 | glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); |
| 577 | |
| 578 | GLfloat clearValue = 0.0f; |
| 579 | glClearBufferfv(GL_DEPTH, 0, &clearValue); |
| 580 | |
| 581 | // There's no error specified for clearing nonexistent buffers, it's simply a no-op. |
| 582 | EXPECT_GL_NO_ERROR(); |
| 583 | } |
| 584 | |
| 585 | // Test that clearing a nonexistent color attachment does not crash. |
| 586 | TEST_P(FramebufferTest_ES3, ClearNonexistentColor) |
| 587 | { |
| 588 | GLRenderbuffer rbo; |
| 589 | glBindRenderbuffer(GL_RENDERBUFFER, rbo); |
| 590 | glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 1); |
| 591 | |
| 592 | GLFramebuffer fbo; |
| 593 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 594 | glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); |
| 595 | |
| 596 | std::vector<GLfloat> clearValue = {{0.0f, 1.0f, 0.0f, 1.0f}}; |
| 597 | glClearBufferfv(GL_COLOR, 1, clearValue.data()); |
| 598 | |
| 599 | // There's no error specified for clearing nonexistent buffers, it's simply a no-op. |
| 600 | EXPECT_GL_NO_ERROR(); |
| 601 | } |
| 602 | |
| 603 | // Test that clearing the depth and stencil buffers when the framebuffer only has a color attachment |
| 604 | // does not crash. |
| 605 | TEST_P(FramebufferTest_ES3, ClearNonexistentDepthStencil) |
| 606 | { |
| 607 | GLRenderbuffer rbo; |
| 608 | glBindRenderbuffer(GL_RENDERBUFFER, rbo); |
| 609 | glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 1); |
| 610 | |
| 611 | GLFramebuffer fbo; |
| 612 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 613 | glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); |
| 614 | |
| 615 | glClearBufferfi(GL_DEPTH_STENCIL, 0, 0.0f, 0); |
| 616 | |
| 617 | // There's no error specified for clearing nonexistent buffers, it's simply a no-op. |
| 618 | EXPECT_GL_NO_ERROR(); |
| 619 | } |
| 620 | |
Olli Etuaho | 4ebd8f3 | 2018-09-20 11:12:46 +0300 | [diff] [blame] | 621 | // Test that clearing a color attachment that has been deleted doesn't crash. |
| 622 | TEST_P(FramebufferTest_ES3, ClearDeletedAttachment) |
| 623 | { |
| 624 | // An INVALID_FRAMEBUFFER_OPERATION error was seen in this test on Mac, not sure where it might |
| 625 | // be originating from. http://anglebug.com/2834 |
| 626 | ANGLE_SKIP_TEST_IF(IsOSX() && IsOpenGL()); |
| 627 | |
| 628 | GLFramebuffer fbo; |
| 629 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 630 | |
| 631 | // There used to be a bug where some draw buffer state used to remain set even after the |
| 632 | // attachment was detached via deletion. That's why we create, attach and delete this RBO here. |
| 633 | GLuint rbo = 0u; |
| 634 | glGenRenderbuffers(1, &rbo); |
| 635 | glBindRenderbuffer(GL_RENDERBUFFER, rbo); |
| 636 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); |
| 637 | glDeleteRenderbuffers(1, &rbo); |
| 638 | |
| 639 | // There needs to be at least one color attachment to prevent early out from the clear calls. |
| 640 | GLRenderbuffer rbo2; |
| 641 | glBindRenderbuffer(GL_RENDERBUFFER, rbo2); |
| 642 | glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 1, 1); |
| 643 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER, rbo2); |
| 644 | |
| 645 | ASSERT_GL_NO_ERROR(); |
| 646 | |
| 647 | // There's no error specified for clearing nonexistent buffers, it's simply a no-op, so we |
| 648 | // expect no GL errors below. |
| 649 | std::array<GLfloat, 4> floatClearValue = {0.0f, 0.0f, 0.0f, 0.0f}; |
| 650 | glClearBufferfv(GL_COLOR, 0, floatClearValue.data()); |
| 651 | EXPECT_GL_NO_ERROR(); |
| 652 | std::array<GLuint, 4> uintClearValue = {0u, 0u, 0u, 0u}; |
| 653 | glClearBufferuiv(GL_COLOR, 0, uintClearValue.data()); |
| 654 | EXPECT_GL_NO_ERROR(); |
| 655 | std::array<GLint, 4> intClearValue = {0, 0, 0, 0}; |
| 656 | glClearBufferiv(GL_COLOR, 0, intClearValue.data()); |
| 657 | EXPECT_GL_NO_ERROR(); |
| 658 | } |
| 659 | |
Tim Van Patten | e600ac2 | 2019-10-04 14:31:57 -0600 | [diff] [blame] | 660 | // Test that resizing the color attachment is handled correctly. |
| 661 | TEST_P(FramebufferTest_ES3, ResizeColorAttachmentSmallToLarge) |
| 662 | { |
| 663 | GLFramebuffer fbo; |
| 664 | GLTexture smallTexture; |
| 665 | GLTexture largeTexture; |
| 666 | |
| 667 | ANGLE_GL_PROGRAM(greenProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Green()); |
| 668 | ANGLE_GL_PROGRAM(blueProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Blue()); |
| 669 | |
| 670 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 671 | |
| 672 | // Bind the small texture |
| 673 | glBindTexture(GL_TEXTURE_2D, smallTexture); |
| 674 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth() / 2, getWindowHeight() / 2, 0, GL_RGBA, |
| 675 | GL_UNSIGNED_BYTE, nullptr); |
| 676 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 677 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 678 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, smallTexture, 0); |
| 679 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 680 | |
| 681 | // Draw to FBO backed by the small texture |
| 682 | glUseProgram(greenProgram); |
| 683 | drawQuad(greenProgram.get(), std::string(essl1_shaders::PositionAttrib()), 0.0f); |
| 684 | ASSERT_GL_NO_ERROR(); |
| 685 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 686 | EXPECT_PIXEL_COLOR_EQ((getWindowWidth() / 2) - 1, (getWindowHeight() / 2) - 1, GLColor::green); |
| 687 | |
| 688 | // Change the attachment to the larger texture that fills the window |
| 689 | glBindTexture(GL_TEXTURE_2D, largeTexture); |
| 690 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA, |
| 691 | GL_UNSIGNED_BYTE, nullptr); |
| 692 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 693 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 694 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, largeTexture, 0); |
| 695 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 696 | |
| 697 | // Draw to FBO backed by the large texture |
| 698 | glUseProgram(blueProgram); |
| 699 | drawQuad(blueProgram.get(), std::string(essl1_shaders::PositionAttrib()), 0.0f); |
| 700 | ASSERT_GL_NO_ERROR(); |
| 701 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue); |
| 702 | EXPECT_PIXEL_COLOR_EQ(getWindowWidth() - 1, getWindowHeight() - 1, GLColor::blue); |
| 703 | } |
| 704 | |
| 705 | // Test that resizing the color attachment is handled correctly. |
| 706 | TEST_P(FramebufferTest_ES3, ResizeColorAttachmentLargeToSmall) |
| 707 | { |
| 708 | GLFramebuffer fbo; |
| 709 | GLTexture smallTexture; |
| 710 | GLTexture largeTexture; |
| 711 | |
| 712 | ANGLE_GL_PROGRAM(greenProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Green()); |
| 713 | ANGLE_GL_PROGRAM(blueProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Blue()); |
| 714 | |
| 715 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 716 | |
| 717 | // Bind the large texture |
| 718 | glBindTexture(GL_TEXTURE_2D, largeTexture); |
| 719 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA, |
| 720 | GL_UNSIGNED_BYTE, nullptr); |
| 721 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 722 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 723 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, largeTexture, 0); |
| 724 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 725 | |
| 726 | // Draw to FBO backed by the large texture |
| 727 | glUseProgram(blueProgram); |
| 728 | drawQuad(blueProgram.get(), std::string(essl1_shaders::PositionAttrib()), 0.0f); |
| 729 | ASSERT_GL_NO_ERROR(); |
| 730 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue); |
| 731 | EXPECT_PIXEL_COLOR_EQ(getWindowWidth() - 1, getWindowHeight() - 1, GLColor::blue); |
| 732 | |
| 733 | // Change the attachment to the smaller texture |
| 734 | glBindTexture(GL_TEXTURE_2D, smallTexture); |
| 735 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth() / 2, getWindowHeight() / 2, 0, GL_RGBA, |
| 736 | GL_UNSIGNED_BYTE, nullptr); |
| 737 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 738 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 739 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, smallTexture, 0); |
| 740 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 741 | |
| 742 | // Draw to FBO backed by the small texture |
| 743 | glUseProgram(greenProgram); |
| 744 | drawQuad(greenProgram.get(), std::string(essl1_shaders::PositionAttrib()), 0.0f); |
| 745 | ASSERT_GL_NO_ERROR(); |
| 746 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 747 | EXPECT_PIXEL_COLOR_EQ((getWindowWidth() / 2) - 1, (getWindowHeight() / 2) - 1, GLColor::green); |
| 748 | } |
| 749 | |
| 750 | // Test that resizing the texture is handled correctly. |
| 751 | TEST_P(FramebufferTest_ES3, ResizeTextureLargeToSmall) |
| 752 | { |
| 753 | GLFramebuffer fbo; |
| 754 | GLTexture texture; |
| 755 | |
| 756 | ANGLE_GL_PROGRAM(greenProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Green()); |
| 757 | ANGLE_GL_PROGRAM(blueProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Blue()); |
| 758 | |
| 759 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 760 | |
| 761 | // Allocate a large texture |
| 762 | glBindTexture(GL_TEXTURE_2D, texture); |
| 763 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA, |
| 764 | GL_UNSIGNED_BYTE, nullptr); |
| 765 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 766 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 767 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); |
| 768 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 769 | |
| 770 | // Draw to FBO backed by the large texture |
| 771 | glUseProgram(blueProgram); |
| 772 | drawQuad(blueProgram.get(), std::string(essl1_shaders::PositionAttrib()), 0.0f); |
| 773 | ASSERT_GL_NO_ERROR(); |
| 774 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue); |
| 775 | EXPECT_PIXEL_COLOR_EQ(getWindowWidth() - 1, getWindowHeight() - 1, GLColor::blue); |
| 776 | |
| 777 | // Shrink the texture |
| 778 | glBindTexture(GL_TEXTURE_2D, texture); |
| 779 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth() / 2, getWindowHeight() / 2, 0, GL_RGBA, |
| 780 | GL_UNSIGNED_BYTE, nullptr); |
| 781 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 782 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 783 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); |
| 784 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 785 | |
| 786 | // Draw to FBO backed by the small texture |
| 787 | glUseProgram(greenProgram); |
| 788 | drawQuad(greenProgram.get(), std::string(essl1_shaders::PositionAttrib()), 0.0f); |
| 789 | ASSERT_GL_NO_ERROR(); |
| 790 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 791 | EXPECT_PIXEL_COLOR_EQ((getWindowWidth() / 2) - 1, (getWindowHeight() / 2) - 1, GLColor::green); |
| 792 | } |
| 793 | |
| 794 | // Test that resizing the texture is handled correctly. |
| 795 | TEST_P(FramebufferTest_ES3, ResizeTextureSmallToLarge) |
| 796 | { |
| 797 | GLFramebuffer fbo; |
| 798 | GLTexture texture; |
| 799 | |
| 800 | ANGLE_GL_PROGRAM(greenProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Green()); |
| 801 | ANGLE_GL_PROGRAM(blueProgram, essl1_shaders::vs::Simple(), essl1_shaders::fs::Blue()); |
| 802 | |
| 803 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 804 | |
| 805 | // Allocate a small texture |
| 806 | glBindTexture(GL_TEXTURE_2D, texture); |
| 807 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth() / 2, getWindowHeight() / 2, 0, GL_RGBA, |
| 808 | GL_UNSIGNED_BYTE, nullptr); |
| 809 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 810 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 811 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); |
| 812 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 813 | |
| 814 | // Draw to FBO backed by the large texture |
| 815 | glUseProgram(blueProgram); |
| 816 | drawQuad(blueProgram.get(), std::string(essl1_shaders::PositionAttrib()), 0.0f); |
| 817 | ASSERT_GL_NO_ERROR(); |
| 818 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue); |
| 819 | EXPECT_PIXEL_COLOR_EQ((getWindowWidth() / 2) - 1, (getWindowHeight() / 2) - 1, GLColor::blue); |
| 820 | |
| 821 | // Grow the texture |
| 822 | glBindTexture(GL_TEXTURE_2D, texture); |
| 823 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA, |
| 824 | GL_UNSIGNED_BYTE, nullptr); |
| 825 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 826 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 827 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0); |
| 828 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 829 | |
| 830 | // Draw to FBO backed by the small texture |
| 831 | glUseProgram(greenProgram); |
| 832 | drawQuad(greenProgram.get(), std::string(essl1_shaders::PositionAttrib()), 0.0f); |
| 833 | ASSERT_GL_NO_ERROR(); |
| 834 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 835 | EXPECT_PIXEL_COLOR_EQ(getWindowWidth() - 1, getWindowHeight() - 1, GLColor::green); |
| 836 | } |
| 837 | |
Shahbaz Youssefi | e28883d | 2020-01-25 23:25:43 -0500 | [diff] [blame] | 838 | // Test that fewer outputs than framebuffer attachments doesn't crash. This causes a Vulkan |
| 839 | // validation warning, but should not be fatal. |
| 840 | TEST_P(FramebufferTest_ES3, FewerShaderOutputsThanAttachments) |
| 841 | { |
| 842 | constexpr char kFS[] = R"(#version 300 es |
| 843 | precision highp float; |
| 844 | |
| 845 | layout(location = 0) out vec4 color0; |
| 846 | layout(location = 1) out vec4 color1; |
| 847 | layout(location = 2) out vec4 color2; |
| 848 | |
| 849 | void main() |
| 850 | { |
| 851 | color0 = vec4(1.0, 0.0, 0.0, 1.0); |
| 852 | color1 = vec4(0.0, 1.0, 0.0, 1.0); |
| 853 | color2 = vec4(0.0, 0.0, 1.0, 1.0); |
| 854 | } |
| 855 | )"; |
| 856 | |
| 857 | ANGLE_GL_PROGRAM(program, essl3_shaders::vs::Simple(), kFS); |
| 858 | |
| 859 | constexpr GLint kDrawBufferCount = 4; |
| 860 | |
| 861 | GLint maxDrawBuffers; |
| 862 | glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuffers); |
| 863 | ASSERT_GE(maxDrawBuffers, kDrawBufferCount); |
| 864 | |
| 865 | GLTexture textures[kDrawBufferCount]; |
| 866 | |
| 867 | for (GLint texIndex = 0; texIndex < kDrawBufferCount; ++texIndex) |
| 868 | { |
| 869 | glBindTexture(GL_TEXTURE_2D, textures[texIndex]); |
| 870 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA, |
| 871 | GL_UNSIGNED_BYTE, nullptr); |
| 872 | } |
| 873 | |
| 874 | GLenum allBufs[kDrawBufferCount] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, |
| 875 | GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3}; |
| 876 | |
| 877 | GLFramebuffer fbo; |
| 878 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo); |
| 879 | |
| 880 | // Enable all draw buffers. |
| 881 | for (GLint texIndex = 0; texIndex < kDrawBufferCount; ++texIndex) |
| 882 | { |
| 883 | glBindTexture(GL_TEXTURE_2D, textures[texIndex]); |
| 884 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + texIndex, GL_TEXTURE_2D, |
| 885 | textures[texIndex], 0); |
| 886 | } |
| 887 | glDrawBuffers(kDrawBufferCount, allBufs); |
| 888 | |
| 889 | // Draw with simple program. |
| 890 | drawQuad(program, essl3_shaders::PositionAttrib(), 0.5f, 1.0f, true); |
| 891 | ASSERT_GL_NO_ERROR(); |
| 892 | } |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 893 | |
| 894 | class FramebufferTest_ES31 : public ANGLETest |
| 895 | { |
JiangYizhou | 511937d | 2017-08-03 15:41:29 +0800 | [diff] [blame] | 896 | protected: |
| 897 | void validateSamplePass(GLuint &query, GLuint &passedCount, GLint width, GLint height) |
| 898 | { |
| 899 | glUniform2i(0, width - 1, height - 1); |
| 900 | glBeginQuery(GL_ANY_SAMPLES_PASSED, query); |
| 901 | glDrawArrays(GL_TRIANGLES, 0, 6); |
| 902 | glEndQuery(GL_ANY_SAMPLES_PASSED); |
| 903 | glGetQueryObjectuiv(query, GL_QUERY_RESULT, &passedCount); |
| 904 | EXPECT_GT(static_cast<GLint>(passedCount), 0); |
| 905 | |
| 906 | glUniform2i(0, width - 1, height); |
| 907 | glBeginQuery(GL_ANY_SAMPLES_PASSED, query); |
| 908 | glDrawArrays(GL_TRIANGLES, 0, 6); |
| 909 | glEndQuery(GL_ANY_SAMPLES_PASSED); |
| 910 | glGetQueryObjectuiv(query, GL_QUERY_RESULT, &passedCount); |
| 911 | EXPECT_EQ(static_cast<GLint>(passedCount), 0); |
| 912 | |
| 913 | glUniform2i(0, width, height - 1); |
| 914 | glBeginQuery(GL_ANY_SAMPLES_PASSED, query); |
| 915 | glDrawArrays(GL_TRIANGLES, 0, 6); |
| 916 | glEndQuery(GL_ANY_SAMPLES_PASSED); |
| 917 | glGetQueryObjectuiv(query, GL_QUERY_RESULT, &passedCount); |
| 918 | EXPECT_EQ(static_cast<GLint>(passedCount), 0); |
| 919 | } |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 920 | }; |
| 921 | |
| 922 | // Test that without attachment, if either the value of FRAMEBUFFER_DEFAULT_WIDTH or |
| 923 | // FRAMEBUFFER_DEFAULT_HEIGHT parameters is zero, the framebuffer is incomplete. |
| 924 | TEST_P(FramebufferTest_ES31, IncompleteMissingAttachmentDefaultParam) |
| 925 | { |
Tim Van Patten | 626a728 | 2019-07-08 15:11:59 -0600 | [diff] [blame] | 926 | // anglebug.com/3565 |
| 927 | ANGLE_SKIP_TEST_IF(IsVulkan()); |
| 928 | |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 929 | GLFramebuffer mFramebuffer; |
| 930 | glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer.get()); |
| 931 | |
| 932 | glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_WIDTH, 1); |
| 933 | glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_HEIGHT, 1); |
| 934 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 935 | |
| 936 | glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_WIDTH, 0); |
| 937 | glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_HEIGHT, 0); |
| 938 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT, |
| 939 | glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 940 | |
| 941 | glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_WIDTH, 1); |
| 942 | glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_HEIGHT, 0); |
| 943 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT, |
| 944 | glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 945 | |
| 946 | glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_WIDTH, 0); |
| 947 | glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_HEIGHT, 1); |
| 948 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT, |
| 949 | glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 950 | |
| 951 | ASSERT_GL_NO_ERROR(); |
| 952 | } |
| 953 | |
| 954 | // Test that the sample count of a mix of texture and renderbuffer should be same. |
| 955 | TEST_P(FramebufferTest_ES31, IncompleteMultisampleSampleCountMix) |
| 956 | { |
Tim Van Patten | 626a728 | 2019-07-08 15:11:59 -0600 | [diff] [blame] | 957 | // anglebug.com/3565 |
| 958 | ANGLE_SKIP_TEST_IF(IsVulkan()); |
| 959 | |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 960 | GLFramebuffer mFramebuffer; |
| 961 | glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer.get()); |
| 962 | |
Ian Elliott | 5f85783 | 2019-12-04 15:30:50 -0700 | [diff] [blame] | 963 | // Lookup the supported number of sample counts (rely on fact that ANGLE uses the same set of |
| 964 | // sample counts for textures and renderbuffers) |
| 965 | GLint numSampleCounts = 0; |
| 966 | std::vector<GLint> sampleCounts; |
| 967 | GLsizei queryBufferSize = 1; |
| 968 | glGetInternalformativ(GL_TEXTURE_2D_MULTISAMPLE, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, |
| 969 | queryBufferSize, &numSampleCounts); |
| 970 | ANGLE_SKIP_TEST_IF((numSampleCounts < 2)); |
| 971 | sampleCounts.resize(numSampleCounts); |
| 972 | queryBufferSize = numSampleCounts; |
| 973 | glGetInternalformativ(GL_TEXTURE_2D_MULTISAMPLE, GL_RGBA8, GL_SAMPLES, queryBufferSize, |
| 974 | sampleCounts.data()); |
| 975 | |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 976 | GLTexture mTexture; |
| 977 | glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTexture.get()); |
Ian Elliott | 5f85783 | 2019-12-04 15:30:50 -0700 | [diff] [blame] | 978 | glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCounts[0], GL_RGBA8, 1, 1, true); |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 979 | |
| 980 | GLRenderbuffer mRenderbuffer; |
| 981 | glBindRenderbuffer(GL_RENDERBUFFER, mRenderbuffer.get()); |
Ian Elliott | 5f85783 | 2019-12-04 15:30:50 -0700 | [diff] [blame] | 982 | glRenderbufferStorageMultisample(GL_RENDERBUFFER, sampleCounts[1], GL_RGBA8, 1, 1); |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 983 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, |
| 984 | mTexture.get(), 0); |
| 985 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER, |
| 986 | mRenderbuffer.get()); |
| 987 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, |
| 988 | glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 989 | |
| 990 | ASSERT_GL_NO_ERROR(); |
| 991 | } |
| 992 | |
| 993 | // Test that the sample count of texture attachments should be same. |
| 994 | TEST_P(FramebufferTest_ES31, IncompleteMultisampleSampleCountTex) |
| 995 | { |
Tim Van Patten | 626a728 | 2019-07-08 15:11:59 -0600 | [diff] [blame] | 996 | // anglebug.com/3565 |
| 997 | ANGLE_SKIP_TEST_IF(IsVulkan()); |
| 998 | |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 999 | GLFramebuffer mFramebuffer; |
| 1000 | glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer.get()); |
| 1001 | |
Ian Elliott | 5f85783 | 2019-12-04 15:30:50 -0700 | [diff] [blame] | 1002 | // Lookup the supported number of sample counts |
| 1003 | GLint numSampleCounts = 0; |
| 1004 | std::vector<GLint> sampleCounts; |
| 1005 | GLsizei queryBufferSize = 1; |
| 1006 | glGetInternalformativ(GL_TEXTURE_2D_MULTISAMPLE, GL_RGBA8, GL_NUM_SAMPLE_COUNTS, |
| 1007 | queryBufferSize, &numSampleCounts); |
| 1008 | ANGLE_SKIP_TEST_IF((numSampleCounts < 2)); |
| 1009 | sampleCounts.resize(numSampleCounts); |
| 1010 | queryBufferSize = numSampleCounts; |
| 1011 | glGetInternalformativ(GL_TEXTURE_2D_MULTISAMPLE, GL_RGBA8, GL_SAMPLES, queryBufferSize, |
| 1012 | sampleCounts.data()); |
| 1013 | |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 1014 | GLTexture mTextures[2]; |
| 1015 | glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTextures[0].get()); |
Ian Elliott | 5f85783 | 2019-12-04 15:30:50 -0700 | [diff] [blame] | 1016 | glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCounts[0], GL_RGBA8, 1, 1, true); |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 1017 | glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTextures[1].get()); |
Ian Elliott | 5f85783 | 2019-12-04 15:30:50 -0700 | [diff] [blame] | 1018 | glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCounts[1], GL_RGBA8, 1, 1, true); |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 1019 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, |
| 1020 | mTextures[0].get(), 0); |
| 1021 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D_MULTISAMPLE, |
| 1022 | mTextures[1].get(), 0); |
| 1023 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, |
| 1024 | glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 1025 | |
| 1026 | ASSERT_GL_NO_ERROR(); |
| 1027 | } |
| 1028 | |
| 1029 | // Test that if the attached images are a mix of renderbuffers and textures, the value of |
| 1030 | // TEXTURE_FIXED_SAMPLE_LOCATIONS must be TRUE for all attached textures. |
| 1031 | TEST_P(FramebufferTest_ES31, IncompleteMultisampleFixedSampleLocationsMix) |
| 1032 | { |
Tim Van Patten | 626a728 | 2019-07-08 15:11:59 -0600 | [diff] [blame] | 1033 | // anglebug.com/3565 |
| 1034 | ANGLE_SKIP_TEST_IF(IsVulkan()); |
| 1035 | |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 1036 | GLFramebuffer mFramebuffer; |
| 1037 | glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer.get()); |
| 1038 | |
| 1039 | GLTexture mTexture; |
| 1040 | glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTexture.get()); |
| 1041 | glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_RGBA8, 1, 1, false); |
| 1042 | |
| 1043 | GLRenderbuffer mRenderbuffer; |
| 1044 | glBindRenderbuffer(GL_RENDERBUFFER, mRenderbuffer.get()); |
| 1045 | glRenderbufferStorageMultisample(GL_RENDERBUFFER, 1, GL_RGBA8, 1, 1); |
| 1046 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, |
| 1047 | mTexture.get(), 0); |
| 1048 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_RENDERBUFFER, |
| 1049 | mRenderbuffer.get()); |
| 1050 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, |
| 1051 | glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 1052 | |
| 1053 | ASSERT_GL_NO_ERROR(); |
| 1054 | } |
| 1055 | |
| 1056 | // Test that the value of TEXTURE_FIXED_SAMPLE_LOCATIONS is the same for all attached textures. |
| 1057 | TEST_P(FramebufferTest_ES31, IncompleteMultisampleFixedSampleLocationsTex) |
| 1058 | { |
Tim Van Patten | 626a728 | 2019-07-08 15:11:59 -0600 | [diff] [blame] | 1059 | // anglebug.com/3565 |
| 1060 | ANGLE_SKIP_TEST_IF(IsVulkan()); |
| 1061 | |
JiangYizhou | 461d9a3 | 2017-01-04 16:37:26 +0800 | [diff] [blame] | 1062 | GLFramebuffer mFramebuffer; |
| 1063 | glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer.get()); |
| 1064 | |
| 1065 | GLTexture mTextures[2]; |
| 1066 | glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTextures[0].get()); |
| 1067 | glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_RGBA8, 1, 1, false); |
| 1068 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, |
| 1069 | mTextures[0].get(), 0); |
| 1070 | glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, mTextures[1].get()); |
| 1071 | glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 1, GL_RGB8, 1, 1, true); |
| 1072 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D_MULTISAMPLE, |
| 1073 | mTextures[1].get(), 0); |
| 1074 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE, |
| 1075 | glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 1076 | |
| 1077 | ASSERT_GL_NO_ERROR(); |
| 1078 | } |
| 1079 | |
JiangYizhou | 511937d | 2017-08-03 15:41:29 +0800 | [diff] [blame] | 1080 | // If there are no attachments, rendering will be limited to a rectangle having a lower left of |
| 1081 | // (0, 0) and an upper right of(width, height), where width and height are the framebuffer |
| 1082 | // object's default width and height. |
JiangYizhou | 3db4072 | 2017-08-28 17:59:13 +0800 | [diff] [blame] | 1083 | TEST_P(FramebufferTest_ES31, RenderingLimitToDefaultFBOSizeWithNoAttachments) |
JiangYizhou | 511937d | 2017-08-03 15:41:29 +0800 | [diff] [blame] | 1084 | { |
Yuly Novikov | 98f9f53 | 2017-11-15 19:16:19 -0500 | [diff] [blame] | 1085 | // anglebug.com/2253 |
| 1086 | ANGLE_SKIP_TEST_IF(IsLinux() && IsAMD() && IsDesktopOpenGL()); |
Tim Van Patten | 626a728 | 2019-07-08 15:11:59 -0600 | [diff] [blame] | 1087 | // Occlusion query reports fragments outside the render area are still rendered |
| 1088 | ANGLE_SKIP_TEST_IF(IsAndroid() || (IsWindows() && (IsIntel() || IsAMD()))); |
Yuly Novikov | 98f9f53 | 2017-11-15 19:16:19 -0500 | [diff] [blame] | 1089 | |
Jamie Madill | 35cd733 | 2018-12-02 12:03:33 -0500 | [diff] [blame] | 1090 | constexpr char kVS1[] = R"(#version 310 es |
| 1091 | in layout(location = 0) highp vec2 a_position; |
| 1092 | void main() |
| 1093 | { |
| 1094 | gl_Position = vec4(a_position, 0.0, 1.0); |
| 1095 | })"; |
JiangYizhou | 511937d | 2017-08-03 15:41:29 +0800 | [diff] [blame] | 1096 | |
Jamie Madill | 35cd733 | 2018-12-02 12:03:33 -0500 | [diff] [blame] | 1097 | constexpr char kFS1[] = R"(#version 310 es |
| 1098 | uniform layout(location = 0) highp ivec2 u_expectedSize; |
Shahbaz Youssefi | 190d9a8 | 2019-11-29 09:57:40 -0500 | [diff] [blame] | 1099 | out layout(location = 3) mediump vec4 f_color; |
Jamie Madill | 35cd733 | 2018-12-02 12:03:33 -0500 | [diff] [blame] | 1100 | void main() |
| 1101 | { |
| 1102 | if (ivec2(gl_FragCoord.xy) != u_expectedSize) discard; |
| 1103 | f_color = vec4(1.0, 0.5, 0.25, 1.0); |
| 1104 | })"; |
JiangYizhou | 511937d | 2017-08-03 15:41:29 +0800 | [diff] [blame] | 1105 | |
Jamie Madill | 35cd733 | 2018-12-02 12:03:33 -0500 | [diff] [blame] | 1106 | constexpr char kVS2[] = R"(#version 310 es |
| 1107 | in layout(location = 0) highp vec2 a_position; |
| 1108 | void main() |
| 1109 | { |
| 1110 | gl_Position = vec4(a_position, 0.0, 1.0); |
| 1111 | })"; |
JiangYizhou | 10d4139 | 2017-12-18 18:13:36 +0800 | [diff] [blame] | 1112 | |
Jamie Madill | 35cd733 | 2018-12-02 12:03:33 -0500 | [diff] [blame] | 1113 | constexpr char kFS2[] = R"(#version 310 es |
| 1114 | uniform layout(location = 0) highp ivec2 u_expectedSize; |
| 1115 | out layout(location = 2) mediump vec4 f_color; |
| 1116 | void main() |
| 1117 | { |
| 1118 | if (ivec2(gl_FragCoord.xy) != u_expectedSize) discard; |
| 1119 | f_color = vec4(1.0, 0.5, 0.25, 1.0); |
| 1120 | })"; |
JiangYizhou | 10d4139 | 2017-12-18 18:13:36 +0800 | [diff] [blame] | 1121 | |
Jamie Madill | 35cd733 | 2018-12-02 12:03:33 -0500 | [diff] [blame] | 1122 | GLuint program1 = CompileProgram(kVS1, kFS1); |
JiangYizhou | 10d4139 | 2017-12-18 18:13:36 +0800 | [diff] [blame] | 1123 | ASSERT_NE(program1, 0u); |
| 1124 | |
Jamie Madill | 35cd733 | 2018-12-02 12:03:33 -0500 | [diff] [blame] | 1125 | GLuint program2 = CompileProgram(kVS2, kFS2); |
JiangYizhou | 10d4139 | 2017-12-18 18:13:36 +0800 | [diff] [blame] | 1126 | ASSERT_NE(program2, 0u); |
| 1127 | |
| 1128 | glUseProgram(program1); |
JiangYizhou | 511937d | 2017-08-03 15:41:29 +0800 | [diff] [blame] | 1129 | |
| 1130 | GLFramebuffer mFramebuffer; |
| 1131 | glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mFramebuffer); |
| 1132 | GLuint defaultWidth = 1; |
| 1133 | GLuint defaultHeight = 1; |
| 1134 | |
| 1135 | glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_WIDTH, defaultWidth); |
| 1136 | glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_HEIGHT, defaultHeight); |
| 1137 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 1138 | |
| 1139 | const float data[] = { |
| 1140 | 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, |
| 1141 | }; |
| 1142 | |
| 1143 | GLuint vertexArray = 0; |
| 1144 | GLuint vertexBuffer = 0; |
| 1145 | GLuint query = 0; |
| 1146 | GLuint passedCount = 0; |
| 1147 | |
| 1148 | glGenQueries(1, &query); |
| 1149 | glGenVertexArrays(1, &vertexArray); |
| 1150 | glBindVertexArray(vertexArray); |
| 1151 | |
| 1152 | glGenBuffers(1, &vertexBuffer); |
| 1153 | glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); |
| 1154 | glBufferData(GL_ARRAY_BUFFER, sizeof(data), data, GL_STATIC_DRAW); |
| 1155 | |
| 1156 | glEnableVertexAttribArray(0); |
| 1157 | glVertexAttribPointer(0, 2, GL_FLOAT, false, 0, 0); |
JiangYizhou | 38d92b5 | 2017-09-13 13:47:52 +0800 | [diff] [blame] | 1158 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
JiangYizhou | 511937d | 2017-08-03 15:41:29 +0800 | [diff] [blame] | 1159 | |
| 1160 | validateSamplePass(query, passedCount, defaultWidth, defaultHeight); |
| 1161 | |
JiangYizhou | 10d4139 | 2017-12-18 18:13:36 +0800 | [diff] [blame] | 1162 | glUseProgram(program2); |
| 1163 | validateSamplePass(query, passedCount, defaultWidth, defaultHeight); |
| 1164 | |
| 1165 | glUseProgram(program1); |
JiangYizhou | 511937d | 2017-08-03 15:41:29 +0800 | [diff] [blame] | 1166 | // If fbo has attachments, the rendering size should be the same as its attachment. |
| 1167 | GLTexture mTexture; |
| 1168 | GLuint width = 2; |
| 1169 | GLuint height = 2; |
| 1170 | glBindTexture(GL_TEXTURE_2D, mTexture.get()); |
| 1171 | glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, width, height); |
JiangYizhou | 38d92b5 | 2017-09-13 13:47:52 +0800 | [diff] [blame] | 1172 | |
Shahbaz Youssefi | 190d9a8 | 2019-11-29 09:57:40 -0500 | [diff] [blame] | 1173 | const GLenum bufs[] = {GL_NONE, GL_NONE, GL_NONE, GL_COLOR_ATTACHMENT3}; |
JiangYizhou | 38d92b5 | 2017-09-13 13:47:52 +0800 | [diff] [blame] | 1174 | |
Shahbaz Youssefi | 190d9a8 | 2019-11-29 09:57:40 -0500 | [diff] [blame] | 1175 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, mTexture.get(), |
JiangYizhou | 511937d | 2017-08-03 15:41:29 +0800 | [diff] [blame] | 1176 | 0); |
| 1177 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
Shahbaz Youssefi | 190d9a8 | 2019-11-29 09:57:40 -0500 | [diff] [blame] | 1178 | glDrawBuffers(4, bufs); |
JiangYizhou | 511937d | 2017-08-03 15:41:29 +0800 | [diff] [blame] | 1179 | |
| 1180 | validateSamplePass(query, passedCount, width, height); |
| 1181 | |
| 1182 | // If fbo's attachment has been removed, the rendering size should be the same as framebuffer |
| 1183 | // default size. |
Shahbaz Youssefi | 190d9a8 | 2019-11-29 09:57:40 -0500 | [diff] [blame] | 1184 | glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, 0, 0, 0); |
JiangYizhou | 511937d | 2017-08-03 15:41:29 +0800 | [diff] [blame] | 1185 | EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 1186 | |
| 1187 | validateSamplePass(query, passedCount, defaultWidth, defaultHeight); |
| 1188 | |
| 1189 | glDisableVertexAttribArray(0); |
| 1190 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 1191 | glBindVertexArray(0); |
| 1192 | glDeleteBuffers(1, &vertexBuffer); |
| 1193 | glDeleteVertexArrays(1, &vertexArray); |
| 1194 | |
| 1195 | ASSERT_GL_NO_ERROR(); |
| 1196 | } |
| 1197 | |
Brandon Jones | 9fc8733 | 2017-12-13 15:46:52 -0800 | [diff] [blame] | 1198 | class AddDummyTextureNoRenderTargetTest : public ANGLETest |
| 1199 | { |
| 1200 | public: |
| 1201 | AddDummyTextureNoRenderTargetTest() |
| 1202 | { |
| 1203 | setWindowWidth(512); |
| 1204 | setWindowHeight(512); |
| 1205 | setConfigRedBits(8); |
| 1206 | setConfigGreenBits(8); |
| 1207 | setConfigBlueBits(8); |
| 1208 | setConfigAlphaBits(8); |
| 1209 | } |
| 1210 | |
Jonah Ryan-Davis | eee67c6 | 2019-06-18 13:00:43 -0400 | [diff] [blame] | 1211 | void overrideWorkaroundsD3D(FeaturesD3D *features) override |
Brandon Jones | 9fc8733 | 2017-12-13 15:46:52 -0800 | [diff] [blame] | 1212 | { |
Jonah Ryan-Davis | beb0eb2 | 2019-06-14 15:10:33 -0400 | [diff] [blame] | 1213 | features->overrideFeatures({"add_dummy_texture_no_render_target"}, true); |
Brandon Jones | 9fc8733 | 2017-12-13 15:46:52 -0800 | [diff] [blame] | 1214 | } |
| 1215 | }; |
| 1216 | |
| 1217 | // Test to verify workaround succeeds when no program outputs exist http://anglebug.com/2283 |
| 1218 | TEST_P(AddDummyTextureNoRenderTargetTest, NoProgramOutputWorkaround) |
| 1219 | { |
Jamie Madill | 35cd733 | 2018-12-02 12:03:33 -0500 | [diff] [blame] | 1220 | constexpr char kVS[] = "void main() {}"; |
| 1221 | constexpr char kFS[] = "void main() {}"; |
Brandon Jones | 9fc8733 | 2017-12-13 15:46:52 -0800 | [diff] [blame] | 1222 | |
Jamie Madill | 35cd733 | 2018-12-02 12:03:33 -0500 | [diff] [blame] | 1223 | ANGLE_GL_PROGRAM(drawProgram, kVS, kFS); |
Brandon Jones | 9fc8733 | 2017-12-13 15:46:52 -0800 | [diff] [blame] | 1224 | |
| 1225 | glUseProgram(drawProgram); |
| 1226 | |
| 1227 | glDrawArrays(GL_TRIANGLES, 0, 6); |
| 1228 | |
| 1229 | ASSERT_GL_NO_ERROR(); |
| 1230 | } |
| 1231 | |
Jamie Madill | 4fb3c28 | 2020-03-19 19:10:45 -0400 | [diff] [blame] | 1232 | // Covers a bug in ANGLE's Vulkan back-end framebuffer cache which ignored depth/stencil after |
| 1233 | // calls to DrawBuffers. |
| 1234 | TEST_P(FramebufferTest_ES3, AttachmentStateChange) |
| 1235 | { |
| 1236 | constexpr GLuint kSize = 2; |
| 1237 | |
| 1238 | ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Simple(), essl1_shaders::fs::Green()); |
| 1239 | |
| 1240 | GLTexture colorTexture; |
| 1241 | glBindTexture(GL_TEXTURE_2D, colorTexture); |
| 1242 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, kSize, kSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 1243 | |
| 1244 | GLFramebuffer fbo; |
| 1245 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 1246 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture, 0); |
| 1247 | |
| 1248 | ASSERT_GL_NO_ERROR(); |
| 1249 | ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER); |
| 1250 | |
| 1251 | // First draw without a depth buffer. |
| 1252 | drawQuad(program, essl1_shaders::PositionAttrib(), 0.5f); |
| 1253 | |
| 1254 | GLRenderbuffer depthBuffer; |
| 1255 | glBindRenderbuffer(GL_RENDERBUFFER, depthBuffer); |
| 1256 | glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, kSize, kSize); |
| 1257 | |
| 1258 | // Bind just a renderbuffer and draw. |
| 1259 | glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthBuffer); |
| 1260 | |
| 1261 | ASSERT_GL_NO_ERROR(); |
| 1262 | ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER); |
| 1263 | |
| 1264 | glDrawBuffers(0, nullptr); |
| 1265 | drawQuad(program, essl1_shaders::PositionAttrib(), 0.5f); |
| 1266 | |
| 1267 | // Re-enable color buffer and draw one final time. This previously triggered a crash. |
| 1268 | GLenum drawBuffs = {GL_COLOR_ATTACHMENT0}; |
| 1269 | glDrawBuffers(1, &drawBuffs); |
| 1270 | |
| 1271 | drawQuad(program, essl1_shaders::PositionAttrib(), 0.5f); |
| 1272 | ASSERT_GL_NO_ERROR(); |
| 1273 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 1274 | } |
| 1275 | |
Jamie Madill | d03b15b | 2020-03-26 17:22:18 -0400 | [diff] [blame] | 1276 | // Tests that we can support a feedback loop between a depth textures and the depth buffer. |
| 1277 | // Does not totally mirror the case used in Manhattan. The Manhattan case seems to handle |
| 1278 | // "clear" specially instead of rendering to depth in the same RP. |
| 1279 | TEST_P(FramebufferTest_ES3, DepthFeedbackLoopSupported) |
| 1280 | { |
| 1281 | // Feedback loops not supported on D3D11 and may not ever be. |
| 1282 | ANGLE_SKIP_TEST_IF(IsD3D11()); |
| 1283 | |
| 1284 | // Also this particular test doesn't work on Android despite similar support in Manhattan. |
| 1285 | ANGLE_SKIP_TEST_IF(IsAndroid() && IsOpenGLES()); |
| 1286 | |
| 1287 | constexpr GLuint kSize = 2; |
| 1288 | glViewport(0, 0, kSize, kSize); |
| 1289 | |
| 1290 | constexpr char kFS[] = R"(precision mediump float; |
| 1291 | varying vec2 v_texCoord; |
| 1292 | uniform sampler2D depth; |
| 1293 | void main() |
| 1294 | { |
| 1295 | if (abs(texture2D(depth, v_texCoord).x - 0.5) < 0.1) |
| 1296 | { |
| 1297 | gl_FragColor = vec4(0, 1, 0, 1); |
| 1298 | } |
| 1299 | else |
| 1300 | { |
| 1301 | gl_FragColor = vec4(1, 0, 0, 1); |
| 1302 | } |
| 1303 | })"; |
| 1304 | |
| 1305 | ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Texture2D(), kFS); |
| 1306 | |
| 1307 | GLFramebuffer framebuffer; |
| 1308 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); |
| 1309 | |
| 1310 | GLTexture colorTexture; |
| 1311 | glBindTexture(GL_TEXTURE_2D, colorTexture); |
| 1312 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, kSize, kSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 1313 | |
| 1314 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 1315 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1316 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture, 0); |
| 1317 | |
| 1318 | GLTexture depthTexture; |
| 1319 | glBindTexture(GL_TEXTURE_2D, depthTexture); |
| 1320 | glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, kSize, kSize, 0, GL_DEPTH_COMPONENT, |
| 1321 | GL_UNSIGNED_INT, nullptr); |
| 1322 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 1323 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1324 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0); |
| 1325 | |
| 1326 | ASSERT_GL_NO_ERROR(); |
| 1327 | ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER); |
| 1328 | |
| 1329 | // Clear depth to 0.5. |
| 1330 | glClearDepthf(0.5f); |
| 1331 | glClear(GL_DEPTH_BUFFER_BIT); |
| 1332 | |
| 1333 | // Disable the depth mask. Although this does not remove the feedback loop as defined by the |
| 1334 | // spec it mimics what gfxbench does in its rendering tests. |
| 1335 | glDepthMask(false); |
| 1336 | |
| 1337 | // Verify we can sample the depth texture and get 0.5. |
| 1338 | drawQuad(program, essl1_shaders::PositionAttrib(), 0.5); |
| 1339 | |
| 1340 | ASSERT_GL_NO_ERROR(); |
| 1341 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 1342 | } |
| 1343 | |
Jamie Madill | dd00f16 | 2020-04-02 14:04:44 -0400 | [diff] [blame] | 1344 | // Covers a bug in ANGLE's Vulkan back-end. Our VkFramebuffer cache would in some cases forget to |
| 1345 | // check the draw states when computing a cache key. |
| 1346 | TEST_P(FramebufferTest_ES3, DisabledAttachmentRedefinition) |
| 1347 | { |
| 1348 | constexpr GLuint kSize = 2; |
| 1349 | |
| 1350 | // Make a Framebuffer with two attachments with one enabled and one disabled. |
| 1351 | GLTexture texA, texB; |
| 1352 | glBindTexture(GL_TEXTURE_2D, texA); |
| 1353 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, kSize, kSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 1354 | glBindTexture(GL_TEXTURE_2D, texB); |
| 1355 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, kSize, kSize, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
| 1356 | |
| 1357 | GLFramebuffer fbo; |
| 1358 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 1359 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texA, 0); |
| 1360 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, texB, 0); |
| 1361 | |
| 1362 | // Mask out the second texture. |
| 1363 | constexpr GLenum kOneDrawBuf = GL_COLOR_ATTACHMENT0; |
| 1364 | glDrawBuffers(1, &kOneDrawBuf); |
| 1365 | |
| 1366 | ASSERT_GL_NO_ERROR(); |
| 1367 | ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER); |
| 1368 | |
| 1369 | // Set up a very simple shader. |
| 1370 | ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Simple(), essl1_shaders::fs::Green()); |
| 1371 | glViewport(0, 0, kSize, kSize); |
| 1372 | |
| 1373 | // Draw |
| 1374 | drawQuad(program, essl1_shaders::PositionAttrib(), 0.5f, 1.0f, true); |
| 1375 | ASSERT_GL_NO_ERROR(); |
| 1376 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 1377 | |
| 1378 | // Update the masked out attachment and draw again. |
| 1379 | std::vector<GLColor> redPixels(kSize * kSize, GLColor::red); |
| 1380 | glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, kSize, kSize, GL_RGBA, GL_UNSIGNED_BYTE, |
| 1381 | redPixels.data()); |
| 1382 | |
| 1383 | // Draw |
| 1384 | drawQuad(program, essl1_shaders::PositionAttrib(), 0.5f, 1.0f, true); |
| 1385 | ASSERT_GL_NO_ERROR(); |
| 1386 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 1387 | |
| 1388 | glReadBuffer(GL_COLOR_ATTACHMENT1); |
| 1389 | ASSERT_GL_NO_ERROR(); |
| 1390 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red); |
| 1391 | } |
| 1392 | |
Jamie Madill | c9c4e4e | 2020-04-02 10:29:52 -0400 | [diff] [blame] | 1393 | class FramebufferTest : public ANGLETest |
| 1394 | {}; |
| 1395 | |
| 1396 | template <typename T> |
| 1397 | void FillTexture2D(GLuint texture, |
| 1398 | GLsizei width, |
| 1399 | GLsizei height, |
| 1400 | const T &onePixelData, |
| 1401 | GLint level, |
| 1402 | GLint internalFormat, |
| 1403 | GLenum format, |
| 1404 | GLenum type) |
| 1405 | { |
| 1406 | std::vector<T> allPixelsData(width * height, onePixelData); |
| 1407 | |
| 1408 | glBindTexture(GL_TEXTURE_2D, texture); |
| 1409 | glTexImage2D(GL_TEXTURE_2D, level, internalFormat, width, height, 0, format, type, |
| 1410 | allPixelsData.data()); |
| 1411 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 1412 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 1413 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 1414 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 1415 | } |
| 1416 | |
| 1417 | // Multi-context uses of textures should not cause rendering feedback loops. |
| 1418 | TEST_P(FramebufferTest, MultiContextNoRenderingFeedbackLoops) |
| 1419 | { |
| 1420 | constexpr char kTextureVS[] = |
| 1421 | R"(attribute vec4 a_position; |
| 1422 | varying vec2 v_texCoord; |
| 1423 | void main() { |
| 1424 | gl_Position = a_position; |
| 1425 | v_texCoord = (a_position.xy * 0.5) + 0.5; |
| 1426 | })"; |
| 1427 | |
| 1428 | constexpr char kTextureFS[] = |
| 1429 | R"(precision mediump float; |
| 1430 | varying vec2 v_texCoord; |
| 1431 | uniform sampler2D u_texture; |
| 1432 | void main() { |
| 1433 | gl_FragColor = texture2D(u_texture, v_texCoord).rgba; |
| 1434 | })"; |
| 1435 | |
| 1436 | ANGLE_GL_PROGRAM(textureProgram, kTextureVS, kTextureFS); |
| 1437 | |
| 1438 | glUseProgram(textureProgram.get()); |
| 1439 | GLint uniformLoc = glGetUniformLocation(textureProgram.get(), "u_texture"); |
| 1440 | ASSERT_NE(-1, uniformLoc); |
| 1441 | glUniform1i(uniformLoc, 0); |
| 1442 | |
| 1443 | GLTexture texture; |
| 1444 | FillTexture2D(texture.get(), 1, 1, GLColor::red, 0, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE); |
| 1445 | glBindTexture(GL_TEXTURE_2D, texture.get()); |
| 1446 | // Note that _texture_ is still bound to GL_TEXTURE_2D in this context at this point. |
| 1447 | |
| 1448 | EGLWindow *window = getEGLWindow(); |
| 1449 | EGLDisplay display = window->getDisplay(); |
| 1450 | EGLConfig config = window->getConfig(); |
| 1451 | EGLSurface surface = window->getSurface(); |
| 1452 | EGLint contextAttributes[] = { |
| 1453 | EGL_CONTEXT_MAJOR_VERSION_KHR, |
| 1454 | GetParam().majorVersion, |
| 1455 | EGL_CONTEXT_MINOR_VERSION_KHR, |
| 1456 | GetParam().minorVersion, |
| 1457 | EGL_NONE, |
| 1458 | }; |
| 1459 | EGLContext context1 = eglGetCurrentContext(); |
| 1460 | // Create context2, sharing resources with context1. |
| 1461 | EGLContext context2 = eglCreateContext(display, config, context1, contextAttributes); |
| 1462 | ASSERT_NE(context2, EGL_NO_CONTEXT); |
| 1463 | eglMakeCurrent(display, surface, surface, context2); |
| 1464 | |
| 1465 | constexpr char kVS[] = |
| 1466 | R"(attribute vec4 a_position; |
| 1467 | void main() { |
| 1468 | gl_Position = a_position; |
| 1469 | })"; |
| 1470 | |
| 1471 | constexpr char kFS[] = |
| 1472 | R"(precision mediump float; |
| 1473 | void main() { |
| 1474 | gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); |
| 1475 | })"; |
| 1476 | |
| 1477 | ANGLE_GL_PROGRAM(program, kVS, kFS); |
| 1478 | glUseProgram(program.get()); |
| 1479 | |
| 1480 | ASSERT_GL_NO_ERROR(); |
| 1481 | |
| 1482 | // Render to the texture in context2. |
| 1483 | GLFramebuffer framebuffer; |
| 1484 | glBindFramebuffer(GL_FRAMEBUFFER, framebuffer.get()); |
| 1485 | // Texture is still a valid name in context2. |
| 1486 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.get(), 0); |
| 1487 | ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER)); |
| 1488 | // There is no rendering feedback loop at this point. |
| 1489 | |
| 1490 | glDisable(GL_BLEND); |
| 1491 | glDisable(GL_DEPTH_TEST); |
| 1492 | ASSERT_GL_NO_ERROR(); |
| 1493 | |
| 1494 | // If draw is no-op'ed, texture will not be filled appropriately. |
| 1495 | drawQuad(program.get(), "a_position", 0.5f, 1.0f, true); |
| 1496 | ASSERT_GL_NO_ERROR(); |
| 1497 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 1498 | |
| 1499 | // Make context1 current again. |
| 1500 | eglMakeCurrent(display, surface, surface, context1); |
| 1501 | |
| 1502 | // Render texture to screen. |
| 1503 | drawQuad(textureProgram.get(), "a_position", 0.5f, 1.0f, true); |
| 1504 | ASSERT_GL_NO_ERROR(); |
| 1505 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
| 1506 | |
| 1507 | eglDestroyContext(display, context2); |
| 1508 | } |
| 1509 | |
Jamie Madill | 2a0c359 | 2020-03-31 15:36:45 -0400 | [diff] [blame] | 1510 | // Ensure cube-incomplete attachments cause incomplete Framebuffers. |
| 1511 | TEST_P(FramebufferTest, IncompleteCubeMap) |
| 1512 | { |
| 1513 | constexpr GLuint kSize = 2; |
| 1514 | |
| 1515 | GLTexture srcTex; |
| 1516 | glBindTexture(GL_TEXTURE_CUBE_MAP, srcTex); |
| 1517 | glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA, kSize, kSize, 0, GL_RGBA, |
| 1518 | GL_UNSIGNED_BYTE, nullptr); |
| 1519 | |
| 1520 | GLFramebuffer fbo; |
| 1521 | glBindFramebuffer(GL_FRAMEBUFFER, fbo); |
| 1522 | glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
| 1523 | srcTex, 0); |
| 1524 | |
| 1525 | ASSERT_GL_NO_ERROR(); |
| 1526 | ASSERT_GLENUM_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), |
| 1527 | GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT); |
| 1528 | } |
| 1529 | |
Tobin Ehlis | 1a01b4b | 2019-11-11 16:41:07 -0700 | [diff] [blame] | 1530 | ANGLE_INSTANTIATE_TEST_ES2(AddDummyTextureNoRenderTargetTest); |
Jamie Madill | c9c4e4e | 2020-04-02 10:29:52 -0400 | [diff] [blame] | 1531 | ANGLE_INSTANTIATE_TEST_ES2(FramebufferTest); |
Shahbaz Youssefi | e28883d | 2020-01-25 23:25:43 -0500 | [diff] [blame] | 1532 | ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(FramebufferFormatsTest); |
| 1533 | ANGLE_INSTANTIATE_TEST_ES3(FramebufferTest_ES3); |
| 1534 | ANGLE_INSTANTIATE_TEST_ES31(FramebufferTest_ES31); |