Hash :
52fe3116
Author :
Date :
2023-07-17T16:20:54
Vulkan: Deduplicate share group's context set tracking Bug: angleproject:8224 Change-Id: I7a59a37229682fb91ff777f31e02e05d7ab2b80f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4690345 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
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
//
// 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.
//
// ShareGroup.h: Defines the egl::ShareGroup class, representing the collection of contexts in a
// share group.
#include "libANGLE/ShareGroup.h"
#include <algorithm>
#include <iterator>
#include <EGL/eglext.h>
#include <platform/PlatformMethods.h>
#include "common/debug.h"
#include "common/platform_helpers.h"
#include "libANGLE/Context.h"
#include "libANGLE/capture/FrameCapture.h"
#include "libANGLE/renderer/DisplayImpl.h"
#include "libANGLE/renderer/ShareGroupImpl.h"
namespace egl
{
// ShareGroupState
ShareGroupState::ShareGroupState()
: mAnyContextWithRobustness(false), mAnyContextWithDisplayTextureShareGroup(false)
{}
ShareGroupState::~ShareGroupState() = default;
void ShareGroupState::addSharedContext(gl::Context *context)
{
mContexts.insert(std::pair(context->id().value, context));
if (context->isRobustnessEnabled())
{
mAnyContextWithRobustness = true;
}
if (context->getState().hasDisplayTextureShareGroup())
{
mAnyContextWithDisplayTextureShareGroup = true;
}
}
void ShareGroupState::removeSharedContext(gl::Context *context)
{
mContexts.erase(context->id().value);
}
// ShareGroup
ShareGroup::ShareGroup(rx::EGLImplFactory *factory)
: mRefCount(1),
mImplementation(factory->createShareGroup(mState)),
mFrameCaptureShared(new angle::FrameCaptureShared)
{}
ShareGroup::~ShareGroup()
{
SafeDelete(mImplementation);
}
void ShareGroup::addRef()
{
// This is protected by global lock, so no atomic is required
mRefCount++;
}
void ShareGroup::release(const Display *display)
{
if (--mRefCount == 0)
{
if (mImplementation)
{
mImplementation->onDestroy(display);
}
delete this;
}
}
void ShareGroup::finishAllContexts()
{
for (auto shareContext : mState.getContexts())
{
if (shareContext.second->hasBeenCurrent() && !shareContext.second->isDestroyed())
{
shareContext.second->finish();
}
}
}
void ShareGroup::addSharedContext(gl::Context *context)
{
mState.addSharedContext(context);
mImplementation->onContextAdd();
}
void ShareGroup::removeSharedContext(gl::Context *context)
{
mState.removeSharedContext(context);
}
} // namespace egl