Commit 09924221 by Ian Elliott Committed by Commit Bot

Convert the EGL end2end tests to use RAII types/macros

These tests are frequently cloned to make new tests, and so it's good to do a more-global refactor so that these and future tests will use RAII. Bug: angleproject:4947 Change-Id: I2973e70ee075629965b18c685793975537e96b6c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2372627Reviewed-by: 's avatarIan Elliott <ianelliott@google.com> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Commit-Queue: Ian Elliott <ianelliott@google.com>
parent 027f0c38
......@@ -159,26 +159,25 @@ void main()
// Compile a shader so it puts something in the cache
if (programBinaryAvailable())
{
GLuint program = CompileProgram(kVertexShaderSrc, kFragmentShaderSrc);
ASSERT_NE(0u, program);
ANGLE_GL_PROGRAM(program, kVertexShaderSrc, kFragmentShaderSrc);
EXPECT_EQ(CacheOpResult::SetSuccess, gLastCacheOpResult);
gLastCacheOpResult = CacheOpResult::ValueNotSet;
// Compile the same shader again, so it would try to retrieve it from the cache
program = CompileProgram(kVertexShaderSrc, kFragmentShaderSrc);
ASSERT_NE(0u, program);
program.makeRaster(kVertexShaderSrc, kFragmentShaderSrc);
ASSERT_TRUE(program.valid());
EXPECT_EQ(CacheOpResult::GetSuccess, gLastCacheOpResult);
gLastCacheOpResult = CacheOpResult::ValueNotSet;
// Compile another shader, which should create a new entry
program = CompileProgram(kVertexShaderSrc2, kFragmentShaderSrc2);
ASSERT_NE(0u, program);
program.makeRaster(kVertexShaderSrc2, kFragmentShaderSrc2);
ASSERT_TRUE(program.valid());
EXPECT_EQ(CacheOpResult::SetSuccess, gLastCacheOpResult);
gLastCacheOpResult = CacheOpResult::ValueNotSet;
// Compile the first shader again, which should still reside in the cache
program = CompileProgram(kVertexShaderSrc, kFragmentShaderSrc);
ASSERT_NE(0u, program);
program.makeRaster(kVertexShaderSrc, kFragmentShaderSrc);
ASSERT_TRUE(program.valid());
EXPECT_EQ(CacheOpResult::GetSuccess, gLastCacheOpResult);
gLastCacheOpResult = CacheOpResult::ValueNotSet;
}
......
......@@ -152,15 +152,13 @@ TEST_P(EGLContextSharingTest, DisplayShareGroupObjectSharing)
ASSERT_EGL_SUCCESS();
// Create a texture and buffer in ctx 0
GLuint textureFromCtx0 = 0;
glGenTextures(1, &textureFromCtx0);
GLTexture textureFromCtx0;
glBindTexture(GL_TEXTURE_2D, textureFromCtx0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glBindTexture(GL_TEXTURE_2D, 0);
ASSERT_GL_TRUE(glIsTexture(textureFromCtx0));
GLuint bufferFromCtx0 = 0;
glGenBuffers(1, &bufferFromCtx0);
GLBuffer bufferFromCtx0;
glBindBuffer(GL_ARRAY_BUFFER, bufferFromCtx0);
glBufferData(GL_ARRAY_BUFFER, 1, nullptr, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
......@@ -178,8 +176,7 @@ TEST_P(EGLContextSharingTest, DisplayShareGroupObjectSharing)
ASSERT_GL_NO_ERROR();
// Call readpixels on the texture to verify that the backend has proper support
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
GLFramebuffer fbo;
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureFromCtx0, 0);
......@@ -187,19 +184,9 @@ TEST_P(EGLContextSharingTest, DisplayShareGroupObjectSharing)
glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
ASSERT_GL_NO_ERROR();
glDeleteFramebuffers(1, &fbo);
glDeleteTextures(1, &textureFromCtx0);
ASSERT_GL_NO_ERROR();
ASSERT_GL_FALSE(glIsTexture(textureFromCtx0));
// Switch back to context 0 and delete the buffer
ASSERT_EGL_TRUE(eglMakeCurrent(display, surface, surface, mContexts[0]));
ASSERT_EGL_SUCCESS();
ASSERT_GL_TRUE(glIsBuffer(bufferFromCtx0));
glDeleteBuffers(1, &bufferFromCtx0);
ASSERT_GL_NO_ERROR();
}
// Tests that shared textures using EGL_ANGLE_display_texture_share_group are released when the last
......@@ -226,8 +213,7 @@ TEST_P(EGLContextSharingTest, DisplayShareGroupReleasedWithLastContext)
// Create a texture and buffer in ctx 0
ASSERT_EGL_TRUE(eglMakeCurrent(display, surface, surface, mContexts[0]));
GLuint textureFromCtx0 = 0;
glGenTextures(1, &textureFromCtx0);
GLTexture textureFromCtx0;
glBindTexture(GL_TEXTURE_2D, textureFromCtx0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glBindTexture(GL_TEXTURE_2D, 0);
......
......@@ -198,7 +198,7 @@ class IOSurfaceClientBufferTest : public ANGLETest
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, getGLTextureTarget(), texture,
0);
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), GL_FRAMEBUFFER_COMPLETE);
ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
EXPECT_GL_NO_ERROR();
glClearColor(1.0f / 255.0f, 2.0f / 255.0f, 3.0f / 255.0f, 4.0f / 255.0f);
......@@ -321,7 +321,7 @@ class IOSurfaceClientBufferTest : public ANGLETest
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, getGLTextureTarget(), texture,
0);
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), GL_FRAMEBUFFER_COMPLETE);
ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
EXPECT_GL_NO_ERROR();
// Create another framebuffer with a regular renderbuffer.
......@@ -335,7 +335,7 @@ class IOSurfaceClientBufferTest : public ANGLETest
EXPECT_GL_NO_ERROR();
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), GL_FRAMEBUFFER_COMPLETE);
ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
EXPECT_GL_NO_ERROR();
glBindRenderbuffer(GL_RENDERBUFFER, 0);
......
......@@ -177,8 +177,7 @@ TEST_P(EGLStreamTest, StreamConsumerGLTextureValidationTest)
ASSERT_EGL_FALSE(result);
ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
GLuint tex;
glGenTextures(1, &tex);
GLTexture tex;
glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex);
result = eglStreamConsumerGLTextureExternalKHR(display, stream);
ASSERT_EGL_TRUE(result);
......@@ -286,8 +285,7 @@ TEST_P(EGLStreamTest, StreamConsumerGLTextureYUVValidationTest)
ASSERT_EGL_FALSE(result);
ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
GLuint tex[2];
glGenTextures(2, tex);
GLTexture tex[2];
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex[0]);
glActiveTexture(GL_TEXTURE1);
......@@ -342,6 +340,7 @@ TEST_P(EGLStreamTest, StreamConsumerGLTextureYUVDeletionTest)
EGL_NONE,
};
// Note: The purpose of this test means that we can't use the RAII GLTexture class
GLuint tex[2];
glGenTextures(2, tex);
glActiveTexture(GL_TEXTURE0);
......@@ -399,7 +398,7 @@ class D3D11TextureStreamSamplingTest : public ANGLETest
glGenFramebuffers(1, &mFB);
glBindFramebuffer(GL_FRAMEBUFFER, mFB);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, mRB);
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
glViewport(0, 0, 2, 2);
glClearColor(1, 0, 0, 1);
......@@ -784,8 +783,7 @@ TEST_P(EGLStreamTest, StreamProducerTextureNV12End2End)
EGL_NONE,
};
GLuint tex[2];
glGenTextures(2, tex);
GLTexture tex[2];
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex[0]);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
......
......@@ -14,6 +14,7 @@
#include "common/Color.h"
#include "common/platform.h"
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
#include "util/EGLWindow.h"
#include "util/OSWindow.h"
#include "util/Timer.h"
......@@ -997,14 +998,12 @@ TEST_P(EGLSurfaceTestD3D11, CreateSurfaceWithTextureOffset)
EXPECT_GL_NO_ERROR();
// Blit framebuffer should also blit to the same subrect despite the dstX/Y arguments.
GLuint renderBuffer = 0;
glGenRenderbuffers(1u, &renderBuffer);
GLRenderbuffer renderBuffer;
glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 50, 50);
EXPECT_GL_NO_ERROR();
GLuint framebuffer = 0;
glGenFramebuffers(1u, &framebuffer);
GLFramebuffer framebuffer;
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderBuffer);
EXPECT_GL_NO_ERROR();
......@@ -1023,10 +1022,6 @@ TEST_P(EGLSurfaceTestD3D11, CreateSurfaceWithTextureOffset)
EXPECT_PIXEL_EQ(25, 25, 0, 0, 0, 255);
EXPECT_PIXEL_EQ(75, 75, 0, 255, 0, 255);
EXPECT_GL_NO_ERROR();
glDeleteFramebuffers(1u, &framebuffer);
glDeleteRenderbuffers(1u, &renderBuffer);
EXPECT_GL_NO_ERROR();
}
TEST_P(EGLSurfaceTestD3D11, CreateSurfaceWithMSAA)
......
......@@ -111,7 +111,7 @@ class EGLSurfacelessContextTest : public ANGLETest
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 500, 500, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex->get(), 0);
EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
}
bool checkExtension(bool verbose = true) const
......@@ -197,7 +197,7 @@ TEST_P(EGLSurfacelessContextTest, CheckFramebufferStatus)
GLTexture tex;
createFramebuffer(&fbo, &tex);
glBindFramebuffer(GL_FRAMEBUFFER, fbo.get());
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
}
// Test that clearing and readpixels work when done in an FBO.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment