aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Lobodzinski <mark@lunarg.com>2020-04-07 13:12:53 -0600
committerMark Lobodzinski <mark@lunarg.com>2020-04-07 16:15:34 -0600
commit444b7cd3eecd538e7cb87027a07c6fb1c0abc6b8 (patch)
tree24ba1a29ae83a81fd1739a155ddc30e3657b24f5
parent4acb8fe0b1336f3b98fabf741e86e8ab590f6926 (diff)
downloadusermoji-444b7cd3eecd538e7cb87027a07c6fb1c0abc6b8.tar.xz
mockicd: Make physical device static
PDev created at EnumPhysDevices time, but destroyed at DestroyInstance time. This crashes as EnumPhysDevices is not required to be called. Change-Id: I2dbfb694364eab57e5173565db795c5c70d458fc
-rw-r--r--icd/generated/mock_icd.cpp8
-rw-r--r--scripts/mock_icd_generator.py8
2 files changed, 2 insertions, 14 deletions
diff --git a/icd/generated/mock_icd.cpp b/icd/generated/mock_icd.cpp
index bdf5a102..eb0c6089 100644
--- a/icd/generated/mock_icd.cpp
+++ b/icd/generated/mock_icd.cpp
@@ -31,7 +31,7 @@ using std::unordered_map;
// Map device memory handle to any mapped allocations that we'll need to free on unmap
static unordered_map<VkDeviceMemory, std::vector<void*>> mapped_memory_map;
-static VkPhysicalDevice physical_device = nullptr;
+static VkPhysicalDevice physical_device = (VkPhysicalDevice)CreateDispObjHandle();
static unordered_map<VkDevice, unordered_map<uint32_t, unordered_map<uint32_t, VkQueue>>> queue_map;
static unordered_map<VkDevice, unordered_map<VkBuffer, VkBufferCreateInfo>> buffer_map;
@@ -186,9 +186,6 @@ static VKAPI_ATTR void VKAPI_CALL DestroyInstance(
const VkAllocationCallbacks* pAllocator)
{
- // Destroy physical device
- DestroyDispObjHandle((void*)physical_device);
-
DestroyDispObjHandle((void*)instance);
}
@@ -198,9 +195,6 @@ static VKAPI_ATTR VkResult VKAPI_CALL EnumeratePhysicalDevices(
VkPhysicalDevice* pPhysicalDevices)
{
if (pPhysicalDevices) {
- if (!physical_device) {
- physical_device = (VkPhysicalDevice)CreateDispObjHandle();
- }
*pPhysicalDevices = physical_device;
} else {
*pPhysicalDeviceCount = 1;
diff --git a/scripts/mock_icd_generator.py b/scripts/mock_icd_generator.py
index 33f2cad8..fff1d7ca 100644
--- a/scripts/mock_icd_generator.py
+++ b/scripts/mock_icd_generator.py
@@ -57,7 +57,7 @@ using std::unordered_map;
// Map device memory handle to any mapped allocations that we'll need to free on unmap
static unordered_map<VkDeviceMemory, std::vector<void*>> mapped_memory_map;
-static VkPhysicalDevice physical_device = nullptr;
+static VkPhysicalDevice physical_device = (VkPhysicalDevice)CreateDispObjHandle();
static unordered_map<VkDevice, unordered_map<uint32_t, unordered_map<uint32_t, VkQueue>>> queue_map;
static unordered_map<VkDevice, unordered_map<VkBuffer, VkBufferCreateInfo>> buffer_map;
@@ -425,16 +425,10 @@ CUSTOM_C_INTERCEPTS = {
return VK_SUCCESS;
''',
'vkDestroyInstance': '''
- // Destroy physical device
- DestroyDispObjHandle((void*)physical_device);
-
DestroyDispObjHandle((void*)instance);
''',
'vkEnumeratePhysicalDevices': '''
if (pPhysicalDevices) {
- if (!physical_device) {
- physical_device = (VkPhysicalDevice)CreateDispObjHandle();
- }
*pPhysicalDevices = physical_device;
} else {
*pPhysicalDeviceCount = 1;