From f196c8d3cafcaf7e628b7b76a799c940999ee984 Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Fri, 17 Mar 2023 16:40:25 -0600 Subject: [PATCH] mock_icd: Add missing locks --- icd/generated/mock_icd.cpp | 3 +++ scripts/mock_icd_generator.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/icd/generated/mock_icd.cpp b/icd/generated/mock_icd.cpp index 9c9d527..b3bf813 100644 --- a/icd/generated/mock_icd.cpp +++ b/icd/generated/mock_icd.cpp @@ -549,6 +549,7 @@ static VKAPI_ATTR void VKAPI_CALL FreeMemory( const VkAllocationCallbacks* pAllocator) { //Destroy object + unique_lock_t lock(global_lock); allocated_memory_size_map.erase(memory); } @@ -640,6 +641,7 @@ static VKAPI_ATTR void VKAPI_CALL GetBufferMemoryRequirements( pMemoryRequirements->alignment = 1; pMemoryRequirements->memoryTypeBits = 0xFFFF; // Return a better size based on the buffer size from the create info. + unique_lock_t lock(global_lock); auto d_iter = buffer_map.find(device); if (d_iter != buffer_map.end()) { auto iter = d_iter->second.find(buffer); @@ -657,6 +659,7 @@ static VKAPI_ATTR void VKAPI_CALL GetImageMemoryRequirements( pMemoryRequirements->size = 0; pMemoryRequirements->alignment = 1; + unique_lock_t lock(global_lock); auto d_iter = image_memory_size_map.find(device); if(d_iter != image_memory_size_map.end()){ auto iter = d_iter->second.find(image); diff --git a/scripts/mock_icd_generator.py b/scripts/mock_icd_generator.py index e4892bd..b6c460b 100644 --- a/scripts/mock_icd_generator.py +++ b/scripts/mock_icd_generator.py @@ -988,6 +988,7 @@ CUSTOM_C_INTERCEPTS = { pMemoryRequirements->alignment = 1; pMemoryRequirements->memoryTypeBits = 0xFFFF; // Return a better size based on the buffer size from the create info. + unique_lock_t lock(global_lock); auto d_iter = buffer_map.find(device); if (d_iter != buffer_map.end()) { auto iter = d_iter->second.find(buffer); @@ -1003,6 +1004,7 @@ CUSTOM_C_INTERCEPTS = { pMemoryRequirements->size = 0; pMemoryRequirements->alignment = 1; + unique_lock_t lock(global_lock); auto d_iter = image_memory_size_map.find(device); if(d_iter != image_memory_size_map.end()){ auto iter = d_iter->second.find(image); @@ -1732,6 +1734,7 @@ class MockICDOutputGenerator(OutputGenerator): self.appendSection('command', '//Destroy object') if 'FreeMemory' in api_function_name: # Remove from allocation map + self.appendSection('command', ' unique_lock_t lock(global_lock);') self.appendSection('command', ' allocated_memory_size_map.erase(memory);') else: self.appendSection('command', '//Not a CREATE or DESTROY function') -- 2.7.4