blob: 1fe60c3c2c2554cf168c042d46539b0977b939d9 [file] [log] [blame]
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001/*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002 * Vulkan
Tobin Ehlis63bb9482015-03-17 16:24:32 -06003 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <unordered_map>
29
30#include "loader_platform.h"
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060031#include "vk_dispatch_table_helper.h"
32#include "vk_struct_string_helper_cpp.h"
Tobin Ehlis63bb9482015-03-17 16:24:32 -060033#pragma GCC diagnostic ignored "-Wwrite-strings"
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060034#include "vk_struct_graphviz_helper.h"
Tobin Ehlis63bb9482015-03-17 16:24:32 -060035#pragma GCC diagnostic warning "-Wwrite-strings"
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060036#include "vk_struct_size_helper.h"
Tobin Ehlis63bb9482015-03-17 16:24:32 -060037#include "draw_state.h"
38#include "layers_config.h"
39// The following is #included again to catch certain OS-specific functions
40// being used:
41#include "loader_platform.h"
42#include "layers_msg.h"
43
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060044unordered_map<VkSampler, SAMPLER_NODE*> sampleMap;
45unordered_map<VkImageView, IMAGE_NODE*> imageMap;
46unordered_map<VkBufferView, BUFFER_NODE*> bufferMap;
47unordered_map<VkDynamicStateObject, DYNAMIC_STATE_NODE*> dynamicStateMap;
48unordered_map<VkPipeline, PIPELINE_NODE*> pipelineMap;
49unordered_map<VkDescriptorPool, POOL_NODE*> poolMap;
50unordered_map<VkDescriptorSet, SET_NODE*> setMap;
51unordered_map<VkDescriptorSetLayout, LAYOUT_NODE*> layoutMap;
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -060052// Map for layout chains
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060053unordered_map<VkCmdBuffer, GLOBAL_CB_NODE*> cmdBufferMap;
54unordered_map<VkRenderPass, VkRenderPassCreateInfo*> renderPassMap;
55unordered_map<VkFramebuffer, VkFramebufferCreateInfo*> frameBufferMap;
Tobin Ehlis63bb9482015-03-17 16:24:32 -060056
Jon Ashburn301c5f02015-04-06 10:58:22 -060057static VkLayerDispatchTable nextTable;
58static VkBaseLayerObject *pCurObj;
Tobin Ehlis63bb9482015-03-17 16:24:32 -060059static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce);
60// TODO : This can be much smarter, using separate locks for separate global data
61static int globalLockInitialized = 0;
62static loader_platform_thread_mutex globalLock;
Tobin Ehlis63bb9482015-03-17 16:24:32 -060063#define MAX_TID 513
64static loader_platform_thread_id g_tidMapping[MAX_TID] = {0};
65static uint32_t g_maxTID = 0;
66// Map actual TID to an index value and return that index
67// This keeps TIDs in range from 0-MAX_TID and simplifies compares between runs
68static uint32_t getTIDIndex() {
69 loader_platform_thread_id tid = loader_platform_get_thread_id();
70 for (uint32_t i = 0; i < g_maxTID; i++) {
71 if (tid == g_tidMapping[i])
72 return i;
73 }
74 // Don't yet have mapping, set it and return newly set index
75 uint32_t retVal = (uint32_t) g_maxTID;
76 g_tidMapping[g_maxTID++] = tid;
77 assert(g_maxTID < MAX_TID);
78 return retVal;
79}
80// Return a string representation of CMD_TYPE enum
81static string cmdTypeToString(CMD_TYPE cmd)
82{
83 switch (cmd)
84 {
85 case CMD_BINDPIPELINE:
86 return "CMD_BINDPIPELINE";
87 case CMD_BINDPIPELINEDELTA:
88 return "CMD_BINDPIPELINEDELTA";
89 case CMD_BINDDYNAMICSTATEOBJECT:
90 return "CMD_BINDDYNAMICSTATEOBJECT";
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -060091 case CMD_BINDDESCRIPTORSETS:
92 return "CMD_BINDDESCRIPTORSETS";
Tobin Ehlis63bb9482015-03-17 16:24:32 -060093 case CMD_BINDINDEXBUFFER:
94 return "CMD_BINDINDEXBUFFER";
95 case CMD_BINDVERTEXBUFFER:
96 return "CMD_BINDVERTEXBUFFER";
97 case CMD_DRAW:
98 return "CMD_DRAW";
99 case CMD_DRAWINDEXED:
100 return "CMD_DRAWINDEXED";
101 case CMD_DRAWINDIRECT:
102 return "CMD_DRAWINDIRECT";
103 case CMD_DRAWINDEXEDINDIRECT:
104 return "CMD_DRAWINDEXEDINDIRECT";
105 case CMD_DISPATCH:
106 return "CMD_DISPATCH";
107 case CMD_DISPATCHINDIRECT:
108 return "CMD_DISPATCHINDIRECT";
109 case CMD_COPYBUFFER:
110 return "CMD_COPYBUFFER";
111 case CMD_COPYIMAGE:
112 return "CMD_COPYIMAGE";
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600113 case CMD_BLITIMAGE:
114 return "CMD_BLITIMAGE";
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600115 case CMD_COPYBUFFERTOIMAGE:
116 return "CMD_COPYBUFFERTOIMAGE";
117 case CMD_COPYIMAGETOBUFFER:
118 return "CMD_COPYIMAGETOBUFFER";
119 case CMD_CLONEIMAGEDATA:
120 return "CMD_CLONEIMAGEDATA";
121 case CMD_UPDATEBUFFER:
122 return "CMD_UPDATEBUFFER";
123 case CMD_FILLBUFFER:
124 return "CMD_FILLBUFFER";
125 case CMD_CLEARCOLORIMAGE:
126 return "CMD_CLEARCOLORIMAGE";
127 case CMD_CLEARCOLORIMAGERAW:
128 return "CMD_CLEARCOLORIMAGERAW";
129 case CMD_CLEARDEPTHSTENCIL:
130 return "CMD_CLEARDEPTHSTENCIL";
131 case CMD_RESOLVEIMAGE:
132 return "CMD_RESOLVEIMAGE";
133 case CMD_SETEVENT:
134 return "CMD_SETEVENT";
135 case CMD_RESETEVENT:
136 return "CMD_RESETEVENT";
137 case CMD_WAITEVENTS:
138 return "CMD_WAITEVENTS";
139 case CMD_PIPELINEBARRIER:
140 return "CMD_PIPELINEBARRIER";
141 case CMD_BEGINQUERY:
142 return "CMD_BEGINQUERY";
143 case CMD_ENDQUERY:
144 return "CMD_ENDQUERY";
145 case CMD_RESETQUERYPOOL:
146 return "CMD_RESETQUERYPOOL";
147 case CMD_WRITETIMESTAMP:
148 return "CMD_WRITETIMESTAMP";
149 case CMD_INITATOMICCOUNTERS:
150 return "CMD_INITATOMICCOUNTERS";
151 case CMD_LOADATOMICCOUNTERS:
152 return "CMD_LOADATOMICCOUNTERS";
153 case CMD_SAVEATOMICCOUNTERS:
154 return "CMD_SAVEATOMICCOUNTERS";
155 case CMD_BEGINRENDERPASS:
156 return "CMD_BEGINRENDERPASS";
157 case CMD_ENDRENDERPASS:
158 return "CMD_ENDRENDERPASS";
159 case CMD_DBGMARKERBEGIN:
160 return "CMD_DBGMARKERBEGIN";
161 case CMD_DBGMARKEREND:
162 return "CMD_DBGMARKEREND";
163 default:
164 return "UNKNOWN";
165 }
166}
167// Block of code at start here for managing/tracking Pipeline state that this layer cares about
168// Just track 2 shaders for now
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600169#define VK_NUM_GRAPHICS_SHADERS VK_SHADER_STAGE_COMPUTE
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600170#define MAX_SLOTS 2048
171#define NUM_COMMAND_BUFFERS_TO_DISPLAY 10
172
173static uint64_t g_drawCount[NUM_DRAW_TYPES] = {0, 0, 0, 0};
174
175// TODO : Should be tracking lastBound per cmdBuffer and when draws occur, report based on that cmd buffer lastBound
176// Then need to synchronize the accesses based on cmd buffer so that if I'm reading state on one cmd buffer, updates
177// to that same cmd buffer by separate thread are not changing state from underneath us
178// Track the last cmd buffer touched by this thread
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600179static VkCmdBuffer g_lastCmdBuffer[MAX_TID] = {NULL};
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600180// Track the last group of CBs touched for displaying to dot file
181static GLOBAL_CB_NODE* g_pLastTouchedCB[NUM_COMMAND_BUFFERS_TO_DISPLAY] = {NULL};
182static uint32_t g_lastTouchedCBIndex = 0;
183// Track the last global DrawState of interest touched by any thread
184static GLOBAL_CB_NODE* g_lastGlobalCB = NULL;
185static PIPELINE_NODE* g_lastBoundPipeline = NULL;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600186static DYNAMIC_STATE_NODE* g_lastBoundDynamicState[VK_NUM_STATE_BIND_POINT] = {NULL};
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600187static VkDescriptorSet g_lastBoundDescriptorSet = NULL;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600188#define MAX_BINDING 0xFFFFFFFF // Default vtxBinding value in CB Node to identify if no vtxBinding set
189
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600190//static DYNAMIC_STATE_NODE* g_pDynamicStateHead[VK_NUM_STATE_BIND_POINT] = {0};
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600191
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600192static void insertDynamicState(const VkDynamicStateObject state, const GENERIC_HEADER* pCreateInfo, VkStateBindPoint bindPoint)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600193{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600194 VkDynamicVpStateCreateInfo* pVPCI = NULL;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600195 size_t scSize = 0;
196 size_t vpSize = 0;
197 loader_platform_thread_lock_mutex(&globalLock);
198 DYNAMIC_STATE_NODE* pStateNode = new DYNAMIC_STATE_NODE;
199 pStateNode->stateObj = state;
200 switch (pCreateInfo->sType) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600201 case VK_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600202 memcpy(&pStateNode->create_info, pCreateInfo, sizeof(VkDynamicVpStateCreateInfo));
203 pVPCI = (VkDynamicVpStateCreateInfo*)pCreateInfo;
204 pStateNode->create_info.vpci.pScissors = new VkRect[pStateNode->create_info.vpci.viewportAndScissorCount];
205 pStateNode->create_info.vpci.pViewports = new VkViewport[pStateNode->create_info.vpci.viewportAndScissorCount];
206 scSize = pVPCI->viewportAndScissorCount * sizeof(VkRect);
207 vpSize = pVPCI->viewportAndScissorCount * sizeof(VkViewport);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600208 memcpy((void*)pStateNode->create_info.vpci.pScissors, pVPCI->pScissors, scSize);
209 memcpy((void*)pStateNode->create_info.vpci.pViewports, pVPCI->pViewports, vpSize);
210 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600211 case VK_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600212 memcpy(&pStateNode->create_info, pCreateInfo, sizeof(VkDynamicRsStateCreateInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600213 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600214 case VK_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600215 memcpy(&pStateNode->create_info, pCreateInfo, sizeof(VkDynamicCbStateCreateInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600216 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600217 case VK_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600218 memcpy(&pStateNode->create_info, pCreateInfo, sizeof(VkDynamicDsStateCreateInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600219 break;
220 default:
221 assert(0);
222 break;
223 }
224 pStateNode->pCreateInfo = (GENERIC_HEADER*)&pStateNode->create_info.cbci;
225 dynamicStateMap[state] = pStateNode;
226 loader_platform_thread_unlock_mutex(&globalLock);
227}
228// Free all allocated nodes for Dynamic State objs
Tobin Ehliseaf28662015-04-08 10:58:37 -0600229static void deleteDynamicState()
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600230{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600231 for (unordered_map<VkDynamicStateObject, DYNAMIC_STATE_NODE*>::iterator ii=dynamicStateMap.begin(); ii!=dynamicStateMap.end(); ++ii) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600232 if (VK_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO == (*ii).second->create_info.vpci.sType) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600233 delete[] (*ii).second->create_info.vpci.pScissors;
234 delete[] (*ii).second->create_info.vpci.pViewports;
235 }
236 delete (*ii).second;
237 }
238}
239// Free all sampler nodes
Tobin Ehliseaf28662015-04-08 10:58:37 -0600240static void deleteSamplers()
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600241{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600242 for (unordered_map<VkSampler, SAMPLER_NODE*>::iterator ii=sampleMap.begin(); ii!=sampleMap.end(); ++ii) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600243 delete (*ii).second;
244 }
245}
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600246static VkImageViewCreateInfo* getImageViewCreateInfo(VkImageView view)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600247{
248 loader_platform_thread_lock_mutex(&globalLock);
249 if (imageMap.find(view) == imageMap.end()) {
250 loader_platform_thread_unlock_mutex(&globalLock);
251 return NULL;
252 }
253 else {
254 loader_platform_thread_unlock_mutex(&globalLock);
255 return &imageMap[view]->createInfo;
256 }
257}
258// Free all image nodes
Tobin Ehliseaf28662015-04-08 10:58:37 -0600259static void deleteImages()
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600260{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600261 for (unordered_map<VkImageView, IMAGE_NODE*>::iterator ii=imageMap.begin(); ii!=imageMap.end(); ++ii) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600262 delete (*ii).second;
263 }
264}
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600265static VkBufferViewCreateInfo* getBufferViewCreateInfo(VkBufferView view)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600266{
267 loader_platform_thread_lock_mutex(&globalLock);
268 if (bufferMap.find(view) == bufferMap.end()) {
269 loader_platform_thread_unlock_mutex(&globalLock);
270 return NULL;
271 }
272 else {
273 loader_platform_thread_unlock_mutex(&globalLock);
274 return &bufferMap[view]->createInfo;
275 }
276}
277// Free all buffer nodes
Tobin Ehliseaf28662015-04-08 10:58:37 -0600278static void deleteBuffers()
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600279{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600280 for (unordered_map<VkBufferView, BUFFER_NODE*>::iterator ii=bufferMap.begin(); ii!=bufferMap.end(); ++ii) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600281 delete (*ii).second;
282 }
283}
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600284static GLOBAL_CB_NODE* getCBNode(VkCmdBuffer cb);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600285
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600286static void updateCBTracking(VkCmdBuffer cb)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600287{
288 g_lastCmdBuffer[getTIDIndex()] = cb;
289 GLOBAL_CB_NODE* pCB = getCBNode(cb);
290 loader_platform_thread_lock_mutex(&globalLock);
291 g_lastGlobalCB = pCB;
292 // TODO : This is a dumb algorithm. Need smart LRU that drops off oldest
293 for (uint32_t i = 0; i < NUM_COMMAND_BUFFERS_TO_DISPLAY; i++) {
294 if (g_pLastTouchedCB[i] == pCB) {
295 loader_platform_thread_unlock_mutex(&globalLock);
296 return;
297 }
298 }
299 g_pLastTouchedCB[g_lastTouchedCBIndex++] = pCB;
300 g_lastTouchedCBIndex = g_lastTouchedCBIndex % NUM_COMMAND_BUFFERS_TO_DISPLAY;
301 loader_platform_thread_unlock_mutex(&globalLock);
302}
303
304// Print the last bound dynamic state
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600305static void printDynamicState(const VkCmdBuffer cb)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600306{
307 GLOBAL_CB_NODE* pCB = getCBNode(cb);
308 if (pCB) {
309 loader_platform_thread_lock_mutex(&globalLock);
310 char str[4*1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600311 for (uint32_t i = 0; i < VK_NUM_STATE_BIND_POINT; i++) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600312 if (pCB->lastBoundDynamicState[i]) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600313 sprintf(str, "Reporting CreateInfo for currently bound %s object %p", string_VkStateBindPoint((VkStateBindPoint)i), pCB->lastBoundDynamicState[i]->stateObj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600314 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pCB->lastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", str);
315 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pCB->lastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", dynamic_display(pCB->lastBoundDynamicState[i]->pCreateInfo, " ").c_str());
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600316 break;
317 }
318 else {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600319 sprintf(str, "No dynamic state of type %s bound", string_VkStateBindPoint((VkStateBindPoint)i));
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600320 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600321 }
322 }
323 loader_platform_thread_unlock_mutex(&globalLock);
324 }
325 else {
326 char str[1024];
327 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cb);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600328 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cb, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600329 }
330}
331// Retrieve pipeline node ptr for given pipeline object
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600332static PIPELINE_NODE* getPipeline(VkPipeline pipeline)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600333{
334 loader_platform_thread_lock_mutex(&globalLock);
335 if (pipelineMap.find(pipeline) == pipelineMap.end()) {
336 loader_platform_thread_unlock_mutex(&globalLock);
337 return NULL;
338 }
339 loader_platform_thread_unlock_mutex(&globalLock);
340 return pipelineMap[pipeline];
341}
342
343// For given sampler, return a ptr to its Create Info struct, or NULL if sampler not found
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600344static VkSamplerCreateInfo* getSamplerCreateInfo(const VkSampler sampler)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600345{
346 loader_platform_thread_lock_mutex(&globalLock);
347 if (sampleMap.find(sampler) == sampleMap.end()) {
348 loader_platform_thread_unlock_mutex(&globalLock);
349 return NULL;
350 }
351 loader_platform_thread_unlock_mutex(&globalLock);
352 return &sampleMap[sampler]->createInfo;
353}
354
355// Init the pipeline mapping info based on pipeline create info LL tree
356// Threading note : Calls to this function should wrapped in mutex
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600357static void initPipeline(PIPELINE_NODE* pPipeline, const VkGraphicsPipelineCreateInfo* pCreateInfo)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600358{
359 // First init create info, we'll shadow the structs as we go down the tree
Tobin Ehlis2464b882015-04-01 08:40:34 -0600360 // TODO : Validate that no create info is incorrectly replicated
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600361 memcpy(&pPipeline->graphicsPipelineCI, pCreateInfo, sizeof(VkGraphicsPipelineCreateInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600362 GENERIC_HEADER* pTrav = (GENERIC_HEADER*)pCreateInfo->pNext;
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600363 GENERIC_HEADER* pPrev = (GENERIC_HEADER*)&pPipeline->graphicsPipelineCI; // Hold prev ptr to tie chain of structs together
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600364 size_t bufferSize = 0;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600365 VkPipelineVertexInputCreateInfo* pVICI = NULL;
366 VkPipelineCbStateCreateInfo* pCBCI = NULL;
367 VkPipelineShaderStageCreateInfo* pTmpPSSCI = NULL;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600368 while (pTrav) {
369 switch (pTrav->sType) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600370 case VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600371 pTmpPSSCI = (VkPipelineShaderStageCreateInfo*)pTrav;
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600372 switch (pTmpPSSCI->shader.stage) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600373 case VK_SHADER_STAGE_VERTEX:
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600374 pPrev->pNext = &pPipeline->vsCI;
375 pPrev = (GENERIC_HEADER*)&pPipeline->vsCI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600376 memcpy(&pPipeline->vsCI, pTmpPSSCI, sizeof(VkPipelineShaderStageCreateInfo));
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600377 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600378 case VK_SHADER_STAGE_TESS_CONTROL:
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600379 pPrev->pNext = &pPipeline->tcsCI;
380 pPrev = (GENERIC_HEADER*)&pPipeline->tcsCI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600381 memcpy(&pPipeline->tcsCI, pTmpPSSCI, sizeof(VkPipelineShaderStageCreateInfo));
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600382 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600383 case VK_SHADER_STAGE_TESS_EVALUATION:
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600384 pPrev->pNext = &pPipeline->tesCI;
385 pPrev = (GENERIC_HEADER*)&pPipeline->tesCI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600386 memcpy(&pPipeline->tesCI, pTmpPSSCI, sizeof(VkPipelineShaderStageCreateInfo));
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600387 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600388 case VK_SHADER_STAGE_GEOMETRY:
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600389 pPrev->pNext = &pPipeline->gsCI;
390 pPrev = (GENERIC_HEADER*)&pPipeline->gsCI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600391 memcpy(&pPipeline->gsCI, pTmpPSSCI, sizeof(VkPipelineShaderStageCreateInfo));
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600392 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600393 case VK_SHADER_STAGE_FRAGMENT:
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600394 pPrev->pNext = &pPipeline->fsCI;
395 pPrev = (GENERIC_HEADER*)&pPipeline->fsCI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600396 memcpy(&pPipeline->fsCI, pTmpPSSCI, sizeof(VkPipelineShaderStageCreateInfo));
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600397 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600398 case VK_SHADER_STAGE_COMPUTE:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600399 // TODO : Flag error, CS is specified through VkComputePipelineCreateInfo
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600400 break;
401 default:
402 // TODO : Flag error
403 break;
404 }
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600405 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600406 case VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO:
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600407 pPrev->pNext = &pPipeline->vertexInputCI;
408 pPrev = (GENERIC_HEADER*)&pPipeline->vertexInputCI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600409 memcpy((void*)&pPipeline->vertexInputCI, pTrav, sizeof(VkPipelineVertexInputCreateInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600410 // Copy embedded ptrs
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600411 pVICI = (VkPipelineVertexInputCreateInfo*)pTrav;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600412 pPipeline->vtxBindingCount = pVICI->bindingCount;
413 if (pPipeline->vtxBindingCount) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600414 pPipeline->pVertexBindingDescriptions = new VkVertexInputBindingDescription[pPipeline->vtxBindingCount];
415 bufferSize = pPipeline->vtxBindingCount * sizeof(VkVertexInputBindingDescription);
416 memcpy((void*)pPipeline->pVertexBindingDescriptions, ((VkPipelineVertexInputCreateInfo*)pTrav)->pVertexAttributeDescriptions, bufferSize);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600417 }
418 pPipeline->vtxAttributeCount = pVICI->attributeCount;
419 if (pPipeline->vtxAttributeCount) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600420 pPipeline->pVertexAttributeDescriptions = new VkVertexInputAttributeDescription[pPipeline->vtxAttributeCount];
421 bufferSize = pPipeline->vtxAttributeCount * sizeof(VkVertexInputAttributeDescription);
422 memcpy((void*)pPipeline->pVertexAttributeDescriptions, ((VkPipelineVertexInputCreateInfo*)pTrav)->pVertexAttributeDescriptions, bufferSize);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600423 }
424 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600425 case VK_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO:
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600426 pPrev->pNext = &pPipeline->iaStateCI;
427 pPrev = (GENERIC_HEADER*)&pPipeline->iaStateCI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600428 memcpy((void*)&pPipeline->iaStateCI, pTrav, sizeof(VkPipelineIaStateCreateInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600429 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600430 case VK_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO:
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600431 pPrev->pNext = &pPipeline->tessStateCI;
432 pPrev = (GENERIC_HEADER*)&pPipeline->tessStateCI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600433 memcpy((void*)&pPipeline->tessStateCI, pTrav, sizeof(VkPipelineTessStateCreateInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600434 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600435 case VK_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO:
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600436 pPrev->pNext = &pPipeline->vpStateCI;
437 pPrev = (GENERIC_HEADER*)&pPipeline->vpStateCI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600438 memcpy((void*)&pPipeline->vpStateCI, pTrav, sizeof(VkPipelineVpStateCreateInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600439 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600440 case VK_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO:
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600441 pPrev->pNext = &pPipeline->rsStateCI;
442 pPrev = (GENERIC_HEADER*)&pPipeline->rsStateCI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600443 memcpy((void*)&pPipeline->rsStateCI, pTrav, sizeof(VkPipelineRsStateCreateInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600444 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600445 case VK_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO:
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600446 pPrev->pNext = &pPipeline->msStateCI;
447 pPrev = (GENERIC_HEADER*)&pPipeline->msStateCI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600448 memcpy((void*)&pPipeline->msStateCI, pTrav, sizeof(VkPipelineMsStateCreateInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600449 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600450 case VK_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO:
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600451 pPrev->pNext = &pPipeline->cbStateCI;
452 pPrev = (GENERIC_HEADER*)&pPipeline->cbStateCI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600453 memcpy((void*)&pPipeline->cbStateCI, pTrav, sizeof(VkPipelineCbStateCreateInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600454 // Copy embedded ptrs
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600455 pCBCI = (VkPipelineCbStateCreateInfo*)pTrav;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600456 pPipeline->attachmentCount = pCBCI->attachmentCount;
457 if (pPipeline->attachmentCount) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600458 pPipeline->pAttachments = new VkPipelineCbAttachmentState[pPipeline->attachmentCount];
459 bufferSize = pPipeline->attachmentCount * sizeof(VkPipelineCbAttachmentState);
460 memcpy((void*)pPipeline->pAttachments, ((VkPipelineCbStateCreateInfo*)pTrav)->pAttachments, bufferSize);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600461 }
462 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600463 case VK_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO:
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600464 pPrev->pNext = &pPipeline->dsStateCI;
465 pPrev = (GENERIC_HEADER*)&pPipeline->dsStateCI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600466 memcpy((void*)&pPipeline->dsStateCI, pTrav, sizeof(VkPipelineDsStateCreateInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600467 break;
468 default:
469 assert(0);
470 break;
471 }
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600472 pTrav = (GENERIC_HEADER*)pTrav->pNext;
473 }
474 pipelineMap[pPipeline->pipeline] = pPipeline;
475}
476// Free the Pipeline nodes
Tobin Ehliseaf28662015-04-08 10:58:37 -0600477static void deletePipelines()
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600478{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600479 for (unordered_map<VkPipeline, PIPELINE_NODE*>::iterator ii=pipelineMap.begin(); ii!=pipelineMap.end(); ++ii) {
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600480 if ((*ii).second->pVertexBindingDescriptions) {
481 delete[] (*ii).second->pVertexBindingDescriptions;
482 }
483 if ((*ii).second->pVertexAttributeDescriptions) {
484 delete[] (*ii).second->pVertexAttributeDescriptions;
485 }
486 if ((*ii).second->pAttachments) {
487 delete[] (*ii).second->pAttachments;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600488 }
489 delete (*ii).second;
490 }
491}
Tobin Ehlis2464b882015-04-01 08:40:34 -0600492// For given pipeline, return number of MSAA samples, or one if MSAA disabled
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600493static uint32_t getNumSamples(const VkPipeline pipeline)
Tobin Ehlis2464b882015-04-01 08:40:34 -0600494{
495 PIPELINE_NODE* pPipe = pipelineMap[pipeline];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600496 if (VK_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO == pPipe->msStateCI.sType) {
Tobin Ehliscd3109e2015-04-01 11:59:08 -0600497 if (pPipe->msStateCI.multisampleEnable)
498 return pPipe->msStateCI.samples;
Tobin Ehlis2464b882015-04-01 08:40:34 -0600499 }
500 return 1;
501}
502// Validate state related to the PSO
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600503static void validatePipelineState(const GLOBAL_CB_NODE* pCB, const VkPipelineBindPoint pipelineBindPoint, const VkPipeline pipeline)
Tobin Ehlis2464b882015-04-01 08:40:34 -0600504{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600505 if (VK_PIPELINE_BIND_POINT_GRAPHICS == pipelineBindPoint) {
Tobin Ehlis2464b882015-04-01 08:40:34 -0600506 // Verify that any MSAA request in PSO matches sample# in bound FB
507 uint32_t psoNumSamples = getNumSamples(pipeline);
508 if (pCB->activeRenderPass) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600509 VkRenderPassCreateInfo* pRPCI = renderPassMap[pCB->activeRenderPass];
510 VkFramebufferCreateInfo* pFBCI = frameBufferMap[pCB->framebuffer];
Tobin Ehlis2464b882015-04-01 08:40:34 -0600511 if (psoNumSamples != pFBCI->sampleCount) {
512 char str[1024];
Courtney Goeltzenleuchtere3b0f3a2015-04-03 15:25:24 -0600513 sprintf(str, "Num samples mismatche! Binding PSO (%p) with %u samples while current RenderPass (%p) uses FB (%p) with %u samples!", (void*)pipeline, psoNumSamples, (void*)pCB->activeRenderPass, (void*)pCB->framebuffer, pFBCI->sampleCount);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600514 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pipeline, 0, DRAWSTATE_NUM_SAMPLES_MISMATCH, "DS", str);
Tobin Ehlis2464b882015-04-01 08:40:34 -0600515 }
516 } else {
517 // TODO : I believe it's an error if we reach this point and don't have an activeRenderPass
518 // Verify and flag error as appropriate
519 }
520 // TODO : Add more checks here
521 } else {
522 // TODO : Validate non-gfx pipeline updates
523 }
524}
525
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600526// Block of code at start here specifically for managing/tracking DSs
527
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600528// Return Pool node ptr for specified pool or else NULL
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600529static POOL_NODE* getPoolNode(VkDescriptorPool pool)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600530{
531 loader_platform_thread_lock_mutex(&globalLock);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600532 if (poolMap.find(pool) == poolMap.end()) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600533 loader_platform_thread_unlock_mutex(&globalLock);
534 return NULL;
535 }
536 loader_platform_thread_unlock_mutex(&globalLock);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600537 return poolMap[pool];
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600538}
539// Return Set node ptr for specified set or else NULL
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600540static SET_NODE* getSetNode(VkDescriptorSet set)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600541{
542 loader_platform_thread_lock_mutex(&globalLock);
543 if (setMap.find(set) == setMap.end()) {
544 loader_platform_thread_unlock_mutex(&globalLock);
545 return NULL;
546 }
547 loader_platform_thread_unlock_mutex(&globalLock);
548 return setMap[set];
549}
550
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600551// Return VK_TRUE if DS Exists and is within an vkBeginDescriptorPoolUpdate() call sequence, otherwise VK_FALSE
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600552static bool32_t dsUpdateActive(VkDescriptorSet ds)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600553{
554 // Note, both "get" functions use global mutex so this guy does not
555 SET_NODE* pTrav = getSetNode(ds);
556 if (pTrav) {
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600557 POOL_NODE* pPool = getPoolNode(pTrav->pool);
558 if (pPool) {
559 return pPool->updateActive;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600560 }
561 }
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600562 return VK_FALSE;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600563}
564
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600565static LAYOUT_NODE* getLayoutNode(const VkDescriptorSetLayout layout) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600566 loader_platform_thread_lock_mutex(&globalLock);
567 if (layoutMap.find(layout) == layoutMap.end()) {
568 loader_platform_thread_unlock_mutex(&globalLock);
569 return NULL;
570 }
571 loader_platform_thread_unlock_mutex(&globalLock);
572 return layoutMap[layout];
573}
574
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600575// For given update struct, return binding
576static uint32_t getUpdateBinding(const GENERIC_HEADER* pUpdateStruct)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600577{
578 switch (pUpdateStruct->sType)
579 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600580 case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600581 return ((VkUpdateSamplers*)pUpdateStruct)->binding;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600582 case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600583 return ((VkUpdateSamplerTextures*)pUpdateStruct)->binding;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600584 case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600585 return ((VkUpdateImages*)pUpdateStruct)->binding;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600586 case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600587 return ((VkUpdateBuffers*)pUpdateStruct)->binding;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600588 case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600589 return ((VkUpdateAsCopy*)pUpdateStruct)->binding;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600590 default:
591 // TODO : Flag specific error for this case
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600592 assert(0);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600593 return 0;
594 }
595}
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600596// Return count for given update struct
597static uint32_t getUpdateArrayIndex(const GENERIC_HEADER* pUpdateStruct)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600598{
599 switch (pUpdateStruct->sType)
600 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600601 case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600602 return (((VkUpdateSamplers*)pUpdateStruct)->arrayIndex);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600603 case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600604 return (((VkUpdateSamplerTextures*)pUpdateStruct)->arrayIndex);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600605 case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600606 return (((VkUpdateImages*)pUpdateStruct)->arrayIndex);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600607 case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600608 return (((VkUpdateBuffers*)pUpdateStruct)->arrayIndex);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600609 case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600610 // TODO : Need to understand this case better and make sure code is correct
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600611 return (((VkUpdateAsCopy*)pUpdateStruct)->arrayElement);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600612 default:
613 // TODO : Flag specific error for this case
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600614 assert(0);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600615 return 0;
616 }
617}
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600618// Return count for given update struct
619static uint32_t getUpdateCount(const GENERIC_HEADER* pUpdateStruct)
620{
621 switch (pUpdateStruct->sType)
622 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600623 case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600624 return (((VkUpdateSamplers*)pUpdateStruct)->count);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600625 case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600626 return (((VkUpdateSamplerTextures*)pUpdateStruct)->count);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600627 case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600628 return (((VkUpdateImages*)pUpdateStruct)->count);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600629 case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600630 return (((VkUpdateBuffers*)pUpdateStruct)->count);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600631 case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600632 // TODO : Need to understand this case better and make sure code is correct
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600633 return (((VkUpdateAsCopy*)pUpdateStruct)->count);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600634 default:
635 // TODO : Flag specific error for this case
636 assert(0);
637 return 0;
638 }
639}
640// For given Layout Node and binding, return index where that binding begins
641static uint32_t getBindingStartIndex(const LAYOUT_NODE* pLayout, const uint32_t binding)
642{
643 uint32_t offsetIndex = 0;
644 for (uint32_t i = 0; i<binding; i++) {
645 offsetIndex += pLayout->createInfo.pBinding[i].count;
646 }
647 return offsetIndex;
648}
649// For given layout node and binding, return last index that is updated
650static uint32_t getBindingEndIndex(const LAYOUT_NODE* pLayout, const uint32_t binding)
651{
652 uint32_t offsetIndex = 0;
653 for (uint32_t i = 0; i<=binding; i++) {
654 offsetIndex += pLayout->createInfo.pBinding[i].count;
655 }
656 return offsetIndex-1;
657}
658// For given layout and update, return the first overall index of the layout that is update
659static uint32_t getUpdateStartIndex(const LAYOUT_NODE* pLayout, const GENERIC_HEADER* pUpdateStruct)
660{
661 return (getBindingStartIndex(pLayout, getUpdateBinding(pUpdateStruct))+getUpdateArrayIndex(pUpdateStruct));
662}
663// For given layout and update, return the last overall index of the layout that is update
664static uint32_t getUpdateEndIndex(const LAYOUT_NODE* pLayout, const GENERIC_HEADER* pUpdateStruct)
665{
666 return (getBindingStartIndex(pLayout, getUpdateBinding(pUpdateStruct))+getUpdateArrayIndex(pUpdateStruct)+getUpdateCount(pUpdateStruct)-1);
667}
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600668// Verify that the descriptor type in the update struct matches what's expected by the layout
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600669static bool32_t validateUpdateType(const LAYOUT_NODE* pLayout, const GENERIC_HEADER* pUpdateStruct)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600670{
671 // First get actual type of update
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600672 VkDescriptorType actualType;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600673 uint32_t i = 0;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600674 switch (pUpdateStruct->sType)
675 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600676 case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
677 actualType = VK_DESCRIPTOR_TYPE_SAMPLER;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600678 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600679 case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600680 actualType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600681 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600682 case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600683 actualType = ((VkUpdateImages*)pUpdateStruct)->descriptorType;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600684 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600685 case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600686 actualType = ((VkUpdateBuffers*)pUpdateStruct)->descriptorType;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600687 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600688 case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600689 actualType = ((VkUpdateAsCopy*)pUpdateStruct)->descriptorType;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600690 break;
691 default:
692 // TODO : Flag specific error for this case
693 return 0;
694 }
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600695 for (i = getUpdateStartIndex(pLayout, pUpdateStruct); i <= getUpdateEndIndex(pLayout, pUpdateStruct); i++) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600696 if (pLayout->pTypes[i] != actualType)
697 return 0;
698 }
699 return 1;
700}
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600701// Determine the update type, allocate a new struct of that type, shadow the given pUpdate
702// struct into the new struct and return ptr to shadow struct cast as GENERIC_HEADER
703// NOTE : Calls to this function should be wrapped in mutex
704static GENERIC_HEADER* shadowUpdateNode(GENERIC_HEADER* pUpdate)
705{
706 GENERIC_HEADER* pNewNode = NULL;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600707 VkUpdateSamplers* pUS = NULL;
708 VkUpdateSamplerTextures* pUST = NULL;
709 VkUpdateBuffers* pUB = NULL;
710 VkUpdateImages* pUI = NULL;
711 VkUpdateAsCopy* pUAC = NULL;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600712 size_t array_size = 0;
713 size_t base_array_size = 0;
714 size_t total_array_size = 0;
715 size_t baseBuffAddr = 0;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600716 VkImageViewAttachInfo** ppLocalImageViews = NULL;
717 VkBufferViewAttachInfo** ppLocalBufferViews = NULL;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600718 char str[1024];
719 switch (pUpdate->sType)
720 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600721 case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600722 pUS = new VkUpdateSamplers;
Tobin Ehliseaf28662015-04-08 10:58:37 -0600723 pNewNode = (GENERIC_HEADER*)pUS;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600724 memcpy(pUS, pUpdate, sizeof(VkUpdateSamplers));
725 pUS->pSamplers = new VkSampler[pUS->count];
726 array_size = sizeof(VkSampler) * pUS->count;
727 memcpy((void*)pUS->pSamplers, ((VkUpdateSamplers*)pUpdate)->pSamplers, array_size);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600728 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600729 case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600730 pUST = new VkUpdateSamplerTextures;
Tobin Ehliseaf28662015-04-08 10:58:37 -0600731 pNewNode = (GENERIC_HEADER*)pUST;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600732 memcpy(pUST, pUpdate, sizeof(VkUpdateSamplerTextures));
733 pUST->pSamplerImageViews = new VkSamplerImageViewInfo[pUST->count];
734 array_size = sizeof(VkSamplerImageViewInfo) * pUST->count;
735 memcpy((void*)pUST->pSamplerImageViews, ((VkUpdateSamplerTextures*)pUpdate)->pSamplerImageViews, array_size);
Tobin Ehliseaf28662015-04-08 10:58:37 -0600736 for (uint32_t i = 0; i < pUST->count; i++) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600737 VkImageViewAttachInfo** ppIV = (VkImageViewAttachInfo**)&pUST->pSamplerImageViews[i].pImageView;
738 *ppIV = new VkImageViewAttachInfo;
739 memcpy((void*)*ppIV, ((VkUpdateSamplerTextures*)pUpdate)->pSamplerImageViews[i].pImageView, sizeof(VkImageViewAttachInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600740 }
741 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600742 case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600743 pUI = new VkUpdateImages;
Tobin Ehliseaf28662015-04-08 10:58:37 -0600744 pNewNode = (GENERIC_HEADER*)pUI;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600745 memcpy(pUI, pUpdate, sizeof(VkUpdateImages));
746 pUI->pImageViews = new VkImageViewAttachInfo[pUI->count];
747 array_size = (sizeof(VkImageViewAttachInfo) * pUI->count);
748 memcpy((void*)pUI->pImageViews, ((VkUpdateImages*)pUpdate)->pImageViews, array_size);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600749 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600750 case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600751 pUB = new VkUpdateBuffers;
Tobin Ehliseaf28662015-04-08 10:58:37 -0600752 pNewNode = (GENERIC_HEADER*)pUB;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600753 memcpy(pUB, pUpdate, sizeof(VkUpdateBuffers));
754 pUB->pBufferViews = new VkBufferViewAttachInfo[pUB->count];
755 array_size = (sizeof(VkBufferViewAttachInfo) * pUB->count);
756 memcpy((void*)pUB->pBufferViews, ((VkUpdateBuffers*)pUpdate)->pBufferViews, array_size);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600757 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600758 case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600759 pUAC = new VkUpdateAsCopy;
Tobin Ehliseaf28662015-04-08 10:58:37 -0600760 pUpdate = (GENERIC_HEADER*)pUAC;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600761 memcpy(pUAC, pUpdate, sizeof(VkUpdateAsCopy));
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600762 break;
763 default:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600764 sprintf(str, "Unexpected UPDATE struct of type %s (value %u) in vkUpdateDescriptors() struct tree", string_VkStructureType(pUpdate->sType), pUpdate->sType);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600765 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_INVALID_UPDATE_STRUCT, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600766 return NULL;
767 }
768 // Make sure that pNext for the end of shadow copy is NULL
769 pNewNode->pNext = NULL;
770 return pNewNode;
771}
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600772// For given ds, update its mapping based on ppUpdateArray
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600773static void dsUpdate(VkDescriptorSet ds, uint32_t updateCount, const void** ppUpdateArray)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600774{
775 SET_NODE* pSet = getSetNode(ds);
776 loader_platform_thread_lock_mutex(&globalLock);
777 g_lastBoundDescriptorSet = pSet->set;
778 LAYOUT_NODE* pLayout = NULL;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600779 VkDescriptorSetLayoutCreateInfo* pLayoutCI = NULL;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600780 // TODO : If pCIList is NULL, flag error
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600781 // Perform all updates
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600782 for (uint32_t i = 0; i < updateCount; i++) {
783 GENERIC_HEADER* pUpdate = (GENERIC_HEADER*)ppUpdateArray[i];
784 pLayout = pSet->pLayout;
785 // Make sure that binding is within bounds
786 if (pLayout->createInfo.count < getUpdateBinding(pUpdate)) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600787 char str[1024];
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600788 sprintf(str, "Descriptor Set %p does not have binding to match update binding %u for update type %s!", ds, getUpdateBinding(pUpdate), string_VkStructureType(pUpdate->sType));
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600789 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_INVALID_UPDATE_INDEX, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600790 }
791 else {
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600792 // Next verify that update falls within size of given binding
793 if (getBindingEndIndex(pLayout, getUpdateBinding(pUpdate)) < getUpdateEndIndex(pLayout, pUpdate)) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600794 char str[48*1024]; // TODO : Keep count of layout CI structs and size this string dynamically based on that count
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600795 pLayoutCI = &pLayout->createInfo;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600796 string DSstr = vk_print_vkdescriptorsetlayoutcreateinfo(pLayoutCI, "{DS} ");
797 sprintf(str, "Descriptor update type of %s is out of bounds for matching binding %u in Layout w/ CI:\n%s!", string_VkStructureType(pUpdate->sType), getUpdateBinding(pUpdate), DSstr.c_str());
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600798 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_DESCRIPTOR_UPDATE_OUT_OF_BOUNDS, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600799 }
800 else { // TODO : should we skip update on a type mismatch or force it?
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600801 // Layout bindings match w/ update ok, now verify that update is of the right type
802 if (!validateUpdateType(pLayout, pUpdate)) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600803 char str[1024];
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600804 sprintf(str, "Descriptor update type of %s does not match overlapping binding type!", string_VkStructureType(pUpdate->sType));
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600805 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_DESCRIPTOR_TYPE_MISMATCH, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600806 }
807 else {
808 // Save the update info
809 // TODO : Info message that update successful
810 // Create new update struct for this set's shadow copy
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600811 GENERIC_HEADER* pNewNode = shadowUpdateNode(pUpdate);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600812 if (NULL == pNewNode) {
813 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600814 sprintf(str, "Out of memory while attempting to allocate UPDATE struct in vkUpdateDescriptors()");
815 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600816 }
817 else {
818 // Insert shadow node into LL of updates for this set
819 pNewNode->pNext = pSet->pUpdateStructs;
820 pSet->pUpdateStructs = pNewNode;
821 // Now update appropriate descriptor(s) to point to new Update node
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600822 for (uint32_t j = getUpdateStartIndex(pLayout, pUpdate); j <= getUpdateEndIndex(pLayout, pUpdate); j++) {
823 assert(j<pSet->descriptorCount);
824 pSet->ppDescriptors[j] = pNewNode;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600825 }
826 }
827 }
828 }
829 }
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600830 }
831 loader_platform_thread_unlock_mutex(&globalLock);
832}
833// Free the shadowed update node for this Set
834// NOTE : Calls to this function should be wrapped in mutex
835static void freeShadowUpdateTree(SET_NODE* pSet)
836{
837 GENERIC_HEADER* pShadowUpdate = pSet->pUpdateStructs;
838 pSet->pUpdateStructs = NULL;
839 GENERIC_HEADER* pFreeUpdate = pShadowUpdate;
840 // Clear the descriptor mappings as they will now be invalid
841 memset(pSet->ppDescriptors, 0, pSet->descriptorCount*sizeof(GENERIC_HEADER*));
842 while(pShadowUpdate) {
843 pFreeUpdate = pShadowUpdate;
844 pShadowUpdate = (GENERIC_HEADER*)pShadowUpdate->pNext;
845 uint32_t index = 0;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600846 VkUpdateSamplers* pUS = NULL;
847 VkUpdateSamplerTextures* pUST = NULL;
848 VkUpdateImages* pUI = NULL;
849 VkUpdateBuffers* pUB = NULL;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600850 void** ppToFree = NULL;
851 switch (pFreeUpdate->sType)
852 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600853 case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600854 pUS = (VkUpdateSamplers*)pFreeUpdate;
Tobin Ehliseaf28662015-04-08 10:58:37 -0600855 if (pUS->pSamplers)
856 delete[] pUS->pSamplers;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600857 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600858 case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600859 pUST = (VkUpdateSamplerTextures*)pFreeUpdate;
Tobin Ehliseaf28662015-04-08 10:58:37 -0600860 if (pUST->pSamplerImageViews) {
861 for (index = 0; index < pUST->count; index++) {
862 if (pUST->pSamplerImageViews[index].pImageView) {
863 delete pUST->pSamplerImageViews[index].pImageView;
864 }
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600865 }
Tobin Ehliseaf28662015-04-08 10:58:37 -0600866 delete[] pUST->pSamplerImageViews;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600867 }
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600868 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600869 case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600870 pUI = (VkUpdateImages*)pFreeUpdate;
Tobin Ehliseaf28662015-04-08 10:58:37 -0600871 if (pUI->pImageViews)
872 delete[] pUI->pImageViews;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600873 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600874 case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600875 pUB = (VkUpdateBuffers*)pFreeUpdate;
Tobin Ehliseaf28662015-04-08 10:58:37 -0600876 if (pUB->pBufferViews)
877 delete[] pUB->pBufferViews;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600878 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600879 case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600880 break;
881 default:
882 assert(0);
883 break;
884 }
Tobin Ehliseaf28662015-04-08 10:58:37 -0600885 delete pFreeUpdate;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600886 }
887}
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600888// Free all DS Pools including their Sets & related sub-structs
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600889// NOTE : Calls to this function should be wrapped in mutex
Tobin Ehliseaf28662015-04-08 10:58:37 -0600890static void deletePools()
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600891{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600892 for (unordered_map<VkDescriptorPool, POOL_NODE*>::iterator ii=poolMap.begin(); ii!=poolMap.end(); ++ii) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600893 SET_NODE* pSet = (*ii).second->pSets;
894 SET_NODE* pFreeSet = pSet;
895 while (pSet) {
896 pFreeSet = pSet;
897 pSet = pSet->pNext;
Tobin Ehliseaf28662015-04-08 10:58:37 -0600898 // Freeing layouts handled in deleteLayouts() function
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600899 // Free Update shadow struct tree
900 freeShadowUpdateTree(pFreeSet);
901 if (pFreeSet->ppDescriptors) {
902 delete pFreeSet->ppDescriptors;
903 }
904 delete pFreeSet;
905 }
906 if ((*ii).second->createInfo.pTypeCount) {
907 delete (*ii).second->createInfo.pTypeCount;
908 }
909 delete (*ii).second;
910 }
911}
Tobin Ehliseaf28662015-04-08 10:58:37 -0600912// WARN : Once deleteLayouts() called, any layout ptrs in Pool/Set data structure will be invalid
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600913// NOTE : Calls to this function should be wrapped in mutex
Tobin Ehliseaf28662015-04-08 10:58:37 -0600914static void deleteLayouts()
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600915{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600916 for (unordered_map<VkDescriptorSetLayout, LAYOUT_NODE*>::iterator ii=layoutMap.begin(); ii!=layoutMap.end(); ++ii) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600917 LAYOUT_NODE* pLayout = (*ii).second;
Tobin Ehliseaf28662015-04-08 10:58:37 -0600918 if (pLayout->createInfo.pBinding) {
919 for (uint32_t i=0; i<pLayout->createInfo.count; i++) {
920 if (pLayout->createInfo.pBinding[i].pImmutableSamplers)
921 delete[] pLayout->createInfo.pBinding[i].pImmutableSamplers;
922 }
923 delete[] pLayout->createInfo.pBinding;
924 }
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600925 if (pLayout->pTypes) {
926 delete pLayout->pTypes;
927 }
928 delete pLayout;
929 }
930}
931// Currently clearing a set is removing all previous updates to that set
932// TODO : Validate if this is correct clearing behavior
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600933static void clearDescriptorSet(VkDescriptorSet set)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600934{
935 SET_NODE* pSet = getSetNode(set);
936 if (!pSet) {
937 // TODO : Return error
938 }
939 else {
940 loader_platform_thread_lock_mutex(&globalLock);
941 freeShadowUpdateTree(pSet);
942 loader_platform_thread_unlock_mutex(&globalLock);
943 }
944}
945
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600946static void clearDescriptorPool(VkDescriptorPool pool)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600947{
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600948 POOL_NODE* pPool = getPoolNode(pool);
949 if (!pPool) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600950 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600951 sprintf(str, "Unable to find pool node for pool %p specified in vkClearDescriptorPool() call", (void*)pool);
952 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pool, 0, DRAWSTATE_INVALID_POOL, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600953 }
954 else
955 {
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -0600956 // For every set off of this pool, clear it
957 SET_NODE* pSet = pPool->pSets;
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600958 while (pSet) {
959 clearDescriptorSet(pSet->set);
960 }
961 }
962}
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600963// Code here to manage the Cmd buffer LL
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600964static GLOBAL_CB_NODE* getCBNode(VkCmdBuffer cb)
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600965{
966 loader_platform_thread_lock_mutex(&globalLock);
967 if (cmdBufferMap.find(cb) == cmdBufferMap.end()) {
968 loader_platform_thread_unlock_mutex(&globalLock);
969 return NULL;
970 }
971 loader_platform_thread_unlock_mutex(&globalLock);
972 return cmdBufferMap[cb];
973}
974// Free all CB Nodes
975// NOTE : Calls to this function should be wrapped in mutex
Tobin Ehliseaf28662015-04-08 10:58:37 -0600976static void deleteCmdBuffers()
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600977{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600978 for (unordered_map<VkCmdBuffer, GLOBAL_CB_NODE*>::iterator ii=cmdBufferMap.begin(); ii!=cmdBufferMap.end(); ++ii) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -0600979 while (!(*ii).second->pCmds.empty()) {
980 delete (*ii).second->pCmds.back();
981 (*ii).second->pCmds.pop_back();
982 }
983 delete (*ii).second;
984 }
985}
986static void addCmd(GLOBAL_CB_NODE* pCB, const CMD_TYPE cmd)
987{
988 CMD_NODE* pCmd = new CMD_NODE;
989 if (pCmd) {
990 // init cmd node and append to end of cmd LL
991 memset(pCmd, 0, sizeof(CMD_NODE));
992 pCmd->cmdNumber = ++pCB->numCmds;
993 pCmd->type = cmd;
994 pCB->pCmds.push_back(pCmd);
995 }
996 else {
997 char str[1024];
998 sprintf(str, "Out of memory while attempting to allocate new CMD_NODE for cmdBuffer %p", (void*)pCB->cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600999 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pCB->cmdBuffer, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001000 }
1001}
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001002static void resetCB(const VkCmdBuffer cb)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001003{
1004 GLOBAL_CB_NODE* pCB = getCBNode(cb);
1005 if (pCB) {
1006 while (!pCB->pCmds.empty()) {
1007 delete pCB->pCmds.back();
1008 pCB->pCmds.pop_back();
1009 }
1010 // Reset CB state
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001011 VkFlags saveFlags = pCB->flags;
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -07001012 uint32_t saveQueueNodeIndex = pCB->queueNodeIndex;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001013 memset(pCB, 0, sizeof(GLOBAL_CB_NODE));
1014 pCB->cmdBuffer = cb;
1015 pCB->flags = saveFlags;
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -07001016 pCB->queueNodeIndex = saveQueueNodeIndex;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001017 pCB->lastVtxBinding = MAX_BINDING;
1018 }
1019}
1020// Set the last bound dynamic state of given type
1021// TODO : Need to track this per cmdBuffer and correlate cmdBuffer for Draw w/ last bound for that cmdBuffer?
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001022static void setLastBoundDynamicState(const VkCmdBuffer cmdBuffer, const VkDynamicStateObject state, const VkStateBindPoint sType)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001023{
1024 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
1025 if (pCB) {
1026 updateCBTracking(cmdBuffer);
1027 loader_platform_thread_lock_mutex(&globalLock);
1028 addCmd(pCB, CMD_BINDDYNAMICSTATEOBJECT);
1029 if (dynamicStateMap.find(state) == dynamicStateMap.end()) {
1030 char str[1024];
1031 sprintf(str, "Unable to find dynamic state object %p, was it ever created?", (void*)state);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001032 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, state, 0, DRAWSTATE_INVALID_DYNAMIC_STATE_OBJECT, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001033 }
1034 else {
1035 pCB->lastBoundDynamicState[sType] = dynamicStateMap[state];
1036 g_lastBoundDynamicState[sType] = dynamicStateMap[state];
1037 }
1038 loader_platform_thread_unlock_mutex(&globalLock);
1039 }
1040 else {
1041 char str[1024];
1042 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001043 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001044 }
1045}
1046// Print the last bound Gfx Pipeline
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001047static void printPipeline(const VkCmdBuffer cb)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001048{
1049 GLOBAL_CB_NODE* pCB = getCBNode(cb);
1050 if (pCB) {
1051 PIPELINE_NODE *pPipeTrav = getPipeline(pCB->lastBoundPipeline);
1052 if (!pPipeTrav) {
1053 // nothing to print
1054 }
1055 else {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001056 string pipeStr = vk_print_vkgraphicspipelinecreateinfo(&pPipeTrav->graphicsPipelineCI, "{DS}").c_str();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001057 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", pipeStr.c_str());
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001058 }
1059 }
1060}
1061// Common Dot dumping code
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001062static void dsCoreDumpDot(const VkDescriptorSet ds, FILE* pOutFile)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001063{
1064 SET_NODE* pSet = getSetNode(ds);
1065 if (pSet) {
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001066 POOL_NODE* pPool = getPoolNode(pSet->pool);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001067 char tmp_str[4*1024];
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001068 fprintf(pOutFile, "subgraph cluster_DescriptorPool\n{\nlabel=\"Descriptor Pool\"\n");
1069 sprintf(tmp_str, "Pool (%p)", pPool->pool);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001070 char* pGVstr = vk_gv_print_vkdescriptorpoolcreateinfo(&pPool->createInfo, tmp_str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001071 fprintf(pOutFile, "%s", pGVstr);
1072 free(pGVstr);
1073 fprintf(pOutFile, "subgraph cluster_DescriptorSet\n{\nlabel=\"Descriptor Set (%p)\"\n", pSet->set);
1074 sprintf(tmp_str, "Descriptor Set (%p)", pSet->set);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001075 LAYOUT_NODE* pLayout = pSet->pLayout;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001076 uint32_t layout_index = 0;
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001077 ++layout_index;
1078 sprintf(tmp_str, "LAYOUT%u", layout_index);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001079 pGVstr = vk_gv_print_vkdescriptorsetlayoutcreateinfo(&pLayout->createInfo, tmp_str);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001080 fprintf(pOutFile, "%s", pGVstr);
1081 free(pGVstr);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001082 if (pSet->pUpdateStructs) {
1083 pGVstr = dynamic_gv_display(pSet->pUpdateStructs, "Descriptor Updates");
1084 fprintf(pOutFile, "%s", pGVstr);
1085 free(pGVstr);
1086 }
1087 if (pSet->ppDescriptors) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001088 fprintf(pOutFile, "\"DESCRIPTORS\" [\nlabel=<<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"> <TR><TD COLSPAN=\"2\" PORT=\"desc\">DESCRIPTORS</TD></TR>");
1089 uint32_t i = 0;
1090 for (i=0; i < pSet->descriptorCount; i++) {
1091 if (pSet->ppDescriptors[i]) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001092 fprintf(pOutFile, "<TR><TD PORT=\"slot%u\">slot%u</TD><TD>%s</TD></TR>", i, i, string_VkStructureType(pSet->ppDescriptors[i]->sType));
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001093 }
1094 }
1095#define NUM_COLORS 7
1096 vector<string> edgeColors;
1097 edgeColors.push_back("0000ff");
1098 edgeColors.push_back("ff00ff");
1099 edgeColors.push_back("ffff00");
1100 edgeColors.push_back("00ff00");
1101 edgeColors.push_back("000000");
1102 edgeColors.push_back("00ffff");
1103 edgeColors.push_back("ff0000");
1104 uint32_t colorIdx = 0;
1105 fprintf(pOutFile, "</TABLE>>\n];\n");
1106 // Now add the views that are mapped to active descriptors
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001107 VkUpdateSamplers* pUS = NULL;
1108 VkUpdateSamplerTextures* pUST = NULL;
1109 VkUpdateImages* pUI = NULL;
1110 VkUpdateBuffers* pUB = NULL;
1111 VkUpdateAsCopy* pUAC = NULL;
1112 VkSamplerCreateInfo* pSCI = NULL;
1113 VkImageViewCreateInfo* pIVCI = NULL;
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -06001114 VkBufferViewCreateInfo* pBVCI = NULL;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001115 void** ppNextPtr = NULL;
1116 void* pSaveNext = NULL;
1117 for (i=0; i < pSet->descriptorCount; i++) {
1118 if (pSet->ppDescriptors[i]) {
1119 switch (pSet->ppDescriptors[i]->sType)
1120 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001121 case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001122 pUS = (VkUpdateSamplers*)pSet->ppDescriptors[i];
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001123 pSCI = getSamplerCreateInfo(pUS->pSamplers[i-pUS->arrayIndex]);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001124 if (pSCI) {
1125 sprintf(tmp_str, "SAMPLER%u", i);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001126 fprintf(pOutFile, "%s", vk_gv_print_vksamplercreateinfo(pSCI, tmp_str));
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001127 fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str());
1128 }
1129 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001130 case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001131 pUST = (VkUpdateSamplerTextures*)pSet->ppDescriptors[i];
Courtney Goeltzenleuchterd38dcc92015-04-09 11:43:10 -06001132 pSCI = getSamplerCreateInfo(pUST->pSamplerImageViews[i-pUST->arrayIndex].sampler);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001133 if (pSCI) {
1134 sprintf(tmp_str, "SAMPLER%u", i);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001135 fprintf(pOutFile, "%s", vk_gv_print_vksamplercreateinfo(pSCI, tmp_str));
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001136 fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str());
1137 }
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001138 pIVCI = getImageViewCreateInfo(pUST->pSamplerImageViews[i-pUST->arrayIndex].pImageView->view);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001139 if (pIVCI) {
1140 sprintf(tmp_str, "IMAGE_VIEW%u", i);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001141 fprintf(pOutFile, "%s", vk_gv_print_vkimageviewcreateinfo(pIVCI, tmp_str));
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001142 fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str());
1143 }
1144 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001145 case VK_STRUCTURE_TYPE_UPDATE_IMAGES:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001146 pUI = (VkUpdateImages*)pSet->ppDescriptors[i];
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001147 pIVCI = getImageViewCreateInfo(pUI->pImageViews[i-pUI->arrayIndex].view);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001148 if (pIVCI) {
1149 sprintf(tmp_str, "IMAGE_VIEW%u", i);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001150 fprintf(pOutFile, "%s", vk_gv_print_vkimageviewcreateinfo(pIVCI, tmp_str));
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001151 fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str());
1152 }
1153 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001154 case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001155 pUB = (VkUpdateBuffers*)pSet->ppDescriptors[i];
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001156 pBVCI = getBufferViewCreateInfo(pUB->pBufferViews[i-pUB->arrayIndex].view);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001157 if (pBVCI) {
1158 sprintf(tmp_str, "BUFFER_VIEW%u", i);
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -06001159 fprintf(pOutFile, "%s", vk_gv_print_vkbufferviewcreateinfo(pBVCI, tmp_str));
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001160 fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str());
1161 }
1162 break;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001163 case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001164 pUAC = (VkUpdateAsCopy*)pSet->ppDescriptors[i];
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001165 // TODO : Need to validate this code
1166 // Save off pNext and set to NULL while printing this struct, then restore it
1167 ppNextPtr = (void**)&pUAC->pNext;
1168 pSaveNext = *ppNextPtr;
1169 *ppNextPtr = NULL;
1170 sprintf(tmp_str, "UPDATE_AS_COPY%u", i);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001171 fprintf(pOutFile, "%s", vk_gv_print_vkupdateascopy(pUAC, tmp_str));
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001172 fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str());
1173 // Restore next ptr
1174 *ppNextPtr = pSaveNext;
1175 break;
1176 default:
1177 break;
1178 }
1179 colorIdx = (colorIdx+1) % NUM_COLORS;
1180 }
1181 }
1182 }
1183 fprintf(pOutFile, "}\n");
1184 fprintf(pOutFile, "}\n");
1185 }
1186}
1187// Dump subgraph w/ DS info
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001188static void dsDumpDot(const VkCmdBuffer cb, FILE* pOutFile)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001189{
1190 GLOBAL_CB_NODE* pCB = getCBNode(cb);
1191 if (pCB && pCB->lastBoundDescriptorSet) {
1192 dsCoreDumpDot(pCB->lastBoundDescriptorSet, pOutFile);
1193 }
1194}
1195// Dump a GraphViz dot file showing the Cmd Buffers
1196static void cbDumpDotFile(string outFileName)
1197{
1198 // Print CB Chain for each CB
1199 FILE* pOutFile;
1200 pOutFile = fopen(outFileName.c_str(), "w");
1201 fprintf(pOutFile, "digraph g {\ngraph [\nrankdir = \"TB\"\n];\nnode [\nfontsize = \"16\"\nshape = \"plaintext\"\n];\nedge [\n];\n");
1202 fprintf(pOutFile, "subgraph cluster_cmdBuffers\n{\nlabel=\"Command Buffers\"\n");
1203 GLOBAL_CB_NODE* pCB = NULL;
1204 for (uint32_t i = 0; i < NUM_COMMAND_BUFFERS_TO_DISPLAY; i++) {
1205 pCB = g_pLastTouchedCB[i];
1206 if (pCB) {
1207 fprintf(pOutFile, "subgraph cluster_cmdBuffer%u\n{\nlabel=\"Command Buffer #%u\"\n", i, i);
1208 uint32_t instNum = 0;
1209 for (vector<CMD_NODE*>::iterator ii=pCB->pCmds.begin(); ii!=pCB->pCmds.end(); ++ii) {
1210 if (instNum) {
1211 fprintf(pOutFile, "\"CB%pCMD%u\" -> \"CB%pCMD%u\" [];\n", (void*)pCB->cmdBuffer, instNum-1, (void*)pCB->cmdBuffer, instNum);
1212 }
1213 if (pCB == g_lastGlobalCB) {
1214 fprintf(pOutFile, "\"CB%pCMD%u\" [\nlabel=<<TABLE BGCOLOR=\"#00FF00\" BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"> <TR><TD>CMD#</TD><TD>%u</TD></TR><TR><TD>CMD Type</TD><TD>%s</TD></TR></TABLE>>\n];\n", (void*)pCB->cmdBuffer, instNum, instNum, cmdTypeToString((*ii)->type).c_str());
1215 }
1216 else {
1217 fprintf(pOutFile, "\"CB%pCMD%u\" [\nlabel=<<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"> <TR><TD>CMD#</TD><TD>%u</TD></TR><TR><TD>CMD Type</TD><TD>%s</TD></TR></TABLE>>\n];\n", (void*)pCB->cmdBuffer, instNum, instNum, cmdTypeToString((*ii)->type).c_str());
1218 }
1219 ++instNum;
1220 }
1221 fprintf(pOutFile, "}\n");
1222 }
1223 }
1224 fprintf(pOutFile, "}\n");
1225 fprintf(pOutFile, "}\n"); // close main graph "g"
1226 fclose(pOutFile);
1227}
1228// Dump a GraphViz dot file showing the pipeline for last bound global state
1229static void dumpGlobalDotFile(char *outFileName)
1230{
1231 PIPELINE_NODE *pPipeTrav = g_lastBoundPipeline;
1232 if (pPipeTrav) {
1233 FILE* pOutFile;
1234 pOutFile = fopen(outFileName, "w");
1235 fprintf(pOutFile, "digraph g {\ngraph [\nrankdir = \"TB\"\n];\nnode [\nfontsize = \"16\"\nshape = \"plaintext\"\n];\nedge [\n];\n");
1236 fprintf(pOutFile, "subgraph cluster_dynamicState\n{\nlabel=\"Dynamic State\"\n");
1237 char* pGVstr = NULL;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001238 for (uint32_t i = 0; i < VK_NUM_STATE_BIND_POINT; i++) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001239 if (g_lastBoundDynamicState[i] && g_lastBoundDynamicState[i]->pCreateInfo) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001240 pGVstr = dynamic_gv_display(g_lastBoundDynamicState[i]->pCreateInfo, string_VkStateBindPoint((VkStateBindPoint)i));
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001241 fprintf(pOutFile, "%s", pGVstr);
1242 free(pGVstr);
1243 }
1244 }
1245 fprintf(pOutFile, "}\n"); // close dynamicState subgraph
1246 fprintf(pOutFile, "subgraph cluster_PipelineStateObject\n{\nlabel=\"Pipeline State Object\"\n");
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001247 pGVstr = vk_gv_print_vkgraphicspipelinecreateinfo(&pPipeTrav->graphicsPipelineCI, "PSO HEAD");
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001248 fprintf(pOutFile, "%s", pGVstr);
1249 free(pGVstr);
1250 fprintf(pOutFile, "}\n");
1251 dsCoreDumpDot(g_lastBoundDescriptorSet, pOutFile);
1252 fprintf(pOutFile, "}\n"); // close main graph "g"
1253 fclose(pOutFile);
1254 }
1255}
1256// Dump a GraphViz dot file showing the pipeline for a given CB
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001257static void dumpDotFile(const VkCmdBuffer cb, string outFileName)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001258{
1259 GLOBAL_CB_NODE* pCB = getCBNode(cb);
1260 if (pCB) {
1261 PIPELINE_NODE *pPipeTrav = getPipeline(pCB->lastBoundPipeline);
1262 if (pPipeTrav) {
1263 FILE* pOutFile;
1264 pOutFile = fopen(outFileName.c_str(), "w");
1265 fprintf(pOutFile, "digraph g {\ngraph [\nrankdir = \"TB\"\n];\nnode [\nfontsize = \"16\"\nshape = \"plaintext\"\n];\nedge [\n];\n");
1266 fprintf(pOutFile, "subgraph cluster_dynamicState\n{\nlabel=\"Dynamic State\"\n");
1267 char* pGVstr = NULL;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001268 for (uint32_t i = 0; i < VK_NUM_STATE_BIND_POINT; i++) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001269 if (pCB->lastBoundDynamicState[i] && pCB->lastBoundDynamicState[i]->pCreateInfo) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001270 pGVstr = dynamic_gv_display(pCB->lastBoundDynamicState[i]->pCreateInfo, string_VkStateBindPoint((VkStateBindPoint)i));
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001271 fprintf(pOutFile, "%s", pGVstr);
1272 free(pGVstr);
1273 }
1274 }
1275 fprintf(pOutFile, "}\n"); // close dynamicState subgraph
1276 fprintf(pOutFile, "subgraph cluster_PipelineStateObject\n{\nlabel=\"Pipeline State Object\"\n");
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001277 pGVstr = vk_gv_print_vkgraphicspipelinecreateinfo(&pPipeTrav->graphicsPipelineCI, "PSO HEAD");
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001278 fprintf(pOutFile, "%s", pGVstr);
1279 free(pGVstr);
1280 fprintf(pOutFile, "}\n");
1281 dsDumpDot(cb, pOutFile);
1282 fprintf(pOutFile, "}\n"); // close main graph "g"
1283 fclose(pOutFile);
1284 }
1285 }
1286}
1287// Verify VB Buffer binding
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001288static void validateVBBinding(const VkCmdBuffer cb)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001289{
1290 GLOBAL_CB_NODE* pCB = getCBNode(cb);
1291 if (pCB && pCB->lastBoundPipeline) {
1292 // First verify that we have a Node for bound pipeline
1293 PIPELINE_NODE *pPipeTrav = getPipeline(pCB->lastBoundPipeline);
1294 char str[1024];
1295 if (!pPipeTrav) {
1296 sprintf(str, "Can't find last bound Pipeline %p!", (void*)pCB->lastBoundPipeline);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001297 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NO_PIPELINE_BOUND, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001298 }
1299 else {
1300 // Verify Vtx binding
1301 if (MAX_BINDING != pCB->lastVtxBinding) {
1302 if (pCB->lastVtxBinding >= pPipeTrav->vtxBindingCount) {
1303 if (0 == pPipeTrav->vtxBindingCount) {
1304 sprintf(str, "Vtx Buffer Index %u was bound, but no vtx buffers are attached to PSO.", pCB->lastVtxBinding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001305 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001306 }
1307 else {
1308 sprintf(str, "Vtx binding Index of %u exceeds PSO pVertexBindingDescriptions max array index of %u.", pCB->lastVtxBinding, (pPipeTrav->vtxBindingCount - 1));
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001309 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001310 }
1311 }
1312 else {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001313 string tmpStr = vk_print_vkvertexinputbindingdescription(&pPipeTrav->pVertexBindingDescriptions[pCB->lastVtxBinding], "{DS}INFO : ").c_str();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001314 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmpStr.c_str());
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001315 }
1316 }
1317 }
1318 }
1319}
1320// Print details of DS config to stdout
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001321static void printDSConfig(const VkCmdBuffer cb)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001322{
1323 char tmp_str[1024];
1324 char ds_config_str[1024*256] = {0}; // TODO : Currently making this buffer HUGE w/o overrun protection. Need to be smarter, start smaller, and grow as needed.
1325 GLOBAL_CB_NODE* pCB = getCBNode(cb);
1326 if (pCB) {
1327 SET_NODE* pSet = getSetNode(pCB->lastBoundDescriptorSet);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001328 POOL_NODE* pPool = getPoolNode(pSet->pool);
1329 // Print out pool details
1330 sprintf(tmp_str, "Details for pool %p.", (void*)pPool->pool);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001331 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001332 string poolStr = vk_print_vkdescriptorpoolcreateinfo(&pPool->createInfo, " ");
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001333 sprintf(ds_config_str, "%s", poolStr.c_str());
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001334 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001335 // Print out set details
1336 char prefix[10];
1337 uint32_t index = 0;
1338 sprintf(tmp_str, "Details for descriptor set %p.", (void*)pSet->set);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001339 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001340 LAYOUT_NODE* pLayout = pSet->pLayout;
1341 // Print layout details
1342 sprintf(tmp_str, "Layout #%u, (object %p) for DS %p.", index+1, (void*)pLayout->layout, (void*)pSet->set);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001343 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001344 sprintf(prefix, " [L%u] ", index);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001345 string DSLstr = vk_print_vkdescriptorsetlayoutcreateinfo(&pLayout->createInfo, prefix).c_str();
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001346 sprintf(ds_config_str, "%s", DSLstr.c_str());
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001347 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001348 index++;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001349 GENERIC_HEADER* pUpdate = pSet->pUpdateStructs;
1350 if (pUpdate) {
1351 sprintf(tmp_str, "Update Chain [UC] for descriptor set %p:", (void*)pSet->set);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001352 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001353 sprintf(prefix, " [UC] ");
1354 sprintf(ds_config_str, "%s", dynamic_display(pUpdate, prefix).c_str());
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001355 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001356 // TODO : If there is a "view" associated with this update, print CI for that view
1357 }
1358 else {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001359 sprintf(tmp_str, "No Update Chain for descriptor set %p (vkUpdateDescriptors has not been called)", (void*)pSet->set);
1360 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001361 }
1362 }
1363}
1364
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001365static void printCB(const VkCmdBuffer cb)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001366{
1367 GLOBAL_CB_NODE* pCB = getCBNode(cb);
1368 if (pCB) {
1369 char str[1024];
1370 sprintf(str, "Cmds in CB %p", (void*)cb);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001371 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001372 for (vector<CMD_NODE*>::iterator ii=pCB->pCmds.begin(); ii!=pCB->pCmds.end(); ++ii) {
1373 sprintf(str, " CMD#%lu: %s", (*ii)->cmdNumber, cmdTypeToString((*ii)->type).c_str());
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001374 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, cb, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001375 }
1376 }
1377 else {
1378 // Nothing to print
1379 }
1380}
1381
1382
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001383static void synchAndPrintDSConfig(const VkCmdBuffer cb)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001384{
1385 printDSConfig(cb);
1386 printPipeline(cb);
1387 printDynamicState(cb);
1388 static int autoDumpOnce = 0;
1389 if (autoDumpOnce) {
1390 autoDumpOnce = 0;
1391 dumpDotFile(cb, "pipeline_dump.dot");
1392 cbDumpDotFile("cb_dump.dot");
1393#if defined(_WIN32)
1394// FIXME: NEED WINDOWS EQUIVALENT
1395#else // WIN32
1396 // Convert dot to svg if dot available
1397 if(access( "/usr/bin/dot", X_OK) != -1) {
1398 system("/usr/bin/dot pipeline_dump.dot -Tsvg -o pipeline_dump.svg");
1399 }
1400#endif // WIN32
1401 }
1402}
1403
1404static void initDrawState(void)
1405{
1406 const char *strOpt;
1407 // initialize DrawState options
1408 getLayerOptionEnum("DrawStateReportLevel", (uint32_t *) &g_reportingLevel);
1409 g_actionIsDefault = getLayerOptionEnum("DrawStateDebugAction", (uint32_t *) &g_debugAction);
1410
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001411 if (g_debugAction & VK_DBG_LAYER_ACTION_LOG_MSG)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001412 {
1413 strOpt = getLayerOption("DrawStateLogFilename");
1414 if (strOpt)
1415 {
1416 g_logFile = fopen(strOpt, "w");
1417 }
1418 if (g_logFile == NULL)
1419 g_logFile = stdout;
1420 }
1421 // initialize Layer dispatch table
1422 // TODO handle multiple GPUs
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001423 PFN_vkGetProcAddr fpNextGPA;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001424 fpNextGPA = pCurObj->pGPA;
1425 assert(fpNextGPA);
1426
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001427 layer_initialize_dispatch_table(&nextTable, fpNextGPA, (VkPhysicalGpu) pCurObj->nextObject);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001428
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001429 if (!globalLockInitialized)
1430 {
1431 // TODO/TBD: Need to delete this mutex sometime. How??? One
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001432 // suggestion is to call this during vkCreateInstance(), and then we
1433 // can clean it up during vkDestroyInstance(). However, that requires
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001434 // that the layer have per-instance locks. We need to come back and
1435 // address this soon.
1436 loader_platform_thread_create_mutex(&globalLock);
1437 globalLockInitialized = 1;
1438 }
1439}
1440
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001441VK_LAYER_EXPORT VkResult VKAPI vkCreateDevice(VkPhysicalGpu gpu, const VkDeviceCreateInfo* pCreateInfo, VkDevice* pDevice)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001442{
Jon Ashburn630e44f2015-04-08 21:33:34 -06001443 pCurObj = (VkBaseLayerObject *) gpu;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001444 loader_platform_thread_once(&g_initOnce, initDrawState);
Jon Ashburn630e44f2015-04-08 21:33:34 -06001445 VkResult result = nextTable.CreateDevice(gpu, pCreateInfo, pDevice);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001446 return result;
1447}
1448
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001449VK_LAYER_EXPORT VkResult VKAPI vkDestroyDevice(VkDevice device)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001450{
1451 // Free all the memory
1452 loader_platform_thread_lock_mutex(&globalLock);
Tobin Ehliseaf28662015-04-08 10:58:37 -06001453 deletePipelines();
1454 deleteSamplers();
1455 deleteImages();
1456 deleteBuffers();
1457 deleteCmdBuffers();
1458 deleteDynamicState();
1459 deletePools();
1460 deleteLayouts();
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001461 loader_platform_thread_unlock_mutex(&globalLock);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001462 VkResult result = nextTable.DestroyDevice(device);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001463 return result;
1464}
1465
Jon Ashburneb2728b2015-04-10 14:33:07 -06001466struct extProps {
1467 uint32_t version;
1468 const char * const name;
1469};
Jon Ashburnbdcd7562015-04-14 14:12:59 -06001470#define DRAW_STATE_LAYER_EXT_ARRAY_SIZE 5
Jon Ashburneb2728b2015-04-10 14:33:07 -06001471static const struct extProps dsExts[DRAW_STATE_LAYER_EXT_ARRAY_SIZE] = {
1472 // TODO what is the version?
Jon Ashburnbdcd7562015-04-14 14:12:59 -06001473 0x10, "DrawState",
1474 0x10, "Validation",
1475 0x10, "drawStateDumpDotFile",
1476 0x10, "drawStateDumpCommandBufferDotFile",
1477 0x10, "drawStateDumpPngFile"
Jon Ashburneb2728b2015-04-10 14:33:07 -06001478};
1479
1480VK_LAYER_EXPORT VkResult VKAPI vkGetGlobalExtensionInfo(
1481 VkExtensionInfoType infoType,
1482 uint32_t extensionIndex,
1483 size_t* pDataSize,
1484 void* pData)
1485{
1486 VkResult result;
1487
1488 /* This entrypoint is NOT going to init it's own dispatch table since loader calls here early */
1489 VkExtensionProperties *ext_props;
1490 uint32_t *count;
1491
1492 if (pDataSize == NULL)
1493 return VK_ERROR_INVALID_POINTER;
1494
1495 switch (infoType) {
1496 case VK_EXTENSION_INFO_TYPE_COUNT:
1497 *pDataSize = sizeof(uint32_t);
1498 if (pData == NULL)
1499 return VK_SUCCESS;
1500 count = (uint32_t *) pData;
1501 *count = DRAW_STATE_LAYER_EXT_ARRAY_SIZE;
1502 break;
1503 case VK_EXTENSION_INFO_TYPE_PROPERTIES:
1504 *pDataSize = sizeof(VkExtensionProperties);
1505 if (pData == NULL)
1506 return VK_SUCCESS;
1507 if (extensionIndex >= DRAW_STATE_LAYER_EXT_ARRAY_SIZE)
1508 return VK_ERROR_INVALID_VALUE;
1509 ext_props = (VkExtensionProperties *) pData;
1510 ext_props->version = dsExts[extensionIndex].version;
1511 strncpy(ext_props->extName, dsExts[extensionIndex].name,
1512 VK_MAX_EXTENSION_NAME);
1513 ext_props->extName[VK_MAX_EXTENSION_NAME - 1] = '\0';
1514 break;
1515 default:
1516 return VK_ERROR_INVALID_VALUE;
1517 };
1518
1519 return VK_SUCCESS;
1520}
1521
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001522VK_LAYER_EXPORT VkResult VKAPI vkGetExtensionSupport(VkPhysicalGpu gpu, const char* pExtName)
Jon Ashburn25566352015-04-02 12:06:28 -06001523{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001524 VkResult result;
Jon Ashburn630e44f2015-04-08 21:33:34 -06001525
Jon Ashburn25566352015-04-02 12:06:28 -06001526 /* This entrypoint is NOT going to init its own dispatch table since loader calls here early */
1527 if (!strcmp(pExtName, "DrawState") || !strcmp(pExtName, "drawStateDumpDotFile") ||
1528 !strcmp(pExtName, "drawStateDumpCommandBufferDotFile") || !strcmp(pExtName, "drawStateDumpPngFile"))
1529 {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001530 result = VK_SUCCESS;
Jon Ashburn25566352015-04-02 12:06:28 -06001531 } else if (nextTable.GetExtensionSupport != NULL)
1532 {
Jon Ashburn630e44f2015-04-08 21:33:34 -06001533 result = nextTable.GetExtensionSupport(gpu, pExtName);
1534 } else {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001535 result = VK_ERROR_INVALID_EXTENSION;
Jon Ashburn25566352015-04-02 12:06:28 -06001536 }
1537 return result;
1538}
1539
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001540VK_LAYER_EXPORT VkResult VKAPI vkEnumerateLayers(VkPhysicalGpu gpu, size_t maxLayerCount, size_t maxStringSize, size_t* pOutLayerCount, char* const* pOutLayers, void* pReserved)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001541{
1542 if (gpu != NULL)
1543 {
Jon Ashburn630e44f2015-04-08 21:33:34 -06001544 pCurObj = (VkBaseLayerObject *) gpu;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001545 loader_platform_thread_once(&g_initOnce, initDrawState);
Jon Ashburn630e44f2015-04-08 21:33:34 -06001546 VkResult result = nextTable.EnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001547 return result;
Jon Ashburn630e44f2015-04-08 21:33:34 -06001548 } else {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001549 if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL)
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001550 return VK_ERROR_INVALID_POINTER;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001551 // This layer compatible with all GPUs
1552 *pOutLayerCount = 1;
1553 strncpy((char *) pOutLayers[0], "DrawState", maxStringSize);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001554 return VK_SUCCESS;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001555 }
1556}
1557
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001558VK_LAYER_EXPORT VkResult VKAPI vkQueueSubmit(VkQueue queue, uint32_t cmdBufferCount, const VkCmdBuffer* pCmdBuffers, VkFence fence)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001559{
1560 for (uint32_t i=0; i < cmdBufferCount; i++) {
1561 // Validate that cmd buffers have been updated
1562 }
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001563 VkResult result = nextTable.QueueSubmit(queue, cmdBufferCount, pCmdBuffers, fence);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001564 return result;
1565}
1566
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001567VK_LAYER_EXPORT VkResult VKAPI vkDestroyObject(VkObject object)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001568{
1569 // TODO : When wrapped objects (such as dynamic state) are destroyed, need to clean up memory
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001570 VkResult result = nextTable.DestroyObject(object);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001571 return result;
1572}
1573
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001574VK_LAYER_EXPORT VkResult VKAPI vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, VkBufferView* pView)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001575{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001576 VkResult result = nextTable.CreateBufferView(device, pCreateInfo, pView);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001577 if (VK_SUCCESS == result) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001578 loader_platform_thread_lock_mutex(&globalLock);
1579 BUFFER_NODE* pNewNode = new BUFFER_NODE;
1580 pNewNode->buffer = *pView;
1581 pNewNode->createInfo = *pCreateInfo;
1582 bufferMap[*pView] = pNewNode;
1583 loader_platform_thread_unlock_mutex(&globalLock);
1584 }
1585 return result;
1586}
1587
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001588VK_LAYER_EXPORT VkResult VKAPI vkCreateImageView(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, VkImageView* pView)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001589{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001590 VkResult result = nextTable.CreateImageView(device, pCreateInfo, pView);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001591 if (VK_SUCCESS == result) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001592 loader_platform_thread_lock_mutex(&globalLock);
1593 IMAGE_NODE *pNewNode = new IMAGE_NODE;
1594 pNewNode->image = *pView;
1595 pNewNode->createInfo = *pCreateInfo;
1596 imageMap[*pView] = pNewNode;
1597 loader_platform_thread_unlock_mutex(&globalLock);
1598 }
1599 return result;
1600}
1601
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001602static void track_pipeline(const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline)
Courtney Goeltzenleuchter9452ac22015-04-13 16:16:04 -06001603{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001604 // Create LL HEAD for this Pipeline
1605 loader_platform_thread_lock_mutex(&globalLock);
Courtney Goeltzenleuchter9452ac22015-04-13 16:16:04 -06001606 PIPELINE_NODE* pPipeNode = new PIPELINE_NODE;
1607 memset((void*)pPipeNode, 0, sizeof(PIPELINE_NODE));
1608 pPipeNode->pipeline = *pPipeline;
1609 initPipeline(pPipeNode, pCreateInfo);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001610 loader_platform_thread_unlock_mutex(&globalLock);
Courtney Goeltzenleuchter9452ac22015-04-13 16:16:04 -06001611}
1612
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001613VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipeline(VkDevice device, const VkGraphicsPipelineCreateInfo* pCreateInfo, VkPipeline* pPipeline)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001614{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001615 VkResult result = nextTable.CreateGraphicsPipeline(device, pCreateInfo, pPipeline);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001616 // Create LL HEAD for this Pipeline
1617 char str[1024];
1618 sprintf(str, "Created Gfx Pipeline %p", (void*)*pPipeline);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001619 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, *pPipeline, 0, DRAWSTATE_NONE, "DS", str);
Courtney Goeltzenleuchter9452ac22015-04-13 16:16:04 -06001620
1621 track_pipeline(pCreateInfo, pPipeline);
1622
Courtney Goeltzenleuchter9452ac22015-04-13 16:16:04 -06001623 return result;
1624}
1625
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001626VK_LAYER_EXPORT VkResult VKAPI vkCreateGraphicsPipelineDerivative(
1627 VkDevice device,
1628 const VkGraphicsPipelineCreateInfo* pCreateInfo,
1629 VkPipeline basePipeline,
1630 VkPipeline* pPipeline)
Courtney Goeltzenleuchter9452ac22015-04-13 16:16:04 -06001631{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001632 VkResult result = nextTable.CreateGraphicsPipelineDerivative(device, pCreateInfo, basePipeline, pPipeline);
Courtney Goeltzenleuchter9452ac22015-04-13 16:16:04 -06001633 // Create LL HEAD for this Pipeline
1634 char str[1024];
1635 sprintf(str, "Created Gfx Pipeline %p (derived from pipeline %p)", (void*)*pPipeline, basePipeline);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001636 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, *pPipeline, 0, DRAWSTATE_NONE, "DS", str);
Courtney Goeltzenleuchter9452ac22015-04-13 16:16:04 -06001637
1638 track_pipeline(pCreateInfo, pPipeline);
1639
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001640 loader_platform_thread_unlock_mutex(&globalLock);
Jon Ashburnbdcd7562015-04-14 14:12:59 -06001641
1642 return result;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001643}
1644
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001645VK_LAYER_EXPORT VkResult VKAPI vkCreateSampler(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, VkSampler* pSampler)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001646{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001647 VkResult result = nextTable.CreateSampler(device, pCreateInfo, pSampler);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001648 if (VK_SUCCESS == result) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001649 loader_platform_thread_lock_mutex(&globalLock);
1650 SAMPLER_NODE* pNewNode = new SAMPLER_NODE;
1651 pNewNode->sampler = *pSampler;
1652 pNewNode->createInfo = *pCreateInfo;
1653 sampleMap[*pSampler] = pNewNode;
1654 loader_platform_thread_unlock_mutex(&globalLock);
1655 }
1656 return result;
1657}
1658
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001659VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorSetLayout(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayout* pSetLayout)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001660{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001661 VkResult result = nextTable.CreateDescriptorSetLayout(device, pCreateInfo, pSetLayout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001662 if (VK_SUCCESS == result) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001663 LAYOUT_NODE* pNewNode = new LAYOUT_NODE;
1664 if (NULL == pNewNode) {
1665 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001666 sprintf(str, "Out of memory while attempting to allocate LAYOUT_NODE in vkCreateDescriptorSetLayout()");
1667 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, *pSetLayout, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001668 }
1669 memset(pNewNode, 0, sizeof(LAYOUT_NODE));
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001670 memcpy((void*)&pNewNode->createInfo, pCreateInfo, sizeof(VkDescriptorSetLayoutCreateInfo));
1671 pNewNode->createInfo.pBinding = new VkDescriptorSetLayoutBinding[pCreateInfo->count];
1672 memcpy((void*)pNewNode->createInfo.pBinding, pCreateInfo->pBinding, sizeof(VkDescriptorSetLayoutBinding)*pCreateInfo->count);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001673 uint32_t totalCount = 0;
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001674 for (uint32_t i=0; i<pCreateInfo->count; i++) {
1675 totalCount += pCreateInfo->pBinding[i].count;
1676 if (pCreateInfo->pBinding[i].pImmutableSamplers) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001677 VkSampler** ppIS = (VkSampler**)&pNewNode->createInfo.pBinding[i].pImmutableSamplers;
1678 *ppIS = new VkSampler[pCreateInfo->pBinding[i].count];
1679 memcpy(*ppIS, pCreateInfo->pBinding[i].pImmutableSamplers, pCreateInfo->pBinding[i].count*sizeof(VkSampler));
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001680 }
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001681 }
1682 if (totalCount > 0) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001683 pNewNode->pTypes = new VkDescriptorType[totalCount];
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001684 uint32_t offset = 0;
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001685 uint32_t j = 0;
1686 for (uint32_t i=0; i<pCreateInfo->count; i++) {
1687 for (j = 0; j < pCreateInfo->pBinding[i].count; j++) {
1688 pNewNode->pTypes[offset + j] = pCreateInfo->pBinding[i].descriptorType;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001689 }
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001690 offset += j;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001691 }
1692 }
1693 pNewNode->layout = *pSetLayout;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001694 pNewNode->startIndex = 0;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001695 pNewNode->endIndex = pNewNode->startIndex + totalCount - 1;
1696 assert(pNewNode->endIndex >= pNewNode->startIndex);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001697 // Put new node at Head of global Layer list
1698 loader_platform_thread_lock_mutex(&globalLock);
1699 layoutMap[*pSetLayout] = pNewNode;
1700 loader_platform_thread_unlock_mutex(&globalLock);
1701 }
1702 return result;
1703}
1704
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001705VkResult VKAPI vkCreateDescriptorSetLayoutChain(VkDevice device, uint32_t setLayoutArrayCount, const VkDescriptorSetLayout* pSetLayoutArray, VkDescriptorSetLayoutChain* pLayoutChain)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001706{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001707 VkResult result = nextTable.CreateDescriptorSetLayoutChain(device, setLayoutArrayCount, pSetLayoutArray, pLayoutChain);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001708 if (VK_SUCCESS == result) {
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001709 // TODO : Need to capture the layout chains
1710 }
1711 return result;
1712}
1713
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001714VK_LAYER_EXPORT VkResult VKAPI vkBeginDescriptorPoolUpdate(VkDevice device, VkDescriptorUpdateMode updateMode)
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001715{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001716 VkResult result = nextTable.BeginDescriptorPoolUpdate(device, updateMode);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001717 if (VK_SUCCESS == result) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001718 loader_platform_thread_lock_mutex(&globalLock);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001719 POOL_NODE* pPoolNode = poolMap.begin()->second;
1720 if (!pPoolNode) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001721 char str[1024];
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001722 sprintf(str, "Unable to find pool node");
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001723 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_INTERNAL_ERROR, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001724 }
1725 else {
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001726 pPoolNode->updateActive = 1;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001727 }
1728 loader_platform_thread_unlock_mutex(&globalLock);
1729 }
1730 return result;
1731}
1732
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001733VK_LAYER_EXPORT VkResult VKAPI vkEndDescriptorPoolUpdate(VkDevice device, VkCmdBuffer cmd)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001734{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001735 VkResult result = nextTable.EndDescriptorPoolUpdate(device, cmd);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001736 if (VK_SUCCESS == result) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001737 loader_platform_thread_lock_mutex(&globalLock);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001738 POOL_NODE* pPoolNode = poolMap.begin()->second;
1739 if (!pPoolNode) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001740 char str[1024];
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001741 sprintf(str, "Unable to find pool node");
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001742 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_INTERNAL_ERROR, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001743 }
1744 else {
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001745 if (!pPoolNode->updateActive) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001746 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001747 sprintf(str, "You must call vkBeginDescriptorPoolUpdate() before this call to vkEndDescriptorPoolUpdate()!");
1748 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_DS_END_WITHOUT_BEGIN, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001749 }
1750 else {
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001751 pPoolNode->updateActive = 0;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001752 }
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001753 pPoolNode->updateActive = 0;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001754 }
1755 loader_platform_thread_unlock_mutex(&globalLock);
1756 }
1757 return result;
1758}
1759
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001760VK_LAYER_EXPORT VkResult VKAPI vkCreateDescriptorPool(VkDevice device, VkDescriptorPoolUsage poolUsage, uint32_t maxSets, const VkDescriptorPoolCreateInfo* pCreateInfo, VkDescriptorPool* pDescriptorPool)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001761{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001762 VkResult result = nextTable.CreateDescriptorPool(device, poolUsage, maxSets, pCreateInfo, pDescriptorPool);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001763 if (VK_SUCCESS == result) {
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001764 // Insert this pool into Global Pool LL at head
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001765 char str[1024];
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001766 sprintf(str, "Created Descriptor Pool %p", (void*)*pDescriptorPool);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001767 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, (VkBaseObject)pDescriptorPool, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001768 loader_platform_thread_lock_mutex(&globalLock);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001769 POOL_NODE* pNewNode = new POOL_NODE;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001770 if (NULL == pNewNode) {
1771 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001772 sprintf(str, "Out of memory while attempting to allocate POOL_NODE in vkCreateDescriptorPool()");
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001773 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, (VkBaseObject)*pDescriptorPool, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001774 }
1775 else {
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001776 memset(pNewNode, 0, sizeof(POOL_NODE));
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001777 VkDescriptorPoolCreateInfo* pCI = (VkDescriptorPoolCreateInfo*)&pNewNode->createInfo;
1778 memcpy((void*)pCI, pCreateInfo, sizeof(VkDescriptorPoolCreateInfo));
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001779 if (pNewNode->createInfo.count) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001780 size_t typeCountSize = pNewNode->createInfo.count * sizeof(VkDescriptorTypeCount);
1781 pNewNode->createInfo.pTypeCount = new VkDescriptorTypeCount[typeCountSize];
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001782 memcpy((void*)pNewNode->createInfo.pTypeCount, pCreateInfo->pTypeCount, typeCountSize);
1783 }
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001784 pNewNode->poolUsage = poolUsage;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001785 pNewNode->updateActive = 0;
1786 pNewNode->maxSets = maxSets;
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001787 pNewNode->pool = *pDescriptorPool;
1788 poolMap[*pDescriptorPool] = pNewNode;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001789 }
1790 loader_platform_thread_unlock_mutex(&globalLock);
1791 }
1792 else {
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001793 // Need to do anything if pool create fails?
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001794 }
1795 return result;
1796}
1797
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001798VK_LAYER_EXPORT VkResult VKAPI vkResetDescriptorPool(VkDescriptorPool descriptorPool)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001799{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001800 VkResult result = nextTable.ResetDescriptorPool(descriptorPool);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001801 if (VK_SUCCESS == result) {
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001802 clearDescriptorPool(descriptorPool);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001803 }
1804 return result;
1805}
1806
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001807VK_LAYER_EXPORT VkResult VKAPI vkAllocDescriptorSets(VkDescriptorPool descriptorPool, VkDescriptorSetUsage setUsage, uint32_t count, const VkDescriptorSetLayout* pSetLayouts, VkDescriptorSet* pDescriptorSets, uint32_t* pCount)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001808{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001809 VkResult result = nextTable.AllocDescriptorSets(descriptorPool, setUsage, count, pSetLayouts, pDescriptorSets, pCount);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001810 if ((VK_SUCCESS == result) || (*pCount > 0)) {
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001811 POOL_NODE *pPoolNode = getPoolNode(descriptorPool);
1812 if (!pPoolNode) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001813 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001814 sprintf(str, "Unable to find pool node for pool %p specified in vkAllocDescriptorSets() call", (void*)descriptorPool);
1815 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, descriptorPool, 0, DRAWSTATE_INVALID_POOL, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001816 }
1817 else {
1818 for (uint32_t i = 0; i < *pCount; i++) {
1819 char str[1024];
1820 sprintf(str, "Created Descriptor Set %p", (void*)pDescriptorSets[i]);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001821 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001822 // Create new set node and add to head of pool nodes
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001823 SET_NODE* pNewNode = new SET_NODE;
1824 if (NULL == pNewNode) {
1825 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001826 sprintf(str, "Out of memory while attempting to allocate SET_NODE in vkAllocDescriptorSets()");
1827 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001828 }
1829 else {
1830 memset(pNewNode, 0, sizeof(SET_NODE));
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001831 // Insert set at head of Set LL for this pool
1832 pNewNode->pNext = pPoolNode->pSets;
1833 pPoolNode->pSets = pNewNode;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001834 LAYOUT_NODE* pLayout = getLayoutNode(pSetLayouts[i]);
1835 if (NULL == pLayout) {
1836 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001837 sprintf(str, "Unable to find set layout node for layout %p specified in vkAllocDescriptorSets() call", (void*)pSetLayouts[i]);
1838 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pSetLayouts[i], 0, DRAWSTATE_INVALID_LAYOUT, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001839 }
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001840 pNewNode->pLayout = pLayout;
1841 pNewNode->pool = descriptorPool;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001842 pNewNode->set = pDescriptorSets[i];
1843 pNewNode->setUsage = setUsage;
1844 pNewNode->descriptorCount = pLayout->endIndex + 1;
1845 if (pNewNode->descriptorCount) {
1846 size_t descriptorArraySize = sizeof(GENERIC_HEADER*)*pNewNode->descriptorCount;
1847 pNewNode->ppDescriptors = new GENERIC_HEADER*[descriptorArraySize];
1848 memset(pNewNode->ppDescriptors, 0, descriptorArraySize);
1849 }
1850 setMap[pDescriptorSets[i]] = pNewNode;
1851 }
1852 }
1853 }
1854 }
1855 return result;
1856}
1857
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001858VK_LAYER_EXPORT void VKAPI vkClearDescriptorSets(VkDescriptorPool descriptorPool, uint32_t count, const VkDescriptorSet* pDescriptorSets)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001859{
1860 for (uint32_t i = 0; i < count; i++) {
1861 clearDescriptorSet(pDescriptorSets[i]);
1862 }
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001863 nextTable.ClearDescriptorSets(descriptorPool, count, pDescriptorSets);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001864}
1865
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001866VK_LAYER_EXPORT void VKAPI vkUpdateDescriptors(VkDescriptorSet descriptorSet, uint32_t updateCount, const void** ppUpdateArray)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001867{
1868 SET_NODE* pSet = getSetNode(descriptorSet);
1869 if (!dsUpdateActive(descriptorSet)) {
1870 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001871 sprintf(str, "You must call vkBeginDescriptorPoolUpdate() before this call to vkUpdateDescriptors()!");
1872 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pSet->pool, 0, DRAWSTATE_UPDATE_WITHOUT_BEGIN, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001873 }
1874 else {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001875 // pUpdateChain is a Linked-list of VK_UPDATE_* structures defining the mappings for the descriptors
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001876 dsUpdate(descriptorSet, updateCount, ppUpdateArray);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001877 }
1878
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06001879 nextTable.UpdateDescriptors(descriptorSet, updateCount, ppUpdateArray);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001880}
1881
Courtney Goeltzenleuchterfcf855f2015-04-10 16:24:50 -06001882VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicViewportState(VkDevice device, const VkDynamicVpStateCreateInfo* pCreateInfo, VkDynamicVpState* pState)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001883{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001884 VkResult result = nextTable.CreateDynamicViewportState(device, pCreateInfo, pState);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001885 insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_VIEWPORT);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001886 return result;
1887}
1888
Courtney Goeltzenleuchterfcf855f2015-04-10 16:24:50 -06001889VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicRasterState(VkDevice device, const VkDynamicRsStateCreateInfo* pCreateInfo, VkDynamicRsState* pState)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001890{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001891 VkResult result = nextTable.CreateDynamicRasterState(device, pCreateInfo, pState);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001892 insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_RASTER);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001893 return result;
1894}
1895
Courtney Goeltzenleuchterfcf855f2015-04-10 16:24:50 -06001896VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicColorBlendState(VkDevice device, const VkDynamicCbStateCreateInfo* pCreateInfo, VkDynamicCbState* pState)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001897{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001898 VkResult result = nextTable.CreateDynamicColorBlendState(device, pCreateInfo, pState);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001899 insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_COLOR_BLEND);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001900 return result;
1901}
1902
Courtney Goeltzenleuchterfcf855f2015-04-10 16:24:50 -06001903VK_LAYER_EXPORT VkResult VKAPI vkCreateDynamicDepthStencilState(VkDevice device, const VkDynamicDsStateCreateInfo* pCreateInfo, VkDynamicDsState* pState)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001904{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001905 VkResult result = nextTable.CreateDynamicDepthStencilState(device, pCreateInfo, pState);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001906 insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, VK_STATE_BIND_DEPTH_STENCIL);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001907 return result;
1908}
1909
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001910VK_LAYER_EXPORT VkResult VKAPI vkCreateCommandBuffer(VkDevice device, const VkCmdBufferCreateInfo* pCreateInfo, VkCmdBuffer* pCmdBuffer)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001911{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001912 VkResult result = nextTable.CreateCommandBuffer(device, pCreateInfo, pCmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001913 if (VK_SUCCESS == result) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001914 loader_platform_thread_lock_mutex(&globalLock);
1915 GLOBAL_CB_NODE* pCB = new GLOBAL_CB_NODE;
1916 memset(pCB, 0, sizeof(GLOBAL_CB_NODE));
1917 pCB->cmdBuffer = *pCmdBuffer;
1918 pCB->flags = pCreateInfo->flags;
Courtney Goeltzenleuchterf3168062015-03-05 18:09:39 -07001919 pCB->queueNodeIndex = pCreateInfo->queueNodeIndex;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001920 pCB->lastVtxBinding = MAX_BINDING;
1921 cmdBufferMap[*pCmdBuffer] = pCB;
1922 loader_platform_thread_unlock_mutex(&globalLock);
1923 updateCBTracking(*pCmdBuffer);
1924 }
1925 return result;
1926}
1927
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001928VK_LAYER_EXPORT VkResult VKAPI vkBeginCommandBuffer(VkCmdBuffer cmdBuffer, const VkCmdBufferBeginInfo* pBeginInfo)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001929{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001930 VkResult result = nextTable.BeginCommandBuffer(cmdBuffer, pBeginInfo);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001931 if (VK_SUCCESS == result) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001932 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
1933 if (pCB) {
1934 if (CB_NEW != pCB->state)
1935 resetCB(cmdBuffer);
1936 pCB->state = CB_UPDATE_ACTIVE;
Tobin Ehlis2464b882015-04-01 08:40:34 -06001937 if (pBeginInfo->pNext) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001938 VkCmdBufferGraphicsBeginInfo* pCbGfxBI = (VkCmdBufferGraphicsBeginInfo*)pBeginInfo->pNext;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001939 if (VK_STRUCTURE_TYPE_CMD_BUFFER_GRAPHICS_BEGIN_INFO == pCbGfxBI->sType) {
Courtney Goeltzenleuchtere3b0f3a2015-04-03 15:25:24 -06001940 pCB->activeRenderPass = pCbGfxBI->renderPassContinue.renderPass;
Tobin Ehlis2464b882015-04-01 08:40:34 -06001941 }
1942 }
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001943 }
1944 else {
1945 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001946 sprintf(str, "In vkBeginCommandBuffer() and unable to find CmdBuffer Node for CB %p!", (void*)cmdBuffer);
1947 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001948 }
1949 updateCBTracking(cmdBuffer);
1950 }
1951 return result;
1952}
1953
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001954VK_LAYER_EXPORT VkResult VKAPI vkEndCommandBuffer(VkCmdBuffer cmdBuffer)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001955{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001956 VkResult result = nextTable.EndCommandBuffer(cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001957 if (VK_SUCCESS == result) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001958 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
1959 if (pCB) {
1960 pCB->state = CB_UPDATE_COMPLETE;
1961 printCB(cmdBuffer);
1962 }
1963 else {
1964 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001965 sprintf(str, "In vkEndCommandBuffer() and unable to find CmdBuffer Node for CB %p!", (void*)cmdBuffer);
1966 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001967 }
1968 updateCBTracking(cmdBuffer);
1969 //cbDumpDotFile("cb_dump.dot");
1970 }
1971 return result;
1972}
1973
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001974VK_LAYER_EXPORT VkResult VKAPI vkResetCommandBuffer(VkCmdBuffer cmdBuffer)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001975{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001976 VkResult result = nextTable.ResetCommandBuffer(cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001977 if (VK_SUCCESS == result) {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001978 resetCB(cmdBuffer);
1979 updateCBTracking(cmdBuffer);
1980 }
1981 return result;
1982}
1983
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06001984VK_LAYER_EXPORT void VKAPI vkCmdBindPipeline(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001985{
1986 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
1987 if (pCB) {
1988 updateCBTracking(cmdBuffer);
1989 addCmd(pCB, CMD_BINDPIPELINE);
1990 PIPELINE_NODE* pPN = getPipeline(pipeline);
1991 if (pPN) {
1992 pCB->lastBoundPipeline = pipeline;
1993 loader_platform_thread_lock_mutex(&globalLock);
1994 g_lastBoundPipeline = pPN;
1995 loader_platform_thread_unlock_mutex(&globalLock);
Tobin Ehlis2464b882015-04-01 08:40:34 -06001996 validatePipelineState(pCB, pipelineBindPoint, pipeline);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06001997 }
1998 else {
1999 char str[1024];
2000 sprintf(str, "Attempt to bind Pipeline %p that doesn't exist!", (void*)pipeline);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002001 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pipeline, 0, DRAWSTATE_INVALID_PIPELINE, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002002 }
2003 }
2004 else {
2005 char str[1024];
2006 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002007 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002008 }
2009 nextTable.CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline);
2010}
2011
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002012VK_LAYER_EXPORT void VKAPI vkCmdBindDynamicStateObject(VkCmdBuffer cmdBuffer, VkStateBindPoint stateBindPoint, VkDynamicStateObject state)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002013{
2014 setLastBoundDynamicState(cmdBuffer, state, stateBindPoint);
2015 nextTable.CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state);
2016}
2017
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002018VK_LAYER_EXPORT void VKAPI vkCmdBindDescriptorSets(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, VkDescriptorSetLayoutChain layoutChain, uint32_t layoutChainSlot, uint32_t count, const VkDescriptorSet* pDescriptorSets, const uint32_t* pUserData)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002019{
2020 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2021 if (pCB) {
2022 updateCBTracking(cmdBuffer);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06002023 addCmd(pCB, CMD_BINDDESCRIPTORSETS);
2024 for (uint32_t i=0; i<count; i++) {
2025 if (getSetNode(pDescriptorSets[i])) {
2026 if (dsUpdateActive(pDescriptorSets[i])) {
2027 // TODO : This check here needs to be made at QueueSubmit time
2028 /*
2029 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002030 sprintf(str, "You must call vkEndDescriptorPoolUpdate(%p) before this call to vkCmdBindDescriptorSet()!", (void*)descriptorSet);
2031 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_BINDING_DS_NO_END_UPDATE, "DS", str);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06002032 */
2033 }
2034 loader_platform_thread_lock_mutex(&globalLock);
2035 pCB->lastBoundDescriptorSet = pDescriptorSets[i];
2036 g_lastBoundDescriptorSet = pDescriptorSets[i];
2037 loader_platform_thread_unlock_mutex(&globalLock);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002038 char str[1024];
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002039 sprintf(str, "DS %p bound on pipeline %s", (void*)pDescriptorSets[i], string_VkPipelineBindPoint(pipelineBindPoint));
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002040 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06002041 synchAndPrintDSConfig(cmdBuffer);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002042 }
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06002043 else {
2044 char str[1024];
2045 sprintf(str, "Attempt to bind DS %p that doesn't exist!", (void*)pDescriptorSets[i]);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002046 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_INVALID_SET, "DS", str);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06002047 }
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002048 }
2049 }
2050 else {
2051 char str[1024];
2052 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002053 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002054 }
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06002055 nextTable.CmdBindDescriptorSets(cmdBuffer, pipelineBindPoint, layoutChain, layoutChainSlot, count, pDescriptorSets, pUserData);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002056}
2057
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002058VK_LAYER_EXPORT void VKAPI vkCmdBindIndexBuffer(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkGpuSize offset, VkIndexType indexType)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002059{
2060 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2061 if (pCB) {
2062 updateCBTracking(cmdBuffer);
2063 addCmd(pCB, CMD_BINDINDEXBUFFER);
2064 // TODO : Track idxBuffer binding
2065 }
2066 else {
2067 char str[1024];
2068 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002069 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002070 }
2071 nextTable.CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType);
2072}
2073
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002074VK_LAYER_EXPORT void VKAPI vkCmdBindVertexBuffer(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkGpuSize offset, uint32_t binding)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002075{
2076 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2077 if (pCB) {
2078 updateCBTracking(cmdBuffer);
2079 addCmd(pCB, CMD_BINDVERTEXBUFFER);
2080 pCB->lastVtxBinding = binding;
2081 validateVBBinding(cmdBuffer);
2082 }
2083 else {
2084 char str[1024];
2085 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002086 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002087 }
2088 nextTable.CmdBindVertexBuffer(cmdBuffer, buffer, offset, binding);
2089}
2090
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002091VK_LAYER_EXPORT void VKAPI vkCmdDraw(VkCmdBuffer cmdBuffer, uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002092{
2093 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2094 if (pCB) {
2095 updateCBTracking(cmdBuffer);
2096 addCmd(pCB, CMD_DRAW);
2097 pCB->drawCount[DRAW]++;
2098 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002099 sprintf(str, "vkCmdDraw() call #%lu, reporting DS state:", g_drawCount[DRAW]++);
2100 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002101 synchAndPrintDSConfig(cmdBuffer);
2102 }
2103 else {
2104 char str[1024];
2105 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002106 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002107 }
2108 nextTable.CmdDraw(cmdBuffer, firstVertex, vertexCount, firstInstance, instanceCount);
2109}
2110
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002111VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexed(VkCmdBuffer cmdBuffer, uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002112{
2113 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2114 if (pCB) {
2115 updateCBTracking(cmdBuffer);
2116 addCmd(pCB, CMD_DRAWINDEXED);
2117 pCB->drawCount[DRAW_INDEXED]++;
2118 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002119 sprintf(str, "vkCmdDrawIndexed() call #%lu, reporting DS state:", g_drawCount[DRAW_INDEXED]++);
2120 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002121 synchAndPrintDSConfig(cmdBuffer);
2122 }
2123 else {
2124 char str[1024];
2125 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002126 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002127 }
2128 nextTable.CmdDrawIndexed(cmdBuffer, firstIndex, indexCount, vertexOffset, firstInstance, instanceCount);
2129}
2130
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002131VK_LAYER_EXPORT void VKAPI vkCmdDrawIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkGpuSize offset, uint32_t count, uint32_t stride)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002132{
2133 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2134 if (pCB) {
2135 updateCBTracking(cmdBuffer);
2136 addCmd(pCB, CMD_DRAWINDIRECT);
2137 pCB->drawCount[DRAW_INDIRECT]++;
2138 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002139 sprintf(str, "vkCmdDrawIndirect() call #%lu, reporting DS state:", g_drawCount[DRAW_INDIRECT]++);
2140 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002141 synchAndPrintDSConfig(cmdBuffer);
2142 }
2143 else {
2144 char str[1024];
2145 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002146 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002147 }
2148 nextTable.CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride);
2149}
2150
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002151VK_LAYER_EXPORT void VKAPI vkCmdDrawIndexedIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkGpuSize offset, uint32_t count, uint32_t stride)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002152{
2153 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2154 if (pCB) {
2155 updateCBTracking(cmdBuffer);
2156 addCmd(pCB, CMD_DRAWINDEXEDINDIRECT);
2157 pCB->drawCount[DRAW_INDEXED_INDIRECT]++;
2158 char str[1024];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002159 sprintf(str, "vkCmdDrawIndexedIndirect() call #%lu, reporting DS state:", g_drawCount[DRAW_INDEXED_INDIRECT]++);
2160 layerCbMsg(VK_DBG_MSG_UNKNOWN, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002161 synchAndPrintDSConfig(cmdBuffer);
2162 }
2163 else {
2164 char str[1024];
2165 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002166 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002167 }
2168 nextTable.CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride);
2169}
2170
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002171VK_LAYER_EXPORT void VKAPI vkCmdDispatch(VkCmdBuffer cmdBuffer, uint32_t x, uint32_t y, uint32_t z)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002172{
2173 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2174 if (pCB) {
2175 updateCBTracking(cmdBuffer);
2176 addCmd(pCB, CMD_DISPATCH);
2177 }
2178 else {
2179 char str[1024];
2180 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002181 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002182 }
2183 nextTable.CmdDispatch(cmdBuffer, x, y, z);
2184}
2185
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002186VK_LAYER_EXPORT void VKAPI vkCmdDispatchIndirect(VkCmdBuffer cmdBuffer, VkBuffer buffer, VkGpuSize offset)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002187{
2188 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2189 if (pCB) {
2190 updateCBTracking(cmdBuffer);
2191 addCmd(pCB, CMD_DISPATCHINDIRECT);
2192 }
2193 else {
2194 char str[1024];
2195 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002196 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002197 }
2198 nextTable.CmdDispatchIndirect(cmdBuffer, buffer, offset);
2199}
2200
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002201VK_LAYER_EXPORT void VKAPI vkCmdCopyBuffer(VkCmdBuffer cmdBuffer, VkBuffer srcBuffer, VkBuffer destBuffer, uint32_t regionCount, const VkBufferCopy* pRegions)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002202{
2203 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2204 if (pCB) {
2205 updateCBTracking(cmdBuffer);
2206 addCmd(pCB, CMD_COPYBUFFER);
2207 }
2208 else {
2209 char str[1024];
2210 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002211 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002212 }
2213 nextTable.CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions);
2214}
2215
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002216VK_LAYER_EXPORT void VKAPI vkCmdCopyImage(VkCmdBuffer cmdBuffer,
2217 VkImage srcImage,
2218 VkImageLayout srcImageLayout,
2219 VkImage destImage,
2220 VkImageLayout destImageLayout,
2221 uint32_t regionCount, const VkImageCopy* pRegions)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002222{
2223 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2224 if (pCB) {
2225 updateCBTracking(cmdBuffer);
2226 addCmd(pCB, CMD_COPYIMAGE);
2227 }
2228 else {
2229 char str[1024];
2230 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002231 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002232 }
Courtney Goeltzenleuchter45334842015-04-13 16:16:56 -06002233 nextTable.CmdCopyImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002234}
2235
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002236VK_LAYER_EXPORT void VKAPI vkCmdBlitImage(VkCmdBuffer cmdBuffer,
2237 VkImage srcImage, VkImageLayout srcImageLayout,
2238 VkImage destImage, VkImageLayout destImageLayout,
2239 uint32_t regionCount, const VkImageBlit* pRegions)
Courtney Goeltzenleuchter6ff8ebc2015-04-03 14:42:51 -06002240{
2241 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2242 if (pCB) {
2243 updateCBTracking(cmdBuffer);
Tobin Ehlisdd82f6b2015-04-03 12:01:11 -06002244 addCmd(pCB, CMD_BLITIMAGE);
Courtney Goeltzenleuchter6ff8ebc2015-04-03 14:42:51 -06002245 }
2246 else {
2247 char str[1024];
2248 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002249 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Courtney Goeltzenleuchter6ff8ebc2015-04-03 14:42:51 -06002250 }
2251 nextTable.CmdBlitImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions);
2252}
2253
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002254VK_LAYER_EXPORT void VKAPI vkCmdCopyBufferToImage(VkCmdBuffer cmdBuffer,
2255 VkBuffer srcBuffer,
2256 VkImage destImage, VkImageLayout destImageLayout,
2257 uint32_t regionCount, const VkBufferImageCopy* pRegions)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002258{
2259 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2260 if (pCB) {
2261 updateCBTracking(cmdBuffer);
2262 addCmd(pCB, CMD_COPYBUFFERTOIMAGE);
2263 }
2264 else {
2265 char str[1024];
2266 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002267 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002268 }
Courtney Goeltzenleuchter45334842015-04-13 16:16:56 -06002269 nextTable.CmdCopyBufferToImage(cmdBuffer, srcBuffer, destImage, destImageLayout, regionCount, pRegions);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002270}
2271
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002272VK_LAYER_EXPORT void VKAPI vkCmdCopyImageToBuffer(VkCmdBuffer cmdBuffer,
2273 VkImage srcImage, VkImageLayout srcImageLayout,
2274 VkBuffer destBuffer,
2275 uint32_t regionCount, const VkBufferImageCopy* pRegions)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002276{
2277 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2278 if (pCB) {
2279 updateCBTracking(cmdBuffer);
2280 addCmd(pCB, CMD_COPYIMAGETOBUFFER);
2281 }
2282 else {
2283 char str[1024];
2284 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002285 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002286 }
Courtney Goeltzenleuchter45334842015-04-13 16:16:56 -06002287 nextTable.CmdCopyImageToBuffer(cmdBuffer, srcImage, srcImageLayout, destBuffer, regionCount, pRegions);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002288}
2289
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002290VK_LAYER_EXPORT void VKAPI vkCmdCloneImageData(VkCmdBuffer cmdBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage destImage, VkImageLayout destImageLayout)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002291{
2292 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2293 if (pCB) {
2294 updateCBTracking(cmdBuffer);
2295 addCmd(pCB, CMD_CLONEIMAGEDATA);
2296 }
2297 else {
2298 char str[1024];
2299 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002300 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002301 }
2302 nextTable.CmdCloneImageData(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout);
2303}
2304
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002305VK_LAYER_EXPORT void VKAPI vkCmdUpdateBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkGpuSize destOffset, VkGpuSize dataSize, const uint32_t* pData)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002306{
2307 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2308 if (pCB) {
2309 updateCBTracking(cmdBuffer);
2310 addCmd(pCB, CMD_UPDATEBUFFER);
2311 }
2312 else {
2313 char str[1024];
2314 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002315 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002316 }
2317 nextTable.CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData);
2318}
2319
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002320VK_LAYER_EXPORT void VKAPI vkCmdFillBuffer(VkCmdBuffer cmdBuffer, VkBuffer destBuffer, VkGpuSize destOffset, VkGpuSize fillSize, uint32_t data)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002321{
2322 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2323 if (pCB) {
2324 updateCBTracking(cmdBuffer);
2325 addCmd(pCB, CMD_FILLBUFFER);
2326 }
2327 else {
2328 char str[1024];
2329 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002330 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002331 }
2332 nextTable.CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data);
2333}
2334
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002335VK_LAYER_EXPORT void VKAPI vkCmdClearColorImage(VkCmdBuffer cmdBuffer,
2336 VkImage image, VkImageLayout imageLayout,
2337 VkClearColor color,
2338 uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002339{
2340 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2341 if (pCB) {
2342 updateCBTracking(cmdBuffer);
2343 addCmd(pCB, CMD_CLEARCOLORIMAGE);
2344 }
2345 else {
2346 char str[1024];
2347 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002348 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002349 }
Courtney Goeltzenleuchter45334842015-04-13 16:16:56 -06002350 nextTable.CmdClearColorImage(cmdBuffer, image, imageLayout, color, rangeCount, pRanges);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002351}
2352
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002353VK_LAYER_EXPORT void VKAPI vkCmdClearDepthStencil(VkCmdBuffer cmdBuffer,
2354 VkImage image, VkImageLayout imageLayout,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002355 float depth, uint32_t stencil,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002356 uint32_t rangeCount, const VkImageSubresourceRange* pRanges)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002357{
2358 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2359 if (pCB) {
2360 updateCBTracking(cmdBuffer);
2361 addCmd(pCB, CMD_CLEARDEPTHSTENCIL);
2362 }
2363 else {
2364 char str[1024];
2365 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002366 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002367 }
Courtney Goeltzenleuchter45334842015-04-13 16:16:56 -06002368 nextTable.CmdClearDepthStencil(cmdBuffer, image, imageLayout, depth, stencil, rangeCount, pRanges);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002369}
2370
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002371VK_LAYER_EXPORT void VKAPI vkCmdResolveImage(VkCmdBuffer cmdBuffer,
2372 VkImage srcImage, VkImageLayout srcImageLayout,
2373 VkImage destImage, VkImageLayout destImageLayout,
2374 uint32_t rectCount, const VkImageResolve* pRects)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002375{
2376 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2377 if (pCB) {
2378 updateCBTracking(cmdBuffer);
2379 addCmd(pCB, CMD_RESOLVEIMAGE);
2380 }
2381 else {
2382 char str[1024];
2383 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002384 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002385 }
Courtney Goeltzenleuchter45334842015-04-13 16:16:56 -06002386 nextTable.CmdResolveImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, rectCount, pRects);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002387}
2388
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002389VK_LAYER_EXPORT void VKAPI vkCmdSetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002390{
2391 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2392 if (pCB) {
2393 updateCBTracking(cmdBuffer);
2394 addCmd(pCB, CMD_SETEVENT);
2395 }
2396 else {
2397 char str[1024];
2398 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002399 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002400 }
2401 nextTable.CmdSetEvent(cmdBuffer, event, pipeEvent);
2402}
2403
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002404VK_LAYER_EXPORT void VKAPI vkCmdResetEvent(VkCmdBuffer cmdBuffer, VkEvent event, VkPipeEvent pipeEvent)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002405{
2406 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2407 if (pCB) {
2408 updateCBTracking(cmdBuffer);
2409 addCmd(pCB, CMD_RESETEVENT);
2410 }
2411 else {
2412 char str[1024];
2413 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002414 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002415 }
Courtney Goeltzenleuchteraa86e0e2015-03-24 18:02:34 -06002416 nextTable.CmdResetEvent(cmdBuffer, event, pipeEvent);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002417}
2418
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002419VK_LAYER_EXPORT void VKAPI vkCmdWaitEvents(VkCmdBuffer cmdBuffer, const VkEventWaitInfo* pWaitInfo)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002420{
2421 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2422 if (pCB) {
2423 updateCBTracking(cmdBuffer);
2424 addCmd(pCB, CMD_WAITEVENTS);
2425 }
2426 else {
2427 char str[1024];
2428 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002429 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002430 }
2431 nextTable.CmdWaitEvents(cmdBuffer, pWaitInfo);
2432}
2433
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002434VK_LAYER_EXPORT void VKAPI vkCmdPipelineBarrier(VkCmdBuffer cmdBuffer, const VkPipelineBarrier* pBarrier)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002435{
2436 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2437 if (pCB) {
2438 updateCBTracking(cmdBuffer);
2439 addCmd(pCB, CMD_PIPELINEBARRIER);
2440 }
2441 else {
2442 char str[1024];
2443 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002444 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002445 }
2446 nextTable.CmdPipelineBarrier(cmdBuffer, pBarrier);
2447}
2448
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002449VK_LAYER_EXPORT void VKAPI vkCmdBeginQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot, VkFlags flags)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002450{
2451 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2452 if (pCB) {
2453 updateCBTracking(cmdBuffer);
2454 addCmd(pCB, CMD_BEGINQUERY);
2455 }
2456 else {
2457 char str[1024];
2458 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002459 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002460 }
2461 nextTable.CmdBeginQuery(cmdBuffer, queryPool, slot, flags);
2462}
2463
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002464VK_LAYER_EXPORT void VKAPI vkCmdEndQuery(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t slot)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002465{
2466 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2467 if (pCB) {
2468 updateCBTracking(cmdBuffer);
2469 addCmd(pCB, CMD_ENDQUERY);
2470 }
2471 else {
2472 char str[1024];
2473 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002474 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002475 }
2476 nextTable.CmdEndQuery(cmdBuffer, queryPool, slot);
2477}
2478
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002479VK_LAYER_EXPORT void VKAPI vkCmdResetQueryPool(VkCmdBuffer cmdBuffer, VkQueryPool queryPool, uint32_t startQuery, uint32_t queryCount)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002480{
2481 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2482 if (pCB) {
2483 updateCBTracking(cmdBuffer);
2484 addCmd(pCB, CMD_RESETQUERYPOOL);
2485 }
2486 else {
2487 char str[1024];
2488 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002489 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002490 }
2491 nextTable.CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount);
2492}
2493
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002494VK_LAYER_EXPORT void VKAPI vkCmdWriteTimestamp(VkCmdBuffer cmdBuffer, VkTimestampType timestampType, VkBuffer destBuffer, VkGpuSize destOffset)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002495{
2496 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2497 if (pCB) {
2498 updateCBTracking(cmdBuffer);
2499 addCmd(pCB, CMD_WRITETIMESTAMP);
2500 }
2501 else {
2502 char str[1024];
2503 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002504 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002505 }
2506 nextTable.CmdWriteTimestamp(cmdBuffer, timestampType, destBuffer, destOffset);
2507}
2508
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002509VK_LAYER_EXPORT void VKAPI vkCmdInitAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, const uint32_t* pData)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002510{
2511 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2512 if (pCB) {
2513 updateCBTracking(cmdBuffer);
2514 addCmd(pCB, CMD_INITATOMICCOUNTERS);
2515 }
2516 else {
2517 char str[1024];
2518 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002519 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002520 }
2521 nextTable.CmdInitAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData);
2522}
2523
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002524VK_LAYER_EXPORT void VKAPI vkCmdLoadAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, VkBuffer srcBuffer, VkGpuSize srcOffset)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002525{
2526 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2527 if (pCB) {
2528 updateCBTracking(cmdBuffer);
2529 addCmd(pCB, CMD_LOADATOMICCOUNTERS);
2530 }
2531 else {
2532 char str[1024];
2533 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002534 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002535 }
2536 nextTable.CmdLoadAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, srcBuffer, srcOffset);
2537}
2538
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002539VK_LAYER_EXPORT void VKAPI vkCmdSaveAtomicCounters(VkCmdBuffer cmdBuffer, VkPipelineBindPoint pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, VkBuffer destBuffer, VkGpuSize destOffset)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002540{
2541 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2542 if (pCB) {
2543 updateCBTracking(cmdBuffer);
2544 addCmd(pCB, CMD_SAVEATOMICCOUNTERS);
2545 }
2546 else {
2547 char str[1024];
2548 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002549 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002550 }
2551 nextTable.CmdSaveAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, destBuffer, destOffset);
2552}
2553
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002554VK_LAYER_EXPORT VkResult VKAPI vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, VkFramebuffer* pFramebuffer)
Tobin Ehlis2464b882015-04-01 08:40:34 -06002555{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002556 VkResult result = nextTable.CreateFramebuffer(device, pCreateInfo, pFramebuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002557 if (VK_SUCCESS == result) {
Tobin Ehlis2464b882015-04-01 08:40:34 -06002558 // Shadow create info and store in map
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002559 VkFramebufferCreateInfo* localFBCI = new VkFramebufferCreateInfo(*pCreateInfo);
Tobin Ehlis2464b882015-04-01 08:40:34 -06002560 if (pCreateInfo->pColorAttachments) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002561 localFBCI->pColorAttachments = new VkColorAttachmentBindInfo[localFBCI->colorAttachmentCount];
2562 memcpy((void*)localFBCI->pColorAttachments, pCreateInfo->pColorAttachments, localFBCI->colorAttachmentCount*sizeof(VkColorAttachmentBindInfo));
Tobin Ehlis2464b882015-04-01 08:40:34 -06002563 }
2564 if (pCreateInfo->pDepthStencilAttachment) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002565 localFBCI->pDepthStencilAttachment = new VkDepthStencilBindInfo[localFBCI->colorAttachmentCount];
2566 memcpy((void*)localFBCI->pDepthStencilAttachment, pCreateInfo->pDepthStencilAttachment, localFBCI->colorAttachmentCount*sizeof(VkDepthStencilBindInfo));
Tobin Ehlis2464b882015-04-01 08:40:34 -06002567 }
2568 frameBufferMap[*pFramebuffer] = localFBCI;
2569 }
2570 return result;
2571}
2572
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002573VK_LAYER_EXPORT VkResult VKAPI vkCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, VkRenderPass* pRenderPass)
Tobin Ehlis2464b882015-04-01 08:40:34 -06002574{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002575 VkResult result = nextTable.CreateRenderPass(device, pCreateInfo, pRenderPass);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002576 if (VK_SUCCESS == result) {
Tobin Ehlis2464b882015-04-01 08:40:34 -06002577 // Shadow create info and store in map
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002578 VkRenderPassCreateInfo* localRPCI = new VkRenderPassCreateInfo(*pCreateInfo);
Tobin Ehlis2464b882015-04-01 08:40:34 -06002579 if (pCreateInfo->pColorLoadOps) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002580 localRPCI->pColorLoadOps = new VkAttachmentLoadOp[localRPCI->colorAttachmentCount];
2581 memcpy((void*)localRPCI->pColorLoadOps, pCreateInfo->pColorLoadOps, localRPCI->colorAttachmentCount*sizeof(VkAttachmentLoadOp));
Tobin Ehlis2464b882015-04-01 08:40:34 -06002582 }
2583 if (pCreateInfo->pColorStoreOps) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002584 localRPCI->pColorStoreOps = new VkAttachmentStoreOp[localRPCI->colorAttachmentCount];
2585 memcpy((void*)localRPCI->pColorStoreOps, pCreateInfo->pColorStoreOps, localRPCI->colorAttachmentCount*sizeof(VkAttachmentStoreOp));
Tobin Ehlis2464b882015-04-01 08:40:34 -06002586 }
2587 if (pCreateInfo->pColorLoadClearValues) {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002588 localRPCI->pColorLoadClearValues = new VkClearColor[localRPCI->colorAttachmentCount];
2589 memcpy((void*)localRPCI->pColorLoadClearValues, pCreateInfo->pColorLoadClearValues, localRPCI->colorAttachmentCount*sizeof(VkClearColor));
Tobin Ehlis2464b882015-04-01 08:40:34 -06002590 }
2591 renderPassMap[*pRenderPass] = localRPCI;
2592 }
2593 return result;
2594}
2595
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002596VK_LAYER_EXPORT void VKAPI vkCmdBeginRenderPass(VkCmdBuffer cmdBuffer, const VkRenderPassBegin *pRenderPassBegin)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002597{
2598 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2599 if (pCB) {
2600 updateCBTracking(cmdBuffer);
2601 addCmd(pCB, CMD_BEGINRENDERPASS);
Courtney Goeltzenleuchtere3b0f3a2015-04-03 15:25:24 -06002602 pCB->activeRenderPass = pRenderPassBegin->renderPass;
2603 pCB->framebuffer = pRenderPassBegin->framebuffer;
Tony Barbourb9f82ba2015-04-06 11:09:26 -06002604 if (pCB->lastBoundPipeline) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002605 validatePipelineState(pCB, VK_PIPELINE_BIND_POINT_GRAPHICS, pCB->lastBoundPipeline);
Tony Barbourb9f82ba2015-04-06 11:09:26 -06002606 }
Courtney Goeltzenleuchtere3b0f3a2015-04-03 15:25:24 -06002607 } else {
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002608 char str[1024];
2609 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002610 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002611 }
Courtney Goeltzenleuchtere3b0f3a2015-04-03 15:25:24 -06002612 nextTable.CmdBeginRenderPass(cmdBuffer, pRenderPassBegin);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002613}
2614
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002615VK_LAYER_EXPORT void VKAPI vkCmdEndRenderPass(VkCmdBuffer cmdBuffer, VkRenderPass renderPass)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002616{
2617 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2618 if (pCB) {
2619 updateCBTracking(cmdBuffer);
2620 addCmd(pCB, CMD_ENDRENDERPASS);
Tobin Ehlis2464b882015-04-01 08:40:34 -06002621 pCB->activeRenderPass = 0;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002622 }
2623 else {
2624 char str[1024];
2625 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002626 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002627 }
2628 nextTable.CmdEndRenderPass(cmdBuffer, renderPass);
2629}
2630
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002631VK_LAYER_EXPORT VkResult VKAPI vkDbgRegisterMsgCallback(VkInstance instance, VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, void* pUserData)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002632{
2633 // This layer intercepts callbacks
Tobin Ehliseaf28662015-04-08 10:58:37 -06002634 VK_LAYER_DBG_FUNCTION_NODE* pNewDbgFuncNode = new VK_LAYER_DBG_FUNCTION_NODE;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002635 if (!pNewDbgFuncNode)
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002636 return VK_ERROR_OUT_OF_MEMORY;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002637 pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback;
2638 pNewDbgFuncNode->pUserData = pUserData;
2639 pNewDbgFuncNode->pNext = g_pDbgFunctionHead;
2640 g_pDbgFunctionHead = pNewDbgFuncNode;
2641 // force callbacks if DebugAction hasn't been set already other than initial value
2642 if (g_actionIsDefault) {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002643 g_debugAction = VK_DBG_LAYER_ACTION_CALLBACK;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002644 }
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002645 VkResult result = nextTable.DbgRegisterMsgCallback(instance, pfnMsgCallback, pUserData);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002646 return result;
2647}
2648
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002649VK_LAYER_EXPORT VkResult VKAPI vkDbgUnregisterMsgCallback(VkInstance instance, VK_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002650{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002651 VK_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead;
2652 VK_LAYER_DBG_FUNCTION_NODE *pPrev = pTrav;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002653 while (pTrav) {
2654 if (pTrav->pfnMsgCallback == pfnMsgCallback) {
2655 pPrev->pNext = pTrav->pNext;
2656 if (g_pDbgFunctionHead == pTrav)
2657 g_pDbgFunctionHead = pTrav->pNext;
Tobin Ehliseaf28662015-04-08 10:58:37 -06002658 delete pTrav;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002659 break;
2660 }
2661 pPrev = pTrav;
2662 pTrav = pTrav->pNext;
2663 }
2664 if (g_pDbgFunctionHead == NULL)
2665 {
2666 if (g_actionIsDefault)
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002667 g_debugAction = VK_DBG_LAYER_ACTION_LOG_MSG;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002668 else
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002669 g_debugAction = (VK_LAYER_DBG_ACTION)(g_debugAction & ~((uint32_t)VK_DBG_LAYER_ACTION_CALLBACK));
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002670 }
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002671 VkResult result = nextTable.DbgUnregisterMsgCallback(instance, pfnMsgCallback);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002672 return result;
2673}
2674
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002675VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerBegin(VkCmdBuffer cmdBuffer, const char* pMarker)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002676{
2677 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2678 if (pCB) {
2679 updateCBTracking(cmdBuffer);
2680 addCmd(pCB, CMD_DBGMARKERBEGIN);
2681 }
2682 else {
2683 char str[1024];
2684 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002685 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002686 }
2687 nextTable.CmdDbgMarkerBegin(cmdBuffer, pMarker);
2688}
2689
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002690VK_LAYER_EXPORT void VKAPI vkCmdDbgMarkerEnd(VkCmdBuffer cmdBuffer)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002691{
2692 GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer);
2693 if (pCB) {
2694 updateCBTracking(cmdBuffer);
2695 addCmd(pCB, CMD_DBGMARKEREND);
2696 }
2697 else {
2698 char str[1024];
2699 sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002700 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002701 }
2702 nextTable.CmdDbgMarkerEnd(cmdBuffer);
2703}
2704
2705// TODO : Want to pass in a cmdBuffer here based on which state to display
2706void drawStateDumpDotFile(char* outFileName)
2707{
2708 // TODO : Currently just setting cmdBuffer based on global var
2709 //dumpDotFile(g_lastDrawStateCmdBuffer, outFileName);
2710 dumpGlobalDotFile(outFileName);
2711}
2712
2713void drawStateDumpCommandBufferDotFile(char* outFileName)
2714{
2715 cbDumpDotFile(outFileName);
2716}
2717
2718void drawStateDumpPngFile(char* outFileName)
2719{
2720#if defined(_WIN32)
2721// FIXME: NEED WINDOWS EQUIVALENT
2722 char str[1024];
2723 sprintf(str, "Cannot execute dot program yet on Windows.");
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002724 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_MISSING_DOT_PROGRAM, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002725#else // WIN32
2726 char dotExe[32] = "/usr/bin/dot";
2727 if( access(dotExe, X_OK) != -1) {
2728 dumpDotFile(g_lastCmdBuffer[getTIDIndex()], "/tmp/tmp.dot");
2729 char dotCmd[1024];
2730 sprintf(dotCmd, "%s /tmp/tmp.dot -Tpng -o %s", dotExe, outFileName);
2731 system(dotCmd);
2732 remove("/tmp/tmp.dot");
2733 }
2734 else {
2735 char str[1024];
2736 sprintf(str, "Cannot execute dot program at (%s) to dump requested %s file.", dotExe, outFileName);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002737 layerCbMsg(VK_DBG_MSG_ERROR, VK_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_MISSING_DOT_PROGRAM, "DS", str);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002738 }
2739#endif // WIN32
2740}
2741
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002742VK_LAYER_EXPORT void* VKAPI vkGetProcAddr(VkPhysicalGpu gpu, const char* funcName)
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002743{
Jon Ashburn301c5f02015-04-06 10:58:22 -06002744 VkBaseLayerObject* gpuw = (VkBaseLayerObject *) gpu;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002745
2746 if (gpu == NULL)
2747 return NULL;
2748 pCurObj = gpuw;
2749 loader_platform_thread_once(&g_initOnce, initDrawState);
2750
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002751 if (!strcmp(funcName, "vkGetProcAddr"))
2752 return (void *) vkGetProcAddr;
2753 if (!strcmp(funcName, "vkCreateDevice"))
2754 return (void*) vkCreateDevice;
2755 if (!strcmp(funcName, "vkDestroyDevice"))
2756 return (void*) vkDestroyDevice;
2757 if (!strcmp(funcName, "vkGetExtensionSupport"))
2758 return (void*) vkGetExtensionSupport;
2759 if (!strcmp(funcName, "vkEnumerateLayers"))
2760 return (void*) vkEnumerateLayers;
2761 if (!strcmp(funcName, "vkQueueSubmit"))
2762 return (void*) vkQueueSubmit;
2763 if (!strcmp(funcName, "vkDestroyObject"))
2764 return (void*) vkDestroyObject;
2765 if (!strcmp(funcName, "vkCreateBufferView"))
2766 return (void*) vkCreateBufferView;
2767 if (!strcmp(funcName, "vkCreateImageView"))
2768 return (void*) vkCreateImageView;
2769 if (!strcmp(funcName, "vkCreateGraphicsPipeline"))
2770 return (void*) vkCreateGraphicsPipeline;
2771 if (!strcmp(funcName, "vkCreateGraphicsPipelineDerivative"))
2772 return (void*) vkCreateGraphicsPipelineDerivative;
2773 if (!strcmp(funcName, "vkCreateSampler"))
2774 return (void*) vkCreateSampler;
2775 if (!strcmp(funcName, "vkCreateDescriptorSetLayout"))
2776 return (void*) vkCreateDescriptorSetLayout;
2777 if (!strcmp(funcName, "vkCreateDescriptorSetLayoutChain"))
2778 return (void*) vkCreateDescriptorSetLayoutChain;
2779 if (!strcmp(funcName, "vkBeginDescriptorPoolUpdate"))
2780 return (void*) vkBeginDescriptorPoolUpdate;
2781 if (!strcmp(funcName, "vkEndDescriptorPoolUpdate"))
2782 return (void*) vkEndDescriptorPoolUpdate;
2783 if (!strcmp(funcName, "vkCreateDescriptorPool"))
2784 return (void*) vkCreateDescriptorPool;
2785 if (!strcmp(funcName, "vkResetDescriptorPool"))
2786 return (void*) vkResetDescriptorPool;
2787 if (!strcmp(funcName, "vkAllocDescriptorSets"))
2788 return (void*) vkAllocDescriptorSets;
2789 if (!strcmp(funcName, "vkClearDescriptorSets"))
2790 return (void*) vkClearDescriptorSets;
2791 if (!strcmp(funcName, "vkUpdateDescriptors"))
2792 return (void*) vkUpdateDescriptors;
2793 if (!strcmp(funcName, "vkCreateDynamicViewportState"))
2794 return (void*) vkCreateDynamicViewportState;
2795 if (!strcmp(funcName, "vkCreateDynamicRasterState"))
2796 return (void*) vkCreateDynamicRasterState;
2797 if (!strcmp(funcName, "vkCreateDynamicColorBlendState"))
2798 return (void*) vkCreateDynamicColorBlendState;
2799 if (!strcmp(funcName, "vkCreateDynamicDepthStencilState"))
2800 return (void*) vkCreateDynamicDepthStencilState;
2801 if (!strcmp(funcName, "vkCreateCommandBuffer"))
2802 return (void*) vkCreateCommandBuffer;
2803 if (!strcmp(funcName, "vkBeginCommandBuffer"))
2804 return (void*) vkBeginCommandBuffer;
2805 if (!strcmp(funcName, "vkEndCommandBuffer"))
2806 return (void*) vkEndCommandBuffer;
2807 if (!strcmp(funcName, "vkResetCommandBuffer"))
2808 return (void*) vkResetCommandBuffer;
2809 if (!strcmp(funcName, "vkCmdBindPipeline"))
2810 return (void*) vkCmdBindPipeline;
2811 if (!strcmp(funcName, "vkCmdBindDynamicStateObject"))
2812 return (void*) vkCmdBindDynamicStateObject;
2813 if (!strcmp(funcName, "vkCmdBindDescriptorSets"))
2814 return (void*) vkCmdBindDescriptorSets;
2815 if (!strcmp(funcName, "vkCmdBindVertexBuffer"))
2816 return (void*) vkCmdBindVertexBuffer;
2817 if (!strcmp(funcName, "vkCmdBindIndexBuffer"))
2818 return (void*) vkCmdBindIndexBuffer;
2819 if (!strcmp(funcName, "vkCmdDraw"))
2820 return (void*) vkCmdDraw;
2821 if (!strcmp(funcName, "vkCmdDrawIndexed"))
2822 return (void*) vkCmdDrawIndexed;
2823 if (!strcmp(funcName, "vkCmdDrawIndirect"))
2824 return (void*) vkCmdDrawIndirect;
2825 if (!strcmp(funcName, "vkCmdDrawIndexedIndirect"))
2826 return (void*) vkCmdDrawIndexedIndirect;
2827 if (!strcmp(funcName, "vkCmdDispatch"))
2828 return (void*) vkCmdDispatch;
2829 if (!strcmp(funcName, "vkCmdDispatchIndirect"))
2830 return (void*) vkCmdDispatchIndirect;
2831 if (!strcmp(funcName, "vkCmdCopyBuffer"))
2832 return (void*) vkCmdCopyBuffer;
2833 if (!strcmp(funcName, "vkCmdCopyImage"))
2834 return (void*) vkCmdCopyImage;
2835 if (!strcmp(funcName, "vkCmdCopyBufferToImage"))
2836 return (void*) vkCmdCopyBufferToImage;
2837 if (!strcmp(funcName, "vkCmdCopyImageToBuffer"))
2838 return (void*) vkCmdCopyImageToBuffer;
2839 if (!strcmp(funcName, "vkCmdCloneImageData"))
2840 return (void*) vkCmdCloneImageData;
2841 if (!strcmp(funcName, "vkCmdUpdateBuffer"))
2842 return (void*) vkCmdUpdateBuffer;
2843 if (!strcmp(funcName, "vkCmdFillBuffer"))
2844 return (void*) vkCmdFillBuffer;
2845 if (!strcmp(funcName, "vkCmdClearColorImage"))
2846 return (void*) vkCmdClearColorImage;
2847 if (!strcmp(funcName, "vkCmdClearDepthStencil"))
2848 return (void*) vkCmdClearDepthStencil;
2849 if (!strcmp(funcName, "vkCmdResolveImage"))
2850 return (void*) vkCmdResolveImage;
2851 if (!strcmp(funcName, "vkCmdSetEvent"))
2852 return (void*) vkCmdSetEvent;
2853 if (!strcmp(funcName, "vkCmdResetEvent"))
2854 return (void*) vkCmdResetEvent;
2855 if (!strcmp(funcName, "vkCmdWaitEvents"))
2856 return (void*) vkCmdWaitEvents;
2857 if (!strcmp(funcName, "vkCmdPipelineBarrier"))
2858 return (void*) vkCmdPipelineBarrier;
2859 if (!strcmp(funcName, "vkCmdBeginQuery"))
2860 return (void*) vkCmdBeginQuery;
2861 if (!strcmp(funcName, "vkCmdEndQuery"))
2862 return (void*) vkCmdEndQuery;
2863 if (!strcmp(funcName, "vkCmdResetQueryPool"))
2864 return (void*) vkCmdResetQueryPool;
2865 if (!strcmp(funcName, "vkCmdWriteTimestamp"))
2866 return (void*) vkCmdWriteTimestamp;
2867 if (!strcmp(funcName, "vkCmdInitAtomicCounters"))
2868 return (void*) vkCmdInitAtomicCounters;
2869 if (!strcmp(funcName, "vkCmdLoadAtomicCounters"))
2870 return (void*) vkCmdLoadAtomicCounters;
2871 if (!strcmp(funcName, "vkCmdSaveAtomicCounters"))
2872 return (void*) vkCmdSaveAtomicCounters;
2873 if (!strcmp(funcName, "vkCreateFramebuffer"))
2874 return (void*) vkCreateFramebuffer;
2875 if (!strcmp(funcName, "vkCreateRenderPass"))
2876 return (void*) vkCreateRenderPass;
2877 if (!strcmp(funcName, "vkCmdBeginRenderPass"))
2878 return (void*) vkCmdBeginRenderPass;
2879 if (!strcmp(funcName, "vkCmdEndRenderPass"))
2880 return (void*) vkCmdEndRenderPass;
2881 if (!strcmp(funcName, "vkDbgRegisterMsgCallback"))
2882 return (void*) vkDbgRegisterMsgCallback;
2883 if (!strcmp(funcName, "vkDbgUnregisterMsgCallback"))
2884 return (void*) vkDbgUnregisterMsgCallback;
2885 if (!strcmp(funcName, "vkCmdDbgMarkerBegin"))
2886 return (void*) vkCmdDbgMarkerBegin;
2887 if (!strcmp(funcName, "vkCmdDbgMarkerEnd"))
2888 return (void*) vkCmdDbgMarkerEnd;
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002889 if (!strcmp("drawStateDumpDotFile", funcName))
2890 return (void*) drawStateDumpDotFile;
2891 if (!strcmp("drawStateDumpCommandBufferDotFile", funcName))
2892 return (void*) drawStateDumpCommandBufferDotFile;
2893 if (!strcmp("drawStateDumpPngFile", funcName))
2894 return (void*) drawStateDumpPngFile;
2895 else {
2896 if (gpuw->pGPA == NULL)
2897 return NULL;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -06002898 return gpuw->pGPA((VkPhysicalGpu)gpuw->nextObject, funcName);
Tobin Ehlis63bb9482015-03-17 16:24:32 -06002899 }
2900}