Hash :
4cc9e0af
Author :
Date :
2023-10-31T11:19:51
Capture Tests: Fix unintentional gen-on-bind usage A handful of tests are binding handles without glGen'ing them first. This causes mismatched handles in capture_replay_test.py now that replay inserts additional gen calls for resources that aren't explicitly gen'd. For handles that are intentionally gen-on-bind, clean up the GL state so it doesn't miscompare. Test: capture_replay_tests.py --gtest_filter=*/ES3_Vulkan_SwiftShader Bug: b/303100333 Change-Id: I5ce8060ff62264b3d648722b3c4542a136d95db5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4994414 Reviewed-by: Roman Lavrov <romanl@google.com> Commit-Queue: Mike Schuchardt <mikes@lunarg.com> Reviewed-by: Cody Northrop <cnorthrop@google.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ObjectAllocationTest
// Tests for object allocations and lifetimes.
//
#include "test_utils/ANGLETest.h"
using namespace angle;
namespace
{
class ObjectAllocationTest : public ANGLETest<>
{
protected:
ObjectAllocationTest() {}
};
class ObjectAllocationTestES3 : public ObjectAllocationTest
{};
// Test that we don't re-allocate a bound framebuffer ID.
TEST_P(ObjectAllocationTestES3, BindFramebufferBeforeGen)
{
glBindFramebuffer(GL_FRAMEBUFFER, 1);
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
EXPECT_NE(1u, fbo);
glDeleteFramebuffers(1, &fbo);
EXPECT_GL_NO_ERROR();
}
// Test that we don't re-allocate a bound framebuffer ID, other pattern.
TEST_P(ObjectAllocationTestES3, BindFramebufferAfterGen)
{
GLuint reservedFBO1 = 1;
GLuint reservedFBO2 = 2;
GLuint firstFBO = 0;
glGenFramebuffers(1, &firstFBO);
glBindFramebuffer(GL_FRAMEBUFFER, reservedFBO1);
glDeleteFramebuffers(1, &firstFBO);
glBindFramebuffer(GL_FRAMEBUFFER, reservedFBO2);
GLuint secondFBOs[2] = {0};
glGenFramebuffers(2, secondFBOs);
EXPECT_NE(reservedFBO2, secondFBOs[0]);
EXPECT_NE(reservedFBO2, secondFBOs[1]);
glDeleteFramebuffers(2, secondFBOs);
// Clean up
glDeleteFramebuffers(1, &reservedFBO1);
glDeleteFramebuffers(1, &reservedFBO2);
EXPECT_GL_NO_ERROR();
}
// Test that we don't re-allocate a bound framebuffer ID.
TEST_P(ObjectAllocationTest, BindRenderbuffer)
{
GLuint rbId;
glGenRenderbuffers(1, &rbId);
glBindRenderbuffer(GL_RENDERBUFFER, rbId);
EXPECT_GL_NO_ERROR();
// Swap now to trigger the serialization of the renderbuffer that
// was initialized with the default values
swapBuffers();
glDeleteRenderbuffers(1, &rbId);
EXPECT_GL_NO_ERROR();
}
// Renderbuffers can be created on the fly by calling glBindRenderbuffer,
// so// check that the call doesn't fail that the renderbuffer is also deleted
TEST_P(ObjectAllocationTest, BindRenderbufferBeforeGenAndDelete)
{
GLuint rbId = 1;
glBindRenderbuffer(GL_RENDERBUFFER, rbId);
EXPECT_GL_NO_ERROR();
// Swap now to trigger the serialization of the renderbuffer that
// was initialized with the default values
swapBuffers();
glDeleteRenderbuffers(1, &rbId);
EXPECT_GL_NO_ERROR();
}
// Buffers can be created on the fly by calling glBindBuffer, so
// check that the call doesn't fail that the buffer is also deleted
TEST_P(ObjectAllocationTest, BindBufferBeforeGenAndDelete)
{
GLuint id = 1;
glBindBuffer(GL_ARRAY_BUFFER, id);
EXPECT_GL_NO_ERROR();
// trigger serialization to capture the created buffer ID
swapBuffers();
glDeleteBuffers(1, &id);
EXPECT_GL_NO_ERROR();
}
// Textures can be created on the fly by calling glBindTexture, so
// check that the call doesn't fail that the texture is also deleted
TEST_P(ObjectAllocationTest, BindTextureBeforeGenAndDelete)
{
GLuint id = 1;
glBindTexture(GL_TEXTURE_2D, id);
EXPECT_GL_NO_ERROR();
// trigger serialization to capture the created texture ID
swapBuffers();
glDeleteTextures(1, &id);
EXPECT_GL_NO_ERROR();
}
} // anonymous namespace
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ObjectAllocationTest);
ANGLE_INSTANTIATE_TEST_ES2(ObjectAllocationTest);
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(ObjectAllocationTestES3);
ANGLE_INSTANTIATE_TEST_ES3(ObjectAllocationTestES3);