Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -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 <assert.h> |
| 29 | #include <pthread.h> |
Tobin Ehlis | 266473d | 2014-12-16 17:34:50 -0700 | [diff] [blame] | 30 | #include <unistd.h> |
Chia-I Wu | 0f65b1e | 2015-01-04 23:11:43 +0800 | [diff] [blame] | 31 | #include "xgl_dispatch_table_helper.h" |
Chia-I Wu | 706533e | 2015-01-05 13:18:57 +0800 | [diff] [blame] | 32 | #include "xgl_generic_intercept_proc_helper.h" |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 33 | #include "xgl_struct_string_helper.h" |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 34 | #include "xgl_struct_graphviz_helper.h" |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 35 | #include "draw_state.h" |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 36 | #include "layers_config.h" |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 37 | |
| 38 | static XGL_LAYER_DISPATCH_TABLE nextTable; |
| 39 | static XGL_BASE_LAYER_OBJECT *pCurObj; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 40 | static pthread_once_t g_initOnce = PTHREAD_ONCE_INIT; |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 41 | // Could be smarter about locking with unique locks for various tasks, but just using one for now |
| 42 | pthread_mutex_t globalLock = PTHREAD_MUTEX_INITIALIZER; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 43 | |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 44 | // Ptr to LL of dbg functions |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 45 | static XGL_LAYER_DBG_FUNCTION_NODE *g_pDbgFunctionHead = NULL; |
Tobin Ehlis | 5b7acaa | 2015-01-08 14:26:53 -0700 | [diff] [blame] | 46 | static XGL_LAYER_DBG_REPORT_LEVEL g_reportingLevel = XGL_DBG_LAYER_LEVEL_INFO; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 47 | static XGL_LAYER_DBG_ACTION g_debugAction = XGL_DBG_LAYER_ACTION_LOG_MSG; |
| 48 | static FILE *g_logFile = NULL; |
| 49 | |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 50 | // Utility function to handle reporting |
| 51 | // If callbacks are enabled, use them, otherwise use printf |
| 52 | static XGL_VOID layerCbMsg(XGL_DBG_MSG_TYPE msgType, |
| 53 | XGL_VALIDATION_LEVEL validationLevel, |
| 54 | XGL_BASE_OBJECT srcObject, |
| 55 | XGL_SIZE location, |
| 56 | XGL_INT msgCode, |
Chia-I Wu | a837c52 | 2014-12-16 10:47:33 +0800 | [diff] [blame] | 57 | const char* pLayerPrefix, |
| 58 | const char* pMsg) |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 59 | { |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 60 | if (g_debugAction & (XGL_DBG_LAYER_ACTION_LOG_MSG | XGL_DBG_LAYER_ACTION_CALLBACK)) { |
| 61 | XGL_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead; |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 62 | switch (msgType) { |
| 63 | case XGL_DBG_MSG_ERROR: |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 64 | if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_ERROR) { |
| 65 | if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) |
| 66 | fprintf(g_logFile, "{%s}ERROR : %s\n", pLayerPrefix, pMsg); |
| 67 | if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK) |
| 68 | while (pTrav) { |
| 69 | pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData); |
| 70 | pTrav = pTrav->pNext; |
| 71 | } |
| 72 | } |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 73 | break; |
| 74 | case XGL_DBG_MSG_WARNING: |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 75 | if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_WARN) { |
| 76 | if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) |
| 77 | fprintf(g_logFile, "{%s}WARN : %s\n", pLayerPrefix, pMsg); |
| 78 | if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK) |
| 79 | while (pTrav) { |
| 80 | pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData); |
| 81 | pTrav = pTrav->pNext; |
| 82 | } |
| 83 | } |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 84 | break; |
| 85 | case XGL_DBG_MSG_PERF_WARNING: |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 86 | if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_PERF_WARN) { |
| 87 | if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) |
| 88 | fprintf(g_logFile, "{%s}PERF_WARN : %s\n", pLayerPrefix, pMsg); |
| 89 | if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK) |
| 90 | while (pTrav) { |
| 91 | pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData); |
| 92 | pTrav = pTrav->pNext; |
| 93 | } |
| 94 | } |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 95 | break; |
| 96 | default: |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 97 | if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_INFO) { |
| 98 | if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) |
| 99 | fprintf(g_logFile, "{%s}INFO : %s\n", pLayerPrefix, pMsg); |
| 100 | if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK) |
| 101 | while (pTrav) { |
| 102 | pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData); |
| 103 | pTrav = pTrav->pNext; |
| 104 | } |
| 105 | } |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 106 | break; |
| 107 | } |
| 108 | } |
| 109 | } |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 110 | // Return the size of the underlying struct based on struct type |
| 111 | static XGL_SIZE sTypeStructSize(XGL_STRUCTURE_TYPE sType) |
| 112 | { |
| 113 | switch (sType) |
| 114 | { |
| 115 | case XGL_STRUCTURE_TYPE_APPLICATION_INFO: |
| 116 | return sizeof(XGL_APPLICATION_INFO); |
| 117 | case XGL_STRUCTURE_TYPE_DEVICE_CREATE_INFO: |
| 118 | return sizeof(XGL_DEVICE_CREATE_INFO); |
| 119 | case XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO: |
| 120 | return sizeof(XGL_MEMORY_ALLOC_INFO); |
| 121 | case XGL_STRUCTURE_TYPE_MEMORY_OPEN_INFO: |
| 122 | return sizeof(XGL_MEMORY_OPEN_INFO); |
| 123 | case XGL_STRUCTURE_TYPE_PEER_MEMORY_OPEN_INFO: |
| 124 | return sizeof(XGL_PEER_MEMORY_OPEN_INFO); |
| 125 | case XGL_STRUCTURE_TYPE_MEMORY_VIEW_ATTACH_INFO: |
| 126 | return sizeof(XGL_MEMORY_VIEW_ATTACH_INFO); |
| 127 | case XGL_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO: |
| 128 | return sizeof(XGL_IMAGE_VIEW_ATTACH_INFO); |
| 129 | case XGL_STRUCTURE_TYPE_MEMORY_STATE_TRANSITION: |
| 130 | return sizeof(XGL_MEMORY_STATE_TRANSITION); |
| 131 | case XGL_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO: |
| 132 | return sizeof(XGL_IMAGE_VIEW_CREATE_INFO); |
| 133 | case XGL_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO: |
| 134 | return sizeof(XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO); |
| 135 | case XGL_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO: |
| 136 | return sizeof(XGL_DEPTH_STENCIL_VIEW_CREATE_INFO); |
| 137 | case XGL_STRUCTURE_TYPE_SHADER_CREATE_INFO: |
| 138 | return sizeof(XGL_SHADER_CREATE_INFO); |
| 139 | case XGL_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO: |
| 140 | return sizeof(XGL_COMPUTE_PIPELINE_CREATE_INFO); |
| 141 | case XGL_STRUCTURE_TYPE_SAMPLER_CREATE_INFO: |
| 142 | return sizeof(XGL_SAMPLER_CREATE_INFO); |
| 143 | case XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_CREATE_INFO: |
| 144 | return sizeof(XGL_DESCRIPTOR_SET_CREATE_INFO); |
| 145 | case XGL_STRUCTURE_TYPE_RASTER_STATE_CREATE_INFO: |
| 146 | return sizeof(XGL_RASTER_STATE_CREATE_INFO); |
| 147 | case XGL_STRUCTURE_TYPE_MSAA_STATE_CREATE_INFO: |
| 148 | return sizeof(XGL_MSAA_STATE_CREATE_INFO); |
| 149 | case XGL_STRUCTURE_TYPE_COLOR_BLEND_STATE_CREATE_INFO: |
| 150 | return sizeof(XGL_COLOR_BLEND_STATE_CREATE_INFO); |
| 151 | case XGL_STRUCTURE_TYPE_DEPTH_STENCIL_STATE_CREATE_INFO: |
| 152 | return sizeof(XGL_DEPTH_STENCIL_STATE_CREATE_INFO); |
| 153 | case XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO: |
| 154 | return sizeof(XGL_CMD_BUFFER_CREATE_INFO); |
| 155 | case XGL_STRUCTURE_TYPE_EVENT_CREATE_INFO: |
| 156 | return sizeof(XGL_EVENT_CREATE_INFO); |
| 157 | case XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO: |
| 158 | return sizeof(XGL_FENCE_CREATE_INFO); |
| 159 | case XGL_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO: |
| 160 | return sizeof(XGL_QUEUE_SEMAPHORE_CREATE_INFO); |
| 161 | case XGL_STRUCTURE_TYPE_SEMAPHORE_OPEN_INFO: |
| 162 | return sizeof(XGL_QUEUE_SEMAPHORE_OPEN_INFO); |
| 163 | case XGL_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO: |
| 164 | return sizeof(XGL_QUERY_POOL_CREATE_INFO); |
| 165 | case XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO: |
| 166 | return sizeof(XGL_PIPELINE_SHADER_STAGE_CREATE_INFO); |
| 167 | case XGL_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO: |
| 168 | return sizeof(XGL_GRAPHICS_PIPELINE_CREATE_INFO); |
| 169 | case XGL_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO: |
| 170 | return sizeof(XGL_PIPELINE_IA_STATE_CREATE_INFO); |
| 171 | case XGL_STRUCTURE_TYPE_PIPELINE_DB_STATE_CREATE_INFO: |
| 172 | return sizeof(XGL_PIPELINE_DB_STATE_CREATE_INFO); |
| 173 | case XGL_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO: |
| 174 | return sizeof(XGL_PIPELINE_CB_STATE); |
| 175 | case XGL_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO: |
| 176 | return sizeof(XGL_PIPELINE_RS_STATE_CREATE_INFO); |
| 177 | case XGL_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO: |
| 178 | return sizeof(XGL_PIPELINE_TESS_STATE_CREATE_INFO); |
| 179 | case XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO: |
| 180 | return sizeof(XGL_IMAGE_CREATE_INFO); |
| 181 | case XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO: |
| 182 | return sizeof(XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO); |
| 183 | case XGL_STRUCTURE_TYPE_LAYER_CREATE_INFO: |
| 184 | return sizeof(XGL_LAYER_CREATE_INFO); |
| 185 | default: |
| 186 | return 0; |
| 187 | } |
| 188 | } |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 189 | // Return the size of the underlying struct based on Bind Point enum |
| 190 | // Have to do this b/c VIEWPORT doesn't have sType in its createinfo struct |
Chia-I Wu | 84d7f5c | 2014-12-16 00:43:20 +0800 | [diff] [blame] | 191 | static XGL_SIZE dynStateCreateInfoSize(XGL_STATE_BIND_POINT sType) |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 192 | { |
| 193 | switch (sType) |
| 194 | { |
| 195 | case XGL_STATE_BIND_VIEWPORT: |
| 196 | return sizeof(XGL_VIEWPORT_STATE_CREATE_INFO); |
| 197 | case XGL_STATE_BIND_RASTER: |
| 198 | return sizeof(XGL_RASTER_STATE_CREATE_INFO); |
| 199 | case XGL_STATE_BIND_DEPTH_STENCIL: |
| 200 | return sizeof(XGL_DEPTH_STENCIL_STATE_CREATE_INFO); |
| 201 | case XGL_STATE_BIND_COLOR_BLEND: |
| 202 | return sizeof(XGL_COLOR_BLEND_STATE_CREATE_INFO); |
| 203 | case XGL_STATE_BIND_MSAA: |
| 204 | return sizeof(XGL_MSAA_STATE_CREATE_INFO); |
| 205 | default: |
| 206 | return 0; |
| 207 | } |
| 208 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 209 | // Block of code at start here for managing/tracking Pipeline state that this layer cares about |
| 210 | // Just track 2 shaders for now |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 211 | #define XGL_NUM_GRAPHICS_SHADERS XGL_SHADER_STAGE_COMPUTE |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 212 | #define MAX_SLOTS 2048 |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 213 | |
| 214 | static uint64_t drawCount[NUM_DRAW_TYPES] = {0, 0, 0, 0}; |
| 215 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 216 | typedef struct _SHADER_DS_MAPPING { |
| 217 | XGL_UINT slotCount; |
| 218 | XGL_DESCRIPTOR_SLOT_INFO* pShaderMappingSlot; |
| 219 | } SHADER_DS_MAPPING; |
| 220 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 221 | typedef struct _PIPELINE_LL_HEADER { |
| 222 | XGL_STRUCTURE_TYPE sType; |
| 223 | const XGL_VOID* pNext; |
| 224 | } PIPELINE_LL_HEADER; |
| 225 | |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 226 | typedef struct _PIPELINE_NODE { |
| 227 | XGL_PIPELINE pipeline; |
| 228 | struct _PIPELINE_NODE *pNext; |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 229 | XGL_GRAPHICS_PIPELINE_CREATE_INFO *pCreateTree; // Ptr to shadow of data in create tree |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 230 | // 1st dimension of array is shader type |
| 231 | SHADER_DS_MAPPING dsMapping[XGL_NUM_GRAPHICS_SHADERS][XGL_MAX_DESCRIPTOR_SETS]; |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 232 | // Vtx input info (if any) |
| 233 | XGL_UINT vtxBindingCount; // number of bindings |
| 234 | XGL_VERTEX_INPUT_BINDING_DESCRIPTION* pVertexBindingDescriptions; |
| 235 | XGL_UINT vtxAttributeCount; // number of attributes |
| 236 | XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION* pVertexAttributeDescriptions; |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 237 | } PIPELINE_NODE; |
| 238 | |
Tobin Ehlis | 5a1d9f3 | 2014-11-20 10:48:56 -0700 | [diff] [blame] | 239 | typedef struct _SAMPLER_NODE { |
| 240 | XGL_SAMPLER sampler; |
| 241 | XGL_SAMPLER_CREATE_INFO createInfo; |
| 242 | struct _SAMPLER_NODE *pNext; |
| 243 | } SAMPLER_NODE; |
| 244 | |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 245 | typedef struct _DYNAMIC_STATE_NODE { |
| 246 | XGL_STATE_OBJECT stateObj; |
| 247 | XGL_STATE_BIND_POINT sType; // Extra data as VIEWPORT CreateInfo doesn't have sType |
| 248 | PIPELINE_LL_HEADER *pCreateInfo; |
| 249 | struct _DYNAMIC_STATE_NODE *pNext; |
| 250 | } DYNAMIC_STATE_NODE; |
| 251 | |
| 252 | // TODO : Should be tracking lastBound per cmdBuffer and when draws occur, report based on that cmd buffer lastBound |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 253 | // Then need to synchronize the accesses based on cmd buffer so that if I'm reading state on one cmd buffer, updates |
| 254 | // to that same cmd buffer by separate thread are not changing state from underneath us |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 255 | static PIPELINE_NODE *pPipelineHead = NULL; |
Tobin Ehlis | 5a1d9f3 | 2014-11-20 10:48:56 -0700 | [diff] [blame] | 256 | static SAMPLER_NODE *pSamplerHead = NULL; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 257 | static XGL_PIPELINE lastBoundPipeline = NULL; |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 258 | #define MAX_BINDING 0xFFFFFFFF |
| 259 | static XGL_UINT lastVtxBinding = MAX_BINDING; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 260 | |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 261 | static DYNAMIC_STATE_NODE* pDynamicStateHead[XGL_NUM_STATE_BIND_POINT] = {0}; |
| 262 | static DYNAMIC_STATE_NODE* pLastBoundDynamicState[XGL_NUM_STATE_BIND_POINT] = {0}; |
| 263 | |
| 264 | // Viewport state create info doesn't have sType so we have to pass in BIND_POINT |
| 265 | static void insertDynamicState(const XGL_STATE_OBJECT state, const PIPELINE_LL_HEADER* pCreateInfo, const XGL_STATE_BIND_POINT sType) |
| 266 | { |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 267 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 268 | // Insert new node at head of appropriate LL |
| 269 | DYNAMIC_STATE_NODE* pStateNode = (DYNAMIC_STATE_NODE*)malloc(sizeof(DYNAMIC_STATE_NODE)); |
| 270 | pStateNode->pNext = pDynamicStateHead[sType]; |
| 271 | pDynamicStateHead[sType] = pStateNode; |
| 272 | pStateNode->stateObj = state; |
| 273 | pStateNode->sType = sType; |
| 274 | pStateNode->pCreateInfo = (PIPELINE_LL_HEADER*)malloc(dynStateCreateInfoSize(sType)); |
| 275 | memcpy(pStateNode->pCreateInfo, pCreateInfo, dynStateCreateInfoSize(sType)); |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 276 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 277 | } |
| 278 | // Set the last bound dynamic state of given type |
| 279 | // TODO : Need to track this per cmdBuffer and correlate cmdBuffer for Draw w/ last bound for that cmdBuffer? |
| 280 | static void setLastBoundDynamicState(const XGL_STATE_OBJECT state, const XGL_STATE_BIND_POINT sType) |
| 281 | { |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 282 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 283 | DYNAMIC_STATE_NODE* pTrav = pDynamicStateHead[sType]; |
| 284 | while (pTrav && (state != pTrav->stateObj)) { |
| 285 | pTrav = pTrav->pNext; |
| 286 | } |
| 287 | if (!pTrav) { |
| 288 | char str[1024]; |
| 289 | sprintf(str, "Unable to find dynamic state object %p, was it ever created?", (void*)state); |
| 290 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, state, 0, DRAWSTATE_INVALID_DYNAMIC_STATE_OBJECT, "DS", str); |
| 291 | } |
| 292 | pLastBoundDynamicState[sType] = pTrav; |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 293 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 294 | } |
| 295 | // Print the last bound dynamic state |
| 296 | static void printDynamicState() |
| 297 | { |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 298 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 299 | char str[1024]; |
| 300 | for (uint32_t i = 0; i < XGL_NUM_STATE_BIND_POINT; i++) { |
| 301 | if (pLastBoundDynamicState[i]) { |
| 302 | sprintf(str, "Reporting CreateInfo for currently bound %s object %p", string_XGL_STATE_BIND_POINT(i), pLastBoundDynamicState[i]->stateObj); |
| 303 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pLastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", str); |
| 304 | switch (pLastBoundDynamicState[i]->sType) |
| 305 | { |
| 306 | case XGL_STATE_BIND_VIEWPORT: |
| 307 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pLastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", xgl_print_xgl_viewport_state_create_info((XGL_VIEWPORT_STATE_CREATE_INFO*)pLastBoundDynamicState[i]->pCreateInfo, " ")); |
| 308 | break; |
| 309 | default: |
| 310 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pLastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", dynamic_display(pLastBoundDynamicState[i]->pCreateInfo, " ")); |
| 311 | break; |
| 312 | } |
| 313 | } |
| 314 | else { |
| 315 | sprintf(str, "No dynamic state of type %s bound", string_XGL_STATE_BIND_POINT(i)); |
| 316 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", str); |
| 317 | } |
| 318 | } |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 319 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 320 | } |
| 321 | // Retrieve pipeline node ptr for given pipeline object |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 322 | static PIPELINE_NODE *getPipeline(XGL_PIPELINE pipeline) |
| 323 | { |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 324 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 325 | PIPELINE_NODE *pTrav = pPipelineHead; |
| 326 | while (pTrav) { |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 327 | if (pTrav->pipeline == pipeline) { |
| 328 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 329 | return pTrav; |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 330 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 331 | pTrav = pTrav->pNext; |
| 332 | } |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 333 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 334 | return NULL; |
| 335 | } |
| 336 | |
Tobin Ehlis | 5a1d9f3 | 2014-11-20 10:48:56 -0700 | [diff] [blame] | 337 | // For given sampler, return a ptr to its Create Info struct, or NULL if sampler not found |
| 338 | static XGL_SAMPLER_CREATE_INFO* getSamplerCreateInfo(const XGL_SAMPLER sampler) |
| 339 | { |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 340 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 5a1d9f3 | 2014-11-20 10:48:56 -0700 | [diff] [blame] | 341 | SAMPLER_NODE *pTrav = pSamplerHead; |
| 342 | while (pTrav) { |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 343 | if (sampler == pTrav->sampler) { |
| 344 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 5a1d9f3 | 2014-11-20 10:48:56 -0700 | [diff] [blame] | 345 | return &pTrav->createInfo; |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 346 | } |
Tobin Ehlis | 5a1d9f3 | 2014-11-20 10:48:56 -0700 | [diff] [blame] | 347 | pTrav = pTrav->pNext; |
| 348 | } |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 349 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 5a1d9f3 | 2014-11-20 10:48:56 -0700 | [diff] [blame] | 350 | return NULL; |
| 351 | } |
| 352 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 353 | // Init the pipeline mapping info based on pipeline create info LL tree |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 354 | // Threading note : Calls to this function should wrapped in mutex |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 355 | static void initPipeline(PIPELINE_NODE *pPipeline, const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo) |
| 356 | { |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 357 | // First init create info, we'll shadow the structs as we go down the tree |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 358 | pPipeline->pCreateTree = (XGL_GRAPHICS_PIPELINE_CREATE_INFO*)malloc(sizeof(XGL_GRAPHICS_PIPELINE_CREATE_INFO)); |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 359 | memcpy(pPipeline->pCreateTree, pCreateInfo, sizeof(XGL_GRAPHICS_PIPELINE_CREATE_INFO)); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 360 | PIPELINE_LL_HEADER *pShadowTrav = (PIPELINE_LL_HEADER*)pPipeline->pCreateTree; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 361 | PIPELINE_LL_HEADER *pTrav = (PIPELINE_LL_HEADER*)pCreateInfo->pNext; |
| 362 | while (pTrav) { |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 363 | // Shadow the struct |
| 364 | pShadowTrav->pNext = (PIPELINE_LL_HEADER*)malloc(sTypeStructSize(pTrav->sType)); |
| 365 | // Typically pNext is const so have to cast to avoid warning when we modify it here |
| 366 | memcpy((void*)pShadowTrav->pNext, pTrav, sTypeStructSize(pTrav->sType)); |
| 367 | pShadowTrav = (PIPELINE_LL_HEADER*)pShadowTrav->pNext; |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 368 | // For deep copy DS Mapping into shadow |
| 369 | XGL_PIPELINE_SHADER_STAGE_CREATE_INFO *pShadowShaderCI = (XGL_PIPELINE_SHADER_STAGE_CREATE_INFO*)pShadowTrav; |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 370 | // TODO : Now that we shadow whole create info, the special copies are just a convenience that can be done away with once shadow is complete and correct |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 371 | // Special copy of DS Mapping info |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 372 | if (XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO == pTrav->sType) { |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 373 | XGL_PIPELINE_SHADER_STAGE_CREATE_INFO *pSSCI = (XGL_PIPELINE_SHADER_STAGE_CREATE_INFO*)pTrav; |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 374 | for (uint32_t i = 0; i < XGL_MAX_DESCRIPTOR_SETS; i++) { |
| 375 | if (pSSCI->shader.descriptorSetMapping[i].descriptorCount > MAX_SLOTS) { |
| 376 | char str[1024]; |
| 377 | sprintf(str, "descriptorCount for %s exceeds 2048 (%u), is this correct? Changing to 0", string_XGL_PIPELINE_SHADER_STAGE(pSSCI->shader.stage), pSSCI->shader.descriptorSetMapping[i].descriptorCount); |
| 378 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pPipeline, 0, DRAWSTATE_DESCRIPTOR_MAX_EXCEEDED, "DS", str); |
| 379 | pSSCI->shader.descriptorSetMapping[i].descriptorCount = 0; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 380 | } |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 381 | pPipeline->dsMapping[pSSCI->shader.stage][i].slotCount = pSSCI->shader.descriptorSetMapping[i].descriptorCount; |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 382 | // Deep copy DS Slot array into our shortcut data structure |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 383 | pPipeline->dsMapping[pSSCI->shader.stage][i].pShaderMappingSlot = (XGL_DESCRIPTOR_SLOT_INFO*)malloc(sizeof(XGL_DESCRIPTOR_SLOT_INFO)*pPipeline->dsMapping[pSSCI->shader.stage][i].slotCount); |
| 384 | memcpy(pPipeline->dsMapping[pSSCI->shader.stage][i].pShaderMappingSlot, pSSCI->shader.descriptorSetMapping[i].pDescriptorInfo, sizeof(XGL_DESCRIPTOR_SLOT_INFO)*pPipeline->dsMapping[pSSCI->shader.stage][i].slotCount); |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 385 | // Deep copy into shadow tree |
| 386 | pShadowShaderCI->shader.descriptorSetMapping[i].descriptorCount = pSSCI->shader.descriptorSetMapping[i].descriptorCount; |
| 387 | pShadowShaderCI->shader.descriptorSetMapping[i].pDescriptorInfo = (XGL_DESCRIPTOR_SLOT_INFO*)malloc(sizeof(XGL_DESCRIPTOR_SLOT_INFO)*pShadowShaderCI->shader.descriptorSetMapping[i].descriptorCount); |
| 388 | memcpy((XGL_DESCRIPTOR_SLOT_INFO*)pShadowShaderCI->shader.descriptorSetMapping[i].pDescriptorInfo, pSSCI->shader.descriptorSetMapping[i].pDescriptorInfo, sizeof(XGL_DESCRIPTOR_SLOT_INFO)*pShadowShaderCI->shader.descriptorSetMapping[i].descriptorCount); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 389 | } |
| 390 | } |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 391 | else if (XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO == pTrav->sType) { |
| 392 | // Special copy of Vtx info |
| 393 | XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO *pVICI = (XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO*)pTrav; |
| 394 | pPipeline->vtxBindingCount = pVICI->bindingCount; |
| 395 | uint32_t allocSize = pPipeline->vtxBindingCount * sizeof(XGL_VERTEX_INPUT_BINDING_DESCRIPTION); |
| 396 | pPipeline->pVertexBindingDescriptions = (XGL_VERTEX_INPUT_BINDING_DESCRIPTION*)malloc(allocSize); |
| 397 | memcpy(pPipeline->pVertexBindingDescriptions, pVICI->pVertexAttributeDescriptions, allocSize); |
| 398 | pPipeline->vtxAttributeCount = pVICI->attributeCount; |
| 399 | allocSize = pPipeline->vtxAttributeCount * sizeof(XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION); |
| 400 | pPipeline->pVertexAttributeDescriptions = (XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION*)malloc(allocSize); |
| 401 | memcpy(pPipeline->pVertexAttributeDescriptions, pVICI->pVertexAttributeDescriptions, allocSize); |
| 402 | } |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 403 | pTrav = (PIPELINE_LL_HEADER*)pTrav->pNext; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 404 | } |
| 405 | } |
| 406 | |
| 407 | // Block of code at start here specifically for managing/tracking DSs |
| 408 | #define MAPPING_MEMORY 0x00000001 |
| 409 | #define MAPPING_IMAGE 0x00000002 |
| 410 | #define MAPPING_SAMPLER 0x00000004 |
| 411 | #define MAPPING_DS 0x00000008 |
| 412 | |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 413 | static char* stringSlotBinding(XGL_UINT binding) |
| 414 | { |
| 415 | switch (binding) |
| 416 | { |
| 417 | case MAPPING_MEMORY: |
| 418 | return "Memory View"; |
| 419 | case MAPPING_IMAGE: |
| 420 | return "Image View"; |
| 421 | case MAPPING_SAMPLER: |
| 422 | return "Sampler"; |
| 423 | default: |
| 424 | return "UNKNOWN DS BINDING"; |
| 425 | } |
| 426 | } |
| 427 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 428 | typedef struct _DS_SLOT { |
| 429 | XGL_UINT slot; |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 430 | XGL_DESCRIPTOR_SLOT_INFO shaderSlotInfo[XGL_NUM_GRAPHICS_SHADERS]; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 431 | // Only 1 of 4 possible slot mappings active |
| 432 | XGL_UINT activeMapping; |
| 433 | XGL_UINT mappingMask; // store record of different mappings used |
| 434 | XGL_MEMORY_VIEW_ATTACH_INFO memView; |
| 435 | XGL_IMAGE_VIEW_ATTACH_INFO imageView; |
| 436 | XGL_SAMPLER sampler; |
| 437 | } DS_SLOT; |
| 438 | |
| 439 | // Top-level node that points to start of DS |
| 440 | typedef struct _DS_LL_HEAD { |
| 441 | XGL_DESCRIPTOR_SET dsID; |
| 442 | XGL_UINT numSlots; |
| 443 | struct _DS_LL_HEAD *pNextDS; |
| 444 | DS_SLOT *dsSlot; // Dynamically allocated array of DS_SLOTs |
| 445 | XGL_BOOL updateActive; // Track if DS is in an update block |
| 446 | } DS_LL_HEAD; |
| 447 | |
| 448 | // ptr to HEAD of LL of DSs |
| 449 | static DS_LL_HEAD *pDSHead = NULL; |
Tobin Ehlis | eacc64f | 2014-11-24 17:09:09 -0700 | [diff] [blame] | 450 | // Last DS that was bound, and slotOffset for the binding |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 451 | static XGL_DESCRIPTOR_SET lastBoundDS[XGL_MAX_DESCRIPTOR_SETS] = {NULL, NULL}; |
Tobin Ehlis | eacc64f | 2014-11-24 17:09:09 -0700 | [diff] [blame] | 452 | static XGL_UINT lastBoundSlotOffset[XGL_MAX_DESCRIPTOR_SETS] = {0, 0}; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 453 | |
| 454 | // Return DS Head ptr for specified ds or else NULL |
| 455 | static DS_LL_HEAD* getDS(XGL_DESCRIPTOR_SET ds) |
| 456 | { |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 457 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 458 | DS_LL_HEAD *pTrav = pDSHead; |
| 459 | while (pTrav) { |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 460 | if (pTrav->dsID == ds) { |
| 461 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 462 | return pTrav; |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 463 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 464 | pTrav = pTrav->pNextDS; |
| 465 | } |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 466 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 467 | return NULL; |
| 468 | } |
| 469 | |
| 470 | // Initialize a DS where all slots are UNUSED for all shaders |
| 471 | static void initDS(DS_LL_HEAD *pDS) |
| 472 | { |
| 473 | for (uint32_t i = 0; i < pDS->numSlots; i++) { |
| 474 | memset((void*)&pDS->dsSlot[i], 0, sizeof(DS_SLOT)); |
| 475 | pDS->dsSlot[i].slot = i; |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | // Return XGL_TRUE if DS Exists and is within an xglBeginDescriptorSetUpdate() call sequence, otherwise XGL_FALSE |
| 480 | static XGL_BOOL dsUpdate(XGL_DESCRIPTOR_SET ds) |
| 481 | { |
| 482 | DS_LL_HEAD *pTrav = getDS(ds); |
| 483 | if (pTrav) |
| 484 | return pTrav->updateActive; |
| 485 | return XGL_FALSE; |
| 486 | } |
| 487 | |
| 488 | // Clear specified slotCount DS Slots starting at startSlot |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 489 | // Return XGL_TRUE if DS exists and is successfully cleared to 0s |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 490 | static XGL_BOOL clearDS(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount) |
| 491 | { |
| 492 | DS_LL_HEAD *pTrav = getDS(descriptorSet); |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 493 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 494 | if (!pTrav || ((startSlot + slotCount) > pTrav->numSlots)) { |
| 495 | // TODO : Log more meaningful error here |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 496 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 497 | return XGL_FALSE; |
| 498 | } |
| 499 | for (uint32_t i = startSlot; i < slotCount; i++) { |
| 500 | memset((void*)&pTrav->dsSlot[i], 0, sizeof(DS_SLOT)); |
| 501 | } |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 502 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 503 | return XGL_TRUE; |
| 504 | } |
| 505 | |
| 506 | static void dsSetMapping(DS_SLOT* pSlot, XGL_UINT mapping) |
| 507 | { |
| 508 | pSlot->mappingMask |= mapping; |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 509 | pSlot->activeMapping = mapping; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 510 | } |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 511 | // Populate pStr w/ a string noting all of the slot mappings based on mapping flag |
| 512 | static char* noteSlotMapping(XGL_UINT32 mapping, char *pStr) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 513 | { |
| 514 | if (MAPPING_MEMORY & mapping) |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 515 | strcat(pStr, "\n\tMemory View previously mapped"); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 516 | if (MAPPING_IMAGE & mapping) |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 517 | strcat(pStr, "\n\tImage View previously mapped"); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 518 | if (MAPPING_SAMPLER & mapping) |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 519 | strcat(pStr, "\n\tSampler previously mapped"); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 520 | if (MAPPING_DS & mapping) |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 521 | strcat(pStr, "\n\tDESCRIPTOR SET ptr previously mapped"); |
| 522 | return pStr; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 523 | } |
| 524 | |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 525 | static void dsSetMemMapping(XGL_DESCRIPTOR_SET descriptorSet, DS_SLOT* pSlot, const XGL_MEMORY_VIEW_ATTACH_INFO* pMemView) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 526 | { |
| 527 | if (pSlot->mappingMask) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 528 | char str[1024]; |
| 529 | char map_str[1024] = {0}; |
| 530 | sprintf(str, "While mapping Memory View to slot %u previous Mapping(s) identified:%s", pSlot->slot, noteSlotMapping(pSlot->mappingMask, map_str)); |
| 531 | layerCbMsg(XGL_DBG_MSG_WARNING, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_SLOT_REMAPPING, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 532 | } |
| 533 | memcpy(&pSlot->memView, pMemView, sizeof(XGL_MEMORY_VIEW_ATTACH_INFO)); |
| 534 | dsSetMapping(pSlot, MAPPING_MEMORY); |
| 535 | } |
| 536 | |
| 537 | static XGL_BOOL dsMemMapping(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_MEMORY_VIEW_ATTACH_INFO* pMemViews) |
| 538 | { |
| 539 | DS_LL_HEAD *pTrav = getDS(descriptorSet); |
| 540 | if (pTrav) { |
| 541 | if (pTrav->numSlots < (startSlot + slotCount)) { |
| 542 | return XGL_FALSE; |
| 543 | } |
| 544 | for (uint32_t i = 0; i < slotCount; i++) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 545 | dsSetMemMapping(descriptorSet, &pTrav->dsSlot[i+startSlot], &pMemViews[i]); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 546 | } |
| 547 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 548 | else |
| 549 | return XGL_FALSE; |
| 550 | return XGL_TRUE; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 551 | } |
| 552 | |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 553 | static void dsSetImageMapping(XGL_DESCRIPTOR_SET descriptorSet, DS_SLOT* pSlot, const XGL_IMAGE_VIEW_ATTACH_INFO* pImageViews) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 554 | { |
| 555 | if (pSlot->mappingMask) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 556 | char str[1024]; |
| 557 | char map_str[1024] = {0}; |
| 558 | sprintf(str, "While mapping Image View to slot %u previous Mapping(s) identified:%s", pSlot->slot, noteSlotMapping(pSlot->mappingMask, map_str)); |
| 559 | layerCbMsg(XGL_DBG_MSG_WARNING, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_SLOT_REMAPPING, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 560 | } |
| 561 | memcpy(&pSlot->imageView, pImageViews, sizeof(XGL_IMAGE_VIEW_ATTACH_INFO)); |
| 562 | dsSetMapping(pSlot, MAPPING_IMAGE); |
| 563 | } |
| 564 | |
| 565 | static XGL_BOOL dsImageMapping(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_IMAGE_VIEW_ATTACH_INFO* pImageViews) |
| 566 | { |
| 567 | DS_LL_HEAD *pTrav = getDS(descriptorSet); |
| 568 | if (pTrav) { |
| 569 | if (pTrav->numSlots < (startSlot + slotCount)) { |
| 570 | return XGL_FALSE; |
| 571 | } |
| 572 | for (uint32_t i = 0; i < slotCount; i++) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 573 | dsSetImageMapping(descriptorSet, &pTrav->dsSlot[i+startSlot], &pImageViews[i]); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 574 | } |
| 575 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 576 | else |
| 577 | return XGL_FALSE; |
| 578 | return XGL_TRUE; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 579 | } |
| 580 | |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 581 | static void dsSetSamplerMapping(XGL_DESCRIPTOR_SET descriptorSet, DS_SLOT* pSlot, const XGL_SAMPLER sampler) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 582 | { |
| 583 | if (pSlot->mappingMask) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 584 | char str[1024]; |
| 585 | char map_str[1024] = {0}; |
| 586 | sprintf(str, "While mapping Sampler to slot %u previous Mapping(s) identified:%s", pSlot->slot, noteSlotMapping(pSlot->mappingMask, map_str)); |
| 587 | layerCbMsg(XGL_DBG_MSG_WARNING, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_SLOT_REMAPPING, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 588 | } |
| 589 | pSlot->sampler = sampler; |
| 590 | dsSetMapping(pSlot, MAPPING_SAMPLER); |
| 591 | } |
| 592 | |
| 593 | static XGL_BOOL dsSamplerMapping(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_SAMPLER* pSamplers) |
| 594 | { |
| 595 | DS_LL_HEAD *pTrav = getDS(descriptorSet); |
| 596 | if (pTrav) { |
| 597 | if (pTrav->numSlots < (startSlot + slotCount)) { |
| 598 | return XGL_FALSE; |
| 599 | } |
| 600 | for (uint32_t i = 0; i < slotCount; i++) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 601 | dsSetSamplerMapping(descriptorSet, &pTrav->dsSlot[i+startSlot], pSamplers[i]); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 602 | } |
| 603 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 604 | else |
| 605 | return XGL_FALSE; |
| 606 | return XGL_TRUE; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 607 | } |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 608 | // Print the last bound Gfx Pipeline |
| 609 | static void printPipeline() |
| 610 | { |
| 611 | PIPELINE_NODE *pPipeTrav = getPipeline(lastBoundPipeline); |
| 612 | if (!pPipeTrav) { |
| 613 | // nothing to print |
| 614 | } |
| 615 | else { |
| 616 | char* pipeStr = xgl_print_xgl_graphics_pipeline_create_info(pPipeTrav->pCreateTree, "{DS}"); |
| 617 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", pipeStr); |
| 618 | } |
| 619 | } |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 620 | // Dump subgraph w/ DS info |
| 621 | static void dsDumpDot(FILE* pOutFile) |
| 622 | { |
| 623 | const int i = 0; // hard-coding to just the first DS index for now |
| 624 | uint32_t skipUnusedCount = 0; // track consecutive unused slots for minimal reporting |
| 625 | DS_LL_HEAD *pDS = getDS(lastBoundDS[i]); |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 626 | if (pDS) { |
| 627 | fprintf(pOutFile, "subgraph DS_SLOTS\n{\nlabel=\"DS0 Slots\"\n"); |
| 628 | // First create simple array node as central DS reference point |
| 629 | fprintf(pOutFile, "\"DS0_MEMORY\" [\nlabel = <<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"> <TR><TD PORT=\"ds2\">DS0 Memory</TD></TR>"); |
| 630 | uint32_t j; |
| 631 | char label[1024]; |
| 632 | for (j = 0; j < pDS->numSlots; j++) { |
Tobin Ehlis | f1c468a | 2014-12-09 17:00:33 -0700 | [diff] [blame] | 633 | // Don't draw unused slots |
| 634 | if (0 != pDS->dsSlot[j].activeMapping) |
| 635 | fprintf(pOutFile, "<TR><TD PORT=\"slot%u\">slot%u</TD></TR>", j, j); |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 636 | } |
| 637 | fprintf(pOutFile, "</TABLE>>\n];\n"); |
| 638 | // Now tie each slot to its info |
| 639 | for (j = 0; j < pDS->numSlots; j++) { |
| 640 | switch (pDS->dsSlot[j].activeMapping) |
| 641 | { |
| 642 | case MAPPING_MEMORY: |
| 643 | /* |
| 644 | if (0 != skipUnusedCount) {// finish sequence of unused slots |
| 645 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 646 | strcat(ds_config_str, tmp_str); |
| 647 | skipUnusedCount = 0; |
| 648 | }*/ |
| 649 | sprintf(label, "MemAttachInfo Slot%u", j); |
| 650 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_memory_view_attach_info(&pDS->dsSlot[j].memView, label)); |
| 651 | fprintf(pOutFile, "\"DS0_MEMORY\":slot%u -> \"%s\" [];\n", j, label); |
| 652 | break; |
| 653 | case MAPPING_IMAGE: |
| 654 | /*if (0 != skipUnusedCount) {// finish sequence of unused slots |
| 655 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 656 | strcat(ds_config_str, tmp_str); |
| 657 | skipUnusedCount = 0; |
| 658 | }*/ |
| 659 | sprintf(label, "ImageAttachInfo Slot%u", j); |
| 660 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_image_view_attach_info(&pDS->dsSlot[j].imageView, label)); |
| 661 | fprintf(pOutFile, "\"DS0_MEMORY\":slot%u -> \"%s\" [];\n", j, label); |
| 662 | break; |
| 663 | case MAPPING_SAMPLER: |
| 664 | /*if (0 != skipUnusedCount) {// finish sequence of unused slots |
| 665 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 666 | strcat(ds_config_str, tmp_str); |
| 667 | skipUnusedCount = 0; |
| 668 | }*/ |
| 669 | sprintf(label, "ImageAttachInfo Slot%u", j); |
| 670 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_sampler_create_info(getSamplerCreateInfo(pDS->dsSlot[j].sampler), label)); |
| 671 | fprintf(pOutFile, "\"DS0_MEMORY\":slot%u -> \"%s\" [];\n", j, label); |
| 672 | break; |
| 673 | default: |
| 674 | /*if (!skipUnusedCount) {// only report start of unused sequences |
| 675 | sprintf(tmp_str, "----Skipping slot(s) w/o a view attached...\n"); |
| 676 | strcat(ds_config_str, tmp_str); |
| 677 | }*/ |
| 678 | skipUnusedCount++; |
| 679 | break; |
| 680 | } |
| 681 | |
| 682 | } |
| 683 | /*if (0 != skipUnusedCount) {// finish sequence of unused slots |
| 684 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 685 | strcat(ds_config_str, tmp_str); |
| 686 | skipUnusedCount = 0; |
| 687 | }*/ |
| 688 | fprintf(pOutFile, "}\n"); |
| 689 | } |
| 690 | } |
| 691 | // Dump a GraphViz dot file showing the pipeline |
| 692 | static void dumpDotFile(char *outFileName) |
| 693 | { |
| 694 | PIPELINE_NODE *pPipeTrav = getPipeline(lastBoundPipeline); |
| 695 | if (pPipeTrav) { |
| 696 | FILE* pOutFile; |
| 697 | pOutFile = fopen(outFileName, "w"); |
| 698 | fprintf(pOutFile, "digraph g {\ngraph [\nrankdir = \"TB\"\n];\nnode [\nfontsize = \"16\"\nshape = \"plaintext\"\n];\nedge [\n];\n"); |
| 699 | fprintf(pOutFile, "subgraph PipelineStateObject\n{\nlabel=\"Pipeline State Object\"\n"); |
| 700 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_graphics_pipeline_create_info(pPipeTrav->pCreateTree, "PSO HEAD")); |
| 701 | fprintf(pOutFile, "}\n"); |
| 702 | // TODO : Add dynamic state dump here |
| 703 | fprintf(pOutFile, "subgraph dynamicState\n{\nlabel=\"Non-Orthogonal XGL State\"\n"); |
| 704 | for (uint32_t i = 0; i < XGL_NUM_STATE_BIND_POINT; i++) { |
| 705 | if (pLastBoundDynamicState[i]) { |
| 706 | switch (pLastBoundDynamicState[i]->sType) |
| 707 | { |
| 708 | case XGL_STATE_BIND_VIEWPORT: |
| 709 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_viewport_state_create_info((XGL_VIEWPORT_STATE_CREATE_INFO*)pLastBoundDynamicState[i]->pCreateInfo, "VIEWPORT State")); |
| 710 | break; |
| 711 | default: |
| 712 | fprintf(pOutFile, "%s", dynamic_gv_display(pLastBoundDynamicState[i]->pCreateInfo, string_XGL_STATE_BIND_POINT(pLastBoundDynamicState[i]->sType))); |
| 713 | break; |
| 714 | } |
| 715 | } |
| 716 | } |
| 717 | fprintf(pOutFile, "}\n"); // close dynamicState subgraph |
| 718 | dsDumpDot(pOutFile); |
| 719 | fprintf(pOutFile, "}\n"); // close main graph "g" |
| 720 | fclose(pOutFile); |
| 721 | } |
| 722 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 723 | // Synch up currently bound pipeline settings with DS mappings |
| 724 | static void synchDSMapping() |
| 725 | { |
| 726 | // First verify that we have a bound pipeline |
| 727 | PIPELINE_NODE *pPipeTrav = getPipeline(lastBoundPipeline); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 728 | char str[1024]; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 729 | if (!pPipeTrav) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 730 | sprintf(str, "Can't find last bound Pipeline %p!", (void*)lastBoundPipeline); |
| 731 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NO_PIPELINE_BOUND, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 732 | } |
| 733 | else { |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 734 | // Synch Descriptor Set Mapping |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 735 | for (uint32_t i = 0; i < XGL_MAX_DESCRIPTOR_SETS; i++) { |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 736 | DS_LL_HEAD *pDS; |
| 737 | if (lastBoundDS[i]) { |
| 738 | pDS = getDS(lastBoundDS[i]); |
| 739 | if (!pDS) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 740 | sprintf(str, "Can't find last bound DS %p. Did you need to bind DS to index %u?", (void*)lastBoundDS[i], i); |
| 741 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NO_DS_BOUND, "DS", str); |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 742 | } |
| 743 | else { // We have a good DS & Pipeline, store pipeline mappings in DS |
Tobin Ehlis | eacc64f | 2014-11-24 17:09:09 -0700 | [diff] [blame] | 744 | XGL_UINT slotOffset = lastBoundSlotOffset[i]; |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 745 | for (uint32_t j = 0; j < XGL_NUM_GRAPHICS_SHADERS; j++) { // j is shader selector |
Tobin Ehlis | eacc64f | 2014-11-24 17:09:09 -0700 | [diff] [blame] | 746 | if (pPipeTrav->dsMapping[j][i].slotCount > (pDS->numSlots - slotOffset)) { |
| 747 | sprintf(str, "DS Mapping for shader %u has more slots (%u) than DS %p (%u) minus slotOffset (%u) (%u slots available)!", j, pPipeTrav->dsMapping[j][i].slotCount, (void*)pDS->dsID, pDS->numSlots, slotOffset, (pDS->numSlots - slotOffset)); |
Tobin Ehlis | 2104279 | 2014-11-24 16:06:04 -0700 | [diff] [blame] | 748 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_DS_SLOT_NUM_MISMATCH, "DS", str); |
| 749 | } |
| 750 | else { |
| 751 | for (uint32_t r = 0; r < pPipeTrav->dsMapping[j][i].slotCount; r++) { |
Tobin Ehlis | eacc64f | 2014-11-24 17:09:09 -0700 | [diff] [blame] | 752 | pDS->dsSlot[r+slotOffset].shaderSlotInfo[j] = pPipeTrav->dsMapping[j][i].pShaderMappingSlot[r]; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 753 | } |
| 754 | } |
| 755 | } |
| 756 | } |
| 757 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 758 | else { |
Tobin Ehlis | 2104279 | 2014-11-24 16:06:04 -0700 | [diff] [blame] | 759 | // Verify that no shader is mapping this DS |
| 760 | uint32_t dsUsed = 0; |
| 761 | for (uint32_t j = 0; j < XGL_NUM_GRAPHICS_SHADERS; j++) { // j is shader selector |
| 762 | if (pPipeTrav->dsMapping[j][i].slotCount > 0) { |
| 763 | dsUsed = 1; |
| 764 | sprintf(str, "No DS was bound to index %u, but shader type %s has slots bound to that DS.", i, string_XGL_PIPELINE_SHADER_STAGE(j)); |
| 765 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NO_DS_BOUND, "DS", str); |
| 766 | } |
| 767 | } |
| 768 | if (0 == dsUsed) { |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 769 | sprintf(str, "No DS was bound to index %u, but no shaders are using that DS so this is not an issue.", i); |
Tobin Ehlis | 2104279 | 2014-11-24 16:06:04 -0700 | [diff] [blame] | 770 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", str); |
| 771 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 772 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 773 | } |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 774 | // Verify Vtx binding |
| 775 | if (MAX_BINDING != lastVtxBinding) { |
| 776 | if (lastVtxBinding >= pPipeTrav->vtxBindingCount) { |
| 777 | sprintf(str, "Vtx binding Index of %u exceeds PSO pVertexBindingDescriptions max array index of %u.", lastVtxBinding, (pPipeTrav->vtxBindingCount - 1)); |
| 778 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", str); |
| 779 | } |
| 780 | else { |
| 781 | char *tmpStr = xgl_print_xgl_vertex_input_binding_description(&pPipeTrav->pVertexBindingDescriptions[lastVtxBinding], "{DS}INFO : "); |
| 782 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmpStr); |
| 783 | free(tmpStr); |
| 784 | } |
| 785 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 786 | } |
| 787 | } |
| 788 | |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 789 | // Checks to make sure that shader mapping matches slot binding |
| 790 | // Print an ERROR and return XGL_FALSE if they don't line up |
| 791 | static XGL_BOOL verifyShaderSlotMapping(const XGL_UINT slot, const XGL_UINT slotBinding, const XGL_UINT shaderStage, const XGL_DESCRIPTOR_SET_SLOT_TYPE shaderMapping) |
| 792 | { |
| 793 | XGL_BOOL error = XGL_FALSE; |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 794 | char str[1024]; |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 795 | switch (shaderMapping) |
| 796 | { |
Cody Northrop | 40316a3 | 2014-12-09 19:08:33 -0700 | [diff] [blame] | 797 | case XGL_SLOT_SHADER_TEXTURE_RESOURCE: |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 798 | case XGL_SLOT_SHADER_RESOURCE: |
| 799 | if (MAPPING_MEMORY != slotBinding && MAPPING_IMAGE != slotBinding) |
| 800 | error = XGL_TRUE; |
| 801 | break; |
| 802 | case XGL_SLOT_SHADER_SAMPLER: |
| 803 | if (MAPPING_SAMPLER != slotBinding) |
| 804 | error = XGL_TRUE; |
| 805 | break; |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 806 | case XGL_SLOT_SHADER_UAV: |
| 807 | if (MAPPING_MEMORY != slotBinding) |
| 808 | error = XGL_TRUE; |
| 809 | break; |
| 810 | case XGL_SLOT_NEXT_DESCRIPTOR_SET: |
| 811 | if (MAPPING_DS != slotBinding) |
| 812 | error = XGL_TRUE; |
| 813 | break; |
| 814 | case XGL_SLOT_UNUSED: |
| 815 | break; |
| 816 | default: |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 817 | sprintf(str, "For DS slot %u, unknown shader slot mapping w/ value %u", slot, shaderMapping); |
| 818 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_UNKNOWN_DS_MAPPING, "DS", str); |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 819 | return XGL_FALSE; |
| 820 | } |
| 821 | if (XGL_TRUE == error) { |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 822 | sprintf(str, "DS Slot #%u binding of %s does not match %s shader mapping of %s", slot, stringSlotBinding(slotBinding), string_XGL_PIPELINE_SHADER_STAGE(shaderStage), string_XGL_DESCRIPTOR_SET_SLOT_TYPE(shaderMapping)); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 823 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_DS_MAPPING_MISMATCH, "DS", str); |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 824 | return XGL_FALSE; |
| 825 | } |
| 826 | return XGL_TRUE; |
| 827 | } |
| 828 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 829 | // Print details of DS config to stdout |
| 830 | static void printDSConfig() |
| 831 | { |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 832 | uint32_t skipUnusedCount = 0; // track consecutive unused slots for minimal reporting |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 833 | char tmp_str[1024]; |
| 834 | 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. |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 835 | for (uint32_t i = 0; i < XGL_MAX_DESCRIPTOR_SETS; i++) { |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 836 | if (lastBoundDS[i]) { |
| 837 | DS_LL_HEAD *pDS = getDS(lastBoundDS[i]); |
Tobin Ehlis | eacc64f | 2014-11-24 17:09:09 -0700 | [diff] [blame] | 838 | XGL_UINT slotOffset = lastBoundSlotOffset[i]; |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 839 | if (pDS) { |
Tobin Ehlis | eacc64f | 2014-11-24 17:09:09 -0700 | [diff] [blame] | 840 | sprintf(tmp_str, "DS INFO : Slot bindings for DS[%u] (%p) - %u slots and slotOffset %u:\n", i, (void*)pDS->dsID, pDS->numSlots, slotOffset); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 841 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 842 | for (uint32_t j = 0; j < pDS->numSlots; j++) { |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 843 | switch (pDS->dsSlot[j].activeMapping) |
| 844 | { |
| 845 | case MAPPING_MEMORY: |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 846 | if (0 != skipUnusedCount) {// finish sequence of unused slots |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 847 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 848 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 849 | skipUnusedCount = 0; |
| 850 | } |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 851 | sprintf(tmp_str, "----Slot %u\n Mapped to Memory View %p:\n%s", j, (void*)&pDS->dsSlot[j].memView, xgl_print_xgl_memory_view_attach_info(&pDS->dsSlot[j].memView, " ")); |
| 852 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 853 | break; |
| 854 | case MAPPING_IMAGE: |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 855 | if (0 != skipUnusedCount) {// finish sequence of unused slots |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 856 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 857 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 858 | skipUnusedCount = 0; |
| 859 | } |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 860 | sprintf(tmp_str, "----Slot %u\n Mapped to Image View %p:\n%s", j, (void*)&pDS->dsSlot[j].imageView, xgl_print_xgl_image_view_attach_info(&pDS->dsSlot[j].imageView, " ")); |
| 861 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 862 | break; |
| 863 | case MAPPING_SAMPLER: |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 864 | if (0 != skipUnusedCount) {// finish sequence of unused slots |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 865 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 866 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 867 | skipUnusedCount = 0; |
| 868 | } |
Tobin Ehlis | 5a1d9f3 | 2014-11-20 10:48:56 -0700 | [diff] [blame] | 869 | sprintf(tmp_str, "----Slot %u\n Mapped to Sampler Object %p:\n%s", j, (void*)pDS->dsSlot[j].sampler, xgl_print_xgl_sampler_create_info(getSamplerCreateInfo(pDS->dsSlot[j].sampler), " ")); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 870 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 871 | break; |
| 872 | default: |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 873 | if (!skipUnusedCount) {// only report start of unused sequences |
| 874 | sprintf(tmp_str, "----Skipping slot(s) w/o a view attached...\n"); |
| 875 | strcat(ds_config_str, tmp_str); |
| 876 | } |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 877 | skipUnusedCount++; |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 878 | break; |
| 879 | } |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 880 | // For each shader type, check its mapping |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 881 | for (uint32_t k = 0; k < XGL_NUM_GRAPHICS_SHADERS; k++) { |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 882 | if (XGL_SLOT_UNUSED != pDS->dsSlot[j].shaderSlotInfo[k].slotObjectType) { |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 883 | sprintf(tmp_str, " Shader type %s has %s slot type mapping to shaderEntityIndex %u\n", string_XGL_PIPELINE_SHADER_STAGE(k), string_XGL_DESCRIPTOR_SET_SLOT_TYPE(pDS->dsSlot[j].shaderSlotInfo[k].slotObjectType), pDS->dsSlot[j].shaderSlotInfo[k].shaderEntityIndex); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 884 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 885 | verifyShaderSlotMapping(j, pDS->dsSlot[j].activeMapping, k, pDS->dsSlot[j].shaderSlotInfo[k].slotObjectType); |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 886 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 887 | } |
| 888 | } |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 889 | if (0 != skipUnusedCount) {// finish sequence of unused slots |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 890 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 891 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 892 | skipUnusedCount = 0; |
| 893 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 894 | } |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 895 | else { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 896 | char str[1024]; |
| 897 | sprintf(str, "Can't find last bound DS %p. Did you need to bind DS to index %u?", (void*)lastBoundDS[i], i); |
| 898 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NO_DS_BOUND, "DS", str); |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 899 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 900 | } |
| 901 | } |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 902 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 903 | } |
| 904 | |
| 905 | static void synchAndPrintDSConfig() |
| 906 | { |
| 907 | synchDSMapping(); |
| 908 | printDSConfig(); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 909 | printPipeline(); |
| 910 | printDynamicState(); |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 911 | static int autoDumpOnce = 1; |
| 912 | if (autoDumpOnce) { |
| 913 | autoDumpOnce = 0; |
| 914 | dumpDotFile("pipeline_dump.dot"); |
Tobin Ehlis | 266473d | 2014-12-16 17:34:50 -0700 | [diff] [blame] | 915 | // Convert dot to png if dot available |
| 916 | if(access( "/usr/bin/dot", X_OK) != -1) { |
| 917 | system("/usr/bin/dot pipeline_dump.dot -Tpng -o pipeline_dump.png"); |
| 918 | } |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 919 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 920 | } |
| 921 | |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 922 | static void initDrawState() |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 923 | { |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 924 | const char *strOpt; |
Tobin Ehlis | 5b7acaa | 2015-01-08 14:26:53 -0700 | [diff] [blame] | 925 | // initialize DrawState options |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 926 | strOpt = getLayerOption("DrawStateReportLevel"); |
| 927 | if (strOpt != NULL) |
| 928 | g_reportingLevel = atoi(strOpt); |
Tobin Ehlis | 5b7acaa | 2015-01-08 14:26:53 -0700 | [diff] [blame] | 929 | |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 930 | strOpt = getLayerOption("DrawStateDebugAction"); |
| 931 | if (strOpt != NULL) |
Tobin Ehlis | 5b7acaa | 2015-01-08 14:26:53 -0700 | [diff] [blame] | 932 | g_debugAction = atoi(strOpt); |
| 933 | |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 934 | if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) |
| 935 | { |
| 936 | strOpt = getLayerOption("DrawStateLogFilename"); |
| 937 | if (strOpt) |
| 938 | { |
| 939 | g_logFile = fopen(strOpt, "w"); |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 940 | } |
| 941 | if (g_logFile == NULL) |
| 942 | g_logFile = stdout; |
| 943 | } |
| 944 | |
| 945 | // initialize Layer dispatch table |
| 946 | // TODO handle multiple GPUs |
Mark Lobodzinski | 953a169 | 2015-01-09 15:12:03 -0600 | [diff] [blame^] | 947 | xglGetProcAddrType fpNextGPA; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 948 | fpNextGPA = pCurObj->pGPA; |
| 949 | assert(fpNextGPA); |
| 950 | |
Chia-I Wu | 0f65b1e | 2015-01-04 23:11:43 +0800 | [diff] [blame] | 951 | layer_initialize_dispatch_table(&nextTable, fpNextGPA, (XGL_PHYSICAL_GPU) pCurObj->nextObject); |
| 952 | |
Mark Lobodzinski | 953a169 | 2015-01-09 15:12:03 -0600 | [diff] [blame^] | 953 | xglGetProcAddrType fpGetProcAddr = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetProcAddr"); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 954 | nextTable.GetProcAddr = fpGetProcAddr; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 955 | } |
| 956 | |
| 957 | |
| 958 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetGpuInfo(XGL_PHYSICAL_GPU gpu, XGL_PHYSICAL_GPU_INFO_TYPE infoType, XGL_SIZE* pDataSize, XGL_VOID* pData) |
| 959 | { |
| 960 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 961 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 962 | pthread_once(&g_initOnce, initDrawState); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 963 | XGL_RESULT result = nextTable.GetGpuInfo((XGL_PHYSICAL_GPU)gpuw->nextObject, infoType, pDataSize, pData); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 964 | return result; |
| 965 | } |
| 966 | |
| 967 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreateInfo, XGL_DEVICE* pDevice) |
| 968 | { |
| 969 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 970 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 971 | pthread_once(&g_initOnce, initDrawState); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 972 | XGL_RESULT result = nextTable.CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 973 | return result; |
| 974 | } |
| 975 | |
| 976 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyDevice(XGL_DEVICE device) |
| 977 | { |
| 978 | XGL_RESULT result = nextTable.DestroyDevice(device); |
| 979 | return result; |
| 980 | } |
| 981 | |
| 982 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu, const XGL_CHAR* pExtName) |
| 983 | { |
| 984 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 985 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 986 | pthread_once(&g_initOnce, initDrawState); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 987 | XGL_RESULT result = nextTable.GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 988 | return result; |
| 989 | } |
| 990 | |
Mark Lobodzinski | 953a169 | 2015-01-09 15:12:03 -0600 | [diff] [blame^] | 991 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, XGL_SIZE maxLayerCount, XGL_SIZE maxStringSize, XGL_SIZE* pOutLayerCount, XGL_CHAR* const* pOutLayers, XGL_VOID* pReserved) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 992 | { |
Jon Ashburn | 451c16f | 2014-11-25 11:08:42 -0700 | [diff] [blame] | 993 | if (gpu != NULL) |
| 994 | { |
| 995 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
| 996 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 997 | pthread_once(&g_initOnce, initDrawState); |
Mark Lobodzinski | 953a169 | 2015-01-09 15:12:03 -0600 | [diff] [blame^] | 998 | XGL_RESULT result = nextTable.EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved); |
Jon Ashburn | 451c16f | 2014-11-25 11:08:42 -0700 | [diff] [blame] | 999 | return result; |
| 1000 | } else |
| 1001 | { |
| 1002 | if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL) |
| 1003 | return XGL_ERROR_INVALID_POINTER; |
| 1004 | // This layer compatible with all GPUs |
| 1005 | *pOutLayerCount = 1; |
Chia-I Wu | a837c52 | 2014-12-16 10:47:33 +0800 | [diff] [blame] | 1006 | strncpy((char *) pOutLayers[0], "DrawState", maxStringSize); |
Jon Ashburn | 451c16f | 2014-11-25 11:08:42 -0700 | [diff] [blame] | 1007 | return XGL_SUCCESS; |
| 1008 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1009 | } |
| 1010 | |
| 1011 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetDeviceQueue(XGL_DEVICE device, XGL_QUEUE_TYPE queueType, XGL_UINT queueIndex, XGL_QUEUE* pQueue) |
| 1012 | { |
| 1013 | XGL_RESULT result = nextTable.GetDeviceQueue(device, queueType, queueIndex, pQueue); |
| 1014 | return result; |
| 1015 | } |
| 1016 | |
| 1017 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueSubmit(XGL_QUEUE queue, XGL_UINT cmdBufferCount, const XGL_CMD_BUFFER* pCmdBuffers, XGL_UINT memRefCount, const XGL_MEMORY_REF* pMemRefs, XGL_FENCE fence) |
| 1018 | { |
| 1019 | XGL_RESULT result = nextTable.QueueSubmit(queue, cmdBufferCount, pCmdBuffers, memRefCount, pMemRefs, fence); |
| 1020 | return result; |
| 1021 | } |
| 1022 | |
| 1023 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueSetGlobalMemReferences(XGL_QUEUE queue, XGL_UINT memRefCount, const XGL_MEMORY_REF* pMemRefs) |
| 1024 | { |
| 1025 | XGL_RESULT result = nextTable.QueueSetGlobalMemReferences(queue, memRefCount, pMemRefs); |
| 1026 | return result; |
| 1027 | } |
| 1028 | |
| 1029 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueWaitIdle(XGL_QUEUE queue) |
| 1030 | { |
| 1031 | XGL_RESULT result = nextTable.QueueWaitIdle(queue); |
| 1032 | return result; |
| 1033 | } |
| 1034 | |
| 1035 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDeviceWaitIdle(XGL_DEVICE device) |
| 1036 | { |
| 1037 | XGL_RESULT result = nextTable.DeviceWaitIdle(device); |
| 1038 | return result; |
| 1039 | } |
| 1040 | |
| 1041 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetMemoryHeapCount(XGL_DEVICE device, XGL_UINT* pCount) |
| 1042 | { |
| 1043 | XGL_RESULT result = nextTable.GetMemoryHeapCount(device, pCount); |
| 1044 | return result; |
| 1045 | } |
| 1046 | |
| 1047 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetMemoryHeapInfo(XGL_DEVICE device, XGL_UINT heapId, XGL_MEMORY_HEAP_INFO_TYPE infoType, XGL_SIZE* pDataSize, XGL_VOID* pData) |
| 1048 | { |
| 1049 | XGL_RESULT result = nextTable.GetMemoryHeapInfo(device, heapId, infoType, pDataSize, pData); |
| 1050 | return result; |
| 1051 | } |
| 1052 | |
| 1053 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglAllocMemory(XGL_DEVICE device, const XGL_MEMORY_ALLOC_INFO* pAllocInfo, XGL_GPU_MEMORY* pMem) |
| 1054 | { |
| 1055 | XGL_RESULT result = nextTable.AllocMemory(device, pAllocInfo, pMem); |
| 1056 | return result; |
| 1057 | } |
| 1058 | |
| 1059 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglFreeMemory(XGL_GPU_MEMORY mem) |
| 1060 | { |
| 1061 | XGL_RESULT result = nextTable.FreeMemory(mem); |
| 1062 | return result; |
| 1063 | } |
| 1064 | |
| 1065 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSetMemoryPriority(XGL_GPU_MEMORY mem, XGL_MEMORY_PRIORITY priority) |
| 1066 | { |
| 1067 | XGL_RESULT result = nextTable.SetMemoryPriority(mem, priority); |
| 1068 | return result; |
| 1069 | } |
| 1070 | |
| 1071 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglMapMemory(XGL_GPU_MEMORY mem, XGL_FLAGS flags, XGL_VOID** ppData) |
| 1072 | { |
| 1073 | XGL_RESULT result = nextTable.MapMemory(mem, flags, ppData); |
| 1074 | return result; |
| 1075 | } |
| 1076 | |
| 1077 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglUnmapMemory(XGL_GPU_MEMORY mem) |
| 1078 | { |
| 1079 | XGL_RESULT result = nextTable.UnmapMemory(mem); |
| 1080 | return result; |
| 1081 | } |
| 1082 | |
| 1083 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglPinSystemMemory(XGL_DEVICE device, const XGL_VOID* pSysMem, XGL_SIZE memSize, XGL_GPU_MEMORY* pMem) |
| 1084 | { |
| 1085 | XGL_RESULT result = nextTable.PinSystemMemory(device, pSysMem, memSize, pMem); |
| 1086 | return result; |
| 1087 | } |
| 1088 | |
| 1089 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglRemapVirtualMemoryPages(XGL_DEVICE device, XGL_UINT rangeCount, const XGL_VIRTUAL_MEMORY_REMAP_RANGE* pRanges, XGL_UINT preWaitSemaphoreCount, const XGL_QUEUE_SEMAPHORE* pPreWaitSemaphores, XGL_UINT postSignalSemaphoreCount, const XGL_QUEUE_SEMAPHORE* pPostSignalSemaphores) |
| 1090 | { |
| 1091 | XGL_RESULT result = nextTable.RemapVirtualMemoryPages(device, rangeCount, pRanges, preWaitSemaphoreCount, pPreWaitSemaphores, postSignalSemaphoreCount, pPostSignalSemaphores); |
| 1092 | return result; |
| 1093 | } |
| 1094 | |
| 1095 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetMultiGpuCompatibility(XGL_PHYSICAL_GPU gpu0, XGL_PHYSICAL_GPU gpu1, XGL_GPU_COMPATIBILITY_INFO* pInfo) |
| 1096 | { |
| 1097 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu0; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1098 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 1099 | pthread_once(&g_initOnce, initDrawState); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1100 | XGL_RESULT result = nextTable.GetMultiGpuCompatibility((XGL_PHYSICAL_GPU)gpuw->nextObject, gpu1, pInfo); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1101 | return result; |
| 1102 | } |
| 1103 | |
| 1104 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenSharedMemory(XGL_DEVICE device, const XGL_MEMORY_OPEN_INFO* pOpenInfo, XGL_GPU_MEMORY* pMem) |
| 1105 | { |
| 1106 | XGL_RESULT result = nextTable.OpenSharedMemory(device, pOpenInfo, pMem); |
| 1107 | return result; |
| 1108 | } |
| 1109 | |
| 1110 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenSharedQueueSemaphore(XGL_DEVICE device, const XGL_QUEUE_SEMAPHORE_OPEN_INFO* pOpenInfo, XGL_QUEUE_SEMAPHORE* pSemaphore) |
| 1111 | { |
| 1112 | XGL_RESULT result = nextTable.OpenSharedQueueSemaphore(device, pOpenInfo, pSemaphore); |
| 1113 | return result; |
| 1114 | } |
| 1115 | |
| 1116 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenPeerMemory(XGL_DEVICE device, const XGL_PEER_MEMORY_OPEN_INFO* pOpenInfo, XGL_GPU_MEMORY* pMem) |
| 1117 | { |
| 1118 | XGL_RESULT result = nextTable.OpenPeerMemory(device, pOpenInfo, pMem); |
| 1119 | return result; |
| 1120 | } |
| 1121 | |
| 1122 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenPeerImage(XGL_DEVICE device, const XGL_PEER_IMAGE_OPEN_INFO* pOpenInfo, XGL_IMAGE* pImage, XGL_GPU_MEMORY* pMem) |
| 1123 | { |
| 1124 | XGL_RESULT result = nextTable.OpenPeerImage(device, pOpenInfo, pImage, pMem); |
| 1125 | return result; |
| 1126 | } |
| 1127 | |
| 1128 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyObject(XGL_OBJECT object) |
| 1129 | { |
| 1130 | XGL_RESULT result = nextTable.DestroyObject(object); |
| 1131 | return result; |
| 1132 | } |
| 1133 | |
| 1134 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetObjectInfo(XGL_BASE_OBJECT object, XGL_OBJECT_INFO_TYPE infoType, XGL_SIZE* pDataSize, XGL_VOID* pData) |
| 1135 | { |
| 1136 | XGL_RESULT result = nextTable.GetObjectInfo(object, infoType, pDataSize, pData); |
| 1137 | return result; |
| 1138 | } |
| 1139 | |
| 1140 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBindObjectMemory(XGL_OBJECT object, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset) |
| 1141 | { |
| 1142 | XGL_RESULT result = nextTable.BindObjectMemory(object, mem, offset); |
| 1143 | return result; |
| 1144 | } |
| 1145 | |
| 1146 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateFence(XGL_DEVICE device, const XGL_FENCE_CREATE_INFO* pCreateInfo, XGL_FENCE* pFence) |
| 1147 | { |
| 1148 | XGL_RESULT result = nextTable.CreateFence(device, pCreateInfo, pFence); |
| 1149 | return result; |
| 1150 | } |
| 1151 | |
| 1152 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetFenceStatus(XGL_FENCE fence) |
| 1153 | { |
| 1154 | XGL_RESULT result = nextTable.GetFenceStatus(fence); |
| 1155 | return result; |
| 1156 | } |
| 1157 | |
| 1158 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWaitForFences(XGL_DEVICE device, XGL_UINT fenceCount, const XGL_FENCE* pFences, XGL_BOOL waitAll, XGL_UINT64 timeout) |
| 1159 | { |
| 1160 | XGL_RESULT result = nextTable.WaitForFences(device, fenceCount, pFences, waitAll, timeout); |
| 1161 | return result; |
| 1162 | } |
| 1163 | |
| 1164 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateQueueSemaphore(XGL_DEVICE device, const XGL_QUEUE_SEMAPHORE_CREATE_INFO* pCreateInfo, XGL_QUEUE_SEMAPHORE* pSemaphore) |
| 1165 | { |
| 1166 | XGL_RESULT result = nextTable.CreateQueueSemaphore(device, pCreateInfo, pSemaphore); |
| 1167 | return result; |
| 1168 | } |
| 1169 | |
| 1170 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSignalQueueSemaphore(XGL_QUEUE queue, XGL_QUEUE_SEMAPHORE semaphore) |
| 1171 | { |
| 1172 | XGL_RESULT result = nextTable.SignalQueueSemaphore(queue, semaphore); |
| 1173 | return result; |
| 1174 | } |
| 1175 | |
| 1176 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWaitQueueSemaphore(XGL_QUEUE queue, XGL_QUEUE_SEMAPHORE semaphore) |
| 1177 | { |
| 1178 | XGL_RESULT result = nextTable.WaitQueueSemaphore(queue, semaphore); |
| 1179 | return result; |
| 1180 | } |
| 1181 | |
| 1182 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateEvent(XGL_DEVICE device, const XGL_EVENT_CREATE_INFO* pCreateInfo, XGL_EVENT* pEvent) |
| 1183 | { |
| 1184 | XGL_RESULT result = nextTable.CreateEvent(device, pCreateInfo, pEvent); |
| 1185 | return result; |
| 1186 | } |
| 1187 | |
| 1188 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetEventStatus(XGL_EVENT event) |
| 1189 | { |
| 1190 | XGL_RESULT result = nextTable.GetEventStatus(event); |
| 1191 | return result; |
| 1192 | } |
| 1193 | |
| 1194 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSetEvent(XGL_EVENT event) |
| 1195 | { |
| 1196 | XGL_RESULT result = nextTable.SetEvent(event); |
| 1197 | return result; |
| 1198 | } |
| 1199 | |
| 1200 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglResetEvent(XGL_EVENT event) |
| 1201 | { |
| 1202 | XGL_RESULT result = nextTable.ResetEvent(event); |
| 1203 | return result; |
| 1204 | } |
| 1205 | |
| 1206 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateQueryPool(XGL_DEVICE device, const XGL_QUERY_POOL_CREATE_INFO* pCreateInfo, XGL_QUERY_POOL* pQueryPool) |
| 1207 | { |
| 1208 | XGL_RESULT result = nextTable.CreateQueryPool(device, pCreateInfo, pQueryPool); |
| 1209 | return result; |
| 1210 | } |
| 1211 | |
| 1212 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetQueryPoolResults(XGL_QUERY_POOL queryPool, XGL_UINT startQuery, XGL_UINT queryCount, XGL_SIZE* pDataSize, XGL_VOID* pData) |
| 1213 | { |
| 1214 | XGL_RESULT result = nextTable.GetQueryPoolResults(queryPool, startQuery, queryCount, pDataSize, pData); |
| 1215 | return result; |
| 1216 | } |
| 1217 | |
| 1218 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetFormatInfo(XGL_DEVICE device, XGL_FORMAT format, XGL_FORMAT_INFO_TYPE infoType, XGL_SIZE* pDataSize, XGL_VOID* pData) |
| 1219 | { |
| 1220 | XGL_RESULT result = nextTable.GetFormatInfo(device, format, infoType, pDataSize, pData); |
| 1221 | return result; |
| 1222 | } |
| 1223 | |
| 1224 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateImage(XGL_DEVICE device, const XGL_IMAGE_CREATE_INFO* pCreateInfo, XGL_IMAGE* pImage) |
| 1225 | { |
| 1226 | XGL_RESULT result = nextTable.CreateImage(device, pCreateInfo, pImage); |
| 1227 | return result; |
| 1228 | } |
| 1229 | |
| 1230 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetImageSubresourceInfo(XGL_IMAGE image, const XGL_IMAGE_SUBRESOURCE* pSubresource, XGL_SUBRESOURCE_INFO_TYPE infoType, XGL_SIZE* pDataSize, XGL_VOID* pData) |
| 1231 | { |
| 1232 | XGL_RESULT result = nextTable.GetImageSubresourceInfo(image, pSubresource, infoType, pDataSize, pData); |
| 1233 | return result; |
| 1234 | } |
| 1235 | |
| 1236 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateImageView(XGL_DEVICE device, const XGL_IMAGE_VIEW_CREATE_INFO* pCreateInfo, XGL_IMAGE_VIEW* pView) |
| 1237 | { |
| 1238 | XGL_RESULT result = nextTable.CreateImageView(device, pCreateInfo, pView); |
| 1239 | return result; |
| 1240 | } |
| 1241 | |
| 1242 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateColorAttachmentView(XGL_DEVICE device, const XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO* pCreateInfo, XGL_COLOR_ATTACHMENT_VIEW* pView) |
| 1243 | { |
| 1244 | XGL_RESULT result = nextTable.CreateColorAttachmentView(device, pCreateInfo, pView); |
| 1245 | return result; |
| 1246 | } |
| 1247 | |
| 1248 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDepthStencilView(XGL_DEVICE device, const XGL_DEPTH_STENCIL_VIEW_CREATE_INFO* pCreateInfo, XGL_DEPTH_STENCIL_VIEW* pView) |
| 1249 | { |
| 1250 | XGL_RESULT result = nextTable.CreateDepthStencilView(device, pCreateInfo, pView); |
| 1251 | return result; |
| 1252 | } |
| 1253 | |
| 1254 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateShader(XGL_DEVICE device, const XGL_SHADER_CREATE_INFO* pCreateInfo, XGL_SHADER* pShader) |
| 1255 | { |
| 1256 | XGL_RESULT result = nextTable.CreateShader(device, pCreateInfo, pShader); |
| 1257 | return result; |
| 1258 | } |
| 1259 | |
| 1260 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateGraphicsPipeline(XGL_DEVICE device, const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo, XGL_PIPELINE* pPipeline) |
| 1261 | { |
| 1262 | XGL_RESULT result = nextTable.CreateGraphicsPipeline(device, pCreateInfo, pPipeline); |
| 1263 | // Create LL HEAD for this Pipeline |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1264 | char str[1024]; |
| 1265 | sprintf(str, "Created Gfx Pipeline %p", (void*)*pPipeline); |
| 1266 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pPipeline, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1267 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1268 | PIPELINE_NODE *pTrav = pPipelineHead; |
| 1269 | if (pTrav) { |
| 1270 | while (pTrav->pNext) |
| 1271 | pTrav = pTrav->pNext; |
| 1272 | pTrav->pNext = (PIPELINE_NODE*)malloc(sizeof(PIPELINE_NODE)); |
| 1273 | pTrav = pTrav->pNext; |
| 1274 | } |
| 1275 | else { |
| 1276 | pTrav = (PIPELINE_NODE*)malloc(sizeof(PIPELINE_NODE)); |
| 1277 | pPipelineHead = pTrav; |
| 1278 | } |
| 1279 | memset((void*)pTrav, 0, sizeof(PIPELINE_NODE)); |
| 1280 | pTrav->pipeline = *pPipeline; |
| 1281 | initPipeline(pTrav, pCreateInfo); |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1282 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1283 | return result; |
| 1284 | } |
| 1285 | |
| 1286 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateComputePipeline(XGL_DEVICE device, const XGL_COMPUTE_PIPELINE_CREATE_INFO* pCreateInfo, XGL_PIPELINE* pPipeline) |
| 1287 | { |
| 1288 | XGL_RESULT result = nextTable.CreateComputePipeline(device, pCreateInfo, pPipeline); |
| 1289 | return result; |
| 1290 | } |
| 1291 | |
| 1292 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglStorePipeline(XGL_PIPELINE pipeline, XGL_SIZE* pDataSize, XGL_VOID* pData) |
| 1293 | { |
| 1294 | XGL_RESULT result = nextTable.StorePipeline(pipeline, pDataSize, pData); |
| 1295 | return result; |
| 1296 | } |
| 1297 | |
| 1298 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglLoadPipeline(XGL_DEVICE device, XGL_SIZE dataSize, const XGL_VOID* pData, XGL_PIPELINE* pPipeline) |
| 1299 | { |
| 1300 | XGL_RESULT result = nextTable.LoadPipeline(device, dataSize, pData, pPipeline); |
| 1301 | return result; |
| 1302 | } |
| 1303 | |
| 1304 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreatePipelineDelta(XGL_DEVICE device, XGL_PIPELINE p1, XGL_PIPELINE p2, XGL_PIPELINE_DELTA* delta) |
| 1305 | { |
| 1306 | XGL_RESULT result = nextTable.CreatePipelineDelta(device, p1, p2, delta); |
| 1307 | return result; |
| 1308 | } |
| 1309 | |
| 1310 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateSampler(XGL_DEVICE device, const XGL_SAMPLER_CREATE_INFO* pCreateInfo, XGL_SAMPLER* pSampler) |
| 1311 | { |
| 1312 | XGL_RESULT result = nextTable.CreateSampler(device, pCreateInfo, pSampler); |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1313 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 5a1d9f3 | 2014-11-20 10:48:56 -0700 | [diff] [blame] | 1314 | SAMPLER_NODE *pNewNode = (SAMPLER_NODE*)malloc(sizeof(SAMPLER_NODE)); |
| 1315 | pNewNode->sampler = *pSampler; |
| 1316 | memcpy(&pNewNode->createInfo, pCreateInfo, sizeof(XGL_SAMPLER_CREATE_INFO)); |
| 1317 | pNewNode->pNext = pSamplerHead; |
| 1318 | pSamplerHead = pNewNode; |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1319 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1320 | return result; |
| 1321 | } |
| 1322 | |
| 1323 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDescriptorSet(XGL_DEVICE device, const XGL_DESCRIPTOR_SET_CREATE_INFO* pCreateInfo, XGL_DESCRIPTOR_SET* pDescriptorSet) |
| 1324 | { |
| 1325 | XGL_RESULT result = nextTable.CreateDescriptorSet(device, pCreateInfo, pDescriptorSet); |
| 1326 | // Create LL chain |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1327 | char str[1024]; |
| 1328 | sprintf(str, "Created Descriptor Set (DS) %p", (void*)*pDescriptorSet); |
| 1329 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pDescriptorSet, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1330 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1331 | DS_LL_HEAD *pTrav = pDSHead; |
| 1332 | if (pTrav) { |
| 1333 | // Grow existing list |
| 1334 | while (pTrav->pNextDS) |
| 1335 | pTrav = pTrav->pNextDS; |
| 1336 | pTrav->pNextDS = (DS_LL_HEAD*)malloc(sizeof(DS_LL_HEAD)); |
| 1337 | pTrav = pTrav->pNextDS; |
| 1338 | } |
| 1339 | else { // Create new list |
| 1340 | pTrav = (DS_LL_HEAD*)malloc(sizeof(DS_LL_HEAD)); |
| 1341 | pDSHead = pTrav; |
| 1342 | } |
| 1343 | pTrav->dsSlot = (DS_SLOT*)malloc(sizeof(DS_SLOT) * pCreateInfo->slots); |
| 1344 | pTrav->dsID = *pDescriptorSet; |
| 1345 | pTrav->numSlots = pCreateInfo->slots; |
| 1346 | pTrav->pNextDS = NULL; |
| 1347 | pTrav->updateActive = XGL_FALSE; |
| 1348 | initDS(pTrav); |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1349 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1350 | return result; |
| 1351 | } |
| 1352 | |
| 1353 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglBeginDescriptorSetUpdate(XGL_DESCRIPTOR_SET descriptorSet) |
| 1354 | { |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 1355 | DS_LL_HEAD* pDS = getDS(descriptorSet); |
| 1356 | if (!pDS) { |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1357 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1358 | char str[1024]; |
| 1359 | sprintf(str, "Specified Descriptor Set %p does not exist!", (void*)descriptorSet); |
| 1360 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_INVALID_DS, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1361 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 1362 | else { |
| 1363 | pDS->updateActive = XGL_TRUE; |
| 1364 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1365 | nextTable.BeginDescriptorSetUpdate(descriptorSet); |
| 1366 | } |
| 1367 | |
| 1368 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglEndDescriptorSetUpdate(XGL_DESCRIPTOR_SET descriptorSet) |
| 1369 | { |
| 1370 | if (!dsUpdate(descriptorSet)) { |
| 1371 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1372 | char str[1024]; |
| 1373 | sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglEndDescriptorSetUpdate()!", (void*)descriptorSet); |
| 1374 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_END_WITHOUT_BEGIN, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1375 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 1376 | else { |
| 1377 | DS_LL_HEAD* pDS = getDS(descriptorSet); |
| 1378 | if (!pDS) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1379 | char str[1024]; |
| 1380 | sprintf(str, "Specified Descriptor Set %p does not exist!", (void*)descriptorSet); |
| 1381 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_INVALID_DS, "DS", str); |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 1382 | } |
| 1383 | else { |
| 1384 | pDS->updateActive = XGL_FALSE; |
| 1385 | } |
| 1386 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1387 | nextTable.EndDescriptorSetUpdate(descriptorSet); |
| 1388 | } |
| 1389 | |
| 1390 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglAttachSamplerDescriptors(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_SAMPLER* pSamplers) |
| 1391 | { |
| 1392 | if (!dsUpdate(descriptorSet)) { |
| 1393 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1394 | char str[1024]; |
| 1395 | sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglAttachSamplerDescriptors()!", (void*)descriptorSet); |
| 1396 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_ATTACH_WITHOUT_BEGIN, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1397 | } |
| 1398 | else { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1399 | if (!dsSamplerMapping(descriptorSet, startSlot, slotCount, pSamplers)) { |
| 1400 | char str[1024]; |
| 1401 | sprintf(str, "Unable to attach sampler descriptors to DS %p!", (void*)descriptorSet); |
| 1402 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_SAMPLE_ATTACH_FAILED, "DS", str); |
| 1403 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1404 | } |
| 1405 | nextTable.AttachSamplerDescriptors(descriptorSet, startSlot, slotCount, pSamplers); |
| 1406 | } |
| 1407 | |
| 1408 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglAttachImageViewDescriptors(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_IMAGE_VIEW_ATTACH_INFO* pImageViews) |
| 1409 | { |
| 1410 | if (!dsUpdate(descriptorSet)) { |
| 1411 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1412 | char str[1024]; |
| 1413 | sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglAttachSamplerDescriptors()!", (void*)descriptorSet); |
| 1414 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_ATTACH_WITHOUT_BEGIN, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1415 | } |
| 1416 | else { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1417 | if (!dsImageMapping(descriptorSet, startSlot, slotCount, pImageViews)) { |
| 1418 | char str[1024]; |
| 1419 | sprintf(str, "Unable to attach image view descriptors to DS %p!", (void*)descriptorSet); |
| 1420 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_IMAGE_ATTACH_FAILED, "DS", str); |
| 1421 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1422 | } |
| 1423 | nextTable.AttachImageViewDescriptors(descriptorSet, startSlot, slotCount, pImageViews); |
| 1424 | } |
| 1425 | |
| 1426 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglAttachMemoryViewDescriptors(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_MEMORY_VIEW_ATTACH_INFO* pMemViews) |
| 1427 | { |
| 1428 | if (!dsUpdate(descriptorSet)) { |
| 1429 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1430 | char str[1024]; |
| 1431 | sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglAttachSamplerDescriptors()!", (void*)descriptorSet); |
| 1432 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_ATTACH_WITHOUT_BEGIN, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1433 | } |
| 1434 | else { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1435 | if (!dsMemMapping(descriptorSet, startSlot, slotCount, pMemViews)) { |
| 1436 | char str[1024]; |
| 1437 | sprintf(str, "Unable to attach memory view descriptors to DS %p!", (void*)descriptorSet); |
| 1438 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_MEMORY_ATTACH_FAILED, "DS", str); |
| 1439 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1440 | } |
| 1441 | nextTable.AttachMemoryViewDescriptors(descriptorSet, startSlot, slotCount, pMemViews); |
| 1442 | } |
| 1443 | |
| 1444 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglAttachNestedDescriptors(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_DESCRIPTOR_SET_ATTACH_INFO* pNestedDescriptorSets) |
| 1445 | { |
| 1446 | if (!dsUpdate(descriptorSet)) { |
| 1447 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1448 | char str[1024]; |
| 1449 | sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglAttachSamplerDescriptors()!", (void*)descriptorSet); |
| 1450 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_ATTACH_WITHOUT_BEGIN, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1451 | } |
| 1452 | nextTable.AttachNestedDescriptors(descriptorSet, startSlot, slotCount, pNestedDescriptorSets); |
| 1453 | } |
| 1454 | |
| 1455 | // TODO : Does xglBeginDescriptorSetUpdate() have to be called before this function? |
| 1456 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglClearDescriptorSetSlots(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount) |
| 1457 | { |
| 1458 | if (!dsUpdate(descriptorSet)) { |
| 1459 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1460 | char str[1024]; |
| 1461 | sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglClearDescriptorSetSlots()!", (void*)descriptorSet); |
| 1462 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_ATTACH_WITHOUT_BEGIN, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1463 | } |
| 1464 | if (!clearDS(descriptorSet, startSlot, slotCount)) { |
| 1465 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1466 | char str[1024]; |
| 1467 | sprintf(str, "Unable to perform xglClearDescriptorSetSlots(%p, %u, %u) call!", descriptorSet, startSlot, slotCount); |
| 1468 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_CLEAR_DS_FAILED, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1469 | } |
| 1470 | nextTable.ClearDescriptorSetSlots(descriptorSet, startSlot, slotCount); |
| 1471 | } |
| 1472 | |
| 1473 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateViewportState(XGL_DEVICE device, const XGL_VIEWPORT_STATE_CREATE_INFO* pCreateInfo, XGL_VIEWPORT_STATE_OBJECT* pState) |
| 1474 | { |
| 1475 | XGL_RESULT result = nextTable.CreateViewportState(device, pCreateInfo, pState); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 1476 | insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_VIEWPORT); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1477 | return result; |
| 1478 | } |
| 1479 | |
| 1480 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateRasterState(XGL_DEVICE device, const XGL_RASTER_STATE_CREATE_INFO* pCreateInfo, XGL_RASTER_STATE_OBJECT* pState) |
| 1481 | { |
| 1482 | XGL_RESULT result = nextTable.CreateRasterState(device, pCreateInfo, pState); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 1483 | insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_RASTER); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1484 | return result; |
| 1485 | } |
| 1486 | |
| 1487 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateMsaaState(XGL_DEVICE device, const XGL_MSAA_STATE_CREATE_INFO* pCreateInfo, XGL_MSAA_STATE_OBJECT* pState) |
| 1488 | { |
| 1489 | XGL_RESULT result = nextTable.CreateMsaaState(device, pCreateInfo, pState); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 1490 | insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_MSAA); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1491 | return result; |
| 1492 | } |
| 1493 | |
| 1494 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateColorBlendState(XGL_DEVICE device, const XGL_COLOR_BLEND_STATE_CREATE_INFO* pCreateInfo, XGL_COLOR_BLEND_STATE_OBJECT* pState) |
| 1495 | { |
| 1496 | XGL_RESULT result = nextTable.CreateColorBlendState(device, pCreateInfo, pState); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 1497 | insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_COLOR_BLEND); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1498 | return result; |
| 1499 | } |
| 1500 | |
| 1501 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDepthStencilState(XGL_DEVICE device, const XGL_DEPTH_STENCIL_STATE_CREATE_INFO* pCreateInfo, XGL_DEPTH_STENCIL_STATE_OBJECT* pState) |
| 1502 | { |
| 1503 | XGL_RESULT result = nextTable.CreateDepthStencilState(device, pCreateInfo, pState); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 1504 | insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_DEPTH_STENCIL); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1505 | return result; |
| 1506 | } |
| 1507 | |
| 1508 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateCommandBuffer(XGL_DEVICE device, const XGL_CMD_BUFFER_CREATE_INFO* pCreateInfo, XGL_CMD_BUFFER* pCmdBuffer) |
| 1509 | { |
| 1510 | XGL_RESULT result = nextTable.CreateCommandBuffer(device, pCreateInfo, pCmdBuffer); |
| 1511 | return result; |
| 1512 | } |
| 1513 | |
| 1514 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBeginCommandBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_FLAGS flags) |
| 1515 | { |
| 1516 | XGL_RESULT result = nextTable.BeginCommandBuffer(cmdBuffer, flags); |
| 1517 | return result; |
| 1518 | } |
| 1519 | |
| 1520 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEndCommandBuffer(XGL_CMD_BUFFER cmdBuffer) |
| 1521 | { |
| 1522 | XGL_RESULT result = nextTable.EndCommandBuffer(cmdBuffer); |
| 1523 | return result; |
| 1524 | } |
| 1525 | |
| 1526 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglResetCommandBuffer(XGL_CMD_BUFFER cmdBuffer) |
| 1527 | { |
| 1528 | XGL_RESULT result = nextTable.ResetCommandBuffer(cmdBuffer); |
| 1529 | return result; |
| 1530 | } |
| 1531 | |
| 1532 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindPipeline(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE pipeline) |
| 1533 | { |
| 1534 | if (getPipeline(pipeline)) { |
| 1535 | lastBoundPipeline = pipeline; |
| 1536 | } |
| 1537 | else { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1538 | char str[1024]; |
| 1539 | sprintf(str, "Attempt to bind Pipeline %p that doesn't exist!", (void*)pipeline); |
| 1540 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pipeline, 0, DRAWSTATE_INVALID_PIPELINE, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1541 | } |
| 1542 | nextTable.CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline); |
| 1543 | } |
| 1544 | |
| 1545 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindPipelineDelta(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE_DELTA delta) |
| 1546 | { |
| 1547 | nextTable.CmdBindPipelineDelta(cmdBuffer, pipelineBindPoint, delta); |
| 1548 | } |
| 1549 | |
| 1550 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindStateObject(XGL_CMD_BUFFER cmdBuffer, XGL_STATE_BIND_POINT stateBindPoint, XGL_STATE_OBJECT state) |
| 1551 | { |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 1552 | setLastBoundDynamicState(state, stateBindPoint); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1553 | nextTable.CmdBindStateObject(cmdBuffer, stateBindPoint, state); |
| 1554 | } |
| 1555 | |
| 1556 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindDescriptorSet(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_UINT index, XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT slotOffset) |
| 1557 | { |
| 1558 | if (getDS(descriptorSet)) { |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 1559 | assert(index < XGL_MAX_DESCRIPTOR_SETS); |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1560 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1561 | lastBoundDS[index] = descriptorSet; |
Tobin Ehlis | eacc64f | 2014-11-24 17:09:09 -0700 | [diff] [blame] | 1562 | lastBoundSlotOffset[index] = slotOffset; |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1563 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1564 | char str[1024]; |
| 1565 | sprintf(str, "DS %p bound to DS index %u on pipeline %s", (void*)descriptorSet, index, string_XGL_PIPELINE_BIND_POINT(pipelineBindPoint)); |
| 1566 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1567 | } |
| 1568 | else { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1569 | char str[1024]; |
| 1570 | sprintf(str, "Attempt to bind DS %p that doesn't exist!", (void*)descriptorSet); |
| 1571 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_INVALID_DS, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1572 | } |
| 1573 | nextTable.CmdBindDescriptorSet(cmdBuffer, pipelineBindPoint, index, descriptorSet, slotOffset); |
| 1574 | } |
| 1575 | |
| 1576 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindDynamicMemoryView(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, const XGL_MEMORY_VIEW_ATTACH_INFO* pMemView) |
| 1577 | { |
| 1578 | nextTable.CmdBindDynamicMemoryView(cmdBuffer, pipelineBindPoint, pMemView); |
| 1579 | } |
| 1580 | |
Chia-I Wu | 3b04af5 | 2014-11-08 10:48:20 +0800 | [diff] [blame] | 1581 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindVertexData(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset, XGL_UINT binding) |
| 1582 | { |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 1583 | lastVtxBinding = binding; |
Chia-I Wu | 3b04af5 | 2014-11-08 10:48:20 +0800 | [diff] [blame] | 1584 | nextTable.CmdBindVertexData(cmdBuffer, mem, offset, binding); |
| 1585 | } |
| 1586 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1587 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindIndexData(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset, XGL_INDEX_TYPE indexType) |
| 1588 | { |
| 1589 | nextTable.CmdBindIndexData(cmdBuffer, mem, offset, indexType); |
| 1590 | } |
| 1591 | |
| 1592 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindAttachments(XGL_CMD_BUFFER cmdBuffer, XGL_UINT colorAttachmentCount, const XGL_COLOR_ATTACHMENT_BIND_INFO* pColorAttachments, const XGL_DEPTH_STENCIL_BIND_INFO* pDepthStencilAttachment) |
| 1593 | { |
| 1594 | nextTable.CmdBindAttachments(cmdBuffer, colorAttachmentCount, pColorAttachments, pDepthStencilAttachment); |
| 1595 | } |
| 1596 | |
| 1597 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdPrepareMemoryRegions(XGL_CMD_BUFFER cmdBuffer, XGL_UINT transitionCount, const XGL_MEMORY_STATE_TRANSITION* pStateTransitions) |
| 1598 | { |
| 1599 | nextTable.CmdPrepareMemoryRegions(cmdBuffer, transitionCount, pStateTransitions); |
| 1600 | } |
| 1601 | |
| 1602 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdPrepareImages(XGL_CMD_BUFFER cmdBuffer, XGL_UINT transitionCount, const XGL_IMAGE_STATE_TRANSITION* pStateTransitions) |
| 1603 | { |
| 1604 | nextTable.CmdPrepareImages(cmdBuffer, transitionCount, pStateTransitions); |
| 1605 | } |
| 1606 | |
| 1607 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDraw(XGL_CMD_BUFFER cmdBuffer, XGL_UINT firstVertex, XGL_UINT vertexCount, XGL_UINT firstInstance, XGL_UINT instanceCount) |
| 1608 | { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1609 | char str[1024]; |
| 1610 | sprintf(str, "xglCmdDraw() call #%lu, reporting DS state:", drawCount[DRAW]++); |
| 1611 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1612 | synchAndPrintDSConfig(); |
| 1613 | nextTable.CmdDraw(cmdBuffer, firstVertex, vertexCount, firstInstance, instanceCount); |
| 1614 | } |
| 1615 | |
| 1616 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDrawIndexed(XGL_CMD_BUFFER cmdBuffer, XGL_UINT firstIndex, XGL_UINT indexCount, XGL_INT vertexOffset, XGL_UINT firstInstance, XGL_UINT instanceCount) |
| 1617 | { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1618 | char str[1024]; |
Tobin Ehlis | 6208641 | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1619 | sprintf(str, "xglCmdDrawIndexed() call #%lu, reporting DS state:", drawCount[DRAW_INDEXED]++); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1620 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 1621 | synchAndPrintDSConfig(); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1622 | nextTable.CmdDrawIndexed(cmdBuffer, firstIndex, indexCount, vertexOffset, firstInstance, instanceCount); |
| 1623 | } |
| 1624 | |
| 1625 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDrawIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset, XGL_UINT32 count, XGL_UINT32 stride) |
| 1626 | { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1627 | char str[1024]; |
Tobin Ehlis | 6208641 | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1628 | sprintf(str, "xglCmdDrawIndirect() call #%lu, reporting DS state:", drawCount[DRAW_INDIRECT]++); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1629 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 1630 | synchAndPrintDSConfig(); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1631 | nextTable.CmdDrawIndirect(cmdBuffer, mem, offset, count, stride); |
| 1632 | } |
| 1633 | |
| 1634 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDrawIndexedIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset, XGL_UINT32 count, XGL_UINT32 stride) |
| 1635 | { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1636 | char str[1024]; |
Tobin Ehlis | 6208641 | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1637 | sprintf(str, "xglCmdDrawIndexedIndirect() call #%lu, reporting DS state:", drawCount[DRAW_INDEXED_INDIRECT]++); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1638 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str); |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 1639 | synchAndPrintDSConfig(); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1640 | nextTable.CmdDrawIndexedIndirect(cmdBuffer, mem, offset, count, stride); |
| 1641 | } |
| 1642 | |
| 1643 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDispatch(XGL_CMD_BUFFER cmdBuffer, XGL_UINT x, XGL_UINT y, XGL_UINT z) |
| 1644 | { |
| 1645 | nextTable.CmdDispatch(cmdBuffer, x, y, z); |
| 1646 | } |
| 1647 | |
| 1648 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDispatchIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset) |
| 1649 | { |
| 1650 | nextTable.CmdDispatchIndirect(cmdBuffer, mem, offset); |
| 1651 | } |
| 1652 | |
| 1653 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdCopyMemory(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY srcMem, XGL_GPU_MEMORY destMem, XGL_UINT regionCount, const XGL_MEMORY_COPY* pRegions) |
| 1654 | { |
| 1655 | nextTable.CmdCopyMemory(cmdBuffer, srcMem, destMem, regionCount, pRegions); |
| 1656 | } |
| 1657 | |
| 1658 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdCopyImage(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_IMAGE destImage, XGL_UINT regionCount, const XGL_IMAGE_COPY* pRegions) |
| 1659 | { |
| 1660 | nextTable.CmdCopyImage(cmdBuffer, srcImage, destImage, regionCount, pRegions); |
| 1661 | } |
| 1662 | |
| 1663 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdCopyMemoryToImage(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY srcMem, XGL_IMAGE destImage, XGL_UINT regionCount, const XGL_MEMORY_IMAGE_COPY* pRegions) |
| 1664 | { |
| 1665 | nextTable.CmdCopyMemoryToImage(cmdBuffer, srcMem, destImage, regionCount, pRegions); |
| 1666 | } |
| 1667 | |
| 1668 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdCopyImageToMemory(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_GPU_MEMORY destMem, XGL_UINT regionCount, const XGL_MEMORY_IMAGE_COPY* pRegions) |
| 1669 | { |
| 1670 | nextTable.CmdCopyImageToMemory(cmdBuffer, srcImage, destMem, regionCount, pRegions); |
| 1671 | } |
| 1672 | |
| 1673 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdCloneImageData(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_IMAGE_STATE srcImageState, XGL_IMAGE destImage, XGL_IMAGE_STATE destImageState) |
| 1674 | { |
| 1675 | nextTable.CmdCloneImageData(cmdBuffer, srcImage, srcImageState, destImage, destImageState); |
| 1676 | } |
| 1677 | |
| 1678 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdUpdateMemory(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY destMem, XGL_GPU_SIZE destOffset, XGL_GPU_SIZE dataSize, const XGL_UINT32* pData) |
| 1679 | { |
| 1680 | nextTable.CmdUpdateMemory(cmdBuffer, destMem, destOffset, dataSize, pData); |
| 1681 | } |
| 1682 | |
| 1683 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdFillMemory(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY destMem, XGL_GPU_SIZE destOffset, XGL_GPU_SIZE fillSize, XGL_UINT32 data) |
| 1684 | { |
| 1685 | nextTable.CmdFillMemory(cmdBuffer, destMem, destOffset, fillSize, data); |
| 1686 | } |
| 1687 | |
| 1688 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdClearColorImage(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE image, const XGL_FLOAT color[4], XGL_UINT rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges) |
| 1689 | { |
| 1690 | nextTable.CmdClearColorImage(cmdBuffer, image, color, rangeCount, pRanges); |
| 1691 | } |
| 1692 | |
| 1693 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdClearColorImageRaw(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE image, const XGL_UINT32 color[4], XGL_UINT rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges) |
| 1694 | { |
| 1695 | nextTable.CmdClearColorImageRaw(cmdBuffer, image, color, rangeCount, pRanges); |
| 1696 | } |
| 1697 | |
| 1698 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdClearDepthStencil(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE image, XGL_FLOAT depth, XGL_UINT32 stencil, XGL_UINT rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges) |
| 1699 | { |
| 1700 | nextTable.CmdClearDepthStencil(cmdBuffer, image, depth, stencil, rangeCount, pRanges); |
| 1701 | } |
| 1702 | |
| 1703 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdResolveImage(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_IMAGE destImage, XGL_UINT rectCount, const XGL_IMAGE_RESOLVE* pRects) |
| 1704 | { |
| 1705 | nextTable.CmdResolveImage(cmdBuffer, srcImage, destImage, rectCount, pRects); |
| 1706 | } |
| 1707 | |
| 1708 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdSetEvent(XGL_CMD_BUFFER cmdBuffer, XGL_EVENT event) |
| 1709 | { |
| 1710 | nextTable.CmdSetEvent(cmdBuffer, event); |
| 1711 | } |
| 1712 | |
| 1713 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdResetEvent(XGL_CMD_BUFFER cmdBuffer, XGL_EVENT event) |
| 1714 | { |
| 1715 | nextTable.CmdResetEvent(cmdBuffer, event); |
| 1716 | } |
| 1717 | |
| 1718 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdMemoryAtomic(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY destMem, XGL_GPU_SIZE destOffset, XGL_UINT64 srcData, XGL_ATOMIC_OP atomicOp) |
| 1719 | { |
| 1720 | nextTable.CmdMemoryAtomic(cmdBuffer, destMem, destOffset, srcData, atomicOp); |
| 1721 | } |
| 1722 | |
| 1723 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBeginQuery(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, XGL_UINT slot, XGL_FLAGS flags) |
| 1724 | { |
| 1725 | nextTable.CmdBeginQuery(cmdBuffer, queryPool, slot, flags); |
| 1726 | } |
| 1727 | |
| 1728 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdEndQuery(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, XGL_UINT slot) |
| 1729 | { |
| 1730 | nextTable.CmdEndQuery(cmdBuffer, queryPool, slot); |
| 1731 | } |
| 1732 | |
| 1733 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdResetQueryPool(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, XGL_UINT startQuery, XGL_UINT queryCount) |
| 1734 | { |
| 1735 | nextTable.CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount); |
| 1736 | } |
| 1737 | |
| 1738 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdWriteTimestamp(XGL_CMD_BUFFER cmdBuffer, XGL_TIMESTAMP_TYPE timestampType, XGL_GPU_MEMORY destMem, XGL_GPU_SIZE destOffset) |
| 1739 | { |
| 1740 | nextTable.CmdWriteTimestamp(cmdBuffer, timestampType, destMem, destOffset); |
| 1741 | } |
| 1742 | |
| 1743 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdInitAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_UINT startCounter, XGL_UINT counterCount, const XGL_UINT32* pData) |
| 1744 | { |
| 1745 | nextTable.CmdInitAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData); |
| 1746 | } |
| 1747 | |
| 1748 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdLoadAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_UINT startCounter, XGL_UINT counterCount, XGL_GPU_MEMORY srcMem, XGL_GPU_SIZE srcOffset) |
| 1749 | { |
| 1750 | nextTable.CmdLoadAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, srcMem, srcOffset); |
| 1751 | } |
| 1752 | |
| 1753 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdSaveAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_UINT startCounter, XGL_UINT counterCount, XGL_GPU_MEMORY destMem, XGL_GPU_SIZE destOffset) |
| 1754 | { |
| 1755 | nextTable.CmdSaveAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, destMem, destOffset); |
| 1756 | } |
| 1757 | |
| 1758 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetValidationLevel(XGL_DEVICE device, XGL_VALIDATION_LEVEL validationLevel) |
| 1759 | { |
| 1760 | XGL_RESULT result = nextTable.DbgSetValidationLevel(device, validationLevel); |
| 1761 | return result; |
| 1762 | } |
| 1763 | |
| 1764 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgRegisterMsgCallback(XGL_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, XGL_VOID* pUserData) |
| 1765 | { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1766 | // This layer intercepts callbacks |
| 1767 | XGL_LAYER_DBG_FUNCTION_NODE *pNewDbgFuncNode = (XGL_LAYER_DBG_FUNCTION_NODE*)malloc(sizeof(XGL_LAYER_DBG_FUNCTION_NODE)); |
| 1768 | if (!pNewDbgFuncNode) |
| 1769 | return XGL_ERROR_OUT_OF_MEMORY; |
| 1770 | pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback; |
| 1771 | pNewDbgFuncNode->pUserData = pUserData; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 1772 | pNewDbgFuncNode->pNext = g_pDbgFunctionHead; |
| 1773 | g_pDbgFunctionHead = pNewDbgFuncNode; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1774 | XGL_RESULT result = nextTable.DbgRegisterMsgCallback(pfnMsgCallback, pUserData); |
| 1775 | return result; |
| 1776 | } |
| 1777 | |
| 1778 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgUnregisterMsgCallback(XGL_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback) |
| 1779 | { |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 1780 | XGL_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead; |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1781 | XGL_LAYER_DBG_FUNCTION_NODE *pPrev = pTrav; |
| 1782 | while (pTrav) { |
| 1783 | if (pTrav->pfnMsgCallback == pfnMsgCallback) { |
| 1784 | pPrev->pNext = pTrav->pNext; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 1785 | if (g_pDbgFunctionHead == pTrav) |
| 1786 | g_pDbgFunctionHead = pTrav->pNext; |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1787 | free(pTrav); |
| 1788 | break; |
| 1789 | } |
| 1790 | pPrev = pTrav; |
| 1791 | pTrav = pTrav->pNext; |
| 1792 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1793 | XGL_RESULT result = nextTable.DbgUnregisterMsgCallback(pfnMsgCallback); |
| 1794 | return result; |
| 1795 | } |
| 1796 | |
| 1797 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetMessageFilter(XGL_DEVICE device, XGL_INT msgCode, XGL_DBG_MSG_FILTER filter) |
| 1798 | { |
| 1799 | XGL_RESULT result = nextTable.DbgSetMessageFilter(device, msgCode, filter); |
| 1800 | return result; |
| 1801 | } |
| 1802 | |
| 1803 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetObjectTag(XGL_BASE_OBJECT object, XGL_SIZE tagSize, const XGL_VOID* pTag) |
| 1804 | { |
| 1805 | XGL_RESULT result = nextTable.DbgSetObjectTag(object, tagSize, pTag); |
| 1806 | return result; |
| 1807 | } |
| 1808 | |
| 1809 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetGlobalOption(XGL_DBG_GLOBAL_OPTION dbgOption, XGL_SIZE dataSize, const XGL_VOID* pData) |
| 1810 | { |
| 1811 | XGL_RESULT result = nextTable.DbgSetGlobalOption(dbgOption, dataSize, pData); |
| 1812 | return result; |
| 1813 | } |
| 1814 | |
| 1815 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetDeviceOption(XGL_DEVICE device, XGL_DBG_DEVICE_OPTION dbgOption, XGL_SIZE dataSize, const XGL_VOID* pData) |
| 1816 | { |
| 1817 | XGL_RESULT result = nextTable.DbgSetDeviceOption(device, dbgOption, dataSize, pData); |
| 1818 | return result; |
| 1819 | } |
| 1820 | |
| 1821 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDbgMarkerBegin(XGL_CMD_BUFFER cmdBuffer, const XGL_CHAR* pMarker) |
| 1822 | { |
| 1823 | nextTable.CmdDbgMarkerBegin(cmdBuffer, pMarker); |
| 1824 | } |
| 1825 | |
| 1826 | XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDbgMarkerEnd(XGL_CMD_BUFFER cmdBuffer) |
| 1827 | { |
| 1828 | nextTable.CmdDbgMarkerEnd(cmdBuffer); |
| 1829 | } |
| 1830 | |
| 1831 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11AssociateConnection(XGL_PHYSICAL_GPU gpu, const XGL_WSI_X11_CONNECTION_INFO* pConnectionInfo) |
| 1832 | { |
| 1833 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1834 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 1835 | pthread_once(&g_initOnce, initDrawState); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1836 | XGL_RESULT result = nextTable.WsiX11AssociateConnection((XGL_PHYSICAL_GPU)gpuw->nextObject, pConnectionInfo); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1837 | return result; |
| 1838 | } |
| 1839 | |
Chia-I Wu | 6204f34 | 2014-11-07 13:33:45 +0800 | [diff] [blame] | 1840 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11GetMSC(XGL_DEVICE device, xcb_window_t window, xcb_randr_crtc_t crtc, XGL_UINT64* pMsc) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1841 | { |
Chia-I Wu | 6204f34 | 2014-11-07 13:33:45 +0800 | [diff] [blame] | 1842 | XGL_RESULT result = nextTable.WsiX11GetMSC(device, window, crtc, pMsc); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1843 | return result; |
| 1844 | } |
| 1845 | |
| 1846 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11CreatePresentableImage(XGL_DEVICE device, const XGL_WSI_X11_PRESENTABLE_IMAGE_CREATE_INFO* pCreateInfo, XGL_IMAGE* pImage, XGL_GPU_MEMORY* pMem) |
| 1847 | { |
| 1848 | XGL_RESULT result = nextTable.WsiX11CreatePresentableImage(device, pCreateInfo, pImage, pMem); |
| 1849 | return result; |
| 1850 | } |
| 1851 | |
| 1852 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11QueuePresent(XGL_QUEUE queue, const XGL_WSI_X11_PRESENT_INFO* pPresentInfo, XGL_FENCE fence) |
| 1853 | { |
| 1854 | XGL_RESULT result = nextTable.WsiX11QueuePresent(queue, pPresentInfo, fence); |
| 1855 | return result; |
| 1856 | } |
| 1857 | |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 1858 | XGL_VOID drawStateDumpDotFile(char* outFileName) |
| 1859 | { |
| 1860 | dumpDotFile(outFileName); |
| 1861 | } |
| 1862 | |
Tobin Ehlis | 266473d | 2014-12-16 17:34:50 -0700 | [diff] [blame] | 1863 | XGL_VOID drawStateDumpPngFile(char* outFileName) |
| 1864 | { |
| 1865 | char dotExe[32] = "/usr/bin/dot"; |
| 1866 | if( access(dotExe, X_OK) != -1) { |
| 1867 | dumpDotFile("/tmp/tmp.dot"); |
| 1868 | char dotCmd[1024]; |
| 1869 | sprintf(dotCmd, "%s /tmp/tmp.dot -Tpng -o %s", dotExe, outFileName); |
| 1870 | system(dotCmd); |
| 1871 | remove("/tmp/tmp.dot"); |
| 1872 | } |
| 1873 | else { |
| 1874 | char str[1024]; |
| 1875 | sprintf(str, "Cannot execute dot program at (%s) to dump requested %s file.", dotExe, outFileName); |
| 1876 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_MISSING_DOT_PROGRAM, "DS", str); |
| 1877 | } |
| 1878 | } |
| 1879 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1880 | XGL_LAYER_EXPORT XGL_VOID* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const XGL_CHAR* funcName) |
| 1881 | { |
| 1882 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
Chia-I Wu | 706533e | 2015-01-05 13:18:57 +0800 | [diff] [blame] | 1883 | void *addr; |
| 1884 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1885 | if (gpu == NULL) |
| 1886 | return NULL; |
| 1887 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 1888 | pthread_once(&g_initOnce, initDrawState); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1889 | |
Chia-I Wu | 706533e | 2015-01-05 13:18:57 +0800 | [diff] [blame] | 1890 | addr = layer_intercept_proc(funcName); |
| 1891 | if (addr) |
| 1892 | return addr; |
Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 1893 | else if (!strncmp("drawStateDumpDotFile", funcName, sizeof("drawStateDumpDotFile"))) |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 1894 | return drawStateDumpDotFile; |
Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 1895 | else if (!strncmp("drawStateDumpPngFile", funcName, sizeof("drawStateDumpPngFile"))) |
Tobin Ehlis | 266473d | 2014-12-16 17:34:50 -0700 | [diff] [blame] | 1896 | return drawStateDumpPngFile; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1897 | else { |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1898 | if (gpuw->pGPA == NULL) |
| 1899 | return NULL; |
| 1900 | return gpuw->pGPA(gpuw->nextObject, funcName); |
| 1901 | } |
| 1902 | } |