Hash :
b194c21a
Author :
Date :
2023-02-24T15:41:00
Vulkan: Enforce ContextPriority in ShareGroup and with EGLImage This CL enforces single Context Priority for all Contexts in a Share Group. This is necessary until Vulkan Semaphores will be used to automatically synchronize Resource access between Contexts. Contexts Priority updated when new Contexts is added to the Share Group. New Priority will be the highest among all ever existed Contexts (except if Priority is locked). When Contexts Priority changes, all flushed commands are submitted to the old VkQueue and semaphore is inserted into the new VkQueue. Currently opened RenderPasses and commands will not be flushed. When EGLImage is used in a Context, all Contexts in that Share Group locked (forever) to the Default Priority (Medium). This is done to simplify the implementation and because of the current limitations (lack of mutex protection across Context Share Groups). Notes: - the EGL_CONTEXT_PRIORITY_LEVEL_IMG will report initial priority. - below tests fail on G996B without this CL. Bug: angleproject:8039 Test: angle_end2end_tests --gtest_filter=MultithreadingTestES3.RenderThenSampleDifferentContextPriority* Test: angle_end2end_tests --gtest_filter=MultithreadingTestES3.RenderThenSampleInNewContextWithDifferentPriority* Test: angle_end2end_tests --gtest_filter=MultithreadingTestES3.RenderThenSampleDifferentContextPriorityUsingEGLImage* Change-Id: Ia6a2f0084d39168a58fd7ec33edc90ece9cead05 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4289750 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Igor Nazarov <i.nazarov@samsung.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
//
// Copyright 2021 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.
//
// vk_command_buffer_utils:
// Helpers for secondary command buffer implementations.
//
#ifndef LIBANGLE_RENDERER_VULKAN_VK_COMMAND_BUFFER_UTILS_H_
#define LIBANGLE_RENDERER_VULKAN_VK_COMMAND_BUFFER_UTILS_H_
#include "common/PackedEnums.h"
#include "common/angleutils.h"
namespace rx
{
namespace vk
{
enum class ProtectionType : uint8_t
{
Unprotected = 0,
Protected = 1,
InvalidEnum = 2,
EnumCount = 2,
};
using ProtectionTypes = angle::PackedEnumBitSet<ProtectionType, uint8_t>;
ANGLE_INLINE ProtectionType ConvertProtectionBoolToType(bool isProtected)
{
return (isProtected ? ProtectionType::Protected : ProtectionType::Unprotected);
}
// A helper class to track commands recorded to a command buffer.
class CommandBufferCommandTracker
{
public:
void onDraw() { ++mRenderPassWriteCommandCount; }
void onClearAttachments() { ++mRenderPassWriteCommandCount; }
uint32_t getRenderPassWriteCommandCount() const { return mRenderPassWriteCommandCount; }
void reset() { *this = CommandBufferCommandTracker{}; }
private:
// The number of commands recorded that can modify a render pass attachment, i.e.
// vkCmdClearAttachment and vkCmdDraw*. Used to know if a command might have written to an
// attachment after it was invalidated.
uint32_t mRenderPassWriteCommandCount = 0;
};
} // namespace vk
} // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_VK_COMMAND_BUFFER_UTILS_H_