blob: e603fe3c78b678004cbd1758aed22ed935f29602 [file] [log] [blame]
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001/*
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 Ehlis266473d2014-12-16 17:34:50 -070030#include <unistd.h>
Tobin Ehlisb8154982014-10-27 14:53:17 -060031#include "xgl_struct_string_helper.h"
Tobin Ehlisa701ef02014-11-27 15:43:39 -070032#include "xgl_struct_graphviz_helper.h"
Tobin Ehlise79df942014-11-18 16:38:08 -070033#include "draw_state.h"
Jon Ashburn2e9b5612014-12-22 13:38:27 -070034#include "layers_config.h"
Tobin Ehlis8726b9f2014-10-24 12:01:45 -060035
36static XGL_LAYER_DISPATCH_TABLE nextTable;
37static XGL_BASE_LAYER_OBJECT *pCurObj;
Jon Ashburn2e9b5612014-12-22 13:38:27 -070038static pthread_once_t g_initOnce = PTHREAD_ONCE_INIT;
Tobin Ehlis9e142a32014-11-21 12:04:39 -070039// Could be smarter about locking with unique locks for various tasks, but just using one for now
40pthread_mutex_t globalLock = PTHREAD_MUTEX_INITIALIZER;
Jon Ashburn2e9b5612014-12-22 13:38:27 -070041
Tobin Ehlise79df942014-11-18 16:38:08 -070042// Ptr to LL of dbg functions
Jon Ashburn2e9b5612014-12-22 13:38:27 -070043static XGL_LAYER_DBG_FUNCTION_NODE *g_pDbgFunctionHead = NULL;
44static XGL_LAYER_DBG_REPORT_LEVEL g_reportingLevel = XGL_DBG_LAYER_LEVEL_ERROR;
45static XGL_LAYER_DBG_ACTION g_debugAction = XGL_DBG_LAYER_ACTION_LOG_MSG;
46static FILE *g_logFile = NULL;
47
Tobin Ehlise79df942014-11-18 16:38:08 -070048// Utility function to handle reporting
49// If callbacks are enabled, use them, otherwise use printf
50static XGL_VOID layerCbMsg(XGL_DBG_MSG_TYPE msgType,
51 XGL_VALIDATION_LEVEL validationLevel,
52 XGL_BASE_OBJECT srcObject,
53 XGL_SIZE location,
54 XGL_INT msgCode,
Chia-I Wua837c522014-12-16 10:47:33 +080055 const char* pLayerPrefix,
56 const char* pMsg)
Tobin Ehlise79df942014-11-18 16:38:08 -070057{
Jon Ashburn2e9b5612014-12-22 13:38:27 -070058 if (g_debugAction & (XGL_DBG_LAYER_ACTION_LOG_MSG | XGL_DBG_LAYER_ACTION_CALLBACK)) {
59 XGL_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead;
Tobin Ehlise79df942014-11-18 16:38:08 -070060 switch (msgType) {
61 case XGL_DBG_MSG_ERROR:
Jon Ashburn2e9b5612014-12-22 13:38:27 -070062 if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_ERROR) {
63 if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG)
64 fprintf(g_logFile, "{%s}ERROR : %s\n", pLayerPrefix, pMsg);
65 if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK)
66 while (pTrav) {
67 pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData);
68 pTrav = pTrav->pNext;
69 }
70 }
Tobin Ehlise79df942014-11-18 16:38:08 -070071 break;
72 case XGL_DBG_MSG_WARNING:
Jon Ashburn2e9b5612014-12-22 13:38:27 -070073 if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_WARN) {
74 if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG)
75 fprintf(g_logFile, "{%s}WARN : %s\n", pLayerPrefix, pMsg);
76 if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK)
77 while (pTrav) {
78 pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData);
79 pTrav = pTrav->pNext;
80 }
81 }
Tobin Ehlise79df942014-11-18 16:38:08 -070082 break;
83 case XGL_DBG_MSG_PERF_WARNING:
Jon Ashburn2e9b5612014-12-22 13:38:27 -070084 if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_PERF_WARN) {
85 if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG)
86 fprintf(g_logFile, "{%s}PERF_WARN : %s\n", pLayerPrefix, pMsg);
87 if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK)
88 while (pTrav) {
89 pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData);
90 pTrav = pTrav->pNext;
91 }
92 }
Tobin Ehlise79df942014-11-18 16:38:08 -070093 break;
94 default:
Jon Ashburn2e9b5612014-12-22 13:38:27 -070095 if (g_reportingLevel <= XGL_DBG_LAYER_LEVEL_INFO) {
96 if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG)
97 fprintf(g_logFile, "{%s}INFO : %s\n", pLayerPrefix, pMsg);
98 if (g_debugAction & XGL_DBG_LAYER_ACTION_CALLBACK)
99 while (pTrav) {
100 pTrav->pfnMsgCallback(msgType, validationLevel, srcObject, location, msgCode, pMsg, pTrav->pUserData);
101 pTrav = pTrav->pNext;
102 }
103 }
Tobin Ehlise79df942014-11-18 16:38:08 -0700104 break;
105 }
106 }
107}
Tobin Ehlis26092022014-11-20 09:49:17 -0700108// Return the size of the underlying struct based on struct type
109static XGL_SIZE sTypeStructSize(XGL_STRUCTURE_TYPE sType)
110{
111 switch (sType)
112 {
113 case XGL_STRUCTURE_TYPE_APPLICATION_INFO:
114 return sizeof(XGL_APPLICATION_INFO);
115 case XGL_STRUCTURE_TYPE_DEVICE_CREATE_INFO:
116 return sizeof(XGL_DEVICE_CREATE_INFO);
117 case XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO:
118 return sizeof(XGL_MEMORY_ALLOC_INFO);
119 case XGL_STRUCTURE_TYPE_MEMORY_OPEN_INFO:
120 return sizeof(XGL_MEMORY_OPEN_INFO);
121 case XGL_STRUCTURE_TYPE_PEER_MEMORY_OPEN_INFO:
122 return sizeof(XGL_PEER_MEMORY_OPEN_INFO);
123 case XGL_STRUCTURE_TYPE_MEMORY_VIEW_ATTACH_INFO:
124 return sizeof(XGL_MEMORY_VIEW_ATTACH_INFO);
125 case XGL_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO:
126 return sizeof(XGL_IMAGE_VIEW_ATTACH_INFO);
127 case XGL_STRUCTURE_TYPE_MEMORY_STATE_TRANSITION:
128 return sizeof(XGL_MEMORY_STATE_TRANSITION);
129 case XGL_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO:
130 return sizeof(XGL_IMAGE_VIEW_CREATE_INFO);
131 case XGL_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO:
132 return sizeof(XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO);
133 case XGL_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO:
134 return sizeof(XGL_DEPTH_STENCIL_VIEW_CREATE_INFO);
135 case XGL_STRUCTURE_TYPE_SHADER_CREATE_INFO:
136 return sizeof(XGL_SHADER_CREATE_INFO);
137 case XGL_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO:
138 return sizeof(XGL_COMPUTE_PIPELINE_CREATE_INFO);
139 case XGL_STRUCTURE_TYPE_SAMPLER_CREATE_INFO:
140 return sizeof(XGL_SAMPLER_CREATE_INFO);
141 case XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_CREATE_INFO:
142 return sizeof(XGL_DESCRIPTOR_SET_CREATE_INFO);
143 case XGL_STRUCTURE_TYPE_RASTER_STATE_CREATE_INFO:
144 return sizeof(XGL_RASTER_STATE_CREATE_INFO);
145 case XGL_STRUCTURE_TYPE_MSAA_STATE_CREATE_INFO:
146 return sizeof(XGL_MSAA_STATE_CREATE_INFO);
147 case XGL_STRUCTURE_TYPE_COLOR_BLEND_STATE_CREATE_INFO:
148 return sizeof(XGL_COLOR_BLEND_STATE_CREATE_INFO);
149 case XGL_STRUCTURE_TYPE_DEPTH_STENCIL_STATE_CREATE_INFO:
150 return sizeof(XGL_DEPTH_STENCIL_STATE_CREATE_INFO);
151 case XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO:
152 return sizeof(XGL_CMD_BUFFER_CREATE_INFO);
153 case XGL_STRUCTURE_TYPE_EVENT_CREATE_INFO:
154 return sizeof(XGL_EVENT_CREATE_INFO);
155 case XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO:
156 return sizeof(XGL_FENCE_CREATE_INFO);
157 case XGL_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO:
158 return sizeof(XGL_QUEUE_SEMAPHORE_CREATE_INFO);
159 case XGL_STRUCTURE_TYPE_SEMAPHORE_OPEN_INFO:
160 return sizeof(XGL_QUEUE_SEMAPHORE_OPEN_INFO);
161 case XGL_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO:
162 return sizeof(XGL_QUERY_POOL_CREATE_INFO);
163 case XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO:
164 return sizeof(XGL_PIPELINE_SHADER_STAGE_CREATE_INFO);
165 case XGL_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO:
166 return sizeof(XGL_GRAPHICS_PIPELINE_CREATE_INFO);
167 case XGL_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO:
168 return sizeof(XGL_PIPELINE_IA_STATE_CREATE_INFO);
169 case XGL_STRUCTURE_TYPE_PIPELINE_DB_STATE_CREATE_INFO:
170 return sizeof(XGL_PIPELINE_DB_STATE_CREATE_INFO);
171 case XGL_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO:
172 return sizeof(XGL_PIPELINE_CB_STATE);
173 case XGL_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO:
174 return sizeof(XGL_PIPELINE_RS_STATE_CREATE_INFO);
175 case XGL_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO:
176 return sizeof(XGL_PIPELINE_TESS_STATE_CREATE_INFO);
177 case XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO:
178 return sizeof(XGL_IMAGE_CREATE_INFO);
179 case XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO:
180 return sizeof(XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO);
181 case XGL_STRUCTURE_TYPE_LAYER_CREATE_INFO:
182 return sizeof(XGL_LAYER_CREATE_INFO);
183 default:
184 return 0;
185 }
186}
Tobin Ehlis56a61072014-11-21 08:58:46 -0700187// Return the size of the underlying struct based on Bind Point enum
188// Have to do this b/c VIEWPORT doesn't have sType in its createinfo struct
Chia-I Wu84d7f5c2014-12-16 00:43:20 +0800189static XGL_SIZE dynStateCreateInfoSize(XGL_STATE_BIND_POINT sType)
Tobin Ehlis56a61072014-11-21 08:58:46 -0700190{
191 switch (sType)
192 {
193 case XGL_STATE_BIND_VIEWPORT:
194 return sizeof(XGL_VIEWPORT_STATE_CREATE_INFO);
195 case XGL_STATE_BIND_RASTER:
196 return sizeof(XGL_RASTER_STATE_CREATE_INFO);
197 case XGL_STATE_BIND_DEPTH_STENCIL:
198 return sizeof(XGL_DEPTH_STENCIL_STATE_CREATE_INFO);
199 case XGL_STATE_BIND_COLOR_BLEND:
200 return sizeof(XGL_COLOR_BLEND_STATE_CREATE_INFO);
201 case XGL_STATE_BIND_MSAA:
202 return sizeof(XGL_MSAA_STATE_CREATE_INFO);
203 default:
204 return 0;
205 }
206}
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600207// Block of code at start here for managing/tracking Pipeline state that this layer cares about
208// Just track 2 shaders for now
Tobin Ehlis26092022014-11-20 09:49:17 -0700209#define XGL_NUM_GRAPHICS_SHADERS XGL_SHADER_STAGE_COMPUTE
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600210#define MAX_SLOTS 2048
Tobin Ehlisb8154982014-10-27 14:53:17 -0600211
212static uint64_t drawCount[NUM_DRAW_TYPES] = {0, 0, 0, 0};
213
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600214typedef struct _SHADER_DS_MAPPING {
215 XGL_UINT slotCount;
216 XGL_DESCRIPTOR_SLOT_INFO* pShaderMappingSlot;
217} SHADER_DS_MAPPING;
218
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600219typedef struct _PIPELINE_LL_HEADER {
220 XGL_STRUCTURE_TYPE sType;
221 const XGL_VOID* pNext;
222} PIPELINE_LL_HEADER;
223
Tobin Ehlis26092022014-11-20 09:49:17 -0700224typedef struct _PIPELINE_NODE {
225 XGL_PIPELINE pipeline;
226 struct _PIPELINE_NODE *pNext;
Tobin Ehlis56a61072014-11-21 08:58:46 -0700227 XGL_GRAPHICS_PIPELINE_CREATE_INFO *pCreateTree; // Ptr to shadow of data in create tree
Tobin Ehlis26092022014-11-20 09:49:17 -0700228 // 1st dimension of array is shader type
229 SHADER_DS_MAPPING dsMapping[XGL_NUM_GRAPHICS_SHADERS][XGL_MAX_DESCRIPTOR_SETS];
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700230 // Vtx input info (if any)
231 XGL_UINT vtxBindingCount; // number of bindings
232 XGL_VERTEX_INPUT_BINDING_DESCRIPTION* pVertexBindingDescriptions;
233 XGL_UINT vtxAttributeCount; // number of attributes
234 XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION* pVertexAttributeDescriptions;
Tobin Ehlis26092022014-11-20 09:49:17 -0700235} PIPELINE_NODE;
236
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -0700237typedef struct _SAMPLER_NODE {
238 XGL_SAMPLER sampler;
239 XGL_SAMPLER_CREATE_INFO createInfo;
240 struct _SAMPLER_NODE *pNext;
241} SAMPLER_NODE;
242
Tobin Ehlis56a61072014-11-21 08:58:46 -0700243typedef struct _DYNAMIC_STATE_NODE {
244 XGL_STATE_OBJECT stateObj;
245 XGL_STATE_BIND_POINT sType; // Extra data as VIEWPORT CreateInfo doesn't have sType
246 PIPELINE_LL_HEADER *pCreateInfo;
247 struct _DYNAMIC_STATE_NODE *pNext;
248} DYNAMIC_STATE_NODE;
249
250// TODO : Should be tracking lastBound per cmdBuffer and when draws occur, report based on that cmd buffer lastBound
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700251// Then need to synchronize the accesses based on cmd buffer so that if I'm reading state on one cmd buffer, updates
252// to that same cmd buffer by separate thread are not changing state from underneath us
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600253static PIPELINE_NODE *pPipelineHead = NULL;
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -0700254static SAMPLER_NODE *pSamplerHead = NULL;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600255static XGL_PIPELINE lastBoundPipeline = NULL;
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700256#define MAX_BINDING 0xFFFFFFFF
257static XGL_UINT lastVtxBinding = MAX_BINDING;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600258
Tobin Ehlis56a61072014-11-21 08:58:46 -0700259static DYNAMIC_STATE_NODE* pDynamicStateHead[XGL_NUM_STATE_BIND_POINT] = {0};
260static DYNAMIC_STATE_NODE* pLastBoundDynamicState[XGL_NUM_STATE_BIND_POINT] = {0};
261
262// Viewport state create info doesn't have sType so we have to pass in BIND_POINT
263static void insertDynamicState(const XGL_STATE_OBJECT state, const PIPELINE_LL_HEADER* pCreateInfo, const XGL_STATE_BIND_POINT sType)
264{
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700265 pthread_mutex_lock(&globalLock);
Tobin Ehlis56a61072014-11-21 08:58:46 -0700266 // Insert new node at head of appropriate LL
267 DYNAMIC_STATE_NODE* pStateNode = (DYNAMIC_STATE_NODE*)malloc(sizeof(DYNAMIC_STATE_NODE));
268 pStateNode->pNext = pDynamicStateHead[sType];
269 pDynamicStateHead[sType] = pStateNode;
270 pStateNode->stateObj = state;
271 pStateNode->sType = sType;
272 pStateNode->pCreateInfo = (PIPELINE_LL_HEADER*)malloc(dynStateCreateInfoSize(sType));
273 memcpy(pStateNode->pCreateInfo, pCreateInfo, dynStateCreateInfoSize(sType));
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700274 pthread_mutex_unlock(&globalLock);
Tobin Ehlis56a61072014-11-21 08:58:46 -0700275}
276// Set the last bound dynamic state of given type
277// TODO : Need to track this per cmdBuffer and correlate cmdBuffer for Draw w/ last bound for that cmdBuffer?
278static void setLastBoundDynamicState(const XGL_STATE_OBJECT state, const XGL_STATE_BIND_POINT sType)
279{
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700280 pthread_mutex_lock(&globalLock);
Tobin Ehlis56a61072014-11-21 08:58:46 -0700281 DYNAMIC_STATE_NODE* pTrav = pDynamicStateHead[sType];
282 while (pTrav && (state != pTrav->stateObj)) {
283 pTrav = pTrav->pNext;
284 }
285 if (!pTrav) {
286 char str[1024];
287 sprintf(str, "Unable to find dynamic state object %p, was it ever created?", (void*)state);
288 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, state, 0, DRAWSTATE_INVALID_DYNAMIC_STATE_OBJECT, "DS", str);
289 }
290 pLastBoundDynamicState[sType] = pTrav;
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700291 pthread_mutex_unlock(&globalLock);
Tobin Ehlis56a61072014-11-21 08:58:46 -0700292}
293// Print the last bound dynamic state
294static void printDynamicState()
295{
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700296 pthread_mutex_lock(&globalLock);
Tobin Ehlis56a61072014-11-21 08:58:46 -0700297 char str[1024];
298 for (uint32_t i = 0; i < XGL_NUM_STATE_BIND_POINT; i++) {
299 if (pLastBoundDynamicState[i]) {
300 sprintf(str, "Reporting CreateInfo for currently bound %s object %p", string_XGL_STATE_BIND_POINT(i), pLastBoundDynamicState[i]->stateObj);
301 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pLastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", str);
302 switch (pLastBoundDynamicState[i]->sType)
303 {
304 case XGL_STATE_BIND_VIEWPORT:
305 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pLastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", xgl_print_xgl_viewport_state_create_info((XGL_VIEWPORT_STATE_CREATE_INFO*)pLastBoundDynamicState[i]->pCreateInfo, " "));
306 break;
307 default:
308 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pLastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", dynamic_display(pLastBoundDynamicState[i]->pCreateInfo, " "));
309 break;
310 }
311 }
312 else {
313 sprintf(str, "No dynamic state of type %s bound", string_XGL_STATE_BIND_POINT(i));
314 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", str);
315 }
316 }
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700317 pthread_mutex_unlock(&globalLock);
Tobin Ehlis56a61072014-11-21 08:58:46 -0700318}
319// Retrieve pipeline node ptr for given pipeline object
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600320static PIPELINE_NODE *getPipeline(XGL_PIPELINE pipeline)
321{
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700322 pthread_mutex_lock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600323 PIPELINE_NODE *pTrav = pPipelineHead;
324 while (pTrav) {
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700325 if (pTrav->pipeline == pipeline) {
326 pthread_mutex_unlock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600327 return pTrav;
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700328 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600329 pTrav = pTrav->pNext;
330 }
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700331 pthread_mutex_unlock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600332 return NULL;
333}
334
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -0700335// For given sampler, return a ptr to its Create Info struct, or NULL if sampler not found
336static XGL_SAMPLER_CREATE_INFO* getSamplerCreateInfo(const XGL_SAMPLER sampler)
337{
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700338 pthread_mutex_lock(&globalLock);
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -0700339 SAMPLER_NODE *pTrav = pSamplerHead;
340 while (pTrav) {
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700341 if (sampler == pTrav->sampler) {
342 pthread_mutex_unlock(&globalLock);
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -0700343 return &pTrav->createInfo;
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700344 }
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -0700345 pTrav = pTrav->pNext;
346 }
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700347 pthread_mutex_unlock(&globalLock);
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -0700348 return NULL;
349}
350
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600351// Init the pipeline mapping info based on pipeline create info LL tree
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700352// Threading note : Calls to this function should wrapped in mutex
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600353static void initPipeline(PIPELINE_NODE *pPipeline, const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo)
354{
Tobin Ehlis26092022014-11-20 09:49:17 -0700355 // First init create info, we'll shadow the structs as we go down the tree
Tobin Ehlis56a61072014-11-21 08:58:46 -0700356 pPipeline->pCreateTree = (XGL_GRAPHICS_PIPELINE_CREATE_INFO*)malloc(sizeof(XGL_GRAPHICS_PIPELINE_CREATE_INFO));
Tobin Ehlis26092022014-11-20 09:49:17 -0700357 memcpy(pPipeline->pCreateTree, pCreateInfo, sizeof(XGL_GRAPHICS_PIPELINE_CREATE_INFO));
Tobin Ehlis56a61072014-11-21 08:58:46 -0700358 PIPELINE_LL_HEADER *pShadowTrav = (PIPELINE_LL_HEADER*)pPipeline->pCreateTree;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600359 PIPELINE_LL_HEADER *pTrav = (PIPELINE_LL_HEADER*)pCreateInfo->pNext;
360 while (pTrav) {
Tobin Ehlis26092022014-11-20 09:49:17 -0700361 // Shadow the struct
362 pShadowTrav->pNext = (PIPELINE_LL_HEADER*)malloc(sTypeStructSize(pTrav->sType));
363 // Typically pNext is const so have to cast to avoid warning when we modify it here
364 memcpy((void*)pShadowTrav->pNext, pTrav, sTypeStructSize(pTrav->sType));
365 pShadowTrav = (PIPELINE_LL_HEADER*)pShadowTrav->pNext;
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700366 // For deep copy DS Mapping into shadow
367 XGL_PIPELINE_SHADER_STAGE_CREATE_INFO *pShadowShaderCI = (XGL_PIPELINE_SHADER_STAGE_CREATE_INFO*)pShadowTrav;
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700368 // 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 Ehlis26092022014-11-20 09:49:17 -0700369 // Special copy of DS Mapping info
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600370 if (XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO == pTrav->sType) {
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700371 XGL_PIPELINE_SHADER_STAGE_CREATE_INFO *pSSCI = (XGL_PIPELINE_SHADER_STAGE_CREATE_INFO*)pTrav;
Tobin Ehlis26092022014-11-20 09:49:17 -0700372 for (uint32_t i = 0; i < XGL_MAX_DESCRIPTOR_SETS; i++) {
373 if (pSSCI->shader.descriptorSetMapping[i].descriptorCount > MAX_SLOTS) {
374 char str[1024];
375 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);
376 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pPipeline, 0, DRAWSTATE_DESCRIPTOR_MAX_EXCEEDED, "DS", str);
377 pSSCI->shader.descriptorSetMapping[i].descriptorCount = 0;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600378 }
Tobin Ehlis26092022014-11-20 09:49:17 -0700379 pPipeline->dsMapping[pSSCI->shader.stage][i].slotCount = pSSCI->shader.descriptorSetMapping[i].descriptorCount;
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700380 // Deep copy DS Slot array into our shortcut data structure
Tobin Ehlis26092022014-11-20 09:49:17 -0700381 pPipeline->dsMapping[pSSCI->shader.stage][i].pShaderMappingSlot = (XGL_DESCRIPTOR_SLOT_INFO*)malloc(sizeof(XGL_DESCRIPTOR_SLOT_INFO)*pPipeline->dsMapping[pSSCI->shader.stage][i].slotCount);
382 memcpy(pPipeline->dsMapping[pSSCI->shader.stage][i].pShaderMappingSlot, pSSCI->shader.descriptorSetMapping[i].pDescriptorInfo, sizeof(XGL_DESCRIPTOR_SLOT_INFO)*pPipeline->dsMapping[pSSCI->shader.stage][i].slotCount);
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700383 // Deep copy into shadow tree
384 pShadowShaderCI->shader.descriptorSetMapping[i].descriptorCount = pSSCI->shader.descriptorSetMapping[i].descriptorCount;
385 pShadowShaderCI->shader.descriptorSetMapping[i].pDescriptorInfo = (XGL_DESCRIPTOR_SLOT_INFO*)malloc(sizeof(XGL_DESCRIPTOR_SLOT_INFO)*pShadowShaderCI->shader.descriptorSetMapping[i].descriptorCount);
386 memcpy((XGL_DESCRIPTOR_SLOT_INFO*)pShadowShaderCI->shader.descriptorSetMapping[i].pDescriptorInfo, pSSCI->shader.descriptorSetMapping[i].pDescriptorInfo, sizeof(XGL_DESCRIPTOR_SLOT_INFO)*pShadowShaderCI->shader.descriptorSetMapping[i].descriptorCount);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600387 }
388 }
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700389 else if (XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO == pTrav->sType) {
390 // Special copy of Vtx info
391 XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO *pVICI = (XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO*)pTrav;
392 pPipeline->vtxBindingCount = pVICI->bindingCount;
393 uint32_t allocSize = pPipeline->vtxBindingCount * sizeof(XGL_VERTEX_INPUT_BINDING_DESCRIPTION);
394 pPipeline->pVertexBindingDescriptions = (XGL_VERTEX_INPUT_BINDING_DESCRIPTION*)malloc(allocSize);
395 memcpy(pPipeline->pVertexBindingDescriptions, pVICI->pVertexAttributeDescriptions, allocSize);
396 pPipeline->vtxAttributeCount = pVICI->attributeCount;
397 allocSize = pPipeline->vtxAttributeCount * sizeof(XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION);
398 pPipeline->pVertexAttributeDescriptions = (XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION*)malloc(allocSize);
399 memcpy(pPipeline->pVertexAttributeDescriptions, pVICI->pVertexAttributeDescriptions, allocSize);
400 }
Tobin Ehlisb8154982014-10-27 14:53:17 -0600401 pTrav = (PIPELINE_LL_HEADER*)pTrav->pNext;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600402 }
403}
404
405// Block of code at start here specifically for managing/tracking DSs
406#define MAPPING_MEMORY 0x00000001
407#define MAPPING_IMAGE 0x00000002
408#define MAPPING_SAMPLER 0x00000004
409#define MAPPING_DS 0x00000008
410
Tobin Ehlis9e3d7532014-10-27 17:12:54 -0600411static char* stringSlotBinding(XGL_UINT binding)
412{
413 switch (binding)
414 {
415 case MAPPING_MEMORY:
416 return "Memory View";
417 case MAPPING_IMAGE:
418 return "Image View";
419 case MAPPING_SAMPLER:
420 return "Sampler";
421 default:
422 return "UNKNOWN DS BINDING";
423 }
424}
425
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600426typedef struct _DS_SLOT {
427 XGL_UINT slot;
Tobin Ehlis26092022014-11-20 09:49:17 -0700428 XGL_DESCRIPTOR_SLOT_INFO shaderSlotInfo[XGL_NUM_GRAPHICS_SHADERS];
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600429 // Only 1 of 4 possible slot mappings active
430 XGL_UINT activeMapping;
431 XGL_UINT mappingMask; // store record of different mappings used
432 XGL_MEMORY_VIEW_ATTACH_INFO memView;
433 XGL_IMAGE_VIEW_ATTACH_INFO imageView;
434 XGL_SAMPLER sampler;
435} DS_SLOT;
436
437// Top-level node that points to start of DS
438typedef struct _DS_LL_HEAD {
439 XGL_DESCRIPTOR_SET dsID;
440 XGL_UINT numSlots;
441 struct _DS_LL_HEAD *pNextDS;
442 DS_SLOT *dsSlot; // Dynamically allocated array of DS_SLOTs
443 XGL_BOOL updateActive; // Track if DS is in an update block
444} DS_LL_HEAD;
445
446// ptr to HEAD of LL of DSs
447static DS_LL_HEAD *pDSHead = NULL;
Tobin Ehliseacc64f2014-11-24 17:09:09 -0700448// Last DS that was bound, and slotOffset for the binding
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600449static XGL_DESCRIPTOR_SET lastBoundDS[XGL_MAX_DESCRIPTOR_SETS] = {NULL, NULL};
Tobin Ehliseacc64f2014-11-24 17:09:09 -0700450static XGL_UINT lastBoundSlotOffset[XGL_MAX_DESCRIPTOR_SETS] = {0, 0};
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600451
452// Return DS Head ptr for specified ds or else NULL
453static DS_LL_HEAD* getDS(XGL_DESCRIPTOR_SET ds)
454{
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700455 pthread_mutex_lock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600456 DS_LL_HEAD *pTrav = pDSHead;
457 while (pTrav) {
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700458 if (pTrav->dsID == ds) {
459 pthread_mutex_unlock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600460 return pTrav;
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700461 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600462 pTrav = pTrav->pNextDS;
463 }
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700464 pthread_mutex_unlock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600465 return NULL;
466}
467
468// Initialize a DS where all slots are UNUSED for all shaders
469static void initDS(DS_LL_HEAD *pDS)
470{
471 for (uint32_t i = 0; i < pDS->numSlots; i++) {
472 memset((void*)&pDS->dsSlot[i], 0, sizeof(DS_SLOT));
473 pDS->dsSlot[i].slot = i;
474 }
475}
476
477// Return XGL_TRUE if DS Exists and is within an xglBeginDescriptorSetUpdate() call sequence, otherwise XGL_FALSE
478static XGL_BOOL dsUpdate(XGL_DESCRIPTOR_SET ds)
479{
480 DS_LL_HEAD *pTrav = getDS(ds);
481 if (pTrav)
482 return pTrav->updateActive;
483 return XGL_FALSE;
484}
485
486// Clear specified slotCount DS Slots starting at startSlot
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700487// Return XGL_TRUE if DS exists and is successfully cleared to 0s
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600488static XGL_BOOL clearDS(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount)
489{
490 DS_LL_HEAD *pTrav = getDS(descriptorSet);
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700491 pthread_mutex_lock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600492 if (!pTrav || ((startSlot + slotCount) > pTrav->numSlots)) {
493 // TODO : Log more meaningful error here
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700494 pthread_mutex_unlock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600495 return XGL_FALSE;
496 }
497 for (uint32_t i = startSlot; i < slotCount; i++) {
498 memset((void*)&pTrav->dsSlot[i], 0, sizeof(DS_SLOT));
499 }
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700500 pthread_mutex_unlock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600501 return XGL_TRUE;
502}
503
504static void dsSetMapping(DS_SLOT* pSlot, XGL_UINT mapping)
505{
506 pSlot->mappingMask |= mapping;
Tobin Ehlis0f051a52014-10-24 13:03:56 -0600507 pSlot->activeMapping = mapping;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600508}
Tobin Ehlise79df942014-11-18 16:38:08 -0700509// Populate pStr w/ a string noting all of the slot mappings based on mapping flag
510static char* noteSlotMapping(XGL_UINT32 mapping, char *pStr)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600511{
512 if (MAPPING_MEMORY & mapping)
Tobin Ehlise79df942014-11-18 16:38:08 -0700513 strcat(pStr, "\n\tMemory View previously mapped");
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600514 if (MAPPING_IMAGE & mapping)
Tobin Ehlise79df942014-11-18 16:38:08 -0700515 strcat(pStr, "\n\tImage View previously mapped");
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600516 if (MAPPING_SAMPLER & mapping)
Tobin Ehlise79df942014-11-18 16:38:08 -0700517 strcat(pStr, "\n\tSampler previously mapped");
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600518 if (MAPPING_DS & mapping)
Tobin Ehlise79df942014-11-18 16:38:08 -0700519 strcat(pStr, "\n\tDESCRIPTOR SET ptr previously mapped");
520 return pStr;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600521}
522
Tobin Ehlise79df942014-11-18 16:38:08 -0700523static void dsSetMemMapping(XGL_DESCRIPTOR_SET descriptorSet, DS_SLOT* pSlot, const XGL_MEMORY_VIEW_ATTACH_INFO* pMemView)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600524{
525 if (pSlot->mappingMask) {
Tobin Ehlise79df942014-11-18 16:38:08 -0700526 char str[1024];
527 char map_str[1024] = {0};
528 sprintf(str, "While mapping Memory View to slot %u previous Mapping(s) identified:%s", pSlot->slot, noteSlotMapping(pSlot->mappingMask, map_str));
529 layerCbMsg(XGL_DBG_MSG_WARNING, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_SLOT_REMAPPING, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600530 }
531 memcpy(&pSlot->memView, pMemView, sizeof(XGL_MEMORY_VIEW_ATTACH_INFO));
532 dsSetMapping(pSlot, MAPPING_MEMORY);
533}
534
535static XGL_BOOL dsMemMapping(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_MEMORY_VIEW_ATTACH_INFO* pMemViews)
536{
537 DS_LL_HEAD *pTrav = getDS(descriptorSet);
538 if (pTrav) {
539 if (pTrav->numSlots < (startSlot + slotCount)) {
540 return XGL_FALSE;
541 }
542 for (uint32_t i = 0; i < slotCount; i++) {
Tobin Ehlise79df942014-11-18 16:38:08 -0700543 dsSetMemMapping(descriptorSet, &pTrav->dsSlot[i+startSlot], &pMemViews[i]);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600544 }
545 }
Tobin Ehlis0f051a52014-10-24 13:03:56 -0600546 else
547 return XGL_FALSE;
548 return XGL_TRUE;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600549}
550
Tobin Ehlise79df942014-11-18 16:38:08 -0700551static void dsSetImageMapping(XGL_DESCRIPTOR_SET descriptorSet, DS_SLOT* pSlot, const XGL_IMAGE_VIEW_ATTACH_INFO* pImageViews)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600552{
553 if (pSlot->mappingMask) {
Tobin Ehlise79df942014-11-18 16:38:08 -0700554 char str[1024];
555 char map_str[1024] = {0};
556 sprintf(str, "While mapping Image View to slot %u previous Mapping(s) identified:%s", pSlot->slot, noteSlotMapping(pSlot->mappingMask, map_str));
557 layerCbMsg(XGL_DBG_MSG_WARNING, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_SLOT_REMAPPING, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600558 }
559 memcpy(&pSlot->imageView, pImageViews, sizeof(XGL_IMAGE_VIEW_ATTACH_INFO));
560 dsSetMapping(pSlot, MAPPING_IMAGE);
561}
562
563static XGL_BOOL dsImageMapping(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_IMAGE_VIEW_ATTACH_INFO* pImageViews)
564{
565 DS_LL_HEAD *pTrav = getDS(descriptorSet);
566 if (pTrav) {
567 if (pTrav->numSlots < (startSlot + slotCount)) {
568 return XGL_FALSE;
569 }
570 for (uint32_t i = 0; i < slotCount; i++) {
Tobin Ehlise79df942014-11-18 16:38:08 -0700571 dsSetImageMapping(descriptorSet, &pTrav->dsSlot[i+startSlot], &pImageViews[i]);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600572 }
573 }
Tobin Ehlis0f051a52014-10-24 13:03:56 -0600574 else
575 return XGL_FALSE;
576 return XGL_TRUE;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600577}
578
Tobin Ehlise79df942014-11-18 16:38:08 -0700579static void dsSetSamplerMapping(XGL_DESCRIPTOR_SET descriptorSet, DS_SLOT* pSlot, const XGL_SAMPLER sampler)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600580{
581 if (pSlot->mappingMask) {
Tobin Ehlise79df942014-11-18 16:38:08 -0700582 char str[1024];
583 char map_str[1024] = {0};
584 sprintf(str, "While mapping Sampler to slot %u previous Mapping(s) identified:%s", pSlot->slot, noteSlotMapping(pSlot->mappingMask, map_str));
585 layerCbMsg(XGL_DBG_MSG_WARNING, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_SLOT_REMAPPING, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600586 }
587 pSlot->sampler = sampler;
588 dsSetMapping(pSlot, MAPPING_SAMPLER);
589}
590
591static XGL_BOOL dsSamplerMapping(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_SAMPLER* pSamplers)
592{
593 DS_LL_HEAD *pTrav = getDS(descriptorSet);
594 if (pTrav) {
595 if (pTrav->numSlots < (startSlot + slotCount)) {
596 return XGL_FALSE;
597 }
598 for (uint32_t i = 0; i < slotCount; i++) {
Tobin Ehlise79df942014-11-18 16:38:08 -0700599 dsSetSamplerMapping(descriptorSet, &pTrav->dsSlot[i+startSlot], pSamplers[i]);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600600 }
601 }
Tobin Ehlis0f051a52014-10-24 13:03:56 -0600602 else
603 return XGL_FALSE;
604 return XGL_TRUE;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600605}
Tobin Ehlis56a61072014-11-21 08:58:46 -0700606// Print the last bound Gfx Pipeline
607static void printPipeline()
608{
609 PIPELINE_NODE *pPipeTrav = getPipeline(lastBoundPipeline);
610 if (!pPipeTrav) {
611 // nothing to print
612 }
613 else {
614 char* pipeStr = xgl_print_xgl_graphics_pipeline_create_info(pPipeTrav->pCreateTree, "{DS}");
615 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", pipeStr);
616 }
617}
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700618// Dump subgraph w/ DS info
619static void dsDumpDot(FILE* pOutFile)
620{
621 const int i = 0; // hard-coding to just the first DS index for now
622 uint32_t skipUnusedCount = 0; // track consecutive unused slots for minimal reporting
623 DS_LL_HEAD *pDS = getDS(lastBoundDS[i]);
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700624 if (pDS) {
625 fprintf(pOutFile, "subgraph DS_SLOTS\n{\nlabel=\"DS0 Slots\"\n");
626 // First create simple array node as central DS reference point
627 fprintf(pOutFile, "\"DS0_MEMORY\" [\nlabel = <<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"> <TR><TD PORT=\"ds2\">DS0 Memory</TD></TR>");
628 uint32_t j;
629 char label[1024];
630 for (j = 0; j < pDS->numSlots; j++) {
Tobin Ehlisf1c468a2014-12-09 17:00:33 -0700631 // Don't draw unused slots
632 if (0 != pDS->dsSlot[j].activeMapping)
633 fprintf(pOutFile, "<TR><TD PORT=\"slot%u\">slot%u</TD></TR>", j, j);
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700634 }
635 fprintf(pOutFile, "</TABLE>>\n];\n");
636 // Now tie each slot to its info
637 for (j = 0; j < pDS->numSlots; j++) {
638 switch (pDS->dsSlot[j].activeMapping)
639 {
640 case MAPPING_MEMORY:
641 /*
642 if (0 != skipUnusedCount) {// finish sequence of unused slots
643 sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : "");
644 strcat(ds_config_str, tmp_str);
645 skipUnusedCount = 0;
646 }*/
647 sprintf(label, "MemAttachInfo Slot%u", j);
648 fprintf(pOutFile, "%s", xgl_gv_print_xgl_memory_view_attach_info(&pDS->dsSlot[j].memView, label));
649 fprintf(pOutFile, "\"DS0_MEMORY\":slot%u -> \"%s\" [];\n", j, label);
650 break;
651 case MAPPING_IMAGE:
652 /*if (0 != skipUnusedCount) {// finish sequence of unused slots
653 sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : "");
654 strcat(ds_config_str, tmp_str);
655 skipUnusedCount = 0;
656 }*/
657 sprintf(label, "ImageAttachInfo Slot%u", j);
658 fprintf(pOutFile, "%s", xgl_gv_print_xgl_image_view_attach_info(&pDS->dsSlot[j].imageView, label));
659 fprintf(pOutFile, "\"DS0_MEMORY\":slot%u -> \"%s\" [];\n", j, label);
660 break;
661 case MAPPING_SAMPLER:
662 /*if (0 != skipUnusedCount) {// finish sequence of unused slots
663 sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : "");
664 strcat(ds_config_str, tmp_str);
665 skipUnusedCount = 0;
666 }*/
667 sprintf(label, "ImageAttachInfo Slot%u", j);
668 fprintf(pOutFile, "%s", xgl_gv_print_xgl_sampler_create_info(getSamplerCreateInfo(pDS->dsSlot[j].sampler), label));
669 fprintf(pOutFile, "\"DS0_MEMORY\":slot%u -> \"%s\" [];\n", j, label);
670 break;
671 default:
672 /*if (!skipUnusedCount) {// only report start of unused sequences
673 sprintf(tmp_str, "----Skipping slot(s) w/o a view attached...\n");
674 strcat(ds_config_str, tmp_str);
675 }*/
676 skipUnusedCount++;
677 break;
678 }
679
680 }
681 /*if (0 != skipUnusedCount) {// finish sequence of unused slots
682 sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : "");
683 strcat(ds_config_str, tmp_str);
684 skipUnusedCount = 0;
685 }*/
686 fprintf(pOutFile, "}\n");
687 }
688}
689// Dump a GraphViz dot file showing the pipeline
690static void dumpDotFile(char *outFileName)
691{
692 PIPELINE_NODE *pPipeTrav = getPipeline(lastBoundPipeline);
693 if (pPipeTrav) {
694 FILE* pOutFile;
695 pOutFile = fopen(outFileName, "w");
696 fprintf(pOutFile, "digraph g {\ngraph [\nrankdir = \"TB\"\n];\nnode [\nfontsize = \"16\"\nshape = \"plaintext\"\n];\nedge [\n];\n");
697 fprintf(pOutFile, "subgraph PipelineStateObject\n{\nlabel=\"Pipeline State Object\"\n");
698 fprintf(pOutFile, "%s", xgl_gv_print_xgl_graphics_pipeline_create_info(pPipeTrav->pCreateTree, "PSO HEAD"));
699 fprintf(pOutFile, "}\n");
700 // TODO : Add dynamic state dump here
701 fprintf(pOutFile, "subgraph dynamicState\n{\nlabel=\"Non-Orthogonal XGL State\"\n");
702 for (uint32_t i = 0; i < XGL_NUM_STATE_BIND_POINT; i++) {
703 if (pLastBoundDynamicState[i]) {
704 switch (pLastBoundDynamicState[i]->sType)
705 {
706 case XGL_STATE_BIND_VIEWPORT:
707 fprintf(pOutFile, "%s", xgl_gv_print_xgl_viewport_state_create_info((XGL_VIEWPORT_STATE_CREATE_INFO*)pLastBoundDynamicState[i]->pCreateInfo, "VIEWPORT State"));
708 break;
709 default:
710 fprintf(pOutFile, "%s", dynamic_gv_display(pLastBoundDynamicState[i]->pCreateInfo, string_XGL_STATE_BIND_POINT(pLastBoundDynamicState[i]->sType)));
711 break;
712 }
713 }
714 }
715 fprintf(pOutFile, "}\n"); // close dynamicState subgraph
716 dsDumpDot(pOutFile);
717 fprintf(pOutFile, "}\n"); // close main graph "g"
718 fclose(pOutFile);
719 }
720}
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600721// Synch up currently bound pipeline settings with DS mappings
722static void synchDSMapping()
723{
724 // First verify that we have a bound pipeline
725 PIPELINE_NODE *pPipeTrav = getPipeline(lastBoundPipeline);
Tobin Ehlise79df942014-11-18 16:38:08 -0700726 char str[1024];
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600727 if (!pPipeTrav) {
Tobin Ehlise79df942014-11-18 16:38:08 -0700728 sprintf(str, "Can't find last bound Pipeline %p!", (void*)lastBoundPipeline);
729 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NO_PIPELINE_BOUND, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600730 }
731 else {
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700732 // Synch Descriptor Set Mapping
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600733 for (uint32_t i = 0; i < XGL_MAX_DESCRIPTOR_SETS; i++) {
Tobin Ehlis0f051a52014-10-24 13:03:56 -0600734 DS_LL_HEAD *pDS;
735 if (lastBoundDS[i]) {
736 pDS = getDS(lastBoundDS[i]);
737 if (!pDS) {
Tobin Ehlise79df942014-11-18 16:38:08 -0700738 sprintf(str, "Can't find last bound DS %p. Did you need to bind DS to index %u?", (void*)lastBoundDS[i], i);
739 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NO_DS_BOUND, "DS", str);
Tobin Ehlis0f051a52014-10-24 13:03:56 -0600740 }
741 else { // We have a good DS & Pipeline, store pipeline mappings in DS
Tobin Ehliseacc64f2014-11-24 17:09:09 -0700742 XGL_UINT slotOffset = lastBoundSlotOffset[i];
Tobin Ehlis26092022014-11-20 09:49:17 -0700743 for (uint32_t j = 0; j < XGL_NUM_GRAPHICS_SHADERS; j++) { // j is shader selector
Tobin Ehliseacc64f2014-11-24 17:09:09 -0700744 if (pPipeTrav->dsMapping[j][i].slotCount > (pDS->numSlots - slotOffset)) {
745 sprintf(str, "DS Mapping for shader %u has more slots (%u) than DS %p (%u) minus slotOffset (%u) (%u slots available)!", j, pPipeTrav->dsMapping[j][i].slotCount, (void*)pDS->dsID, pDS->numSlots, slotOffset, (pDS->numSlots - slotOffset));
Tobin Ehlis21042792014-11-24 16:06:04 -0700746 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_DS_SLOT_NUM_MISMATCH, "DS", str);
747 }
748 else {
749 for (uint32_t r = 0; r < pPipeTrav->dsMapping[j][i].slotCount; r++) {
Tobin Ehliseacc64f2014-11-24 17:09:09 -0700750 pDS->dsSlot[r+slotOffset].shaderSlotInfo[j] = pPipeTrav->dsMapping[j][i].pShaderMappingSlot[r];
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600751 }
752 }
753 }
754 }
755 }
Tobin Ehlis0f051a52014-10-24 13:03:56 -0600756 else {
Tobin Ehlis21042792014-11-24 16:06:04 -0700757 // Verify that no shader is mapping this DS
758 uint32_t dsUsed = 0;
759 for (uint32_t j = 0; j < XGL_NUM_GRAPHICS_SHADERS; j++) { // j is shader selector
760 if (pPipeTrav->dsMapping[j][i].slotCount > 0) {
761 dsUsed = 1;
762 sprintf(str, "No DS was bound to index %u, but shader type %s has slots bound to that DS.", i, string_XGL_PIPELINE_SHADER_STAGE(j));
763 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NO_DS_BOUND, "DS", str);
764 }
765 }
766 if (0 == dsUsed) {
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700767 sprintf(str, "No DS was bound to index %u, but no shaders are using that DS so this is not an issue.", i);
Tobin Ehlis21042792014-11-24 16:06:04 -0700768 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", str);
769 }
Tobin Ehlis0f051a52014-10-24 13:03:56 -0600770 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600771 }
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700772 // Verify Vtx binding
773 if (MAX_BINDING != lastVtxBinding) {
774 if (lastVtxBinding >= pPipeTrav->vtxBindingCount) {
775 sprintf(str, "Vtx binding Index of %u exceeds PSO pVertexBindingDescriptions max array index of %u.", lastVtxBinding, (pPipeTrav->vtxBindingCount - 1));
776 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", str);
777 }
778 else {
779 char *tmpStr = xgl_print_xgl_vertex_input_binding_description(&pPipeTrav->pVertexBindingDescriptions[lastVtxBinding], "{DS}INFO : ");
780 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmpStr);
781 free(tmpStr);
782 }
783 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600784 }
785}
786
Tobin Ehlis9e3d7532014-10-27 17:12:54 -0600787// Checks to make sure that shader mapping matches slot binding
788// Print an ERROR and return XGL_FALSE if they don't line up
789static XGL_BOOL verifyShaderSlotMapping(const XGL_UINT slot, const XGL_UINT slotBinding, const XGL_UINT shaderStage, const XGL_DESCRIPTOR_SET_SLOT_TYPE shaderMapping)
790{
791 XGL_BOOL error = XGL_FALSE;
Tobin Ehlise79df942014-11-18 16:38:08 -0700792 char str[1024];
Tobin Ehlis9e3d7532014-10-27 17:12:54 -0600793 switch (shaderMapping)
794 {
Cody Northrop40316a32014-12-09 19:08:33 -0700795 case XGL_SLOT_SHADER_TEXTURE_RESOURCE:
Tobin Ehlis9e3d7532014-10-27 17:12:54 -0600796 case XGL_SLOT_SHADER_RESOURCE:
797 if (MAPPING_MEMORY != slotBinding && MAPPING_IMAGE != slotBinding)
798 error = XGL_TRUE;
799 break;
800 case XGL_SLOT_SHADER_SAMPLER:
801 if (MAPPING_SAMPLER != slotBinding)
802 error = XGL_TRUE;
803 break;
Tobin Ehlis9e3d7532014-10-27 17:12:54 -0600804 case XGL_SLOT_SHADER_UAV:
805 if (MAPPING_MEMORY != slotBinding)
806 error = XGL_TRUE;
807 break;
808 case XGL_SLOT_NEXT_DESCRIPTOR_SET:
809 if (MAPPING_DS != slotBinding)
810 error = XGL_TRUE;
811 break;
812 case XGL_SLOT_UNUSED:
813 break;
814 default:
Tobin Ehlise79df942014-11-18 16:38:08 -0700815 sprintf(str, "For DS slot %u, unknown shader slot mapping w/ value %u", slot, shaderMapping);
816 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_UNKNOWN_DS_MAPPING, "DS", str);
Tobin Ehlis9e3d7532014-10-27 17:12:54 -0600817 return XGL_FALSE;
818 }
819 if (XGL_TRUE == error) {
Tobin Ehlis26092022014-11-20 09:49:17 -0700820 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 Ehlise79df942014-11-18 16:38:08 -0700821 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_DS_MAPPING_MISMATCH, "DS", str);
Tobin Ehlis9e3d7532014-10-27 17:12:54 -0600822 return XGL_FALSE;
823 }
824 return XGL_TRUE;
825}
826
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600827// Print details of DS config to stdout
828static void printDSConfig()
829{
Tobin Ehlis791a49c2014-11-10 12:29:12 -0700830 uint32_t skipUnusedCount = 0; // track consecutive unused slots for minimal reporting
Tobin Ehlise79df942014-11-18 16:38:08 -0700831 char tmp_str[1024];
832 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 Ehlis8726b9f2014-10-24 12:01:45 -0600833 for (uint32_t i = 0; i < XGL_MAX_DESCRIPTOR_SETS; i++) {
Tobin Ehlisb8154982014-10-27 14:53:17 -0600834 if (lastBoundDS[i]) {
835 DS_LL_HEAD *pDS = getDS(lastBoundDS[i]);
Tobin Ehliseacc64f2014-11-24 17:09:09 -0700836 XGL_UINT slotOffset = lastBoundSlotOffset[i];
Tobin Ehlisb8154982014-10-27 14:53:17 -0600837 if (pDS) {
Tobin Ehliseacc64f2014-11-24 17:09:09 -0700838 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 Ehlise79df942014-11-18 16:38:08 -0700839 strcat(ds_config_str, tmp_str);
Tobin Ehlisb8154982014-10-27 14:53:17 -0600840 for (uint32_t j = 0; j < pDS->numSlots; j++) {
Tobin Ehlisb8154982014-10-27 14:53:17 -0600841 switch (pDS->dsSlot[j].activeMapping)
842 {
843 case MAPPING_MEMORY:
Tobin Ehlis791a49c2014-11-10 12:29:12 -0700844 if (0 != skipUnusedCount) {// finish sequence of unused slots
Tobin Ehlise79df942014-11-18 16:38:08 -0700845 sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : "");
846 strcat(ds_config_str, tmp_str);
Tobin Ehlis791a49c2014-11-10 12:29:12 -0700847 skipUnusedCount = 0;
848 }
Tobin Ehlise79df942014-11-18 16:38:08 -0700849 sprintf(tmp_str, "----Slot %u\n Mapped to Memory View %p:\n%s", j, (void*)&pDS->dsSlot[j].memView, xgl_print_xgl_memory_view_attach_info(&pDS->dsSlot[j].memView, " "));
850 strcat(ds_config_str, tmp_str);
Tobin Ehlisb8154982014-10-27 14:53:17 -0600851 break;
852 case MAPPING_IMAGE:
Tobin Ehlis791a49c2014-11-10 12:29:12 -0700853 if (0 != skipUnusedCount) {// finish sequence of unused slots
Tobin Ehlise79df942014-11-18 16:38:08 -0700854 sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : "");
855 strcat(ds_config_str, tmp_str);
Tobin Ehlis791a49c2014-11-10 12:29:12 -0700856 skipUnusedCount = 0;
857 }
Tobin Ehlise79df942014-11-18 16:38:08 -0700858 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, " "));
859 strcat(ds_config_str, tmp_str);
Tobin Ehlisb8154982014-10-27 14:53:17 -0600860 break;
861 case MAPPING_SAMPLER:
Tobin Ehlis791a49c2014-11-10 12:29:12 -0700862 if (0 != skipUnusedCount) {// finish sequence of unused slots
Tobin Ehlise79df942014-11-18 16:38:08 -0700863 sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : "");
864 strcat(ds_config_str, tmp_str);
Tobin Ehlis791a49c2014-11-10 12:29:12 -0700865 skipUnusedCount = 0;
866 }
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -0700867 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 Ehlise79df942014-11-18 16:38:08 -0700868 strcat(ds_config_str, tmp_str);
Tobin Ehlisb8154982014-10-27 14:53:17 -0600869 break;
870 default:
Tobin Ehlise79df942014-11-18 16:38:08 -0700871 if (!skipUnusedCount) {// only report start of unused sequences
872 sprintf(tmp_str, "----Skipping slot(s) w/o a view attached...\n");
873 strcat(ds_config_str, tmp_str);
874 }
Tobin Ehlis791a49c2014-11-10 12:29:12 -0700875 skipUnusedCount++;
Tobin Ehlisb8154982014-10-27 14:53:17 -0600876 break;
877 }
Tobin Ehlis9e3d7532014-10-27 17:12:54 -0600878 // For each shader type, check its mapping
Tobin Ehlis26092022014-11-20 09:49:17 -0700879 for (uint32_t k = 0; k < XGL_NUM_GRAPHICS_SHADERS; k++) {
Tobin Ehlisb8154982014-10-27 14:53:17 -0600880 if (XGL_SLOT_UNUSED != pDS->dsSlot[j].shaderSlotInfo[k].slotObjectType) {
Tobin Ehlis26092022014-11-20 09:49:17 -0700881 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 Ehlise79df942014-11-18 16:38:08 -0700882 strcat(ds_config_str, tmp_str);
Tobin Ehlis9e3d7532014-10-27 17:12:54 -0600883 verifyShaderSlotMapping(j, pDS->dsSlot[j].activeMapping, k, pDS->dsSlot[j].shaderSlotInfo[k].slotObjectType);
Tobin Ehlisb8154982014-10-27 14:53:17 -0600884 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600885 }
886 }
Tobin Ehlis791a49c2014-11-10 12:29:12 -0700887 if (0 != skipUnusedCount) {// finish sequence of unused slots
Tobin Ehlise79df942014-11-18 16:38:08 -0700888 sprintf(tmp_str, "----Skipped %u slot%s w/o a view attached...\n", skipUnusedCount, (1 != skipUnusedCount) ? "s" : "");
889 strcat(ds_config_str, tmp_str);
Tobin Ehlis791a49c2014-11-10 12:29:12 -0700890 skipUnusedCount = 0;
891 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600892 }
Tobin Ehlisb8154982014-10-27 14:53:17 -0600893 else {
Tobin Ehlise79df942014-11-18 16:38:08 -0700894 char str[1024];
895 sprintf(str, "Can't find last bound DS %p. Did you need to bind DS to index %u?", (void*)lastBoundDS[i], i);
896 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NO_DS_BOUND, "DS", str);
Tobin Ehlisb8154982014-10-27 14:53:17 -0600897 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600898 }
899 }
Tobin Ehlise79df942014-11-18 16:38:08 -0700900 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600901}
902
903static void synchAndPrintDSConfig()
904{
905 synchDSMapping();
906 printDSConfig();
Tobin Ehlis56a61072014-11-21 08:58:46 -0700907 printPipeline();
908 printDynamicState();
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700909 static int autoDumpOnce = 1;
910 if (autoDumpOnce) {
911 autoDumpOnce = 0;
912 dumpDotFile("pipeline_dump.dot");
Tobin Ehlis266473d2014-12-16 17:34:50 -0700913 // Convert dot to png if dot available
914 if(access( "/usr/bin/dot", X_OK) != -1) {
915 system("/usr/bin/dot pipeline_dump.dot -Tpng -o pipeline_dump.png");
916 }
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700917 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600918}
919
Jon Ashburn2e9b5612014-12-22 13:38:27 -0700920static void initDrawState()
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600921{
Jon Ashburn2e9b5612014-12-22 13:38:27 -0700922 const char *strOpt;
923 // initialize MemTracker options
924 strOpt = getLayerOption("DrawStateReportLevel");
925 if (strOpt != NULL)
926 g_reportingLevel = atoi(strOpt);
927 strOpt = getLayerOption("DrawStateDebugAction");
928 if (strOpt != NULL)
929 g_debugAction = atoi(strOpt);
930 if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG)
931 {
932 strOpt = getLayerOption("DrawStateLogFilename");
933 if (strOpt)
934 {
935 g_logFile = fopen(strOpt, "w");
936
937 }
938 if (g_logFile == NULL)
939 g_logFile = stdout;
940 }
941
942 // initialize Layer dispatch table
943 // TODO handle multiple GPUs
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600944 GetProcAddrType fpNextGPA;
945 fpNextGPA = pCurObj->pGPA;
946 assert(fpNextGPA);
947
948 GetProcAddrType fpGetProcAddr = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetProcAddr");
949 nextTable.GetProcAddr = fpGetProcAddr;
950 InitAndEnumerateGpusType fpInitAndEnumerateGpus = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglInitAndEnumerateGpus");
951 nextTable.InitAndEnumerateGpus = fpInitAndEnumerateGpus;
952 GetGpuInfoType fpGetGpuInfo = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetGpuInfo");
953 nextTable.GetGpuInfo = fpGetGpuInfo;
954 CreateDeviceType fpCreateDevice = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateDevice");
955 nextTable.CreateDevice = fpCreateDevice;
956 DestroyDeviceType fpDestroyDevice = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglDestroyDevice");
957 nextTable.DestroyDevice = fpDestroyDevice;
958 GetExtensionSupportType fpGetExtensionSupport = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetExtensionSupport");
959 nextTable.GetExtensionSupport = fpGetExtensionSupport;
960 EnumerateLayersType fpEnumerateLayers = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglEnumerateLayers");
961 nextTable.EnumerateLayers = fpEnumerateLayers;
962 GetDeviceQueueType fpGetDeviceQueue = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetDeviceQueue");
963 nextTable.GetDeviceQueue = fpGetDeviceQueue;
964 QueueSubmitType fpQueueSubmit = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglQueueSubmit");
965 nextTable.QueueSubmit = fpQueueSubmit;
966 QueueSetGlobalMemReferencesType fpQueueSetGlobalMemReferences = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglQueueSetGlobalMemReferences");
967 nextTable.QueueSetGlobalMemReferences = fpQueueSetGlobalMemReferences;
968 QueueWaitIdleType fpQueueWaitIdle = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglQueueWaitIdle");
969 nextTable.QueueWaitIdle = fpQueueWaitIdle;
970 DeviceWaitIdleType fpDeviceWaitIdle = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglDeviceWaitIdle");
971 nextTable.DeviceWaitIdle = fpDeviceWaitIdle;
972 GetMemoryHeapCountType fpGetMemoryHeapCount = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetMemoryHeapCount");
973 nextTable.GetMemoryHeapCount = fpGetMemoryHeapCount;
974 GetMemoryHeapInfoType fpGetMemoryHeapInfo = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetMemoryHeapInfo");
975 nextTable.GetMemoryHeapInfo = fpGetMemoryHeapInfo;
976 AllocMemoryType fpAllocMemory = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglAllocMemory");
977 nextTable.AllocMemory = fpAllocMemory;
978 FreeMemoryType fpFreeMemory = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglFreeMemory");
979 nextTable.FreeMemory = fpFreeMemory;
980 SetMemoryPriorityType fpSetMemoryPriority = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglSetMemoryPriority");
981 nextTable.SetMemoryPriority = fpSetMemoryPriority;
982 MapMemoryType fpMapMemory = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglMapMemory");
983 nextTable.MapMemory = fpMapMemory;
984 UnmapMemoryType fpUnmapMemory = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglUnmapMemory");
985 nextTable.UnmapMemory = fpUnmapMemory;
986 PinSystemMemoryType fpPinSystemMemory = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglPinSystemMemory");
987 nextTable.PinSystemMemory = fpPinSystemMemory;
988 RemapVirtualMemoryPagesType fpRemapVirtualMemoryPages = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglRemapVirtualMemoryPages");
989 nextTable.RemapVirtualMemoryPages = fpRemapVirtualMemoryPages;
990 GetMultiGpuCompatibilityType fpGetMultiGpuCompatibility = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetMultiGpuCompatibility");
991 nextTable.GetMultiGpuCompatibility = fpGetMultiGpuCompatibility;
992 OpenSharedMemoryType fpOpenSharedMemory = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglOpenSharedMemory");
993 nextTable.OpenSharedMemory = fpOpenSharedMemory;
994 OpenSharedQueueSemaphoreType fpOpenSharedQueueSemaphore = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglOpenSharedQueueSemaphore");
995 nextTable.OpenSharedQueueSemaphore = fpOpenSharedQueueSemaphore;
996 OpenPeerMemoryType fpOpenPeerMemory = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglOpenPeerMemory");
997 nextTable.OpenPeerMemory = fpOpenPeerMemory;
998 OpenPeerImageType fpOpenPeerImage = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglOpenPeerImage");
999 nextTable.OpenPeerImage = fpOpenPeerImage;
1000 DestroyObjectType fpDestroyObject = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglDestroyObject");
1001 nextTable.DestroyObject = fpDestroyObject;
1002 GetObjectInfoType fpGetObjectInfo = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetObjectInfo");
1003 nextTable.GetObjectInfo = fpGetObjectInfo;
1004 BindObjectMemoryType fpBindObjectMemory = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglBindObjectMemory");
1005 nextTable.BindObjectMemory = fpBindObjectMemory;
1006 CreateFenceType fpCreateFence = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateFence");
1007 nextTable.CreateFence = fpCreateFence;
1008 GetFenceStatusType fpGetFenceStatus = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetFenceStatus");
1009 nextTable.GetFenceStatus = fpGetFenceStatus;
1010 WaitForFencesType fpWaitForFences = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglWaitForFences");
1011 nextTable.WaitForFences = fpWaitForFences;
1012 CreateQueueSemaphoreType fpCreateQueueSemaphore = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateQueueSemaphore");
1013 nextTable.CreateQueueSemaphore = fpCreateQueueSemaphore;
1014 SignalQueueSemaphoreType fpSignalQueueSemaphore = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglSignalQueueSemaphore");
1015 nextTable.SignalQueueSemaphore = fpSignalQueueSemaphore;
1016 WaitQueueSemaphoreType fpWaitQueueSemaphore = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglWaitQueueSemaphore");
1017 nextTable.WaitQueueSemaphore = fpWaitQueueSemaphore;
1018 CreateEventType fpCreateEvent = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateEvent");
1019 nextTable.CreateEvent = fpCreateEvent;
1020 GetEventStatusType fpGetEventStatus = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetEventStatus");
1021 nextTable.GetEventStatus = fpGetEventStatus;
1022 SetEventType fpSetEvent = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglSetEvent");
1023 nextTable.SetEvent = fpSetEvent;
1024 ResetEventType fpResetEvent = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglResetEvent");
1025 nextTable.ResetEvent = fpResetEvent;
1026 CreateQueryPoolType fpCreateQueryPool = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateQueryPool");
1027 nextTable.CreateQueryPool = fpCreateQueryPool;
1028 GetQueryPoolResultsType fpGetQueryPoolResults = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetQueryPoolResults");
1029 nextTable.GetQueryPoolResults = fpGetQueryPoolResults;
1030 GetFormatInfoType fpGetFormatInfo = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetFormatInfo");
1031 nextTable.GetFormatInfo = fpGetFormatInfo;
1032 CreateImageType fpCreateImage = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateImage");
1033 nextTable.CreateImage = fpCreateImage;
1034 GetImageSubresourceInfoType fpGetImageSubresourceInfo = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglGetImageSubresourceInfo");
1035 nextTable.GetImageSubresourceInfo = fpGetImageSubresourceInfo;
1036 CreateImageViewType fpCreateImageView = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateImageView");
1037 nextTable.CreateImageView = fpCreateImageView;
1038 CreateColorAttachmentViewType fpCreateColorAttachmentView = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateColorAttachmentView");
1039 nextTable.CreateColorAttachmentView = fpCreateColorAttachmentView;
1040 CreateDepthStencilViewType fpCreateDepthStencilView = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateDepthStencilView");
1041 nextTable.CreateDepthStencilView = fpCreateDepthStencilView;
1042 CreateShaderType fpCreateShader = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateShader");
1043 nextTable.CreateShader = fpCreateShader;
1044 CreateGraphicsPipelineType fpCreateGraphicsPipeline = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateGraphicsPipeline");
1045 nextTable.CreateGraphicsPipeline = fpCreateGraphicsPipeline;
1046 CreateComputePipelineType fpCreateComputePipeline = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateComputePipeline");
1047 nextTable.CreateComputePipeline = fpCreateComputePipeline;
1048 StorePipelineType fpStorePipeline = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglStorePipeline");
1049 nextTable.StorePipeline = fpStorePipeline;
1050 LoadPipelineType fpLoadPipeline = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglLoadPipeline");
1051 nextTable.LoadPipeline = fpLoadPipeline;
1052 CreatePipelineDeltaType fpCreatePipelineDelta = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreatePipelineDelta");
1053 nextTable.CreatePipelineDelta = fpCreatePipelineDelta;
1054 CreateSamplerType fpCreateSampler = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateSampler");
1055 nextTable.CreateSampler = fpCreateSampler;
1056 CreateDescriptorSetType fpCreateDescriptorSet = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateDescriptorSet");
1057 nextTable.CreateDescriptorSet = fpCreateDescriptorSet;
1058 BeginDescriptorSetUpdateType fpBeginDescriptorSetUpdate = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglBeginDescriptorSetUpdate");
1059 nextTable.BeginDescriptorSetUpdate = fpBeginDescriptorSetUpdate;
1060 EndDescriptorSetUpdateType fpEndDescriptorSetUpdate = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglEndDescriptorSetUpdate");
1061 nextTable.EndDescriptorSetUpdate = fpEndDescriptorSetUpdate;
1062 AttachSamplerDescriptorsType fpAttachSamplerDescriptors = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglAttachSamplerDescriptors");
1063 nextTable.AttachSamplerDescriptors = fpAttachSamplerDescriptors;
1064 AttachImageViewDescriptorsType fpAttachImageViewDescriptors = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglAttachImageViewDescriptors");
1065 nextTable.AttachImageViewDescriptors = fpAttachImageViewDescriptors;
1066 AttachMemoryViewDescriptorsType fpAttachMemoryViewDescriptors = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglAttachMemoryViewDescriptors");
1067 nextTable.AttachMemoryViewDescriptors = fpAttachMemoryViewDescriptors;
1068 AttachNestedDescriptorsType fpAttachNestedDescriptors = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglAttachNestedDescriptors");
1069 nextTable.AttachNestedDescriptors = fpAttachNestedDescriptors;
1070 ClearDescriptorSetSlotsType fpClearDescriptorSetSlots = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglClearDescriptorSetSlots");
1071 nextTable.ClearDescriptorSetSlots = fpClearDescriptorSetSlots;
1072 CreateViewportStateType fpCreateViewportState = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateViewportState");
1073 nextTable.CreateViewportState = fpCreateViewportState;
1074 CreateRasterStateType fpCreateRasterState = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateRasterState");
1075 nextTable.CreateRasterState = fpCreateRasterState;
1076 CreateMsaaStateType fpCreateMsaaState = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateMsaaState");
1077 nextTable.CreateMsaaState = fpCreateMsaaState;
1078 CreateColorBlendStateType fpCreateColorBlendState = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateColorBlendState");
1079 nextTable.CreateColorBlendState = fpCreateColorBlendState;
1080 CreateDepthStencilStateType fpCreateDepthStencilState = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateDepthStencilState");
1081 nextTable.CreateDepthStencilState = fpCreateDepthStencilState;
1082 CreateCommandBufferType fpCreateCommandBuffer = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCreateCommandBuffer");
1083 nextTable.CreateCommandBuffer = fpCreateCommandBuffer;
1084 BeginCommandBufferType fpBeginCommandBuffer = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglBeginCommandBuffer");
1085 nextTable.BeginCommandBuffer = fpBeginCommandBuffer;
1086 EndCommandBufferType fpEndCommandBuffer = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglEndCommandBuffer");
1087 nextTable.EndCommandBuffer = fpEndCommandBuffer;
1088 ResetCommandBufferType fpResetCommandBuffer = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglResetCommandBuffer");
1089 nextTable.ResetCommandBuffer = fpResetCommandBuffer;
1090 CmdBindPipelineType fpCmdBindPipeline = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdBindPipeline");
1091 nextTable.CmdBindPipeline = fpCmdBindPipeline;
1092 CmdBindPipelineDeltaType fpCmdBindPipelineDelta = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdBindPipelineDelta");
1093 nextTable.CmdBindPipelineDelta = fpCmdBindPipelineDelta;
1094 CmdBindStateObjectType fpCmdBindStateObject = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdBindStateObject");
1095 nextTable.CmdBindStateObject = fpCmdBindStateObject;
1096 CmdBindDescriptorSetType fpCmdBindDescriptorSet = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdBindDescriptorSet");
1097 nextTable.CmdBindDescriptorSet = fpCmdBindDescriptorSet;
1098 CmdBindDynamicMemoryViewType fpCmdBindDynamicMemoryView = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdBindDynamicMemoryView");
1099 nextTable.CmdBindDynamicMemoryView = fpCmdBindDynamicMemoryView;
Chia-I Wu3b04af52014-11-08 10:48:20 +08001100 CmdBindVertexDataType fpCmdBindVertexData = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdBindVertexData");
1101 nextTable.CmdBindVertexData = fpCmdBindVertexData;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001102 CmdBindIndexDataType fpCmdBindIndexData = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdBindIndexData");
1103 nextTable.CmdBindIndexData = fpCmdBindIndexData;
1104 CmdBindAttachmentsType fpCmdBindAttachments = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdBindAttachments");
1105 nextTable.CmdBindAttachments = fpCmdBindAttachments;
1106 CmdPrepareMemoryRegionsType fpCmdPrepareMemoryRegions = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdPrepareMemoryRegions");
1107 nextTable.CmdPrepareMemoryRegions = fpCmdPrepareMemoryRegions;
1108 CmdPrepareImagesType fpCmdPrepareImages = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdPrepareImages");
1109 nextTable.CmdPrepareImages = fpCmdPrepareImages;
1110 CmdDrawType fpCmdDraw = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdDraw");
1111 nextTable.CmdDraw = fpCmdDraw;
1112 CmdDrawIndexedType fpCmdDrawIndexed = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdDrawIndexed");
1113 nextTable.CmdDrawIndexed = fpCmdDrawIndexed;
1114 CmdDrawIndirectType fpCmdDrawIndirect = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdDrawIndirect");
1115 nextTable.CmdDrawIndirect = fpCmdDrawIndirect;
1116 CmdDrawIndexedIndirectType fpCmdDrawIndexedIndirect = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdDrawIndexedIndirect");
1117 nextTable.CmdDrawIndexedIndirect = fpCmdDrawIndexedIndirect;
1118 CmdDispatchType fpCmdDispatch = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdDispatch");
1119 nextTable.CmdDispatch = fpCmdDispatch;
1120 CmdDispatchIndirectType fpCmdDispatchIndirect = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdDispatchIndirect");
1121 nextTable.CmdDispatchIndirect = fpCmdDispatchIndirect;
1122 CmdCopyMemoryType fpCmdCopyMemory = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdCopyMemory");
1123 nextTable.CmdCopyMemory = fpCmdCopyMemory;
1124 CmdCopyImageType fpCmdCopyImage = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdCopyImage");
1125 nextTable.CmdCopyImage = fpCmdCopyImage;
1126 CmdCopyMemoryToImageType fpCmdCopyMemoryToImage = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdCopyMemoryToImage");
1127 nextTable.CmdCopyMemoryToImage = fpCmdCopyMemoryToImage;
1128 CmdCopyImageToMemoryType fpCmdCopyImageToMemory = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdCopyImageToMemory");
1129 nextTable.CmdCopyImageToMemory = fpCmdCopyImageToMemory;
1130 CmdCloneImageDataType fpCmdCloneImageData = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdCloneImageData");
1131 nextTable.CmdCloneImageData = fpCmdCloneImageData;
1132 CmdUpdateMemoryType fpCmdUpdateMemory = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdUpdateMemory");
1133 nextTable.CmdUpdateMemory = fpCmdUpdateMemory;
1134 CmdFillMemoryType fpCmdFillMemory = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdFillMemory");
1135 nextTable.CmdFillMemory = fpCmdFillMemory;
1136 CmdClearColorImageType fpCmdClearColorImage = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdClearColorImage");
1137 nextTable.CmdClearColorImage = fpCmdClearColorImage;
1138 CmdClearColorImageRawType fpCmdClearColorImageRaw = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdClearColorImageRaw");
1139 nextTable.CmdClearColorImageRaw = fpCmdClearColorImageRaw;
1140 CmdClearDepthStencilType fpCmdClearDepthStencil = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdClearDepthStencil");
1141 nextTable.CmdClearDepthStencil = fpCmdClearDepthStencil;
1142 CmdResolveImageType fpCmdResolveImage = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdResolveImage");
1143 nextTable.CmdResolveImage = fpCmdResolveImage;
1144 CmdSetEventType fpCmdSetEvent = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdSetEvent");
1145 nextTable.CmdSetEvent = fpCmdSetEvent;
1146 CmdResetEventType fpCmdResetEvent = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdResetEvent");
1147 nextTable.CmdResetEvent = fpCmdResetEvent;
1148 CmdMemoryAtomicType fpCmdMemoryAtomic = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdMemoryAtomic");
1149 nextTable.CmdMemoryAtomic = fpCmdMemoryAtomic;
1150 CmdBeginQueryType fpCmdBeginQuery = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdBeginQuery");
1151 nextTable.CmdBeginQuery = fpCmdBeginQuery;
1152 CmdEndQueryType fpCmdEndQuery = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdEndQuery");
1153 nextTable.CmdEndQuery = fpCmdEndQuery;
1154 CmdResetQueryPoolType fpCmdResetQueryPool = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdResetQueryPool");
1155 nextTable.CmdResetQueryPool = fpCmdResetQueryPool;
1156 CmdWriteTimestampType fpCmdWriteTimestamp = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdWriteTimestamp");
1157 nextTable.CmdWriteTimestamp = fpCmdWriteTimestamp;
1158 CmdInitAtomicCountersType fpCmdInitAtomicCounters = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdInitAtomicCounters");
1159 nextTable.CmdInitAtomicCounters = fpCmdInitAtomicCounters;
1160 CmdLoadAtomicCountersType fpCmdLoadAtomicCounters = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdLoadAtomicCounters");
1161 nextTable.CmdLoadAtomicCounters = fpCmdLoadAtomicCounters;
1162 CmdSaveAtomicCountersType fpCmdSaveAtomicCounters = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdSaveAtomicCounters");
1163 nextTable.CmdSaveAtomicCounters = fpCmdSaveAtomicCounters;
1164 DbgSetValidationLevelType fpDbgSetValidationLevel = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglDbgSetValidationLevel");
1165 nextTable.DbgSetValidationLevel = fpDbgSetValidationLevel;
1166 DbgRegisterMsgCallbackType fpDbgRegisterMsgCallback = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglDbgRegisterMsgCallback");
1167 nextTable.DbgRegisterMsgCallback = fpDbgRegisterMsgCallback;
1168 DbgUnregisterMsgCallbackType fpDbgUnregisterMsgCallback = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglDbgUnregisterMsgCallback");
1169 nextTable.DbgUnregisterMsgCallback = fpDbgUnregisterMsgCallback;
1170 DbgSetMessageFilterType fpDbgSetMessageFilter = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglDbgSetMessageFilter");
1171 nextTable.DbgSetMessageFilter = fpDbgSetMessageFilter;
1172 DbgSetObjectTagType fpDbgSetObjectTag = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglDbgSetObjectTag");
1173 nextTable.DbgSetObjectTag = fpDbgSetObjectTag;
1174 DbgSetGlobalOptionType fpDbgSetGlobalOption = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglDbgSetGlobalOption");
1175 nextTable.DbgSetGlobalOption = fpDbgSetGlobalOption;
1176 DbgSetDeviceOptionType fpDbgSetDeviceOption = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglDbgSetDeviceOption");
1177 nextTable.DbgSetDeviceOption = fpDbgSetDeviceOption;
1178 CmdDbgMarkerBeginType fpCmdDbgMarkerBegin = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdDbgMarkerBegin");
1179 nextTable.CmdDbgMarkerBegin = fpCmdDbgMarkerBegin;
1180 CmdDbgMarkerEndType fpCmdDbgMarkerEnd = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglCmdDbgMarkerEnd");
1181 nextTable.CmdDbgMarkerEnd = fpCmdDbgMarkerEnd;
1182 WsiX11AssociateConnectionType fpWsiX11AssociateConnection = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglWsiX11AssociateConnection");
1183 nextTable.WsiX11AssociateConnection = fpWsiX11AssociateConnection;
1184 WsiX11GetMSCType fpWsiX11GetMSC = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglWsiX11GetMSC");
1185 nextTable.WsiX11GetMSC = fpWsiX11GetMSC;
1186 WsiX11CreatePresentableImageType fpWsiX11CreatePresentableImage = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglWsiX11CreatePresentableImage");
1187 nextTable.WsiX11CreatePresentableImage = fpWsiX11CreatePresentableImage;
1188 WsiX11QueuePresentType fpWsiX11QueuePresent = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (XGL_CHAR *) "xglWsiX11QueuePresent");
1189 nextTable.WsiX11QueuePresent = fpWsiX11QueuePresent;
1190}
1191
1192
1193XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetGpuInfo(XGL_PHYSICAL_GPU gpu, XGL_PHYSICAL_GPU_INFO_TYPE infoType, XGL_SIZE* pDataSize, XGL_VOID* pData)
1194{
1195 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001196 pCurObj = gpuw;
Jon Ashburn2e9b5612014-12-22 13:38:27 -07001197 pthread_once(&g_initOnce, initDrawState);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001198 XGL_RESULT result = nextTable.GetGpuInfo((XGL_PHYSICAL_GPU)gpuw->nextObject, infoType, pDataSize, pData);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001199 return result;
1200}
1201
1202XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreateInfo, XGL_DEVICE* pDevice)
1203{
1204 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001205 pCurObj = gpuw;
Jon Ashburn2e9b5612014-12-22 13:38:27 -07001206 pthread_once(&g_initOnce, initDrawState);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001207 XGL_RESULT result = nextTable.CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001208 return result;
1209}
1210
1211XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyDevice(XGL_DEVICE device)
1212{
1213 XGL_RESULT result = nextTable.DestroyDevice(device);
1214 return result;
1215}
1216
1217XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu, const XGL_CHAR* pExtName)
1218{
1219 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001220 pCurObj = gpuw;
Jon Ashburn2e9b5612014-12-22 13:38:27 -07001221 pthread_once(&g_initOnce, initDrawState);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001222 XGL_RESULT result = nextTable.GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001223 return result;
1224}
1225
Jon Ashburn6847c2b2014-11-25 12:56:49 -07001226XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, XGL_SIZE maxLayerCount, XGL_SIZE maxStringSize, XGL_CHAR* const* pOutLayers, XGL_SIZE * pOutLayerCount, XGL_VOID* pReserved)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001227{
Jon Ashburn451c16f2014-11-25 11:08:42 -07001228 if (gpu != NULL)
1229 {
1230 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
1231 pCurObj = gpuw;
Jon Ashburn2e9b5612014-12-22 13:38:27 -07001232 pthread_once(&g_initOnce, initDrawState);
Jon Ashburn6847c2b2014-11-25 12:56:49 -07001233 XGL_RESULT result = nextTable.EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayers, pOutLayerCount, pReserved);
Jon Ashburn451c16f2014-11-25 11:08:42 -07001234 return result;
1235 } else
1236 {
1237 if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL)
1238 return XGL_ERROR_INVALID_POINTER;
1239 // This layer compatible with all GPUs
1240 *pOutLayerCount = 1;
Chia-I Wua837c522014-12-16 10:47:33 +08001241 strncpy((char *) pOutLayers[0], "DrawState", maxStringSize);
Jon Ashburn451c16f2014-11-25 11:08:42 -07001242 return XGL_SUCCESS;
1243 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001244}
1245
1246XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetDeviceQueue(XGL_DEVICE device, XGL_QUEUE_TYPE queueType, XGL_UINT queueIndex, XGL_QUEUE* pQueue)
1247{
1248 XGL_RESULT result = nextTable.GetDeviceQueue(device, queueType, queueIndex, pQueue);
1249 return result;
1250}
1251
1252XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueSubmit(XGL_QUEUE queue, XGL_UINT cmdBufferCount, const XGL_CMD_BUFFER* pCmdBuffers, XGL_UINT memRefCount, const XGL_MEMORY_REF* pMemRefs, XGL_FENCE fence)
1253{
1254 XGL_RESULT result = nextTable.QueueSubmit(queue, cmdBufferCount, pCmdBuffers, memRefCount, pMemRefs, fence);
1255 return result;
1256}
1257
1258XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueSetGlobalMemReferences(XGL_QUEUE queue, XGL_UINT memRefCount, const XGL_MEMORY_REF* pMemRefs)
1259{
1260 XGL_RESULT result = nextTable.QueueSetGlobalMemReferences(queue, memRefCount, pMemRefs);
1261 return result;
1262}
1263
1264XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueWaitIdle(XGL_QUEUE queue)
1265{
1266 XGL_RESULT result = nextTable.QueueWaitIdle(queue);
1267 return result;
1268}
1269
1270XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDeviceWaitIdle(XGL_DEVICE device)
1271{
1272 XGL_RESULT result = nextTable.DeviceWaitIdle(device);
1273 return result;
1274}
1275
1276XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetMemoryHeapCount(XGL_DEVICE device, XGL_UINT* pCount)
1277{
1278 XGL_RESULT result = nextTable.GetMemoryHeapCount(device, pCount);
1279 return result;
1280}
1281
1282XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetMemoryHeapInfo(XGL_DEVICE device, XGL_UINT heapId, XGL_MEMORY_HEAP_INFO_TYPE infoType, XGL_SIZE* pDataSize, XGL_VOID* pData)
1283{
1284 XGL_RESULT result = nextTable.GetMemoryHeapInfo(device, heapId, infoType, pDataSize, pData);
1285 return result;
1286}
1287
1288XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglAllocMemory(XGL_DEVICE device, const XGL_MEMORY_ALLOC_INFO* pAllocInfo, XGL_GPU_MEMORY* pMem)
1289{
1290 XGL_RESULT result = nextTable.AllocMemory(device, pAllocInfo, pMem);
1291 return result;
1292}
1293
1294XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglFreeMemory(XGL_GPU_MEMORY mem)
1295{
1296 XGL_RESULT result = nextTable.FreeMemory(mem);
1297 return result;
1298}
1299
1300XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSetMemoryPriority(XGL_GPU_MEMORY mem, XGL_MEMORY_PRIORITY priority)
1301{
1302 XGL_RESULT result = nextTable.SetMemoryPriority(mem, priority);
1303 return result;
1304}
1305
1306XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglMapMemory(XGL_GPU_MEMORY mem, XGL_FLAGS flags, XGL_VOID** ppData)
1307{
1308 XGL_RESULT result = nextTable.MapMemory(mem, flags, ppData);
1309 return result;
1310}
1311
1312XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglUnmapMemory(XGL_GPU_MEMORY mem)
1313{
1314 XGL_RESULT result = nextTable.UnmapMemory(mem);
1315 return result;
1316}
1317
1318XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglPinSystemMemory(XGL_DEVICE device, const XGL_VOID* pSysMem, XGL_SIZE memSize, XGL_GPU_MEMORY* pMem)
1319{
1320 XGL_RESULT result = nextTable.PinSystemMemory(device, pSysMem, memSize, pMem);
1321 return result;
1322}
1323
1324XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglRemapVirtualMemoryPages(XGL_DEVICE device, XGL_UINT rangeCount, const XGL_VIRTUAL_MEMORY_REMAP_RANGE* pRanges, XGL_UINT preWaitSemaphoreCount, const XGL_QUEUE_SEMAPHORE* pPreWaitSemaphores, XGL_UINT postSignalSemaphoreCount, const XGL_QUEUE_SEMAPHORE* pPostSignalSemaphores)
1325{
1326 XGL_RESULT result = nextTable.RemapVirtualMemoryPages(device, rangeCount, pRanges, preWaitSemaphoreCount, pPreWaitSemaphores, postSignalSemaphoreCount, pPostSignalSemaphores);
1327 return result;
1328}
1329
1330XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetMultiGpuCompatibility(XGL_PHYSICAL_GPU gpu0, XGL_PHYSICAL_GPU gpu1, XGL_GPU_COMPATIBILITY_INFO* pInfo)
1331{
1332 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu0;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001333 pCurObj = gpuw;
Jon Ashburn2e9b5612014-12-22 13:38:27 -07001334 pthread_once(&g_initOnce, initDrawState);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001335 XGL_RESULT result = nextTable.GetMultiGpuCompatibility((XGL_PHYSICAL_GPU)gpuw->nextObject, gpu1, pInfo);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001336 return result;
1337}
1338
1339XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenSharedMemory(XGL_DEVICE device, const XGL_MEMORY_OPEN_INFO* pOpenInfo, XGL_GPU_MEMORY* pMem)
1340{
1341 XGL_RESULT result = nextTable.OpenSharedMemory(device, pOpenInfo, pMem);
1342 return result;
1343}
1344
1345XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenSharedQueueSemaphore(XGL_DEVICE device, const XGL_QUEUE_SEMAPHORE_OPEN_INFO* pOpenInfo, XGL_QUEUE_SEMAPHORE* pSemaphore)
1346{
1347 XGL_RESULT result = nextTable.OpenSharedQueueSemaphore(device, pOpenInfo, pSemaphore);
1348 return result;
1349}
1350
1351XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenPeerMemory(XGL_DEVICE device, const XGL_PEER_MEMORY_OPEN_INFO* pOpenInfo, XGL_GPU_MEMORY* pMem)
1352{
1353 XGL_RESULT result = nextTable.OpenPeerMemory(device, pOpenInfo, pMem);
1354 return result;
1355}
1356
1357XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenPeerImage(XGL_DEVICE device, const XGL_PEER_IMAGE_OPEN_INFO* pOpenInfo, XGL_IMAGE* pImage, XGL_GPU_MEMORY* pMem)
1358{
1359 XGL_RESULT result = nextTable.OpenPeerImage(device, pOpenInfo, pImage, pMem);
1360 return result;
1361}
1362
1363XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyObject(XGL_OBJECT object)
1364{
1365 XGL_RESULT result = nextTable.DestroyObject(object);
1366 return result;
1367}
1368
1369XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetObjectInfo(XGL_BASE_OBJECT object, XGL_OBJECT_INFO_TYPE infoType, XGL_SIZE* pDataSize, XGL_VOID* pData)
1370{
1371 XGL_RESULT result = nextTable.GetObjectInfo(object, infoType, pDataSize, pData);
1372 return result;
1373}
1374
1375XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBindObjectMemory(XGL_OBJECT object, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset)
1376{
1377 XGL_RESULT result = nextTable.BindObjectMemory(object, mem, offset);
1378 return result;
1379}
1380
1381XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateFence(XGL_DEVICE device, const XGL_FENCE_CREATE_INFO* pCreateInfo, XGL_FENCE* pFence)
1382{
1383 XGL_RESULT result = nextTable.CreateFence(device, pCreateInfo, pFence);
1384 return result;
1385}
1386
1387XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetFenceStatus(XGL_FENCE fence)
1388{
1389 XGL_RESULT result = nextTable.GetFenceStatus(fence);
1390 return result;
1391}
1392
1393XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWaitForFences(XGL_DEVICE device, XGL_UINT fenceCount, const XGL_FENCE* pFences, XGL_BOOL waitAll, XGL_UINT64 timeout)
1394{
1395 XGL_RESULT result = nextTable.WaitForFences(device, fenceCount, pFences, waitAll, timeout);
1396 return result;
1397}
1398
1399XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateQueueSemaphore(XGL_DEVICE device, const XGL_QUEUE_SEMAPHORE_CREATE_INFO* pCreateInfo, XGL_QUEUE_SEMAPHORE* pSemaphore)
1400{
1401 XGL_RESULT result = nextTable.CreateQueueSemaphore(device, pCreateInfo, pSemaphore);
1402 return result;
1403}
1404
1405XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSignalQueueSemaphore(XGL_QUEUE queue, XGL_QUEUE_SEMAPHORE semaphore)
1406{
1407 XGL_RESULT result = nextTable.SignalQueueSemaphore(queue, semaphore);
1408 return result;
1409}
1410
1411XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWaitQueueSemaphore(XGL_QUEUE queue, XGL_QUEUE_SEMAPHORE semaphore)
1412{
1413 XGL_RESULT result = nextTable.WaitQueueSemaphore(queue, semaphore);
1414 return result;
1415}
1416
1417XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateEvent(XGL_DEVICE device, const XGL_EVENT_CREATE_INFO* pCreateInfo, XGL_EVENT* pEvent)
1418{
1419 XGL_RESULT result = nextTable.CreateEvent(device, pCreateInfo, pEvent);
1420 return result;
1421}
1422
1423XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetEventStatus(XGL_EVENT event)
1424{
1425 XGL_RESULT result = nextTable.GetEventStatus(event);
1426 return result;
1427}
1428
1429XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSetEvent(XGL_EVENT event)
1430{
1431 XGL_RESULT result = nextTable.SetEvent(event);
1432 return result;
1433}
1434
1435XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglResetEvent(XGL_EVENT event)
1436{
1437 XGL_RESULT result = nextTable.ResetEvent(event);
1438 return result;
1439}
1440
1441XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateQueryPool(XGL_DEVICE device, const XGL_QUERY_POOL_CREATE_INFO* pCreateInfo, XGL_QUERY_POOL* pQueryPool)
1442{
1443 XGL_RESULT result = nextTable.CreateQueryPool(device, pCreateInfo, pQueryPool);
1444 return result;
1445}
1446
1447XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetQueryPoolResults(XGL_QUERY_POOL queryPool, XGL_UINT startQuery, XGL_UINT queryCount, XGL_SIZE* pDataSize, XGL_VOID* pData)
1448{
1449 XGL_RESULT result = nextTable.GetQueryPoolResults(queryPool, startQuery, queryCount, pDataSize, pData);
1450 return result;
1451}
1452
1453XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetFormatInfo(XGL_DEVICE device, XGL_FORMAT format, XGL_FORMAT_INFO_TYPE infoType, XGL_SIZE* pDataSize, XGL_VOID* pData)
1454{
1455 XGL_RESULT result = nextTable.GetFormatInfo(device, format, infoType, pDataSize, pData);
1456 return result;
1457}
1458
1459XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateImage(XGL_DEVICE device, const XGL_IMAGE_CREATE_INFO* pCreateInfo, XGL_IMAGE* pImage)
1460{
1461 XGL_RESULT result = nextTable.CreateImage(device, pCreateInfo, pImage);
1462 return result;
1463}
1464
1465XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetImageSubresourceInfo(XGL_IMAGE image, const XGL_IMAGE_SUBRESOURCE* pSubresource, XGL_SUBRESOURCE_INFO_TYPE infoType, XGL_SIZE* pDataSize, XGL_VOID* pData)
1466{
1467 XGL_RESULT result = nextTable.GetImageSubresourceInfo(image, pSubresource, infoType, pDataSize, pData);
1468 return result;
1469}
1470
1471XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateImageView(XGL_DEVICE device, const XGL_IMAGE_VIEW_CREATE_INFO* pCreateInfo, XGL_IMAGE_VIEW* pView)
1472{
1473 XGL_RESULT result = nextTable.CreateImageView(device, pCreateInfo, pView);
1474 return result;
1475}
1476
1477XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateColorAttachmentView(XGL_DEVICE device, const XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO* pCreateInfo, XGL_COLOR_ATTACHMENT_VIEW* pView)
1478{
1479 XGL_RESULT result = nextTable.CreateColorAttachmentView(device, pCreateInfo, pView);
1480 return result;
1481}
1482
1483XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDepthStencilView(XGL_DEVICE device, const XGL_DEPTH_STENCIL_VIEW_CREATE_INFO* pCreateInfo, XGL_DEPTH_STENCIL_VIEW* pView)
1484{
1485 XGL_RESULT result = nextTable.CreateDepthStencilView(device, pCreateInfo, pView);
1486 return result;
1487}
1488
1489XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateShader(XGL_DEVICE device, const XGL_SHADER_CREATE_INFO* pCreateInfo, XGL_SHADER* pShader)
1490{
1491 XGL_RESULT result = nextTable.CreateShader(device, pCreateInfo, pShader);
1492 return result;
1493}
1494
1495XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateGraphicsPipeline(XGL_DEVICE device, const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo, XGL_PIPELINE* pPipeline)
1496{
1497 XGL_RESULT result = nextTable.CreateGraphicsPipeline(device, pCreateInfo, pPipeline);
1498 // Create LL HEAD for this Pipeline
Tobin Ehlise79df942014-11-18 16:38:08 -07001499 char str[1024];
1500 sprintf(str, "Created Gfx Pipeline %p", (void*)*pPipeline);
1501 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pPipeline, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis9e142a32014-11-21 12:04:39 -07001502 pthread_mutex_lock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001503 PIPELINE_NODE *pTrav = pPipelineHead;
1504 if (pTrav) {
1505 while (pTrav->pNext)
1506 pTrav = pTrav->pNext;
1507 pTrav->pNext = (PIPELINE_NODE*)malloc(sizeof(PIPELINE_NODE));
1508 pTrav = pTrav->pNext;
1509 }
1510 else {
1511 pTrav = (PIPELINE_NODE*)malloc(sizeof(PIPELINE_NODE));
1512 pPipelineHead = pTrav;
1513 }
1514 memset((void*)pTrav, 0, sizeof(PIPELINE_NODE));
1515 pTrav->pipeline = *pPipeline;
1516 initPipeline(pTrav, pCreateInfo);
Tobin Ehlis9e142a32014-11-21 12:04:39 -07001517 pthread_mutex_unlock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001518 return result;
1519}
1520
1521XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateComputePipeline(XGL_DEVICE device, const XGL_COMPUTE_PIPELINE_CREATE_INFO* pCreateInfo, XGL_PIPELINE* pPipeline)
1522{
1523 XGL_RESULT result = nextTable.CreateComputePipeline(device, pCreateInfo, pPipeline);
1524 return result;
1525}
1526
1527XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglStorePipeline(XGL_PIPELINE pipeline, XGL_SIZE* pDataSize, XGL_VOID* pData)
1528{
1529 XGL_RESULT result = nextTable.StorePipeline(pipeline, pDataSize, pData);
1530 return result;
1531}
1532
1533XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglLoadPipeline(XGL_DEVICE device, XGL_SIZE dataSize, const XGL_VOID* pData, XGL_PIPELINE* pPipeline)
1534{
1535 XGL_RESULT result = nextTable.LoadPipeline(device, dataSize, pData, pPipeline);
1536 return result;
1537}
1538
1539XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreatePipelineDelta(XGL_DEVICE device, XGL_PIPELINE p1, XGL_PIPELINE p2, XGL_PIPELINE_DELTA* delta)
1540{
1541 XGL_RESULT result = nextTable.CreatePipelineDelta(device, p1, p2, delta);
1542 return result;
1543}
1544
1545XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateSampler(XGL_DEVICE device, const XGL_SAMPLER_CREATE_INFO* pCreateInfo, XGL_SAMPLER* pSampler)
1546{
1547 XGL_RESULT result = nextTable.CreateSampler(device, pCreateInfo, pSampler);
Tobin Ehlis9e142a32014-11-21 12:04:39 -07001548 pthread_mutex_lock(&globalLock);
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -07001549 SAMPLER_NODE *pNewNode = (SAMPLER_NODE*)malloc(sizeof(SAMPLER_NODE));
1550 pNewNode->sampler = *pSampler;
1551 memcpy(&pNewNode->createInfo, pCreateInfo, sizeof(XGL_SAMPLER_CREATE_INFO));
1552 pNewNode->pNext = pSamplerHead;
1553 pSamplerHead = pNewNode;
Tobin Ehlis9e142a32014-11-21 12:04:39 -07001554 pthread_mutex_unlock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001555 return result;
1556}
1557
1558XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDescriptorSet(XGL_DEVICE device, const XGL_DESCRIPTOR_SET_CREATE_INFO* pCreateInfo, XGL_DESCRIPTOR_SET* pDescriptorSet)
1559{
1560 XGL_RESULT result = nextTable.CreateDescriptorSet(device, pCreateInfo, pDescriptorSet);
1561 // Create LL chain
Tobin Ehlise79df942014-11-18 16:38:08 -07001562 char str[1024];
1563 sprintf(str, "Created Descriptor Set (DS) %p", (void*)*pDescriptorSet);
1564 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pDescriptorSet, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis9e142a32014-11-21 12:04:39 -07001565 pthread_mutex_lock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001566 DS_LL_HEAD *pTrav = pDSHead;
1567 if (pTrav) {
1568 // Grow existing list
1569 while (pTrav->pNextDS)
1570 pTrav = pTrav->pNextDS;
1571 pTrav->pNextDS = (DS_LL_HEAD*)malloc(sizeof(DS_LL_HEAD));
1572 pTrav = pTrav->pNextDS;
1573 }
1574 else { // Create new list
1575 pTrav = (DS_LL_HEAD*)malloc(sizeof(DS_LL_HEAD));
1576 pDSHead = pTrav;
1577 }
1578 pTrav->dsSlot = (DS_SLOT*)malloc(sizeof(DS_SLOT) * pCreateInfo->slots);
1579 pTrav->dsID = *pDescriptorSet;
1580 pTrav->numSlots = pCreateInfo->slots;
1581 pTrav->pNextDS = NULL;
1582 pTrav->updateActive = XGL_FALSE;
1583 initDS(pTrav);
Tobin Ehlis9e142a32014-11-21 12:04:39 -07001584 pthread_mutex_unlock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001585 return result;
1586}
1587
1588XGL_LAYER_EXPORT XGL_VOID XGLAPI xglBeginDescriptorSetUpdate(XGL_DESCRIPTOR_SET descriptorSet)
1589{
Tobin Ehlis0f051a52014-10-24 13:03:56 -06001590 DS_LL_HEAD* pDS = getDS(descriptorSet);
1591 if (!pDS) {
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001592 // TODO : This is where we should flag a REAL error
Tobin Ehlise79df942014-11-18 16:38:08 -07001593 char str[1024];
1594 sprintf(str, "Specified Descriptor Set %p does not exist!", (void*)descriptorSet);
1595 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_INVALID_DS, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001596 }
Tobin Ehlis0f051a52014-10-24 13:03:56 -06001597 else {
1598 pDS->updateActive = XGL_TRUE;
1599 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001600 nextTable.BeginDescriptorSetUpdate(descriptorSet);
1601}
1602
1603XGL_LAYER_EXPORT XGL_VOID XGLAPI xglEndDescriptorSetUpdate(XGL_DESCRIPTOR_SET descriptorSet)
1604{
1605 if (!dsUpdate(descriptorSet)) {
1606 // TODO : This is where we should flag a REAL error
Tobin Ehlise79df942014-11-18 16:38:08 -07001607 char str[1024];
1608 sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglEndDescriptorSetUpdate()!", (void*)descriptorSet);
1609 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_END_WITHOUT_BEGIN, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001610 }
Tobin Ehlis0f051a52014-10-24 13:03:56 -06001611 else {
1612 DS_LL_HEAD* pDS = getDS(descriptorSet);
1613 if (!pDS) {
Tobin Ehlise79df942014-11-18 16:38:08 -07001614 char str[1024];
1615 sprintf(str, "Specified Descriptor Set %p does not exist!", (void*)descriptorSet);
1616 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_INVALID_DS, "DS", str);
Tobin Ehlis0f051a52014-10-24 13:03:56 -06001617 }
1618 else {
1619 pDS->updateActive = XGL_FALSE;
1620 }
1621 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001622 nextTable.EndDescriptorSetUpdate(descriptorSet);
1623}
1624
1625XGL_LAYER_EXPORT XGL_VOID XGLAPI xglAttachSamplerDescriptors(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_SAMPLER* pSamplers)
1626{
1627 if (!dsUpdate(descriptorSet)) {
1628 // TODO : This is where we should flag a REAL error
Tobin Ehlise79df942014-11-18 16:38:08 -07001629 char str[1024];
1630 sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglAttachSamplerDescriptors()!", (void*)descriptorSet);
1631 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_ATTACH_WITHOUT_BEGIN, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001632 }
1633 else {
Tobin Ehlise79df942014-11-18 16:38:08 -07001634 if (!dsSamplerMapping(descriptorSet, startSlot, slotCount, pSamplers)) {
1635 char str[1024];
1636 sprintf(str, "Unable to attach sampler descriptors to DS %p!", (void*)descriptorSet);
1637 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_SAMPLE_ATTACH_FAILED, "DS", str);
1638 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001639 }
1640 nextTable.AttachSamplerDescriptors(descriptorSet, startSlot, slotCount, pSamplers);
1641}
1642
1643XGL_LAYER_EXPORT XGL_VOID XGLAPI xglAttachImageViewDescriptors(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_IMAGE_VIEW_ATTACH_INFO* pImageViews)
1644{
1645 if (!dsUpdate(descriptorSet)) {
1646 // TODO : This is where we should flag a REAL error
Tobin Ehlise79df942014-11-18 16:38:08 -07001647 char str[1024];
1648 sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglAttachSamplerDescriptors()!", (void*)descriptorSet);
1649 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_ATTACH_WITHOUT_BEGIN, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001650 }
1651 else {
Tobin Ehlise79df942014-11-18 16:38:08 -07001652 if (!dsImageMapping(descriptorSet, startSlot, slotCount, pImageViews)) {
1653 char str[1024];
1654 sprintf(str, "Unable to attach image view descriptors to DS %p!", (void*)descriptorSet);
1655 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_IMAGE_ATTACH_FAILED, "DS", str);
1656 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001657 }
1658 nextTable.AttachImageViewDescriptors(descriptorSet, startSlot, slotCount, pImageViews);
1659}
1660
1661XGL_LAYER_EXPORT XGL_VOID XGLAPI xglAttachMemoryViewDescriptors(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_MEMORY_VIEW_ATTACH_INFO* pMemViews)
1662{
1663 if (!dsUpdate(descriptorSet)) {
1664 // TODO : This is where we should flag a REAL error
Tobin Ehlise79df942014-11-18 16:38:08 -07001665 char str[1024];
1666 sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglAttachSamplerDescriptors()!", (void*)descriptorSet);
1667 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_ATTACH_WITHOUT_BEGIN, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001668 }
1669 else {
Tobin Ehlise79df942014-11-18 16:38:08 -07001670 if (!dsMemMapping(descriptorSet, startSlot, slotCount, pMemViews)) {
1671 char str[1024];
1672 sprintf(str, "Unable to attach memory view descriptors to DS %p!", (void*)descriptorSet);
1673 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_MEMORY_ATTACH_FAILED, "DS", str);
1674 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001675 }
1676 nextTable.AttachMemoryViewDescriptors(descriptorSet, startSlot, slotCount, pMemViews);
1677}
1678
1679XGL_LAYER_EXPORT XGL_VOID XGLAPI xglAttachNestedDescriptors(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount, const XGL_DESCRIPTOR_SET_ATTACH_INFO* pNestedDescriptorSets)
1680{
1681 if (!dsUpdate(descriptorSet)) {
1682 // TODO : This is where we should flag a REAL error
Tobin Ehlise79df942014-11-18 16:38:08 -07001683 char str[1024];
1684 sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglAttachSamplerDescriptors()!", (void*)descriptorSet);
1685 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_ATTACH_WITHOUT_BEGIN, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001686 }
1687 nextTable.AttachNestedDescriptors(descriptorSet, startSlot, slotCount, pNestedDescriptorSets);
1688}
1689
1690// TODO : Does xglBeginDescriptorSetUpdate() have to be called before this function?
1691XGL_LAYER_EXPORT XGL_VOID XGLAPI xglClearDescriptorSetSlots(XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT startSlot, XGL_UINT slotCount)
1692{
1693 if (!dsUpdate(descriptorSet)) {
1694 // TODO : This is where we should flag a REAL error
Tobin Ehlise79df942014-11-18 16:38:08 -07001695 char str[1024];
1696 sprintf(str, "You must call xglBeginDescriptorSetUpdate(%p) before this call to xglClearDescriptorSetSlots()!", (void*)descriptorSet);
1697 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_DS_ATTACH_WITHOUT_BEGIN, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001698 }
1699 if (!clearDS(descriptorSet, startSlot, slotCount)) {
1700 // TODO : This is where we should flag a REAL error
Tobin Ehlise79df942014-11-18 16:38:08 -07001701 char str[1024];
1702 sprintf(str, "Unable to perform xglClearDescriptorSetSlots(%p, %u, %u) call!", descriptorSet, startSlot, slotCount);
1703 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_CLEAR_DS_FAILED, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001704 }
1705 nextTable.ClearDescriptorSetSlots(descriptorSet, startSlot, slotCount);
1706}
1707
1708XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateViewportState(XGL_DEVICE device, const XGL_VIEWPORT_STATE_CREATE_INFO* pCreateInfo, XGL_VIEWPORT_STATE_OBJECT* pState)
1709{
1710 XGL_RESULT result = nextTable.CreateViewportState(device, pCreateInfo, pState);
Tobin Ehlis56a61072014-11-21 08:58:46 -07001711 insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_VIEWPORT);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001712 return result;
1713}
1714
1715XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateRasterState(XGL_DEVICE device, const XGL_RASTER_STATE_CREATE_INFO* pCreateInfo, XGL_RASTER_STATE_OBJECT* pState)
1716{
1717 XGL_RESULT result = nextTable.CreateRasterState(device, pCreateInfo, pState);
Tobin Ehlis56a61072014-11-21 08:58:46 -07001718 insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_RASTER);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001719 return result;
1720}
1721
1722XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateMsaaState(XGL_DEVICE device, const XGL_MSAA_STATE_CREATE_INFO* pCreateInfo, XGL_MSAA_STATE_OBJECT* pState)
1723{
1724 XGL_RESULT result = nextTable.CreateMsaaState(device, pCreateInfo, pState);
Tobin Ehlis56a61072014-11-21 08:58:46 -07001725 insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_MSAA);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001726 return result;
1727}
1728
1729XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateColorBlendState(XGL_DEVICE device, const XGL_COLOR_BLEND_STATE_CREATE_INFO* pCreateInfo, XGL_COLOR_BLEND_STATE_OBJECT* pState)
1730{
1731 XGL_RESULT result = nextTable.CreateColorBlendState(device, pCreateInfo, pState);
Tobin Ehlis56a61072014-11-21 08:58:46 -07001732 insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_COLOR_BLEND);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001733 return result;
1734}
1735
1736XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDepthStencilState(XGL_DEVICE device, const XGL_DEPTH_STENCIL_STATE_CREATE_INFO* pCreateInfo, XGL_DEPTH_STENCIL_STATE_OBJECT* pState)
1737{
1738 XGL_RESULT result = nextTable.CreateDepthStencilState(device, pCreateInfo, pState);
Tobin Ehlis56a61072014-11-21 08:58:46 -07001739 insertDynamicState(*pState, (PIPELINE_LL_HEADER*)pCreateInfo, XGL_STATE_BIND_DEPTH_STENCIL);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001740 return result;
1741}
1742
1743XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateCommandBuffer(XGL_DEVICE device, const XGL_CMD_BUFFER_CREATE_INFO* pCreateInfo, XGL_CMD_BUFFER* pCmdBuffer)
1744{
1745 XGL_RESULT result = nextTable.CreateCommandBuffer(device, pCreateInfo, pCmdBuffer);
1746 return result;
1747}
1748
1749XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBeginCommandBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_FLAGS flags)
1750{
1751 XGL_RESULT result = nextTable.BeginCommandBuffer(cmdBuffer, flags);
1752 return result;
1753}
1754
1755XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEndCommandBuffer(XGL_CMD_BUFFER cmdBuffer)
1756{
1757 XGL_RESULT result = nextTable.EndCommandBuffer(cmdBuffer);
1758 return result;
1759}
1760
1761XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglResetCommandBuffer(XGL_CMD_BUFFER cmdBuffer)
1762{
1763 XGL_RESULT result = nextTable.ResetCommandBuffer(cmdBuffer);
1764 return result;
1765}
1766
1767XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindPipeline(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE pipeline)
1768{
1769 if (getPipeline(pipeline)) {
1770 lastBoundPipeline = pipeline;
1771 }
1772 else {
Tobin Ehlise79df942014-11-18 16:38:08 -07001773 char str[1024];
1774 sprintf(str, "Attempt to bind Pipeline %p that doesn't exist!", (void*)pipeline);
1775 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pipeline, 0, DRAWSTATE_INVALID_PIPELINE, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001776 }
1777 nextTable.CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline);
1778}
1779
1780XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindPipelineDelta(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE_DELTA delta)
1781{
1782 nextTable.CmdBindPipelineDelta(cmdBuffer, pipelineBindPoint, delta);
1783}
1784
1785XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindStateObject(XGL_CMD_BUFFER cmdBuffer, XGL_STATE_BIND_POINT stateBindPoint, XGL_STATE_OBJECT state)
1786{
Tobin Ehlis56a61072014-11-21 08:58:46 -07001787 setLastBoundDynamicState(state, stateBindPoint);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001788 nextTable.CmdBindStateObject(cmdBuffer, stateBindPoint, state);
1789}
1790
1791XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindDescriptorSet(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_UINT index, XGL_DESCRIPTOR_SET descriptorSet, XGL_UINT slotOffset)
1792{
1793 if (getDS(descriptorSet)) {
Tobin Ehlisb8154982014-10-27 14:53:17 -06001794 assert(index < XGL_MAX_DESCRIPTOR_SETS);
Tobin Ehlis9e142a32014-11-21 12:04:39 -07001795 pthread_mutex_lock(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001796 lastBoundDS[index] = descriptorSet;
Tobin Ehliseacc64f2014-11-24 17:09:09 -07001797 lastBoundSlotOffset[index] = slotOffset;
Tobin Ehlis9e142a32014-11-21 12:04:39 -07001798 pthread_mutex_unlock(&globalLock);
Tobin Ehlise79df942014-11-18 16:38:08 -07001799 char str[1024];
1800 sprintf(str, "DS %p bound to DS index %u on pipeline %s", (void*)descriptorSet, index, string_XGL_PIPELINE_BIND_POINT(pipelineBindPoint));
1801 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001802 }
1803 else {
Tobin Ehlise79df942014-11-18 16:38:08 -07001804 char str[1024];
1805 sprintf(str, "Attempt to bind DS %p that doesn't exist!", (void*)descriptorSet);
1806 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_INVALID_DS, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001807 }
1808 nextTable.CmdBindDescriptorSet(cmdBuffer, pipelineBindPoint, index, descriptorSet, slotOffset);
1809}
1810
1811XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindDynamicMemoryView(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, const XGL_MEMORY_VIEW_ATTACH_INFO* pMemView)
1812{
1813 nextTable.CmdBindDynamicMemoryView(cmdBuffer, pipelineBindPoint, pMemView);
1814}
1815
Chia-I Wu3b04af52014-11-08 10:48:20 +08001816XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindVertexData(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset, XGL_UINT binding)
1817{
Tobin Ehlis1affd3c2014-11-25 10:24:15 -07001818 lastVtxBinding = binding;
Chia-I Wu3b04af52014-11-08 10:48:20 +08001819 nextTable.CmdBindVertexData(cmdBuffer, mem, offset, binding);
1820}
1821
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001822XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindIndexData(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset, XGL_INDEX_TYPE indexType)
1823{
1824 nextTable.CmdBindIndexData(cmdBuffer, mem, offset, indexType);
1825}
1826
1827XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBindAttachments(XGL_CMD_BUFFER cmdBuffer, XGL_UINT colorAttachmentCount, const XGL_COLOR_ATTACHMENT_BIND_INFO* pColorAttachments, const XGL_DEPTH_STENCIL_BIND_INFO* pDepthStencilAttachment)
1828{
1829 nextTable.CmdBindAttachments(cmdBuffer, colorAttachmentCount, pColorAttachments, pDepthStencilAttachment);
1830}
1831
1832XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdPrepareMemoryRegions(XGL_CMD_BUFFER cmdBuffer, XGL_UINT transitionCount, const XGL_MEMORY_STATE_TRANSITION* pStateTransitions)
1833{
1834 nextTable.CmdPrepareMemoryRegions(cmdBuffer, transitionCount, pStateTransitions);
1835}
1836
1837XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdPrepareImages(XGL_CMD_BUFFER cmdBuffer, XGL_UINT transitionCount, const XGL_IMAGE_STATE_TRANSITION* pStateTransitions)
1838{
1839 nextTable.CmdPrepareImages(cmdBuffer, transitionCount, pStateTransitions);
1840}
1841
1842XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDraw(XGL_CMD_BUFFER cmdBuffer, XGL_UINT firstVertex, XGL_UINT vertexCount, XGL_UINT firstInstance, XGL_UINT instanceCount)
1843{
Tobin Ehlise79df942014-11-18 16:38:08 -07001844 char str[1024];
1845 sprintf(str, "xglCmdDraw() call #%lu, reporting DS state:", drawCount[DRAW]++);
1846 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001847 synchAndPrintDSConfig();
1848 nextTable.CmdDraw(cmdBuffer, firstVertex, vertexCount, firstInstance, instanceCount);
1849}
1850
1851XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDrawIndexed(XGL_CMD_BUFFER cmdBuffer, XGL_UINT firstIndex, XGL_UINT indexCount, XGL_INT vertexOffset, XGL_UINT firstInstance, XGL_UINT instanceCount)
1852{
Tobin Ehlise79df942014-11-18 16:38:08 -07001853 char str[1024];
Tobin Ehlis62086412014-11-19 16:19:28 -07001854 sprintf(str, "xglCmdDrawIndexed() call #%lu, reporting DS state:", drawCount[DRAW_INDEXED]++);
Tobin Ehlise79df942014-11-18 16:38:08 -07001855 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlisb8154982014-10-27 14:53:17 -06001856 synchAndPrintDSConfig();
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001857 nextTable.CmdDrawIndexed(cmdBuffer, firstIndex, indexCount, vertexOffset, firstInstance, instanceCount);
1858}
1859
1860XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDrawIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset, XGL_UINT32 count, XGL_UINT32 stride)
1861{
Tobin Ehlise79df942014-11-18 16:38:08 -07001862 char str[1024];
Tobin Ehlis62086412014-11-19 16:19:28 -07001863 sprintf(str, "xglCmdDrawIndirect() call #%lu, reporting DS state:", drawCount[DRAW_INDIRECT]++);
Tobin Ehlise79df942014-11-18 16:38:08 -07001864 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlisb8154982014-10-27 14:53:17 -06001865 synchAndPrintDSConfig();
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001866 nextTable.CmdDrawIndirect(cmdBuffer, mem, offset, count, stride);
1867}
1868
1869XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDrawIndexedIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset, XGL_UINT32 count, XGL_UINT32 stride)
1870{
Tobin Ehlise79df942014-11-18 16:38:08 -07001871 char str[1024];
Tobin Ehlis62086412014-11-19 16:19:28 -07001872 sprintf(str, "xglCmdDrawIndexedIndirect() call #%lu, reporting DS state:", drawCount[DRAW_INDEXED_INDIRECT]++);
Tobin Ehlise79df942014-11-18 16:38:08 -07001873 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlisb8154982014-10-27 14:53:17 -06001874 synchAndPrintDSConfig();
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001875 nextTable.CmdDrawIndexedIndirect(cmdBuffer, mem, offset, count, stride);
1876}
1877
1878XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDispatch(XGL_CMD_BUFFER cmdBuffer, XGL_UINT x, XGL_UINT y, XGL_UINT z)
1879{
1880 nextTable.CmdDispatch(cmdBuffer, x, y, z);
1881}
1882
1883XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDispatchIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset)
1884{
1885 nextTable.CmdDispatchIndirect(cmdBuffer, mem, offset);
1886}
1887
1888XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdCopyMemory(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY srcMem, XGL_GPU_MEMORY destMem, XGL_UINT regionCount, const XGL_MEMORY_COPY* pRegions)
1889{
1890 nextTable.CmdCopyMemory(cmdBuffer, srcMem, destMem, regionCount, pRegions);
1891}
1892
1893XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdCopyImage(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_IMAGE destImage, XGL_UINT regionCount, const XGL_IMAGE_COPY* pRegions)
1894{
1895 nextTable.CmdCopyImage(cmdBuffer, srcImage, destImage, regionCount, pRegions);
1896}
1897
1898XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdCopyMemoryToImage(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY srcMem, XGL_IMAGE destImage, XGL_UINT regionCount, const XGL_MEMORY_IMAGE_COPY* pRegions)
1899{
1900 nextTable.CmdCopyMemoryToImage(cmdBuffer, srcMem, destImage, regionCount, pRegions);
1901}
1902
1903XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdCopyImageToMemory(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_GPU_MEMORY destMem, XGL_UINT regionCount, const XGL_MEMORY_IMAGE_COPY* pRegions)
1904{
1905 nextTable.CmdCopyImageToMemory(cmdBuffer, srcImage, destMem, regionCount, pRegions);
1906}
1907
1908XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdCloneImageData(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_IMAGE_STATE srcImageState, XGL_IMAGE destImage, XGL_IMAGE_STATE destImageState)
1909{
1910 nextTable.CmdCloneImageData(cmdBuffer, srcImage, srcImageState, destImage, destImageState);
1911}
1912
1913XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdUpdateMemory(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY destMem, XGL_GPU_SIZE destOffset, XGL_GPU_SIZE dataSize, const XGL_UINT32* pData)
1914{
1915 nextTable.CmdUpdateMemory(cmdBuffer, destMem, destOffset, dataSize, pData);
1916}
1917
1918XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdFillMemory(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY destMem, XGL_GPU_SIZE destOffset, XGL_GPU_SIZE fillSize, XGL_UINT32 data)
1919{
1920 nextTable.CmdFillMemory(cmdBuffer, destMem, destOffset, fillSize, data);
1921}
1922
1923XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdClearColorImage(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE image, const XGL_FLOAT color[4], XGL_UINT rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges)
1924{
1925 nextTable.CmdClearColorImage(cmdBuffer, image, color, rangeCount, pRanges);
1926}
1927
1928XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdClearColorImageRaw(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE image, const XGL_UINT32 color[4], XGL_UINT rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges)
1929{
1930 nextTable.CmdClearColorImageRaw(cmdBuffer, image, color, rangeCount, pRanges);
1931}
1932
1933XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdClearDepthStencil(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE image, XGL_FLOAT depth, XGL_UINT32 stencil, XGL_UINT rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges)
1934{
1935 nextTable.CmdClearDepthStencil(cmdBuffer, image, depth, stencil, rangeCount, pRanges);
1936}
1937
1938XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdResolveImage(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_IMAGE destImage, XGL_UINT rectCount, const XGL_IMAGE_RESOLVE* pRects)
1939{
1940 nextTable.CmdResolveImage(cmdBuffer, srcImage, destImage, rectCount, pRects);
1941}
1942
1943XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdSetEvent(XGL_CMD_BUFFER cmdBuffer, XGL_EVENT event)
1944{
1945 nextTable.CmdSetEvent(cmdBuffer, event);
1946}
1947
1948XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdResetEvent(XGL_CMD_BUFFER cmdBuffer, XGL_EVENT event)
1949{
1950 nextTable.CmdResetEvent(cmdBuffer, event);
1951}
1952
1953XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdMemoryAtomic(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_MEMORY destMem, XGL_GPU_SIZE destOffset, XGL_UINT64 srcData, XGL_ATOMIC_OP atomicOp)
1954{
1955 nextTable.CmdMemoryAtomic(cmdBuffer, destMem, destOffset, srcData, atomicOp);
1956}
1957
1958XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdBeginQuery(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, XGL_UINT slot, XGL_FLAGS flags)
1959{
1960 nextTable.CmdBeginQuery(cmdBuffer, queryPool, slot, flags);
1961}
1962
1963XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdEndQuery(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, XGL_UINT slot)
1964{
1965 nextTable.CmdEndQuery(cmdBuffer, queryPool, slot);
1966}
1967
1968XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdResetQueryPool(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, XGL_UINT startQuery, XGL_UINT queryCount)
1969{
1970 nextTable.CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount);
1971}
1972
1973XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdWriteTimestamp(XGL_CMD_BUFFER cmdBuffer, XGL_TIMESTAMP_TYPE timestampType, XGL_GPU_MEMORY destMem, XGL_GPU_SIZE destOffset)
1974{
1975 nextTable.CmdWriteTimestamp(cmdBuffer, timestampType, destMem, destOffset);
1976}
1977
1978XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdInitAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_UINT startCounter, XGL_UINT counterCount, const XGL_UINT32* pData)
1979{
1980 nextTable.CmdInitAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData);
1981}
1982
1983XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdLoadAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_UINT startCounter, XGL_UINT counterCount, XGL_GPU_MEMORY srcMem, XGL_GPU_SIZE srcOffset)
1984{
1985 nextTable.CmdLoadAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, srcMem, srcOffset);
1986}
1987
1988XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdSaveAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_UINT startCounter, XGL_UINT counterCount, XGL_GPU_MEMORY destMem, XGL_GPU_SIZE destOffset)
1989{
1990 nextTable.CmdSaveAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, destMem, destOffset);
1991}
1992
1993XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetValidationLevel(XGL_DEVICE device, XGL_VALIDATION_LEVEL validationLevel)
1994{
1995 XGL_RESULT result = nextTable.DbgSetValidationLevel(device, validationLevel);
1996 return result;
1997}
1998
1999XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgRegisterMsgCallback(XGL_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, XGL_VOID* pUserData)
2000{
Tobin Ehlise79df942014-11-18 16:38:08 -07002001 // This layer intercepts callbacks
2002 XGL_LAYER_DBG_FUNCTION_NODE *pNewDbgFuncNode = (XGL_LAYER_DBG_FUNCTION_NODE*)malloc(sizeof(XGL_LAYER_DBG_FUNCTION_NODE));
2003 if (!pNewDbgFuncNode)
2004 return XGL_ERROR_OUT_OF_MEMORY;
2005 pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback;
2006 pNewDbgFuncNode->pUserData = pUserData;
Jon Ashburn2e9b5612014-12-22 13:38:27 -07002007 pNewDbgFuncNode->pNext = g_pDbgFunctionHead;
2008 g_pDbgFunctionHead = pNewDbgFuncNode;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002009 XGL_RESULT result = nextTable.DbgRegisterMsgCallback(pfnMsgCallback, pUserData);
2010 return result;
2011}
2012
2013XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgUnregisterMsgCallback(XGL_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback)
2014{
Jon Ashburn2e9b5612014-12-22 13:38:27 -07002015 XGL_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead;
Tobin Ehlise79df942014-11-18 16:38:08 -07002016 XGL_LAYER_DBG_FUNCTION_NODE *pPrev = pTrav;
2017 while (pTrav) {
2018 if (pTrav->pfnMsgCallback == pfnMsgCallback) {
2019 pPrev->pNext = pTrav->pNext;
Jon Ashburn2e9b5612014-12-22 13:38:27 -07002020 if (g_pDbgFunctionHead == pTrav)
2021 g_pDbgFunctionHead = pTrav->pNext;
Tobin Ehlise79df942014-11-18 16:38:08 -07002022 free(pTrav);
2023 break;
2024 }
2025 pPrev = pTrav;
2026 pTrav = pTrav->pNext;
2027 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002028 XGL_RESULT result = nextTable.DbgUnregisterMsgCallback(pfnMsgCallback);
2029 return result;
2030}
2031
2032XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetMessageFilter(XGL_DEVICE device, XGL_INT msgCode, XGL_DBG_MSG_FILTER filter)
2033{
2034 XGL_RESULT result = nextTable.DbgSetMessageFilter(device, msgCode, filter);
2035 return result;
2036}
2037
2038XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetObjectTag(XGL_BASE_OBJECT object, XGL_SIZE tagSize, const XGL_VOID* pTag)
2039{
2040 XGL_RESULT result = nextTable.DbgSetObjectTag(object, tagSize, pTag);
2041 return result;
2042}
2043
2044XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetGlobalOption(XGL_DBG_GLOBAL_OPTION dbgOption, XGL_SIZE dataSize, const XGL_VOID* pData)
2045{
2046 XGL_RESULT result = nextTable.DbgSetGlobalOption(dbgOption, dataSize, pData);
2047 return result;
2048}
2049
2050XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetDeviceOption(XGL_DEVICE device, XGL_DBG_DEVICE_OPTION dbgOption, XGL_SIZE dataSize, const XGL_VOID* pData)
2051{
2052 XGL_RESULT result = nextTable.DbgSetDeviceOption(device, dbgOption, dataSize, pData);
2053 return result;
2054}
2055
2056XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDbgMarkerBegin(XGL_CMD_BUFFER cmdBuffer, const XGL_CHAR* pMarker)
2057{
2058 nextTable.CmdDbgMarkerBegin(cmdBuffer, pMarker);
2059}
2060
2061XGL_LAYER_EXPORT XGL_VOID XGLAPI xglCmdDbgMarkerEnd(XGL_CMD_BUFFER cmdBuffer)
2062{
2063 nextTable.CmdDbgMarkerEnd(cmdBuffer);
2064}
2065
2066XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11AssociateConnection(XGL_PHYSICAL_GPU gpu, const XGL_WSI_X11_CONNECTION_INFO* pConnectionInfo)
2067{
2068 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002069 pCurObj = gpuw;
Jon Ashburn2e9b5612014-12-22 13:38:27 -07002070 pthread_once(&g_initOnce, initDrawState);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002071 XGL_RESULT result = nextTable.WsiX11AssociateConnection((XGL_PHYSICAL_GPU)gpuw->nextObject, pConnectionInfo);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002072 return result;
2073}
2074
Chia-I Wu6204f342014-11-07 13:33:45 +08002075XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11GetMSC(XGL_DEVICE device, xcb_window_t window, xcb_randr_crtc_t crtc, XGL_UINT64* pMsc)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002076{
Chia-I Wu6204f342014-11-07 13:33:45 +08002077 XGL_RESULT result = nextTable.WsiX11GetMSC(device, window, crtc, pMsc);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002078 return result;
2079}
2080
2081XGL_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)
2082{
2083 XGL_RESULT result = nextTable.WsiX11CreatePresentableImage(device, pCreateInfo, pImage, pMem);
2084 return result;
2085}
2086
2087XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11QueuePresent(XGL_QUEUE queue, const XGL_WSI_X11_PRESENT_INFO* pPresentInfo, XGL_FENCE fence)
2088{
2089 XGL_RESULT result = nextTable.WsiX11QueuePresent(queue, pPresentInfo, fence);
2090 return result;
2091}
2092
Tobin Ehlisa701ef02014-11-27 15:43:39 -07002093XGL_VOID drawStateDumpDotFile(char* outFileName)
2094{
2095 dumpDotFile(outFileName);
2096}
2097
Tobin Ehlis266473d2014-12-16 17:34:50 -07002098XGL_VOID drawStateDumpPngFile(char* outFileName)
2099{
2100 char dotExe[32] = "/usr/bin/dot";
2101 if( access(dotExe, X_OK) != -1) {
2102 dumpDotFile("/tmp/tmp.dot");
2103 char dotCmd[1024];
2104 sprintf(dotCmd, "%s /tmp/tmp.dot -Tpng -o %s", dotExe, outFileName);
2105 system(dotCmd);
2106 remove("/tmp/tmp.dot");
2107 }
2108 else {
2109 char str[1024];
2110 sprintf(str, "Cannot execute dot program at (%s) to dump requested %s file.", dotExe, outFileName);
2111 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_MISSING_DOT_PROGRAM, "DS", str);
2112 }
2113}
2114
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002115XGL_LAYER_EXPORT XGL_VOID* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const XGL_CHAR* funcName)
2116{
2117 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
2118 if (gpu == NULL)
2119 return NULL;
2120 pCurObj = gpuw;
Jon Ashburn2e9b5612014-12-22 13:38:27 -07002121 pthread_once(&g_initOnce, initDrawState);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002122
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002123 if (!strncmp("xglGetProcAddr", funcName, sizeof("xglGetProcAddr")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002124 return xglGetProcAddr;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002125 else if (!strncmp("xglInitAndEnumerateGpus", funcName, sizeof("xglInitAndEnumerateGpus")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002126 return nextTable.InitAndEnumerateGpus;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002127 else if (!strncmp("xglGetGpuInfo", funcName, sizeof("xglGetGpuInfo")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002128 return xglGetGpuInfo;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002129 else if (!strncmp("xglCreateDevice", funcName, sizeof("xglCreateDevice")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002130 return xglCreateDevice;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002131 else if (!strncmp("xglDestroyDevice", funcName, sizeof("xglDestroyDevice")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002132 return xglDestroyDevice;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002133 else if (!strncmp("xglGetExtensionSupport", funcName, sizeof("xglGetExtensionSupport")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002134 return xglGetExtensionSupport;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002135 else if (!strncmp("xglEnumerateLayers", funcName, sizeof("xglEnumerateLayers")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002136 return xglEnumerateLayers;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002137 else if (!strncmp("xglGetDeviceQueue", funcName, sizeof("xglGetDeviceQueue")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002138 return xglGetDeviceQueue;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002139 else if (!strncmp("xglQueueSubmit", funcName, sizeof("xglQueueSubmit")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002140 return xglQueueSubmit;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002141 else if (!strncmp("xglQueueSetGlobalMemReferences", funcName, sizeof("xglQueueSetGlobalMemReferences")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002142 return xglQueueSetGlobalMemReferences;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002143 else if (!strncmp("xglQueueWaitIdle", funcName, sizeof("xglQueueWaitIdle")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002144 return xglQueueWaitIdle;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002145 else if (!strncmp("xglDeviceWaitIdle", funcName, sizeof("xglDeviceWaitIdle")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002146 return xglDeviceWaitIdle;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002147 else if (!strncmp("drawStateDumpDotFile", funcName, sizeof("drawStateDumpDotFile")))
Tobin Ehlisa701ef02014-11-27 15:43:39 -07002148 return drawStateDumpDotFile;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002149 else if (!strncmp("drawStateDumpPngFile", funcName, sizeof("drawStateDumpPngFile")))
Tobin Ehlis266473d2014-12-16 17:34:50 -07002150 return drawStateDumpPngFile;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002151 else if (!strncmp("xglGetMemoryHeapCount", funcName, sizeof("xglGetMemoryHeapCount")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002152 return xglGetMemoryHeapCount;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002153 else if (!strncmp("xglGetMemoryHeapInfo", funcName, sizeof("xglGetMemoryHeapInfo")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002154 return xglGetMemoryHeapInfo;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002155 else if (!strncmp("xglAllocMemory", funcName, sizeof("xglAllocMemory")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002156 return xglAllocMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002157 else if (!strncmp("xglFreeMemory", funcName, sizeof("xglFreeMemory")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002158 return xglFreeMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002159 else if (!strncmp("xglSetMemoryPriority", funcName, sizeof("xglSetMemoryPriority")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002160 return xglSetMemoryPriority;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002161 else if (!strncmp("xglMapMemory", funcName, sizeof("xglMapMemory")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002162 return xglMapMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002163 else if (!strncmp("xglUnmapMemory", funcName, sizeof("xglUnmapMemory")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002164 return xglUnmapMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002165 else if (!strncmp("xglPinSystemMemory", funcName, sizeof("xglPinSystemMemory")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002166 return xglPinSystemMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002167 else if (!strncmp("xglRemapVirtualMemoryPages", funcName, sizeof("xglRemapVirtualMemoryPages")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002168 return xglRemapVirtualMemoryPages;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002169 else if (!strncmp("xglGetMultiGpuCompatibility", funcName, sizeof("xglGetMultiGpuCompatibility")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002170 return xglGetMultiGpuCompatibility;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002171 else if (!strncmp("xglOpenSharedMemory", funcName, sizeof("xglOpenSharedMemory")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002172 return xglOpenSharedMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002173 else if (!strncmp("xglOpenSharedQueueSemaphore", funcName, sizeof("xglOpenSharedQueueSemaphore")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002174 return xglOpenSharedQueueSemaphore;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002175 else if (!strncmp("xglOpenPeerMemory", funcName, sizeof("xglOpenPeerMemory")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002176 return xglOpenPeerMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002177 else if (!strncmp("xglOpenPeerImage", funcName, sizeof("xglOpenPeerImage")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002178 return xglOpenPeerImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002179 else if (!strncmp("xglDestroyObject", funcName, sizeof("xglDestroyObject")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002180 return xglDestroyObject;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002181 else if (!strncmp("xglGetObjectInfo", funcName, sizeof("xglGetObjectInfo")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002182 return xglGetObjectInfo;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002183 else if (!strncmp("xglBindObjectMemory", funcName, sizeof("xglBindObjectMemory")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002184 return xglBindObjectMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002185 else if (!strncmp("xglCreateFence", funcName, sizeof("xglCreateFence")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002186 return xglCreateFence;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002187 else if (!strncmp("xglGetFenceStatus", funcName, sizeof("xglGetFenceStatus")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002188 return xglGetFenceStatus;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002189 else if (!strncmp("xglWaitForFences", funcName, sizeof("xglWaitForFences")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002190 return xglWaitForFences;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002191 else if (!strncmp("xglCreateQueueSemaphore", funcName, sizeof("xglCreateQueueSemaphore")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002192 return xglCreateQueueSemaphore;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002193 else if (!strncmp("xglSignalQueueSemaphore", funcName, sizeof("xglSignalQueueSemaphore")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002194 return xglSignalQueueSemaphore;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002195 else if (!strncmp("xglWaitQueueSemaphore", funcName, sizeof("xglWaitQueueSemaphore")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002196 return xglWaitQueueSemaphore;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002197 else if (!strncmp("xglCreateEvent", funcName, sizeof("xglCreateEvent")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002198 return xglCreateEvent;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002199 else if (!strncmp("xglGetEventStatus", funcName, sizeof("xglGetEventStatus")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002200 return xglGetEventStatus;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002201 else if (!strncmp("xglSetEvent", funcName, sizeof("xglSetEvent")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002202 return xglSetEvent;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002203 else if (!strncmp("xglResetEvent", funcName, sizeof("xglResetEvent")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002204 return xglResetEvent;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002205 else if (!strncmp("xglCreateQueryPool", funcName, sizeof("xglCreateQueryPool")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002206 return xglCreateQueryPool;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002207 else if (!strncmp("xglGetQueryPoolResults", funcName, sizeof("xglGetQueryPoolResults")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002208 return xglGetQueryPoolResults;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002209 else if (!strncmp("xglGetFormatInfo", funcName, sizeof("xglGetFormatInfo")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002210 return xglGetFormatInfo;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002211 else if (!strncmp("xglCreateImage", funcName, sizeof("xglCreateImage")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002212 return xglCreateImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002213 else if (!strncmp("xglGetImageSubresourceInfo", funcName, sizeof("xglGetImageSubresourceInfo")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002214 return xglGetImageSubresourceInfo;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002215 else if (!strncmp("xglCreateImageView", funcName, sizeof("xglCreateImageView")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002216 return xglCreateImageView;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002217 else if (!strncmp("xglCreateColorAttachmentView", funcName, sizeof("xglCreateColorAttachmentView")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002218 return xglCreateColorAttachmentView;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002219 else if (!strncmp("xglCreateDepthStencilView", funcName, sizeof("xglCreateDepthStencilView")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002220 return xglCreateDepthStencilView;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002221 else if (!strncmp("xglCreateShader", funcName, sizeof("xglCreateShader")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002222 return xglCreateShader;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002223 else if (!strncmp("xglCreateGraphicsPipeline", funcName, sizeof("xglCreateGraphicsPipeline")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002224 return xglCreateGraphicsPipeline;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002225 else if (!strncmp("xglCreateComputePipeline", funcName, sizeof("xglCreateComputePipeline")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002226 return xglCreateComputePipeline;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002227 else if (!strncmp("xglStorePipeline", funcName, sizeof("xglStorePipeline")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002228 return xglStorePipeline;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002229 else if (!strncmp("xglLoadPipeline", funcName, sizeof("xglLoadPipeline")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002230 return xglLoadPipeline;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002231 else if (!strncmp("xglCreatePipelineDelta", funcName, sizeof("xglCreatePipelineDelta")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002232 return xglCreatePipelineDelta;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002233 else if (!strncmp("xglCreateSampler", funcName, sizeof("xglCreateSampler")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002234 return xglCreateSampler;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002235 else if (!strncmp("xglCreateDescriptorSet", funcName, sizeof("xglCreateDescriptorSet")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002236 return xglCreateDescriptorSet;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002237 else if (!strncmp("xglBeginDescriptorSetUpdate", funcName, sizeof("xglBeginDescriptorSetUpdate")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002238 return xglBeginDescriptorSetUpdate;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002239 else if (!strncmp("xglEndDescriptorSetUpdate", funcName, sizeof("xglEndDescriptorSetUpdate")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002240 return xglEndDescriptorSetUpdate;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002241 else if (!strncmp("xglAttachSamplerDescriptors", funcName, sizeof("xglAttachSamplerDescriptors")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002242 return xglAttachSamplerDescriptors;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002243 else if (!strncmp("xglAttachImageViewDescriptors", funcName, sizeof("xglAttachImageViewDescriptors")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002244 return xglAttachImageViewDescriptors;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002245 else if (!strncmp("xglAttachMemoryViewDescriptors", funcName, sizeof("xglAttachMemoryViewDescriptors")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002246 return xglAttachMemoryViewDescriptors;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002247 else if (!strncmp("xglAttachNestedDescriptors", funcName, sizeof("xglAttachNestedDescriptors")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002248 return xglAttachNestedDescriptors;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002249 else if (!strncmp("xglClearDescriptorSetSlots", funcName, sizeof("xglClearDescriptorSetSlots")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002250 return xglClearDescriptorSetSlots;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002251 else if (!strncmp("xglCreateViewportState", funcName, sizeof("xglCreateViewportState")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002252 return xglCreateViewportState;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002253 else if (!strncmp("xglCreateRasterState", funcName, sizeof("xglCreateRasterState")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002254 return xglCreateRasterState;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002255 else if (!strncmp("xglCreateMsaaState", funcName, sizeof("xglCreateMsaaState")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002256 return xglCreateMsaaState;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002257 else if (!strncmp("xglCreateColorBlendState", funcName, sizeof("xglCreateColorBlendState")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002258 return xglCreateColorBlendState;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002259 else if (!strncmp("xglCreateDepthStencilState", funcName, sizeof("xglCreateDepthStencilState")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002260 return xglCreateDepthStencilState;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002261 else if (!strncmp("xglCreateCommandBuffer", funcName, sizeof("xglCreateCommandBuffer")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002262 return xglCreateCommandBuffer;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002263 else if (!strncmp("xglBeginCommandBuffer", funcName, sizeof("xglBeginCommandBuffer")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002264 return xglBeginCommandBuffer;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002265 else if (!strncmp("xglEndCommandBuffer", funcName, sizeof("xglEndCommandBuffer")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002266 return xglEndCommandBuffer;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002267 else if (!strncmp("xglResetCommandBuffer", funcName, sizeof("xglResetCommandBuffer")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002268 return xglResetCommandBuffer;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002269 else if (!strncmp("xglCmdBindPipeline", funcName, sizeof("xglCmdBindPipeline")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002270 return xglCmdBindPipeline;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002271 else if (!strncmp("xglCmdBindPipelineDelta", funcName, sizeof("xglCmdBindPipelineDelta")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002272 return xglCmdBindPipelineDelta;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002273 else if (!strncmp("xglCmdBindStateObject", funcName, sizeof("xglCmdBindStateObject")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002274 return xglCmdBindStateObject;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002275 else if (!strncmp("xglCmdBindDescriptorSet", funcName, sizeof("xglCmdBindDescriptorSet")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002276 return xglCmdBindDescriptorSet;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002277 else if (!strncmp("xglCmdBindDynamicMemoryView", funcName, sizeof("xglCmdBindDynamicMemoryView")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002278 return xglCmdBindDynamicMemoryView;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002279 else if (!strncmp("xglCmdBindIndexData", funcName, sizeof("xglCmdBindIndexData")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002280 return xglCmdBindIndexData;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002281 else if (!strncmp("xglCmdBindAttachments", funcName, sizeof("xglCmdBindAttachments")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002282 return xglCmdBindAttachments;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002283 else if (!strncmp("xglCmdPrepareMemoryRegions", funcName, sizeof("xglCmdPrepareMemoryRegions")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002284 return xglCmdPrepareMemoryRegions;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002285 else if (!strncmp("xglCmdPrepareImages", funcName, sizeof("xglCmdPrepareImages")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002286 return xglCmdPrepareImages;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002287 else if (!strncmp("xglCmdDraw", funcName, sizeof("xglCmdDraw")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002288 return xglCmdDraw;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002289 else if (!strncmp("xglCmdDrawIndexed", funcName, sizeof("xglCmdDrawIndexed")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002290 return xglCmdDrawIndexed;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002291 else if (!strncmp("xglCmdDrawIndirect", funcName, sizeof("xglCmdDrawIndirect")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002292 return xglCmdDrawIndirect;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002293 else if (!strncmp("xglCmdDrawIndexedIndirect", funcName, sizeof("xglCmdDrawIndexedIndirect")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002294 return xglCmdDrawIndexedIndirect;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002295 else if (!strncmp("xglCmdDispatch", funcName, sizeof("xglCmdDispatch")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002296 return xglCmdDispatch;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002297 else if (!strncmp("xglCmdDispatchIndirect", funcName, sizeof("xglCmdDispatchIndirect")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002298 return xglCmdDispatchIndirect;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002299 else if (!strncmp("xglCmdCopyMemory", funcName, sizeof("xglCmdCopyMemory")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002300 return xglCmdCopyMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002301 else if (!strncmp("xglCmdCopyImage", funcName, sizeof("xglCmdCopyImage")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002302 return xglCmdCopyImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002303 else if (!strncmp("xglCmdCopyMemoryToImage", funcName, sizeof("xglCmdCopyMemoryToImage")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002304 return xglCmdCopyMemoryToImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002305 else if (!strncmp("xglCmdCopyImageToMemory", funcName, sizeof("xglCmdCopyImageToMemory")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002306 return xglCmdCopyImageToMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002307 else if (!strncmp("xglCmdCloneImageData", funcName, sizeof("xglCmdCloneImageData")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002308 return xglCmdCloneImageData;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002309 else if (!strncmp("xglCmdUpdateMemory", funcName, sizeof("xglCmdUpdateMemory")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002310 return xglCmdUpdateMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002311 else if (!strncmp("xglCmdFillMemory", funcName, sizeof("xglCmdFillMemory")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002312 return xglCmdFillMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002313 else if (!strncmp("xglCmdClearColorImage", funcName, sizeof("xglCmdClearColorImage")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002314 return xglCmdClearColorImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002315 else if (!strncmp("xglCmdClearColorImageRaw", funcName, sizeof("xglCmdClearColorImageRaw")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002316 return xglCmdClearColorImageRaw;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002317 else if (!strncmp("xglCmdClearDepthStencil", funcName, sizeof("xglCmdClearDepthStencil")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002318 return xglCmdClearDepthStencil;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002319 else if (!strncmp("xglCmdResolveImage", funcName, sizeof("xglCmdResolveImage")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002320 return xglCmdResolveImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002321 else if (!strncmp("xglCmdSetEvent", funcName, sizeof("xglCmdSetEvent")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002322 return xglCmdSetEvent;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002323 else if (!strncmp("xglCmdResetEvent", funcName, sizeof("xglCmdResetEvent")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002324 return xglCmdResetEvent;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002325 else if (!strncmp("xglCmdMemoryAtomic", funcName, sizeof("xglCmdMemoryAtomic")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002326 return xglCmdMemoryAtomic;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002327 else if (!strncmp("xglCmdBeginQuery", funcName, sizeof("xglCmdBeginQuery")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002328 return xglCmdBeginQuery;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002329 else if (!strncmp("xglCmdEndQuery", funcName, sizeof("xglCmdEndQuery")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002330 return xglCmdEndQuery;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002331 else if (!strncmp("xglCmdResetQueryPool", funcName, sizeof("xglCmdResetQueryPool")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002332 return xglCmdResetQueryPool;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002333 else if (!strncmp("xglCmdWriteTimestamp", funcName, sizeof("xglCmdWriteTimestamp")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002334 return xglCmdWriteTimestamp;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002335 else if (!strncmp("xglCmdInitAtomicCounters", funcName, sizeof("xglCmdInitAtomicCounters")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002336 return xglCmdInitAtomicCounters;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002337 else if (!strncmp("xglCmdLoadAtomicCounters", funcName, sizeof("xglCmdLoadAtomicCounters")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002338 return xglCmdLoadAtomicCounters;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002339 else if (!strncmp("xglCmdSaveAtomicCounters", funcName, sizeof("xglCmdSaveAtomicCounters")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002340 return xglCmdSaveAtomicCounters;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002341 else if (!strncmp("xglDbgSetValidationLevel", funcName, sizeof("xglDbgSetValidationLevel")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002342 return xglDbgSetValidationLevel;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002343 else if (!strncmp("xglDbgRegisterMsgCallback", funcName, sizeof("xglDbgRegisterMsgCallback")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002344 return xglDbgRegisterMsgCallback;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002345 else if (!strncmp("xglDbgUnregisterMsgCallback", funcName, sizeof("xglDbgUnregisterMsgCallback")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002346 return xglDbgUnregisterMsgCallback;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002347 else if (!strncmp("xglDbgSetMessageFilter", funcName, sizeof("xglDbgSetMessageFilter")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002348 return xglDbgSetMessageFilter;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002349 else if (!strncmp("xglDbgSetObjectTag", funcName, sizeof("xglDbgSetObjectTag")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002350 return xglDbgSetObjectTag;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002351 else if (!strncmp("xglDbgSetGlobalOption", funcName, sizeof("xglDbgSetGlobalOption")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002352 return xglDbgSetGlobalOption;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002353 else if (!strncmp("xglDbgSetDeviceOption", funcName, sizeof("xglDbgSetDeviceOption")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002354 return xglDbgSetDeviceOption;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002355 else if (!strncmp("xglCmdDbgMarkerBegin", funcName, sizeof("xglCmdDbgMarkerBegin")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002356 return xglCmdDbgMarkerBegin;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002357 else if (!strncmp("xglCmdDbgMarkerEnd", funcName, sizeof("xglCmdDbgMarkerEnd")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002358 return xglCmdDbgMarkerEnd;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002359 else if (!strncmp("xglWsiX11AssociateConnection", funcName, sizeof("xglWsiX11AssociateConnection")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002360 return xglWsiX11AssociateConnection;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002361 else if (!strncmp("xglWsiX11GetMSC", funcName, sizeof("xglWsiX11GetMSC")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002362 return xglWsiX11GetMSC;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002363 else if (!strncmp("xglWsiX11CreatePresentableImage", funcName, sizeof("xglWsiX11CreatePresentableImage")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002364 return xglWsiX11CreatePresentableImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002365 else if (!strncmp("xglWsiX11QueuePresent", funcName, sizeof("xglWsiX11QueuePresent")))
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002366 return xglWsiX11QueuePresent;
2367 else {
2368 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
2369 if (gpuw->pGPA == NULL)
2370 return NULL;
2371 return gpuw->pGPA(gpuw->nextObject, funcName);
2372 }
2373}
2374