Hash :
44a5c913
Author :
Date :
2021-06-17T09:29:29
CL: Make CL front end and back end thread-safe Add locking to all mutable variables of the CL objects in the front end and pass-through back end to make them thread-safe. This fixes a crash in a multi-threaded CTS test. Bug: angleproject:6015 Change-Id: I1d6471c851217639411c434c82acd32d14035291 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2967468 Commit-Queue: John Plate <jplate@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
//
// 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.
//
// CLSamplerCL.cpp: Implements the class methods for CLSamplerCL.
#include "libANGLE/renderer/cl/CLSamplerCL.h"
#include "libANGLE/renderer/cl/CLContextCL.h"
#include "libANGLE/CLContext.h"
#include "libANGLE/CLSampler.h"
namespace rx
{
CLSamplerCL::CLSamplerCL(const cl::Sampler &sampler, cl_sampler native)
: CLSamplerImpl(sampler), mNative(native)
{
sampler.getContext().getImpl<CLContextCL>().mData->mSamplers.emplace(sampler.getNative());
}
CLSamplerCL::~CLSamplerCL()
{
const size_t numRemoved =
mSampler.getContext().getImpl<CLContextCL>().mData->mSamplers.erase(mSampler.getNative());
ASSERT(numRemoved == 1u);
if (mNative->getDispatch().clReleaseSampler(mNative) != CL_SUCCESS)
{
ERR() << "Error while releasing CL sampler";
}
}
} // namespace rx