diff options
| author | Mark Lobodzinski <mark@lunarg.com> | 2016-04-28 16:36:58 -0600 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2016-05-02 10:47:15 -0600 |
| commit | af2e5855da29e0087c2c7827802a459ddcc859da (patch) | |
| tree | 5082f0b97eae3fdde662f7a9066154420568619d | |
| parent | db50be7872385b1c21d471d4665510f0fa61fa54 (diff) | |
| download | usermoji-af2e5855da29e0087c2c7827802a459ddcc859da.tar.xz | |
layers: Make unique object IDs unique cross-device and cross-instance
Change-Id: Ic45e21bd3137dc0474c59f0f4cf9331f070dac20
| -rw-r--r-- | layers/unique_objects.h | 14 | ||||
| -rwxr-xr-x | vk-layer-generate.py | 4 |
2 files changed, 10 insertions, 8 deletions
diff --git a/layers/unique_objects.h b/layers/unique_objects.h index e2854508..e32970da 100644 --- a/layers/unique_objects.h +++ b/layers/unique_objects.h @@ -39,13 +39,15 @@ #include "vk_safe_struct.h" #include "vk_layer_utils.h" +// All increments must be guarded by global_lock +static uint64_t global_unique_id = 1; + struct layer_data { bool wsi_enabled; - uint64_t unique_id; // All increments are guarded by global_lock std::unordered_map<uint64_t, uint64_t> unique_id_mapping; // Map uniqueID to actual object handle VkPhysicalDevice gpu; - layer_data() : wsi_enabled(false), unique_id(1), gpu(VK_NULL_HANDLE){}; + layer_data() : wsi_enabled(false), gpu(VK_NULL_HANDLE){}; }; struct instExts { @@ -268,7 +270,7 @@ VkResult explicit_CreateComputePipelines(VkDevice device, VkPipelineCache pipeli uint64_t unique_id = 0; std::lock_guard<std::mutex> lock(global_lock); for (uint32_t i = 0; i < createInfoCount; ++i) { - unique_id = my_device_data->unique_id++; + unique_id = global_unique_id++; my_device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(pPipelines[i]); pPipelines[i] = reinterpret_cast<VkPipeline &>(unique_id); } @@ -329,7 +331,7 @@ VkResult explicit_CreateGraphicsPipelines(VkDevice device, VkPipelineCache pipel uint64_t unique_id = 0; std::lock_guard<std::mutex> lock(global_lock); for (uint32_t i = 0; i < createInfoCount; ++i) { - unique_id = my_device_data->unique_id++; + unique_id = global_unique_id++; my_device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(pPipelines[i]); pPipelines[i] = reinterpret_cast<VkPipeline &>(unique_id); } @@ -359,7 +361,7 @@ VkResult explicit_CreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInf delete local_pCreateInfo; if (VK_SUCCESS == result) { std::lock_guard<std::mutex> lock(global_lock); - uint64_t unique_id = my_map_data->unique_id++; + uint64_t unique_id =global_unique_id++; my_map_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(*pSwapchain); *pSwapchain = reinterpret_cast<VkSwapchainKHR &>(unique_id); } @@ -383,7 +385,7 @@ VkResult explicit_GetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapchai uint64_t unique_id = 0; std::lock_guard<std::mutex> lock(global_lock); for (uint32_t i = 0; i < *pSwapchainImageCount; ++i) { - unique_id = my_device_data->unique_id++; + unique_id = global_unique_id++; my_device_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(pSwapchainImages[i]); pSwapchainImages[i] = reinterpret_cast<VkImage &>(unique_id); } diff --git a/vk-layer-generate.py b/vk-layer-generate.py index 467e602a..1c7cf24a 100755 --- a/vk-layer-generate.py +++ b/vk-layer-generate.py @@ -1628,14 +1628,14 @@ class UniqueObjectsSubcommand(Subcommand): local_name = '%ss' % (local_name) # add 's' to end for vector of many post_call_txt += '%sfor (uint32_t i=0; i<%s; ++i) {\n' % (indent, custom_create_dict[obj_name]) indent += ' ' - post_call_txt += '%suint64_t unique_id = my_map_data->unique_id++;\n' % (indent) + post_call_txt += '%suint64_t unique_id = global_unique_id++;\n' % (indent) post_call_txt += '%smy_map_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(%s[i]);\n' % (indent, obj_name) post_call_txt += '%s%s[i] = reinterpret_cast<%s&>(unique_id);\n' % (indent, obj_name, obj_type) indent = indent[4:] post_call_txt += '%s}\n' % (indent) else: post_call_txt += '%s\n' % (self.lineinfo.get()) - post_call_txt += '%suint64_t unique_id = my_map_data->unique_id++;\n' % (indent) + post_call_txt += '%suint64_t unique_id = global_unique_id++;\n' % (indent) post_call_txt += '%smy_map_data->unique_id_mapping[unique_id] = reinterpret_cast<uint64_t &>(*%s);\n' % (indent, obj_name) post_call_txt += '%s*%s = reinterpret_cast<%s&>(unique_id);\n' % (indent, obj_name, obj_type) indent = indent[4:] |
