Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1 | /* |
| 2 | * XGL |
| 3 | * |
| 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" |
| 31 | #include "xgl_dispatch_table_helper.h" |
| 32 | #include "xgl_struct_string_helper_cpp.h" |
| 33 | #pragma GCC diagnostic ignored "-Wwrite-strings" |
| 34 | #include "xgl_struct_graphviz_helper.h" |
| 35 | #pragma GCC diagnostic warning "-Wwrite-strings" |
| 36 | #include "xgl_struct_size_helper.h" |
| 37 | #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 | |
| 44 | unordered_map<XGL_SAMPLER, SAMPLER_NODE*> sampleMap; |
| 45 | unordered_map<XGL_IMAGE_VIEW, IMAGE_NODE*> imageMap; |
| 46 | unordered_map<XGL_BUFFER_VIEW, BUFFER_NODE*> bufferMap; |
| 47 | unordered_map<XGL_DYNAMIC_STATE_OBJECT, DYNAMIC_STATE_NODE*> dynamicStateMap; |
| 48 | unordered_map<XGL_PIPELINE, PIPELINE_NODE*> pipelineMap; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 49 | unordered_map<XGL_DESCRIPTOR_POOL, POOL_NODE*> poolMap; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 50 | unordered_map<XGL_DESCRIPTOR_SET, SET_NODE*> setMap; |
| 51 | unordered_map<XGL_DESCRIPTOR_SET_LAYOUT, LAYOUT_NODE*> layoutMap; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 52 | // Map for layout chains |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 53 | unordered_map<XGL_CMD_BUFFER, GLOBAL_CB_NODE*> cmdBufferMap; |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 54 | unordered_map<XGL_RENDER_PASS, XGL_RENDER_PASS_CREATE_INFO*> renderPassMap; |
| 55 | unordered_map<XGL_FRAMEBUFFER, XGL_FRAMEBUFFER_CREATE_INFO*> frameBufferMap; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 56 | |
| 57 | static XGL_LAYER_DISPATCH_TABLE nextTable; |
| 58 | static XGL_BASE_LAYER_OBJECT *pCurObj; |
| 59 | static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce); |
| 60 | // TODO : This can be much smarter, using separate locks for separate global data |
| 61 | static int globalLockInitialized = 0; |
| 62 | static loader_platform_thread_mutex globalLock; |
| 63 | #define ALLOC_DEBUG 0 |
| 64 | #if ALLOC_DEBUG |
| 65 | static uint64_t g_alloc_count = 0; |
| 66 | static uint64_t g_free_count = 0; |
| 67 | #endif |
| 68 | #define MAX_TID 513 |
| 69 | static loader_platform_thread_id g_tidMapping[MAX_TID] = {0}; |
| 70 | static uint32_t g_maxTID = 0; |
| 71 | // Map actual TID to an index value and return that index |
| 72 | // This keeps TIDs in range from 0-MAX_TID and simplifies compares between runs |
| 73 | static uint32_t getTIDIndex() { |
| 74 | loader_platform_thread_id tid = loader_platform_get_thread_id(); |
| 75 | for (uint32_t i = 0; i < g_maxTID; i++) { |
| 76 | if (tid == g_tidMapping[i]) |
| 77 | return i; |
| 78 | } |
| 79 | // Don't yet have mapping, set it and return newly set index |
| 80 | uint32_t retVal = (uint32_t) g_maxTID; |
| 81 | g_tidMapping[g_maxTID++] = tid; |
| 82 | assert(g_maxTID < MAX_TID); |
| 83 | return retVal; |
| 84 | } |
| 85 | // Return a string representation of CMD_TYPE enum |
| 86 | static string cmdTypeToString(CMD_TYPE cmd) |
| 87 | { |
| 88 | switch (cmd) |
| 89 | { |
| 90 | case CMD_BINDPIPELINE: |
| 91 | return "CMD_BINDPIPELINE"; |
| 92 | case CMD_BINDPIPELINEDELTA: |
| 93 | return "CMD_BINDPIPELINEDELTA"; |
| 94 | case CMD_BINDDYNAMICSTATEOBJECT: |
| 95 | return "CMD_BINDDYNAMICSTATEOBJECT"; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 96 | case CMD_BINDDESCRIPTORSETS: |
| 97 | return "CMD_BINDDESCRIPTORSETS"; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 98 | case CMD_BINDINDEXBUFFER: |
| 99 | return "CMD_BINDINDEXBUFFER"; |
| 100 | case CMD_BINDVERTEXBUFFER: |
| 101 | return "CMD_BINDVERTEXBUFFER"; |
| 102 | case CMD_DRAW: |
| 103 | return "CMD_DRAW"; |
| 104 | case CMD_DRAWINDEXED: |
| 105 | return "CMD_DRAWINDEXED"; |
| 106 | case CMD_DRAWINDIRECT: |
| 107 | return "CMD_DRAWINDIRECT"; |
| 108 | case CMD_DRAWINDEXEDINDIRECT: |
| 109 | return "CMD_DRAWINDEXEDINDIRECT"; |
| 110 | case CMD_DISPATCH: |
| 111 | return "CMD_DISPATCH"; |
| 112 | case CMD_DISPATCHINDIRECT: |
| 113 | return "CMD_DISPATCHINDIRECT"; |
| 114 | case CMD_COPYBUFFER: |
| 115 | return "CMD_COPYBUFFER"; |
| 116 | case CMD_COPYIMAGE: |
| 117 | return "CMD_COPYIMAGE"; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 118 | case CMD_BLITIMAGE: |
| 119 | return "CMD_BLITIMAGE"; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 120 | case CMD_COPYBUFFERTOIMAGE: |
| 121 | return "CMD_COPYBUFFERTOIMAGE"; |
| 122 | case CMD_COPYIMAGETOBUFFER: |
| 123 | return "CMD_COPYIMAGETOBUFFER"; |
| 124 | case CMD_CLONEIMAGEDATA: |
| 125 | return "CMD_CLONEIMAGEDATA"; |
| 126 | case CMD_UPDATEBUFFER: |
| 127 | return "CMD_UPDATEBUFFER"; |
| 128 | case CMD_FILLBUFFER: |
| 129 | return "CMD_FILLBUFFER"; |
| 130 | case CMD_CLEARCOLORIMAGE: |
| 131 | return "CMD_CLEARCOLORIMAGE"; |
| 132 | case CMD_CLEARCOLORIMAGERAW: |
| 133 | return "CMD_CLEARCOLORIMAGERAW"; |
| 134 | case CMD_CLEARDEPTHSTENCIL: |
| 135 | return "CMD_CLEARDEPTHSTENCIL"; |
| 136 | case CMD_RESOLVEIMAGE: |
| 137 | return "CMD_RESOLVEIMAGE"; |
| 138 | case CMD_SETEVENT: |
| 139 | return "CMD_SETEVENT"; |
| 140 | case CMD_RESETEVENT: |
| 141 | return "CMD_RESETEVENT"; |
| 142 | case CMD_WAITEVENTS: |
| 143 | return "CMD_WAITEVENTS"; |
| 144 | case CMD_PIPELINEBARRIER: |
| 145 | return "CMD_PIPELINEBARRIER"; |
| 146 | case CMD_BEGINQUERY: |
| 147 | return "CMD_BEGINQUERY"; |
| 148 | case CMD_ENDQUERY: |
| 149 | return "CMD_ENDQUERY"; |
| 150 | case CMD_RESETQUERYPOOL: |
| 151 | return "CMD_RESETQUERYPOOL"; |
| 152 | case CMD_WRITETIMESTAMP: |
| 153 | return "CMD_WRITETIMESTAMP"; |
| 154 | case CMD_INITATOMICCOUNTERS: |
| 155 | return "CMD_INITATOMICCOUNTERS"; |
| 156 | case CMD_LOADATOMICCOUNTERS: |
| 157 | return "CMD_LOADATOMICCOUNTERS"; |
| 158 | case CMD_SAVEATOMICCOUNTERS: |
| 159 | return "CMD_SAVEATOMICCOUNTERS"; |
| 160 | case CMD_BEGINRENDERPASS: |
| 161 | return "CMD_BEGINRENDERPASS"; |
| 162 | case CMD_ENDRENDERPASS: |
| 163 | return "CMD_ENDRENDERPASS"; |
| 164 | case CMD_DBGMARKERBEGIN: |
| 165 | return "CMD_DBGMARKERBEGIN"; |
| 166 | case CMD_DBGMARKEREND: |
| 167 | return "CMD_DBGMARKEREND"; |
| 168 | default: |
| 169 | return "UNKNOWN"; |
| 170 | } |
| 171 | } |
| 172 | // Block of code at start here for managing/tracking Pipeline state that this layer cares about |
| 173 | // Just track 2 shaders for now |
| 174 | #define XGL_NUM_GRAPHICS_SHADERS XGL_SHADER_STAGE_COMPUTE |
| 175 | #define MAX_SLOTS 2048 |
| 176 | #define NUM_COMMAND_BUFFERS_TO_DISPLAY 10 |
| 177 | |
| 178 | static uint64_t g_drawCount[NUM_DRAW_TYPES] = {0, 0, 0, 0}; |
| 179 | |
| 180 | // TODO : Should be tracking lastBound per cmdBuffer and when draws occur, report based on that cmd buffer lastBound |
| 181 | // Then need to synchronize the accesses based on cmd buffer so that if I'm reading state on one cmd buffer, updates |
| 182 | // to that same cmd buffer by separate thread are not changing state from underneath us |
| 183 | // Track the last cmd buffer touched by this thread |
| 184 | static XGL_CMD_BUFFER g_lastCmdBuffer[MAX_TID] = {NULL}; |
| 185 | // Track the last group of CBs touched for displaying to dot file |
| 186 | static GLOBAL_CB_NODE* g_pLastTouchedCB[NUM_COMMAND_BUFFERS_TO_DISPLAY] = {NULL}; |
| 187 | static uint32_t g_lastTouchedCBIndex = 0; |
| 188 | // Track the last global DrawState of interest touched by any thread |
| 189 | static GLOBAL_CB_NODE* g_lastGlobalCB = NULL; |
| 190 | static PIPELINE_NODE* g_lastBoundPipeline = NULL; |
| 191 | static DYNAMIC_STATE_NODE* g_lastBoundDynamicState[XGL_NUM_STATE_BIND_POINT] = {NULL}; |
| 192 | static XGL_DESCRIPTOR_SET g_lastBoundDescriptorSet = NULL; |
| 193 | #define MAX_BINDING 0xFFFFFFFF // Default vtxBinding value in CB Node to identify if no vtxBinding set |
| 194 | |
| 195 | //static DYNAMIC_STATE_NODE* g_pDynamicStateHead[XGL_NUM_STATE_BIND_POINT] = {0}; |
| 196 | |
| 197 | static void insertDynamicState(const XGL_DYNAMIC_STATE_OBJECT state, const GENERIC_HEADER* pCreateInfo, XGL_STATE_BIND_POINT bindPoint) |
| 198 | { |
| 199 | XGL_DYNAMIC_VP_STATE_CREATE_INFO* pVPCI = NULL; |
| 200 | size_t scSize = 0; |
| 201 | size_t vpSize = 0; |
| 202 | loader_platform_thread_lock_mutex(&globalLock); |
| 203 | DYNAMIC_STATE_NODE* pStateNode = new DYNAMIC_STATE_NODE; |
| 204 | pStateNode->stateObj = state; |
| 205 | switch (pCreateInfo->sType) { |
| 206 | case XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO: |
| 207 | memcpy(&pStateNode->create_info, pCreateInfo, sizeof(XGL_DYNAMIC_VP_STATE_CREATE_INFO)); |
| 208 | pVPCI = (XGL_DYNAMIC_VP_STATE_CREATE_INFO*)pCreateInfo; |
| 209 | pStateNode->create_info.vpci.pScissors = new XGL_RECT[pStateNode->create_info.vpci.viewportAndScissorCount]; |
| 210 | pStateNode->create_info.vpci.pViewports = new XGL_VIEWPORT[pStateNode->create_info.vpci.viewportAndScissorCount]; |
| 211 | scSize = pVPCI->viewportAndScissorCount * sizeof(XGL_RECT); |
| 212 | vpSize = pVPCI->viewportAndScissorCount * sizeof(XGL_VIEWPORT); |
| 213 | memcpy((void*)pStateNode->create_info.vpci.pScissors, pVPCI->pScissors, scSize); |
| 214 | memcpy((void*)pStateNode->create_info.vpci.pViewports, pVPCI->pViewports, vpSize); |
| 215 | break; |
| 216 | case XGL_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO: |
| 217 | memcpy(&pStateNode->create_info, pCreateInfo, sizeof(XGL_DYNAMIC_RS_STATE_CREATE_INFO)); |
| 218 | break; |
| 219 | case XGL_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO: |
| 220 | memcpy(&pStateNode->create_info, pCreateInfo, sizeof(XGL_DYNAMIC_CB_STATE_CREATE_INFO)); |
| 221 | break; |
| 222 | case XGL_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO: |
| 223 | memcpy(&pStateNode->create_info, pCreateInfo, sizeof(XGL_DYNAMIC_DS_STATE_CREATE_INFO)); |
| 224 | break; |
| 225 | default: |
| 226 | assert(0); |
| 227 | break; |
| 228 | } |
| 229 | pStateNode->pCreateInfo = (GENERIC_HEADER*)&pStateNode->create_info.cbci; |
| 230 | dynamicStateMap[state] = pStateNode; |
| 231 | loader_platform_thread_unlock_mutex(&globalLock); |
| 232 | } |
| 233 | // Free all allocated nodes for Dynamic State objs |
| 234 | static void freeDynamicState() |
| 235 | { |
| 236 | for (unordered_map<XGL_DYNAMIC_STATE_OBJECT, DYNAMIC_STATE_NODE*>::iterator ii=dynamicStateMap.begin(); ii!=dynamicStateMap.end(); ++ii) { |
| 237 | if (XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO == (*ii).second->create_info.vpci.sType) { |
| 238 | delete[] (*ii).second->create_info.vpci.pScissors; |
| 239 | delete[] (*ii).second->create_info.vpci.pViewports; |
| 240 | } |
| 241 | delete (*ii).second; |
| 242 | } |
| 243 | } |
| 244 | // Free all sampler nodes |
| 245 | static void freeSamplers() |
| 246 | { |
| 247 | for (unordered_map<XGL_SAMPLER, SAMPLER_NODE*>::iterator ii=sampleMap.begin(); ii!=sampleMap.end(); ++ii) { |
| 248 | delete (*ii).second; |
| 249 | } |
| 250 | } |
| 251 | static XGL_IMAGE_VIEW_CREATE_INFO* getImageViewCreateInfo(XGL_IMAGE_VIEW view) |
| 252 | { |
| 253 | loader_platform_thread_lock_mutex(&globalLock); |
| 254 | if (imageMap.find(view) == imageMap.end()) { |
| 255 | loader_platform_thread_unlock_mutex(&globalLock); |
| 256 | return NULL; |
| 257 | } |
| 258 | else { |
| 259 | loader_platform_thread_unlock_mutex(&globalLock); |
| 260 | return &imageMap[view]->createInfo; |
| 261 | } |
| 262 | } |
| 263 | // Free all image nodes |
| 264 | static void freeImages() |
| 265 | { |
| 266 | for (unordered_map<XGL_IMAGE_VIEW, IMAGE_NODE*>::iterator ii=imageMap.begin(); ii!=imageMap.end(); ++ii) { |
| 267 | delete (*ii).second; |
| 268 | } |
| 269 | } |
| 270 | static XGL_BUFFER_VIEW_CREATE_INFO* getBufferViewCreateInfo(XGL_BUFFER_VIEW view) |
| 271 | { |
| 272 | loader_platform_thread_lock_mutex(&globalLock); |
| 273 | if (bufferMap.find(view) == bufferMap.end()) { |
| 274 | loader_platform_thread_unlock_mutex(&globalLock); |
| 275 | return NULL; |
| 276 | } |
| 277 | else { |
| 278 | loader_platform_thread_unlock_mutex(&globalLock); |
| 279 | return &bufferMap[view]->createInfo; |
| 280 | } |
| 281 | } |
| 282 | // Free all buffer nodes |
| 283 | static void freeBuffers() |
| 284 | { |
| 285 | for (unordered_map<XGL_BUFFER_VIEW, BUFFER_NODE*>::iterator ii=bufferMap.begin(); ii!=bufferMap.end(); ++ii) { |
| 286 | delete (*ii).second; |
| 287 | } |
| 288 | } |
| 289 | static GLOBAL_CB_NODE* getCBNode(XGL_CMD_BUFFER cb); |
| 290 | |
| 291 | static void updateCBTracking(XGL_CMD_BUFFER cb) |
| 292 | { |
| 293 | g_lastCmdBuffer[getTIDIndex()] = cb; |
| 294 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 295 | loader_platform_thread_lock_mutex(&globalLock); |
| 296 | g_lastGlobalCB = pCB; |
| 297 | // TODO : This is a dumb algorithm. Need smart LRU that drops off oldest |
| 298 | for (uint32_t i = 0; i < NUM_COMMAND_BUFFERS_TO_DISPLAY; i++) { |
| 299 | if (g_pLastTouchedCB[i] == pCB) { |
| 300 | loader_platform_thread_unlock_mutex(&globalLock); |
| 301 | return; |
| 302 | } |
| 303 | } |
| 304 | g_pLastTouchedCB[g_lastTouchedCBIndex++] = pCB; |
| 305 | g_lastTouchedCBIndex = g_lastTouchedCBIndex % NUM_COMMAND_BUFFERS_TO_DISPLAY; |
| 306 | loader_platform_thread_unlock_mutex(&globalLock); |
| 307 | } |
| 308 | |
| 309 | // Print the last bound dynamic state |
| 310 | static void printDynamicState(const XGL_CMD_BUFFER cb) |
| 311 | { |
| 312 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 313 | if (pCB) { |
| 314 | loader_platform_thread_lock_mutex(&globalLock); |
| 315 | char str[4*1024]; |
| 316 | for (uint32_t i = 0; i < XGL_NUM_STATE_BIND_POINT; i++) { |
| 317 | if (pCB->lastBoundDynamicState[i]) { |
| 318 | sprintf(str, "Reporting CreateInfo for currently bound %s object %p", string_XGL_STATE_BIND_POINT((XGL_STATE_BIND_POINT)i), pCB->lastBoundDynamicState[i]->stateObj); |
| 319 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pCB->lastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", str); |
| 320 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pCB->lastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", dynamic_display(pCB->lastBoundDynamicState[i]->pCreateInfo, " ").c_str()); |
| 321 | break; |
| 322 | } |
| 323 | else { |
| 324 | sprintf(str, "No dynamic state of type %s bound", string_XGL_STATE_BIND_POINT((XGL_STATE_BIND_POINT)i)); |
| 325 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", str); |
| 326 | } |
| 327 | } |
| 328 | loader_platform_thread_unlock_mutex(&globalLock); |
| 329 | } |
| 330 | else { |
| 331 | char str[1024]; |
| 332 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cb); |
| 333 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cb, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 334 | } |
| 335 | } |
| 336 | // Retrieve pipeline node ptr for given pipeline object |
| 337 | static PIPELINE_NODE* getPipeline(XGL_PIPELINE pipeline) |
| 338 | { |
| 339 | loader_platform_thread_lock_mutex(&globalLock); |
| 340 | if (pipelineMap.find(pipeline) == pipelineMap.end()) { |
| 341 | loader_platform_thread_unlock_mutex(&globalLock); |
| 342 | return NULL; |
| 343 | } |
| 344 | loader_platform_thread_unlock_mutex(&globalLock); |
| 345 | return pipelineMap[pipeline]; |
| 346 | } |
| 347 | |
| 348 | // For given sampler, return a ptr to its Create Info struct, or NULL if sampler not found |
| 349 | static XGL_SAMPLER_CREATE_INFO* getSamplerCreateInfo(const XGL_SAMPLER sampler) |
| 350 | { |
| 351 | loader_platform_thread_lock_mutex(&globalLock); |
| 352 | if (sampleMap.find(sampler) == sampleMap.end()) { |
| 353 | loader_platform_thread_unlock_mutex(&globalLock); |
| 354 | return NULL; |
| 355 | } |
| 356 | loader_platform_thread_unlock_mutex(&globalLock); |
| 357 | return &sampleMap[sampler]->createInfo; |
| 358 | } |
| 359 | |
| 360 | // Init the pipeline mapping info based on pipeline create info LL tree |
| 361 | // Threading note : Calls to this function should wrapped in mutex |
| 362 | static void initPipeline(PIPELINE_NODE* pPipeline, const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo) |
| 363 | { |
| 364 | // First init create info, we'll shadow the structs as we go down the tree |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 365 | // TODO : Validate that no create info is incorrectly replicated |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 366 | memcpy(&pPipeline->graphicsPipelineCI, pCreateInfo, sizeof(XGL_GRAPHICS_PIPELINE_CREATE_INFO)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 367 | GENERIC_HEADER* pTrav = (GENERIC_HEADER*)pCreateInfo->pNext; |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 368 | GENERIC_HEADER* pPrev = (GENERIC_HEADER*)&pPipeline->graphicsPipelineCI; // Hold prev ptr to tie chain of structs together |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 369 | size_t bufferSize = 0; |
| 370 | XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO* pVICI = NULL; |
| 371 | XGL_PIPELINE_CB_STATE_CREATE_INFO* pCBCI = NULL; |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 372 | XGL_PIPELINE_SHADER_STAGE_CREATE_INFO* pTmpPSSCI = NULL; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 373 | while (pTrav) { |
| 374 | switch (pTrav->sType) { |
| 375 | case XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 376 | pTmpPSSCI = (XGL_PIPELINE_SHADER_STAGE_CREATE_INFO*)pTrav; |
| 377 | switch (pTmpPSSCI->shader.stage) { |
| 378 | case XGL_SHADER_STAGE_VERTEX: |
| 379 | pPrev->pNext = &pPipeline->vsCI; |
| 380 | pPrev = (GENERIC_HEADER*)&pPipeline->vsCI; |
| 381 | memcpy(&pPipeline->vsCI, pTmpPSSCI, sizeof(XGL_PIPELINE_SHADER_STAGE_CREATE_INFO)); |
| 382 | break; |
| 383 | case XGL_SHADER_STAGE_TESS_CONTROL: |
| 384 | pPrev->pNext = &pPipeline->tcsCI; |
| 385 | pPrev = (GENERIC_HEADER*)&pPipeline->tcsCI; |
| 386 | memcpy(&pPipeline->tcsCI, pTmpPSSCI, sizeof(XGL_PIPELINE_SHADER_STAGE_CREATE_INFO)); |
| 387 | break; |
| 388 | case XGL_SHADER_STAGE_TESS_EVALUATION: |
| 389 | pPrev->pNext = &pPipeline->tesCI; |
| 390 | pPrev = (GENERIC_HEADER*)&pPipeline->tesCI; |
| 391 | memcpy(&pPipeline->tesCI, pTmpPSSCI, sizeof(XGL_PIPELINE_SHADER_STAGE_CREATE_INFO)); |
| 392 | break; |
| 393 | case XGL_SHADER_STAGE_GEOMETRY: |
| 394 | pPrev->pNext = &pPipeline->gsCI; |
| 395 | pPrev = (GENERIC_HEADER*)&pPipeline->gsCI; |
| 396 | memcpy(&pPipeline->gsCI, pTmpPSSCI, sizeof(XGL_PIPELINE_SHADER_STAGE_CREATE_INFO)); |
| 397 | break; |
| 398 | case XGL_SHADER_STAGE_FRAGMENT: |
| 399 | pPrev->pNext = &pPipeline->fsCI; |
| 400 | pPrev = (GENERIC_HEADER*)&pPipeline->fsCI; |
| 401 | memcpy(&pPipeline->fsCI, pTmpPSSCI, sizeof(XGL_PIPELINE_SHADER_STAGE_CREATE_INFO)); |
| 402 | break; |
| 403 | case XGL_SHADER_STAGE_COMPUTE: |
| 404 | // TODO : Flag error, CS is specified through XGL_COMPUTE_PIPELINE_CREATE_INFO |
| 405 | break; |
| 406 | default: |
| 407 | // TODO : Flag error |
| 408 | break; |
| 409 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 410 | break; |
| 411 | case XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 412 | pPrev->pNext = &pPipeline->vertexInputCI; |
| 413 | pPrev = (GENERIC_HEADER*)&pPipeline->vertexInputCI; |
| 414 | memcpy((void*)&pPipeline->vertexInputCI, pTrav, sizeof(XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 415 | // Copy embedded ptrs |
| 416 | pVICI = (XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO*)pTrav; |
| 417 | pPipeline->vtxBindingCount = pVICI->bindingCount; |
| 418 | if (pPipeline->vtxBindingCount) { |
| 419 | pPipeline->pVertexBindingDescriptions = new XGL_VERTEX_INPUT_BINDING_DESCRIPTION[pPipeline->vtxBindingCount]; |
| 420 | bufferSize = pPipeline->vtxBindingCount * sizeof(XGL_VERTEX_INPUT_BINDING_DESCRIPTION); |
| 421 | memcpy((void*)pPipeline->pVertexBindingDescriptions, ((XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO*)pTrav)->pVertexAttributeDescriptions, bufferSize); |
| 422 | } |
| 423 | pPipeline->vtxAttributeCount = pVICI->attributeCount; |
| 424 | if (pPipeline->vtxAttributeCount) { |
| 425 | pPipeline->pVertexAttributeDescriptions = new XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION[pPipeline->vtxAttributeCount]; |
| 426 | bufferSize = pPipeline->vtxAttributeCount * sizeof(XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION); |
| 427 | memcpy((void*)pPipeline->pVertexAttributeDescriptions, ((XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO*)pTrav)->pVertexAttributeDescriptions, bufferSize); |
| 428 | } |
| 429 | break; |
| 430 | case XGL_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 431 | pPrev->pNext = &pPipeline->iaStateCI; |
| 432 | pPrev = (GENERIC_HEADER*)&pPipeline->iaStateCI; |
| 433 | memcpy((void*)&pPipeline->iaStateCI, pTrav, sizeof(XGL_PIPELINE_IA_STATE_CREATE_INFO)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 434 | break; |
| 435 | case XGL_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 436 | pPrev->pNext = &pPipeline->tessStateCI; |
| 437 | pPrev = (GENERIC_HEADER*)&pPipeline->tessStateCI; |
| 438 | memcpy((void*)&pPipeline->tessStateCI, pTrav, sizeof(XGL_PIPELINE_TESS_STATE_CREATE_INFO)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 439 | break; |
| 440 | case XGL_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 441 | pPrev->pNext = &pPipeline->vpStateCI; |
| 442 | pPrev = (GENERIC_HEADER*)&pPipeline->vpStateCI; |
| 443 | memcpy((void*)&pPipeline->vpStateCI, pTrav, sizeof(XGL_PIPELINE_VP_STATE_CREATE_INFO)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 444 | break; |
| 445 | case XGL_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 446 | pPrev->pNext = &pPipeline->rsStateCI; |
| 447 | pPrev = (GENERIC_HEADER*)&pPipeline->rsStateCI; |
| 448 | memcpy((void*)&pPipeline->rsStateCI, pTrav, sizeof(XGL_PIPELINE_RS_STATE_CREATE_INFO)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 449 | break; |
| 450 | case XGL_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 451 | pPrev->pNext = &pPipeline->msStateCI; |
| 452 | pPrev = (GENERIC_HEADER*)&pPipeline->msStateCI; |
| 453 | memcpy((void*)&pPipeline->msStateCI, pTrav, sizeof(XGL_PIPELINE_MS_STATE_CREATE_INFO)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 454 | break; |
| 455 | case XGL_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 456 | pPrev->pNext = &pPipeline->cbStateCI; |
| 457 | pPrev = (GENERIC_HEADER*)&pPipeline->cbStateCI; |
| 458 | memcpy((void*)&pPipeline->cbStateCI, pTrav, sizeof(XGL_PIPELINE_CB_STATE_CREATE_INFO)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 459 | // Copy embedded ptrs |
| 460 | pCBCI = (XGL_PIPELINE_CB_STATE_CREATE_INFO*)pTrav; |
| 461 | pPipeline->attachmentCount = pCBCI->attachmentCount; |
| 462 | if (pPipeline->attachmentCount) { |
| 463 | pPipeline->pAttachments = new XGL_PIPELINE_CB_ATTACHMENT_STATE[pPipeline->attachmentCount]; |
| 464 | bufferSize = pPipeline->attachmentCount * sizeof(XGL_PIPELINE_CB_ATTACHMENT_STATE); |
| 465 | memcpy((void*)pPipeline->pAttachments, ((XGL_PIPELINE_CB_STATE_CREATE_INFO*)pTrav)->pAttachments, bufferSize); |
| 466 | } |
| 467 | break; |
| 468 | case XGL_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO: |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 469 | pPrev->pNext = &pPipeline->dsStateCI; |
| 470 | pPrev = (GENERIC_HEADER*)&pPipeline->dsStateCI; |
| 471 | memcpy((void*)&pPipeline->dsStateCI, pTrav, sizeof(XGL_PIPELINE_DS_STATE_CREATE_INFO)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 472 | break; |
| 473 | default: |
| 474 | assert(0); |
| 475 | break; |
| 476 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 477 | pTrav = (GENERIC_HEADER*)pTrav->pNext; |
| 478 | } |
| 479 | pipelineMap[pPipeline->pipeline] = pPipeline; |
| 480 | } |
| 481 | // Free the Pipeline nodes |
| 482 | static void freePipelines() |
| 483 | { |
| 484 | for (unordered_map<XGL_PIPELINE, PIPELINE_NODE*>::iterator ii=pipelineMap.begin(); ii!=pipelineMap.end(); ++ii) { |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 485 | if ((*ii).second->pVertexBindingDescriptions) { |
| 486 | delete[] (*ii).second->pVertexBindingDescriptions; |
| 487 | } |
| 488 | if ((*ii).second->pVertexAttributeDescriptions) { |
| 489 | delete[] (*ii).second->pVertexAttributeDescriptions; |
| 490 | } |
| 491 | if ((*ii).second->pAttachments) { |
| 492 | delete[] (*ii).second->pAttachments; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 493 | } |
| 494 | delete (*ii).second; |
| 495 | } |
| 496 | } |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 497 | // For given pipeline, return number of MSAA samples, or one if MSAA disabled |
| 498 | static uint32_t getNumSamples(const XGL_PIPELINE pipeline) |
| 499 | { |
| 500 | PIPELINE_NODE* pPipe = pipelineMap[pipeline]; |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 501 | if (XGL_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO == pPipe->msStateCI.sType) { |
| 502 | if (pPipe->msStateCI.multisampleEnable) |
| 503 | return pPipe->msStateCI.samples; |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 504 | } |
| 505 | return 1; |
| 506 | } |
| 507 | // Validate state related to the PSO |
| 508 | static void validatePipelineState(const GLOBAL_CB_NODE* pCB, const XGL_PIPELINE_BIND_POINT pipelineBindPoint, const XGL_PIPELINE pipeline) |
| 509 | { |
| 510 | if (XGL_PIPELINE_BIND_POINT_GRAPHICS == pipelineBindPoint) { |
| 511 | // Verify that any MSAA request in PSO matches sample# in bound FB |
| 512 | uint32_t psoNumSamples = getNumSamples(pipeline); |
| 513 | if (pCB->activeRenderPass) { |
| 514 | XGL_RENDER_PASS_CREATE_INFO* pRPCI = renderPassMap[pCB->activeRenderPass]; |
Courtney Goeltzenleuchter | e3b0f3a | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 515 | XGL_FRAMEBUFFER_CREATE_INFO* pFBCI = frameBufferMap[pCB->framebuffer]; |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 516 | if (psoNumSamples != pFBCI->sampleCount) { |
| 517 | char str[1024]; |
Courtney Goeltzenleuchter | e3b0f3a | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 518 | 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); |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 519 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pipeline, 0, DRAWSTATE_NUM_SAMPLES_MISMATCH, "DS", str); |
| 520 | } |
| 521 | } else { |
| 522 | // TODO : I believe it's an error if we reach this point and don't have an activeRenderPass |
| 523 | // Verify and flag error as appropriate |
| 524 | } |
| 525 | // TODO : Add more checks here |
| 526 | } else { |
| 527 | // TODO : Validate non-gfx pipeline updates |
| 528 | } |
| 529 | } |
| 530 | |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 531 | // Block of code at start here specifically for managing/tracking DSs |
| 532 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 533 | // Return Pool node ptr for specified pool or else NULL |
| 534 | static POOL_NODE* getPoolNode(XGL_DESCRIPTOR_POOL pool) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 535 | { |
| 536 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 537 | if (poolMap.find(pool) == poolMap.end()) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 538 | loader_platform_thread_unlock_mutex(&globalLock); |
| 539 | return NULL; |
| 540 | } |
| 541 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 542 | return poolMap[pool]; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 543 | } |
| 544 | // Return Set node ptr for specified set or else NULL |
| 545 | static SET_NODE* getSetNode(XGL_DESCRIPTOR_SET set) |
| 546 | { |
| 547 | loader_platform_thread_lock_mutex(&globalLock); |
| 548 | if (setMap.find(set) == setMap.end()) { |
| 549 | loader_platform_thread_unlock_mutex(&globalLock); |
| 550 | return NULL; |
| 551 | } |
| 552 | loader_platform_thread_unlock_mutex(&globalLock); |
| 553 | return setMap[set]; |
| 554 | } |
| 555 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 556 | // Return XGL_TRUE if DS Exists and is within an xglBeginDescriptorPoolUpdate() call sequence, otherwise XGL_FALSE |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 557 | static bool32_t dsUpdateActive(XGL_DESCRIPTOR_SET ds) |
| 558 | { |
| 559 | // Note, both "get" functions use global mutex so this guy does not |
| 560 | SET_NODE* pTrav = getSetNode(ds); |
| 561 | if (pTrav) { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 562 | POOL_NODE* pPool = getPoolNode(pTrav->pool); |
| 563 | if (pPool) { |
| 564 | return pPool->updateActive; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 565 | } |
| 566 | } |
| 567 | return XGL_FALSE; |
| 568 | } |
| 569 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 570 | static LAYOUT_NODE* getLayoutNode(const XGL_DESCRIPTOR_SET_LAYOUT layout) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 571 | loader_platform_thread_lock_mutex(&globalLock); |
| 572 | if (layoutMap.find(layout) == layoutMap.end()) { |
| 573 | loader_platform_thread_unlock_mutex(&globalLock); |
| 574 | return NULL; |
| 575 | } |
| 576 | loader_platform_thread_unlock_mutex(&globalLock); |
| 577 | return layoutMap[layout]; |
| 578 | } |
| 579 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 580 | // For given update struct, return binding |
| 581 | static uint32_t getUpdateBinding(const GENERIC_HEADER* pUpdateStruct) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 582 | { |
| 583 | switch (pUpdateStruct->sType) |
| 584 | { |
| 585 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 586 | return ((XGL_UPDATE_SAMPLERS*)pUpdateStruct)->binding; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 587 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 588 | return ((XGL_UPDATE_SAMPLER_TEXTURES*)pUpdateStruct)->binding; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 589 | case XGL_STRUCTURE_TYPE_UPDATE_IMAGES: |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 590 | return ((XGL_UPDATE_IMAGES*)pUpdateStruct)->binding; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 591 | case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS: |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 592 | return ((XGL_UPDATE_BUFFERS*)pUpdateStruct)->binding; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 593 | case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY: |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 594 | return ((XGL_UPDATE_AS_COPY*)pUpdateStruct)->binding; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 595 | default: |
| 596 | // TODO : Flag specific error for this case |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 597 | assert(0); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 598 | return 0; |
| 599 | } |
| 600 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 601 | // Return count for given update struct |
| 602 | static uint32_t getUpdateArrayIndex(const GENERIC_HEADER* pUpdateStruct) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 603 | { |
| 604 | switch (pUpdateStruct->sType) |
| 605 | { |
| 606 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 607 | return (((XGL_UPDATE_SAMPLERS*)pUpdateStruct)->arrayIndex); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 608 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 609 | return (((XGL_UPDATE_SAMPLER_TEXTURES*)pUpdateStruct)->arrayIndex); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 610 | case XGL_STRUCTURE_TYPE_UPDATE_IMAGES: |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 611 | return (((XGL_UPDATE_IMAGES*)pUpdateStruct)->arrayIndex); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 612 | case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS: |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 613 | return (((XGL_UPDATE_BUFFERS*)pUpdateStruct)->arrayIndex); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 614 | case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY: |
| 615 | // TODO : Need to understand this case better and make sure code is correct |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 616 | return (((XGL_UPDATE_AS_COPY*)pUpdateStruct)->arrayElement); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 617 | default: |
| 618 | // TODO : Flag specific error for this case |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 619 | assert(0); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 620 | return 0; |
| 621 | } |
| 622 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 623 | // Return count for given update struct |
| 624 | static uint32_t getUpdateCount(const GENERIC_HEADER* pUpdateStruct) |
| 625 | { |
| 626 | switch (pUpdateStruct->sType) |
| 627 | { |
| 628 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
| 629 | return (((XGL_UPDATE_SAMPLERS*)pUpdateStruct)->count); |
| 630 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
| 631 | return (((XGL_UPDATE_SAMPLER_TEXTURES*)pUpdateStruct)->count); |
| 632 | case XGL_STRUCTURE_TYPE_UPDATE_IMAGES: |
| 633 | return (((XGL_UPDATE_IMAGES*)pUpdateStruct)->count); |
| 634 | case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS: |
| 635 | return (((XGL_UPDATE_BUFFERS*)pUpdateStruct)->count); |
| 636 | case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY: |
| 637 | // TODO : Need to understand this case better and make sure code is correct |
| 638 | return (((XGL_UPDATE_AS_COPY*)pUpdateStruct)->count); |
| 639 | default: |
| 640 | // TODO : Flag specific error for this case |
| 641 | assert(0); |
| 642 | return 0; |
| 643 | } |
| 644 | } |
| 645 | // For given Layout Node and binding, return index where that binding begins |
| 646 | static uint32_t getBindingStartIndex(const LAYOUT_NODE* pLayout, const uint32_t binding) |
| 647 | { |
| 648 | uint32_t offsetIndex = 0; |
| 649 | for (uint32_t i = 0; i<binding; i++) { |
| 650 | offsetIndex += pLayout->createInfo.pBinding[i].count; |
| 651 | } |
| 652 | return offsetIndex; |
| 653 | } |
| 654 | // For given layout node and binding, return last index that is updated |
| 655 | static uint32_t getBindingEndIndex(const LAYOUT_NODE* pLayout, const uint32_t binding) |
| 656 | { |
| 657 | uint32_t offsetIndex = 0; |
| 658 | for (uint32_t i = 0; i<=binding; i++) { |
| 659 | offsetIndex += pLayout->createInfo.pBinding[i].count; |
| 660 | } |
| 661 | return offsetIndex-1; |
| 662 | } |
| 663 | // For given layout and update, return the first overall index of the layout that is update |
| 664 | static uint32_t getUpdateStartIndex(const LAYOUT_NODE* pLayout, const GENERIC_HEADER* pUpdateStruct) |
| 665 | { |
| 666 | return (getBindingStartIndex(pLayout, getUpdateBinding(pUpdateStruct))+getUpdateArrayIndex(pUpdateStruct)); |
| 667 | } |
| 668 | // For given layout and update, return the last overall index of the layout that is update |
| 669 | static uint32_t getUpdateEndIndex(const LAYOUT_NODE* pLayout, const GENERIC_HEADER* pUpdateStruct) |
| 670 | { |
| 671 | return (getBindingStartIndex(pLayout, getUpdateBinding(pUpdateStruct))+getUpdateArrayIndex(pUpdateStruct)+getUpdateCount(pUpdateStruct)-1); |
| 672 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 673 | // Verify that the descriptor type in the update struct matches what's expected by the layout |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 674 | static bool32_t validateUpdateType(const LAYOUT_NODE* pLayout, const GENERIC_HEADER* pUpdateStruct) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 675 | { |
| 676 | // First get actual type of update |
| 677 | XGL_DESCRIPTOR_TYPE actualType; |
| 678 | uint32_t i = 0; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 679 | switch (pUpdateStruct->sType) |
| 680 | { |
| 681 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
| 682 | actualType = XGL_DESCRIPTOR_TYPE_SAMPLER; |
| 683 | break; |
| 684 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
| 685 | actualType = XGL_DESCRIPTOR_TYPE_SAMPLER_TEXTURE; |
| 686 | break; |
| 687 | case XGL_STRUCTURE_TYPE_UPDATE_IMAGES: |
| 688 | actualType = ((XGL_UPDATE_IMAGES*)pUpdateStruct)->descriptorType; |
| 689 | break; |
| 690 | case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS: |
| 691 | actualType = ((XGL_UPDATE_BUFFERS*)pUpdateStruct)->descriptorType; |
| 692 | break; |
| 693 | case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY: |
| 694 | actualType = ((XGL_UPDATE_AS_COPY*)pUpdateStruct)->descriptorType; |
| 695 | break; |
| 696 | default: |
| 697 | // TODO : Flag specific error for this case |
| 698 | return 0; |
| 699 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 700 | for (i = getUpdateStartIndex(pLayout, pUpdateStruct); i <= getUpdateEndIndex(pLayout, pUpdateStruct); i++) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 701 | if (pLayout->pTypes[i] != actualType) |
| 702 | return 0; |
| 703 | } |
| 704 | return 1; |
| 705 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 706 | // Determine the update type, allocate a new struct of that type, shadow the given pUpdate |
| 707 | // struct into the new struct and return ptr to shadow struct cast as GENERIC_HEADER |
| 708 | // NOTE : Calls to this function should be wrapped in mutex |
| 709 | static GENERIC_HEADER* shadowUpdateNode(GENERIC_HEADER* pUpdate) |
| 710 | { |
| 711 | GENERIC_HEADER* pNewNode = NULL; |
| 712 | size_t array_size = 0; |
| 713 | size_t base_array_size = 0; |
| 714 | size_t total_array_size = 0; |
| 715 | size_t baseBuffAddr = 0; |
| 716 | XGL_UPDATE_BUFFERS* pUBCI; |
| 717 | XGL_UPDATE_IMAGES* pUICI; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 718 | XGL_IMAGE_VIEW_ATTACH_INFO** ppLocalImageViews = NULL; |
| 719 | XGL_BUFFER_VIEW_ATTACH_INFO** ppLocalBufferViews = NULL; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 720 | char str[1024]; |
| 721 | switch (pUpdate->sType) |
| 722 | { |
| 723 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
| 724 | pNewNode = (GENERIC_HEADER*)malloc(sizeof(XGL_UPDATE_SAMPLERS)); |
| 725 | #if ALLOC_DEBUG |
| 726 | printf("Alloc10 #%lu pNewNode addr(%p)\n", ++g_alloc_count, (void*)pNewNode); |
| 727 | #endif |
| 728 | memcpy(pNewNode, pUpdate, sizeof(XGL_UPDATE_SAMPLERS)); |
| 729 | array_size = sizeof(XGL_SAMPLER) * ((XGL_UPDATE_SAMPLERS*)pNewNode)->count; |
| 730 | ((XGL_UPDATE_SAMPLERS*)pNewNode)->pSamplers = (XGL_SAMPLER*)malloc(array_size); |
| 731 | #if ALLOC_DEBUG |
| 732 | printf("Alloc11 #%lu pNewNode->pSamplers addr(%p)\n", ++g_alloc_count, (void*)((XGL_UPDATE_SAMPLERS*)pNewNode)->pSamplers); |
| 733 | #endif |
| 734 | memcpy((XGL_SAMPLER*)((XGL_UPDATE_SAMPLERS*)pNewNode)->pSamplers, ((XGL_UPDATE_SAMPLERS*)pUpdate)->pSamplers, array_size); |
| 735 | break; |
| 736 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
| 737 | pNewNode = (GENERIC_HEADER*)malloc(sizeof(XGL_UPDATE_SAMPLER_TEXTURES)); |
| 738 | #if ALLOC_DEBUG |
| 739 | printf("Alloc12 #%lu pNewNode addr(%p)\n", ++g_alloc_count, (void*)pNewNode); |
| 740 | #endif |
| 741 | memcpy(pNewNode, pUpdate, sizeof(XGL_UPDATE_SAMPLER_TEXTURES)); |
| 742 | array_size = sizeof(XGL_SAMPLER_IMAGE_VIEW_INFO) * ((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->count; |
| 743 | ((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->pSamplerImageViews = (XGL_SAMPLER_IMAGE_VIEW_INFO*)malloc(array_size); |
| 744 | #if ALLOC_DEBUG |
| 745 | printf("Alloc13 #%lu pNewNode->pSamplerImageViews addr(%p)\n", ++g_alloc_count, (void*)((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->pSamplerImageViews); |
| 746 | #endif |
| 747 | for (uint32_t i = 0; i < ((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->count; i++) { |
| 748 | memcpy((XGL_SAMPLER_IMAGE_VIEW_INFO*)&((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->pSamplerImageViews[i], &((XGL_UPDATE_SAMPLER_TEXTURES*)pUpdate)->pSamplerImageViews[i], sizeof(XGL_SAMPLER_IMAGE_VIEW_INFO)); |
| 749 | ((XGL_SAMPLER_IMAGE_VIEW_INFO*)((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->pSamplerImageViews)[i].pImageView = (XGL_IMAGE_VIEW_ATTACH_INFO*)malloc(sizeof(XGL_IMAGE_VIEW_ATTACH_INFO)); |
| 750 | #if ALLOC_DEBUG |
| 751 | printf("Alloc14 #%lu pSamplerImageViews)[%u].pImageView addr(%p)\n", ++g_alloc_count, i, (void*)((XGL_SAMPLER_IMAGE_VIEW_INFO*)((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->pSamplerImageViews)[i].pImageView); |
| 752 | #endif |
| 753 | memcpy((XGL_IMAGE_VIEW_ATTACH_INFO*)((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->pSamplerImageViews[i].pImageView, ((XGL_UPDATE_SAMPLER_TEXTURES*)pUpdate)->pSamplerImageViews[i].pImageView, sizeof(XGL_IMAGE_VIEW_ATTACH_INFO)); |
| 754 | } |
| 755 | break; |
| 756 | case XGL_STRUCTURE_TYPE_UPDATE_IMAGES: |
| 757 | pUICI = (XGL_UPDATE_IMAGES*)pUpdate; |
| 758 | pNewNode = (GENERIC_HEADER*)malloc(sizeof(XGL_UPDATE_IMAGES)); |
| 759 | #if ALLOC_DEBUG |
| 760 | printf("Alloc15 #%lu pNewNode addr(%p)\n", ++g_alloc_count, (void*)pNewNode); |
| 761 | #endif |
| 762 | memcpy(pNewNode, pUpdate, sizeof(XGL_UPDATE_IMAGES)); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 763 | total_array_size = (sizeof(XGL_IMAGE_VIEW_ATTACH_INFO) * ((XGL_UPDATE_IMAGES*)pNewNode)->count); |
| 764 | ppLocalImageViews = (XGL_IMAGE_VIEW_ATTACH_INFO**)&(((XGL_UPDATE_IMAGES*)pNewNode)->pImageViews); |
| 765 | *ppLocalImageViews = (XGL_IMAGE_VIEW_ATTACH_INFO*)malloc(total_array_size); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 766 | #if ALLOC_DEBUG |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 767 | printf("Alloc16 #%lu *pppLocalImageViews addr(%p)\n", ++g_alloc_count, (void*)*ppLocalImageViews); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 768 | #endif |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 769 | memcpy((void*)*ppLocalImageViews, pUICI->pImageViews, total_array_size); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 770 | break; |
| 771 | case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS: |
| 772 | pUBCI = (XGL_UPDATE_BUFFERS*)pUpdate; |
| 773 | pNewNode = (GENERIC_HEADER*)malloc(sizeof(XGL_UPDATE_BUFFERS)); |
| 774 | #if ALLOC_DEBUG |
| 775 | printf("Alloc17 #%lu pNewNode addr(%p)\n", ++g_alloc_count, (void*)pNewNode); |
| 776 | #endif |
| 777 | memcpy(pNewNode, pUpdate, sizeof(XGL_UPDATE_BUFFERS)); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 778 | total_array_size = (sizeof(XGL_BUFFER_VIEW_ATTACH_INFO) * pUBCI->count); |
| 779 | ppLocalBufferViews = (XGL_BUFFER_VIEW_ATTACH_INFO**)&(((XGL_UPDATE_BUFFERS*)pNewNode)->pBufferViews); |
| 780 | *ppLocalBufferViews = (XGL_BUFFER_VIEW_ATTACH_INFO*)malloc(total_array_size); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 781 | #if ALLOC_DEBUG |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 782 | printf("Alloc18 #%lu *pppLocalBufferViews addr(%p)\n", ++g_alloc_count, (void*)*ppLocalBufferViews); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 783 | #endif |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 784 | memcpy((void*)*ppLocalBufferViews, pUBCI->pBufferViews, total_array_size); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 785 | break; |
| 786 | case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY: |
| 787 | pNewNode = (GENERIC_HEADER*)malloc(sizeof(XGL_UPDATE_AS_COPY)); |
| 788 | #if ALLOC_DEBUG |
| 789 | printf("Alloc19 #%lu pNewNode addr(%p)\n", ++g_alloc_count, (void*)pNewNode); |
| 790 | #endif |
| 791 | memcpy(pNewNode, pUpdate, sizeof(XGL_UPDATE_AS_COPY)); |
| 792 | break; |
| 793 | default: |
| 794 | sprintf(str, "Unexpected UPDATE struct of type %s (value %u) in xglUpdateDescriptors() struct tree", string_XGL_STRUCTURE_TYPE(pUpdate->sType), pUpdate->sType); |
| 795 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_INVALID_UPDATE_STRUCT, "DS", str); |
| 796 | return NULL; |
| 797 | } |
| 798 | // Make sure that pNext for the end of shadow copy is NULL |
| 799 | pNewNode->pNext = NULL; |
| 800 | return pNewNode; |
| 801 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 802 | // For given ds, update its mapping based on ppUpdateArray |
| 803 | static void dsUpdate(XGL_DESCRIPTOR_SET ds, uint32_t updateCount, const void** ppUpdateArray) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 804 | { |
| 805 | SET_NODE* pSet = getSetNode(ds); |
| 806 | loader_platform_thread_lock_mutex(&globalLock); |
| 807 | g_lastBoundDescriptorSet = pSet->set; |
| 808 | LAYOUT_NODE* pLayout = NULL; |
| 809 | XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pLayoutCI = NULL; |
| 810 | // TODO : If pCIList is NULL, flag error |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 811 | // Perform all updates |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 812 | for (uint32_t i = 0; i < updateCount; i++) { |
| 813 | GENERIC_HEADER* pUpdate = (GENERIC_HEADER*)ppUpdateArray[i]; |
| 814 | pLayout = pSet->pLayout; |
| 815 | // Make sure that binding is within bounds |
| 816 | if (pLayout->createInfo.count < getUpdateBinding(pUpdate)) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 817 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 818 | sprintf(str, "Descriptor Set %p does not have binding to match update binding %u for update type %s!", ds, getUpdateBinding(pUpdate), string_XGL_STRUCTURE_TYPE(pUpdate->sType)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 819 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_INVALID_UPDATE_INDEX, "DS", str); |
| 820 | } |
| 821 | else { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 822 | // Next verify that update falls within size of given binding |
| 823 | if (getBindingEndIndex(pLayout, getUpdateBinding(pUpdate)) < getUpdateEndIndex(pLayout, pUpdate)) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 824 | char str[48*1024]; // TODO : Keep count of layout CI structs and size this string dynamically based on that count |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 825 | pLayoutCI = &pLayout->createInfo; |
| 826 | string DSstr = xgl_print_xgl_descriptor_set_layout_create_info(pLayoutCI, "{DS} "); |
| 827 | sprintf(str, "Descriptor update type of %s is out of bounds for matching binding %u in Layout w/ CI:\n%s!", string_XGL_STRUCTURE_TYPE(pUpdate->sType), getUpdateBinding(pUpdate), DSstr.c_str()); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 828 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_DESCRIPTOR_UPDATE_OUT_OF_BOUNDS, "DS", str); |
| 829 | } |
| 830 | else { // TODO : should we skip update on a type mismatch or force it? |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 831 | // Layout bindings match w/ update ok, now verify that update is of the right type |
| 832 | if (!validateUpdateType(pLayout, pUpdate)) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 833 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 834 | sprintf(str, "Descriptor update type of %s does not match overlapping binding type!", string_XGL_STRUCTURE_TYPE(pUpdate->sType)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 835 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_DESCRIPTOR_TYPE_MISMATCH, "DS", str); |
| 836 | } |
| 837 | else { |
| 838 | // Save the update info |
| 839 | // TODO : Info message that update successful |
| 840 | // Create new update struct for this set's shadow copy |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 841 | GENERIC_HEADER* pNewNode = shadowUpdateNode(pUpdate); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 842 | if (NULL == pNewNode) { |
| 843 | char str[1024]; |
| 844 | sprintf(str, "Out of memory while attempting to allocate UPDATE struct in xglUpdateDescriptors()"); |
| 845 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str); |
| 846 | } |
| 847 | else { |
| 848 | // Insert shadow node into LL of updates for this set |
| 849 | pNewNode->pNext = pSet->pUpdateStructs; |
| 850 | pSet->pUpdateStructs = pNewNode; |
| 851 | // Now update appropriate descriptor(s) to point to new Update node |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 852 | for (uint32_t j = getUpdateStartIndex(pLayout, pUpdate); j <= getUpdateEndIndex(pLayout, pUpdate); j++) { |
| 853 | assert(j<pSet->descriptorCount); |
| 854 | pSet->ppDescriptors[j] = pNewNode; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 855 | } |
| 856 | } |
| 857 | } |
| 858 | } |
| 859 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 860 | } |
| 861 | loader_platform_thread_unlock_mutex(&globalLock); |
| 862 | } |
| 863 | // Free the shadowed update node for this Set |
| 864 | // NOTE : Calls to this function should be wrapped in mutex |
| 865 | static void freeShadowUpdateTree(SET_NODE* pSet) |
| 866 | { |
| 867 | GENERIC_HEADER* pShadowUpdate = pSet->pUpdateStructs; |
| 868 | pSet->pUpdateStructs = NULL; |
| 869 | GENERIC_HEADER* pFreeUpdate = pShadowUpdate; |
| 870 | // Clear the descriptor mappings as they will now be invalid |
| 871 | memset(pSet->ppDescriptors, 0, pSet->descriptorCount*sizeof(GENERIC_HEADER*)); |
| 872 | while(pShadowUpdate) { |
| 873 | pFreeUpdate = pShadowUpdate; |
| 874 | pShadowUpdate = (GENERIC_HEADER*)pShadowUpdate->pNext; |
| 875 | uint32_t index = 0; |
| 876 | XGL_UPDATE_SAMPLERS* pUS = NULL; |
| 877 | XGL_UPDATE_SAMPLER_TEXTURES* pUST = NULL; |
| 878 | XGL_UPDATE_IMAGES* pUI = NULL; |
| 879 | XGL_UPDATE_BUFFERS* pUB = NULL; |
| 880 | void** ppToFree = NULL; |
| 881 | switch (pFreeUpdate->sType) |
| 882 | { |
| 883 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
| 884 | pUS = (XGL_UPDATE_SAMPLERS*)pFreeUpdate; |
| 885 | if (pUS->pSamplers) { |
| 886 | ppToFree = (void**)&pUS->pSamplers; |
| 887 | #if ALLOC_DEBUG |
| 888 | printf("Free11 #%lu pSamplers addr(%p)\n", ++g_free_count, (void*)*ppToFree); |
| 889 | #endif |
| 890 | free(*ppToFree); |
| 891 | } |
| 892 | break; |
| 893 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
| 894 | pUST = (XGL_UPDATE_SAMPLER_TEXTURES*)pFreeUpdate; |
| 895 | for (index = 0; index < pUST->count; index++) { |
| 896 | if (pUST->pSamplerImageViews[index].pImageView) { |
| 897 | ppToFree = (void**)&pUST->pSamplerImageViews[index].pImageView; |
| 898 | #if ALLOC_DEBUG |
| 899 | printf("Free14 #%lu pImageView addr(%p)\n", ++g_free_count, (void*)*ppToFree); |
| 900 | #endif |
| 901 | free(*ppToFree); |
| 902 | } |
| 903 | } |
| 904 | ppToFree = (void**)&pUST->pSamplerImageViews; |
| 905 | #if ALLOC_DEBUG |
| 906 | printf("Free13 #%lu pSamplerImageViews addr(%p)\n", ++g_free_count, (void*)*ppToFree); |
| 907 | #endif |
| 908 | free(*ppToFree); |
| 909 | break; |
| 910 | case XGL_STRUCTURE_TYPE_UPDATE_IMAGES: |
| 911 | pUI = (XGL_UPDATE_IMAGES*)pFreeUpdate; |
| 912 | if (pUI->pImageViews) { |
| 913 | ppToFree = (void**)&pUI->pImageViews; |
| 914 | #if ALLOC_DEBUG |
| 915 | printf("Free16 #%lu pImageViews addr(%p)\n", ++g_free_count, (void*)*ppToFree); |
| 916 | #endif |
| 917 | free(*ppToFree); |
| 918 | } |
| 919 | break; |
| 920 | case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS: |
| 921 | pUB = (XGL_UPDATE_BUFFERS*)pFreeUpdate; |
| 922 | if (pUB->pBufferViews) { |
| 923 | ppToFree = (void**)&pUB->pBufferViews; |
| 924 | #if ALLOC_DEBUG |
| 925 | printf("Free18 #%lu pBufferViews addr(%p)\n", ++g_free_count, (void*)*ppToFree); |
| 926 | #endif |
| 927 | free(*ppToFree); |
| 928 | } |
| 929 | break; |
| 930 | case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY: |
| 931 | break; |
| 932 | default: |
| 933 | assert(0); |
| 934 | break; |
| 935 | } |
| 936 | #if ALLOC_DEBUG |
| 937 | printf("Free10, Free12, Free15, Free17, Free19 #%lu pUpdateNode addr(%p)\n", ++g_free_count, (void*)pFreeUpdate); |
| 938 | #endif |
| 939 | free(pFreeUpdate); |
| 940 | } |
| 941 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 942 | // Free all DS Pools including their Sets & related sub-structs |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 943 | // NOTE : Calls to this function should be wrapped in mutex |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 944 | static void freePools() |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 945 | { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 946 | for (unordered_map<XGL_DESCRIPTOR_POOL, POOL_NODE*>::iterator ii=poolMap.begin(); ii!=poolMap.end(); ++ii) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 947 | SET_NODE* pSet = (*ii).second->pSets; |
| 948 | SET_NODE* pFreeSet = pSet; |
| 949 | while (pSet) { |
| 950 | pFreeSet = pSet; |
| 951 | pSet = pSet->pNext; |
| 952 | // Freeing layouts handled in freeLayouts() function |
| 953 | // Free Update shadow struct tree |
| 954 | freeShadowUpdateTree(pFreeSet); |
| 955 | if (pFreeSet->ppDescriptors) { |
| 956 | delete pFreeSet->ppDescriptors; |
| 957 | } |
| 958 | delete pFreeSet; |
| 959 | } |
| 960 | if ((*ii).second->createInfo.pTypeCount) { |
| 961 | delete (*ii).second->createInfo.pTypeCount; |
| 962 | } |
| 963 | delete (*ii).second; |
| 964 | } |
| 965 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 966 | // WARN : Once freeLayouts() called, any layout ptrs in Pool/Set data structure will be invalid |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 967 | // NOTE : Calls to this function should be wrapped in mutex |
| 968 | static void freeLayouts() |
| 969 | { |
| 970 | for (unordered_map<XGL_DESCRIPTOR_SET_LAYOUT, LAYOUT_NODE*>::iterator ii=layoutMap.begin(); ii!=layoutMap.end(); ++ii) { |
| 971 | LAYOUT_NODE* pLayout = (*ii).second; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 972 | if (pLayout->pTypes) { |
| 973 | delete pLayout->pTypes; |
| 974 | } |
| 975 | delete pLayout; |
| 976 | } |
| 977 | } |
| 978 | // Currently clearing a set is removing all previous updates to that set |
| 979 | // TODO : Validate if this is correct clearing behavior |
| 980 | static void clearDescriptorSet(XGL_DESCRIPTOR_SET set) |
| 981 | { |
| 982 | SET_NODE* pSet = getSetNode(set); |
| 983 | if (!pSet) { |
| 984 | // TODO : Return error |
| 985 | } |
| 986 | else { |
| 987 | loader_platform_thread_lock_mutex(&globalLock); |
| 988 | freeShadowUpdateTree(pSet); |
| 989 | loader_platform_thread_unlock_mutex(&globalLock); |
| 990 | } |
| 991 | } |
| 992 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 993 | static void clearDescriptorPool(XGL_DESCRIPTOR_POOL pool) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 994 | { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 995 | POOL_NODE* pPool = getPoolNode(pool); |
| 996 | if (!pPool) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 997 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 998 | sprintf(str, "Unable to find pool node for pool %p specified in xglClearDescriptorPool() call", (void*)pool); |
| 999 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pool, 0, DRAWSTATE_INVALID_POOL, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1000 | } |
| 1001 | else |
| 1002 | { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1003 | // For every set off of this pool, clear it |
| 1004 | SET_NODE* pSet = pPool->pSets; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1005 | while (pSet) { |
| 1006 | clearDescriptorSet(pSet->set); |
| 1007 | } |
| 1008 | } |
| 1009 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1010 | // Code here to manage the Cmd buffer LL |
| 1011 | static GLOBAL_CB_NODE* getCBNode(XGL_CMD_BUFFER cb) |
| 1012 | { |
| 1013 | loader_platform_thread_lock_mutex(&globalLock); |
| 1014 | if (cmdBufferMap.find(cb) == cmdBufferMap.end()) { |
| 1015 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1016 | return NULL; |
| 1017 | } |
| 1018 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1019 | return cmdBufferMap[cb]; |
| 1020 | } |
| 1021 | // Free all CB Nodes |
| 1022 | // NOTE : Calls to this function should be wrapped in mutex |
| 1023 | static void freeCmdBuffers() |
| 1024 | { |
| 1025 | for (unordered_map<XGL_CMD_BUFFER, GLOBAL_CB_NODE*>::iterator ii=cmdBufferMap.begin(); ii!=cmdBufferMap.end(); ++ii) { |
| 1026 | while (!(*ii).second->pCmds.empty()) { |
| 1027 | delete (*ii).second->pCmds.back(); |
| 1028 | (*ii).second->pCmds.pop_back(); |
| 1029 | } |
| 1030 | delete (*ii).second; |
| 1031 | } |
| 1032 | } |
| 1033 | static void addCmd(GLOBAL_CB_NODE* pCB, const CMD_TYPE cmd) |
| 1034 | { |
| 1035 | CMD_NODE* pCmd = new CMD_NODE; |
| 1036 | if (pCmd) { |
| 1037 | // init cmd node and append to end of cmd LL |
| 1038 | memset(pCmd, 0, sizeof(CMD_NODE)); |
| 1039 | pCmd->cmdNumber = ++pCB->numCmds; |
| 1040 | pCmd->type = cmd; |
| 1041 | pCB->pCmds.push_back(pCmd); |
| 1042 | } |
| 1043 | else { |
| 1044 | char str[1024]; |
| 1045 | sprintf(str, "Out of memory while attempting to allocate new CMD_NODE for cmdBuffer %p", (void*)pCB->cmdBuffer); |
| 1046 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pCB->cmdBuffer, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str); |
| 1047 | } |
| 1048 | } |
| 1049 | static void resetCB(const XGL_CMD_BUFFER cb) |
| 1050 | { |
| 1051 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1052 | if (pCB) { |
| 1053 | while (!pCB->pCmds.empty()) { |
| 1054 | delete pCB->pCmds.back(); |
| 1055 | pCB->pCmds.pop_back(); |
| 1056 | } |
| 1057 | // Reset CB state |
| 1058 | XGL_FLAGS saveFlags = pCB->flags; |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 1059 | uint32_t saveQueueNodeIndex = pCB->queueNodeIndex; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1060 | memset(pCB, 0, sizeof(GLOBAL_CB_NODE)); |
| 1061 | pCB->cmdBuffer = cb; |
| 1062 | pCB->flags = saveFlags; |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 1063 | pCB->queueNodeIndex = saveQueueNodeIndex; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1064 | pCB->lastVtxBinding = MAX_BINDING; |
| 1065 | } |
| 1066 | } |
| 1067 | // Set the last bound dynamic state of given type |
| 1068 | // TODO : Need to track this per cmdBuffer and correlate cmdBuffer for Draw w/ last bound for that cmdBuffer? |
| 1069 | static void setLastBoundDynamicState(const XGL_CMD_BUFFER cmdBuffer, const XGL_DYNAMIC_STATE_OBJECT state, const XGL_STATE_BIND_POINT sType) |
| 1070 | { |
| 1071 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 1072 | if (pCB) { |
| 1073 | updateCBTracking(cmdBuffer); |
| 1074 | loader_platform_thread_lock_mutex(&globalLock); |
| 1075 | addCmd(pCB, CMD_BINDDYNAMICSTATEOBJECT); |
| 1076 | if (dynamicStateMap.find(state) == dynamicStateMap.end()) { |
| 1077 | char str[1024]; |
| 1078 | sprintf(str, "Unable to find dynamic state object %p, was it ever created?", (void*)state); |
| 1079 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, state, 0, DRAWSTATE_INVALID_DYNAMIC_STATE_OBJECT, "DS", str); |
| 1080 | } |
| 1081 | else { |
| 1082 | pCB->lastBoundDynamicState[sType] = dynamicStateMap[state]; |
| 1083 | g_lastBoundDynamicState[sType] = dynamicStateMap[state]; |
| 1084 | } |
| 1085 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1086 | } |
| 1087 | else { |
| 1088 | char str[1024]; |
| 1089 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 1090 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 1091 | } |
| 1092 | } |
| 1093 | // Print the last bound Gfx Pipeline |
| 1094 | static void printPipeline(const XGL_CMD_BUFFER cb) |
| 1095 | { |
| 1096 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1097 | if (pCB) { |
| 1098 | PIPELINE_NODE *pPipeTrav = getPipeline(pCB->lastBoundPipeline); |
| 1099 | if (!pPipeTrav) { |
| 1100 | // nothing to print |
| 1101 | } |
| 1102 | else { |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 1103 | string pipeStr = xgl_print_xgl_graphics_pipeline_create_info(&pPipeTrav->graphicsPipelineCI, "{DS}").c_str(); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1104 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", pipeStr.c_str()); |
| 1105 | } |
| 1106 | } |
| 1107 | } |
| 1108 | // Common Dot dumping code |
| 1109 | static void dsCoreDumpDot(const XGL_DESCRIPTOR_SET ds, FILE* pOutFile) |
| 1110 | { |
| 1111 | SET_NODE* pSet = getSetNode(ds); |
| 1112 | if (pSet) { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1113 | POOL_NODE* pPool = getPoolNode(pSet->pool); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1114 | char tmp_str[4*1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1115 | fprintf(pOutFile, "subgraph cluster_DescriptorPool\n{\nlabel=\"Descriptor Pool\"\n"); |
| 1116 | sprintf(tmp_str, "Pool (%p)", pPool->pool); |
| 1117 | char* pGVstr = xgl_gv_print_xgl_descriptor_pool_create_info(&pPool->createInfo, tmp_str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1118 | fprintf(pOutFile, "%s", pGVstr); |
| 1119 | free(pGVstr); |
| 1120 | fprintf(pOutFile, "subgraph cluster_DescriptorSet\n{\nlabel=\"Descriptor Set (%p)\"\n", pSet->set); |
| 1121 | sprintf(tmp_str, "Descriptor Set (%p)", pSet->set); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1122 | LAYOUT_NODE* pLayout = pSet->pLayout; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1123 | uint32_t layout_index = 0; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1124 | ++layout_index; |
| 1125 | sprintf(tmp_str, "LAYOUT%u", layout_index); |
| 1126 | pGVstr = xgl_gv_print_xgl_descriptor_set_layout_create_info(&pLayout->createInfo, tmp_str); |
| 1127 | fprintf(pOutFile, "%s", pGVstr); |
| 1128 | free(pGVstr); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1129 | if (pSet->pUpdateStructs) { |
| 1130 | pGVstr = dynamic_gv_display(pSet->pUpdateStructs, "Descriptor Updates"); |
| 1131 | fprintf(pOutFile, "%s", pGVstr); |
| 1132 | free(pGVstr); |
| 1133 | } |
| 1134 | if (pSet->ppDescriptors) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1135 | fprintf(pOutFile, "\"DESCRIPTORS\" [\nlabel=<<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"> <TR><TD COLSPAN=\"2\" PORT=\"desc\">DESCRIPTORS</TD></TR>"); |
| 1136 | uint32_t i = 0; |
| 1137 | for (i=0; i < pSet->descriptorCount; i++) { |
| 1138 | if (pSet->ppDescriptors[i]) { |
| 1139 | fprintf(pOutFile, "<TR><TD PORT=\"slot%u\">slot%u</TD><TD>%s</TD></TR>", i, i, string_XGL_STRUCTURE_TYPE(pSet->ppDescriptors[i]->sType)); |
| 1140 | } |
| 1141 | } |
| 1142 | #define NUM_COLORS 7 |
| 1143 | vector<string> edgeColors; |
| 1144 | edgeColors.push_back("0000ff"); |
| 1145 | edgeColors.push_back("ff00ff"); |
| 1146 | edgeColors.push_back("ffff00"); |
| 1147 | edgeColors.push_back("00ff00"); |
| 1148 | edgeColors.push_back("000000"); |
| 1149 | edgeColors.push_back("00ffff"); |
| 1150 | edgeColors.push_back("ff0000"); |
| 1151 | uint32_t colorIdx = 0; |
| 1152 | fprintf(pOutFile, "</TABLE>>\n];\n"); |
| 1153 | // Now add the views that are mapped to active descriptors |
| 1154 | XGL_UPDATE_SAMPLERS* pUS = NULL; |
| 1155 | XGL_UPDATE_SAMPLER_TEXTURES* pUST = NULL; |
| 1156 | XGL_UPDATE_IMAGES* pUI = NULL; |
| 1157 | XGL_UPDATE_BUFFERS* pUB = NULL; |
| 1158 | XGL_UPDATE_AS_COPY* pUAC = NULL; |
| 1159 | XGL_SAMPLER_CREATE_INFO* pSCI = NULL; |
| 1160 | XGL_IMAGE_VIEW_CREATE_INFO* pIVCI = NULL; |
| 1161 | XGL_BUFFER_VIEW_CREATE_INFO* pBVCI = NULL; |
| 1162 | void** ppNextPtr = NULL; |
| 1163 | void* pSaveNext = NULL; |
| 1164 | for (i=0; i < pSet->descriptorCount; i++) { |
| 1165 | if (pSet->ppDescriptors[i]) { |
| 1166 | switch (pSet->ppDescriptors[i]->sType) |
| 1167 | { |
| 1168 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
| 1169 | pUS = (XGL_UPDATE_SAMPLERS*)pSet->ppDescriptors[i]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1170 | pSCI = getSamplerCreateInfo(pUS->pSamplers[i-pUS->arrayIndex]); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1171 | if (pSCI) { |
| 1172 | sprintf(tmp_str, "SAMPLER%u", i); |
| 1173 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_sampler_create_info(pSCI, tmp_str)); |
| 1174 | fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str()); |
| 1175 | } |
| 1176 | break; |
| 1177 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
| 1178 | pUST = (XGL_UPDATE_SAMPLER_TEXTURES*)pSet->ppDescriptors[i]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1179 | pSCI = getSamplerCreateInfo(pUST->pSamplerImageViews[i-pUST->arrayIndex].sampler); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1180 | if (pSCI) { |
| 1181 | sprintf(tmp_str, "SAMPLER%u", i); |
| 1182 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_sampler_create_info(pSCI, tmp_str)); |
| 1183 | fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str()); |
| 1184 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1185 | pIVCI = getImageViewCreateInfo(pUST->pSamplerImageViews[i-pUST->arrayIndex].pImageView->view); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1186 | if (pIVCI) { |
| 1187 | sprintf(tmp_str, "IMAGE_VIEW%u", i); |
| 1188 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_image_view_create_info(pIVCI, tmp_str)); |
| 1189 | fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str()); |
| 1190 | } |
| 1191 | break; |
| 1192 | case XGL_STRUCTURE_TYPE_UPDATE_IMAGES: |
| 1193 | pUI = (XGL_UPDATE_IMAGES*)pSet->ppDescriptors[i]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1194 | pIVCI = getImageViewCreateInfo(pUI->pImageViews[i-pUI->arrayIndex].view); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1195 | if (pIVCI) { |
| 1196 | sprintf(tmp_str, "IMAGE_VIEW%u", i); |
| 1197 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_image_view_create_info(pIVCI, tmp_str)); |
| 1198 | fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str()); |
| 1199 | } |
| 1200 | break; |
| 1201 | case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS: |
| 1202 | pUB = (XGL_UPDATE_BUFFERS*)pSet->ppDescriptors[i]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1203 | pBVCI = getBufferViewCreateInfo(pUB->pBufferViews[i-pUB->arrayIndex].view); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1204 | if (pBVCI) { |
| 1205 | sprintf(tmp_str, "BUFFER_VIEW%u", i); |
| 1206 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_buffer_view_create_info(pBVCI, tmp_str)); |
| 1207 | fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str()); |
| 1208 | } |
| 1209 | break; |
| 1210 | case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY: |
| 1211 | pUAC = (XGL_UPDATE_AS_COPY*)pSet->ppDescriptors[i]; |
| 1212 | // TODO : Need to validate this code |
| 1213 | // Save off pNext and set to NULL while printing this struct, then restore it |
| 1214 | ppNextPtr = (void**)&pUAC->pNext; |
| 1215 | pSaveNext = *ppNextPtr; |
| 1216 | *ppNextPtr = NULL; |
| 1217 | sprintf(tmp_str, "UPDATE_AS_COPY%u", i); |
| 1218 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_update_as_copy(pUAC, tmp_str)); |
| 1219 | fprintf(pOutFile, "\"DESCRIPTORS\":slot%u -> \"%s\" [color=\"#%s\"];\n", i, tmp_str, edgeColors[colorIdx].c_str()); |
| 1220 | // Restore next ptr |
| 1221 | *ppNextPtr = pSaveNext; |
| 1222 | break; |
| 1223 | default: |
| 1224 | break; |
| 1225 | } |
| 1226 | colorIdx = (colorIdx+1) % NUM_COLORS; |
| 1227 | } |
| 1228 | } |
| 1229 | } |
| 1230 | fprintf(pOutFile, "}\n"); |
| 1231 | fprintf(pOutFile, "}\n"); |
| 1232 | } |
| 1233 | } |
| 1234 | // Dump subgraph w/ DS info |
| 1235 | static void dsDumpDot(const XGL_CMD_BUFFER cb, FILE* pOutFile) |
| 1236 | { |
| 1237 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1238 | if (pCB && pCB->lastBoundDescriptorSet) { |
| 1239 | dsCoreDumpDot(pCB->lastBoundDescriptorSet, pOutFile); |
| 1240 | } |
| 1241 | } |
| 1242 | // Dump a GraphViz dot file showing the Cmd Buffers |
| 1243 | static void cbDumpDotFile(string outFileName) |
| 1244 | { |
| 1245 | // Print CB Chain for each CB |
| 1246 | FILE* pOutFile; |
| 1247 | pOutFile = fopen(outFileName.c_str(), "w"); |
| 1248 | fprintf(pOutFile, "digraph g {\ngraph [\nrankdir = \"TB\"\n];\nnode [\nfontsize = \"16\"\nshape = \"plaintext\"\n];\nedge [\n];\n"); |
| 1249 | fprintf(pOutFile, "subgraph cluster_cmdBuffers\n{\nlabel=\"Command Buffers\"\n"); |
| 1250 | GLOBAL_CB_NODE* pCB = NULL; |
| 1251 | for (uint32_t i = 0; i < NUM_COMMAND_BUFFERS_TO_DISPLAY; i++) { |
| 1252 | pCB = g_pLastTouchedCB[i]; |
| 1253 | if (pCB) { |
| 1254 | fprintf(pOutFile, "subgraph cluster_cmdBuffer%u\n{\nlabel=\"Command Buffer #%u\"\n", i, i); |
| 1255 | uint32_t instNum = 0; |
| 1256 | for (vector<CMD_NODE*>::iterator ii=pCB->pCmds.begin(); ii!=pCB->pCmds.end(); ++ii) { |
| 1257 | if (instNum) { |
| 1258 | fprintf(pOutFile, "\"CB%pCMD%u\" -> \"CB%pCMD%u\" [];\n", (void*)pCB->cmdBuffer, instNum-1, (void*)pCB->cmdBuffer, instNum); |
| 1259 | } |
| 1260 | if (pCB == g_lastGlobalCB) { |
| 1261 | 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()); |
| 1262 | } |
| 1263 | else { |
| 1264 | 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()); |
| 1265 | } |
| 1266 | ++instNum; |
| 1267 | } |
| 1268 | fprintf(pOutFile, "}\n"); |
| 1269 | } |
| 1270 | } |
| 1271 | fprintf(pOutFile, "}\n"); |
| 1272 | fprintf(pOutFile, "}\n"); // close main graph "g" |
| 1273 | fclose(pOutFile); |
| 1274 | } |
| 1275 | // Dump a GraphViz dot file showing the pipeline for last bound global state |
| 1276 | static void dumpGlobalDotFile(char *outFileName) |
| 1277 | { |
| 1278 | PIPELINE_NODE *pPipeTrav = g_lastBoundPipeline; |
| 1279 | if (pPipeTrav) { |
| 1280 | FILE* pOutFile; |
| 1281 | pOutFile = fopen(outFileName, "w"); |
| 1282 | fprintf(pOutFile, "digraph g {\ngraph [\nrankdir = \"TB\"\n];\nnode [\nfontsize = \"16\"\nshape = \"plaintext\"\n];\nedge [\n];\n"); |
| 1283 | fprintf(pOutFile, "subgraph cluster_dynamicState\n{\nlabel=\"Dynamic State\"\n"); |
| 1284 | char* pGVstr = NULL; |
| 1285 | for (uint32_t i = 0; i < XGL_NUM_STATE_BIND_POINT; i++) { |
| 1286 | if (g_lastBoundDynamicState[i] && g_lastBoundDynamicState[i]->pCreateInfo) { |
| 1287 | pGVstr = dynamic_gv_display(g_lastBoundDynamicState[i]->pCreateInfo, string_XGL_STATE_BIND_POINT((XGL_STATE_BIND_POINT)i)); |
| 1288 | fprintf(pOutFile, "%s", pGVstr); |
| 1289 | free(pGVstr); |
| 1290 | } |
| 1291 | } |
| 1292 | fprintf(pOutFile, "}\n"); // close dynamicState subgraph |
| 1293 | fprintf(pOutFile, "subgraph cluster_PipelineStateObject\n{\nlabel=\"Pipeline State Object\"\n"); |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 1294 | pGVstr = xgl_gv_print_xgl_graphics_pipeline_create_info(&pPipeTrav->graphicsPipelineCI, "PSO HEAD"); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1295 | fprintf(pOutFile, "%s", pGVstr); |
| 1296 | free(pGVstr); |
| 1297 | fprintf(pOutFile, "}\n"); |
| 1298 | dsCoreDumpDot(g_lastBoundDescriptorSet, pOutFile); |
| 1299 | fprintf(pOutFile, "}\n"); // close main graph "g" |
| 1300 | fclose(pOutFile); |
| 1301 | } |
| 1302 | } |
| 1303 | // Dump a GraphViz dot file showing the pipeline for a given CB |
| 1304 | static void dumpDotFile(const XGL_CMD_BUFFER cb, string outFileName) |
| 1305 | { |
| 1306 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1307 | if (pCB) { |
| 1308 | PIPELINE_NODE *pPipeTrav = getPipeline(pCB->lastBoundPipeline); |
| 1309 | if (pPipeTrav) { |
| 1310 | FILE* pOutFile; |
| 1311 | pOutFile = fopen(outFileName.c_str(), "w"); |
| 1312 | fprintf(pOutFile, "digraph g {\ngraph [\nrankdir = \"TB\"\n];\nnode [\nfontsize = \"16\"\nshape = \"plaintext\"\n];\nedge [\n];\n"); |
| 1313 | fprintf(pOutFile, "subgraph cluster_dynamicState\n{\nlabel=\"Dynamic State\"\n"); |
| 1314 | char* pGVstr = NULL; |
| 1315 | for (uint32_t i = 0; i < XGL_NUM_STATE_BIND_POINT; i++) { |
| 1316 | if (pCB->lastBoundDynamicState[i] && pCB->lastBoundDynamicState[i]->pCreateInfo) { |
| 1317 | pGVstr = dynamic_gv_display(pCB->lastBoundDynamicState[i]->pCreateInfo, string_XGL_STATE_BIND_POINT((XGL_STATE_BIND_POINT)i)); |
| 1318 | fprintf(pOutFile, "%s", pGVstr); |
| 1319 | free(pGVstr); |
| 1320 | } |
| 1321 | } |
| 1322 | fprintf(pOutFile, "}\n"); // close dynamicState subgraph |
| 1323 | fprintf(pOutFile, "subgraph cluster_PipelineStateObject\n{\nlabel=\"Pipeline State Object\"\n"); |
Tobin Ehlis | cd3109e | 2015-04-01 11:59:08 -0600 | [diff] [blame] | 1324 | pGVstr = xgl_gv_print_xgl_graphics_pipeline_create_info(&pPipeTrav->graphicsPipelineCI, "PSO HEAD"); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1325 | fprintf(pOutFile, "%s", pGVstr); |
| 1326 | free(pGVstr); |
| 1327 | fprintf(pOutFile, "}\n"); |
| 1328 | dsDumpDot(cb, pOutFile); |
| 1329 | fprintf(pOutFile, "}\n"); // close main graph "g" |
| 1330 | fclose(pOutFile); |
| 1331 | } |
| 1332 | } |
| 1333 | } |
| 1334 | // Verify VB Buffer binding |
| 1335 | static void validateVBBinding(const XGL_CMD_BUFFER cb) |
| 1336 | { |
| 1337 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1338 | if (pCB && pCB->lastBoundPipeline) { |
| 1339 | // First verify that we have a Node for bound pipeline |
| 1340 | PIPELINE_NODE *pPipeTrav = getPipeline(pCB->lastBoundPipeline); |
| 1341 | char str[1024]; |
| 1342 | if (!pPipeTrav) { |
| 1343 | sprintf(str, "Can't find last bound Pipeline %p!", (void*)pCB->lastBoundPipeline); |
| 1344 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NO_PIPELINE_BOUND, "DS", str); |
| 1345 | } |
| 1346 | else { |
| 1347 | // Verify Vtx binding |
| 1348 | if (MAX_BINDING != pCB->lastVtxBinding) { |
| 1349 | if (pCB->lastVtxBinding >= pPipeTrav->vtxBindingCount) { |
| 1350 | if (0 == pPipeTrav->vtxBindingCount) { |
| 1351 | sprintf(str, "Vtx Buffer Index %u was bound, but no vtx buffers are attached to PSO.", pCB->lastVtxBinding); |
| 1352 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", str); |
| 1353 | } |
| 1354 | else { |
| 1355 | sprintf(str, "Vtx binding Index of %u exceeds PSO pVertexBindingDescriptions max array index of %u.", pCB->lastVtxBinding, (pPipeTrav->vtxBindingCount - 1)); |
| 1356 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", str); |
| 1357 | } |
| 1358 | } |
| 1359 | else { |
| 1360 | string tmpStr = xgl_print_xgl_vertex_input_binding_description(&pPipeTrav->pVertexBindingDescriptions[pCB->lastVtxBinding], "{DS}INFO : ").c_str(); |
| 1361 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmpStr.c_str()); |
| 1362 | } |
| 1363 | } |
| 1364 | } |
| 1365 | } |
| 1366 | } |
| 1367 | // Print details of DS config to stdout |
| 1368 | static void printDSConfig(const XGL_CMD_BUFFER cb) |
| 1369 | { |
| 1370 | char tmp_str[1024]; |
| 1371 | 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. |
| 1372 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1373 | if (pCB) { |
| 1374 | SET_NODE* pSet = getSetNode(pCB->lastBoundDescriptorSet); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1375 | POOL_NODE* pPool = getPoolNode(pSet->pool); |
| 1376 | // Print out pool details |
| 1377 | sprintf(tmp_str, "Details for pool %p.", (void*)pPool->pool); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1378 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1379 | string poolStr = xgl_print_xgl_descriptor_pool_create_info(&pPool->createInfo, " "); |
| 1380 | sprintf(ds_config_str, "%s", poolStr.c_str()); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1381 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str); |
| 1382 | // Print out set details |
| 1383 | char prefix[10]; |
| 1384 | uint32_t index = 0; |
| 1385 | sprintf(tmp_str, "Details for descriptor set %p.", (void*)pSet->set); |
| 1386 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1387 | LAYOUT_NODE* pLayout = pSet->pLayout; |
| 1388 | // Print layout details |
| 1389 | sprintf(tmp_str, "Layout #%u, (object %p) for DS %p.", index+1, (void*)pLayout->layout, (void*)pSet->set); |
| 1390 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str); |
| 1391 | sprintf(prefix, " [L%u] ", index); |
| 1392 | string DSLstr = xgl_print_xgl_descriptor_set_layout_create_info(&pLayout->createInfo, prefix).c_str(); |
| 1393 | sprintf(ds_config_str, "%s", DSLstr.c_str()); |
| 1394 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str); |
| 1395 | index++; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1396 | GENERIC_HEADER* pUpdate = pSet->pUpdateStructs; |
| 1397 | if (pUpdate) { |
| 1398 | sprintf(tmp_str, "Update Chain [UC] for descriptor set %p:", (void*)pSet->set); |
| 1399 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str); |
| 1400 | sprintf(prefix, " [UC] "); |
| 1401 | sprintf(ds_config_str, "%s", dynamic_display(pUpdate, prefix).c_str()); |
| 1402 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str); |
| 1403 | // TODO : If there is a "view" associated with this update, print CI for that view |
| 1404 | } |
| 1405 | else { |
| 1406 | sprintf(tmp_str, "No Update Chain for descriptor set %p (xglUpdateDescriptors has not been called)", (void*)pSet->set); |
| 1407 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str); |
| 1408 | } |
| 1409 | } |
| 1410 | } |
| 1411 | |
| 1412 | static void printCB(const XGL_CMD_BUFFER cb) |
| 1413 | { |
| 1414 | GLOBAL_CB_NODE* pCB = getCBNode(cb); |
| 1415 | if (pCB) { |
| 1416 | char str[1024]; |
| 1417 | sprintf(str, "Cmds in CB %p", (void*)cb); |
| 1418 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", str); |
| 1419 | for (vector<CMD_NODE*>::iterator ii=pCB->pCmds.begin(); ii!=pCB->pCmds.end(); ++ii) { |
| 1420 | sprintf(str, " CMD#%lu: %s", (*ii)->cmdNumber, cmdTypeToString((*ii)->type).c_str()); |
| 1421 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cb, 0, DRAWSTATE_NONE, "DS", str); |
| 1422 | } |
| 1423 | } |
| 1424 | else { |
| 1425 | // Nothing to print |
| 1426 | } |
| 1427 | } |
| 1428 | |
| 1429 | |
| 1430 | static void synchAndPrintDSConfig(const XGL_CMD_BUFFER cb) |
| 1431 | { |
| 1432 | printDSConfig(cb); |
| 1433 | printPipeline(cb); |
| 1434 | printDynamicState(cb); |
| 1435 | static int autoDumpOnce = 0; |
| 1436 | if (autoDumpOnce) { |
| 1437 | autoDumpOnce = 0; |
| 1438 | dumpDotFile(cb, "pipeline_dump.dot"); |
| 1439 | cbDumpDotFile("cb_dump.dot"); |
| 1440 | #if defined(_WIN32) |
| 1441 | // FIXME: NEED WINDOWS EQUIVALENT |
| 1442 | #else // WIN32 |
| 1443 | // Convert dot to svg if dot available |
| 1444 | if(access( "/usr/bin/dot", X_OK) != -1) { |
| 1445 | system("/usr/bin/dot pipeline_dump.dot -Tsvg -o pipeline_dump.svg"); |
| 1446 | } |
| 1447 | #endif // WIN32 |
| 1448 | } |
| 1449 | } |
| 1450 | |
| 1451 | static void initDrawState(void) |
| 1452 | { |
| 1453 | const char *strOpt; |
| 1454 | // initialize DrawState options |
| 1455 | getLayerOptionEnum("DrawStateReportLevel", (uint32_t *) &g_reportingLevel); |
| 1456 | g_actionIsDefault = getLayerOptionEnum("DrawStateDebugAction", (uint32_t *) &g_debugAction); |
| 1457 | |
| 1458 | if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) |
| 1459 | { |
| 1460 | strOpt = getLayerOption("DrawStateLogFilename"); |
| 1461 | if (strOpt) |
| 1462 | { |
| 1463 | g_logFile = fopen(strOpt, "w"); |
| 1464 | } |
| 1465 | if (g_logFile == NULL) |
| 1466 | g_logFile = stdout; |
| 1467 | } |
| 1468 | // initialize Layer dispatch table |
| 1469 | // TODO handle multiple GPUs |
| 1470 | xglGetProcAddrType fpNextGPA; |
| 1471 | fpNextGPA = pCurObj->pGPA; |
| 1472 | assert(fpNextGPA); |
| 1473 | |
| 1474 | layer_initialize_dispatch_table(&nextTable, fpNextGPA, (XGL_PHYSICAL_GPU) pCurObj->nextObject); |
| 1475 | |
| 1476 | xglGetProcAddrType fpGetProcAddr = (xglGetProcAddrType)fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (char *) "xglGetProcAddr"); |
| 1477 | nextTable.GetProcAddr = fpGetProcAddr; |
| 1478 | |
| 1479 | if (!globalLockInitialized) |
| 1480 | { |
| 1481 | // TODO/TBD: Need to delete this mutex sometime. How??? One |
| 1482 | // suggestion is to call this during xglCreateInstance(), and then we |
| 1483 | // can clean it up during xglDestroyInstance(). However, that requires |
| 1484 | // that the layer have per-instance locks. We need to come back and |
| 1485 | // address this soon. |
| 1486 | loader_platform_thread_create_mutex(&globalLock); |
| 1487 | globalLockInitialized = 1; |
| 1488 | } |
| 1489 | } |
| 1490 | |
| 1491 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreateInfo, XGL_DEVICE* pDevice) |
| 1492 | { |
| 1493 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
| 1494 | pCurObj = gpuw; |
| 1495 | loader_platform_thread_once(&g_initOnce, initDrawState); |
| 1496 | XGL_RESULT result = nextTable.CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice); |
| 1497 | return result; |
| 1498 | } |
| 1499 | |
| 1500 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyDevice(XGL_DEVICE device) |
| 1501 | { |
| 1502 | // Free all the memory |
| 1503 | loader_platform_thread_lock_mutex(&globalLock); |
| 1504 | freePipelines(); |
| 1505 | freeSamplers(); |
| 1506 | freeImages(); |
| 1507 | freeBuffers(); |
| 1508 | freeCmdBuffers(); |
| 1509 | freeDynamicState(); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1510 | freePools(); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1511 | freeLayouts(); |
| 1512 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1513 | XGL_RESULT result = nextTable.DestroyDevice(device); |
| 1514 | return result; |
| 1515 | } |
| 1516 | |
| 1517 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, size_t* pOutLayerCount, char* const* pOutLayers, void* pReserved) |
| 1518 | { |
| 1519 | if (gpu != NULL) |
| 1520 | { |
| 1521 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
| 1522 | pCurObj = gpuw; |
| 1523 | loader_platform_thread_once(&g_initOnce, initDrawState); |
| 1524 | XGL_RESULT result = nextTable.EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved); |
| 1525 | return result; |
| 1526 | } else |
| 1527 | { |
| 1528 | if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL) |
| 1529 | return XGL_ERROR_INVALID_POINTER; |
| 1530 | // This layer compatible with all GPUs |
| 1531 | *pOutLayerCount = 1; |
| 1532 | strncpy((char *) pOutLayers[0], "DrawState", maxStringSize); |
| 1533 | return XGL_SUCCESS; |
| 1534 | } |
| 1535 | } |
| 1536 | |
| 1537 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueSubmit(XGL_QUEUE queue, uint32_t cmdBufferCount, const XGL_CMD_BUFFER* pCmdBuffers, uint32_t memRefCount, const XGL_MEMORY_REF* pMemRefs, XGL_FENCE fence) |
| 1538 | { |
| 1539 | for (uint32_t i=0; i < cmdBufferCount; i++) { |
| 1540 | // Validate that cmd buffers have been updated |
| 1541 | } |
| 1542 | XGL_RESULT result = nextTable.QueueSubmit(queue, cmdBufferCount, pCmdBuffers, memRefCount, pMemRefs, fence); |
| 1543 | return result; |
| 1544 | } |
| 1545 | |
| 1546 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyObject(XGL_OBJECT object) |
| 1547 | { |
| 1548 | // TODO : When wrapped objects (such as dynamic state) are destroyed, need to clean up memory |
| 1549 | XGL_RESULT result = nextTable.DestroyObject(object); |
| 1550 | return result; |
| 1551 | } |
| 1552 | |
| 1553 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateBufferView(XGL_DEVICE device, const XGL_BUFFER_VIEW_CREATE_INFO* pCreateInfo, XGL_BUFFER_VIEW* pView) |
| 1554 | { |
| 1555 | XGL_RESULT result = nextTable.CreateBufferView(device, pCreateInfo, pView); |
| 1556 | if (XGL_SUCCESS == result) { |
| 1557 | loader_platform_thread_lock_mutex(&globalLock); |
| 1558 | BUFFER_NODE* pNewNode = new BUFFER_NODE; |
| 1559 | pNewNode->buffer = *pView; |
| 1560 | pNewNode->createInfo = *pCreateInfo; |
| 1561 | bufferMap[*pView] = pNewNode; |
| 1562 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1563 | } |
| 1564 | return result; |
| 1565 | } |
| 1566 | |
| 1567 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateImageView(XGL_DEVICE device, const XGL_IMAGE_VIEW_CREATE_INFO* pCreateInfo, XGL_IMAGE_VIEW* pView) |
| 1568 | { |
| 1569 | XGL_RESULT result = nextTable.CreateImageView(device, pCreateInfo, pView); |
| 1570 | if (XGL_SUCCESS == result) { |
| 1571 | loader_platform_thread_lock_mutex(&globalLock); |
| 1572 | IMAGE_NODE *pNewNode = new IMAGE_NODE; |
| 1573 | pNewNode->image = *pView; |
| 1574 | pNewNode->createInfo = *pCreateInfo; |
| 1575 | imageMap[*pView] = pNewNode; |
| 1576 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1577 | } |
| 1578 | return result; |
| 1579 | } |
| 1580 | |
Courtney Goeltzenleuchter | 9452ac2 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1581 | static void track_pipeline(const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo, XGL_PIPELINE* pPipeline) |
| 1582 | { |
| 1583 | PIPELINE_NODE* pPipeNode = new PIPELINE_NODE; |
| 1584 | memset((void*)pPipeNode, 0, sizeof(PIPELINE_NODE)); |
| 1585 | pPipeNode->pipeline = *pPipeline; |
| 1586 | initPipeline(pPipeNode, pCreateInfo); |
| 1587 | } |
| 1588 | |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1589 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateGraphicsPipeline(XGL_DEVICE device, const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo, XGL_PIPELINE* pPipeline) |
| 1590 | { |
| 1591 | XGL_RESULT result = nextTable.CreateGraphicsPipeline(device, pCreateInfo, pPipeline); |
| 1592 | // Create LL HEAD for this Pipeline |
| 1593 | char str[1024]; |
| 1594 | sprintf(str, "Created Gfx Pipeline %p", (void*)*pPipeline); |
| 1595 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, (XGL_BASE_OBJECT)pPipeline, 0, DRAWSTATE_NONE, "DS", str); |
| 1596 | loader_platform_thread_lock_mutex(&globalLock); |
Courtney Goeltzenleuchter | 9452ac2 | 2015-04-13 16:16:04 -0600 | [diff] [blame] | 1597 | |
| 1598 | track_pipeline(pCreateInfo, pPipeline); |
| 1599 | |
| 1600 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1601 | return result; |
| 1602 | } |
| 1603 | |
| 1604 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateGraphicsPipelineDerivative( |
| 1605 | XGL_DEVICE device, |
| 1606 | const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo, |
| 1607 | XGL_PIPELINE basePipeline, |
| 1608 | XGL_PIPELINE* pPipeline) |
| 1609 | { |
| 1610 | XGL_RESULT result = nextTable.CreateGraphicsPipelineDerivative(device, pCreateInfo, basePipeline, pPipeline); |
| 1611 | // Create LL HEAD for this Pipeline |
| 1612 | char str[1024]; |
| 1613 | sprintf(str, "Created Gfx Pipeline %p (derived from pipeline %p)", (void*)*pPipeline, basePipeline); |
| 1614 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, (XGL_BASE_OBJECT)pPipeline, 0, DRAWSTATE_NONE, "DS", str); |
| 1615 | loader_platform_thread_lock_mutex(&globalLock); |
| 1616 | |
| 1617 | track_pipeline(pCreateInfo, pPipeline); |
| 1618 | |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1619 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1620 | } |
| 1621 | |
| 1622 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateSampler(XGL_DEVICE device, const XGL_SAMPLER_CREATE_INFO* pCreateInfo, XGL_SAMPLER* pSampler) |
| 1623 | { |
| 1624 | XGL_RESULT result = nextTable.CreateSampler(device, pCreateInfo, pSampler); |
| 1625 | if (XGL_SUCCESS == result) { |
| 1626 | loader_platform_thread_lock_mutex(&globalLock); |
| 1627 | SAMPLER_NODE* pNewNode = new SAMPLER_NODE; |
| 1628 | pNewNode->sampler = *pSampler; |
| 1629 | pNewNode->createInfo = *pCreateInfo; |
| 1630 | sampleMap[*pSampler] = pNewNode; |
| 1631 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1632 | } |
| 1633 | return result; |
| 1634 | } |
| 1635 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1636 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDescriptorSetLayout(XGL_DEVICE device, const XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pCreateInfo, XGL_DESCRIPTOR_SET_LAYOUT* pSetLayout) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1637 | { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1638 | XGL_RESULT result = nextTable.CreateDescriptorSetLayout(device, pCreateInfo, pSetLayout); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1639 | if (XGL_SUCCESS == result) { |
| 1640 | LAYOUT_NODE* pNewNode = new LAYOUT_NODE; |
| 1641 | if (NULL == pNewNode) { |
| 1642 | char str[1024]; |
| 1643 | sprintf(str, "Out of memory while attempting to allocate LAYOUT_NODE in xglCreateDescriptorSetLayout()"); |
| 1644 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, *pSetLayout, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str); |
| 1645 | } |
| 1646 | memset(pNewNode, 0, sizeof(LAYOUT_NODE)); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1647 | memcpy((void*)&pNewNode->createInfo, pCreateInfo, sizeof(XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO)); |
| 1648 | pNewNode->createInfo.pBinding = new XGL_DESCRIPTOR_SET_LAYOUT_BINDING[pCreateInfo->count]; |
| 1649 | memcpy((void*)pNewNode->createInfo.pBinding, pCreateInfo->pBinding, sizeof(XGL_DESCRIPTOR_SET_LAYOUT_BINDING)*pCreateInfo->count); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1650 | uint32_t totalCount = 0; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1651 | for (uint32_t i=0; i<pCreateInfo->count; i++) { |
| 1652 | totalCount += pCreateInfo->pBinding[i].count; |
| 1653 | if (pCreateInfo->pBinding[i].pImmutableSamplers) { |
| 1654 | void** ppImmutableSamplers = (void**)&pNewNode->createInfo.pBinding[i].pImmutableSamplers; |
| 1655 | *ppImmutableSamplers = malloc(sizeof(XGL_SAMPLER)*pCreateInfo->pBinding[i].count); |
| 1656 | memcpy(*ppImmutableSamplers, pCreateInfo->pBinding[i].pImmutableSamplers, pCreateInfo->pBinding[i].count*sizeof(XGL_SAMPLER)); |
| 1657 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1658 | } |
| 1659 | if (totalCount > 0) { |
| 1660 | pNewNode->pTypes = new XGL_DESCRIPTOR_TYPE[totalCount]; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1661 | uint32_t offset = 0; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1662 | uint32_t j = 0; |
| 1663 | for (uint32_t i=0; i<pCreateInfo->count; i++) { |
| 1664 | for (j = 0; j < pCreateInfo->pBinding[i].count; j++) { |
| 1665 | pNewNode->pTypes[offset + j] = pCreateInfo->pBinding[i].descriptorType; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1666 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1667 | offset += j; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1668 | } |
| 1669 | } |
| 1670 | pNewNode->layout = *pSetLayout; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1671 | pNewNode->startIndex = 0; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1672 | pNewNode->endIndex = pNewNode->startIndex + totalCount - 1; |
| 1673 | assert(pNewNode->endIndex >= pNewNode->startIndex); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1674 | // Put new node at Head of global Layer list |
| 1675 | loader_platform_thread_lock_mutex(&globalLock); |
| 1676 | layoutMap[*pSetLayout] = pNewNode; |
| 1677 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1678 | } |
| 1679 | return result; |
| 1680 | } |
| 1681 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1682 | XGL_RESULT XGLAPI xglCreateDescriptorSetLayoutChain(XGL_DEVICE device, uint32_t setLayoutArrayCount, const XGL_DESCRIPTOR_SET_LAYOUT* pSetLayoutArray, XGL_DESCRIPTOR_SET_LAYOUT_CHAIN* pLayoutChain) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1683 | { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1684 | XGL_RESULT result = nextTable.CreateDescriptorSetLayoutChain(device, setLayoutArrayCount, pSetLayoutArray, pLayoutChain); |
| 1685 | if (XGL_SUCCESS == result) { |
| 1686 | // TODO : Need to capture the layout chains |
| 1687 | } |
| 1688 | return result; |
| 1689 | } |
| 1690 | |
| 1691 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBeginDescriptorPoolUpdate(XGL_DEVICE device, XGL_DESCRIPTOR_UPDATE_MODE updateMode) |
| 1692 | { |
| 1693 | XGL_RESULT result = nextTable.BeginDescriptorPoolUpdate(device, updateMode); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1694 | if (XGL_SUCCESS == result) { |
| 1695 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1696 | POOL_NODE* pPoolNode = poolMap.begin()->second; |
| 1697 | if (!pPoolNode) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1698 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1699 | sprintf(str, "Unable to find pool node"); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1700 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_INTERNAL_ERROR, "DS", str); |
| 1701 | } |
| 1702 | else { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1703 | pPoolNode->updateActive = 1; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1704 | } |
| 1705 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1706 | } |
| 1707 | return result; |
| 1708 | } |
| 1709 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1710 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEndDescriptorPoolUpdate(XGL_DEVICE device, XGL_CMD_BUFFER cmd) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1711 | { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1712 | XGL_RESULT result = nextTable.EndDescriptorPoolUpdate(device, cmd); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1713 | if (XGL_SUCCESS == result) { |
| 1714 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1715 | POOL_NODE* pPoolNode = poolMap.begin()->second; |
| 1716 | if (!pPoolNode) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1717 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1718 | sprintf(str, "Unable to find pool node"); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1719 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_INTERNAL_ERROR, "DS", str); |
| 1720 | } |
| 1721 | else { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1722 | if (!pPoolNode->updateActive) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1723 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1724 | sprintf(str, "You must call xglBeginDescriptorPoolUpdate() before this call to xglEndDescriptorPoolUpdate()!"); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1725 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_DS_END_WITHOUT_BEGIN, "DS", str); |
| 1726 | } |
| 1727 | else { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1728 | pPoolNode->updateActive = 0; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1729 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1730 | pPoolNode->updateActive = 0; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1731 | } |
| 1732 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1733 | } |
| 1734 | return result; |
| 1735 | } |
| 1736 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1737 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDescriptorPool(XGL_DEVICE device, XGL_DESCRIPTOR_POOL_USAGE poolUsage, uint32_t maxSets, const XGL_DESCRIPTOR_POOL_CREATE_INFO* pCreateInfo, XGL_DESCRIPTOR_POOL* pDescriptorPool) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1738 | { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1739 | XGL_RESULT result = nextTable.CreateDescriptorPool(device, poolUsage, maxSets, pCreateInfo, pDescriptorPool); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1740 | if (XGL_SUCCESS == result) { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1741 | // Insert this pool into Global Pool LL at head |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1742 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1743 | sprintf(str, "Created Descriptor Pool %p", (void*)*pDescriptorPool); |
| 1744 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, (XGL_BASE_OBJECT)pDescriptorPool, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1745 | loader_platform_thread_lock_mutex(&globalLock); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1746 | POOL_NODE* pNewNode = new POOL_NODE; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1747 | if (NULL == pNewNode) { |
| 1748 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1749 | sprintf(str, "Out of memory while attempting to allocate POOL_NODE in xglCreateDescriptorPool()"); |
| 1750 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, (XGL_BASE_OBJECT)*pDescriptorPool, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1751 | } |
| 1752 | else { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1753 | memset(pNewNode, 0, sizeof(POOL_NODE)); |
| 1754 | XGL_DESCRIPTOR_POOL_CREATE_INFO* pCI = (XGL_DESCRIPTOR_POOL_CREATE_INFO*)&pNewNode->createInfo; |
| 1755 | memcpy((void*)pCI, pCreateInfo, sizeof(XGL_DESCRIPTOR_POOL_CREATE_INFO)); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1756 | if (pNewNode->createInfo.count) { |
| 1757 | size_t typeCountSize = pNewNode->createInfo.count * sizeof(XGL_DESCRIPTOR_TYPE_COUNT); |
| 1758 | pNewNode->createInfo.pTypeCount = new XGL_DESCRIPTOR_TYPE_COUNT[typeCountSize]; |
| 1759 | memcpy((void*)pNewNode->createInfo.pTypeCount, pCreateInfo->pTypeCount, typeCountSize); |
| 1760 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1761 | pNewNode->poolUsage = poolUsage; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1762 | pNewNode->updateActive = 0; |
| 1763 | pNewNode->maxSets = maxSets; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1764 | pNewNode->pool = *pDescriptorPool; |
| 1765 | poolMap[*pDescriptorPool] = pNewNode; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1766 | } |
| 1767 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1768 | } |
| 1769 | else { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1770 | // Need to do anything if pool create fails? |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1771 | } |
| 1772 | return result; |
| 1773 | } |
| 1774 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1775 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglResetDescriptorPool(XGL_DESCRIPTOR_POOL descriptorPool) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1776 | { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1777 | XGL_RESULT result = nextTable.ResetDescriptorPool(descriptorPool); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1778 | if (XGL_SUCCESS == result) { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1779 | clearDescriptorPool(descriptorPool); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1780 | } |
| 1781 | return result; |
| 1782 | } |
| 1783 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1784 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglAllocDescriptorSets(XGL_DESCRIPTOR_POOL descriptorPool, XGL_DESCRIPTOR_SET_USAGE setUsage, uint32_t count, const XGL_DESCRIPTOR_SET_LAYOUT* pSetLayouts, XGL_DESCRIPTOR_SET* pDescriptorSets, uint32_t* pCount) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1785 | { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1786 | XGL_RESULT result = nextTable.AllocDescriptorSets(descriptorPool, setUsage, count, pSetLayouts, pDescriptorSets, pCount); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1787 | if ((XGL_SUCCESS == result) || (*pCount > 0)) { |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1788 | POOL_NODE *pPoolNode = getPoolNode(descriptorPool); |
| 1789 | if (!pPoolNode) { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1790 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1791 | sprintf(str, "Unable to find pool node for pool %p specified in xglAllocDescriptorSets() call", (void*)descriptorPool); |
| 1792 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorPool, 0, DRAWSTATE_INVALID_POOL, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1793 | } |
| 1794 | else { |
| 1795 | for (uint32_t i = 0; i < *pCount; i++) { |
| 1796 | char str[1024]; |
| 1797 | sprintf(str, "Created Descriptor Set %p", (void*)pDescriptorSets[i]); |
| 1798 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1799 | // Create new set node and add to head of pool nodes |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1800 | SET_NODE* pNewNode = new SET_NODE; |
| 1801 | if (NULL == pNewNode) { |
| 1802 | char str[1024]; |
| 1803 | sprintf(str, "Out of memory while attempting to allocate SET_NODE in xglAllocDescriptorSets()"); |
| 1804 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str); |
| 1805 | } |
| 1806 | else { |
| 1807 | memset(pNewNode, 0, sizeof(SET_NODE)); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1808 | // Insert set at head of Set LL for this pool |
| 1809 | pNewNode->pNext = pPoolNode->pSets; |
| 1810 | pPoolNode->pSets = pNewNode; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1811 | LAYOUT_NODE* pLayout = getLayoutNode(pSetLayouts[i]); |
| 1812 | if (NULL == pLayout) { |
| 1813 | char str[1024]; |
| 1814 | sprintf(str, "Unable to find set layout node for layout %p specified in xglAllocDescriptorSets() call", (void*)pSetLayouts[i]); |
| 1815 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pSetLayouts[i], 0, DRAWSTATE_INVALID_LAYOUT, "DS", str); |
| 1816 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1817 | pNewNode->pLayout = pLayout; |
| 1818 | pNewNode->pool = descriptorPool; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1819 | pNewNode->set = pDescriptorSets[i]; |
| 1820 | pNewNode->setUsage = setUsage; |
| 1821 | pNewNode->descriptorCount = pLayout->endIndex + 1; |
| 1822 | if (pNewNode->descriptorCount) { |
| 1823 | size_t descriptorArraySize = sizeof(GENERIC_HEADER*)*pNewNode->descriptorCount; |
| 1824 | pNewNode->ppDescriptors = new GENERIC_HEADER*[descriptorArraySize]; |
| 1825 | memset(pNewNode->ppDescriptors, 0, descriptorArraySize); |
| 1826 | } |
| 1827 | setMap[pDescriptorSets[i]] = pNewNode; |
| 1828 | } |
| 1829 | } |
| 1830 | } |
| 1831 | } |
| 1832 | return result; |
| 1833 | } |
| 1834 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1835 | XGL_LAYER_EXPORT void XGLAPI xglClearDescriptorSets(XGL_DESCRIPTOR_POOL descriptorPool, uint32_t count, const XGL_DESCRIPTOR_SET* pDescriptorSets) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1836 | { |
| 1837 | for (uint32_t i = 0; i < count; i++) { |
| 1838 | clearDescriptorSet(pDescriptorSets[i]); |
| 1839 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1840 | nextTable.ClearDescriptorSets(descriptorPool, count, pDescriptorSets); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1841 | } |
| 1842 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1843 | XGL_LAYER_EXPORT void XGLAPI xglUpdateDescriptors(XGL_DESCRIPTOR_SET descriptorSet, uint32_t updateCount, const void** ppUpdateArray) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1844 | { |
| 1845 | SET_NODE* pSet = getSetNode(descriptorSet); |
| 1846 | if (!dsUpdateActive(descriptorSet)) { |
| 1847 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1848 | sprintf(str, "You must call xglBeginDescriptorPoolUpdate() before this call to xglUpdateDescriptors()!"); |
| 1849 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pSet->pool, 0, DRAWSTATE_UPDATE_WITHOUT_BEGIN, "DS", str); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1850 | } |
| 1851 | else { |
| 1852 | // pUpdateChain is a Linked-list of XGL_UPDATE_* structures defining the mappings for the descriptors |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1853 | dsUpdate(descriptorSet, updateCount, ppUpdateArray); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1854 | } |
| 1855 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1856 | nextTable.UpdateDescriptors(descriptorSet, updateCount, ppUpdateArray); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1857 | } |
| 1858 | |
| 1859 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicViewportState(XGL_DEVICE device, const XGL_DYNAMIC_VP_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_VP_STATE_OBJECT* pState) |
| 1860 | { |
| 1861 | XGL_RESULT result = nextTable.CreateDynamicViewportState(device, pCreateInfo, pState); |
| 1862 | insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, XGL_STATE_BIND_VIEWPORT); |
| 1863 | return result; |
| 1864 | } |
| 1865 | |
| 1866 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicRasterState(XGL_DEVICE device, const XGL_DYNAMIC_RS_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_RS_STATE_OBJECT* pState) |
| 1867 | { |
| 1868 | XGL_RESULT result = nextTable.CreateDynamicRasterState(device, pCreateInfo, pState); |
| 1869 | insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, XGL_STATE_BIND_RASTER); |
| 1870 | return result; |
| 1871 | } |
| 1872 | |
| 1873 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicColorBlendState(XGL_DEVICE device, const XGL_DYNAMIC_CB_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_CB_STATE_OBJECT* pState) |
| 1874 | { |
| 1875 | XGL_RESULT result = nextTable.CreateDynamicColorBlendState(device, pCreateInfo, pState); |
| 1876 | insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, XGL_STATE_BIND_COLOR_BLEND); |
| 1877 | return result; |
| 1878 | } |
| 1879 | |
| 1880 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicDepthStencilState(XGL_DEVICE device, const XGL_DYNAMIC_DS_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_DS_STATE_OBJECT* pState) |
| 1881 | { |
| 1882 | XGL_RESULT result = nextTable.CreateDynamicDepthStencilState(device, pCreateInfo, pState); |
| 1883 | insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, XGL_STATE_BIND_DEPTH_STENCIL); |
| 1884 | return result; |
| 1885 | } |
| 1886 | |
| 1887 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateCommandBuffer(XGL_DEVICE device, const XGL_CMD_BUFFER_CREATE_INFO* pCreateInfo, XGL_CMD_BUFFER* pCmdBuffer) |
| 1888 | { |
| 1889 | XGL_RESULT result = nextTable.CreateCommandBuffer(device, pCreateInfo, pCmdBuffer); |
| 1890 | if (XGL_SUCCESS == result) { |
| 1891 | loader_platform_thread_lock_mutex(&globalLock); |
| 1892 | GLOBAL_CB_NODE* pCB = new GLOBAL_CB_NODE; |
| 1893 | memset(pCB, 0, sizeof(GLOBAL_CB_NODE)); |
| 1894 | pCB->cmdBuffer = *pCmdBuffer; |
| 1895 | pCB->flags = pCreateInfo->flags; |
Courtney Goeltzenleuchter | f316806 | 2015-03-05 18:09:39 -0700 | [diff] [blame] | 1896 | pCB->queueNodeIndex = pCreateInfo->queueNodeIndex; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1897 | pCB->lastVtxBinding = MAX_BINDING; |
| 1898 | cmdBufferMap[*pCmdBuffer] = pCB; |
| 1899 | loader_platform_thread_unlock_mutex(&globalLock); |
| 1900 | updateCBTracking(*pCmdBuffer); |
| 1901 | } |
| 1902 | return result; |
| 1903 | } |
| 1904 | |
| 1905 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBeginCommandBuffer(XGL_CMD_BUFFER cmdBuffer, const XGL_CMD_BUFFER_BEGIN_INFO* pBeginInfo) |
| 1906 | { |
| 1907 | XGL_RESULT result = nextTable.BeginCommandBuffer(cmdBuffer, pBeginInfo); |
| 1908 | if (XGL_SUCCESS == result) { |
| 1909 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 1910 | if (pCB) { |
| 1911 | if (CB_NEW != pCB->state) |
| 1912 | resetCB(cmdBuffer); |
| 1913 | pCB->state = CB_UPDATE_ACTIVE; |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 1914 | if (pBeginInfo->pNext) { |
| 1915 | XGL_CMD_BUFFER_GRAPHICS_BEGIN_INFO* pCbGfxBI = (XGL_CMD_BUFFER_GRAPHICS_BEGIN_INFO*)pBeginInfo->pNext; |
| 1916 | if (XGL_STRUCTURE_TYPE_CMD_BUFFER_GRAPHICS_BEGIN_INFO == pCbGfxBI->sType) { |
Courtney Goeltzenleuchter | e3b0f3a | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 1917 | pCB->activeRenderPass = pCbGfxBI->renderPassContinue.renderPass; |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 1918 | } |
| 1919 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1920 | } |
| 1921 | else { |
| 1922 | char str[1024]; |
| 1923 | sprintf(str, "In xglBeginCommandBuffer() and unable to find CmdBuffer Node for CB %p!", (void*)cmdBuffer); |
| 1924 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 1925 | } |
| 1926 | updateCBTracking(cmdBuffer); |
| 1927 | } |
| 1928 | return result; |
| 1929 | } |
| 1930 | |
| 1931 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEndCommandBuffer(XGL_CMD_BUFFER cmdBuffer) |
| 1932 | { |
| 1933 | XGL_RESULT result = nextTable.EndCommandBuffer(cmdBuffer); |
| 1934 | if (XGL_SUCCESS == result) { |
| 1935 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 1936 | if (pCB) { |
| 1937 | pCB->state = CB_UPDATE_COMPLETE; |
| 1938 | printCB(cmdBuffer); |
| 1939 | } |
| 1940 | else { |
| 1941 | char str[1024]; |
| 1942 | sprintf(str, "In xglEndCommandBuffer() and unable to find CmdBuffer Node for CB %p!", (void*)cmdBuffer); |
| 1943 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 1944 | } |
| 1945 | updateCBTracking(cmdBuffer); |
| 1946 | //cbDumpDotFile("cb_dump.dot"); |
| 1947 | } |
| 1948 | return result; |
| 1949 | } |
| 1950 | |
| 1951 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglResetCommandBuffer(XGL_CMD_BUFFER cmdBuffer) |
| 1952 | { |
| 1953 | XGL_RESULT result = nextTable.ResetCommandBuffer(cmdBuffer); |
| 1954 | if (XGL_SUCCESS == result) { |
| 1955 | resetCB(cmdBuffer); |
| 1956 | updateCBTracking(cmdBuffer); |
| 1957 | } |
| 1958 | return result; |
| 1959 | } |
| 1960 | |
| 1961 | XGL_LAYER_EXPORT void XGLAPI xglCmdBindPipeline(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE pipeline) |
| 1962 | { |
| 1963 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 1964 | if (pCB) { |
| 1965 | updateCBTracking(cmdBuffer); |
| 1966 | addCmd(pCB, CMD_BINDPIPELINE); |
| 1967 | PIPELINE_NODE* pPN = getPipeline(pipeline); |
| 1968 | if (pPN) { |
| 1969 | pCB->lastBoundPipeline = pipeline; |
| 1970 | loader_platform_thread_lock_mutex(&globalLock); |
| 1971 | g_lastBoundPipeline = pPN; |
| 1972 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 1973 | validatePipelineState(pCB, pipelineBindPoint, pipeline); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1974 | } |
| 1975 | else { |
| 1976 | char str[1024]; |
| 1977 | sprintf(str, "Attempt to bind Pipeline %p that doesn't exist!", (void*)pipeline); |
| 1978 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pipeline, 0, DRAWSTATE_INVALID_PIPELINE, "DS", str); |
| 1979 | } |
| 1980 | } |
| 1981 | else { |
| 1982 | char str[1024]; |
| 1983 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 1984 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 1985 | } |
| 1986 | nextTable.CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline); |
| 1987 | } |
| 1988 | |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1989 | XGL_LAYER_EXPORT void XGLAPI xglCmdBindDynamicStateObject(XGL_CMD_BUFFER cmdBuffer, XGL_STATE_BIND_POINT stateBindPoint, XGL_DYNAMIC_STATE_OBJECT state) |
| 1990 | { |
| 1991 | setLastBoundDynamicState(cmdBuffer, state, stateBindPoint); |
| 1992 | nextTable.CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state); |
| 1993 | } |
| 1994 | |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 1995 | XGL_LAYER_EXPORT void XGLAPI xglCmdBindDescriptorSets(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_DESCRIPTOR_SET_LAYOUT_CHAIN layoutChain, uint32_t layoutChainSlot, uint32_t count, const XGL_DESCRIPTOR_SET* pDescriptorSets, const uint32_t* pUserData) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 1996 | { |
| 1997 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 1998 | if (pCB) { |
| 1999 | updateCBTracking(cmdBuffer); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2000 | addCmd(pCB, CMD_BINDDESCRIPTORSETS); |
| 2001 | for (uint32_t i=0; i<count; i++) { |
| 2002 | if (getSetNode(pDescriptorSets[i])) { |
| 2003 | if (dsUpdateActive(pDescriptorSets[i])) { |
| 2004 | // TODO : This check here needs to be made at QueueSubmit time |
| 2005 | /* |
| 2006 | char str[1024]; |
| 2007 | sprintf(str, "You must call xglEndDescriptorPoolUpdate(%p) before this call to xglCmdBindDescriptorSet()!", (void*)descriptorSet); |
| 2008 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_BINDING_DS_NO_END_UPDATE, "DS", str); |
| 2009 | */ |
| 2010 | } |
| 2011 | loader_platform_thread_lock_mutex(&globalLock); |
| 2012 | pCB->lastBoundDescriptorSet = pDescriptorSets[i]; |
| 2013 | g_lastBoundDescriptorSet = pDescriptorSets[i]; |
| 2014 | loader_platform_thread_unlock_mutex(&globalLock); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2015 | char str[1024]; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2016 | sprintf(str, "DS %p bound on pipeline %s", (void*)pDescriptorSets[i], string_XGL_PIPELINE_BIND_POINT(pipelineBindPoint)); |
| 2017 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_NONE, "DS", str); |
| 2018 | synchAndPrintDSConfig(cmdBuffer); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2019 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2020 | else { |
| 2021 | char str[1024]; |
| 2022 | sprintf(str, "Attempt to bind DS %p that doesn't exist!", (void*)pDescriptorSets[i]); |
| 2023 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_INVALID_SET, "DS", str); |
| 2024 | } |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2025 | } |
| 2026 | } |
| 2027 | else { |
| 2028 | char str[1024]; |
| 2029 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2030 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2031 | } |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2032 | nextTable.CmdBindDescriptorSets(cmdBuffer, pipelineBindPoint, layoutChain, layoutChainSlot, count, pDescriptorSets, pUserData); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2033 | } |
| 2034 | |
| 2035 | XGL_LAYER_EXPORT void XGLAPI xglCmdBindIndexBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, XGL_INDEX_TYPE indexType) |
| 2036 | { |
| 2037 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2038 | if (pCB) { |
| 2039 | updateCBTracking(cmdBuffer); |
| 2040 | addCmd(pCB, CMD_BINDINDEXBUFFER); |
| 2041 | // TODO : Track idxBuffer binding |
| 2042 | } |
| 2043 | else { |
| 2044 | char str[1024]; |
| 2045 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2046 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2047 | } |
| 2048 | nextTable.CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType); |
| 2049 | } |
| 2050 | |
| 2051 | XGL_LAYER_EXPORT void XGLAPI xglCmdBindVertexBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, uint32_t binding) |
| 2052 | { |
| 2053 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2054 | if (pCB) { |
| 2055 | updateCBTracking(cmdBuffer); |
| 2056 | addCmd(pCB, CMD_BINDVERTEXBUFFER); |
| 2057 | pCB->lastVtxBinding = binding; |
| 2058 | validateVBBinding(cmdBuffer); |
| 2059 | } |
| 2060 | else { |
| 2061 | char str[1024]; |
| 2062 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2063 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2064 | } |
| 2065 | nextTable.CmdBindVertexBuffer(cmdBuffer, buffer, offset, binding); |
| 2066 | } |
| 2067 | |
| 2068 | XGL_LAYER_EXPORT void XGLAPI xglCmdDraw(XGL_CMD_BUFFER cmdBuffer, uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount) |
| 2069 | { |
| 2070 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2071 | if (pCB) { |
| 2072 | updateCBTracking(cmdBuffer); |
| 2073 | addCmd(pCB, CMD_DRAW); |
| 2074 | pCB->drawCount[DRAW]++; |
| 2075 | char str[1024]; |
| 2076 | sprintf(str, "xglCmdDraw() call #%lu, reporting DS state:", g_drawCount[DRAW]++); |
| 2077 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str); |
| 2078 | synchAndPrintDSConfig(cmdBuffer); |
| 2079 | } |
| 2080 | else { |
| 2081 | char str[1024]; |
| 2082 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2083 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2084 | } |
| 2085 | nextTable.CmdDraw(cmdBuffer, firstVertex, vertexCount, firstInstance, instanceCount); |
| 2086 | } |
| 2087 | |
| 2088 | XGL_LAYER_EXPORT void XGLAPI xglCmdDrawIndexed(XGL_CMD_BUFFER cmdBuffer, uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount) |
| 2089 | { |
| 2090 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2091 | if (pCB) { |
| 2092 | updateCBTracking(cmdBuffer); |
| 2093 | addCmd(pCB, CMD_DRAWINDEXED); |
| 2094 | pCB->drawCount[DRAW_INDEXED]++; |
| 2095 | char str[1024]; |
| 2096 | sprintf(str, "xglCmdDrawIndexed() call #%lu, reporting DS state:", g_drawCount[DRAW_INDEXED]++); |
| 2097 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str); |
| 2098 | synchAndPrintDSConfig(cmdBuffer); |
| 2099 | } |
| 2100 | else { |
| 2101 | char str[1024]; |
| 2102 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2103 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2104 | } |
| 2105 | nextTable.CmdDrawIndexed(cmdBuffer, firstIndex, indexCount, vertexOffset, firstInstance, instanceCount); |
| 2106 | } |
| 2107 | |
| 2108 | XGL_LAYER_EXPORT void XGLAPI xglCmdDrawIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, uint32_t count, uint32_t stride) |
| 2109 | { |
| 2110 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2111 | if (pCB) { |
| 2112 | updateCBTracking(cmdBuffer); |
| 2113 | addCmd(pCB, CMD_DRAWINDIRECT); |
| 2114 | pCB->drawCount[DRAW_INDIRECT]++; |
| 2115 | char str[1024]; |
| 2116 | sprintf(str, "xglCmdDrawIndirect() call #%lu, reporting DS state:", g_drawCount[DRAW_INDIRECT]++); |
| 2117 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str); |
| 2118 | synchAndPrintDSConfig(cmdBuffer); |
| 2119 | } |
| 2120 | else { |
| 2121 | char str[1024]; |
| 2122 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2123 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2124 | } |
| 2125 | nextTable.CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride); |
| 2126 | } |
| 2127 | |
| 2128 | XGL_LAYER_EXPORT void XGLAPI xglCmdDrawIndexedIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, uint32_t count, uint32_t stride) |
| 2129 | { |
| 2130 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2131 | if (pCB) { |
| 2132 | updateCBTracking(cmdBuffer); |
| 2133 | addCmd(pCB, CMD_DRAWINDEXEDINDIRECT); |
| 2134 | pCB->drawCount[DRAW_INDEXED_INDIRECT]++; |
| 2135 | char str[1024]; |
| 2136 | sprintf(str, "xglCmdDrawIndexedIndirect() call #%lu, reporting DS state:", g_drawCount[DRAW_INDEXED_INDIRECT]++); |
| 2137 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str); |
| 2138 | synchAndPrintDSConfig(cmdBuffer); |
| 2139 | } |
| 2140 | else { |
| 2141 | char str[1024]; |
| 2142 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2143 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2144 | } |
| 2145 | nextTable.CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride); |
| 2146 | } |
| 2147 | |
| 2148 | XGL_LAYER_EXPORT void XGLAPI xglCmdDispatch(XGL_CMD_BUFFER cmdBuffer, uint32_t x, uint32_t y, uint32_t z) |
| 2149 | { |
| 2150 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2151 | if (pCB) { |
| 2152 | updateCBTracking(cmdBuffer); |
| 2153 | addCmd(pCB, CMD_DISPATCH); |
| 2154 | } |
| 2155 | else { |
| 2156 | char str[1024]; |
| 2157 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2158 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2159 | } |
| 2160 | nextTable.CmdDispatch(cmdBuffer, x, y, z); |
| 2161 | } |
| 2162 | |
| 2163 | XGL_LAYER_EXPORT void XGLAPI xglCmdDispatchIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset) |
| 2164 | { |
| 2165 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2166 | if (pCB) { |
| 2167 | updateCBTracking(cmdBuffer); |
| 2168 | addCmd(pCB, CMD_DISPATCHINDIRECT); |
| 2169 | } |
| 2170 | else { |
| 2171 | char str[1024]; |
| 2172 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2173 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2174 | } |
| 2175 | nextTable.CmdDispatchIndirect(cmdBuffer, buffer, offset); |
| 2176 | } |
| 2177 | |
| 2178 | XGL_LAYER_EXPORT void XGLAPI xglCmdCopyBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER srcBuffer, XGL_BUFFER destBuffer, uint32_t regionCount, const XGL_BUFFER_COPY* pRegions) |
| 2179 | { |
| 2180 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2181 | if (pCB) { |
| 2182 | updateCBTracking(cmdBuffer); |
| 2183 | addCmd(pCB, CMD_COPYBUFFER); |
| 2184 | } |
| 2185 | else { |
| 2186 | char str[1024]; |
| 2187 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2188 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2189 | } |
| 2190 | nextTable.CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions); |
| 2191 | } |
| 2192 | |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2193 | XGL_LAYER_EXPORT void XGLAPI xglCmdCopyImage( |
| 2194 | XGL_CMD_BUFFER cmdBuffer, |
| 2195 | XGL_IMAGE srcImage, XGL_IMAGE_LAYOUT srcImageLayout, |
| 2196 | XGL_IMAGE destImage, XGL_IMAGE_LAYOUT destImageLayout, |
| 2197 | uint32_t regionCount, const XGL_IMAGE_COPY* pRegions) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2198 | { |
| 2199 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2200 | if (pCB) { |
| 2201 | updateCBTracking(cmdBuffer); |
| 2202 | addCmd(pCB, CMD_COPYIMAGE); |
| 2203 | } |
| 2204 | else { |
| 2205 | char str[1024]; |
| 2206 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2207 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2208 | } |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2209 | nextTable.CmdCopyImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2210 | } |
| 2211 | |
Courtney Goeltzenleuchter | 6ff8ebc | 2015-04-03 14:42:51 -0600 | [diff] [blame] | 2212 | XGL_LAYER_EXPORT void XGLAPI xglCmdBlitImage(XGL_CMD_BUFFER cmdBuffer, |
| 2213 | XGL_IMAGE srcImage, XGL_IMAGE_LAYOUT srcImageLayout, |
| 2214 | XGL_IMAGE destImage, XGL_IMAGE_LAYOUT destImageLayout, |
| 2215 | uint32_t regionCount, const XGL_IMAGE_BLIT* pRegions) |
| 2216 | { |
| 2217 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2218 | if (pCB) { |
| 2219 | updateCBTracking(cmdBuffer); |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2220 | addCmd(pCB, CMD_BLITIMAGE); |
Courtney Goeltzenleuchter | 6ff8ebc | 2015-04-03 14:42:51 -0600 | [diff] [blame] | 2221 | } |
| 2222 | else { |
| 2223 | char str[1024]; |
| 2224 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2225 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2226 | } |
| 2227 | nextTable.CmdBlitImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, regionCount, pRegions); |
| 2228 | } |
| 2229 | |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2230 | XGL_LAYER_EXPORT void XGLAPI xglCmdCopyBufferToImage( |
| 2231 | XGL_CMD_BUFFER cmdBuffer, |
| 2232 | XGL_BUFFER srcBuffer, |
| 2233 | XGL_IMAGE destImage, XGL_IMAGE_LAYOUT destImageLayout, |
| 2234 | uint32_t regionCount, const XGL_BUFFER_IMAGE_COPY* pRegions) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2235 | { |
| 2236 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2237 | if (pCB) { |
| 2238 | updateCBTracking(cmdBuffer); |
| 2239 | addCmd(pCB, CMD_COPYBUFFERTOIMAGE); |
| 2240 | } |
| 2241 | else { |
| 2242 | char str[1024]; |
| 2243 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2244 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2245 | } |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2246 | nextTable.CmdCopyBufferToImage(cmdBuffer, srcBuffer, destImage, destImageLayout, regionCount, pRegions); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2247 | } |
| 2248 | |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2249 | XGL_LAYER_EXPORT void XGLAPI xglCmdCopyImageToBuffer( |
| 2250 | XGL_CMD_BUFFER cmdBuffer, |
| 2251 | XGL_IMAGE srcImage, XGL_IMAGE_LAYOUT srcImageLayout, |
| 2252 | XGL_BUFFER destBuffer, |
| 2253 | uint32_t regionCount, const XGL_BUFFER_IMAGE_COPY* pRegions) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2254 | { |
| 2255 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2256 | if (pCB) { |
| 2257 | updateCBTracking(cmdBuffer); |
| 2258 | addCmd(pCB, CMD_COPYIMAGETOBUFFER); |
| 2259 | } |
| 2260 | else { |
| 2261 | char str[1024]; |
| 2262 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2263 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2264 | } |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2265 | nextTable.CmdCopyImageToBuffer(cmdBuffer, srcImage, srcImageLayout, destBuffer, regionCount, pRegions); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2266 | } |
| 2267 | |
| 2268 | XGL_LAYER_EXPORT void XGLAPI xglCmdCloneImageData(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_IMAGE_LAYOUT srcImageLayout, XGL_IMAGE destImage, XGL_IMAGE_LAYOUT destImageLayout) |
| 2269 | { |
| 2270 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2271 | if (pCB) { |
| 2272 | updateCBTracking(cmdBuffer); |
| 2273 | addCmd(pCB, CMD_CLONEIMAGEDATA); |
| 2274 | } |
| 2275 | else { |
| 2276 | char str[1024]; |
| 2277 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2278 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2279 | } |
| 2280 | nextTable.CmdCloneImageData(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout); |
| 2281 | } |
| 2282 | |
| 2283 | XGL_LAYER_EXPORT void XGLAPI xglCmdUpdateBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER destBuffer, XGL_GPU_SIZE destOffset, XGL_GPU_SIZE dataSize, const uint32_t* pData) |
| 2284 | { |
| 2285 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2286 | if (pCB) { |
| 2287 | updateCBTracking(cmdBuffer); |
| 2288 | addCmd(pCB, CMD_UPDATEBUFFER); |
| 2289 | } |
| 2290 | else { |
| 2291 | char str[1024]; |
| 2292 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2293 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2294 | } |
| 2295 | nextTable.CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData); |
| 2296 | } |
| 2297 | |
| 2298 | XGL_LAYER_EXPORT void XGLAPI xglCmdFillBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER destBuffer, XGL_GPU_SIZE destOffset, XGL_GPU_SIZE fillSize, uint32_t data) |
| 2299 | { |
| 2300 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2301 | if (pCB) { |
| 2302 | updateCBTracking(cmdBuffer); |
| 2303 | addCmd(pCB, CMD_FILLBUFFER); |
| 2304 | } |
| 2305 | else { |
| 2306 | char str[1024]; |
| 2307 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2308 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2309 | } |
| 2310 | nextTable.CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data); |
| 2311 | } |
| 2312 | |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2313 | XGL_LAYER_EXPORT void XGLAPI xglCmdClearColorImage( |
| 2314 | XGL_CMD_BUFFER cmdBuffer, |
| 2315 | XGL_IMAGE image, XGL_IMAGE_LAYOUT imageLayout, |
| 2316 | XGL_CLEAR_COLOR color, |
| 2317 | uint32_t rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2318 | { |
| 2319 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2320 | if (pCB) { |
| 2321 | updateCBTracking(cmdBuffer); |
| 2322 | addCmd(pCB, CMD_CLEARCOLORIMAGE); |
| 2323 | } |
| 2324 | else { |
| 2325 | char str[1024]; |
| 2326 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2327 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2328 | } |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2329 | nextTable.CmdClearColorImage(cmdBuffer, image, imageLayout, color, rangeCount, pRanges); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2330 | } |
| 2331 | |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2332 | XGL_LAYER_EXPORT void XGLAPI xglCmdClearDepthStencil( |
| 2333 | XGL_CMD_BUFFER cmdBuffer, |
| 2334 | XGL_IMAGE image, XGL_IMAGE_LAYOUT imageLayout, |
| 2335 | float depth, uint32_t stencil, |
| 2336 | uint32_t rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2337 | { |
| 2338 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2339 | if (pCB) { |
| 2340 | updateCBTracking(cmdBuffer); |
| 2341 | addCmd(pCB, CMD_CLEARDEPTHSTENCIL); |
| 2342 | } |
| 2343 | else { |
| 2344 | char str[1024]; |
| 2345 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2346 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2347 | } |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2348 | nextTable.CmdClearDepthStencil(cmdBuffer, image, imageLayout, depth, stencil, rangeCount, pRanges); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2349 | } |
| 2350 | |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2351 | XGL_LAYER_EXPORT void XGLAPI xglCmdResolveImage( |
| 2352 | XGL_CMD_BUFFER cmdBuffer, |
| 2353 | XGL_IMAGE srcImage, XGL_IMAGE_LAYOUT srcImageLayout, |
| 2354 | XGL_IMAGE destImage, XGL_IMAGE_LAYOUT destImageLayout, |
| 2355 | uint32_t rectCount, const XGL_IMAGE_RESOLVE* pRects) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2356 | { |
| 2357 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2358 | if (pCB) { |
| 2359 | updateCBTracking(cmdBuffer); |
| 2360 | addCmd(pCB, CMD_RESOLVEIMAGE); |
| 2361 | } |
| 2362 | else { |
| 2363 | char str[1024]; |
| 2364 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2365 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2366 | } |
Courtney Goeltzenleuchter | 4533484 | 2015-04-13 16:16:56 -0600 | [diff] [blame] | 2367 | nextTable.CmdResolveImage(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout, rectCount, pRects); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2368 | } |
| 2369 | |
Courtney Goeltzenleuchter | aa86e0e | 2015-03-24 18:02:34 -0600 | [diff] [blame] | 2370 | XGL_LAYER_EXPORT void XGLAPI xglCmdSetEvent(XGL_CMD_BUFFER cmdBuffer, XGL_EVENT event, XGL_PIPE_EVENT pipeEvent) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2371 | { |
| 2372 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2373 | if (pCB) { |
| 2374 | updateCBTracking(cmdBuffer); |
| 2375 | addCmd(pCB, CMD_SETEVENT); |
| 2376 | } |
| 2377 | else { |
| 2378 | char str[1024]; |
| 2379 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2380 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2381 | } |
| 2382 | nextTable.CmdSetEvent(cmdBuffer, event, pipeEvent); |
| 2383 | } |
| 2384 | |
Courtney Goeltzenleuchter | aa86e0e | 2015-03-24 18:02:34 -0600 | [diff] [blame] | 2385 | XGL_LAYER_EXPORT void XGLAPI xglCmdResetEvent(XGL_CMD_BUFFER cmdBuffer, XGL_EVENT event, XGL_PIPE_EVENT pipeEvent) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2386 | { |
| 2387 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2388 | if (pCB) { |
| 2389 | updateCBTracking(cmdBuffer); |
| 2390 | addCmd(pCB, CMD_RESETEVENT); |
| 2391 | } |
| 2392 | else { |
| 2393 | char str[1024]; |
| 2394 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2395 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2396 | } |
Courtney Goeltzenleuchter | aa86e0e | 2015-03-24 18:02:34 -0600 | [diff] [blame] | 2397 | nextTable.CmdResetEvent(cmdBuffer, event, pipeEvent); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2398 | } |
| 2399 | |
| 2400 | XGL_LAYER_EXPORT void XGLAPI xglCmdWaitEvents(XGL_CMD_BUFFER cmdBuffer, const XGL_EVENT_WAIT_INFO* pWaitInfo) |
| 2401 | { |
| 2402 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2403 | if (pCB) { |
| 2404 | updateCBTracking(cmdBuffer); |
| 2405 | addCmd(pCB, CMD_WAITEVENTS); |
| 2406 | } |
| 2407 | else { |
| 2408 | char str[1024]; |
| 2409 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2410 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2411 | } |
| 2412 | nextTable.CmdWaitEvents(cmdBuffer, pWaitInfo); |
| 2413 | } |
| 2414 | |
| 2415 | XGL_LAYER_EXPORT void XGLAPI xglCmdPipelineBarrier(XGL_CMD_BUFFER cmdBuffer, const XGL_PIPELINE_BARRIER* pBarrier) |
| 2416 | { |
| 2417 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2418 | if (pCB) { |
| 2419 | updateCBTracking(cmdBuffer); |
| 2420 | addCmd(pCB, CMD_PIPELINEBARRIER); |
| 2421 | } |
| 2422 | else { |
| 2423 | char str[1024]; |
| 2424 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2425 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2426 | } |
| 2427 | nextTable.CmdPipelineBarrier(cmdBuffer, pBarrier); |
| 2428 | } |
| 2429 | |
| 2430 | XGL_LAYER_EXPORT void XGLAPI xglCmdBeginQuery(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, uint32_t slot, XGL_FLAGS flags) |
| 2431 | { |
| 2432 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2433 | if (pCB) { |
| 2434 | updateCBTracking(cmdBuffer); |
| 2435 | addCmd(pCB, CMD_BEGINQUERY); |
| 2436 | } |
| 2437 | else { |
| 2438 | char str[1024]; |
| 2439 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2440 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2441 | } |
| 2442 | nextTable.CmdBeginQuery(cmdBuffer, queryPool, slot, flags); |
| 2443 | } |
| 2444 | |
| 2445 | XGL_LAYER_EXPORT void XGLAPI xglCmdEndQuery(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, uint32_t slot) |
| 2446 | { |
| 2447 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2448 | if (pCB) { |
| 2449 | updateCBTracking(cmdBuffer); |
| 2450 | addCmd(pCB, CMD_ENDQUERY); |
| 2451 | } |
| 2452 | else { |
| 2453 | char str[1024]; |
| 2454 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2455 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2456 | } |
| 2457 | nextTable.CmdEndQuery(cmdBuffer, queryPool, slot); |
| 2458 | } |
| 2459 | |
| 2460 | XGL_LAYER_EXPORT void XGLAPI xglCmdResetQueryPool(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, uint32_t startQuery, uint32_t queryCount) |
| 2461 | { |
| 2462 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2463 | if (pCB) { |
| 2464 | updateCBTracking(cmdBuffer); |
| 2465 | addCmd(pCB, CMD_RESETQUERYPOOL); |
| 2466 | } |
| 2467 | else { |
| 2468 | char str[1024]; |
| 2469 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2470 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2471 | } |
| 2472 | nextTable.CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount); |
| 2473 | } |
| 2474 | |
| 2475 | XGL_LAYER_EXPORT void XGLAPI xglCmdWriteTimestamp(XGL_CMD_BUFFER cmdBuffer, XGL_TIMESTAMP_TYPE timestampType, XGL_BUFFER destBuffer, XGL_GPU_SIZE destOffset) |
| 2476 | { |
| 2477 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2478 | if (pCB) { |
| 2479 | updateCBTracking(cmdBuffer); |
| 2480 | addCmd(pCB, CMD_WRITETIMESTAMP); |
| 2481 | } |
| 2482 | else { |
| 2483 | char str[1024]; |
| 2484 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2485 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2486 | } |
| 2487 | nextTable.CmdWriteTimestamp(cmdBuffer, timestampType, destBuffer, destOffset); |
| 2488 | } |
| 2489 | |
| 2490 | XGL_LAYER_EXPORT void XGLAPI xglCmdInitAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, const uint32_t* pData) |
| 2491 | { |
| 2492 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2493 | if (pCB) { |
| 2494 | updateCBTracking(cmdBuffer); |
| 2495 | addCmd(pCB, CMD_INITATOMICCOUNTERS); |
| 2496 | } |
| 2497 | else { |
| 2498 | char str[1024]; |
| 2499 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2500 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2501 | } |
| 2502 | nextTable.CmdInitAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData); |
| 2503 | } |
| 2504 | |
| 2505 | XGL_LAYER_EXPORT void XGLAPI xglCmdLoadAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, XGL_BUFFER srcBuffer, XGL_GPU_SIZE srcOffset) |
| 2506 | { |
| 2507 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2508 | if (pCB) { |
| 2509 | updateCBTracking(cmdBuffer); |
| 2510 | addCmd(pCB, CMD_LOADATOMICCOUNTERS); |
| 2511 | } |
| 2512 | else { |
| 2513 | char str[1024]; |
| 2514 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2515 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2516 | } |
| 2517 | nextTable.CmdLoadAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, srcBuffer, srcOffset); |
| 2518 | } |
| 2519 | |
| 2520 | XGL_LAYER_EXPORT void XGLAPI xglCmdSaveAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, XGL_BUFFER destBuffer, XGL_GPU_SIZE destOffset) |
| 2521 | { |
| 2522 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2523 | if (pCB) { |
| 2524 | updateCBTracking(cmdBuffer); |
| 2525 | addCmd(pCB, CMD_SAVEATOMICCOUNTERS); |
| 2526 | } |
| 2527 | else { |
| 2528 | char str[1024]; |
| 2529 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2530 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2531 | } |
| 2532 | nextTable.CmdSaveAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, destBuffer, destOffset); |
| 2533 | } |
| 2534 | |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2535 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateFramebuffer(XGL_DEVICE device, const XGL_FRAMEBUFFER_CREATE_INFO* pCreateInfo, XGL_FRAMEBUFFER* pFramebuffer) |
| 2536 | { |
| 2537 | XGL_RESULT result = nextTable.CreateFramebuffer(device, pCreateInfo, pFramebuffer); |
| 2538 | if (XGL_SUCCESS == result) { |
| 2539 | // Shadow create info and store in map |
| 2540 | XGL_FRAMEBUFFER_CREATE_INFO* localFBCI = new XGL_FRAMEBUFFER_CREATE_INFO(*pCreateInfo); |
| 2541 | if (pCreateInfo->pColorAttachments) { |
| 2542 | localFBCI->pColorAttachments = new XGL_COLOR_ATTACHMENT_BIND_INFO[localFBCI->colorAttachmentCount]; |
| 2543 | memcpy((void*)localFBCI->pColorAttachments, pCreateInfo->pColorAttachments, localFBCI->colorAttachmentCount*sizeof(XGL_COLOR_ATTACHMENT_BIND_INFO)); |
| 2544 | } |
| 2545 | if (pCreateInfo->pDepthStencilAttachment) { |
| 2546 | localFBCI->pDepthStencilAttachment = new XGL_DEPTH_STENCIL_BIND_INFO[localFBCI->colorAttachmentCount]; |
| 2547 | memcpy((void*)localFBCI->pDepthStencilAttachment, pCreateInfo->pDepthStencilAttachment, localFBCI->colorAttachmentCount*sizeof(XGL_DEPTH_STENCIL_BIND_INFO)); |
| 2548 | } |
| 2549 | frameBufferMap[*pFramebuffer] = localFBCI; |
| 2550 | } |
| 2551 | return result; |
| 2552 | } |
| 2553 | |
| 2554 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateRenderPass(XGL_DEVICE device, const XGL_RENDER_PASS_CREATE_INFO* pCreateInfo, XGL_RENDER_PASS* pRenderPass) |
| 2555 | { |
| 2556 | XGL_RESULT result = nextTable.CreateRenderPass(device, pCreateInfo, pRenderPass); |
| 2557 | if (XGL_SUCCESS == result) { |
| 2558 | // Shadow create info and store in map |
| 2559 | XGL_RENDER_PASS_CREATE_INFO* localRPCI = new XGL_RENDER_PASS_CREATE_INFO(*pCreateInfo); |
| 2560 | if (pCreateInfo->pColorLoadOps) { |
| 2561 | localRPCI->pColorLoadOps = new XGL_ATTACHMENT_LOAD_OP[localRPCI->colorAttachmentCount]; |
| 2562 | memcpy((void*)localRPCI->pColorLoadOps, pCreateInfo->pColorLoadOps, localRPCI->colorAttachmentCount*sizeof(XGL_ATTACHMENT_LOAD_OP)); |
| 2563 | } |
| 2564 | if (pCreateInfo->pColorStoreOps) { |
| 2565 | localRPCI->pColorStoreOps = new XGL_ATTACHMENT_STORE_OP[localRPCI->colorAttachmentCount]; |
| 2566 | memcpy((void*)localRPCI->pColorStoreOps, pCreateInfo->pColorStoreOps, localRPCI->colorAttachmentCount*sizeof(XGL_ATTACHMENT_STORE_OP)); |
| 2567 | } |
| 2568 | if (pCreateInfo->pColorLoadClearValues) { |
| 2569 | localRPCI->pColorLoadClearValues = new XGL_CLEAR_COLOR[localRPCI->colorAttachmentCount]; |
| 2570 | memcpy((void*)localRPCI->pColorLoadClearValues, pCreateInfo->pColorLoadClearValues, localRPCI->colorAttachmentCount*sizeof(XGL_CLEAR_COLOR)); |
| 2571 | } |
| 2572 | renderPassMap[*pRenderPass] = localRPCI; |
| 2573 | } |
| 2574 | return result; |
| 2575 | } |
| 2576 | |
Courtney Goeltzenleuchter | e3b0f3a | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 2577 | XGL_LAYER_EXPORT void XGLAPI xglCmdBeginRenderPass(XGL_CMD_BUFFER cmdBuffer, const XGL_RENDER_PASS_BEGIN *pRenderPassBegin) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2578 | { |
| 2579 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2580 | if (pCB) { |
| 2581 | updateCBTracking(cmdBuffer); |
| 2582 | addCmd(pCB, CMD_BEGINRENDERPASS); |
Courtney Goeltzenleuchter | e3b0f3a | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 2583 | pCB->activeRenderPass = pRenderPassBegin->renderPass; |
| 2584 | pCB->framebuffer = pRenderPassBegin->framebuffer; |
Tony Barbour | 1f81bb4 | 2015-04-06 11:00:38 -0600 | [diff] [blame^] | 2585 | if (pCB->lastBoundPipeline) |
| 2586 | validatePipelineState(pCB, XGL_PIPELINE_BIND_POINT_GRAPHICS, pCB->lastBoundPipeline); |
Courtney Goeltzenleuchter | e3b0f3a | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 2587 | } else { |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2588 | char str[1024]; |
| 2589 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2590 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2591 | } |
Courtney Goeltzenleuchter | e3b0f3a | 2015-04-03 15:25:24 -0600 | [diff] [blame] | 2592 | nextTable.CmdBeginRenderPass(cmdBuffer, pRenderPassBegin); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2593 | } |
| 2594 | |
| 2595 | XGL_LAYER_EXPORT void XGLAPI xglCmdEndRenderPass(XGL_CMD_BUFFER cmdBuffer, XGL_RENDER_PASS renderPass) |
| 2596 | { |
| 2597 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2598 | if (pCB) { |
| 2599 | updateCBTracking(cmdBuffer); |
| 2600 | addCmd(pCB, CMD_ENDRENDERPASS); |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2601 | pCB->activeRenderPass = 0; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2602 | } |
| 2603 | else { |
| 2604 | char str[1024]; |
| 2605 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2606 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2607 | } |
| 2608 | nextTable.CmdEndRenderPass(cmdBuffer, renderPass); |
| 2609 | } |
| 2610 | |
Courtney Goeltzenleuchter | 9d36ef4 | 2015-04-13 14:10:06 -0600 | [diff] [blame] | 2611 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgRegisterMsgCallback(XGL_INSTANCE instance, XGL_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, void* pUserData) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2612 | { |
| 2613 | // This layer intercepts callbacks |
| 2614 | XGL_LAYER_DBG_FUNCTION_NODE* pNewDbgFuncNode = (XGL_LAYER_DBG_FUNCTION_NODE*)malloc(sizeof(XGL_LAYER_DBG_FUNCTION_NODE)); |
| 2615 | #if ALLOC_DEBUG |
| 2616 | printf("Alloc34 #%lu pNewDbgFuncNode addr(%p)\n", ++g_alloc_count, (void*)pNewDbgFuncNode); |
| 2617 | #endif |
| 2618 | if (!pNewDbgFuncNode) |
| 2619 | return XGL_ERROR_OUT_OF_MEMORY; |
| 2620 | pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback; |
| 2621 | pNewDbgFuncNode->pUserData = pUserData; |
| 2622 | pNewDbgFuncNode->pNext = g_pDbgFunctionHead; |
| 2623 | g_pDbgFunctionHead = pNewDbgFuncNode; |
| 2624 | // force callbacks if DebugAction hasn't been set already other than initial value |
| 2625 | if (g_actionIsDefault) { |
| 2626 | g_debugAction = XGL_DBG_LAYER_ACTION_CALLBACK; |
| 2627 | } |
Courtney Goeltzenleuchter | 9d36ef4 | 2015-04-13 14:10:06 -0600 | [diff] [blame] | 2628 | XGL_RESULT result = nextTable.DbgRegisterMsgCallback(instance, pfnMsgCallback, pUserData); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2629 | return result; |
| 2630 | } |
| 2631 | |
Courtney Goeltzenleuchter | 9d36ef4 | 2015-04-13 14:10:06 -0600 | [diff] [blame] | 2632 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgUnregisterMsgCallback(XGL_INSTANCE instance, XGL_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback) |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2633 | { |
| 2634 | XGL_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead; |
| 2635 | XGL_LAYER_DBG_FUNCTION_NODE *pPrev = pTrav; |
| 2636 | while (pTrav) { |
| 2637 | if (pTrav->pfnMsgCallback == pfnMsgCallback) { |
| 2638 | pPrev->pNext = pTrav->pNext; |
| 2639 | if (g_pDbgFunctionHead == pTrav) |
| 2640 | g_pDbgFunctionHead = pTrav->pNext; |
| 2641 | #if ALLOC_DEBUG |
| 2642 | printf("Free34 #%lu pNewDbgFuncNode addr(%p)\n", ++g_alloc_count, (void*)pTrav); |
| 2643 | #endif |
| 2644 | free(pTrav); |
| 2645 | break; |
| 2646 | } |
| 2647 | pPrev = pTrav; |
| 2648 | pTrav = pTrav->pNext; |
| 2649 | } |
| 2650 | if (g_pDbgFunctionHead == NULL) |
| 2651 | { |
| 2652 | if (g_actionIsDefault) |
| 2653 | g_debugAction = XGL_DBG_LAYER_ACTION_LOG_MSG; |
| 2654 | else |
| 2655 | g_debugAction = (XGL_LAYER_DBG_ACTION)(g_debugAction & ~((uint32_t)XGL_DBG_LAYER_ACTION_CALLBACK)); |
| 2656 | } |
Courtney Goeltzenleuchter | 9d36ef4 | 2015-04-13 14:10:06 -0600 | [diff] [blame] | 2657 | XGL_RESULT result = nextTable.DbgUnregisterMsgCallback(instance, pfnMsgCallback); |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2658 | return result; |
| 2659 | } |
| 2660 | |
| 2661 | XGL_LAYER_EXPORT void XGLAPI xglCmdDbgMarkerBegin(XGL_CMD_BUFFER cmdBuffer, const char* pMarker) |
| 2662 | { |
| 2663 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2664 | if (pCB) { |
| 2665 | updateCBTracking(cmdBuffer); |
| 2666 | addCmd(pCB, CMD_DBGMARKERBEGIN); |
| 2667 | } |
| 2668 | else { |
| 2669 | char str[1024]; |
| 2670 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2671 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2672 | } |
| 2673 | nextTable.CmdDbgMarkerBegin(cmdBuffer, pMarker); |
| 2674 | } |
| 2675 | |
| 2676 | XGL_LAYER_EXPORT void XGLAPI xglCmdDbgMarkerEnd(XGL_CMD_BUFFER cmdBuffer) |
| 2677 | { |
| 2678 | GLOBAL_CB_NODE* pCB = getCBNode(cmdBuffer); |
| 2679 | if (pCB) { |
| 2680 | updateCBTracking(cmdBuffer); |
| 2681 | addCmd(pCB, CMD_DBGMARKEREND); |
| 2682 | } |
| 2683 | else { |
| 2684 | char str[1024]; |
| 2685 | sprintf(str, "Attempt to use CmdBuffer %p that doesn't exist!", (void*)cmdBuffer); |
| 2686 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_INVALID_CMD_BUFFER, "DS", str); |
| 2687 | } |
| 2688 | nextTable.CmdDbgMarkerEnd(cmdBuffer); |
| 2689 | } |
| 2690 | |
| 2691 | // TODO : Want to pass in a cmdBuffer here based on which state to display |
| 2692 | void drawStateDumpDotFile(char* outFileName) |
| 2693 | { |
| 2694 | // TODO : Currently just setting cmdBuffer based on global var |
| 2695 | //dumpDotFile(g_lastDrawStateCmdBuffer, outFileName); |
| 2696 | dumpGlobalDotFile(outFileName); |
| 2697 | } |
| 2698 | |
| 2699 | void drawStateDumpCommandBufferDotFile(char* outFileName) |
| 2700 | { |
| 2701 | cbDumpDotFile(outFileName); |
| 2702 | } |
| 2703 | |
| 2704 | void drawStateDumpPngFile(char* outFileName) |
| 2705 | { |
| 2706 | #if defined(_WIN32) |
| 2707 | // FIXME: NEED WINDOWS EQUIVALENT |
| 2708 | char str[1024]; |
| 2709 | sprintf(str, "Cannot execute dot program yet on Windows."); |
| 2710 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_MISSING_DOT_PROGRAM, "DS", str); |
| 2711 | #else // WIN32 |
| 2712 | char dotExe[32] = "/usr/bin/dot"; |
| 2713 | if( access(dotExe, X_OK) != -1) { |
| 2714 | dumpDotFile(g_lastCmdBuffer[getTIDIndex()], "/tmp/tmp.dot"); |
| 2715 | char dotCmd[1024]; |
| 2716 | sprintf(dotCmd, "%s /tmp/tmp.dot -Tpng -o %s", dotExe, outFileName); |
| 2717 | system(dotCmd); |
| 2718 | remove("/tmp/tmp.dot"); |
| 2719 | } |
| 2720 | else { |
| 2721 | char str[1024]; |
| 2722 | sprintf(str, "Cannot execute dot program at (%s) to dump requested %s file.", dotExe, outFileName); |
| 2723 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_MISSING_DOT_PROGRAM, "DS", str); |
| 2724 | } |
| 2725 | #endif // WIN32 |
| 2726 | } |
| 2727 | |
| 2728 | XGL_LAYER_EXPORT void* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char* funcName) |
| 2729 | { |
| 2730 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
| 2731 | |
| 2732 | if (gpu == NULL) |
| 2733 | return NULL; |
| 2734 | pCurObj = gpuw; |
| 2735 | loader_platform_thread_once(&g_initOnce, initDrawState); |
| 2736 | |
| 2737 | if (!strcmp(funcName, "xglGetProcAddr")) |
| 2738 | return (void *) xglGetProcAddr; |
| 2739 | if (!strcmp(funcName, "xglCreateDevice")) |
| 2740 | return (void*) xglCreateDevice; |
| 2741 | if (!strcmp(funcName, "xglDestroyDevice")) |
| 2742 | return (void*) xglDestroyDevice; |
| 2743 | if (!strcmp(funcName, "xglEnumerateLayers")) |
| 2744 | return (void*) xglEnumerateLayers; |
| 2745 | if (!strcmp(funcName, "xglQueueSubmit")) |
| 2746 | return (void*) xglQueueSubmit; |
| 2747 | if (!strcmp(funcName, "xglDestroyObject")) |
| 2748 | return (void*) xglDestroyObject; |
| 2749 | if (!strcmp(funcName, "xglCreateBufferView")) |
| 2750 | return (void*) xglCreateBufferView; |
| 2751 | if (!strcmp(funcName, "xglCreateImageView")) |
| 2752 | return (void*) xglCreateImageView; |
| 2753 | if (!strcmp(funcName, "xglCreateGraphicsPipeline")) |
| 2754 | return (void*) xglCreateGraphicsPipeline; |
Tobin Ehlis | e19e7ed | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2755 | if (!strcmp(funcName, "xglCreateGraphicsPipelineDerivative")) |
| 2756 | return (void*) xglCreateGraphicsPipelineDerivative; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2757 | if (!strcmp(funcName, "xglCreateSampler")) |
| 2758 | return (void*) xglCreateSampler; |
| 2759 | if (!strcmp(funcName, "xglCreateDescriptorSetLayout")) |
| 2760 | return (void*) xglCreateDescriptorSetLayout; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2761 | if (!strcmp(funcName, "xglCreateDescriptorSetLayoutChain")) |
| 2762 | return (void*) xglCreateDescriptorSetLayoutChain; |
| 2763 | if (!strcmp(funcName, "xglBeginDescriptorPoolUpdate")) |
| 2764 | return (void*) xglBeginDescriptorPoolUpdate; |
| 2765 | if (!strcmp(funcName, "xglEndDescriptorPoolUpdate")) |
| 2766 | return (void*) xglEndDescriptorPoolUpdate; |
| 2767 | if (!strcmp(funcName, "xglCreateDescriptorPool")) |
| 2768 | return (void*) xglCreateDescriptorPool; |
| 2769 | if (!strcmp(funcName, "xglResetDescriptorPool")) |
| 2770 | return (void*) xglResetDescriptorPool; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2771 | if (!strcmp(funcName, "xglAllocDescriptorSets")) |
| 2772 | return (void*) xglAllocDescriptorSets; |
| 2773 | if (!strcmp(funcName, "xglClearDescriptorSets")) |
| 2774 | return (void*) xglClearDescriptorSets; |
| 2775 | if (!strcmp(funcName, "xglUpdateDescriptors")) |
| 2776 | return (void*) xglUpdateDescriptors; |
| 2777 | if (!strcmp(funcName, "xglCreateDynamicViewportState")) |
| 2778 | return (void*) xglCreateDynamicViewportState; |
| 2779 | if (!strcmp(funcName, "xglCreateDynamicRasterState")) |
| 2780 | return (void*) xglCreateDynamicRasterState; |
| 2781 | if (!strcmp(funcName, "xglCreateDynamicColorBlendState")) |
| 2782 | return (void*) xglCreateDynamicColorBlendState; |
| 2783 | if (!strcmp(funcName, "xglCreateDynamicDepthStencilState")) |
| 2784 | return (void*) xglCreateDynamicDepthStencilState; |
| 2785 | if (!strcmp(funcName, "xglCreateCommandBuffer")) |
| 2786 | return (void*) xglCreateCommandBuffer; |
| 2787 | if (!strcmp(funcName, "xglBeginCommandBuffer")) |
| 2788 | return (void*) xglBeginCommandBuffer; |
| 2789 | if (!strcmp(funcName, "xglEndCommandBuffer")) |
| 2790 | return (void*) xglEndCommandBuffer; |
| 2791 | if (!strcmp(funcName, "xglResetCommandBuffer")) |
| 2792 | return (void*) xglResetCommandBuffer; |
| 2793 | if (!strcmp(funcName, "xglCmdBindPipeline")) |
| 2794 | return (void*) xglCmdBindPipeline; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2795 | if (!strcmp(funcName, "xglCmdBindDynamicStateObject")) |
| 2796 | return (void*) xglCmdBindDynamicStateObject; |
Tobin Ehlis | dd82f6b | 2015-04-03 12:01:11 -0600 | [diff] [blame] | 2797 | if (!strcmp(funcName, "xglCmdBindDescriptorSets")) |
| 2798 | return (void*) xglCmdBindDescriptorSets; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2799 | if (!strcmp(funcName, "xglCmdBindVertexBuffer")) |
| 2800 | return (void*) xglCmdBindVertexBuffer; |
| 2801 | if (!strcmp(funcName, "xglCmdBindIndexBuffer")) |
| 2802 | return (void*) xglCmdBindIndexBuffer; |
| 2803 | if (!strcmp(funcName, "xglCmdDraw")) |
| 2804 | return (void*) xglCmdDraw; |
| 2805 | if (!strcmp(funcName, "xglCmdDrawIndexed")) |
| 2806 | return (void*) xglCmdDrawIndexed; |
| 2807 | if (!strcmp(funcName, "xglCmdDrawIndirect")) |
| 2808 | return (void*) xglCmdDrawIndirect; |
| 2809 | if (!strcmp(funcName, "xglCmdDrawIndexedIndirect")) |
| 2810 | return (void*) xglCmdDrawIndexedIndirect; |
| 2811 | if (!strcmp(funcName, "xglCmdDispatch")) |
| 2812 | return (void*) xglCmdDispatch; |
| 2813 | if (!strcmp(funcName, "xglCmdDispatchIndirect")) |
| 2814 | return (void*) xglCmdDispatchIndirect; |
| 2815 | if (!strcmp(funcName, "xglCmdCopyBuffer")) |
| 2816 | return (void*) xglCmdCopyBuffer; |
| 2817 | if (!strcmp(funcName, "xglCmdCopyImage")) |
| 2818 | return (void*) xglCmdCopyImage; |
| 2819 | if (!strcmp(funcName, "xglCmdCopyBufferToImage")) |
| 2820 | return (void*) xglCmdCopyBufferToImage; |
| 2821 | if (!strcmp(funcName, "xglCmdCopyImageToBuffer")) |
| 2822 | return (void*) xglCmdCopyImageToBuffer; |
| 2823 | if (!strcmp(funcName, "xglCmdCloneImageData")) |
| 2824 | return (void*) xglCmdCloneImageData; |
| 2825 | if (!strcmp(funcName, "xglCmdUpdateBuffer")) |
| 2826 | return (void*) xglCmdUpdateBuffer; |
| 2827 | if (!strcmp(funcName, "xglCmdFillBuffer")) |
| 2828 | return (void*) xglCmdFillBuffer; |
| 2829 | if (!strcmp(funcName, "xglCmdClearColorImage")) |
| 2830 | return (void*) xglCmdClearColorImage; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2831 | if (!strcmp(funcName, "xglCmdClearDepthStencil")) |
| 2832 | return (void*) xglCmdClearDepthStencil; |
| 2833 | if (!strcmp(funcName, "xglCmdResolveImage")) |
| 2834 | return (void*) xglCmdResolveImage; |
| 2835 | if (!strcmp(funcName, "xglCmdSetEvent")) |
| 2836 | return (void*) xglCmdSetEvent; |
| 2837 | if (!strcmp(funcName, "xglCmdResetEvent")) |
| 2838 | return (void*) xglCmdResetEvent; |
| 2839 | if (!strcmp(funcName, "xglCmdWaitEvents")) |
| 2840 | return (void*) xglCmdWaitEvents; |
| 2841 | if (!strcmp(funcName, "xglCmdPipelineBarrier")) |
| 2842 | return (void*) xglCmdPipelineBarrier; |
| 2843 | if (!strcmp(funcName, "xglCmdBeginQuery")) |
| 2844 | return (void*) xglCmdBeginQuery; |
| 2845 | if (!strcmp(funcName, "xglCmdEndQuery")) |
| 2846 | return (void*) xglCmdEndQuery; |
| 2847 | if (!strcmp(funcName, "xglCmdResetQueryPool")) |
| 2848 | return (void*) xglCmdResetQueryPool; |
| 2849 | if (!strcmp(funcName, "xglCmdWriteTimestamp")) |
| 2850 | return (void*) xglCmdWriteTimestamp; |
| 2851 | if (!strcmp(funcName, "xglCmdInitAtomicCounters")) |
| 2852 | return (void*) xglCmdInitAtomicCounters; |
| 2853 | if (!strcmp(funcName, "xglCmdLoadAtomicCounters")) |
| 2854 | return (void*) xglCmdLoadAtomicCounters; |
| 2855 | if (!strcmp(funcName, "xglCmdSaveAtomicCounters")) |
| 2856 | return (void*) xglCmdSaveAtomicCounters; |
Tobin Ehlis | 2464b88 | 2015-04-01 08:40:34 -0600 | [diff] [blame] | 2857 | if (!strcmp(funcName, "xglCreateFramebuffer")) |
| 2858 | return (void*) xglCreateFramebuffer; |
| 2859 | if (!strcmp(funcName, "xglCreateRenderPass")) |
| 2860 | return (void*) xglCreateRenderPass; |
Tobin Ehlis | 63bb948 | 2015-03-17 16:24:32 -0600 | [diff] [blame] | 2861 | if (!strcmp(funcName, "xglCmdBeginRenderPass")) |
| 2862 | return (void*) xglCmdBeginRenderPass; |
| 2863 | if (!strcmp(funcName, "xglCmdEndRenderPass")) |
| 2864 | return (void*) xglCmdEndRenderPass; |
| 2865 | if (!strcmp(funcName, "xglDbgRegisterMsgCallback")) |
| 2866 | return (void*) xglDbgRegisterMsgCallback; |
| 2867 | if (!strcmp(funcName, "xglDbgUnregisterMsgCallback")) |
| 2868 | return (void*) xglDbgUnregisterMsgCallback; |
| 2869 | if (!strcmp(funcName, "xglCmdDbgMarkerBegin")) |
| 2870 | return (void*) xglCmdDbgMarkerBegin; |
| 2871 | if (!strcmp(funcName, "xglCmdDbgMarkerEnd")) |
| 2872 | return (void*) xglCmdDbgMarkerEnd; |
| 2873 | if (!strcmp("drawStateDumpDotFile", funcName)) |
| 2874 | return (void*) drawStateDumpDotFile; |
| 2875 | if (!strcmp("drawStateDumpCommandBufferDotFile", funcName)) |
| 2876 | return (void*) drawStateDumpCommandBufferDotFile; |
| 2877 | if (!strcmp("drawStateDumpPngFile", funcName)) |
| 2878 | return (void*) drawStateDumpPngFile; |
| 2879 | else { |
| 2880 | if (gpuw->pGPA == NULL) |
| 2881 | return NULL; |
| 2882 | return gpuw->pGPA((XGL_PHYSICAL_GPU)gpuw->nextObject, funcName); |
| 2883 | } |
| 2884 | } |