shader_checker: capture spir-v for every shader at vkCreateShader time
authorChris Forbes <chrisf@ijw.co.nz>
Tue, 7 Apr 2015 22:11:59 +0000 (10:11 +1200)
committerChris Forbes <chrisf@ijw.co.nz>
Thu, 16 Apr 2015 22:13:58 +0000 (10:13 +1200)
layers/shader_checker.cpp

index 8affef1..7eeb82c 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <assert.h>
 #include <unordered_map>
+#include <vector>
 #include "loader_platform.h"
 #include "vk_dispatch_table_helper.h"
 #include "vkLayer.h"
 
 static std::unordered_map<void *, VkLayerDispatchTable *> tableMap;
 
+
+struct shader_source {
+    std::vector<uint32_t> words;
+
+    shader_source(VkShaderCreateInfo const *pCreateInfo) :
+        words((uint32_t *)pCreateInfo->pCode, (uint32_t *)pCreateInfo->pCode + pCreateInfo->codeSize / sizeof(uint32_t)) {
+    }
+};
+
+
+static std::unordered_map<void *, shader_source *> shader_map;
+
+
 static VkLayerDispatchTable * initLayerTable(const VkBaseLayerObject *gpuw)
 {
     VkLayerDispatchTable *pTable;
@@ -139,6 +153,8 @@ VK_LAYER_EXPORT VkResult VKAPI vkCreateShader(VkDevice device, const VkShaderCre
 {
     VkLayerDispatchTable* pTable = tableMap[(VkBaseLayerObject *)device];
     VkResult res = pTable->CreateShader(device, pCreateInfo, pShader);
+
+    shader_map[(VkBaseLayerObject *) *pShader] = new shader_source(pCreateInfo);
     return res;
 }