Hash :
786d237f
Author :
Date :
2023-01-26T22:24:03
Vulkan: Fixed bug in rx::vk::SharedFence with repeated init(). Bug: b/261106868 Test: angle_white_box_tests VulkanSharedFenceTest* Change-Id: I1e657a52332b2166f05841f91747b1bfec1504e7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4194177 Reviewed-by: Charlie Lao <cclao@google.com> Commit-Queue: Charlie Lao <cclao@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
//
// Copyright 2023 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.
//
// VulkanSharedFenceTest:
// Various tests related for rx::vk::SharedFence class.
//
#include "test_utils/ANGLETest.h"
#include "libANGLE/Display.h"
#include "libANGLE/renderer/vulkan/CommandProcessor.h"
#include "libANGLE/renderer/vulkan/ContextVk.h"
using namespace angle;
namespace
{
class VulkanSharedFenceTest : public ANGLETest<>
{
protected:
gl::Context *hackContext() const
{
egl::Display *display = static_cast<egl::Display *>(getEGLWindow()->getDisplay());
gl::ContextID contextID = {
static_cast<GLuint>(reinterpret_cast<uintptr_t>(getEGLWindow()->getContext()))};
return display->getContext(contextID);
}
rx::ContextVk *hackANGLE() const
{
// Hack the angle!
return rx::GetImplAs<rx::ContextVk>(hackContext());
}
};
// Test init/release/init sequence.
TEST_P(VulkanSharedFenceTest, InitReleaseInit)
{
ASSERT_TRUE(IsVulkan());
rx::ContextVk *contextVk = hackANGLE();
VkDevice device = contextVk->getDevice();
rx::vk::FenceRecycler recycler;
{
rx::vk::SharedFence fence;
VkResult result = fence.init(device, &recycler);
ASSERT_EQ(result, VK_SUCCESS);
fence.release();
result = fence.init(device, &recycler);
ASSERT_EQ(result, VK_SUCCESS);
}
recycler.destroy(contextVk);
}
// Test init/destroy/init sequence.
TEST_P(VulkanSharedFenceTest, InitDestroyInit)
{
ASSERT_TRUE(IsVulkan());
rx::ContextVk *contextVk = hackANGLE();
VkDevice device = contextVk->getDevice();
rx::vk::FenceRecycler recycler;
{
rx::vk::SharedFence fence;
VkResult result = fence.init(device, &recycler);
ASSERT_EQ(result, VK_SUCCESS);
fence.destroy(device);
result = fence.init(device, &recycler);
ASSERT_EQ(result, VK_SUCCESS);
}
recycler.destroy(contextVk);
}
ANGLE_INSTANTIATE_TEST(VulkanSharedFenceTest, ES2_VULKAN());
} // namespace