diff options
| author | Chris Forbes <chrisf@ijw.co.nz> | 2015-08-12 15:03:22 +1200 |
|---|---|---|
| committer | Chris Forbes <chrisf@ijw.co.nz> | 2015-09-18 12:08:21 +1200 |
| commit | efb150b97dab7a4a7872615a44ccb2f5798d4439 (patch) | |
| tree | 93737a6b51f059e6f406a8f6b08b0b7acd5b89e2 /layers/shader_checker.cpp | |
| parent | 5b9a4a4450d71beabb113336906b68f781b28427 (diff) | |
| download | usermoji-efb150b97dab7a4a7872615a44ccb2f5798d4439.tar.xz | |
layers: Shadow descriptor set layout in ShaderChecker
Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Courtney Goeltzenleuchter <courtney@lunarg.com>
Diffstat (limited to 'layers/shader_checker.cpp')
| -rw-r--r-- | layers/shader_checker.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/layers/shader_checker.cpp b/layers/shader_checker.cpp index e0f36938..4127d02c 100644 --- a/layers/shader_checker.cpp +++ b/layers/shader_checker.cpp @@ -88,6 +88,54 @@ static int globalLockInitialized = 0; static loader_platform_thread_mutex globalLock; +std::unordered_map<uint32_t, std::vector<VkDescriptorSetLayoutBinding>*> descriptor_set_layout_map; + +VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorSetLayout( + VkDevice device, + const VkDescriptorSetLayoutCreateInfo* pCreateInfo, + VkDescriptorSetLayout* pSetLayout) +{ + /* stash a copy of the layout bindings */ + VkLayerDispatchTable *pDeviceTable = get_dispatch_table(shader_checker_device_table_map, device); + VkResult result = pDeviceTable->CreateDescriptorSetLayout(device, pCreateInfo, pSetLayout); + + if (VK_SUCCESS == result) { + loader_platform_thread_lock_mutex(&globalLock); + auto& bindings = descriptor_set_layout_map[pSetLayout->handle]; + bindings = new std::vector<VkDescriptorSetLayoutBinding>( + pCreateInfo->pBinding, pCreateInfo->pBinding + pCreateInfo->count); + loader_platform_thread_unlock_mutex(&globalLock); + } + + return result; +} + + +std::unordered_map<uint32_t, std::vector<std::vector<VkDescriptorSetLayoutBinding>*>*> pipeline_layout_map; + +VK_LAYER_EXPORT VkResult VKAPI vkCreatePipelineLayout( + VkDevice device, + const VkPipelineLayoutCreateInfo* pCreateInfo, + VkPipelineLayout* pPipelineLayout) +{ + VkLayerDispatchTable *pDeviceTable = get_dispatch_table(shader_checker_device_table_map, device); + VkResult result = pDeviceTable->CreatePipelineLayout(device, pCreateInfo, pPipelineLayout); + + if (VK_SUCCESS == result) { + loader_platform_thread_lock_mutex(&globalLock); + auto& layouts = pipeline_layout_map[pPipelineLayout->handle]; + layouts = new std::vector<std::vector<VkDescriptorSetLayoutBinding>*>(); + layouts->reserve(pCreateInfo->descriptorSetCount); + for (unsigned i = 0; i < pCreateInfo->descriptorSetCount; i++) { + layouts->push_back(descriptor_set_layout_map[pCreateInfo->pSetLayouts[i].handle]); + } + loader_platform_thread_unlock_mutex(&globalLock); + } + + return result; +} + + static void build_type_def_index(std::vector<unsigned> const &words, std::unordered_map<unsigned, unsigned> &type_def_index) { @@ -1092,6 +1140,8 @@ VK_LAYER_EXPORT PFN_vkVoidFunction VKAPI vkGetDeviceProcAddr(VkDevice dev, const ADD_HOOK(vkCreateRenderPass); ADD_HOOK(vkDestroyDevice); ADD_HOOK(vkCreateGraphicsPipelines); + ADD_HOOK(vkCreateDescriptorSetLayout); + ADD_HOOK(vkCreatePipelineLayout); #undef ADD_HOOK VkLayerDispatchTable* pTable = get_dispatch_table(shader_checker_device_table_map, dev); |
