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 |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 52 | static void layerCbMsg(XGL_DBG_MSG_TYPE msgType, |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 53 | XGL_VALIDATION_LEVEL validationLevel, |
| 54 | XGL_BASE_OBJECT srcObject, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 55 | size_t location, |
| 56 | int32_t 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 |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 111 | static size_t sTypeStructSize(XGL_STRUCTURE_TYPE sType) |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 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); |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 125 | case XGL_STRUCTURE_TYPE_BUFFER_VIEW_ATTACH_INFO: |
| 126 | return sizeof(XGL_BUFFER_VIEW_ATTACH_INFO); |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 127 | case XGL_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO: |
| 128 | return sizeof(XGL_IMAGE_VIEW_ATTACH_INFO); |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 129 | case XGL_STRUCTURE_TYPE_EVENT_WAIT_INFO: |
| 130 | return sizeof(XGL_EVENT_WAIT_INFO); |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 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); |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 143 | case XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO: |
| 144 | return sizeof(XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO); |
| 145 | case XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO: |
| 146 | return sizeof(XGL_DYNAMIC_VP_STATE_CREATE_INFO); |
| 147 | case XGL_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO: |
| 148 | return sizeof(XGL_DYNAMIC_RS_STATE_CREATE_INFO); |
| 149 | case XGL_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO: |
| 150 | return sizeof(XGL_DYNAMIC_CB_STATE_CREATE_INFO); |
| 151 | case XGL_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO: |
| 152 | return sizeof(XGL_DYNAMIC_DS_STATE_CREATE_INFO); |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 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); |
Mark Lobodzinski | 4eca697 | 2015-01-26 10:34:00 -0600 | [diff] [blame] | 159 | case XGL_STRUCTURE_TYPE_QUEUE_SEMAPHORE_CREATE_INFO: |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 160 | return sizeof(XGL_QUEUE_SEMAPHORE_CREATE_INFO); |
Mark Lobodzinski | 4eca697 | 2015-01-26 10:34:00 -0600 | [diff] [blame] | 161 | case XGL_STRUCTURE_TYPE_QUEUE_SEMAPHORE_OPEN_INFO: |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 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); |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 169 | case XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO: |
| 170 | return sizeof(XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO); |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 171 | case XGL_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO: |
| 172 | return sizeof(XGL_PIPELINE_IA_STATE_CREATE_INFO); |
| 173 | case XGL_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO: |
| 174 | return sizeof(XGL_PIPELINE_VP_STATE_CREATE_INFO); |
| 175 | case XGL_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO: |
| 176 | return sizeof(XGL_PIPELINE_CB_STATE_CREATE_INFO); |
| 177 | case XGL_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO: |
| 178 | return sizeof(XGL_PIPELINE_RS_STATE_CREATE_INFO); |
| 179 | case XGL_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO: |
| 180 | return sizeof(XGL_PIPELINE_MS_STATE_CREATE_INFO); |
| 181 | case XGL_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO: |
| 182 | return sizeof(XGL_PIPELINE_TESS_STATE_CREATE_INFO); |
| 183 | case XGL_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO: |
| 184 | return sizeof(XGL_PIPELINE_DS_STATE_CREATE_INFO); |
| 185 | case XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO: |
| 186 | return sizeof(XGL_IMAGE_CREATE_INFO); |
| 187 | case XGL_STRUCTURE_TYPE_BUFFER_CREATE_INFO: |
| 188 | return sizeof(XGL_BUFFER_CREATE_INFO); |
| 189 | case XGL_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO: |
| 190 | return sizeof(XGL_BUFFER_VIEW_CREATE_INFO); |
| 191 | case XGL_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO: |
| 192 | return sizeof(XGL_FRAMEBUFFER_CREATE_INFO); |
| 193 | case XGL_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO: |
| 194 | return sizeof(XGL_CMD_BUFFER_BEGIN_INFO); |
| 195 | case XGL_STRUCTURE_TYPE_CMD_BUFFER_GRAPHICS_BEGIN_INFO: |
| 196 | return sizeof(XGL_CMD_BUFFER_GRAPHICS_BEGIN_INFO); |
| 197 | case XGL_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO: |
| 198 | return sizeof(XGL_RENDER_PASS_CREATE_INFO); |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 199 | case XGL_STRUCTURE_TYPE_LAYER_CREATE_INFO: |
| 200 | return sizeof(XGL_LAYER_CREATE_INFO); |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 201 | case XGL_STRUCTURE_TYPE_PIPELINE_BARRIER: |
| 202 | return sizeof(XGL_PIPELINE_BARRIER); |
| 203 | case XGL_STRUCTURE_TYPE_MEMORY_BARRIER: |
| 204 | return sizeof(XGL_MEMORY_BARRIER); |
| 205 | case XGL_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER: |
| 206 | return sizeof(XGL_BUFFER_MEMORY_BARRIER); |
| 207 | case XGL_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER: |
| 208 | return sizeof(XGL_IMAGE_MEMORY_BARRIER); |
| 209 | case XGL_STRUCTURE_TYPE_DESCRIPTOR_REGION_CREATE_INFO: |
| 210 | return sizeof(XGL_DESCRIPTOR_REGION_CREATE_INFO); |
| 211 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS: |
| 212 | return sizeof(XGL_UPDATE_SAMPLERS); |
| 213 | case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES: |
| 214 | return sizeof(XGL_UPDATE_SAMPLER_TEXTURES); |
| 215 | case XGL_STRUCTURE_TYPE_UPDATE_IMAGES: |
| 216 | return sizeof(XGL_UPDATE_IMAGES); |
| 217 | case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS: |
| 218 | return sizeof(XGL_UPDATE_BUFFERS); |
| 219 | case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY: |
| 220 | return sizeof(XGL_UPDATE_AS_COPY); |
| 221 | case XGL_STRUCTURE_TYPE_MEMORY_ALLOC_BUFFER_INFO: |
| 222 | return sizeof(XGL_MEMORY_ALLOC_BUFFER_INFO); |
| 223 | case XGL_STRUCTURE_TYPE_MEMORY_ALLOC_IMAGE_INFO: |
| 224 | return sizeof(XGL_MEMORY_ALLOC_IMAGE_INFO); |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 225 | default: |
| 226 | return 0; |
| 227 | } |
| 228 | } |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 229 | // Return the size of the underlying struct based on sType |
| 230 | static size_t dynStateCreateInfoSize(XGL_STRUCTURE_TYPE sType) |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 231 | { |
| 232 | switch (sType) |
| 233 | { |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 234 | case XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO: |
| 235 | return sizeof(XGL_DYNAMIC_VP_STATE_CREATE_INFO); |
| 236 | case XGL_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO: |
| 237 | return sizeof(XGL_DYNAMIC_RS_STATE_CREATE_INFO); |
| 238 | case XGL_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO: |
| 239 | return sizeof(XGL_DYNAMIC_DS_STATE_CREATE_INFO); |
| 240 | case XGL_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO: |
| 241 | return sizeof(XGL_DYNAMIC_CB_STATE_CREATE_INFO); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 242 | default: |
| 243 | return 0; |
| 244 | } |
| 245 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 246 | // Block of code at start here for managing/tracking Pipeline state that this layer cares about |
| 247 | // Just track 2 shaders for now |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 248 | #define XGL_NUM_GRAPHICS_SHADERS XGL_SHADER_STAGE_COMPUTE |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 249 | #define MAX_SLOTS 2048 |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 250 | |
| 251 | static uint64_t drawCount[NUM_DRAW_TYPES] = {0, 0, 0, 0}; |
| 252 | |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 253 | // 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] | 254 | // Then need to synchronize the accesses based on cmd buffer so that if I'm reading state on one cmd buffer, updates |
| 255 | // 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] | 256 | static PIPELINE_NODE *pPipelineHead = NULL; |
Tobin Ehlis | 5a1d9f3 | 2014-11-20 10:48:56 -0700 | [diff] [blame] | 257 | static SAMPLER_NODE *pSamplerHead = NULL; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 258 | static XGL_PIPELINE lastBoundPipeline = NULL; |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 259 | #define MAX_BINDING 0xFFFFFFFF |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 260 | static uint32_t lastVtxBinding = MAX_BINDING; |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 261 | static uint32_t lastIdxBinding = MAX_BINDING; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 262 | |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 263 | static DYNAMIC_STATE_NODE* pDynamicStateHead[XGL_NUM_STATE_BIND_POINT] = {0}; |
| 264 | static DYNAMIC_STATE_NODE* pLastBoundDynamicState[XGL_NUM_STATE_BIND_POINT] = {0}; |
| 265 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 266 | static void insertDynamicState(const XGL_DYNAMIC_STATE_OBJECT state, const PIPELINE_LL_HEADER* pCreateInfo, XGL_STATE_BIND_POINT bindPoint) |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 267 | { |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 268 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 269 | // Insert new node at head of appropriate LL |
| 270 | DYNAMIC_STATE_NODE* pStateNode = (DYNAMIC_STATE_NODE*)malloc(sizeof(DYNAMIC_STATE_NODE)); |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 271 | pStateNode->pNext = pDynamicStateHead[bindPoint]; |
| 272 | pDynamicStateHead[bindPoint] = pStateNode; |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 273 | pStateNode->stateObj = state; |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 274 | pStateNode->pCreateInfo = (PIPELINE_LL_HEADER*)malloc(dynStateCreateInfoSize(pCreateInfo->sType)); |
| 275 | memcpy(pStateNode->pCreateInfo, pCreateInfo, dynStateCreateInfoSize(pCreateInfo->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? |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 280 | static void setLastBoundDynamicState(const XGL_DYNAMIC_STATE_OBJECT state, const XGL_STATE_BIND_POINT sType) |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 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: |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 307 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pLastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", xgl_print_xgl_dynamic_vp_state_create_info((XGL_DYNAMIC_VP_STATE_CREATE_INFO*)pLastBoundDynamicState[i]->pCreateInfo, " ")); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 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 |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 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 | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 373 | //XGL_PIPELINE_SHADER_STAGE_CREATE_INFO *pSSCI = (XGL_PIPELINE_SHADER_STAGE_CREATE_INFO*)pTrav; |
| 374 | // TODO : Fix this for new binding model |
| 375 | /* |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 376 | for (uint32_t i = 0; i < XGL_MAX_DESCRIPTOR_SETS; i++) { |
| 377 | if (pSSCI->shader.descriptorSetMapping[i].descriptorCount > MAX_SLOTS) { |
| 378 | char str[1024]; |
| 379 | 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); |
| 380 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pPipeline, 0, DRAWSTATE_DESCRIPTOR_MAX_EXCEEDED, "DS", str); |
| 381 | pSSCI->shader.descriptorSetMapping[i].descriptorCount = 0; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 382 | } |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 383 | pPipeline->dsMapping[pSSCI->shader.stage][i].slotCount = pSSCI->shader.descriptorSetMapping[i].descriptorCount; |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 384 | // Deep copy DS Slot array into our shortcut data structure |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 385 | pPipeline->dsMapping[pSSCI->shader.stage][i].pShaderMappingSlot = (XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO*)malloc(sizeof(XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO)*pPipeline->dsMapping[pSSCI->shader.stage][i].slotCount); |
| 386 | memcpy(pPipeline->dsMapping[pSSCI->shader.stage][i].pShaderMappingSlot, pSSCI->shader.descriptorSetMapping[i].pDescriptorInfo, sizeof(XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO)*pPipeline->dsMapping[pSSCI->shader.stage][i].slotCount); |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 387 | // Deep copy into shadow tree |
| 388 | pShadowShaderCI->shader.descriptorSetMapping[i].descriptorCount = pSSCI->shader.descriptorSetMapping[i].descriptorCount; |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 389 | pShadowShaderCI->shader.descriptorSetMapping[i].pDescriptorInfo = (XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO*)malloc(sizeof(XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO)*pShadowShaderCI->shader.descriptorSetMapping[i].descriptorCount); |
| 390 | memcpy((XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO*)pShadowShaderCI->shader.descriptorSetMapping[i].pDescriptorInfo, pSSCI->shader.descriptorSetMapping[i].pDescriptorInfo, sizeof(XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO)*pShadowShaderCI->shader.descriptorSetMapping[i].descriptorCount); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 391 | } |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 392 | */ |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 393 | } |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 394 | else if (XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO == pTrav->sType) { |
| 395 | // Special copy of Vtx info |
| 396 | XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO *pVICI = (XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO*)pTrav; |
| 397 | pPipeline->vtxBindingCount = pVICI->bindingCount; |
| 398 | uint32_t allocSize = pPipeline->vtxBindingCount * sizeof(XGL_VERTEX_INPUT_BINDING_DESCRIPTION); |
| 399 | pPipeline->pVertexBindingDescriptions = (XGL_VERTEX_INPUT_BINDING_DESCRIPTION*)malloc(allocSize); |
| 400 | memcpy(pPipeline->pVertexBindingDescriptions, pVICI->pVertexAttributeDescriptions, allocSize); |
| 401 | pPipeline->vtxAttributeCount = pVICI->attributeCount; |
| 402 | allocSize = pPipeline->vtxAttributeCount * sizeof(XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION); |
| 403 | pPipeline->pVertexAttributeDescriptions = (XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION*)malloc(allocSize); |
| 404 | memcpy(pPipeline->pVertexAttributeDescriptions, pVICI->pVertexAttributeDescriptions, allocSize); |
| 405 | } |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 406 | pTrav = (PIPELINE_LL_HEADER*)pTrav->pNext; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 407 | } |
| 408 | } |
| 409 | |
| 410 | // Block of code at start here specifically for managing/tracking DSs |
| 411 | #define MAPPING_MEMORY 0x00000001 |
| 412 | #define MAPPING_IMAGE 0x00000002 |
| 413 | #define MAPPING_SAMPLER 0x00000004 |
| 414 | #define MAPPING_DS 0x00000008 |
| 415 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 416 | static char* stringSlotBinding(uint32_t binding) |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 417 | { |
| 418 | switch (binding) |
| 419 | { |
| 420 | case MAPPING_MEMORY: |
| 421 | return "Memory View"; |
| 422 | case MAPPING_IMAGE: |
| 423 | return "Image View"; |
| 424 | case MAPPING_SAMPLER: |
| 425 | return "Sampler"; |
| 426 | default: |
| 427 | return "UNKNOWN DS BINDING"; |
| 428 | } |
| 429 | } |
| 430 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 431 | // ptr to HEAD of LL of DS Regions |
| 432 | static REGION_NODE* g_pRegionHead = NULL; |
Tobin Ehlis | eacc64f | 2014-11-24 17:09:09 -0700 | [diff] [blame] | 433 | // Last DS that was bound, and slotOffset for the binding |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 434 | static XGL_DESCRIPTOR_SET lastBoundDS = NULL; |
| 435 | static uint32_t lastBoundSlotOffset = 0; |
| 436 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 437 | // Return Region node ptr for specified region or else NULL |
| 438 | static REGION_NODE* getRegionNode(XGL_DESCRIPTOR_REGION region) |
| 439 | { |
| 440 | pthread_mutex_lock(&globalLock); |
| 441 | REGION_NODE* pTrav = g_pRegionHead; |
| 442 | while (pTrav) { |
| 443 | if (pTrav->region == region) { |
| 444 | pthread_mutex_unlock(&globalLock); |
| 445 | return pTrav; |
| 446 | } |
| 447 | pTrav = pTrav->pNext; |
| 448 | } |
| 449 | pthread_mutex_unlock(&globalLock); |
| 450 | return NULL; |
| 451 | } |
| 452 | |
| 453 | // Return Set node ptr for specified set or else NULL |
| 454 | static SET_NODE* getSetNode(XGL_DESCRIPTOR_REGION set) |
| 455 | { |
| 456 | pthread_mutex_lock(&globalLock); |
| 457 | REGION_NODE* pTrav = g_pRegionHead; |
| 458 | while (pTrav) { |
| 459 | if (pTrav->region == region) { |
| 460 | pthread_mutex_unlock(&globalLock); |
| 461 | return pTrav; |
| 462 | } |
| 463 | pTrav = pTrav->pNext; |
| 464 | } |
| 465 | pthread_mutex_unlock(&globalLock); |
| 466 | return NULL; |
| 467 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 468 | |
| 469 | // Return DS Head ptr for specified ds or else NULL |
| 470 | static DS_LL_HEAD* getDS(XGL_DESCRIPTOR_SET ds) |
| 471 | { |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 472 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 473 | DS_LL_HEAD *pTrav = pDSHead; |
| 474 | while (pTrav) { |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 475 | if (pTrav->dsID == ds) { |
| 476 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 477 | return pTrav; |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 478 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 479 | pTrav = pTrav->pNextDS; |
| 480 | } |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 481 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 482 | return NULL; |
| 483 | } |
| 484 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 485 | // Return XGL_TRUE if DS Exists and is within an xglBeginDescriptorSetUpdate() call sequence, otherwise XGL_FALSE |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 486 | static bool32_t dsUpdate(XGL_DESCRIPTOR_SET ds) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 487 | { |
| 488 | DS_LL_HEAD *pTrav = getDS(ds); |
| 489 | if (pTrav) |
| 490 | return pTrav->updateActive; |
| 491 | return XGL_FALSE; |
| 492 | } |
| 493 | |
| 494 | // Clear specified slotCount DS Slots starting at startSlot |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 495 | // Return XGL_TRUE if DS exists and is successfully cleared to 0s |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 496 | static bool32_t clearDS(XGL_DESCRIPTOR_SET descriptorSet, uint32_t startSlot, uint32_t slotCount) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 497 | { |
| 498 | DS_LL_HEAD *pTrav = getDS(descriptorSet); |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 499 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 500 | if (!pTrav || ((startSlot + slotCount) > pTrav->numSlots)) { |
| 501 | // TODO : Log more meaningful error here |
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_FALSE; |
| 504 | } |
| 505 | for (uint32_t i = startSlot; i < slotCount; i++) { |
| 506 | memset((void*)&pTrav->dsSlot[i], 0, sizeof(DS_SLOT)); |
| 507 | } |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 508 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 509 | return XGL_TRUE; |
| 510 | } |
| 511 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 512 | static void dsSetMapping(DS_SLOT* pSlot, uint32_t mapping) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 513 | { |
| 514 | pSlot->mappingMask |= mapping; |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 515 | pSlot->activeMapping = mapping; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 516 | } |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 517 | // Populate pStr w/ a string noting all of the slot mappings based on mapping flag |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 518 | static char* noteSlotMapping(uint32_t32 mapping, char *pStr) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 519 | { |
| 520 | if (MAPPING_MEMORY & mapping) |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 521 | strcat(pStr, "\n\tMemory View previously mapped"); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 522 | if (MAPPING_IMAGE & mapping) |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 523 | strcat(pStr, "\n\tImage View previously mapped"); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 524 | if (MAPPING_SAMPLER & mapping) |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 525 | strcat(pStr, "\n\tSampler previously mapped"); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 526 | if (MAPPING_DS & mapping) |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 527 | strcat(pStr, "\n\tDESCRIPTOR SET ptr previously mapped"); |
| 528 | return pStr; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 529 | } |
| 530 | |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 531 | static void dsSetMemMapping(XGL_DESCRIPTOR_SET descriptorSet, DS_SLOT* pSlot, const XGL_BUFFER_VIEW_ATTACH_INFO* pMemView) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 532 | { |
| 533 | if (pSlot->mappingMask) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 534 | char str[1024]; |
| 535 | char map_str[1024] = {0}; |
| 536 | sprintf(str, "While mapping Memory View to slot %u previous Mapping(s) identified:%s", pSlot->slot, noteSlotMapping(pSlot->mappingMask, map_str)); |
| 537 | 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] | 538 | } |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 539 | memcpy(&pSlot->buffView, pMemView, sizeof(XGL_BUFFER_VIEW_ATTACH_INFO)); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 540 | dsSetMapping(pSlot, MAPPING_MEMORY); |
| 541 | } |
| 542 | |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 543 | static bool32_t dsMemMapping(XGL_DESCRIPTOR_SET descriptorSet, uint32_t startSlot, uint32_t slotCount, const XGL_BUFFER_VIEW_ATTACH_INFO* pMemViews) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 544 | { |
| 545 | DS_LL_HEAD *pTrav = getDS(descriptorSet); |
| 546 | if (pTrav) { |
| 547 | if (pTrav->numSlots < (startSlot + slotCount)) { |
| 548 | return XGL_FALSE; |
| 549 | } |
| 550 | for (uint32_t i = 0; i < slotCount; i++) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 551 | dsSetMemMapping(descriptorSet, &pTrav->dsSlot[i+startSlot], &pMemViews[i]); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 552 | } |
| 553 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 554 | else |
| 555 | return XGL_FALSE; |
| 556 | return XGL_TRUE; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 557 | } |
| 558 | |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 559 | 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] | 560 | { |
| 561 | if (pSlot->mappingMask) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 562 | char str[1024]; |
| 563 | char map_str[1024] = {0}; |
| 564 | sprintf(str, "While mapping Image View to slot %u previous Mapping(s) identified:%s", pSlot->slot, noteSlotMapping(pSlot->mappingMask, map_str)); |
| 565 | 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] | 566 | } |
| 567 | memcpy(&pSlot->imageView, pImageViews, sizeof(XGL_IMAGE_VIEW_ATTACH_INFO)); |
| 568 | dsSetMapping(pSlot, MAPPING_IMAGE); |
| 569 | } |
| 570 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 571 | static bool32_t dsImageMapping(XGL_DESCRIPTOR_SET descriptorSet, uint32_t startSlot, uint32_t slotCount, const XGL_IMAGE_VIEW_ATTACH_INFO* pImageViews) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 572 | { |
| 573 | DS_LL_HEAD *pTrav = getDS(descriptorSet); |
| 574 | if (pTrav) { |
| 575 | if (pTrav->numSlots < (startSlot + slotCount)) { |
| 576 | return XGL_FALSE; |
| 577 | } |
| 578 | for (uint32_t i = 0; i < slotCount; i++) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 579 | dsSetImageMapping(descriptorSet, &pTrav->dsSlot[i+startSlot], &pImageViews[i]); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 580 | } |
| 581 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 582 | else |
| 583 | return XGL_FALSE; |
| 584 | return XGL_TRUE; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 585 | } |
| 586 | |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 587 | 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] | 588 | { |
| 589 | if (pSlot->mappingMask) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 590 | char str[1024]; |
| 591 | char map_str[1024] = {0}; |
| 592 | sprintf(str, "While mapping Sampler to slot %u previous Mapping(s) identified:%s", pSlot->slot, noteSlotMapping(pSlot->mappingMask, map_str)); |
| 593 | 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] | 594 | } |
| 595 | pSlot->sampler = sampler; |
| 596 | dsSetMapping(pSlot, MAPPING_SAMPLER); |
| 597 | } |
| 598 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 599 | static bool32_t dsSamplerMapping(XGL_DESCRIPTOR_SET descriptorSet, uint32_t startSlot, uint32_t slotCount, const XGL_SAMPLER* pSamplers) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 600 | { |
| 601 | DS_LL_HEAD *pTrav = getDS(descriptorSet); |
| 602 | if (pTrav) { |
| 603 | if (pTrav->numSlots < (startSlot + slotCount)) { |
| 604 | return XGL_FALSE; |
| 605 | } |
| 606 | for (uint32_t i = 0; i < slotCount; i++) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 607 | dsSetSamplerMapping(descriptorSet, &pTrav->dsSlot[i+startSlot], pSamplers[i]); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 608 | } |
| 609 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 610 | else |
| 611 | return XGL_FALSE; |
| 612 | return XGL_TRUE; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 613 | } |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 614 | // Print the last bound Gfx Pipeline |
| 615 | static void printPipeline() |
| 616 | { |
| 617 | PIPELINE_NODE *pPipeTrav = getPipeline(lastBoundPipeline); |
| 618 | if (!pPipeTrav) { |
| 619 | // nothing to print |
| 620 | } |
| 621 | else { |
| 622 | char* pipeStr = xgl_print_xgl_graphics_pipeline_create_info(pPipeTrav->pCreateTree, "{DS}"); |
| 623 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", pipeStr); |
| 624 | } |
| 625 | } |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 626 | // Dump subgraph w/ DS info |
| 627 | static void dsDumpDot(FILE* pOutFile) |
| 628 | { |
| 629 | const int i = 0; // hard-coding to just the first DS index for now |
| 630 | uint32_t skipUnusedCount = 0; // track consecutive unused slots for minimal reporting |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 631 | DS_LL_HEAD *pDS = getDS(lastBoundDS); |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 632 | if (pDS) { |
| 633 | fprintf(pOutFile, "subgraph DS_SLOTS\n{\nlabel=\"DS0 Slots\"\n"); |
| 634 | // First create simple array node as central DS reference point |
| 635 | fprintf(pOutFile, "\"DS0_MEMORY\" [\nlabel = <<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"> <TR><TD PORT=\"ds2\">DS0 Memory</TD></TR>"); |
| 636 | uint32_t j; |
| 637 | char label[1024]; |
| 638 | for (j = 0; j < pDS->numSlots; j++) { |
Tobin Ehlis | f1c468a | 2014-12-09 17:00:33 -0700 | [diff] [blame] | 639 | // Don't draw unused slots |
| 640 | if (0 != pDS->dsSlot[j].activeMapping) |
| 641 | 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] | 642 | } |
| 643 | fprintf(pOutFile, "</TABLE>>\n];\n"); |
| 644 | // Now tie each slot to its info |
| 645 | for (j = 0; j < pDS->numSlots; j++) { |
| 646 | switch (pDS->dsSlot[j].activeMapping) |
| 647 | { |
| 648 | case MAPPING_MEMORY: |
| 649 | /* |
| 650 | if (0 != skipUnusedCount) {// finish sequence of unused slots |
| 651 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 652 | strcat(ds_config_str, tmp_str); |
| 653 | skipUnusedCount = 0; |
| 654 | }*/ |
| 655 | sprintf(label, "MemAttachInfo Slot%u", j); |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 656 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_memory_view_attach_info(&pDS->dsSlot[j].buffView, label)); |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 657 | fprintf(pOutFile, "\"DS0_MEMORY\":slot%u -> \"%s\" [];\n", j, label); |
| 658 | break; |
| 659 | case MAPPING_IMAGE: |
| 660 | /*if (0 != skipUnusedCount) {// finish sequence of unused slots |
| 661 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 662 | strcat(ds_config_str, tmp_str); |
| 663 | skipUnusedCount = 0; |
| 664 | }*/ |
| 665 | sprintf(label, "ImageAttachInfo Slot%u", j); |
| 666 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_image_view_attach_info(&pDS->dsSlot[j].imageView, label)); |
| 667 | fprintf(pOutFile, "\"DS0_MEMORY\":slot%u -> \"%s\" [];\n", j, label); |
| 668 | break; |
| 669 | case MAPPING_SAMPLER: |
| 670 | /*if (0 != skipUnusedCount) {// finish sequence of unused slots |
| 671 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 672 | strcat(ds_config_str, tmp_str); |
| 673 | skipUnusedCount = 0; |
| 674 | }*/ |
Tobin Ehlis | 2836a7d | 2015-01-08 15:22:32 -0700 | [diff] [blame] | 675 | sprintf(label, "SamplerAttachInfo Slot%u", j); |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 676 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_sampler_create_info(getSamplerCreateInfo(pDS->dsSlot[j].sampler), label)); |
| 677 | fprintf(pOutFile, "\"DS0_MEMORY\":slot%u -> \"%s\" [];\n", j, label); |
| 678 | break; |
| 679 | default: |
| 680 | /*if (!skipUnusedCount) {// only report start of unused sequences |
| 681 | sprintf(tmp_str, "----Skipping slot(s) w/o a view attached...\n"); |
| 682 | strcat(ds_config_str, tmp_str); |
| 683 | }*/ |
| 684 | skipUnusedCount++; |
| 685 | break; |
| 686 | } |
| 687 | |
| 688 | } |
| 689 | /*if (0 != skipUnusedCount) {// finish sequence of unused slots |
| 690 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 691 | strcat(ds_config_str, tmp_str); |
| 692 | skipUnusedCount = 0; |
| 693 | }*/ |
| 694 | fprintf(pOutFile, "}\n"); |
| 695 | } |
| 696 | } |
| 697 | // Dump a GraphViz dot file showing the pipeline |
| 698 | static void dumpDotFile(char *outFileName) |
| 699 | { |
| 700 | PIPELINE_NODE *pPipeTrav = getPipeline(lastBoundPipeline); |
| 701 | if (pPipeTrav) { |
| 702 | FILE* pOutFile; |
| 703 | pOutFile = fopen(outFileName, "w"); |
| 704 | fprintf(pOutFile, "digraph g {\ngraph [\nrankdir = \"TB\"\n];\nnode [\nfontsize = \"16\"\nshape = \"plaintext\"\n];\nedge [\n];\n"); |
| 705 | fprintf(pOutFile, "subgraph PipelineStateObject\n{\nlabel=\"Pipeline State Object\"\n"); |
| 706 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_graphics_pipeline_create_info(pPipeTrav->pCreateTree, "PSO HEAD")); |
| 707 | fprintf(pOutFile, "}\n"); |
| 708 | // TODO : Add dynamic state dump here |
| 709 | fprintf(pOutFile, "subgraph dynamicState\n{\nlabel=\"Non-Orthogonal XGL State\"\n"); |
| 710 | for (uint32_t i = 0; i < XGL_NUM_STATE_BIND_POINT; i++) { |
| 711 | if (pLastBoundDynamicState[i]) { |
| 712 | switch (pLastBoundDynamicState[i]->sType) |
| 713 | { |
| 714 | case XGL_STATE_BIND_VIEWPORT: |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 715 | fprintf(pOutFile, "%s", xgl_gv_print_xgl_viewport_state_create_info((XGL_DYNAMIC_VP_STATE_CREATE_INFO*)pLastBoundDynamicState[i]->pCreateInfo, "VIEWPORT State")); |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 716 | break; |
| 717 | default: |
| 718 | fprintf(pOutFile, "%s", dynamic_gv_display(pLastBoundDynamicState[i]->pCreateInfo, string_XGL_STATE_BIND_POINT(pLastBoundDynamicState[i]->sType))); |
| 719 | break; |
| 720 | } |
| 721 | } |
| 722 | } |
| 723 | fprintf(pOutFile, "}\n"); // close dynamicState subgraph |
| 724 | dsDumpDot(pOutFile); |
| 725 | fprintf(pOutFile, "}\n"); // close main graph "g" |
| 726 | fclose(pOutFile); |
| 727 | } |
| 728 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 729 | // Synch up currently bound pipeline settings with DS mappings |
| 730 | static void synchDSMapping() |
| 731 | { |
| 732 | // First verify that we have a bound pipeline |
| 733 | PIPELINE_NODE *pPipeTrav = getPipeline(lastBoundPipeline); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 734 | char str[1024]; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 735 | if (!pPipeTrav) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 736 | sprintf(str, "Can't find last bound Pipeline %p!", (void*)lastBoundPipeline); |
| 737 | 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] | 738 | } |
| 739 | else { |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 740 | // Synch Descriptor Set Mapping |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 741 | //for (uint32_t i = 0; i < XGL_MAX_DESCRIPTOR_SETS; i++) { |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 742 | DS_LL_HEAD *pDS; |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 743 | if (lastBoundDS) { |
| 744 | pDS = getDS(lastBoundDS); |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 745 | if (!pDS) { |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 746 | sprintf(str, "Can't find last bound DS %p. Did you need to bind DS?", (void*)lastBoundDS); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 747 | 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] | 748 | } |
| 749 | else { // We have a good DS & Pipeline, store pipeline mappings in DS |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 750 | uint32_t slotOffset = lastBoundSlotOffset; |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 751 | for (uint32_t j = 0; j < XGL_NUM_GRAPHICS_SHADERS; j++) { // j is shader selector |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 752 | if (pPipeTrav->dsMapping[j].count > (pDS->numSlots - slotOffset)) { |
| 753 | 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].count, (void*)pDS->dsID, pDS->numSlots, slotOffset, (pDS->numSlots - slotOffset)); |
Tobin Ehlis | 2104279 | 2014-11-24 16:06:04 -0700 | [diff] [blame] | 754 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_DS_SLOT_NUM_MISMATCH, "DS", str); |
| 755 | } |
| 756 | else { |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 757 | for (uint32_t r = 0; r < pPipeTrav->dsMapping[j].count; r++) { |
| 758 | pDS->dsSlot[r+slotOffset].shaderSlotInfo[j] = pPipeTrav->dsMapping[j].pShaderMappingSlot[r]; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 759 | } |
| 760 | } |
| 761 | } |
| 762 | } |
| 763 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 764 | else { |
Tobin Ehlis | 2104279 | 2014-11-24 16:06:04 -0700 | [diff] [blame] | 765 | // Verify that no shader is mapping this DS |
| 766 | uint32_t dsUsed = 0; |
| 767 | for (uint32_t j = 0; j < XGL_NUM_GRAPHICS_SHADERS; j++) { // j is shader selector |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 768 | if (pPipeTrav->dsMapping[j].count > 0) { |
Tobin Ehlis | 2104279 | 2014-11-24 16:06:04 -0700 | [diff] [blame] | 769 | dsUsed = 1; |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 770 | sprintf(str, "No DS was bound, but shader type %s has slots bound to that DS.", string_XGL_PIPELINE_SHADER_STAGE(j)); |
Tobin Ehlis | 2104279 | 2014-11-24 16:06:04 -0700 | [diff] [blame] | 771 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NO_DS_BOUND, "DS", str); |
| 772 | } |
| 773 | } |
| 774 | if (0 == dsUsed) { |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 775 | sprintf(str, "No DS was bound, but no shaders are using that DS so this is not an issue."); |
Tobin Ehlis | 2104279 | 2014-11-24 16:06:04 -0700 | [diff] [blame] | 776 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", str); |
| 777 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 778 | } |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 779 | //} |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 780 | // Verify Vtx binding |
| 781 | if (MAX_BINDING != lastVtxBinding) { |
| 782 | if (lastVtxBinding >= pPipeTrav->vtxBindingCount) { |
| 783 | sprintf(str, "Vtx binding Index of %u exceeds PSO pVertexBindingDescriptions max array index of %u.", lastVtxBinding, (pPipeTrav->vtxBindingCount - 1)); |
| 784 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", str); |
| 785 | } |
| 786 | else { |
| 787 | char *tmpStr = xgl_print_xgl_vertex_input_binding_description(&pPipeTrav->pVertexBindingDescriptions[lastVtxBinding], "{DS}INFO : "); |
| 788 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmpStr); |
| 789 | free(tmpStr); |
| 790 | } |
| 791 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 792 | } |
| 793 | } |
| 794 | |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 795 | // Checks to make sure that shader mapping matches slot binding |
| 796 | // Print an ERROR and return XGL_FALSE if they don't line up |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 797 | static bool32_t verifyShaderSlotMapping(const uint32_t slot, const uint32_t slotBinding, const uint32_t shaderStage, const XGL_DESCRIPTOR_SET_SLOT_TYPE shaderMapping) |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 798 | { |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 799 | bool32_t error = XGL_FALSE; |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 800 | char str[1024]; |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 801 | switch (shaderMapping) |
| 802 | { |
Cody Northrop | 40316a3 | 2014-12-09 19:08:33 -0700 | [diff] [blame] | 803 | case XGL_SLOT_SHADER_TEXTURE_RESOURCE: |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 804 | case XGL_SLOT_SHADER_RESOURCE: |
| 805 | if (MAPPING_MEMORY != slotBinding && MAPPING_IMAGE != slotBinding) |
| 806 | error = XGL_TRUE; |
| 807 | break; |
| 808 | case XGL_SLOT_SHADER_SAMPLER: |
| 809 | if (MAPPING_SAMPLER != slotBinding) |
| 810 | error = XGL_TRUE; |
| 811 | break; |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 812 | case XGL_SLOT_SHADER_UAV: |
| 813 | if (MAPPING_MEMORY != slotBinding) |
| 814 | error = XGL_TRUE; |
| 815 | break; |
| 816 | case XGL_SLOT_NEXT_DESCRIPTOR_SET: |
| 817 | if (MAPPING_DS != slotBinding) |
| 818 | error = XGL_TRUE; |
| 819 | break; |
| 820 | case XGL_SLOT_UNUSED: |
| 821 | break; |
| 822 | default: |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 823 | sprintf(str, "For DS slot %u, unknown shader slot mapping w/ value %u", slot, shaderMapping); |
| 824 | 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] | 825 | return XGL_FALSE; |
| 826 | } |
| 827 | if (XGL_TRUE == error) { |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 828 | 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] | 829 | 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] | 830 | return XGL_FALSE; |
| 831 | } |
| 832 | return XGL_TRUE; |
| 833 | } |
| 834 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 835 | // Print details of DS config to stdout |
| 836 | static void printDSConfig() |
| 837 | { |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 838 | uint32_t skipUnusedCount = 0; // track consecutive unused slots for minimal reporting |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 839 | char tmp_str[1024]; |
| 840 | 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] | 841 | for (uint32_t i = 0; i < XGL_MAX_DESCRIPTOR_SETS; i++) { |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 842 | if (lastBoundDS[i]) { |
| 843 | DS_LL_HEAD *pDS = getDS(lastBoundDS[i]); |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 844 | uint32_t slotOffset = lastBoundSlotOffset[i]; |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 845 | if (pDS) { |
Tobin Ehlis | eacc64f | 2014-11-24 17:09:09 -0700 | [diff] [blame] | 846 | 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] | 847 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 848 | for (uint32_t j = 0; j < pDS->numSlots; j++) { |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 849 | switch (pDS->dsSlot[j].activeMapping) |
| 850 | { |
| 851 | case MAPPING_MEMORY: |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 852 | if (0 != skipUnusedCount) {// finish sequence of unused slots |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 853 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 854 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 855 | skipUnusedCount = 0; |
| 856 | } |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 857 | sprintf(tmp_str, "----Slot %u\n Mapped to Memory View %p:\n%s", j, (void*)&pDS->dsSlot[j].buffView, xgl_print_xgl_memory_view_attach_info(&pDS->dsSlot[j].buffView, " ")); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 858 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 859 | break; |
| 860 | case MAPPING_IMAGE: |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 861 | if (0 != skipUnusedCount) {// finish sequence of unused slots |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 862 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 863 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 864 | skipUnusedCount = 0; |
| 865 | } |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 866 | 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, " ")); |
| 867 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 868 | break; |
| 869 | case MAPPING_SAMPLER: |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 870 | if (0 != skipUnusedCount) {// finish sequence of unused slots |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 871 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 872 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 873 | skipUnusedCount = 0; |
| 874 | } |
Tobin Ehlis | 5a1d9f3 | 2014-11-20 10:48:56 -0700 | [diff] [blame] | 875 | 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] | 876 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 877 | break; |
| 878 | default: |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 879 | if (!skipUnusedCount) {// only report start of unused sequences |
| 880 | sprintf(tmp_str, "----Skipping slot(s) w/o a view attached...\n"); |
| 881 | strcat(ds_config_str, tmp_str); |
| 882 | } |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 883 | skipUnusedCount++; |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 884 | break; |
| 885 | } |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 886 | // For each shader type, check its mapping |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 887 | for (uint32_t k = 0; k < XGL_NUM_GRAPHICS_SHADERS; k++) { |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 888 | if (XGL_SLOT_UNUSED != pDS->dsSlot[j].shaderSlotInfo[k].slotObjectType) { |
Tobin Ehlis | 2609202 | 2014-11-20 09:49:17 -0700 | [diff] [blame] | 889 | 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] | 890 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | 9e3d753 | 2014-10-27 17:12:54 -0600 | [diff] [blame] | 891 | 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] | 892 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 893 | } |
| 894 | } |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 895 | if (0 != skipUnusedCount) {// finish sequence of unused slots |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 896 | sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : ""); |
| 897 | strcat(ds_config_str, tmp_str); |
Tobin Ehlis | 791a49c | 2014-11-10 12:29:12 -0700 | [diff] [blame] | 898 | skipUnusedCount = 0; |
| 899 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 900 | } |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 901 | else { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 902 | char str[1024]; |
| 903 | sprintf(str, "Can't find last bound DS %p. Did you need to bind DS to index %u?", (void*)lastBoundDS[i], i); |
| 904 | 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] | 905 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 906 | } |
| 907 | } |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 908 | 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] | 909 | } |
| 910 | |
| 911 | static void synchAndPrintDSConfig() |
| 912 | { |
| 913 | synchDSMapping(); |
| 914 | printDSConfig(); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 915 | printPipeline(); |
| 916 | printDynamicState(); |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 917 | static int autoDumpOnce = 1; |
| 918 | if (autoDumpOnce) { |
| 919 | autoDumpOnce = 0; |
| 920 | dumpDotFile("pipeline_dump.dot"); |
Tobin Ehlis | 266473d | 2014-12-16 17:34:50 -0700 | [diff] [blame] | 921 | // Convert dot to png if dot available |
| 922 | if(access( "/usr/bin/dot", X_OK) != -1) { |
| 923 | system("/usr/bin/dot pipeline_dump.dot -Tpng -o pipeline_dump.png"); |
| 924 | } |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 925 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 926 | } |
| 927 | |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 928 | static void initDrawState() |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 929 | { |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 930 | const char *strOpt; |
Tobin Ehlis | 5b7acaa | 2015-01-08 14:26:53 -0700 | [diff] [blame] | 931 | // initialize DrawState options |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 932 | strOpt = getLayerOption("DrawStateReportLevel"); |
| 933 | if (strOpt != NULL) |
| 934 | g_reportingLevel = atoi(strOpt); |
Tobin Ehlis | 5b7acaa | 2015-01-08 14:26:53 -0700 | [diff] [blame] | 935 | |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 936 | strOpt = getLayerOption("DrawStateDebugAction"); |
| 937 | if (strOpt != NULL) |
Tobin Ehlis | 5b7acaa | 2015-01-08 14:26:53 -0700 | [diff] [blame] | 938 | g_debugAction = atoi(strOpt); |
| 939 | |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 940 | if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG) |
| 941 | { |
| 942 | strOpt = getLayerOption("DrawStateLogFilename"); |
| 943 | if (strOpt) |
| 944 | { |
| 945 | g_logFile = fopen(strOpt, "w"); |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 946 | } |
| 947 | if (g_logFile == NULL) |
| 948 | g_logFile = stdout; |
| 949 | } |
| 950 | |
| 951 | // initialize Layer dispatch table |
| 952 | // TODO handle multiple GPUs |
Mark Lobodzinski | 953a169 | 2015-01-09 15:12:03 -0600 | [diff] [blame] | 953 | xglGetProcAddrType fpNextGPA; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 954 | fpNextGPA = pCurObj->pGPA; |
| 955 | assert(fpNextGPA); |
| 956 | |
Chia-I Wu | 0f65b1e | 2015-01-04 23:11:43 +0800 | [diff] [blame] | 957 | layer_initialize_dispatch_table(&nextTable, fpNextGPA, (XGL_PHYSICAL_GPU) pCurObj->nextObject); |
| 958 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 959 | xglGetProcAddrType fpGetProcAddr = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (char *) "xglGetProcAddr"); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 960 | nextTable.GetProcAddr = fpGetProcAddr; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 961 | } |
| 962 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 963 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateInstance(const XGL_APPLICATION_INFO* pAppInfo, const XGL_ALLOC_CALLBACKS* pAllocCb, XGL_INSTANCE* pInstance) |
| 964 | { |
| 965 | XGL_RESULT result = nextTable.CreateInstance(pAppInfo, pAllocCb, pInstance); |
| 966 | return result; |
| 967 | } |
| 968 | |
| 969 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyInstance(XGL_INSTANCE instance) |
| 970 | { |
| 971 | XGL_RESULT result = nextTable.DestroyInstance(instance); |
| 972 | return result; |
| 973 | } |
| 974 | |
| 975 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateGpus(XGL_INSTANCE instance, uint32_t maxGpus, uint32_t* pGpuCount, XGL_PHYSICAL_GPU* pGpus) |
| 976 | { |
| 977 | XGL_RESULT result = nextTable.EnumerateGpus(instance, maxGpus, pGpuCount, pGpus); |
| 978 | return result; |
| 979 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 980 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 981 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetGpuInfo(XGL_PHYSICAL_GPU gpu, XGL_PHYSICAL_GPU_INFO_TYPE infoType, size_t* pDataSize, void* pData) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 982 | { |
| 983 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 984 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 985 | pthread_once(&g_initOnce, initDrawState); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 986 | 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] | 987 | return result; |
| 988 | } |
| 989 | |
| 990 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreateInfo, XGL_DEVICE* pDevice) |
| 991 | { |
| 992 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 993 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 994 | pthread_once(&g_initOnce, initDrawState); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 995 | XGL_RESULT result = nextTable.CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 996 | return result; |
| 997 | } |
| 998 | |
| 999 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyDevice(XGL_DEVICE device) |
| 1000 | { |
| 1001 | XGL_RESULT result = nextTable.DestroyDevice(device); |
| 1002 | return result; |
| 1003 | } |
| 1004 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1005 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu, const char* pExtName) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1006 | { |
| 1007 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1008 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 1009 | pthread_once(&g_initOnce, initDrawState); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1010 | XGL_RESULT result = nextTable.GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1011 | return result; |
| 1012 | } |
| 1013 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1014 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, size_t* pOutLayerCount, char* const* pOutLayers, void* pReserved) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1015 | { |
Jon Ashburn | 451c16f | 2014-11-25 11:08:42 -0700 | [diff] [blame] | 1016 | if (gpu != NULL) |
| 1017 | { |
| 1018 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
| 1019 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 1020 | pthread_once(&g_initOnce, initDrawState); |
Mark Lobodzinski | 953a169 | 2015-01-09 15:12:03 -0600 | [diff] [blame] | 1021 | 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] | 1022 | return result; |
| 1023 | } else |
| 1024 | { |
| 1025 | if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL) |
| 1026 | return XGL_ERROR_INVALID_POINTER; |
| 1027 | // This layer compatible with all GPUs |
| 1028 | *pOutLayerCount = 1; |
Chia-I Wu | a837c52 | 2014-12-16 10:47:33 +0800 | [diff] [blame] | 1029 | strncpy((char *) pOutLayers[0], "DrawState", maxStringSize); |
Jon Ashburn | 451c16f | 2014-11-25 11:08:42 -0700 | [diff] [blame] | 1030 | return XGL_SUCCESS; |
| 1031 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1032 | } |
| 1033 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1034 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetDeviceQueue(XGL_DEVICE device, XGL_QUEUE_TYPE queueType, uint32_t queueIndex, XGL_QUEUE* pQueue) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1035 | { |
| 1036 | XGL_RESULT result = nextTable.GetDeviceQueue(device, queueType, queueIndex, pQueue); |
| 1037 | return result; |
| 1038 | } |
| 1039 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1040 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueSubmit(XGL_QUEUE queue, uint32_t cmdBufferCount, const XGL_CMD_BUFFER* pCmdBuffers, uint32_t memRefCount, const XGL_MEMORY_REF* pMemRefs, XGL_FENCE fence) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1041 | { |
| 1042 | XGL_RESULT result = nextTable.QueueSubmit(queue, cmdBufferCount, pCmdBuffers, memRefCount, pMemRefs, fence); |
| 1043 | return result; |
| 1044 | } |
| 1045 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1046 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueSetGlobalMemReferences(XGL_QUEUE queue, uint32_t memRefCount, const XGL_MEMORY_REF* pMemRefs) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1047 | { |
| 1048 | XGL_RESULT result = nextTable.QueueSetGlobalMemReferences(queue, memRefCount, pMemRefs); |
| 1049 | return result; |
| 1050 | } |
| 1051 | |
| 1052 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueWaitIdle(XGL_QUEUE queue) |
| 1053 | { |
| 1054 | XGL_RESULT result = nextTable.QueueWaitIdle(queue); |
| 1055 | return result; |
| 1056 | } |
| 1057 | |
| 1058 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDeviceWaitIdle(XGL_DEVICE device) |
| 1059 | { |
| 1060 | XGL_RESULT result = nextTable.DeviceWaitIdle(device); |
| 1061 | return result; |
| 1062 | } |
| 1063 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1064 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglAllocMemory(XGL_DEVICE device, const XGL_MEMORY_ALLOC_INFO* pAllocInfo, XGL_GPU_MEMORY* pMem) |
| 1065 | { |
| 1066 | XGL_RESULT result = nextTable.AllocMemory(device, pAllocInfo, pMem); |
| 1067 | return result; |
| 1068 | } |
| 1069 | |
| 1070 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglFreeMemory(XGL_GPU_MEMORY mem) |
| 1071 | { |
| 1072 | XGL_RESULT result = nextTable.FreeMemory(mem); |
| 1073 | return result; |
| 1074 | } |
| 1075 | |
| 1076 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSetMemoryPriority(XGL_GPU_MEMORY mem, XGL_MEMORY_PRIORITY priority) |
| 1077 | { |
| 1078 | XGL_RESULT result = nextTable.SetMemoryPriority(mem, priority); |
| 1079 | return result; |
| 1080 | } |
| 1081 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1082 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglMapMemory(XGL_GPU_MEMORY mem, XGL_FLAGS flags, void** ppData) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1083 | { |
| 1084 | XGL_RESULT result = nextTable.MapMemory(mem, flags, ppData); |
| 1085 | return result; |
| 1086 | } |
| 1087 | |
| 1088 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglUnmapMemory(XGL_GPU_MEMORY mem) |
| 1089 | { |
| 1090 | XGL_RESULT result = nextTable.UnmapMemory(mem); |
| 1091 | return result; |
| 1092 | } |
| 1093 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1094 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglPinSystemMemory(XGL_DEVICE device, const void* pSysMem, size_t memSize, XGL_GPU_MEMORY* pMem) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1095 | { |
| 1096 | XGL_RESULT result = nextTable.PinSystemMemory(device, pSysMem, memSize, pMem); |
| 1097 | return result; |
| 1098 | } |
| 1099 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1100 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetMultiGpuCompatibility(XGL_PHYSICAL_GPU gpu0, XGL_PHYSICAL_GPU gpu1, XGL_GPU_COMPATIBILITY_INFO* pInfo) |
| 1101 | { |
| 1102 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu0; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1103 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 1104 | pthread_once(&g_initOnce, initDrawState); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1105 | XGL_RESULT result = nextTable.GetMultiGpuCompatibility((XGL_PHYSICAL_GPU)gpuw->nextObject, gpu1, pInfo); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1106 | return result; |
| 1107 | } |
| 1108 | |
| 1109 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenSharedMemory(XGL_DEVICE device, const XGL_MEMORY_OPEN_INFO* pOpenInfo, XGL_GPU_MEMORY* pMem) |
| 1110 | { |
| 1111 | XGL_RESULT result = nextTable.OpenSharedMemory(device, pOpenInfo, pMem); |
| 1112 | return result; |
| 1113 | } |
| 1114 | |
| 1115 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenSharedQueueSemaphore(XGL_DEVICE device, const XGL_QUEUE_SEMAPHORE_OPEN_INFO* pOpenInfo, XGL_QUEUE_SEMAPHORE* pSemaphore) |
| 1116 | { |
| 1117 | XGL_RESULT result = nextTable.OpenSharedQueueSemaphore(device, pOpenInfo, pSemaphore); |
| 1118 | return result; |
| 1119 | } |
| 1120 | |
| 1121 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenPeerMemory(XGL_DEVICE device, const XGL_PEER_MEMORY_OPEN_INFO* pOpenInfo, XGL_GPU_MEMORY* pMem) |
| 1122 | { |
| 1123 | XGL_RESULT result = nextTable.OpenPeerMemory(device, pOpenInfo, pMem); |
| 1124 | return result; |
| 1125 | } |
| 1126 | |
| 1127 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenPeerImage(XGL_DEVICE device, const XGL_PEER_IMAGE_OPEN_INFO* pOpenInfo, XGL_IMAGE* pImage, XGL_GPU_MEMORY* pMem) |
| 1128 | { |
| 1129 | XGL_RESULT result = nextTable.OpenPeerImage(device, pOpenInfo, pImage, pMem); |
| 1130 | return result; |
| 1131 | } |
| 1132 | |
| 1133 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyObject(XGL_OBJECT object) |
| 1134 | { |
| 1135 | XGL_RESULT result = nextTable.DestroyObject(object); |
| 1136 | return result; |
| 1137 | } |
| 1138 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1139 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetObjectInfo(XGL_BASE_OBJECT object, XGL_OBJECT_INFO_TYPE infoType, size_t* pDataSize, void* pData) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1140 | { |
| 1141 | XGL_RESULT result = nextTable.GetObjectInfo(object, infoType, pDataSize, pData); |
| 1142 | return result; |
| 1143 | } |
| 1144 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1145 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBindObjectMemory(XGL_OBJECT object, uint32_t allocationIdx, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1146 | { |
Jon Ashburn | ed62b41 | 2015-01-15 10:39:19 -0700 | [diff] [blame] | 1147 | XGL_RESULT result = nextTable.BindObjectMemory(object, allocationIdx, mem, offset); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1148 | return result; |
| 1149 | } |
| 1150 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1151 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBindObjectMemoryRange(XGL_OBJECT object, uint32_t allocationIdx, XGL_GPU_SIZE rangeOffset, XGL_GPU_SIZE rangeSize, XGL_GPU_MEMORY mem, XGL_GPU_SIZE memOffset) |
| 1152 | { |
| 1153 | XGL_RESULT result = nextTable.BindObjectMemoryRange(object, allocationIdx, rangeOffset, rangeSize, mem, memOffset); |
| 1154 | return result; |
| 1155 | } |
| 1156 | |
| 1157 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBindImageMemoryRange(XGL_IMAGE image, uint32_t allocationIdx, const XGL_IMAGE_MEMORY_BIND_INFO* bindInfo, XGL_GPU_MEMORY mem, XGL_GPU_SIZE memOffset) |
| 1158 | { |
| 1159 | XGL_RESULT result = nextTable.BindImageMemoryRange(image, allocationIdx, bindInfo, mem, memOffset); |
| 1160 | return result; |
| 1161 | } |
| 1162 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1163 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateFence(XGL_DEVICE device, const XGL_FENCE_CREATE_INFO* pCreateInfo, XGL_FENCE* pFence) |
| 1164 | { |
| 1165 | XGL_RESULT result = nextTable.CreateFence(device, pCreateInfo, pFence); |
| 1166 | return result; |
| 1167 | } |
| 1168 | |
| 1169 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetFenceStatus(XGL_FENCE fence) |
| 1170 | { |
| 1171 | XGL_RESULT result = nextTable.GetFenceStatus(fence); |
| 1172 | return result; |
| 1173 | } |
| 1174 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1175 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWaitForFences(XGL_DEVICE device, uint32_t fenceCount, const XGL_FENCE* pFences, bool32_t waitAll, uint64_t timeout) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1176 | { |
| 1177 | XGL_RESULT result = nextTable.WaitForFences(device, fenceCount, pFences, waitAll, timeout); |
| 1178 | return result; |
| 1179 | } |
| 1180 | |
| 1181 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateQueueSemaphore(XGL_DEVICE device, const XGL_QUEUE_SEMAPHORE_CREATE_INFO* pCreateInfo, XGL_QUEUE_SEMAPHORE* pSemaphore) |
| 1182 | { |
| 1183 | XGL_RESULT result = nextTable.CreateQueueSemaphore(device, pCreateInfo, pSemaphore); |
| 1184 | return result; |
| 1185 | } |
| 1186 | |
| 1187 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSignalQueueSemaphore(XGL_QUEUE queue, XGL_QUEUE_SEMAPHORE semaphore) |
| 1188 | { |
| 1189 | XGL_RESULT result = nextTable.SignalQueueSemaphore(queue, semaphore); |
| 1190 | return result; |
| 1191 | } |
| 1192 | |
| 1193 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWaitQueueSemaphore(XGL_QUEUE queue, XGL_QUEUE_SEMAPHORE semaphore) |
| 1194 | { |
| 1195 | XGL_RESULT result = nextTable.WaitQueueSemaphore(queue, semaphore); |
| 1196 | return result; |
| 1197 | } |
| 1198 | |
| 1199 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateEvent(XGL_DEVICE device, const XGL_EVENT_CREATE_INFO* pCreateInfo, XGL_EVENT* pEvent) |
| 1200 | { |
| 1201 | XGL_RESULT result = nextTable.CreateEvent(device, pCreateInfo, pEvent); |
| 1202 | return result; |
| 1203 | } |
| 1204 | |
| 1205 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetEventStatus(XGL_EVENT event) |
| 1206 | { |
| 1207 | XGL_RESULT result = nextTable.GetEventStatus(event); |
| 1208 | return result; |
| 1209 | } |
| 1210 | |
| 1211 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSetEvent(XGL_EVENT event) |
| 1212 | { |
| 1213 | XGL_RESULT result = nextTable.SetEvent(event); |
| 1214 | return result; |
| 1215 | } |
| 1216 | |
| 1217 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglResetEvent(XGL_EVENT event) |
| 1218 | { |
| 1219 | XGL_RESULT result = nextTable.ResetEvent(event); |
| 1220 | return result; |
| 1221 | } |
| 1222 | |
| 1223 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateQueryPool(XGL_DEVICE device, const XGL_QUERY_POOL_CREATE_INFO* pCreateInfo, XGL_QUERY_POOL* pQueryPool) |
| 1224 | { |
| 1225 | XGL_RESULT result = nextTable.CreateQueryPool(device, pCreateInfo, pQueryPool); |
| 1226 | return result; |
| 1227 | } |
| 1228 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1229 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetQueryPoolResults(XGL_QUERY_POOL queryPool, uint32_t startQuery, uint32_t queryCount, size_t* pDataSize, void* pData) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1230 | { |
| 1231 | XGL_RESULT result = nextTable.GetQueryPoolResults(queryPool, startQuery, queryCount, pDataSize, pData); |
| 1232 | return result; |
| 1233 | } |
| 1234 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1235 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetFormatInfo(XGL_DEVICE device, XGL_FORMAT format, XGL_FORMAT_INFO_TYPE infoType, size_t* pDataSize, void* pData) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1236 | { |
| 1237 | XGL_RESULT result = nextTable.GetFormatInfo(device, format, infoType, pDataSize, pData); |
| 1238 | return result; |
| 1239 | } |
| 1240 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1241 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateBuffer(XGL_DEVICE device, const XGL_BUFFER_CREATE_INFO* pCreateInfo, XGL_BUFFER* pBuffer) |
| 1242 | { |
| 1243 | XGL_RESULT result = nextTable.CreateBuffer(device, pCreateInfo, pBuffer); |
| 1244 | return result; |
| 1245 | } |
| 1246 | |
| 1247 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateBufferView(XGL_DEVICE device, const XGL_BUFFER_VIEW_CREATE_INFO* pCreateInfo, XGL_BUFFER_VIEW* pView) |
| 1248 | { |
| 1249 | XGL_RESULT result = nextTable.CreateBufferView(device, pCreateInfo, pView); |
| 1250 | return result; |
| 1251 | } |
| 1252 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1253 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateImage(XGL_DEVICE device, const XGL_IMAGE_CREATE_INFO* pCreateInfo, XGL_IMAGE* pImage) |
| 1254 | { |
| 1255 | XGL_RESULT result = nextTable.CreateImage(device, pCreateInfo, pImage); |
| 1256 | return result; |
| 1257 | } |
| 1258 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1259 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSetFastClearColor(XGL_IMAGE image, const float color[4]) |
| 1260 | { |
| 1261 | XGL_RESULT result = nextTable.SetFastClearColor(image, color); |
| 1262 | return result; |
| 1263 | } |
| 1264 | |
| 1265 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSetFastClearDepth(XGL_IMAGE image, float depth) |
| 1266 | { |
| 1267 | XGL_RESULT result = nextTable.SetFastClearDepth(image, depth); |
| 1268 | return result; |
| 1269 | } |
| 1270 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1271 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetImageSubresourceInfo(XGL_IMAGE image, const XGL_IMAGE_SUBRESOURCE* pSubresource, XGL_SUBRESOURCE_INFO_TYPE infoType, size_t* pDataSize, void* pData) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1272 | { |
| 1273 | XGL_RESULT result = nextTable.GetImageSubresourceInfo(image, pSubresource, infoType, pDataSize, pData); |
| 1274 | return result; |
| 1275 | } |
| 1276 | |
| 1277 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateImageView(XGL_DEVICE device, const XGL_IMAGE_VIEW_CREATE_INFO* pCreateInfo, XGL_IMAGE_VIEW* pView) |
| 1278 | { |
| 1279 | XGL_RESULT result = nextTable.CreateImageView(device, pCreateInfo, pView); |
| 1280 | return result; |
| 1281 | } |
| 1282 | |
| 1283 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateColorAttachmentView(XGL_DEVICE device, const XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO* pCreateInfo, XGL_COLOR_ATTACHMENT_VIEW* pView) |
| 1284 | { |
| 1285 | XGL_RESULT result = nextTable.CreateColorAttachmentView(device, pCreateInfo, pView); |
| 1286 | return result; |
| 1287 | } |
| 1288 | |
| 1289 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDepthStencilView(XGL_DEVICE device, const XGL_DEPTH_STENCIL_VIEW_CREATE_INFO* pCreateInfo, XGL_DEPTH_STENCIL_VIEW* pView) |
| 1290 | { |
| 1291 | XGL_RESULT result = nextTable.CreateDepthStencilView(device, pCreateInfo, pView); |
| 1292 | return result; |
| 1293 | } |
| 1294 | |
| 1295 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateShader(XGL_DEVICE device, const XGL_SHADER_CREATE_INFO* pCreateInfo, XGL_SHADER* pShader) |
| 1296 | { |
| 1297 | XGL_RESULT result = nextTable.CreateShader(device, pCreateInfo, pShader); |
| 1298 | return result; |
| 1299 | } |
| 1300 | |
| 1301 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateGraphicsPipeline(XGL_DEVICE device, const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo, XGL_PIPELINE* pPipeline) |
| 1302 | { |
| 1303 | XGL_RESULT result = nextTable.CreateGraphicsPipeline(device, pCreateInfo, pPipeline); |
| 1304 | // Create LL HEAD for this Pipeline |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1305 | char str[1024]; |
| 1306 | sprintf(str, "Created Gfx Pipeline %p", (void*)*pPipeline); |
| 1307 | 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] | 1308 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1309 | PIPELINE_NODE *pTrav = pPipelineHead; |
| 1310 | if (pTrav) { |
| 1311 | while (pTrav->pNext) |
| 1312 | pTrav = pTrav->pNext; |
| 1313 | pTrav->pNext = (PIPELINE_NODE*)malloc(sizeof(PIPELINE_NODE)); |
| 1314 | pTrav = pTrav->pNext; |
| 1315 | } |
| 1316 | else { |
| 1317 | pTrav = (PIPELINE_NODE*)malloc(sizeof(PIPELINE_NODE)); |
| 1318 | pPipelineHead = pTrav; |
| 1319 | } |
| 1320 | memset((void*)pTrav, 0, sizeof(PIPELINE_NODE)); |
| 1321 | pTrav->pipeline = *pPipeline; |
| 1322 | initPipeline(pTrav, pCreateInfo); |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1323 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1324 | return result; |
| 1325 | } |
| 1326 | |
| 1327 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateComputePipeline(XGL_DEVICE device, const XGL_COMPUTE_PIPELINE_CREATE_INFO* pCreateInfo, XGL_PIPELINE* pPipeline) |
| 1328 | { |
| 1329 | XGL_RESULT result = nextTable.CreateComputePipeline(device, pCreateInfo, pPipeline); |
| 1330 | return result; |
| 1331 | } |
| 1332 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1333 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglStorePipeline(XGL_PIPELINE pipeline, size_t* pDataSize, void* pData) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1334 | { |
| 1335 | XGL_RESULT result = nextTable.StorePipeline(pipeline, pDataSize, pData); |
| 1336 | return result; |
| 1337 | } |
| 1338 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1339 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglLoadPipeline(XGL_DEVICE device, size_t dataSize, const void* pData, XGL_PIPELINE* pPipeline) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1340 | { |
| 1341 | XGL_RESULT result = nextTable.LoadPipeline(device, dataSize, pData, pPipeline); |
| 1342 | return result; |
| 1343 | } |
| 1344 | |
| 1345 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreatePipelineDelta(XGL_DEVICE device, XGL_PIPELINE p1, XGL_PIPELINE p2, XGL_PIPELINE_DELTA* delta) |
| 1346 | { |
| 1347 | XGL_RESULT result = nextTable.CreatePipelineDelta(device, p1, p2, delta); |
| 1348 | return result; |
| 1349 | } |
| 1350 | |
| 1351 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateSampler(XGL_DEVICE device, const XGL_SAMPLER_CREATE_INFO* pCreateInfo, XGL_SAMPLER* pSampler) |
| 1352 | { |
| 1353 | XGL_RESULT result = nextTable.CreateSampler(device, pCreateInfo, pSampler); |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1354 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 5a1d9f3 | 2014-11-20 10:48:56 -0700 | [diff] [blame] | 1355 | SAMPLER_NODE *pNewNode = (SAMPLER_NODE*)malloc(sizeof(SAMPLER_NODE)); |
| 1356 | pNewNode->sampler = *pSampler; |
| 1357 | memcpy(&pNewNode->createInfo, pCreateInfo, sizeof(XGL_SAMPLER_CREATE_INFO)); |
| 1358 | pNewNode->pNext = pSamplerHead; |
| 1359 | pSamplerHead = pNewNode; |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1360 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1361 | return result; |
| 1362 | } |
| 1363 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1364 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDescriptorSetLayout(XGL_DEVICE device, XGL_FLAGS stageFlags, const uint32_t* pSetBindPoints, XGL_DESCRIPTOR_SET_LAYOUT priorSetLayout, const XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pSetLayoutInfoList, XGL_DESCRIPTOR_SET_LAYOUT* pSetLayout) |
| 1365 | { |
| 1366 | XGL_RESULT result = nextTable.CreateDescriptorSetLayout(device, stageFlags, pSetBindPoints, priorSetLayout, pSetLayoutInfoList, pSetLayout); |
| 1367 | if (XGL_SUCCESS == result) { |
| 1368 | if (NULL != priorSetLayout) { |
| 1369 | // Create new layout node off of prior layout |
| 1370 | } |
| 1371 | LAYOUT_NODE* pNewNode = (LAYOUT_NODE*)malloc(sizeof(LAYOUT_NODE)); |
| 1372 | if (NULL == pNewNode) { |
| 1373 | char str[1024]; |
| 1374 | sprintf(str, "Out of memory while attempting to allocate LAYOUT_NODE in xglCreateDescriptorSetLayout()"); |
| 1375 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, *pSetLayout, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str); |
| 1376 | } |
| 1377 | memset(pNewNode, 0, sizeof(LAYOUT_NODE)); |
| 1378 | pNewNode->pNext = ; |
| 1379 | pNewNode->stageFlags = stageFlags; |
| 1380 | memcpy(&pNewNode->createInfo, pCreateInfo, sizeof()); |
| 1381 | } |
| 1382 | return result; |
| 1383 | } |
| 1384 | |
| 1385 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBeginDescriptorRegionUpdate(XGL_DEVICE device, XGL_DESCRIPTOR_UPDATE_MODE updateMode) |
| 1386 | { |
| 1387 | XGL_RESULT result = nextTable.BeginDescriptorRegionUpdate(device, updateMode); |
| 1388 | if (XGL_SUCCESS == result) { |
| 1389 | if (!g_pRegionHead) { |
| 1390 | char str[1024]; |
| 1391 | sprintf(str, "No descriptor region found! Global descriptor region is NULL!"); |
| 1392 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, g_pRegionHead, 0, DRAWSTATE_NO_DS_REGION, "DS", str); |
| 1393 | } |
| 1394 | else { |
| 1395 | REGION_NODE* pRegionNode = getRegionNode(g_pRegionHead); |
| 1396 | if (!pRegionNode) { |
| 1397 | char str[1024]; |
| 1398 | sprintf(str, "Unable to find region node for global region head %p", (void*)g_pRegionHead); |
| 1399 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, g_pRegionHead, 0, DRAWSTATE_INTERNAL_ERROR, "DS", str); |
| 1400 | } |
| 1401 | else { |
| 1402 | pRegionNode->updateActive = 1; |
| 1403 | } |
| 1404 | } |
| 1405 | } |
| 1406 | return result; |
| 1407 | } |
| 1408 | |
| 1409 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEndDescriptorRegionUpdate(XGL_DEVICE device, XGL_CMD_BUFFER cmd) |
| 1410 | { |
| 1411 | XGL_RESULT result = nextTable.EndDescriptorRegionUpdate(device, cmd); |
| 1412 | if (XGL_SUCCESS == result) { |
| 1413 | if (!g_pRegionHead) { |
| 1414 | char str[1024]; |
| 1415 | sprintf(str, "No descriptor region found! Global descriptor region is NULL!"); |
| 1416 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, g_pRegionHead, 0, DRAWSTATE_NO_DS_REGION, "DS", str); |
| 1417 | } |
| 1418 | else { |
| 1419 | REGION_NODE* pRegionNode = getRegionNode(g_pRegionHead); |
| 1420 | if (!pRegionNode) { |
| 1421 | char str[1024]; |
| 1422 | sprintf(str, "Unable to find region node for global region head %p", (void*)g_pRegionHead); |
| 1423 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, g_pRegionHead, 0, DRAWSTATE_INTERNAL_ERROR, "DS", str); |
| 1424 | } |
| 1425 | else { |
| 1426 | if (!pRegionNode->updateActive) { |
| 1427 | char str[1024]; |
| 1428 | sprintf(str, "You must call xglBeginDescriptorRegionUpdate() before this call to xglEndDescriptorRegionUpdate()!"); |
| 1429 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, g_pRegionHead, 0, DRAWSTATE_DS_END_WITHOUT_BEGIN, "DS", str); |
| 1430 | } |
| 1431 | else { |
| 1432 | pRegionNode->updateActive = 0; |
| 1433 | } |
| 1434 | } |
| 1435 | } |
| 1436 | } |
| 1437 | return result; |
| 1438 | } |
| 1439 | |
| 1440 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDescriptorRegion(XGL_DEVICE device, XGL_DESCRIPTOR_REGION_USAGE regionUsage, uint32_t maxSets, const XGL_DESCRIPTOR_REGION_CREATE_INFO* pCreateInfo, XGL_DESCRIPTOR_REGION* pDescriptorRegion) |
| 1441 | { |
| 1442 | XGL_RESULT result = nextTable.CreateDescriptorRegion(device, regionUsage, maxSets, pCreateInfo, pDescriptorRegion); |
| 1443 | if (XGL_SUCCESS == result) { |
| 1444 | // Insert this region into Global Region LL at head |
| 1445 | char str[1024]; |
| 1446 | sprintf(str, "Created Descriptor Region %p", (void*)*pDescriptorRegion); |
| 1447 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pDescriptorRegion, 0, DRAWSTATE_NONE, "DS", str); |
| 1448 | pthread_mutex_lock(&globalLock); |
| 1449 | REGION_NODE *pTrav = g_pRegionHead; |
| 1450 | REGION_NODE pNewNode = (REGION_NODE*)malloc(sizeof(REGION_NODE)); |
| 1451 | if (NULL == pNewNode) { |
| 1452 | char str[1024]; |
| 1453 | sprintf(str, "Out of memory while attempting to allocate SET_NODE in xglAllocDescriptorSets()"); |
| 1454 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, *pDescriptorRegion, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str); |
| 1455 | } |
| 1456 | else { |
| 1457 | memset(pNewNode, 0, sizeof(REGION_NODE)); |
| 1458 | pNewNode->pNext = g_pRegionHead; |
| 1459 | g_pRegionHead = pNewNode; |
| 1460 | memcpy(&pNewNode->createInfo, pCreateInfo, sizeof(XGL_DESCRIPTOR_REGION_CREATE_INFO)); |
| 1461 | pNewNode->regionUsage = regionUsage; |
| 1462 | pNewNode->updateActive = 0; |
| 1463 | pNewNode->maxSets = maxSets; |
| 1464 | pNewNode->region = *pDescriptorRegion; |
| 1465 | } |
| 1466 | pthread_mutex_unlock(&globalLock); |
| 1467 | } |
| 1468 | else { |
| 1469 | // Need to do anything if region create fails? |
| 1470 | } |
| 1471 | return result; |
| 1472 | } |
| 1473 | |
| 1474 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglClearDescriptorRegion(XGL_DESCRIPTOR_REGION descriptorRegion) |
| 1475 | { |
| 1476 | // TODO : Handle clearing a region |
| 1477 | XGL_RESULT result = nextTable.ClearDescriptorRegion(descriptorRegion); |
| 1478 | return result; |
| 1479 | } |
| 1480 | |
| 1481 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglAllocDescriptorSets(XGL_DESCRIPTOR_REGION descriptorRegion, XGL_DESCRIPTOR_SET_USAGE setUsage, uint32_t count, const XGL_DESCRIPTOR_SET_LAYOUT* pSetLayouts, XGL_DESCRIPTOR_SET* pDescriptorSets, uint32_t* pCount) |
| 1482 | { |
| 1483 | XGL_RESULT result = nextTable.AllocDescriptorSets(descriptorRegion, setUsage, count, pSetLayouts, pDescriptorSets, pCount); |
| 1484 | if (XGL_SUCCESS == result) { |
| 1485 | REGION_NODE *pRegion = getRegionNode(descriptorRegion); |
| 1486 | // TODO : Handle Null Region |
| 1487 | for (uint32_t i; i < *pCount; i++) { |
| 1488 | char str[1024]; |
| 1489 | sprintf(str, "Created Descriptor Set %p", (void*)pDescriptorSets[i]); |
| 1490 | layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pDescriptorSet[i], 0, DRAWSTATE_NONE, "DS", str); |
| 1491 | pthread_mutex_lock(&globalLock); |
| 1492 | // Create new set node and add to head of region nodes |
| 1493 | SET_NODE pNewNode = (SET_NODE*)malloc(sizeof(SET_NODE)); |
| 1494 | if (NULL == pNewNode) { |
| 1495 | char str[1024]; |
| 1496 | sprintf(str, "Out of memory while attempting to allocate SET_NODE in xglAllocDescriptorSets()"); |
| 1497 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pDescriptorSet[i], 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str); |
| 1498 | } |
| 1499 | else { |
| 1500 | memset(pNewNode, 0, sizeof(SET_NODE)); |
| 1501 | pNewNode->pNext = pRegion->pSets; |
| 1502 | pRegion->pSets = pNewNode; |
| 1503 | LAYOUT_NODE* pLayout = getLayoutNode(pSetLayouts[i]); |
| 1504 | // TODO : Handle NULL layout |
| 1505 | pNewNode->pLayouts = pLayout; |
| 1506 | pNewNode->pNext = pRegion->pSets; |
| 1507 | pRegion->pSets = pNewNode; |
| 1508 | pNewNode->region = descriptorRegion; |
| 1509 | pNewNode->set = pDescriptorSets[i]; |
| 1510 | pNewNode->setUsage = setUsage; |
| 1511 | pNewNode->updateActive = 0; |
| 1512 | } |
| 1513 | pthread_mutex_unlock(&globalLock); |
| 1514 | } |
| 1515 | } |
| 1516 | return result; |
| 1517 | } |
| 1518 | |
| 1519 | XGL_LAYER_EXPORT void XGLAPI xglClearDescriptorSets(XGL_DESCRIPTOR_REGION descriptorRegion, uint32_t count, const XGL_DESCRIPTOR_SET* pDescriptorSets) |
| 1520 | { |
| 1521 | // TODO : For each descriptor set, clear it |
| 1522 | nextTable.ClearDescriptorSets(descriptorRegion, count, pDescriptorSets); |
| 1523 | } |
| 1524 | |
| 1525 | XGL_LAYER_EXPORT void XGLAPI xglUpdateDescriptors(XGL_DESCRIPTOR_SET descriptorSet, const void* pUpdateChain) |
| 1526 | { |
| 1527 | REGION_NODE* pRegionNode = getRegionNode(g_pRegionHead); |
| 1528 | if (!pRegionNode->updateActive) { |
| 1529 | char str[1024]; |
| 1530 | sprintf(str, "You must call xglBeginDescriptorRegionUpdate() before this call to xglUpdateDescriptors()!"); |
| 1531 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, g_pRegionHead, 0, DRAWSTATE_UPDATE_WITHOUT_BEGIN, "DS", str); |
| 1532 | } |
| 1533 | // TODO : How does pUpdateChain work? Need to account for the actual updates |
| 1534 | nextTable.UpdateDescriptors(descriptorSet, pUpdateChain); |
| 1535 | } |
| 1536 | /* |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1537 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDescriptorSet(XGL_DEVICE device, const XGL_DESCRIPTOR_SET_CREATE_INFO* pCreateInfo, XGL_DESCRIPTOR_SET* pDescriptorSet) |
| 1538 | { |
| 1539 | XGL_RESULT result = nextTable.CreateDescriptorSet(device, pCreateInfo, pDescriptorSet); |
| 1540 | // Create LL chain |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1541 | char str[1024]; |
| 1542 | sprintf(str, "Created Descriptor Set (DS) %p", (void*)*pDescriptorSet); |
| 1543 | 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] | 1544 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1545 | DS_LL_HEAD *pTrav = pDSHead; |
| 1546 | if (pTrav) { |
| 1547 | // Grow existing list |
| 1548 | while (pTrav->pNextDS) |
| 1549 | pTrav = pTrav->pNextDS; |
| 1550 | pTrav->pNextDS = (DS_LL_HEAD*)malloc(sizeof(DS_LL_HEAD)); |
| 1551 | pTrav = pTrav->pNextDS; |
| 1552 | } |
| 1553 | else { // Create new list |
| 1554 | pTrav = (DS_LL_HEAD*)malloc(sizeof(DS_LL_HEAD)); |
| 1555 | pDSHead = pTrav; |
| 1556 | } |
| 1557 | pTrav->dsSlot = (DS_SLOT*)malloc(sizeof(DS_SLOT) * pCreateInfo->slots); |
| 1558 | pTrav->dsID = *pDescriptorSet; |
| 1559 | pTrav->numSlots = pCreateInfo->slots; |
| 1560 | pTrav->pNextDS = NULL; |
| 1561 | pTrav->updateActive = XGL_FALSE; |
| 1562 | initDS(pTrav); |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1563 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1564 | return result; |
| 1565 | } |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 1566 | /* TODO : Update these functions for new binding model |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1567 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1568 | XGL_LAYER_EXPORT void XGLAPI xglBeginDescriptorSetUpdate(XGL_DESCRIPTOR_SET descriptorSet) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1569 | { |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 1570 | DS_LL_HEAD* pDS = getDS(descriptorSet); |
| 1571 | if (!pDS) { |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1572 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1573 | char str[1024]; |
| 1574 | sprintf(str, "Specified Descriptor Set %p does not exist!", (void*)descriptorSet); |
| 1575 | 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] | 1576 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 1577 | else { |
| 1578 | pDS->updateActive = XGL_TRUE; |
| 1579 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1580 | nextTable.BeginDescriptorSetUpdate(descriptorSet); |
| 1581 | } |
| 1582 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1583 | XGL_LAYER_EXPORT void XGLAPI xglEndDescriptorSetUpdate(XGL_DESCRIPTOR_SET descriptorSet) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1584 | { |
| 1585 | if (!dsUpdate(descriptorSet)) { |
| 1586 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1587 | char str[1024]; |
| 1588 | sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglEndDescriptorSetUpdate()!", (void*)descriptorSet); |
| 1589 | 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] | 1590 | } |
Tobin Ehlis | 0f051a5 | 2014-10-24 13:03:56 -0600 | [diff] [blame] | 1591 | else { |
| 1592 | DS_LL_HEAD* pDS = getDS(descriptorSet); |
| 1593 | if (!pDS) { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1594 | char str[1024]; |
| 1595 | sprintf(str, "Specified Descriptor Set %p does not exist!", (void*)descriptorSet); |
| 1596 | 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] | 1597 | } |
| 1598 | else { |
| 1599 | pDS->updateActive = XGL_FALSE; |
| 1600 | } |
| 1601 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1602 | nextTable.EndDescriptorSetUpdate(descriptorSet); |
| 1603 | } |
| 1604 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1605 | XGL_LAYER_EXPORT void XGLAPI xglAttachSamplerDescriptors(XGL_DESCRIPTOR_SET descriptorSet, uint32_t startSlot, uint32_t slotCount, const XGL_SAMPLER* pSamplers) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1606 | { |
| 1607 | if (!dsUpdate(descriptorSet)) { |
| 1608 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1609 | char str[1024]; |
| 1610 | sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglAttachSamplerDescriptors()!", (void*)descriptorSet); |
| 1611 | 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] | 1612 | } |
| 1613 | else { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1614 | if (!dsSamplerMapping(descriptorSet, startSlot, slotCount, pSamplers)) { |
| 1615 | char str[1024]; |
| 1616 | sprintf(str, "Unable to attach sampler descriptors to DS %p!", (void*)descriptorSet); |
| 1617 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_SAMPLE_ATTACH_FAILED, "DS", str); |
| 1618 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1619 | } |
| 1620 | nextTable.AttachSamplerDescriptors(descriptorSet, startSlot, slotCount, pSamplers); |
| 1621 | } |
| 1622 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1623 | XGL_LAYER_EXPORT void XGLAPI xglAttachImageViewDescriptors(XGL_DESCRIPTOR_SET descriptorSet, uint32_t startSlot, uint32_t slotCount, const XGL_IMAGE_VIEW_ATTACH_INFO* pImageViews) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1624 | { |
| 1625 | if (!dsUpdate(descriptorSet)) { |
| 1626 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1627 | char str[1024]; |
| 1628 | sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglAttachSamplerDescriptors()!", (void*)descriptorSet); |
| 1629 | 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] | 1630 | } |
| 1631 | else { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1632 | if (!dsImageMapping(descriptorSet, startSlot, slotCount, pImageViews)) { |
| 1633 | char str[1024]; |
| 1634 | sprintf(str, "Unable to attach image view descriptors to DS %p!", (void*)descriptorSet); |
| 1635 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_IMAGE_ATTACH_FAILED, "DS", str); |
| 1636 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1637 | } |
| 1638 | nextTable.AttachImageViewDescriptors(descriptorSet, startSlot, slotCount, pImageViews); |
| 1639 | } |
| 1640 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1641 | XGL_LAYER_EXPORT void XGLAPI xglAttachMemoryViewDescriptors(XGL_DESCRIPTOR_SET descriptorSet, uint32_t startSlot, uint32_t slotCount, const XGL_MEMORY_VIEW_ATTACH_INFO* pMemViews) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1642 | { |
| 1643 | if (!dsUpdate(descriptorSet)) { |
| 1644 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1645 | char str[1024]; |
| 1646 | sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglAttachSamplerDescriptors()!", (void*)descriptorSet); |
| 1647 | 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] | 1648 | } |
| 1649 | else { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1650 | if (!dsMemMapping(descriptorSet, startSlot, slotCount, pMemViews)) { |
| 1651 | char str[1024]; |
| 1652 | sprintf(str, "Unable to attach memory view descriptors to DS %p!", (void*)descriptorSet); |
| 1653 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_MEMORY_ATTACH_FAILED, "DS", str); |
| 1654 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1655 | } |
| 1656 | nextTable.AttachMemoryViewDescriptors(descriptorSet, startSlot, slotCount, pMemViews); |
| 1657 | } |
| 1658 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1659 | XGL_LAYER_EXPORT void XGLAPI xglAttachNestedDescriptors(XGL_DESCRIPTOR_SET descriptorSet, uint32_t startSlot, uint32_t slotCount, const XGL_DESCRIPTOR_SET_ATTACH_INFO* pNestedDescriptorSets) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1660 | { |
| 1661 | if (!dsUpdate(descriptorSet)) { |
| 1662 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1663 | char str[1024]; |
| 1664 | sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglAttachSamplerDescriptors()!", (void*)descriptorSet); |
| 1665 | 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] | 1666 | } |
| 1667 | nextTable.AttachNestedDescriptors(descriptorSet, startSlot, slotCount, pNestedDescriptorSets); |
| 1668 | } |
| 1669 | |
| 1670 | // TODO : Does xglBeginDescriptorSetUpdate() have to be called before this function? |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1671 | XGL_LAYER_EXPORT void XGLAPI xglClearDescriptorSetSlots(XGL_DESCRIPTOR_SET descriptorSet, uint32_t startSlot, uint32_t slotCount) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1672 | { |
| 1673 | if (!dsUpdate(descriptorSet)) { |
| 1674 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1675 | char str[1024]; |
| 1676 | sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglClearDescriptorSetSlots()!", (void*)descriptorSet); |
| 1677 | 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] | 1678 | } |
| 1679 | if (!clearDS(descriptorSet, startSlot, slotCount)) { |
| 1680 | // TODO : This is where we should flag a REAL error |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1681 | char str[1024]; |
| 1682 | sprintf(str, "Unable to perform xglClearDescriptorSetSlots(%p, %u, %u) call!", descriptorSet, startSlot, slotCount); |
| 1683 | 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] | 1684 | } |
| 1685 | nextTable.ClearDescriptorSetSlots(descriptorSet, startSlot, slotCount); |
| 1686 | } |
Tobin Ehlis | 2f3726c | 2015-01-15 17:51:52 -0700 | [diff] [blame] | 1687 | */ |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1688 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1689 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicViewportState(XGL_DEVICE device, const XGL_DYNAMIC_VP_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_VP_STATE_OBJECT* pState) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1690 | { |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1691 | XGL_RESULT result = nextTable.CreateDynamicViewportState(device, pCreateInfo, pState); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 1692 | insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_VIEWPORT); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1693 | return result; |
| 1694 | } |
| 1695 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1696 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicRasterState(XGL_DEVICE device, const XGL_DYNAMIC_RS_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_RS_STATE_OBJECT* pState) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1697 | { |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1698 | XGL_RESULT result = nextTable.CreateDynamicRasterState(device, pCreateInfo, pState); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 1699 | insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_RASTER); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1700 | return result; |
| 1701 | } |
| 1702 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1703 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicColorBlendState(XGL_DEVICE device, const XGL_DYNAMIC_CB_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_CB_STATE_OBJECT* pState) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1704 | { |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1705 | XGL_RESULT result = nextTable.CreateDynamicColorBlendState(device, pCreateInfo, pState); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 1706 | insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_MSAA); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1707 | return result; |
| 1708 | } |
| 1709 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1710 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicDepthStencilState(XGL_DEVICE device, const XGL_DYNAMIC_DS_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_DS_STATE_OBJECT* pState) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1711 | { |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1712 | XGL_RESULT result = nextTable.CreateDynamicDepthStencilState(device, pCreateInfo, pState); |
Tobin Ehlis | 56a6107 | 2014-11-21 08:58:46 -0700 | [diff] [blame] | 1713 | insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_DEPTH_STENCIL); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1714 | return result; |
| 1715 | } |
| 1716 | |
| 1717 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateCommandBuffer(XGL_DEVICE device, const XGL_CMD_BUFFER_CREATE_INFO* pCreateInfo, XGL_CMD_BUFFER* pCmdBuffer) |
| 1718 | { |
| 1719 | XGL_RESULT result = nextTable.CreateCommandBuffer(device, pCreateInfo, pCmdBuffer); |
| 1720 | return result; |
| 1721 | } |
| 1722 | |
Jon Ashburn | 57ba18d | 2014-12-31 17:11:49 -0700 | [diff] [blame] | 1723 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBeginCommandBuffer(XGL_CMD_BUFFER cmdBuffer, const XGL_CMD_BUFFER_BEGIN_INFO* pBeginInfo) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1724 | { |
Jon Ashburn | 57ba18d | 2014-12-31 17:11:49 -0700 | [diff] [blame] | 1725 | XGL_RESULT result = nextTable.BeginCommandBuffer(cmdBuffer, pBeginInfo); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1726 | return result; |
| 1727 | } |
| 1728 | |
| 1729 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEndCommandBuffer(XGL_CMD_BUFFER cmdBuffer) |
| 1730 | { |
| 1731 | XGL_RESULT result = nextTable.EndCommandBuffer(cmdBuffer); |
| 1732 | return result; |
| 1733 | } |
| 1734 | |
| 1735 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglResetCommandBuffer(XGL_CMD_BUFFER cmdBuffer) |
| 1736 | { |
| 1737 | XGL_RESULT result = nextTable.ResetCommandBuffer(cmdBuffer); |
| 1738 | return result; |
| 1739 | } |
| 1740 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1741 | XGL_LAYER_EXPORT void XGLAPI xglCmdBindPipeline(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE pipeline) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1742 | { |
| 1743 | if (getPipeline(pipeline)) { |
| 1744 | lastBoundPipeline = pipeline; |
| 1745 | } |
| 1746 | else { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1747 | char str[1024]; |
| 1748 | sprintf(str, "Attempt to bind Pipeline %p that doesn't exist!", (void*)pipeline); |
| 1749 | 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] | 1750 | } |
| 1751 | nextTable.CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline); |
| 1752 | } |
| 1753 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1754 | XGL_LAYER_EXPORT void XGLAPI xglCmdBindPipelineDelta(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE_DELTA delta) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1755 | { |
| 1756 | nextTable.CmdBindPipelineDelta(cmdBuffer, pipelineBindPoint, delta); |
| 1757 | } |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1758 | /* |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1759 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1760 | XGL_LAYER_EXPORT void XGLAPI xglCmdBindDescriptorSet(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, uint32_t index, XGL_DESCRIPTOR_SET descriptorSet, uint32_t slotOffset) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1761 | { |
| 1762 | if (getDS(descriptorSet)) { |
Tobin Ehlis | b815498 | 2014-10-27 14:53:17 -0600 | [diff] [blame] | 1763 | assert(index < XGL_MAX_DESCRIPTOR_SETS); |
Tobin Ehlis | 6aa7742 | 2015-01-07 17:49:29 -0700 | [diff] [blame] | 1764 | if (dsUpdate(descriptorSet)) { |
| 1765 | char str[1024]; |
| 1766 | sprintf(str, "You must call xglEndDescriptorSetUpdate(%p) before this call to xglCmdBindDescriptorSet()!", (void*)descriptorSet); |
| 1767 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_BINDING_DS_NO_END_UPDATE, "DS", str); |
| 1768 | } |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1769 | pthread_mutex_lock(&globalLock); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1770 | lastBoundDS[index] = descriptorSet; |
Tobin Ehlis | eacc64f | 2014-11-24 17:09:09 -0700 | [diff] [blame] | 1771 | lastBoundSlotOffset[index] = slotOffset; |
Tobin Ehlis | 9e142a3 | 2014-11-21 12:04:39 -0700 | [diff] [blame] | 1772 | pthread_mutex_unlock(&globalLock); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1773 | char str[1024]; |
| 1774 | sprintf(str, "DS %p bound to DS index %u on pipeline %s", (void*)descriptorSet, index, string_XGL_PIPELINE_BIND_POINT(pipelineBindPoint)); |
| 1775 | 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] | 1776 | } |
| 1777 | else { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1778 | char str[1024]; |
| 1779 | sprintf(str, "Attempt to bind DS %p that doesn't exist!", (void*)descriptorSet); |
| 1780 | 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] | 1781 | } |
| 1782 | nextTable.CmdBindDescriptorSet(cmdBuffer, pipelineBindPoint, index, descriptorSet, slotOffset); |
| 1783 | } |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1784 | */ |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1785 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1786 | |
| 1787 | XGL_LAYER_EXPORT void XGLAPI xglCmdBindDynamicStateObject(XGL_CMD_BUFFER cmdBuffer, XGL_STATE_BIND_POINT stateBindPoint, XGL_DYNAMIC_STATE_OBJECT state) |
| 1788 | { |
| 1789 | setLastBoundDynamicState(state, stateBindPoint); |
| 1790 | nextTable.CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state); |
| 1791 | } |
| 1792 | |
| 1793 | XGL_LAYER_EXPORT void XGLAPI xglCmdBindDescriptorSet(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_DESCRIPTOR_SET descriptorSet, const uint32_t* pUserData) |
| 1794 | { |
| 1795 | nextTable.CmdBindDescriptorSet(cmdBuffer, pipelineBindPoint, descriptorSet, pUserData); |
| 1796 | } |
| 1797 | |
| 1798 | XGL_LAYER_EXPORT void XGLAPI xglCmdBindIndexBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, XGL_INDEX_TYPE indexType) |
| 1799 | { |
| 1800 | lastIdxBinding = binding; |
| 1801 | nextTable.CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType); |
| 1802 | } |
| 1803 | |
| 1804 | XGL_LAYER_EXPORT void XGLAPI xglCmdBindVertexBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, uint32_t binding) |
Chia-I Wu | 3b04af5 | 2014-11-08 10:48:20 +0800 | [diff] [blame] | 1805 | { |
Tobin Ehlis | 1affd3c | 2014-11-25 10:24:15 -0700 | [diff] [blame] | 1806 | lastVtxBinding = binding; |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1807 | nextTable.CmdBindVertexBuffer(cmdBuffer, buffer, offset, binding); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1808 | } |
| 1809 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1810 | XGL_LAYER_EXPORT void XGLAPI xglCmdDraw(XGL_CMD_BUFFER cmdBuffer, uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1811 | { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1812 | char str[1024]; |
| 1813 | sprintf(str, "xglCmdDraw() call #%lu, reporting DS state:", drawCount[DRAW]++); |
| 1814 | 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] | 1815 | synchAndPrintDSConfig(); |
| 1816 | nextTable.CmdDraw(cmdBuffer, firstVertex, vertexCount, firstInstance, instanceCount); |
| 1817 | } |
| 1818 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1819 | XGL_LAYER_EXPORT void XGLAPI xglCmdDrawIndexed(XGL_CMD_BUFFER cmdBuffer, uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1820 | { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1821 | char str[1024]; |
Tobin Ehlis | 6208641 | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1822 | sprintf(str, "xglCmdDrawIndexed() call #%lu, reporting DS state:", drawCount[DRAW_INDEXED]++); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1823 | 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] | 1824 | synchAndPrintDSConfig(); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1825 | nextTable.CmdDrawIndexed(cmdBuffer, firstIndex, indexCount, vertexOffset, firstInstance, instanceCount); |
| 1826 | } |
| 1827 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1828 | XGL_LAYER_EXPORT void XGLAPI xglCmdDrawIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, uint32_t count, uint32_t stride) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1829 | { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1830 | char str[1024]; |
Tobin Ehlis | 6208641 | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1831 | sprintf(str, "xglCmdDrawIndirect() call #%lu, reporting DS state:", drawCount[DRAW_INDIRECT]++); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1832 | 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] | 1833 | synchAndPrintDSConfig(); |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1834 | nextTable.CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1835 | } |
| 1836 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1837 | XGL_LAYER_EXPORT void XGLAPI xglCmdDrawIndexedIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, uint32_t count, uint32_t stride) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1838 | { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1839 | char str[1024]; |
Tobin Ehlis | 6208641 | 2014-11-19 16:19:28 -0700 | [diff] [blame] | 1840 | sprintf(str, "xglCmdDrawIndexedIndirect() call #%lu, reporting DS state:", drawCount[DRAW_INDEXED_INDIRECT]++); |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1841 | 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] | 1842 | synchAndPrintDSConfig(); |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1843 | nextTable.CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1844 | } |
| 1845 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1846 | XGL_LAYER_EXPORT void XGLAPI xglCmdDispatch(XGL_CMD_BUFFER cmdBuffer, uint32_t x, uint32_t y, uint32_t z) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1847 | { |
| 1848 | nextTable.CmdDispatch(cmdBuffer, x, y, z); |
| 1849 | } |
| 1850 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1851 | XGL_LAYER_EXPORT void XGLAPI xglCmdDispatchIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1852 | { |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1853 | nextTable.CmdDispatchIndirect(cmdBuffer, buffer, offset); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1854 | } |
| 1855 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1856 | XGL_LAYER_EXPORT void XGLAPI xglCmdCopyBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER srcBuffer, XGL_BUFFER destBuffer, uint32_t regionCount, const XGL_BUFFER_COPY* pRegions) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1857 | { |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1858 | nextTable.CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1859 | } |
| 1860 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1861 | XGL_LAYER_EXPORT void XGLAPI xglCmdCopyImage(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_IMAGE destImage, uint32_t regionCount, const XGL_IMAGE_COPY* pRegions) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1862 | { |
| 1863 | nextTable.CmdCopyImage(cmdBuffer, srcImage, destImage, regionCount, pRegions); |
| 1864 | } |
| 1865 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1866 | XGL_LAYER_EXPORT void XGLAPI xglCmdCopyBufferToImage(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER srcBuffer, XGL_IMAGE destImage, uint32_t regionCount, const XGL_BUFFER_IMAGE_COPY* pRegions) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1867 | { |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1868 | nextTable.CmdCopyBufferToImage(cmdBuffer, srcBuffer, destImage, regionCount, pRegions); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1869 | } |
| 1870 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1871 | XGL_LAYER_EXPORT void XGLAPI xglCmdCopyImageToBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_BUFFER destBuffer, uint32_t regionCount, const XGL_BUFFER_IMAGE_COPY* pRegions) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1872 | { |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1873 | nextTable.CmdCopyImageToBuffer(cmdBuffer, srcImage, destBuffer, regionCount, pRegions); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1874 | } |
| 1875 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1876 | XGL_LAYER_EXPORT void XGLAPI xglCmdCloneImageData(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_IMAGE_LAYOUT srcImageLayout, XGL_IMAGE destImage, XGL_IMAGE_LAYOUT destImageLayout) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1877 | { |
Mike Stroyan | 55658c2 | 2014-12-04 11:08:39 +0000 | [diff] [blame] | 1878 | nextTable.CmdCloneImageData(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1879 | } |
| 1880 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1881 | XGL_LAYER_EXPORT void XGLAPI xglCmdUpdateBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER destBuffer, XGL_GPU_SIZE destOffset, XGL_GPU_SIZE dataSize, const uint32_t* pData) |
| 1882 | { |
| 1883 | nextTable.CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData); |
| 1884 | } |
| 1885 | |
| 1886 | XGL_LAYER_EXPORT void XGLAPI xglCmdFillBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER destBuffer, XGL_GPU_SIZE destOffset, XGL_GPU_SIZE fillSize, uint32_t data) |
| 1887 | { |
| 1888 | nextTable.CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data); |
| 1889 | } |
| 1890 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1891 | XGL_LAYER_EXPORT void XGLAPI xglCmdClearColorImage(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE image, const float color[4], uint32_t rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1892 | { |
| 1893 | nextTable.CmdClearColorImage(cmdBuffer, image, color, rangeCount, pRanges); |
| 1894 | } |
| 1895 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1896 | XGL_LAYER_EXPORT void XGLAPI xglCmdClearColorImageRaw(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE image, const uint32_t color[4], uint32_t rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1897 | { |
| 1898 | nextTable.CmdClearColorImageRaw(cmdBuffer, image, color, rangeCount, pRanges); |
| 1899 | } |
| 1900 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1901 | XGL_LAYER_EXPORT void XGLAPI xglCmdClearDepthStencil(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE image, float depth, uint32_t stencil, uint32_t rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1902 | { |
| 1903 | nextTable.CmdClearDepthStencil(cmdBuffer, image, depth, stencil, rangeCount, pRanges); |
| 1904 | } |
| 1905 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1906 | XGL_LAYER_EXPORT void XGLAPI xglCmdResolveImage(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_IMAGE destImage, uint32_t rectCount, const XGL_IMAGE_RESOLVE* pRects) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1907 | { |
| 1908 | nextTable.CmdResolveImage(cmdBuffer, srcImage, destImage, rectCount, pRects); |
| 1909 | } |
| 1910 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1911 | XGL_LAYER_EXPORT void XGLAPI xglCmdSetEvent(XGL_CMD_BUFFER cmdBuffer, XGL_EVENT event, XGL_SET_EVENT pipeEvent) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1912 | { |
Mike Stroyan | 55658c2 | 2014-12-04 11:08:39 +0000 | [diff] [blame] | 1913 | nextTable.CmdSetEvent(cmdBuffer, event, pipeEvent); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1914 | } |
| 1915 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1916 | XGL_LAYER_EXPORT void XGLAPI xglCmdResetEvent(XGL_CMD_BUFFER cmdBuffer, XGL_EVENT event) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1917 | { |
| 1918 | nextTable.CmdResetEvent(cmdBuffer, event); |
| 1919 | } |
| 1920 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1921 | XGL_LAYER_EXPORT void XGLAPI xglCmdWaitEvents(XGL_CMD_BUFFER cmdBuffer, const XGL_EVENT_WAIT_INFO* pWaitInfo) |
Mike Stroyan | 55658c2 | 2014-12-04 11:08:39 +0000 | [diff] [blame] | 1922 | { |
| 1923 | nextTable.CmdWaitEvents(cmdBuffer, pWaitInfo); |
| 1924 | } |
| 1925 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1926 | XGL_LAYER_EXPORT void XGLAPI xglCmdPipelineBarrier(XGL_CMD_BUFFER cmdBuffer, const XGL_PIPELINE_BARRIER* pBarrier) |
Mike Stroyan | 55658c2 | 2014-12-04 11:08:39 +0000 | [diff] [blame] | 1927 | { |
| 1928 | nextTable.CmdPipelineBarrier(cmdBuffer, pBarrier); |
| 1929 | } |
| 1930 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1931 | XGL_LAYER_EXPORT void XGLAPI xglCmdBeginQuery(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, uint32_t slot, XGL_FLAGS flags) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1932 | { |
| 1933 | nextTable.CmdBeginQuery(cmdBuffer, queryPool, slot, flags); |
| 1934 | } |
| 1935 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1936 | XGL_LAYER_EXPORT void XGLAPI xglCmdEndQuery(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, uint32_t slot) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1937 | { |
| 1938 | nextTable.CmdEndQuery(cmdBuffer, queryPool, slot); |
| 1939 | } |
| 1940 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1941 | XGL_LAYER_EXPORT void XGLAPI xglCmdResetQueryPool(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, uint32_t startQuery, uint32_t queryCount) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1942 | { |
| 1943 | nextTable.CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount); |
| 1944 | } |
| 1945 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1946 | XGL_LAYER_EXPORT void XGLAPI xglCmdWriteTimestamp(XGL_CMD_BUFFER cmdBuffer, XGL_TIMESTAMP_TYPE timestampType, XGL_BUFFER destBuffer, XGL_GPU_SIZE destOffset) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1947 | { |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1948 | nextTable.CmdWriteTimestamp(cmdBuffer, timestampType, destBuffer, destOffset); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1949 | } |
| 1950 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1951 | XGL_LAYER_EXPORT void XGLAPI xglCmdInitAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, const uint32_t* pData) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1952 | { |
| 1953 | nextTable.CmdInitAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData); |
| 1954 | } |
| 1955 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1956 | XGL_LAYER_EXPORT void XGLAPI xglCmdLoadAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, XGL_BUFFER srcBuffer, XGL_GPU_SIZE srcOffset) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1957 | { |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1958 | nextTable.CmdLoadAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, srcBuffer, srcOffset); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1959 | } |
| 1960 | |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1961 | XGL_LAYER_EXPORT void XGLAPI xglCmdSaveAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, XGL_BUFFER destBuffer, XGL_GPU_SIZE destOffset) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1962 | { |
Tobin Ehlis | 84c521c | 2015-01-19 08:42:29 -0700 | [diff] [blame^] | 1963 | nextTable.CmdSaveAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, destBuffer, destOffset); |
| 1964 | } |
| 1965 | |
| 1966 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateFramebuffer(XGL_DEVICE device, const XGL_FRAMEBUFFER_CREATE_INFO* pCreateInfo, XGL_FRAMEBUFFER* pFramebuffer) |
| 1967 | { |
| 1968 | XGL_RESULT result = nextTable.CreateFramebuffer(device, pCreateInfo, pFramebuffer); |
| 1969 | return result; |
| 1970 | } |
| 1971 | |
| 1972 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateRenderPass(XGL_DEVICE device, const XGL_RENDER_PASS_CREATE_INFO* pCreateInfo, XGL_RENDER_PASS* pRenderPass) |
| 1973 | { |
| 1974 | XGL_RESULT result = nextTable.CreateRenderPass(device, pCreateInfo, pRenderPass); |
| 1975 | return result; |
| 1976 | } |
| 1977 | |
| 1978 | XGL_LAYER_EXPORT void XGLAPI xglCmdBeginRenderPass(XGL_CMD_BUFFER cmdBuffer, XGL_RENDER_PASS renderPass) |
| 1979 | { |
| 1980 | nextTable.CmdBeginRenderPass(cmdBuffer, renderPass); |
| 1981 | } |
| 1982 | |
| 1983 | XGL_LAYER_EXPORT void XGLAPI xglCmdEndRenderPass(XGL_CMD_BUFFER cmdBuffer, XGL_RENDER_PASS renderPass) |
| 1984 | { |
| 1985 | nextTable.CmdEndRenderPass(cmdBuffer, renderPass); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1986 | } |
| 1987 | |
| 1988 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetValidationLevel(XGL_DEVICE device, XGL_VALIDATION_LEVEL validationLevel) |
| 1989 | { |
| 1990 | XGL_RESULT result = nextTable.DbgSetValidationLevel(device, validationLevel); |
| 1991 | return result; |
| 1992 | } |
| 1993 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1994 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgRegisterMsgCallback(XGL_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, void* pUserData) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 1995 | { |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 1996 | // This layer intercepts callbacks |
| 1997 | XGL_LAYER_DBG_FUNCTION_NODE *pNewDbgFuncNode = (XGL_LAYER_DBG_FUNCTION_NODE*)malloc(sizeof(XGL_LAYER_DBG_FUNCTION_NODE)); |
| 1998 | if (!pNewDbgFuncNode) |
| 1999 | return XGL_ERROR_OUT_OF_MEMORY; |
| 2000 | pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback; |
| 2001 | pNewDbgFuncNode->pUserData = pUserData; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 2002 | pNewDbgFuncNode->pNext = g_pDbgFunctionHead; |
| 2003 | g_pDbgFunctionHead = pNewDbgFuncNode; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2004 | XGL_RESULT result = nextTable.DbgRegisterMsgCallback(pfnMsgCallback, pUserData); |
| 2005 | return result; |
| 2006 | } |
| 2007 | |
| 2008 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgUnregisterMsgCallback(XGL_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback) |
| 2009 | { |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 2010 | XGL_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead; |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 2011 | XGL_LAYER_DBG_FUNCTION_NODE *pPrev = pTrav; |
| 2012 | while (pTrav) { |
| 2013 | if (pTrav->pfnMsgCallback == pfnMsgCallback) { |
| 2014 | pPrev->pNext = pTrav->pNext; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 2015 | if (g_pDbgFunctionHead == pTrav) |
| 2016 | g_pDbgFunctionHead = pTrav->pNext; |
Tobin Ehlis | e79df94 | 2014-11-18 16:38:08 -0700 | [diff] [blame] | 2017 | free(pTrav); |
| 2018 | break; |
| 2019 | } |
| 2020 | pPrev = pTrav; |
| 2021 | pTrav = pTrav->pNext; |
| 2022 | } |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2023 | XGL_RESULT result = nextTable.DbgUnregisterMsgCallback(pfnMsgCallback); |
| 2024 | return result; |
| 2025 | } |
| 2026 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 2027 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetMessageFilter(XGL_DEVICE device, int32_t msgCode, XGL_DBG_MSG_FILTER filter) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2028 | { |
| 2029 | XGL_RESULT result = nextTable.DbgSetMessageFilter(device, msgCode, filter); |
| 2030 | return result; |
| 2031 | } |
| 2032 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 2033 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetObjectTag(XGL_BASE_OBJECT object, size_t tagSize, const void* pTag) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2034 | { |
| 2035 | XGL_RESULT result = nextTable.DbgSetObjectTag(object, tagSize, pTag); |
| 2036 | return result; |
| 2037 | } |
| 2038 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 2039 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetGlobalOption(XGL_DBG_GLOBAL_OPTION dbgOption, size_t dataSize, const void* pData) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2040 | { |
| 2041 | XGL_RESULT result = nextTable.DbgSetGlobalOption(dbgOption, dataSize, pData); |
| 2042 | return result; |
| 2043 | } |
| 2044 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 2045 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetDeviceOption(XGL_DEVICE device, XGL_DBG_DEVICE_OPTION dbgOption, size_t dataSize, const void* pData) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2046 | { |
| 2047 | XGL_RESULT result = nextTable.DbgSetDeviceOption(device, dbgOption, dataSize, pData); |
| 2048 | return result; |
| 2049 | } |
| 2050 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 2051 | XGL_LAYER_EXPORT void XGLAPI xglCmdDbgMarkerBegin(XGL_CMD_BUFFER cmdBuffer, const char* pMarker) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2052 | { |
| 2053 | nextTable.CmdDbgMarkerBegin(cmdBuffer, pMarker); |
| 2054 | } |
| 2055 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 2056 | XGL_LAYER_EXPORT void XGLAPI xglCmdDbgMarkerEnd(XGL_CMD_BUFFER cmdBuffer) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2057 | { |
| 2058 | nextTable.CmdDbgMarkerEnd(cmdBuffer); |
| 2059 | } |
| 2060 | |
| 2061 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11AssociateConnection(XGL_PHYSICAL_GPU gpu, const XGL_WSI_X11_CONNECTION_INFO* pConnectionInfo) |
| 2062 | { |
| 2063 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2064 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 2065 | pthread_once(&g_initOnce, initDrawState); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2066 | XGL_RESULT result = nextTable.WsiX11AssociateConnection((XGL_PHYSICAL_GPU)gpuw->nextObject, pConnectionInfo); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2067 | return result; |
| 2068 | } |
| 2069 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 2070 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11GetMSC(XGL_DEVICE device, xcb_window_t window, xcb_randr_crtc_t crtc, uint64_t* pMsc) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2071 | { |
Chia-I Wu | 6204f34 | 2014-11-07 13:33:45 +0800 | [diff] [blame] | 2072 | XGL_RESULT result = nextTable.WsiX11GetMSC(device, window, crtc, pMsc); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2073 | return result; |
| 2074 | } |
| 2075 | |
| 2076 | 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) |
| 2077 | { |
| 2078 | XGL_RESULT result = nextTable.WsiX11CreatePresentableImage(device, pCreateInfo, pImage, pMem); |
| 2079 | return result; |
| 2080 | } |
| 2081 | |
| 2082 | XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11QueuePresent(XGL_QUEUE queue, const XGL_WSI_X11_PRESENT_INFO* pPresentInfo, XGL_FENCE fence) |
| 2083 | { |
| 2084 | XGL_RESULT result = nextTable.WsiX11QueuePresent(queue, pPresentInfo, fence); |
| 2085 | return result; |
| 2086 | } |
| 2087 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 2088 | void drawStateDumpDotFile(char* outFileName) |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 2089 | { |
| 2090 | dumpDotFile(outFileName); |
| 2091 | } |
| 2092 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 2093 | void drawStateDumpPngFile(char* outFileName) |
Tobin Ehlis | 266473d | 2014-12-16 17:34:50 -0700 | [diff] [blame] | 2094 | { |
| 2095 | char dotExe[32] = "/usr/bin/dot"; |
| 2096 | if( access(dotExe, X_OK) != -1) { |
| 2097 | dumpDotFile("/tmp/tmp.dot"); |
| 2098 | char dotCmd[1024]; |
| 2099 | sprintf(dotCmd, "%s /tmp/tmp.dot -Tpng -o %s", dotExe, outFileName); |
| 2100 | system(dotCmd); |
| 2101 | remove("/tmp/tmp.dot"); |
| 2102 | } |
| 2103 | else { |
| 2104 | char str[1024]; |
| 2105 | sprintf(str, "Cannot execute dot program at (%s) to dump requested %s file.", dotExe, outFileName); |
| 2106 | layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_MISSING_DOT_PROGRAM, "DS", str); |
| 2107 | } |
| 2108 | } |
| 2109 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 2110 | XGL_LAYER_EXPORT void* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char* funcName) |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2111 | { |
| 2112 | XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu; |
Chia-I Wu | 706533e | 2015-01-05 13:18:57 +0800 | [diff] [blame] | 2113 | void *addr; |
| 2114 | |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2115 | if (gpu == NULL) |
| 2116 | return NULL; |
| 2117 | pCurObj = gpuw; |
Jon Ashburn | 2e9b561 | 2014-12-22 13:38:27 -0700 | [diff] [blame] | 2118 | pthread_once(&g_initOnce, initDrawState); |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2119 | |
Chia-I Wu | 706533e | 2015-01-05 13:18:57 +0800 | [diff] [blame] | 2120 | addr = layer_intercept_proc(funcName); |
| 2121 | if (addr) |
| 2122 | return addr; |
Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 2123 | else if (!strncmp("drawStateDumpDotFile", funcName, sizeof("drawStateDumpDotFile"))) |
Tobin Ehlis | a701ef0 | 2014-11-27 15:43:39 -0700 | [diff] [blame] | 2124 | return drawStateDumpDotFile; |
Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 2125 | else if (!strncmp("drawStateDumpPngFile", funcName, sizeof("drawStateDumpPngFile"))) |
Tobin Ehlis | 266473d | 2014-12-16 17:34:50 -0700 | [diff] [blame] | 2126 | return drawStateDumpPngFile; |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2127 | else { |
Tobin Ehlis | 8726b9f | 2014-10-24 12:01:45 -0600 | [diff] [blame] | 2128 | if (gpuw->pGPA == NULL) |
| 2129 | return NULL; |
| 2130 | return gpuw->pGPA(gpuw->nextObject, funcName); |
| 2131 | } |
| 2132 | } |