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() ...@@ -159,26 +159,25 @@ void main()
// Compile a shader so it puts something in the cache // Compile a shader so it puts something in the cache
if (programBinaryAvailable()) if (programBinaryAvailable())
{ {
GLuint program = CompileProgram(kVertexShaderSrc, kFragmentShaderSrc); ANGLE_GL_PROGRAM(program, kVertexShaderSrc, kFragmentShaderSrc);
ASSERT_NE(0u, program);
EXPECT_EQ(CacheOpResult::SetSuccess, gLastCacheOpResult); EXPECT_EQ(CacheOpResult::SetSuccess, gLastCacheOpResult);
gLastCacheOpResult = CacheOpResult::ValueNotSet; gLastCacheOpResult = CacheOpResult::ValueNotSet;
// Compile the same shader again, so it would try to retrieve it from the cache // Compile the same shader again, so it would try to retrieve it from the cache
program = CompileProgram(kVertexShaderSrc, kFragmentShaderSrc); program.makeRaster(kVertexShaderSrc, kFragmentShaderSrc);
ASSERT_NE(0u, program); ASSERT_TRUE(program.valid());
EXPECT_EQ(CacheOpResult::GetSuccess, gLastCacheOpResult); EXPECT_EQ(CacheOpResult::GetSuccess, gLastCacheOpResult);
gLastCacheOpResult = CacheOpResult::ValueNotSet; gLastCacheOpResult = CacheOpResult::ValueNotSet;
// Compile another shader, which should create a new entry // Compile another shader, which should create a new entry
program = CompileProgram(kVertexShaderSrc2, kFragmentShaderSrc2); program.makeRaster(kVertexShaderSrc2, kFragmentShaderSrc2);
ASSERT_NE(0u, program); ASSERT_TRUE(program.valid());
EXPECT_EQ(CacheOpResult::SetSuccess, gLastCacheOpResult); EXPECT_EQ(CacheOpResult::SetSuccess, gLastCacheOpResult);
gLastCacheOpResult = CacheOpResult::ValueNotSet; gLastCacheOpResult = CacheOpResult::ValueNotSet;
// Compile the first shader again, which should still reside in the cache // Compile the first shader again, which should still reside in the cache
program = CompileProgram(kVertexShaderSrc, kFragmentShaderSrc); program.makeRaster(kVertexShaderSrc, kFragmentShaderSrc);
ASSERT_NE(0u, program); ASSERT_TRUE(program.valid());
EXPECT_EQ(CacheOpResult::GetSuccess, gLastCacheOpResult); EXPECT_EQ(CacheOpResult::GetSuccess, gLastCacheOpResult);
gLastCacheOpResult = CacheOpResult::ValueNotSet; gLastCacheOpResult = CacheOpResult::ValueNotSet;
} }
......
...@@ -152,15 +152,13 @@ TEST_P(EGLContextSharingTest, DisplayShareGroupObjectSharing) ...@@ -152,15 +152,13 @@ TEST_P(EGLContextSharingTest, DisplayShareGroupObjectSharing)
ASSERT_EGL_SUCCESS(); ASSERT_EGL_SUCCESS();
// Create a texture and buffer in ctx 0 // Create a texture and buffer in ctx 0
GLuint textureFromCtx0 = 0; GLTexture textureFromCtx0;
glGenTextures(1, &textureFromCtx0);
glBindTexture(GL_TEXTURE_2D, textureFromCtx0); glBindTexture(GL_TEXTURE_2D, textureFromCtx0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
ASSERT_GL_TRUE(glIsTexture(textureFromCtx0)); ASSERT_GL_TRUE(glIsTexture(textureFromCtx0));
GLuint bufferFromCtx0 = 0; GLBuffer bufferFromCtx0;
glGenBuffers(1, &bufferFromCtx0);
glBindBuffer(GL_ARRAY_BUFFER, bufferFromCtx0); glBindBuffer(GL_ARRAY_BUFFER, bufferFromCtx0);
glBufferData(GL_ARRAY_BUFFER, 1, nullptr, GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, 1, nullptr, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
...@@ -178,8 +176,7 @@ TEST_P(EGLContextSharingTest, DisplayShareGroupObjectSharing) ...@@ -178,8 +176,7 @@ TEST_P(EGLContextSharingTest, DisplayShareGroupObjectSharing)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
// Call readpixels on the texture to verify that the backend has proper support // Call readpixels on the texture to verify that the backend has proper support
GLuint fbo = 0; GLFramebuffer fbo;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo); glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureFromCtx0, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureFromCtx0, 0);
...@@ -187,19 +184,9 @@ TEST_P(EGLContextSharingTest, DisplayShareGroupObjectSharing) ...@@ -187,19 +184,9 @@ TEST_P(EGLContextSharingTest, DisplayShareGroupObjectSharing)
glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel); glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
ASSERT_GL_NO_ERROR(); 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 // Switch back to context 0 and delete the buffer
ASSERT_EGL_TRUE(eglMakeCurrent(display, surface, surface, mContexts[0])); ASSERT_EGL_TRUE(eglMakeCurrent(display, surface, surface, mContexts[0]));
ASSERT_EGL_SUCCESS(); 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 // Tests that shared textures using EGL_ANGLE_display_texture_share_group are released when the last
...@@ -226,8 +213,7 @@ TEST_P(EGLContextSharingTest, DisplayShareGroupReleasedWithLastContext) ...@@ -226,8 +213,7 @@ TEST_P(EGLContextSharingTest, DisplayShareGroupReleasedWithLastContext)
// Create a texture and buffer in ctx 0 // Create a texture and buffer in ctx 0
ASSERT_EGL_TRUE(eglMakeCurrent(display, surface, surface, mContexts[0])); ASSERT_EGL_TRUE(eglMakeCurrent(display, surface, surface, mContexts[0]));
GLuint textureFromCtx0 = 0; GLTexture textureFromCtx0;
glGenTextures(1, &textureFromCtx0);
glBindTexture(GL_TEXTURE_2D, textureFromCtx0); glBindTexture(GL_TEXTURE_2D, textureFromCtx0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
......
...@@ -198,7 +198,7 @@ class IOSurfaceClientBufferTest : public ANGLETest ...@@ -198,7 +198,7 @@ class IOSurfaceClientBufferTest : public ANGLETest
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, getGLTextureTarget(), texture, glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, getGLTextureTarget(), texture,
0); 0);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), GL_FRAMEBUFFER_COMPLETE); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
glClearColor(1.0f / 255.0f, 2.0f / 255.0f, 3.0f / 255.0f, 4.0f / 255.0f); 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 ...@@ -321,7 +321,7 @@ class IOSurfaceClientBufferTest : public ANGLETest
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, getGLTextureTarget(), texture, glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, getGLTextureTarget(), texture,
0); 0);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), GL_FRAMEBUFFER_COMPLETE); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
// Create another framebuffer with a regular renderbuffer. // Create another framebuffer with a regular renderbuffer.
...@@ -335,7 +335,7 @@ class IOSurfaceClientBufferTest : public ANGLETest ...@@ -335,7 +335,7 @@ class IOSurfaceClientBufferTest : public ANGLETest
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rbo);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
EXPECT_GLENUM_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), GL_FRAMEBUFFER_COMPLETE); ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
glBindRenderbuffer(GL_RENDERBUFFER, 0); glBindRenderbuffer(GL_RENDERBUFFER, 0);
......
...@@ -177,8 +177,7 @@ TEST_P(EGLStreamTest, StreamConsumerGLTextureValidationTest) ...@@ -177,8 +177,7 @@ TEST_P(EGLStreamTest, StreamConsumerGLTextureValidationTest)
ASSERT_EGL_FALSE(result); ASSERT_EGL_FALSE(result);
ASSERT_EGL_ERROR(EGL_BAD_ACCESS); ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
GLuint tex; GLTexture tex;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex); glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex);
result = eglStreamConsumerGLTextureExternalKHR(display, stream); result = eglStreamConsumerGLTextureExternalKHR(display, stream);
ASSERT_EGL_TRUE(result); ASSERT_EGL_TRUE(result);
...@@ -286,8 +285,7 @@ TEST_P(EGLStreamTest, StreamConsumerGLTextureYUVValidationTest) ...@@ -286,8 +285,7 @@ TEST_P(EGLStreamTest, StreamConsumerGLTextureYUVValidationTest)
ASSERT_EGL_FALSE(result); ASSERT_EGL_FALSE(result);
ASSERT_EGL_ERROR(EGL_BAD_ACCESS); ASSERT_EGL_ERROR(EGL_BAD_ACCESS);
GLuint tex[2]; GLTexture tex[2];
glGenTextures(2, tex);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex[0]); glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex[0]);
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
...@@ -342,6 +340,7 @@ TEST_P(EGLStreamTest, StreamConsumerGLTextureYUVDeletionTest) ...@@ -342,6 +340,7 @@ TEST_P(EGLStreamTest, StreamConsumerGLTextureYUVDeletionTest)
EGL_NONE, EGL_NONE,
}; };
// Note: The purpose of this test means that we can't use the RAII GLTexture class
GLuint tex[2]; GLuint tex[2];
glGenTextures(2, tex); glGenTextures(2, tex);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
...@@ -399,7 +398,7 @@ class D3D11TextureStreamSamplingTest : public ANGLETest ...@@ -399,7 +398,7 @@ class D3D11TextureStreamSamplingTest : public ANGLETest
glGenFramebuffers(1, &mFB); glGenFramebuffers(1, &mFB);
glBindFramebuffer(GL_FRAMEBUFFER, mFB); glBindFramebuffer(GL_FRAMEBUFFER, mFB);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, mRB); 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); glViewport(0, 0, 2, 2);
glClearColor(1, 0, 0, 1); glClearColor(1, 0, 0, 1);
...@@ -784,8 +783,7 @@ TEST_P(EGLStreamTest, StreamProducerTextureNV12End2End) ...@@ -784,8 +783,7 @@ TEST_P(EGLStreamTest, StreamProducerTextureNV12End2End)
EGL_NONE, EGL_NONE,
}; };
GLuint tex[2]; GLTexture tex[2];
glGenTextures(2, tex);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex[0]); glBindTexture(GL_TEXTURE_EXTERNAL_OES, tex[0]);
glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "common/Color.h" #include "common/Color.h"
#include "common/platform.h" #include "common/platform.h"
#include "test_utils/ANGLETest.h" #include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
#include "util/EGLWindow.h" #include "util/EGLWindow.h"
#include "util/OSWindow.h" #include "util/OSWindow.h"
#include "util/Timer.h" #include "util/Timer.h"
...@@ -997,14 +998,12 @@ TEST_P(EGLSurfaceTestD3D11, CreateSurfaceWithTextureOffset) ...@@ -997,14 +998,12 @@ TEST_P(EGLSurfaceTestD3D11, CreateSurfaceWithTextureOffset)
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
// Blit framebuffer should also blit to the same subrect despite the dstX/Y arguments. // Blit framebuffer should also blit to the same subrect despite the dstX/Y arguments.
GLuint renderBuffer = 0; GLRenderbuffer renderBuffer;
glGenRenderbuffers(1u, &renderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer); glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 50, 50); glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 50, 50);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
GLuint framebuffer = 0; GLFramebuffer framebuffer;
glGenFramebuffers(1u, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderBuffer); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderBuffer);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
...@@ -1023,10 +1022,6 @@ TEST_P(EGLSurfaceTestD3D11, CreateSurfaceWithTextureOffset) ...@@ -1023,10 +1022,6 @@ TEST_P(EGLSurfaceTestD3D11, CreateSurfaceWithTextureOffset)
EXPECT_PIXEL_EQ(25, 25, 0, 0, 0, 255); EXPECT_PIXEL_EQ(25, 25, 0, 0, 0, 255);
EXPECT_PIXEL_EQ(75, 75, 0, 255, 0, 255); EXPECT_PIXEL_EQ(75, 75, 0, 255, 0, 255);
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
glDeleteFramebuffers(1u, &framebuffer);
glDeleteRenderbuffers(1u, &renderBuffer);
EXPECT_GL_NO_ERROR();
} }
TEST_P(EGLSurfaceTestD3D11, CreateSurfaceWithMSAA) TEST_P(EGLSurfaceTestD3D11, CreateSurfaceWithMSAA)
......
...@@ -111,7 +111,7 @@ class EGLSurfacelessContextTest : public ANGLETest ...@@ -111,7 +111,7 @@ class EGLSurfacelessContextTest : public ANGLETest
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 500, 500, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); 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); 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 bool checkExtension(bool verbose = true) const
...@@ -197,7 +197,7 @@ TEST_P(EGLSurfacelessContextTest, CheckFramebufferStatus) ...@@ -197,7 +197,7 @@ TEST_P(EGLSurfacelessContextTest, CheckFramebufferStatus)
GLTexture tex; GLTexture tex;
createFramebuffer(&fbo, &tex); createFramebuffer(&fbo, &tex);
glBindFramebuffer(GL_FRAMEBUFFER, fbo.get()); 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. // 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