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 | af4ffe0 | 2017-09-09 23:32:48 -0400 | [diff] [blame] | 8 | #include "test_utils/gl_raii.h" |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 9 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 10 | using namespace angle; |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 11 | |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 12 | class PbufferTest : public ANGLETest |
| 13 | { |
| 14 | protected: |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 15 | PbufferTest() |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 16 | { |
| 17 | setWindowWidth(512); |
| 18 | setWindowHeight(512); |
| 19 | setConfigRedBits(8); |
| 20 | setConfigGreenBits(8); |
| 21 | setConfigBlueBits(8); |
| 22 | setConfigAlphaBits(8); |
| 23 | } |
| 24 | |
| 25 | virtual void SetUp() |
| 26 | { |
| 27 | ANGLETest::SetUp(); |
| 28 | |
| 29 | const std::string vsSource = SHADER_SOURCE |
| 30 | ( |
| 31 | precision highp float; |
| 32 | attribute vec4 position; |
| 33 | varying vec2 texcoord; |
| 34 | |
| 35 | void main() |
| 36 | { |
| 37 | gl_Position = position; |
| 38 | texcoord = (position.xy * 0.5) + 0.5; |
| 39 | texcoord.y = 1.0 - texcoord.y; |
| 40 | } |
| 41 | ); |
| 42 | |
| 43 | const std::string textureFSSource = SHADER_SOURCE |
| 44 | ( |
| 45 | precision highp float; |
| 46 | uniform sampler2D tex; |
| 47 | varying vec2 texcoord; |
| 48 | |
| 49 | void main() |
| 50 | { |
| 51 | gl_FragColor = texture2D(tex, texcoord); |
| 52 | } |
| 53 | ); |
| 54 | |
| 55 | mTextureProgram = CompileProgram(vsSource, textureFSSource); |
| 56 | if (mTextureProgram == 0) |
| 57 | { |
| 58 | FAIL() << "shader compilation failed."; |
| 59 | } |
| 60 | |
| 61 | mTextureUniformLocation = glGetUniformLocation(mTextureProgram, "tex"); |
| 62 | |
Geoff Lang | 1c906c2 | 2015-04-10 11:26:17 -0400 | [diff] [blame] | 63 | EGLWindow *window = getEGLWindow(); |
| 64 | |
| 65 | EGLint surfaceType = 0; |
| 66 | eglGetConfigAttrib(window->getDisplay(), window->getConfig(), EGL_SURFACE_TYPE, &surfaceType); |
| 67 | mSupportsPbuffers = (surfaceType & EGL_PBUFFER_BIT) != 0; |
| 68 | |
| 69 | EGLint bindToTextureRGBA = 0; |
| 70 | eglGetConfigAttrib(window->getDisplay(), window->getConfig(), EGL_BIND_TO_TEXTURE_RGBA, &bindToTextureRGBA); |
| 71 | mSupportsBindTexImage = (bindToTextureRGBA == EGL_TRUE); |
| 72 | |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 73 | const EGLint pBufferAttributes[] = |
| 74 | { |
Corentin Wallez | 973402f | 2015-05-11 13:42:22 -0400 | [diff] [blame] | 75 | EGL_WIDTH, static_cast<EGLint>(mPbufferSize), |
| 76 | EGL_HEIGHT, static_cast<EGLint>(mPbufferSize), |
Geoff Lang | 1c906c2 | 2015-04-10 11:26:17 -0400 | [diff] [blame] | 77 | EGL_TEXTURE_FORMAT, mSupportsBindTexImage ? EGL_TEXTURE_RGBA : EGL_NO_TEXTURE, |
| 78 | EGL_TEXTURE_TARGET, mSupportsBindTexImage ? EGL_TEXTURE_2D : EGL_NO_TEXTURE, |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 79 | EGL_NONE, EGL_NONE, |
| 80 | }; |
| 81 | |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 82 | mPbuffer = eglCreatePbufferSurface(window->getDisplay(), window->getConfig(), pBufferAttributes); |
Geoff Lang | 1c906c2 | 2015-04-10 11:26:17 -0400 | [diff] [blame] | 83 | if (mSupportsPbuffers) |
| 84 | { |
| 85 | ASSERT_NE(mPbuffer, EGL_NO_SURFACE); |
| 86 | ASSERT_EGL_SUCCESS(); |
| 87 | } |
| 88 | else |
| 89 | { |
| 90 | ASSERT_EQ(mPbuffer, EGL_NO_SURFACE); |
| 91 | ASSERT_EGL_ERROR(EGL_BAD_MATCH); |
| 92 | } |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 93 | |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 94 | ASSERT_GL_NO_ERROR(); |
| 95 | } |
| 96 | |
| 97 | virtual void TearDown() |
| 98 | { |
| 99 | glDeleteProgram(mTextureProgram); |
| 100 | |
| 101 | EGLWindow *window = getEGLWindow(); |
| 102 | eglDestroySurface(window->getDisplay(), mPbuffer); |
| 103 | |
| 104 | ANGLETest::TearDown(); |
| 105 | } |
| 106 | |
| 107 | GLuint mTextureProgram; |
| 108 | GLint mTextureUniformLocation; |
| 109 | |
| 110 | const size_t mPbufferSize = 32; |
| 111 | EGLSurface mPbuffer; |
Geoff Lang | 1c906c2 | 2015-04-10 11:26:17 -0400 | [diff] [blame] | 112 | bool mSupportsPbuffers; |
| 113 | bool mSupportsBindTexImage; |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 114 | }; |
| 115 | |
| 116 | // Test clearing a Pbuffer and checking the color is correct |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 117 | TEST_P(PbufferTest, Clearing) |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 118 | { |
Geoff Lang | 1c906c2 | 2015-04-10 11:26:17 -0400 | [diff] [blame] | 119 | if (!mSupportsPbuffers) |
| 120 | { |
| 121 | std::cout << "Test skipped because Pbuffers are not supported." << std::endl; |
| 122 | return; |
| 123 | } |
| 124 | |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 125 | EGLWindow *window = getEGLWindow(); |
| 126 | |
| 127 | // Clear the window surface to blue and verify |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 128 | window->makeCurrent(); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 129 | ASSERT_EGL_SUCCESS(); |
| 130 | |
| 131 | glClearColor(0.0f, 0.0f, 1.0f, 1.0f); |
| 132 | glClear(GL_COLOR_BUFFER_BIT); |
| 133 | ASSERT_GL_NO_ERROR(); |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 134 | EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 255, 255); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 135 | |
| 136 | // Apply the Pbuffer and clear it to purple and verify |
| 137 | eglMakeCurrent(window->getDisplay(), mPbuffer, mPbuffer, window->getContext()); |
| 138 | ASSERT_EGL_SUCCESS(); |
| 139 | |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 140 | glViewport(0, 0, static_cast<GLsizei>(mPbufferSize), static_cast<GLsizei>(mPbufferSize)); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 141 | glClearColor(1.0f, 0.0f, 1.0f, 1.0f); |
| 142 | glClear(GL_COLOR_BUFFER_BIT); |
| 143 | ASSERT_GL_NO_ERROR(); |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 144 | EXPECT_PIXEL_EQ(static_cast<GLint>(mPbufferSize) / 2, static_cast<GLint>(mPbufferSize) / 2, 255, |
| 145 | 0, 255, 255); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 146 | |
Corentin Wallez | 21ce9b0 | 2015-05-14 11:50:08 -0400 | [diff] [blame] | 147 | // Rebind the window surface and verify that it is still blue |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 148 | window->makeCurrent(); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 149 | ASSERT_EGL_SUCCESS(); |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 150 | EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 0, 0, 255, 255); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | // Bind the Pbuffer to a texture and verify it renders correctly |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 154 | TEST_P(PbufferTest, BindTexImage) |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 155 | { |
Geoff Lang | 1c906c2 | 2015-04-10 11:26:17 -0400 | [diff] [blame] | 156 | if (!mSupportsPbuffers) |
| 157 | { |
| 158 | std::cout << "Test skipped because Pbuffers are not supported." << std::endl; |
| 159 | return; |
| 160 | } |
| 161 | |
| 162 | if (!mSupportsBindTexImage) |
| 163 | { |
| 164 | std::cout << "Test skipped because Pbuffer does not support binding to RGBA textures." << std::endl; |
| 165 | return; |
| 166 | } |
| 167 | |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 168 | EGLWindow *window = getEGLWindow(); |
| 169 | |
| 170 | // Apply the Pbuffer and clear it to purple |
| 171 | eglMakeCurrent(window->getDisplay(), mPbuffer, mPbuffer, window->getContext()); |
| 172 | ASSERT_EGL_SUCCESS(); |
| 173 | |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 174 | glViewport(0, 0, static_cast<GLsizei>(mPbufferSize), static_cast<GLsizei>(mPbufferSize)); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 175 | glClearColor(1.0f, 0.0f, 1.0f, 1.0f); |
| 176 | glClear(GL_COLOR_BUFFER_BIT); |
| 177 | ASSERT_GL_NO_ERROR(); |
| 178 | |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 179 | EXPECT_PIXEL_EQ(static_cast<GLint>(mPbufferSize) / 2, static_cast<GLint>(mPbufferSize) / 2, 255, |
| 180 | 0, 255, 255); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 181 | |
| 182 | // Apply the window surface |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 183 | window->makeCurrent(); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 184 | |
| 185 | // Create a texture and bind the Pbuffer to it |
| 186 | GLuint texture = 0; |
| 187 | glGenTextures(1, &texture); |
| 188 | glBindTexture(GL_TEXTURE_2D, texture); |
| 189 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 190 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 191 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 192 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 193 | EXPECT_GL_NO_ERROR(); |
| 194 | |
| 195 | eglBindTexImage(window->getDisplay(), mPbuffer, EGL_BACK_BUFFER); |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 196 | glViewport(0, 0, getWindowWidth(), getWindowHeight()); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 197 | ASSERT_EGL_SUCCESS(); |
| 198 | |
| 199 | // Draw a quad and verify that it is purple |
| 200 | glUseProgram(mTextureProgram); |
| 201 | glUniform1i(mTextureUniformLocation, 0); |
| 202 | |
| 203 | drawQuad(mTextureProgram, "position", 0.5f); |
| 204 | EXPECT_GL_NO_ERROR(); |
| 205 | |
| 206 | // Unbind the texture |
| 207 | eglReleaseTexImage(window->getDisplay(), mPbuffer, EGL_BACK_BUFFER); |
| 208 | ASSERT_EGL_SUCCESS(); |
| 209 | |
| 210 | // Verify that purple was drawn |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 211 | EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 255, 0, 255, 255); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 212 | |
| 213 | glDeleteTextures(1, &texture); |
| 214 | } |
| 215 | |
| 216 | // Verify that when eglBind/ReleaseTexImage are called, the texture images are freed and their |
| 217 | // size information is correctly updated. |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 218 | TEST_P(PbufferTest, TextureSizeReset) |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 219 | { |
Jamie Madill | af4ffe0 | 2017-09-09 23:32:48 -0400 | [diff] [blame] | 220 | ANGLE_SKIP_TEST_IF(!mSupportsPbuffers); |
| 221 | ANGLE_SKIP_TEST_IF(!mSupportsBindTexImage); |
Geoff Lang | 1c906c2 | 2015-04-10 11:26:17 -0400 | [diff] [blame] | 222 | |
Jamie Madill | af4ffe0 | 2017-09-09 23:32:48 -0400 | [diff] [blame] | 223 | GLTexture texture; |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 224 | glBindTexture(GL_TEXTURE_2D, texture); |
| 225 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 226 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 227 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 228 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 229 | EXPECT_GL_NO_ERROR(); |
| 230 | |
| 231 | glUseProgram(mTextureProgram); |
| 232 | glUniform1i(mTextureUniformLocation, 0); |
| 233 | |
| 234 | // Fill the texture with white pixels |
Jamie Madill | af4ffe0 | 2017-09-09 23:32:48 -0400 | [diff] [blame] | 235 | std::vector<GLColor> whitePixels(mPbufferSize * mPbufferSize, GLColor::white); |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 236 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, static_cast<GLsizei>(mPbufferSize), |
Jamie Madill | af4ffe0 | 2017-09-09 23:32:48 -0400 | [diff] [blame] | 237 | static_cast<GLsizei>(mPbufferSize), 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 238 | whitePixels.data()); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 239 | EXPECT_GL_NO_ERROR(); |
| 240 | |
| 241 | // Draw the white texture and verify that the pixels are correct |
| 242 | drawQuad(mTextureProgram, "position", 0.5f); |
Jamie Madill | af4ffe0 | 2017-09-09 23:32:48 -0400 | [diff] [blame] | 243 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::white); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 244 | |
| 245 | // Bind the EGL surface and draw with it, results are undefined since nothing has |
| 246 | // been written to it |
| 247 | EGLWindow *window = getEGLWindow(); |
| 248 | eglBindTexImage(window->getDisplay(), mPbuffer, EGL_BACK_BUFFER); |
| 249 | drawQuad(mTextureProgram, "position", 0.5f); |
| 250 | EXPECT_GL_NO_ERROR(); |
| 251 | |
| 252 | // Clear the back buffer to a unique color (green) |
| 253 | glClearColor(0.0f, 1.0f, 0.0f, 1.0f); |
| 254 | glClear(GL_COLOR_BUFFER_BIT); |
Jamie Madill | af4ffe0 | 2017-09-09 23:32:48 -0400 | [diff] [blame] | 255 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 256 | |
| 257 | // Unbind the EGL surface and try to draw with the texture again, the texture's size should |
| 258 | // now be zero and incomplete so the back buffer should be black |
| 259 | eglReleaseTexImage(window->getDisplay(), mPbuffer, EGL_BACK_BUFFER); |
| 260 | drawQuad(mTextureProgram, "position", 0.5f); |
Jamie Madill | af4ffe0 | 2017-09-09 23:32:48 -0400 | [diff] [blame] | 261 | EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black); |
Geoff Lang | 0ca42a5 | 2015-04-07 13:47:41 -0400 | [diff] [blame] | 262 | } |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 263 | |
Jamie Madill | bb714f7 | 2015-05-20 10:22:18 -0400 | [diff] [blame] | 264 | // Bind a Pbuffer, redefine the texture, and verify it renders correctly |
| 265 | TEST_P(PbufferTest, BindTexImageAndRedefineTexture) |
| 266 | { |
| 267 | if (!mSupportsPbuffers) |
| 268 | { |
| 269 | std::cout << "Test skipped because Pbuffers are not supported." << std::endl; |
| 270 | return; |
| 271 | } |
| 272 | |
| 273 | if (!mSupportsBindTexImage) |
| 274 | { |
| 275 | std::cout << "Test skipped because Pbuffer does not support binding to RGBA textures." << std::endl; |
| 276 | return; |
| 277 | } |
| 278 | |
| 279 | EGLWindow *window = getEGLWindow(); |
| 280 | |
| 281 | // Apply the Pbuffer and clear it to purple |
| 282 | eglMakeCurrent(window->getDisplay(), mPbuffer, mPbuffer, window->getContext()); |
| 283 | ASSERT_EGL_SUCCESS(); |
| 284 | |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 285 | glViewport(0, 0, static_cast<GLsizei>(mPbufferSize), static_cast<GLsizei>(mPbufferSize)); |
Jamie Madill | bb714f7 | 2015-05-20 10:22:18 -0400 | [diff] [blame] | 286 | glClearColor(1.0f, 0.0f, 1.0f, 1.0f); |
| 287 | glClear(GL_COLOR_BUFFER_BIT); |
| 288 | ASSERT_GL_NO_ERROR(); |
| 289 | |
Cooper Partin | 4d61f7e | 2015-08-12 10:56:50 -0700 | [diff] [blame] | 290 | EXPECT_PIXEL_EQ(static_cast<GLint>(mPbufferSize) / 2, static_cast<GLint>(mPbufferSize) / 2, 255, |
| 291 | 0, 255, 255); |
Jamie Madill | bb714f7 | 2015-05-20 10:22:18 -0400 | [diff] [blame] | 292 | |
| 293 | // Apply the window surface |
Jamie Madill | fe54834 | 2017-06-19 11:13:24 -0400 | [diff] [blame] | 294 | window->makeCurrent(); |
Jamie Madill | bb714f7 | 2015-05-20 10:22:18 -0400 | [diff] [blame] | 295 | |
| 296 | // Create a texture and bind the Pbuffer to it |
| 297 | GLuint texture = 0; |
| 298 | glGenTextures(1, &texture); |
| 299 | glBindTexture(GL_TEXTURE_2D, texture); |
| 300 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
| 301 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
| 302 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 303 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 304 | EXPECT_GL_NO_ERROR(); |
| 305 | |
| 306 | eglBindTexImage(window->getDisplay(), mPbuffer, EGL_BACK_BUFFER); |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 307 | glViewport(0, 0, getWindowWidth(), getWindowHeight()); |
Jamie Madill | bb714f7 | 2015-05-20 10:22:18 -0400 | [diff] [blame] | 308 | ASSERT_EGL_SUCCESS(); |
| 309 | |
| 310 | // Redefine the texture |
| 311 | unsigned int pixelValue = 0xFFFF00FF; |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 312 | std::vector<unsigned int> pixelData(getWindowWidth() * getWindowHeight(), pixelValue); |
| 313 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindowWidth(), getWindowHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixelData[0]); |
Jamie Madill | bb714f7 | 2015-05-20 10:22:18 -0400 | [diff] [blame] | 314 | |
| 315 | // Draw a quad and verify that it is magenta |
| 316 | glUseProgram(mTextureProgram); |
| 317 | glUniform1i(mTextureUniformLocation, 0); |
| 318 | |
| 319 | drawQuad(mTextureProgram, "position", 0.5f); |
| 320 | EXPECT_GL_NO_ERROR(); |
| 321 | |
| 322 | // Verify that magenta was drawn |
Corentin Wallez | f3357ee | 2015-07-22 14:10:19 -0400 | [diff] [blame] | 323 | EXPECT_PIXEL_EQ(getWindowWidth() / 2, getWindowHeight() / 2, 255, 0, 255, 255); |
Jamie Madill | bb714f7 | 2015-05-20 10:22:18 -0400 | [diff] [blame] | 324 | |
| 325 | glDeleteTextures(1, &texture); |
| 326 | } |
| 327 | |
Jamie Madill | fa05f60 | 2015-05-07 13:47:11 -0400 | [diff] [blame] | 328 | // Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against. |
Geoff Lang | e0cc2a4 | 2016-01-20 10:58:17 -0500 | [diff] [blame] | 329 | ANGLE_INSTANTIATE_TEST(PbufferTest, |
| 330 | ES2_D3D9(), |
| 331 | ES2_D3D11(), |
| 332 | ES2_OPENGL(), |
| 333 | ES2_D3D11_WARP(), |
| 334 | ES2_D3D11_REFERENCE(), |
| 335 | ES2_OPENGLES()); |