gfxstream: guest: nuke AndroidLock
Removes dependency on gfxstream::guest's AEMU lock classes. Mostly consists on Autolock<RecursiveMutex> to std::lock_guard<std::recursive_mutex>. There are some cases where the code does: Autolock<RecursiveMutex> lock(mLock) .. lock.unlock() [ do something ] lock.lock(). .. Those cases were replaced with std::unique_lock. Reviewed-by: Aaron Ruby <aruby@blackberry.com> Acked-by: Yonggang Luo <luoyonggang@gmail.com> Acked-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
committed by
Marge Bot
parent
5cb32d45a8
commit
109a7b8d54
@@ -129,7 +129,7 @@ uint32_t ResourceTracker::streamFeatureBits = 0;
|
||||
ResourceTracker::ThreadingCallbacks ResourceTracker::threadingCallbacks;
|
||||
|
||||
struct StagingInfo {
|
||||
Lock mLock;
|
||||
std::mutex mLock;
|
||||
std::vector<CommandBufferStagingStream*> streams;
|
||||
std::vector<VkEncoder*> encoders;
|
||||
/// \brief sets alloc and free callbacks for memory allocation for CommandBufferStagingStream(s)
|
||||
@@ -152,14 +152,14 @@ struct StagingInfo {
|
||||
}
|
||||
|
||||
void pushStaging(CommandBufferStagingStream* stream, VkEncoder* encoder) {
|
||||
AutoLock<Lock> lock(mLock);
|
||||
std::lock_guard<std::mutex> lock(mLock);
|
||||
stream->reset();
|
||||
streams.push_back(stream);
|
||||
encoders.push_back(encoder);
|
||||
}
|
||||
|
||||
void popStaging(CommandBufferStagingStream** streamOut, VkEncoder** encoderOut) {
|
||||
AutoLock<Lock> lock(mLock);
|
||||
std::lock_guard<std::mutex> lock(mLock);
|
||||
CommandBufferStagingStream* stream;
|
||||
VkEncoder* encoder;
|
||||
if (streams.empty()) {
|
||||
@@ -191,16 +191,16 @@ struct CommandBufferPendingDescriptorSets {
|
||||
std::unordered_set<VkDescriptorSet> sets;
|
||||
};
|
||||
|
||||
#define HANDLE_REGISTER_IMPL_IMPL(type) \
|
||||
void ResourceTracker::register_##type(type obj) { \
|
||||
AutoLock<RecursiveLock> lock(mLock); \
|
||||
info_##type[obj] = type##_Info(); \
|
||||
#define HANDLE_REGISTER_IMPL_IMPL(type) \
|
||||
void ResourceTracker::register_##type(type obj) { \
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock); \
|
||||
info_##type[obj] = type##_Info(); \
|
||||
}
|
||||
|
||||
#define HANDLE_UNREGISTER_IMPL_IMPL(type) \
|
||||
void ResourceTracker::unregister_##type(type obj) { \
|
||||
AutoLock<RecursiveLock> lock(mLock); \
|
||||
info_##type.erase(obj); \
|
||||
#define HANDLE_UNREGISTER_IMPL_IMPL(type) \
|
||||
void ResourceTracker::unregister_##type(type obj) { \
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock); \
|
||||
info_##type.erase(obj); \
|
||||
}
|
||||
|
||||
GOLDFISH_VK_LIST_HANDLE_TYPES(HANDLE_REGISTER_IMPL_IMPL)
|
||||
@@ -1018,23 +1018,21 @@ void ResourceTracker::ensureSyncDeviceFd() {
|
||||
}
|
||||
|
||||
void ResourceTracker::unregister_VkInstance(VkInstance instance) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkInstance.find(instance);
|
||||
if (it == info_VkInstance.end()) return;
|
||||
auto info = it->second;
|
||||
info_VkInstance.erase(instance);
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
void ResourceTracker::unregister_VkDevice(VkDevice device) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkDevice.find(device);
|
||||
if (it == info_VkDevice.end()) return;
|
||||
auto info = it->second;
|
||||
info_VkDevice.erase(device);
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
void ResourceTracker::unregister_VkCommandPool(VkCommandPool pool) {
|
||||
@@ -1042,14 +1040,14 @@ void ResourceTracker::unregister_VkCommandPool(VkCommandPool pool) {
|
||||
|
||||
clearCommandPool(pool);
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
info_VkCommandPool.erase(pool);
|
||||
}
|
||||
|
||||
void ResourceTracker::unregister_VkSampler(VkSampler sampler) {
|
||||
if (!sampler) return;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
info_VkSampler.erase(sampler);
|
||||
}
|
||||
|
||||
@@ -1075,7 +1073,7 @@ void ResourceTracker::unregister_VkCommandBuffer(VkCommandBuffer commandBuffer)
|
||||
delete pendingSets;
|
||||
}
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
info_VkCommandBuffer.erase(commandBuffer);
|
||||
}
|
||||
|
||||
@@ -1086,12 +1084,12 @@ void ResourceTracker::unregister_VkQueue(VkQueue queue) {
|
||||
q->lastUsedEncoder->decRef();
|
||||
}
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
info_VkQueue.erase(queue);
|
||||
}
|
||||
|
||||
void ResourceTracker::unregister_VkDeviceMemory(VkDeviceMemory mem) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkDeviceMemory.find(mem);
|
||||
if (it == info_VkDeviceMemory.end()) return;
|
||||
@@ -1114,7 +1112,7 @@ void ResourceTracker::unregister_VkDeviceMemory(VkDeviceMemory mem) {
|
||||
}
|
||||
|
||||
void ResourceTracker::unregister_VkImage(VkImage img) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkImage.find(img);
|
||||
if (it == info_VkImage.end()) return;
|
||||
@@ -1125,7 +1123,7 @@ void ResourceTracker::unregister_VkImage(VkImage img) {
|
||||
}
|
||||
|
||||
void ResourceTracker::unregister_VkBuffer(VkBuffer buf) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkBuffer.find(buf);
|
||||
if (it == info_VkBuffer.end()) return;
|
||||
@@ -1134,7 +1132,7 @@ void ResourceTracker::unregister_VkBuffer(VkBuffer buf) {
|
||||
}
|
||||
|
||||
void ResourceTracker::unregister_VkSemaphore(VkSemaphore sem) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkSemaphore.find(sem);
|
||||
if (it == info_VkSemaphore.end()) return;
|
||||
@@ -1157,7 +1155,7 @@ void ResourceTracker::unregister_VkSemaphore(VkSemaphore sem) {
|
||||
}
|
||||
|
||||
void ResourceTracker::unregister_VkDescriptorUpdateTemplate(VkDescriptorUpdateTemplate templ) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto it = info_VkDescriptorUpdateTemplate.find(templ);
|
||||
if (it == info_VkDescriptorUpdateTemplate.end()) return;
|
||||
|
||||
@@ -1179,7 +1177,7 @@ void ResourceTracker::unregister_VkDescriptorUpdateTemplate(VkDescriptorUpdateTe
|
||||
}
|
||||
|
||||
void ResourceTracker::unregister_VkFence(VkFence fence) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto it = info_VkFence.find(fence);
|
||||
if (it == info_VkFence.end()) return;
|
||||
|
||||
@@ -1199,7 +1197,7 @@ void ResourceTracker::unregister_VkFence(VkFence fence) {
|
||||
|
||||
#ifdef VK_USE_PLATFORM_FUCHSIA
|
||||
void ResourceTracker::unregister_VkBufferCollectionFUCHSIA(VkBufferCollectionFUCHSIA collection) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
info_VkBufferCollectionFUCHSIA.erase(collection);
|
||||
}
|
||||
#endif
|
||||
@@ -1213,14 +1211,14 @@ void ResourceTracker::unregister_VkDescriptorSet_locked(VkDescriptorSet set) {
|
||||
void ResourceTracker::unregister_VkDescriptorSet(VkDescriptorSet set) {
|
||||
if (!set) return;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
unregister_VkDescriptorSet_locked(set);
|
||||
}
|
||||
|
||||
void ResourceTracker::unregister_VkDescriptorSetLayout(VkDescriptorSetLayout setLayout) {
|
||||
if (!setLayout) return;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
delete as_goldfish_VkDescriptorSetLayout(setLayout)->layoutInfo;
|
||||
info_VkDescriptorSetLayout.erase(setLayout);
|
||||
}
|
||||
@@ -1257,7 +1255,7 @@ void ResourceTracker::clearDescriptorPoolAndUnregisterDescriptorSets(void* conte
|
||||
void ResourceTracker::unregister_VkDescriptorPool(VkDescriptorPool pool) {
|
||||
if (!pool) return;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
struct goldfish_VkDescriptorPool* dp = as_goldfish_VkDescriptorPool(pool);
|
||||
delete dp->allocInfo;
|
||||
@@ -1301,7 +1299,7 @@ void ResourceTracker::transformImpl_VkExternalMemoryProperties_fromhost(
|
||||
void ResourceTracker::setInstanceInfo(VkInstance instance, uint32_t enabledExtensionCount,
|
||||
const char* const* ppEnabledExtensionNames,
|
||||
uint32_t apiVersion) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto& info = info_VkInstance[instance];
|
||||
info.highestApiVersion = apiVersion;
|
||||
|
||||
@@ -1317,7 +1315,7 @@ void ResourceTracker::setDeviceInfo(VkDevice device, VkPhysicalDevice physdev,
|
||||
VkPhysicalDeviceMemoryProperties memProps,
|
||||
uint32_t enabledExtensionCount,
|
||||
const char* const* ppEnabledExtensionNames, const void* pNext) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto& info = info_VkDevice[device];
|
||||
info.physdev = physdev;
|
||||
info.props = props;
|
||||
@@ -1353,7 +1351,7 @@ void ResourceTracker::setDeviceMemoryInfo(VkDevice device, VkDeviceMemory memory
|
||||
uint32_t memoryTypeIndex, AHardwareBuffer* ahw,
|
||||
bool imported, zx_handle_t vmoHandle,
|
||||
VirtGpuResourcePtr blobPtr) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto& info = info_VkDeviceMemory[memory];
|
||||
|
||||
info.device = device;
|
||||
@@ -1370,7 +1368,7 @@ void ResourceTracker::setDeviceMemoryInfo(VkDevice device, VkDeviceMemory memory
|
||||
|
||||
void ResourceTracker::setImageInfo(VkImage image, VkDevice device,
|
||||
const VkImageCreateInfo* pCreateInfo) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto& info = info_VkImage[image];
|
||||
|
||||
info.device = device;
|
||||
@@ -1378,7 +1376,7 @@ void ResourceTracker::setImageInfo(VkImage image, VkDevice device,
|
||||
}
|
||||
|
||||
uint8_t* ResourceTracker::getMappedPointer(VkDeviceMemory memory) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
const auto it = info_VkDeviceMemory.find(memory);
|
||||
if (it == info_VkDeviceMemory.end()) return nullptr;
|
||||
|
||||
@@ -1387,7 +1385,7 @@ uint8_t* ResourceTracker::getMappedPointer(VkDeviceMemory memory) {
|
||||
}
|
||||
|
||||
VkDeviceSize ResourceTracker::getMappedSize(VkDeviceMemory memory) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
const auto it = info_VkDeviceMemory.find(memory);
|
||||
if (it == info_VkDeviceMemory.end()) return 0;
|
||||
|
||||
@@ -1395,8 +1393,8 @@ VkDeviceSize ResourceTracker::getMappedSize(VkDeviceMemory memory) {
|
||||
return info.allocationSize;
|
||||
}
|
||||
|
||||
bool ResourceTracker::isValidMemoryRange(const VkMappedMemoryRange& range) const {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
bool ResourceTracker::isValidMemoryRange(const VkMappedMemoryRange& range) {
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
const auto it = info_VkDeviceMemory.find(range.memory);
|
||||
if (it == info_VkDeviceMemory.end()) return false;
|
||||
const auto& info = it->second;
|
||||
@@ -1570,7 +1568,7 @@ void ResourceTracker::deviceMemoryTransform_tohost(VkDeviceMemory* memory, uint3
|
||||
(void)typeBitsCount;
|
||||
|
||||
if (memory) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
for (uint32_t i = 0; i < memoryCount; ++i) {
|
||||
VkDeviceMemory mem = memory[i];
|
||||
@@ -1972,7 +1970,7 @@ VkResult ResourceTracker::on_vkEnumeratePhysicalDevices(void* context, VkResult,
|
||||
|
||||
if (!pPhysicalDeviceCount) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::unique_lock<std::recursive_mutex> lock(mLock);
|
||||
|
||||
// When this function is called, we actually need to do two things:
|
||||
// - Get full information about physical devices from the host,
|
||||
@@ -2122,13 +2120,13 @@ void ResourceTracker::on_vkGetPhysicalDeviceMemoryProperties2(
|
||||
|
||||
void ResourceTracker::on_vkGetDeviceQueue(void*, VkDevice device, uint32_t, uint32_t,
|
||||
VkQueue* pQueue) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
info_VkQueue[*pQueue].device = device;
|
||||
}
|
||||
|
||||
void ResourceTracker::on_vkGetDeviceQueue2(void*, VkDevice device, const VkDeviceQueueInfo2*,
|
||||
VkQueue* pQueue) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
info_VkQueue[*pQueue].device = device;
|
||||
}
|
||||
|
||||
@@ -2171,7 +2169,7 @@ VkResult ResourceTracker::on_vkCreateDevice(void* context, VkResult input_result
|
||||
void ResourceTracker::on_vkDestroyDevice_pre(void* context, VkDevice device,
|
||||
const VkAllocationCallbacks*) {
|
||||
(void)context;
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkDevice.find(device);
|
||||
if (it == info_VkDevice.end()) return;
|
||||
@@ -2216,7 +2214,7 @@ VkResult ResourceTracker::on_vkGetMemoryAndroidHardwareBufferANDROID(
|
||||
if (!pInfo) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
if (!pInfo->memory) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto deviceIt = info_VkDevice.find(device);
|
||||
|
||||
@@ -2250,7 +2248,7 @@ VkResult ResourceTracker::on_vkGetMemoryZirconHandleFUCHSIA(
|
||||
if (!pInfo) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
if (!pInfo->memory) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto deviceIt = info_VkDevice.find(device);
|
||||
|
||||
@@ -2293,7 +2291,7 @@ VkResult ResourceTracker::on_vkGetMemoryZirconHandlePropertiesFUCHSIA(
|
||||
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
|
||||
}
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto deviceIt = info_VkDevice.find(device);
|
||||
|
||||
@@ -2367,7 +2365,7 @@ VkResult ResourceTracker::on_vkImportSemaphoreZirconHandleFUCHSIA(
|
||||
if (!pInfo) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
if (!pInfo->semaphore) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto deviceIt = info_VkDevice.find(device);
|
||||
|
||||
@@ -2404,7 +2402,7 @@ VkResult ResourceTracker::on_vkGetSemaphoreZirconHandleFUCHSIA(
|
||||
if (!pInfo) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
if (!pInfo->semaphore) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto deviceIt = info_VkDevice.find(device);
|
||||
|
||||
@@ -2516,7 +2514,7 @@ SetBufferCollectionImageConstraintsResult ResourceTracker::setBufferCollectionIm
|
||||
|
||||
VkPhysicalDevice physicalDevice;
|
||||
{
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto deviceIt = info_VkDevice.find(device);
|
||||
if (deviceIt == info_VkDevice.end()) {
|
||||
return {VK_ERROR_INITIALIZATION_FAILED};
|
||||
@@ -2629,7 +2627,7 @@ VkResult ResourceTracker::setBufferCollectionImageConstraintsFUCHSIA(
|
||||
|
||||
// copy constraints to info_VkBufferCollectionFUCHSIA if
|
||||
// |collection| is a valid VkBufferCollectionFUCHSIA handle.
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
VkBufferCollectionFUCHSIA buffer_collection =
|
||||
reinterpret_cast<VkBufferCollectionFUCHSIA>(pCollection);
|
||||
if (info_VkBufferCollectionFUCHSIA.find(buffer_collection) !=
|
||||
@@ -2654,7 +2652,7 @@ VkResult ResourceTracker::setBufferCollectionBufferConstraintsFUCHSIA(
|
||||
|
||||
// copy constraints to info_VkBufferCollectionFUCHSIA if
|
||||
// |collection| is a valid VkBufferCollectionFUCHSIA handle.
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
VkBufferCollectionFUCHSIA buffer_collection =
|
||||
reinterpret_cast<VkBufferCollectionFUCHSIA>(pCollection);
|
||||
if (info_VkBufferCollectionFUCHSIA.find(buffer_collection) !=
|
||||
@@ -2775,7 +2773,7 @@ VkResult ResourceTracker::on_vkGetBufferCollectionPropertiesFUCHSIA(
|
||||
// memoryTypeBits
|
||||
// ====================================================================
|
||||
{
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto deviceIt = info_VkDevice.find(device);
|
||||
if (deviceIt == info_VkDevice.end()) {
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
@@ -2800,7 +2798,7 @@ VkResult ResourceTracker::on_vkGetBufferCollectionPropertiesFUCHSIA(
|
||||
|
||||
auto storeProperties = [this, collection, pProperties]() -> VkResult {
|
||||
// store properties to storage
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
if (info_VkBufferCollectionFUCHSIA.find(collection) ==
|
||||
info_VkBufferCollectionFUCHSIA.end()) {
|
||||
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
@@ -2844,7 +2842,7 @@ VkResult ResourceTracker::on_vkGetBufferCollectionPropertiesFUCHSIA(
|
||||
// createInfoIndex
|
||||
// ====================================================================
|
||||
{
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto getIndexResult = getBufferCollectionImageCreateInfoIndexLocked(
|
||||
collection, info, &pProperties->createInfoIndex);
|
||||
if (getIndexResult != VK_SUCCESS) {
|
||||
@@ -2856,7 +2854,7 @@ VkResult ResourceTracker::on_vkGetBufferCollectionPropertiesFUCHSIA(
|
||||
// ====================================================================
|
||||
VkPhysicalDevice physicalDevice;
|
||||
{
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto deviceIt = info_VkDevice.find(device);
|
||||
if (deviceIt == info_VkDevice.end()) {
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
@@ -2938,7 +2936,7 @@ CoherentMemoryPtr ResourceTracker::createCoherentMemory(
|
||||
return coherentMemory;
|
||||
}
|
||||
{
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto it = info_VkDeviceMemory.find(mem);
|
||||
if (it == info_VkDeviceMemory.end()) {
|
||||
mesa_loge("Failed to create coherent memory: failed to find device memory.");
|
||||
@@ -2967,7 +2965,7 @@ CoherentMemoryPtr ResourceTracker::createCoherentMemory(
|
||||
return coherentMemory;
|
||||
}
|
||||
{
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
VirtGpuDevice* instance = VirtGpuDevice::getInstance((enum VirtGpuCapset)3);
|
||||
createBlob.blobMem = kBlobMemHost3d;
|
||||
createBlob.flags = kBlobFlagMappable;
|
||||
@@ -3134,7 +3132,7 @@ VkResult ResourceTracker::allocateCoherentMemory(VkDevice device,
|
||||
{
|
||||
// createCoherentMemory inside need to access info_VkDeviceMemory
|
||||
// information. set it before use.
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
info_VkDeviceMemory[mem] = info;
|
||||
}
|
||||
|
||||
@@ -3145,7 +3143,7 @@ VkResult ResourceTracker::allocateCoherentMemory(VkDevice device,
|
||||
|
||||
auto coherentMemory = createCoherentMemory(device, mem, hostAllocationInfo, enc, host_res);
|
||||
if (coherentMemory) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
coherentMemory->subAllocate(pAllocateInfo->allocationSize, &ptr, offset);
|
||||
info.allocationSize = pAllocateInfo->allocationSize;
|
||||
info.coherentMemoryOffset = offset;
|
||||
@@ -3155,7 +3153,7 @@ VkResult ResourceTracker::allocateCoherentMemory(VkDevice device,
|
||||
*pMemory = mem;
|
||||
} else {
|
||||
enc->vkFreeMemory(device, mem, nullptr, true);
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
info_VkDeviceMemory.erase(mem);
|
||||
}
|
||||
return host_res;
|
||||
@@ -3183,7 +3181,7 @@ VkResult ResourceTracker::getCoherentMemory(const VkMemoryAllocateInfo* pAllocat
|
||||
uint8_t* ptr = nullptr;
|
||||
uint64_t offset = 0;
|
||||
{
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
for (const auto& [memory, info] : info_VkDeviceMemory) {
|
||||
if (info.device != device) continue;
|
||||
|
||||
@@ -3416,7 +3414,7 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
|
||||
VkDeviceSize allocationInfoAllocSize = finalAllocInfo.allocationSize;
|
||||
|
||||
if (hasDedicatedImage) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkImage.find(dedicatedAllocInfoPtr->image);
|
||||
if (it == info_VkImage.end())
|
||||
@@ -3432,7 +3430,7 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
|
||||
}
|
||||
|
||||
if (hasDedicatedBuffer) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkBuffer.find(dedicatedAllocInfoPtr->buffer);
|
||||
if (it == info_VkBuffer.end())
|
||||
@@ -3536,7 +3534,7 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
|
||||
const VkBufferConstraintsInfoFUCHSIA* pBufferConstraintsInfo = nullptr;
|
||||
|
||||
if (hasDedicatedImage) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkImage.find(dedicatedAllocInfoPtr->image);
|
||||
if (it == info_VkImage.end()) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
@@ -3546,7 +3544,7 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
|
||||
}
|
||||
|
||||
if (hasDedicatedBuffer) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkBuffer.find(dedicatedAllocInfoPtr->buffer);
|
||||
if (it == info_VkBuffer.end()) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
@@ -3787,7 +3785,7 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
|
||||
VkImageCreateInfo imageCreateInfo;
|
||||
bool isDmaBufImage = false;
|
||||
{
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkImage.find(dedicatedAllocInfoPtr->image);
|
||||
if (it == info_VkImage.end()) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
@@ -4026,7 +4024,7 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
|
||||
|
||||
void ResourceTracker::on_vkFreeMemory(void* context, VkDevice device, VkDeviceMemory memory,
|
||||
const VkAllocationCallbacks* pAllocateInfo) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::unique_lock<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkDeviceMemory.find(memory);
|
||||
if (it == info_VkDeviceMemory.end()) return;
|
||||
@@ -4079,7 +4077,7 @@ VkResult ResourceTracker::on_vkMapMemory(void* context, VkResult host_result, Vk
|
||||
return host_result;
|
||||
}
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::unique_lock<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto deviceMemoryInfoIt = info_VkDeviceMemory.find(memory);
|
||||
if (deviceMemoryInfoIt == info_VkDeviceMemory.end()) {
|
||||
@@ -4152,7 +4150,7 @@ void ResourceTracker::on_vkUnmapMemory(void*, VkDevice, VkDeviceMemory) {
|
||||
|
||||
void ResourceTracker::transformImageMemoryRequirements2ForGuest(VkImage image,
|
||||
VkMemoryRequirements2* reqs2) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkImage.find(image);
|
||||
if (it == info_VkImage.end()) return;
|
||||
@@ -4176,7 +4174,7 @@ void ResourceTracker::transformImageMemoryRequirements2ForGuest(VkImage image,
|
||||
|
||||
void ResourceTracker::transformBufferMemoryRequirements2ForGuest(VkBuffer buffer,
|
||||
VkMemoryRequirements2* reqs2) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkBuffer.find(buffer);
|
||||
if (it == info_VkBuffer.end()) return;
|
||||
@@ -4384,7 +4382,7 @@ VkResult ResourceTracker::on_vkCreateImage(void* context, VkResult, VkDevice dev
|
||||
|
||||
if (res != VK_SUCCESS) return res;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkImage.find(*pImage);
|
||||
if (it == info_VkImage.end()) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
@@ -4658,7 +4656,7 @@ VkResult ResourceTracker::on_vkCreateFence(void* context, VkResult input_result,
|
||||
}
|
||||
|
||||
mesa_logd("%s: getting fence info\n", __func__);
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto it = info_VkFence.find(*pFence);
|
||||
|
||||
if (it == info_VkFence.end()) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
@@ -4694,7 +4692,7 @@ VkResult ResourceTracker::on_vkResetFences(void* context, VkResult, VkDevice dev
|
||||
// Permanence: temporary
|
||||
// on fence reset, close the fence fd
|
||||
// and act like we need to GetFenceFdKHR/ImportFenceFdKHR again
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
for (uint32_t i = 0; i < fenceCount; ++i) {
|
||||
VkFence fence = pFences[i];
|
||||
auto it = info_VkFence.find(fence);
|
||||
@@ -4740,7 +4738,7 @@ VkResult ResourceTracker::on_vkImportFenceFdKHR(void* context, VkResult, VkDevic
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto it = info_VkFence.find(pImportFenceFdInfo->fence);
|
||||
if (it == info_VkFence.end()) {
|
||||
mesa_loge("%s: VK_ERROR_OUT_OF_HOST_MEMORY: no fence info\n", __func__);
|
||||
@@ -4810,7 +4808,7 @@ VkResult ResourceTracker::on_vkGetFenceFdKHR(void* context, VkResult, VkDevice d
|
||||
// fence, because ANGLE will use the returned fd directly to
|
||||
// implement eglDupNativeFenceFDANDROID, where -1 is only returned
|
||||
// when error occurs.
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkFence.find(pGetFdInfo->fence);
|
||||
if (it == info_VkFence.end()) {
|
||||
@@ -4867,7 +4865,7 @@ VkResult ResourceTracker::on_vkWaitForFences(void* context, VkResult, VkDevice d
|
||||
std::vector<int> fencesExternalWaitFds;
|
||||
std::vector<VkFence> fencesNonExternal;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::unique_lock<std::recursive_mutex> lock(mLock);
|
||||
|
||||
for (uint32_t i = 0; i < fenceCount; ++i) {
|
||||
auto it = info_VkFence.find(pFences[i]);
|
||||
@@ -5056,7 +5054,7 @@ VkResult ResourceTracker::on_vkFreeDescriptorSets(void* context, VkResult, VkDev
|
||||
// (people expect VK_SUCCESS to always be returned by vkFreeDescriptorSets)
|
||||
std::vector<VkDescriptorSet> toActuallyFree;
|
||||
{
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
// Pool was destroyed
|
||||
if (info_VkDescriptorPool.find(descriptorPool) == info_VkDescriptorPool.end()) {
|
||||
@@ -5176,7 +5174,7 @@ void ResourceTracker::on_vkUpdateDescriptorSets(void* context, VkDevice device,
|
||||
|
||||
{
|
||||
// Validate and filter samplers
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
size_t imageInfoIndex = 0;
|
||||
for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
|
||||
if (!isDescriptorTypeImageInfo(transformedWrites[i].descriptorType)) continue;
|
||||
@@ -5220,8 +5218,8 @@ void ResourceTracker::on_vkDestroyImage(void* context, VkDevice device, VkImage
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
auto* syncHelper = ResourceTracker::threadingCallbacks.hostConnectionGetFunc()->syncHelper();
|
||||
{
|
||||
AutoLock<RecursiveLock> lock(mLock); // do not guard encoder may cause
|
||||
// deadlock b/243339973
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock); // do not guard encoder may cause
|
||||
// deadlock b/243339973
|
||||
|
||||
// Wait for any pending QSRIs to prevent a race between the Gfxstream host
|
||||
// potentially processing the below `vkDestroyImage()` from the VK encoder
|
||||
@@ -5258,7 +5256,7 @@ void ResourceTracker::on_vkDestroyImage(void* context, VkDevice device, VkImage
|
||||
|
||||
void ResourceTracker::on_vkGetImageMemoryRequirements(void* context, VkDevice device, VkImage image,
|
||||
VkMemoryRequirements* pMemoryRequirements) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::unique_lock<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkImage.find(image);
|
||||
if (it == info_VkImage.end()) return;
|
||||
@@ -5467,7 +5465,7 @@ VkResult ResourceTracker::on_vkCreateBuffer(void* context, VkResult, VkDevice de
|
||||
}
|
||||
#endif
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkBuffer.find(*pBuffer);
|
||||
if (it == info_VkBuffer.end()) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
@@ -5505,7 +5503,7 @@ void ResourceTracker::on_vkDestroyBuffer(void* context, VkDevice device, VkBuffe
|
||||
void ResourceTracker::on_vkGetBufferMemoryRequirements(void* context, VkDevice device,
|
||||
VkBuffer buffer,
|
||||
VkMemoryRequirements* pMemoryRequirements) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::unique_lock<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkBuffer.find(buffer);
|
||||
if (it == info_VkBuffer.end()) return;
|
||||
@@ -5615,7 +5613,7 @@ VkResult ResourceTracker::on_vkCreateSemaphore(void* context, VkResult input_res
|
||||
}
|
||||
#endif
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkSemaphore.find(*pSemaphore);
|
||||
if (it == info_VkSemaphore.end()) return VK_ERROR_INITIALIZATION_FAILED;
|
||||
@@ -5702,7 +5700,7 @@ VkResult ResourceTracker::on_vkGetSemaphoreFdKHR(void* context, VkResult, VkDevi
|
||||
// Doesn't this assume that sync file descriptor generated via the non-fence
|
||||
// passing path during "on_vkCreateSemaphore" is the same one that would be
|
||||
// generated via guest's "okGetSemaphoreFdKHR" call?
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto it = info_VkSemaphore.find(pGetFdInfo->semaphore);
|
||||
if (it == info_VkSemaphore.end()) return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
auto& semInfo = it->second;
|
||||
@@ -5746,7 +5744,7 @@ VkResult ResourceTracker::on_vkImportSemaphoreFdKHR(
|
||||
if (pImportSemaphoreFdInfo->handleType & VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT) {
|
||||
VkImportSemaphoreFdInfoKHR tmpInfo = *pImportSemaphoreFdInfo;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto semaphoreIt = info_VkSemaphore.find(pImportSemaphoreFdInfo->semaphore);
|
||||
auto& info = semaphoreIt->second;
|
||||
@@ -5791,7 +5789,7 @@ VkResult ResourceTracker::on_vkGetMemoryFdPropertiesKHR(
|
||||
return VK_ERROR_INVALID_EXTERNAL_HANDLE;
|
||||
}
|
||||
// Sanity-check device
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto deviceIt = info_VkDevice.find(device);
|
||||
if (deviceIt == info_VkDevice.end()) {
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
@@ -5830,7 +5828,7 @@ VkResult ResourceTracker::on_vkGetMemoryFdKHR(void* context, VkResult, VkDevice
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
// Sanity-check device
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto deviceIt = info_VkDevice.find(device);
|
||||
if (deviceIt == info_VkDevice.end()) {
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
@@ -6029,7 +6027,7 @@ VkResult ResourceTracker::on_vkQueueSubmitTemplate(void* context, VkResult input
|
||||
|
||||
VkEncoder* enc = (VkEncoder*)context;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::unique_lock<std::recursive_mutex> lock(mLock);
|
||||
|
||||
for (uint32_t i = 0; i < submitCount; ++i) {
|
||||
for (uint32_t j = 0; j < getWaitSemaphoreCount(pSubmits[i]); ++j) {
|
||||
@@ -6183,7 +6181,7 @@ VkResult ResourceTracker::on_vkQueueSubmitTemplate(void* context, VkResult input
|
||||
VkResult ResourceTracker::on_vkQueueWaitIdle(void* context, VkResult, VkQueue queue) {
|
||||
VkEncoder* enc = (VkEncoder*)context;
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::unique_lock<std::recursive_mutex> lock(mLock);
|
||||
std::vector<WorkPool::WaitGroupHandle> toWait = mQueueSensitiveWorkPoolItems[queue];
|
||||
mQueueSensitiveWorkPoolItems[queue].clear();
|
||||
lock.unlock();
|
||||
@@ -6319,7 +6317,7 @@ void ResourceTracker::unwrap_VkBindImageMemory2_pBindInfos(
|
||||
VkResult ResourceTracker::on_vkMapMemoryIntoAddressSpaceGOOGLE_pre(void*, VkResult, VkDevice,
|
||||
VkDeviceMemory memory,
|
||||
uint64_t* pAddress) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkDeviceMemory.find(memory);
|
||||
if (it == info_VkDeviceMemory.end()) {
|
||||
@@ -6358,7 +6356,7 @@ VkResult ResourceTracker::on_vkMapMemoryIntoAddressSpaceGOOGLE(void*, VkResult i
|
||||
VkResult ResourceTracker::initDescriptorUpdateTemplateBuffers(
|
||||
const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo,
|
||||
VkDescriptorUpdateTemplate descriptorUpdateTemplate) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkDescriptorUpdateTemplate.find(descriptorUpdateTemplate);
|
||||
if (it == info_VkDescriptorUpdateTemplate.end()) {
|
||||
@@ -6489,7 +6487,7 @@ void ResourceTracker::on_vkUpdateDescriptorSetWithTemplate(
|
||||
if (!userBuffer) return;
|
||||
|
||||
// TODO: Make this thread safe
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::unique_lock<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkDescriptorUpdateTemplate.find(descriptorUpdateTemplate);
|
||||
if (it == info_VkDescriptorUpdateTemplate.end()) {
|
||||
@@ -6863,18 +6861,18 @@ void ResourceTracker::on_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(
|
||||
|
||||
void ResourceTracker::registerEncoderCleanupCallback(const VkEncoder* encoder, void* object,
|
||||
CleanupCallback callback) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto& callbacks = mEncoderCleanupCallbacks[encoder];
|
||||
callbacks[object] = callback;
|
||||
}
|
||||
|
||||
void ResourceTracker::unregisterEncoderCleanupCallback(const VkEncoder* encoder, void* object) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
mEncoderCleanupCallbacks[encoder].erase(object);
|
||||
}
|
||||
|
||||
void ResourceTracker::onEncoderDeleted(const VkEncoder* encoder) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::unique_lock<std::recursive_mutex> lock(mLock);
|
||||
if (mEncoderCleanupCallbacks.find(encoder) == mEncoderCleanupCallbacks.end()) return;
|
||||
|
||||
std::unordered_map<void*, CleanupCallback> callbackCopies = mEncoderCleanupCallbacks[encoder];
|
||||
@@ -6911,7 +6909,7 @@ CommandBufferStagingStream::Alloc ResourceTracker::getAlloc() {
|
||||
// VkDeviceMemory filled in by getCoherentMemory()
|
||||
// scope of mLock
|
||||
{
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
const auto it = info_VkDeviceMemory.find(vkDeviceMem);
|
||||
if (it == info_VkDeviceMemory.end()) {
|
||||
mesa_loge("Coherent memory allocated %u not found", result);
|
||||
@@ -6933,7 +6931,7 @@ CommandBufferStagingStream::Free ResourceTracker::getFree() {
|
||||
// for suballocations, deviceMemory is a alias VkDeviceMemory hand;
|
||||
// freeCoherentMemoryLocked maps the alias to the backing VkDeviceMemory
|
||||
VkDeviceMemory deviceMemory = memory.deviceMemory;
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::unique_lock<std::recursive_mutex> lock(mLock);
|
||||
auto it = info_VkDeviceMemory.find(deviceMemory);
|
||||
if (it == info_VkDeviceMemory.end()) {
|
||||
mesa_loge("Device memory to free not found");
|
||||
@@ -7027,7 +7025,7 @@ VkResult ResourceTracker::on_vkCreateImageView(void* context, VkResult input_res
|
||||
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
if (pCreateInfo->format == VK_FORMAT_UNDEFINED) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkImage.find(pCreateInfo->image);
|
||||
if (it != info_VkImage.end() && it->second.hasExternalFormat) {
|
||||
@@ -7241,7 +7239,7 @@ VkResult ResourceTracker::on_vkQueueSignalReleaseImageANDROID(void* context, VkR
|
||||
}
|
||||
|
||||
{
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
auto it = info_VkImage.find(image);
|
||||
if (it == info_VkImage.end()) {
|
||||
if (pNativeFenceFd) *pNativeFenceFd = -1;
|
||||
@@ -7252,7 +7250,7 @@ VkResult ResourceTracker::on_vkQueueSignalReleaseImageANDROID(void* context, VkR
|
||||
enc->vkQueueSignalReleaseImageANDROIDAsyncGOOGLE(queue, waitSemaphoreCount, pWaitSemaphores,
|
||||
image, true /* lock */);
|
||||
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
VkResult result;
|
||||
if (pNativeFenceFd) {
|
||||
result = exportSyncFdForQSRILocked(image, pNativeFenceFd);
|
||||
@@ -7343,8 +7341,8 @@ VkResult ResourceTracker::on_vkCreateGraphicsPipelines(
|
||||
true /* do lock */);
|
||||
}
|
||||
|
||||
uint32_t ResourceTracker::getApiVersionFromInstance(VkInstance instance) const {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
uint32_t ResourceTracker::getApiVersionFromInstance(VkInstance instance) {
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
uint32_t api = kDefaultApiVersion;
|
||||
|
||||
auto it = info_VkInstance.find(instance);
|
||||
@@ -7355,8 +7353,8 @@ uint32_t ResourceTracker::getApiVersionFromInstance(VkInstance instance) const {
|
||||
return api;
|
||||
}
|
||||
|
||||
uint32_t ResourceTracker::getApiVersionFromDevice(VkDevice device) const {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
uint32_t ResourceTracker::getApiVersionFromDevice(VkDevice device) {
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
uint32_t api = kDefaultApiVersion;
|
||||
|
||||
@@ -7368,8 +7366,8 @@ uint32_t ResourceTracker::getApiVersionFromDevice(VkDevice device) const {
|
||||
return api;
|
||||
}
|
||||
|
||||
bool ResourceTracker::hasInstanceExtension(VkInstance instance, const std::string& name) const {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
bool ResourceTracker::hasInstanceExtension(VkInstance instance, const std::string& name) {
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkInstance.find(instance);
|
||||
if (it == info_VkInstance.end()) return false;
|
||||
@@ -7377,8 +7375,8 @@ bool ResourceTracker::hasInstanceExtension(VkInstance instance, const std::strin
|
||||
return it->second.enabledExtensions.find(name) != it->second.enabledExtensions.end();
|
||||
}
|
||||
|
||||
bool ResourceTracker::hasDeviceExtension(VkDevice device, const std::string& name) const {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
bool ResourceTracker::hasDeviceExtension(VkDevice device, const std::string& name) {
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto it = info_VkDevice.find(device);
|
||||
if (it == info_VkDevice.end()) return false;
|
||||
@@ -7494,7 +7492,7 @@ const VkPhysicalDeviceMemoryProperties& ResourceTracker::getPhysicalDeviceMemory
|
||||
void* context, VkDevice device, VkPhysicalDevice physicalDevice) {
|
||||
if (!mCachedPhysicalDeviceMemoryProps) {
|
||||
if (physicalDevice == VK_NULL_HANDLE) {
|
||||
AutoLock<RecursiveLock> lock(mLock);
|
||||
std::lock_guard<std::recursive_mutex> lock(mLock);
|
||||
|
||||
auto deviceInfoIt = info_VkDevice.find(device);
|
||||
if (deviceInfoIt == info_VkDevice.end()) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
@@ -30,14 +31,10 @@
|
||||
#include "VulkanHandles.h"
|
||||
#include "aemu/base/Optional.h"
|
||||
#include "aemu/base/Tracing.h"
|
||||
#include "aemu/base/synchronization/AndroidLock.h"
|
||||
#include "aemu/base/threads/AndroidWorkPool.h"
|
||||
#include "goldfish_vk_transform_guest.h"
|
||||
|
||||
using gfxstream::guest::AutoLock;
|
||||
using gfxstream::guest::Lock;
|
||||
using gfxstream::guest::Optional;
|
||||
using gfxstream::guest::RecursiveLock;
|
||||
using gfxstream::guest::WorkPool;
|
||||
|
||||
/// Use installed headers or locally defined Fuchsia-specific bits
|
||||
@@ -533,7 +530,7 @@ class ResourceTracker {
|
||||
uint8_t* getMappedPointer(VkDeviceMemory memory);
|
||||
VkDeviceSize getMappedSize(VkDeviceMemory memory);
|
||||
VkDeviceSize getNonCoherentExtendedSize(VkDevice device, VkDeviceSize basicSize) const;
|
||||
bool isValidMemoryRange(const VkMappedMemoryRange& range) const;
|
||||
bool isValidMemoryRange(const VkMappedMemoryRange& range);
|
||||
|
||||
void setupFeatures(const EmulatorFeatureInfo* features);
|
||||
void setupCaps(uint32_t& noRenderControlEnc);
|
||||
@@ -542,10 +539,10 @@ class ResourceTracker {
|
||||
bool hostSupportsVulkan() const;
|
||||
bool usingDirectMapping() const;
|
||||
uint32_t getStreamFeatures() const;
|
||||
uint32_t getApiVersionFromInstance(VkInstance instance) const;
|
||||
uint32_t getApiVersionFromDevice(VkDevice device) const;
|
||||
bool hasInstanceExtension(VkInstance instance, const std::string& name) const;
|
||||
bool hasDeviceExtension(VkDevice instance, const std::string& name) const;
|
||||
uint32_t getApiVersionFromInstance(VkInstance instance);
|
||||
uint32_t getApiVersionFromDevice(VkDevice device);
|
||||
bool hasInstanceExtension(VkInstance instance, const std::string& name);
|
||||
bool hasDeviceExtension(VkDevice instance, const std::string& name);
|
||||
VkDevice getDevice(VkCommandBuffer commandBuffer) const;
|
||||
void addToCommandPool(VkCommandPool commandPool, uint32_t commandBufferCount,
|
||||
VkCommandBuffer* pCommandBuffers);
|
||||
@@ -879,7 +876,7 @@ class ResourceTracker {
|
||||
void transformImageMemoryRequirementsForGuestLocked(VkImage image, VkMemoryRequirements* reqs);
|
||||
CoherentMemoryPtr freeCoherentMemoryLocked(VkDeviceMemory memory, VkDeviceMemory_Info& info);
|
||||
|
||||
mutable RecursiveLock mLock;
|
||||
std::recursive_mutex mLock;
|
||||
|
||||
std::optional<const VkPhysicalDeviceMemoryProperties> mCachedPhysicalDeviceMemoryProps;
|
||||
std::unique_ptr<EmulatorFeatureInfo> mFeatureInfo;
|
||||
|
||||
Reference in New Issue
Block a user