blob: db92eda9c9c7c8638ced99a72510ff8df6541a66 [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>
Ian Elliott81ac44c2015-01-13 17:52:38 -070028#include "loader_platform.h"
Chia-I Wu0f65b1e2015-01-04 23:11:43 +080029#include "xgl_dispatch_table_helper.h"
Chia-I Wu706533e2015-01-05 13:18:57 +080030#include "xgl_generic_intercept_proc_helper.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;
Ian Elliott81ac44c2015-01-13 17:52:38 -070038static LOADER_PLATFORM_THREAD_ONCE_DECLARATION(g_initOnce);
39static int globalLockInitialized = 0;
40static loader_platform_thread_mutex globalLock;
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;
Tobin Ehlis5b7acaa2015-01-08 14:26:53 -070044static XGL_LAYER_DBG_REPORT_LEVEL g_reportingLevel = XGL_DBG_LAYER_LEVEL_INFO;
Jon Ashburn2e9b5612014-12-22 13:38:27 -070045static 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
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060050static void layerCbMsg(XGL_DBG_MSG_TYPE msgType,
Tobin Ehlise79df942014-11-18 16:38:08 -070051 XGL_VALIDATION_LEVEL validationLevel,
52 XGL_BASE_OBJECT srcObject,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060053 size_t location,
54 int32_t 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
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600109static size_t sTypeStructSize(XGL_STRUCTURE_TYPE sType)
Tobin Ehlis26092022014-11-20 09:49:17 -0700110{
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);
Tobin Ehlis2f3726c2015-01-15 17:51:52 -0700123 case XGL_STRUCTURE_TYPE_BUFFER_VIEW_ATTACH_INFO:
124 return sizeof(XGL_BUFFER_VIEW_ATTACH_INFO);
Tobin Ehlis26092022014-11-20 09:49:17 -0700125 case XGL_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO:
126 return sizeof(XGL_IMAGE_VIEW_ATTACH_INFO);
Tobin Ehlis2f3726c2015-01-15 17:51:52 -0700127 case XGL_STRUCTURE_TYPE_EVENT_WAIT_INFO:
128 return sizeof(XGL_EVENT_WAIT_INFO);
Tobin Ehlis26092022014-11-20 09:49:17 -0700129 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);
Tobin Ehlis2f3726c2015-01-15 17:51:52 -0700141 case XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO:
142 return sizeof(XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO);
143 case XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO:
144 return sizeof(XGL_DYNAMIC_VP_STATE_CREATE_INFO);
145 case XGL_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO:
146 return sizeof(XGL_DYNAMIC_RS_STATE_CREATE_INFO);
147 case XGL_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO:
148 return sizeof(XGL_DYNAMIC_CB_STATE_CREATE_INFO);
149 case XGL_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO:
150 return sizeof(XGL_DYNAMIC_DS_STATE_CREATE_INFO);
Tobin Ehlis26092022014-11-20 09:49:17 -0700151 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);
Mark Lobodzinski4eca6972015-01-26 10:34:00 -0600157 case XGL_STRUCTURE_TYPE_QUEUE_SEMAPHORE_CREATE_INFO:
Tobin Ehlis26092022014-11-20 09:49:17 -0700158 return sizeof(XGL_QUEUE_SEMAPHORE_CREATE_INFO);
Mark Lobodzinski4eca6972015-01-26 10:34:00 -0600159 case XGL_STRUCTURE_TYPE_QUEUE_SEMAPHORE_OPEN_INFO:
Tobin Ehlis26092022014-11-20 09:49:17 -0700160 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);
Tobin Ehlis26092022014-11-20 09:49:17 -0700167 case XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO:
168 return sizeof(XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO);
Tobin Ehlis2f3726c2015-01-15 17:51:52 -0700169 case XGL_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO:
170 return sizeof(XGL_PIPELINE_IA_STATE_CREATE_INFO);
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700171 case XGL_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO:
172 return sizeof(XGL_PIPELINE_TESS_STATE_CREATE_INFO);
Tobin Ehlis2f3726c2015-01-15 17:51:52 -0700173 case XGL_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO:
174 return sizeof(XGL_PIPELINE_VP_STATE_CREATE_INFO);
Tobin Ehlis2f3726c2015-01-15 17:51:52 -0700175 case XGL_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO:
176 return sizeof(XGL_PIPELINE_RS_STATE_CREATE_INFO);
177 case XGL_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO:
178 return sizeof(XGL_PIPELINE_MS_STATE_CREATE_INFO);
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700179 case XGL_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO:
180 return sizeof(XGL_PIPELINE_CB_STATE_CREATE_INFO);
Tobin Ehlis2f3726c2015-01-15 17:51:52 -0700181 case XGL_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO:
182 return sizeof(XGL_PIPELINE_DS_STATE_CREATE_INFO);
183 case XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO:
184 return sizeof(XGL_IMAGE_CREATE_INFO);
185 case XGL_STRUCTURE_TYPE_BUFFER_CREATE_INFO:
186 return sizeof(XGL_BUFFER_CREATE_INFO);
187 case XGL_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO:
188 return sizeof(XGL_BUFFER_VIEW_CREATE_INFO);
189 case XGL_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO:
190 return sizeof(XGL_FRAMEBUFFER_CREATE_INFO);
191 case XGL_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO:
192 return sizeof(XGL_CMD_BUFFER_BEGIN_INFO);
193 case XGL_STRUCTURE_TYPE_CMD_BUFFER_GRAPHICS_BEGIN_INFO:
194 return sizeof(XGL_CMD_BUFFER_GRAPHICS_BEGIN_INFO);
195 case XGL_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO:
196 return sizeof(XGL_RENDER_PASS_CREATE_INFO);
Tobin Ehlis26092022014-11-20 09:49:17 -0700197 case XGL_STRUCTURE_TYPE_LAYER_CREATE_INFO:
198 return sizeof(XGL_LAYER_CREATE_INFO);
Tobin Ehlis2f3726c2015-01-15 17:51:52 -0700199 case XGL_STRUCTURE_TYPE_PIPELINE_BARRIER:
200 return sizeof(XGL_PIPELINE_BARRIER);
201 case XGL_STRUCTURE_TYPE_MEMORY_BARRIER:
202 return sizeof(XGL_MEMORY_BARRIER);
203 case XGL_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER:
204 return sizeof(XGL_BUFFER_MEMORY_BARRIER);
205 case XGL_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER:
206 return sizeof(XGL_IMAGE_MEMORY_BARRIER);
207 case XGL_STRUCTURE_TYPE_DESCRIPTOR_REGION_CREATE_INFO:
208 return sizeof(XGL_DESCRIPTOR_REGION_CREATE_INFO);
209 case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS:
210 return sizeof(XGL_UPDATE_SAMPLERS);
211 case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
212 return sizeof(XGL_UPDATE_SAMPLER_TEXTURES);
213 case XGL_STRUCTURE_TYPE_UPDATE_IMAGES:
214 return sizeof(XGL_UPDATE_IMAGES);
215 case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS:
216 return sizeof(XGL_UPDATE_BUFFERS);
217 case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY:
218 return sizeof(XGL_UPDATE_AS_COPY);
219 case XGL_STRUCTURE_TYPE_MEMORY_ALLOC_BUFFER_INFO:
220 return sizeof(XGL_MEMORY_ALLOC_BUFFER_INFO);
221 case XGL_STRUCTURE_TYPE_MEMORY_ALLOC_IMAGE_INFO:
222 return sizeof(XGL_MEMORY_ALLOC_IMAGE_INFO);
Tobin Ehlis26092022014-11-20 09:49:17 -0700223 default:
224 return 0;
225 }
226}
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700227// Return the size of the underlying struct based on sType
228static size_t dynStateCreateInfoSize(XGL_STRUCTURE_TYPE sType)
Tobin Ehlis56a61072014-11-21 08:58:46 -0700229{
230 switch (sType)
231 {
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700232 case XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO:
233 return sizeof(XGL_DYNAMIC_VP_STATE_CREATE_INFO);
234 case XGL_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO:
235 return sizeof(XGL_DYNAMIC_RS_STATE_CREATE_INFO);
236 case XGL_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO:
237 return sizeof(XGL_DYNAMIC_DS_STATE_CREATE_INFO);
238 case XGL_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO:
239 return sizeof(XGL_DYNAMIC_CB_STATE_CREATE_INFO);
Tobin Ehlis56a61072014-11-21 08:58:46 -0700240 default:
241 return 0;
242 }
243}
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600244// Block of code at start here for managing/tracking Pipeline state that this layer cares about
245// Just track 2 shaders for now
Tobin Ehlis26092022014-11-20 09:49:17 -0700246#define XGL_NUM_GRAPHICS_SHADERS XGL_SHADER_STAGE_COMPUTE
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600247#define MAX_SLOTS 2048
Tobin Ehlisb8154982014-10-27 14:53:17 -0600248
249static uint64_t drawCount[NUM_DRAW_TYPES] = {0, 0, 0, 0};
250
Tobin Ehlis56a61072014-11-21 08:58:46 -0700251// 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 -0700252// Then need to synchronize the accesses based on cmd buffer so that if I'm reading state on one cmd buffer, updates
253// to that same cmd buffer by separate thread are not changing state from underneath us
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700254static PIPELINE_NODE* g_pPipelineHead = NULL;
255static SAMPLER_NODE* g_pSamplerHead = NULL;
256static IMAGE_NODE* g_pImageHead = NULL;
257static BUFFER_NODE* g_pBufferHead = NULL;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600258static XGL_PIPELINE lastBoundPipeline = NULL;
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700259#define MAX_BINDING 0xFFFFFFFF
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700260static uint32_t g_lastVtxBinding = MAX_BINDING;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600261
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700262static DYNAMIC_STATE_NODE* g_pDynamicStateHead[XGL_NUM_STATE_BIND_POINT] = {0};
263static DYNAMIC_STATE_NODE* g_pLastBoundDynamicState[XGL_NUM_STATE_BIND_POINT] = {0};
Tobin Ehlis56a61072014-11-21 08:58:46 -0700264
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700265static void insertDynamicState(const XGL_DYNAMIC_STATE_OBJECT state, const GENERIC_HEADER* pCreateInfo, XGL_STATE_BIND_POINT bindPoint)
Tobin Ehlis56a61072014-11-21 08:58:46 -0700266{
Ian Elliott81ac44c2015-01-13 17:52:38 -0700267 loader_platform_thread_lock_mutex(&globalLock);
Tobin Ehlis56a61072014-11-21 08:58:46 -0700268 // Insert new node at head of appropriate LL
269 DYNAMIC_STATE_NODE* pStateNode = (DYNAMIC_STATE_NODE*)malloc(sizeof(DYNAMIC_STATE_NODE));
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700270 pStateNode->pNext = g_pDynamicStateHead[bindPoint];
271 g_pDynamicStateHead[bindPoint] = pStateNode;
Tobin Ehlis56a61072014-11-21 08:58:46 -0700272 pStateNode->stateObj = state;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700273 pStateNode->pCreateInfo = (GENERIC_HEADER*)malloc(dynStateCreateInfoSize(pCreateInfo->sType));
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700274 memcpy(pStateNode->pCreateInfo, pCreateInfo, dynStateCreateInfoSize(pCreateInfo->sType));
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700275 // VP has embedded ptr so need to handle that as special case
276 if (XGL_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO == pCreateInfo->sType) {
277 XGL_DYNAMIC_VP_STATE_CREATE_INFO* pVPCI = (XGL_DYNAMIC_VP_STATE_CREATE_INFO*)pStateNode->pCreateInfo;
278 XGL_VIEWPORT** ppViewports = (XGL_VIEWPORT**)&pVPCI->pViewports;
279 size_t vpSize = sizeof(XGL_VIEWPORT) * pVPCI->viewportCount;
280 if (vpSize) {
281 *ppViewports = (XGL_VIEWPORT*)malloc(vpSize);
282 memcpy(*ppViewports, ((XGL_DYNAMIC_VP_STATE_CREATE_INFO*)pCreateInfo)->pViewports, vpSize);
283 }
284 XGL_RECT** ppScissors = (XGL_RECT**)&pVPCI->pScissors;
285 size_t scSize = sizeof(XGL_RECT) * pVPCI->scissorCount;
286 if (scSize) {
287 *ppScissors = (XGL_RECT*)malloc(scSize);
288 memcpy(*ppScissors, ((XGL_DYNAMIC_VP_STATE_CREATE_INFO*)pCreateInfo)->pScissors, scSize);
289 }
290 }
Ian Elliott81ac44c2015-01-13 17:52:38 -0700291 loader_platform_thread_unlock_mutex(&globalLock);
Tobin Ehlis56a61072014-11-21 08:58:46 -0700292}
293// Set the last bound dynamic state of given type
294// TODO : Need to track this per cmdBuffer and correlate cmdBuffer for Draw w/ last bound for that cmdBuffer?
Tobin Ehlis2f3726c2015-01-15 17:51:52 -0700295static void setLastBoundDynamicState(const XGL_DYNAMIC_STATE_OBJECT state, const XGL_STATE_BIND_POINT sType)
Tobin Ehlis56a61072014-11-21 08:58:46 -0700296{
Ian Elliott81ac44c2015-01-13 17:52:38 -0700297 loader_platform_thread_lock_mutex(&globalLock);
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700298 DYNAMIC_STATE_NODE* pTrav = g_pDynamicStateHead[sType];
Tobin Ehlis56a61072014-11-21 08:58:46 -0700299 while (pTrav && (state != pTrav->stateObj)) {
300 pTrav = pTrav->pNext;
301 }
302 if (!pTrav) {
303 char str[1024];
304 sprintf(str, "Unable to find dynamic state object %p, was it ever created?", (void*)state);
305 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, state, 0, DRAWSTATE_INVALID_DYNAMIC_STATE_OBJECT, "DS", str);
306 }
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700307 g_pLastBoundDynamicState[sType] = pTrav;
Ian Elliott81ac44c2015-01-13 17:52:38 -0700308 loader_platform_thread_unlock_mutex(&globalLock);
Tobin Ehlis56a61072014-11-21 08:58:46 -0700309}
310// Print the last bound dynamic state
311static void printDynamicState()
312{
Ian Elliott81ac44c2015-01-13 17:52:38 -0700313 loader_platform_thread_lock_mutex(&globalLock);
Tobin Ehlis56a61072014-11-21 08:58:46 -0700314 char str[1024];
315 for (uint32_t i = 0; i < XGL_NUM_STATE_BIND_POINT; i++) {
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700316 if (g_pLastBoundDynamicState[i]) {
317 sprintf(str, "Reporting CreateInfo for currently bound %s object %p", string_XGL_STATE_BIND_POINT(i), g_pLastBoundDynamicState[i]->stateObj);
318 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, g_pLastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700319 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, g_pLastBoundDynamicState[i]->stateObj, 0, DRAWSTATE_NONE, "DS", dynamic_display(g_pLastBoundDynamicState[i]->pCreateInfo, " "));
320 break;
Tobin Ehlis56a61072014-11-21 08:58:46 -0700321 }
322 else {
323 sprintf(str, "No dynamic state of type %s bound", string_XGL_STATE_BIND_POINT(i));
324 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", str);
325 }
326 }
Ian Elliott81ac44c2015-01-13 17:52:38 -0700327 loader_platform_thread_unlock_mutex(&globalLock);
Tobin Ehlis56a61072014-11-21 08:58:46 -0700328}
329// Retrieve pipeline node ptr for given pipeline object
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600330static PIPELINE_NODE *getPipeline(XGL_PIPELINE pipeline)
331{
Ian Elliott81ac44c2015-01-13 17:52:38 -0700332 loader_platform_thread_lock_mutex(&globalLock);
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700333 PIPELINE_NODE *pTrav = g_pPipelineHead;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600334 while (pTrav) {
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700335 if (pTrav->pipeline == pipeline) {
Ian Elliott81ac44c2015-01-13 17:52:38 -0700336 loader_platform_thread_unlock_mutex(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600337 return pTrav;
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700338 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600339 pTrav = pTrav->pNext;
340 }
Ian Elliott81ac44c2015-01-13 17:52:38 -0700341 loader_platform_thread_unlock_mutex(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600342 return NULL;
343}
344
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -0700345// For given sampler, return a ptr to its Create Info struct, or NULL if sampler not found
346static XGL_SAMPLER_CREATE_INFO* getSamplerCreateInfo(const XGL_SAMPLER sampler)
347{
Ian Elliott81ac44c2015-01-13 17:52:38 -0700348 loader_platform_thread_lock_mutex(&globalLock);
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700349 SAMPLER_NODE *pTrav = g_pSamplerHead;
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -0700350 while (pTrav) {
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700351 if (sampler == pTrav->sampler) {
Ian Elliott81ac44c2015-01-13 17:52:38 -0700352 loader_platform_thread_unlock_mutex(&globalLock);
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -0700353 return &pTrav->createInfo;
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700354 }
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -0700355 pTrav = pTrav->pNext;
356 }
Ian Elliott81ac44c2015-01-13 17:52:38 -0700357 loader_platform_thread_unlock_mutex(&globalLock);
Tobin Ehlis5a1d9f32014-11-20 10:48:56 -0700358 return NULL;
359}
360
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600361// Init the pipeline mapping info based on pipeline create info LL tree
Tobin Ehlis9e142a32014-11-21 12:04:39 -0700362// Threading note : Calls to this function should wrapped in mutex
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600363static void initPipeline(PIPELINE_NODE *pPipeline, const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo)
364{
Tobin Ehlis26092022014-11-20 09:49:17 -0700365 // First init create info, we'll shadow the structs as we go down the tree
Tobin Ehlis56a61072014-11-21 08:58:46 -0700366 pPipeline->pCreateTree = (XGL_GRAPHICS_PIPELINE_CREATE_INFO*)malloc(sizeof(XGL_GRAPHICS_PIPELINE_CREATE_INFO));
Tobin Ehlis26092022014-11-20 09:49:17 -0700367 memcpy(pPipeline->pCreateTree, pCreateInfo, sizeof(XGL_GRAPHICS_PIPELINE_CREATE_INFO));
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700368 GENERIC_HEADER *pShadowTrav = (GENERIC_HEADER*)pPipeline->pCreateTree;
369 GENERIC_HEADER *pTrav = (GENERIC_HEADER*)pCreateInfo->pNext;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600370 while (pTrav) {
Tobin Ehlis26092022014-11-20 09:49:17 -0700371 // Shadow the struct
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700372 pShadowTrav->pNext = (GENERIC_HEADER*)malloc(sTypeStructSize(pTrav->sType));
Tobin Ehlis26092022014-11-20 09:49:17 -0700373 // Typically pNext is const so have to cast to avoid warning when we modify it here
374 memcpy((void*)pShadowTrav->pNext, pTrav, sTypeStructSize(pTrav->sType));
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700375 pShadowTrav = (GENERIC_HEADER*)pShadowTrav->pNext;
376 // Special copy of Vtx info as it has embedded array
377 if (XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO == pTrav->sType) {
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700378 XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO *pVICI = (XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO*)pShadowTrav;
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700379 pPipeline->vtxBindingCount = pVICI->bindingCount;
380 uint32_t allocSize = pPipeline->vtxBindingCount * sizeof(XGL_VERTEX_INPUT_BINDING_DESCRIPTION);
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700381 if (allocSize) {
382 pPipeline->pVertexBindingDescriptions = (XGL_VERTEX_INPUT_BINDING_DESCRIPTION*)malloc(allocSize);
383 memcpy(pPipeline->pVertexBindingDescriptions, ((XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO*)pTrav)->pVertexAttributeDescriptions, allocSize);
384 }
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700385 pPipeline->vtxAttributeCount = pVICI->attributeCount;
386 allocSize = pPipeline->vtxAttributeCount * sizeof(XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION);
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700387 if (allocSize) {
388 pPipeline->pVertexAttributeDescriptions = (XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION*)malloc(allocSize);
389 memcpy(pPipeline->pVertexAttributeDescriptions, ((XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO*)pTrav)->pVertexAttributeDescriptions, allocSize);
390 }
391 }
392 else if (XGL_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO == pTrav->sType) {
393 // Special copy of CB state as it has embedded array
394 XGL_PIPELINE_CB_STATE_CREATE_INFO *pCBCI = (XGL_PIPELINE_CB_STATE_CREATE_INFO*)pShadowTrav;
395 pPipeline->attachmentCount = pCBCI->attachmentCount;
396 uint32_t allocSize = pPipeline->attachmentCount * sizeof(XGL_PIPELINE_CB_ATTACHMENT_STATE);
397 if (allocSize) {
398 pPipeline->pAttachments = (XGL_PIPELINE_CB_ATTACHMENT_STATE*)malloc(allocSize);
399 XGL_PIPELINE_CB_ATTACHMENT_STATE** ppAttachments = (XGL_PIPELINE_CB_ATTACHMENT_STATE**)&pCBCI->pAttachments;
400 *ppAttachments = pPipeline->pAttachments;
401 memcpy(pPipeline->pAttachments, ((XGL_PIPELINE_CB_STATE_CREATE_INFO*)pTrav)->pAttachments, allocSize);
402 }
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700403 }
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700404 pTrav = (GENERIC_HEADER*)pTrav->pNext;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600405 }
406}
407
408// Block of code at start here specifically for managing/tracking DSs
Tobin Ehlis9e3d7532014-10-27 17:12:54 -0600409
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700410// ptr to HEAD of LL of DS Regions
411static REGION_NODE* g_pRegionHead = NULL;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700412// ptr to HEAD of LL of top-level Layouts
413static LAYOUT_NODE* g_pLayoutHead = NULL;
Tobin Ehliseacc64f2014-11-24 17:09:09 -0700414// Last DS that was bound, and slotOffset for the binding
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700415static XGL_DESCRIPTOR_SET g_lastBoundDS = NULL;
Tobin Ehlis2f3726c2015-01-15 17:51:52 -0700416
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700417// Return Region node ptr for specified region or else NULL
418static REGION_NODE* getRegionNode(XGL_DESCRIPTOR_REGION region)
419{
420 pthread_mutex_lock(&globalLock);
421 REGION_NODE* pTrav = g_pRegionHead;
422 while (pTrav) {
423 if (pTrav->region == region) {
424 pthread_mutex_unlock(&globalLock);
425 return pTrav;
426 }
427 pTrav = pTrav->pNext;
428 }
429 pthread_mutex_unlock(&globalLock);
430 return NULL;
431}
432
433// Return Set node ptr for specified set or else NULL
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700434static SET_NODE* getSetNode(XGL_DESCRIPTOR_SET set)
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700435{
436 pthread_mutex_lock(&globalLock);
437 REGION_NODE* pTrav = g_pRegionHead;
438 while (pTrav) {
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700439 SET_NODE* pSet = pTrav->pSets;
440 while (pSet) {
441 if (pSet->set == set) {
442 pthread_mutex_unlock(&globalLock);
443 return pSet;
444 }
445 pSet = pSet->pNext;
446 }
447 pTrav = pTrav->pNext;
448 }
449 pthread_mutex_unlock(&globalLock);
450 return NULL;
451}
452
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700453// Return XGL_TRUE if DS Exists and is within an xglBeginDescriptorRegionUpdate() call sequence, otherwise XGL_FALSE
454static bool32_t dsUpdateActive(XGL_DESCRIPTOR_SET ds)
455{
456 SET_NODE* pTrav = getSetNode(ds);
457 if (pTrav) {
458 REGION_NODE* pRegion = NULL;
459 pRegion = getRegionNode(pTrav->region);
460 if (pRegion) {
461 return pRegion->updateActive;
462 }
463 }
464 return XGL_FALSE;
465}
466
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700467static LAYOUT_NODE* getLayoutNode(XGL_DESCRIPTOR_SET_LAYOUT layout) {
468 pthread_mutex_lock(&globalLock);
469 LAYOUT_NODE* pTrav = g_pLayoutHead;
470 while (pTrav) {
471 if (pTrav->layout == layout) {
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700472 pthread_mutex_unlock(&globalLock);
473 return pTrav;
474 }
475 pTrav = pTrav->pNext;
476 }
477 pthread_mutex_unlock(&globalLock);
478 return NULL;
479}
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600480
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700481static uint32_t getUpdateIndex(GENERIC_HEADER* pUpdateStruct)
482{
483 switch (pUpdateStruct->sType)
484 {
485 case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS:
486 return ((XGL_UPDATE_SAMPLERS*)pUpdateStruct)->index;
487 case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
488 return ((XGL_UPDATE_SAMPLER_TEXTURES*)pUpdateStruct)->index;
489 case XGL_STRUCTURE_TYPE_UPDATE_IMAGES:
490 return ((XGL_UPDATE_IMAGES*)pUpdateStruct)->index;
491 case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS:
492 return ((XGL_UPDATE_BUFFERS*)pUpdateStruct)->index;
493 case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY:
494 return ((XGL_UPDATE_AS_COPY*)pUpdateStruct)->descriptorIndex;
495 default:
496 // TODO : Flag specific error for this case
497 return 0;
498 }
499}
500
501static uint32_t getUpdateUpperBound(GENERIC_HEADER* pUpdateStruct)
502{
503 switch (pUpdateStruct->sType)
504 {
505 case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS:
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700506 return (((XGL_UPDATE_SAMPLERS*)pUpdateStruct)->count + ((XGL_UPDATE_SAMPLERS*)pUpdateStruct)->index) - 1;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700507 case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700508 return (((XGL_UPDATE_SAMPLER_TEXTURES*)pUpdateStruct)->count + ((XGL_UPDATE_SAMPLER_TEXTURES*)pUpdateStruct)->index) - 1;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700509 case XGL_STRUCTURE_TYPE_UPDATE_IMAGES:
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700510 return (((XGL_UPDATE_IMAGES*)pUpdateStruct)->count + ((XGL_UPDATE_IMAGES*)pUpdateStruct)->index) - 1;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700511 case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS:
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700512 return (((XGL_UPDATE_BUFFERS*)pUpdateStruct)->count + ((XGL_UPDATE_BUFFERS*)pUpdateStruct)->index) - 1;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700513 case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY:
514 // TODO : Need to understand this case better and make sure code is correct
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700515 return (((XGL_UPDATE_AS_COPY*)pUpdateStruct)->count + ((XGL_UPDATE_AS_COPY*)pUpdateStruct)->descriptorIndex) - 1;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700516 default:
517 // TODO : Flag specific error for this case
518 return 0;
519 }
520}
521
522// Verify that the descriptor type in the update struct matches what's expected by the layout
523static bool32_t validateUpdateType(GENERIC_HEADER* pUpdateStruct, XGL_DESCRIPTOR_TYPE type)
524{
525 // First get actual type of update
526 XGL_DESCRIPTOR_TYPE actualType;
527 switch (pUpdateStruct->sType)
528 {
529 case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS:
530 actualType = XGL_DESCRIPTOR_TYPE_SAMPLER;
531 break;
532 case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
533 actualType = XGL_DESCRIPTOR_TYPE_SAMPLER_TEXTURE;
534 break;
535 case XGL_STRUCTURE_TYPE_UPDATE_IMAGES:
536 actualType = ((XGL_UPDATE_IMAGES*)pUpdateStruct)->descriptorType;
537 break;
538 case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS:
539 actualType = ((XGL_UPDATE_BUFFERS*)pUpdateStruct)->descriptorType;
540 break;
541 case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY:
542 actualType = ((XGL_UPDATE_AS_COPY*)pUpdateStruct)->descriptorType;
543 break;
544 default:
545 // TODO : Flag specific error for this case
546 return 0;
547 }
548 if (actualType == type)
549 return 1;
550 return 0;
551}
552
553// Verify that update region for this update does not exceed max layout index for this type
554static bool32_t validateUpdateSize(GENERIC_HEADER* pUpdateStruct, uint32_t layoutIdx)
555{
556 if (getUpdateUpperBound(pUpdateStruct) > layoutIdx)
557 return 0;
558 return 1;
559}
560
561// Determine the update type, allocate a new struct of that type, shadow the given pUpdate
562// struct into the new struct and return ptr to shadow struct cast as GENERIC_HEADER
563static GENERIC_HEADER* shadowUpdateNode(GENERIC_HEADER* pUpdate)
564{
565 GENERIC_HEADER* pNewNode = NULL;
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700566 size_t array_size = 0;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700567 switch (pUpdate->sType)
568 {
569 case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS:
570 pNewNode = (GENERIC_HEADER*)malloc(sizeof(XGL_UPDATE_SAMPLERS));
571 memcpy(pNewNode, pUpdate, sizeof(XGL_UPDATE_SAMPLERS));
572 array_size = sizeof(XGL_SAMPLER) * ((XGL_UPDATE_SAMPLERS*)pNewNode)->count;
573 ((XGL_UPDATE_SAMPLERS*)pNewNode)->pSamplers = (XGL_SAMPLER*)malloc(array_size);
574 memcpy((XGL_SAMPLER*)((XGL_UPDATE_SAMPLERS*)pNewNode)->pSamplers, ((XGL_UPDATE_SAMPLERS*)pUpdate)->pSamplers, array_size);
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700575 break;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700576 case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
577 pNewNode = (GENERIC_HEADER*)malloc(sizeof(XGL_UPDATE_SAMPLER_TEXTURES));
578 memcpy(pNewNode, pUpdate, sizeof(XGL_UPDATE_SAMPLER_TEXTURES));
579 array_size = sizeof(XGL_SAMPLER_IMAGE_VIEW_INFO) * ((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->count;
580 ((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->pSamplerImageViews = (XGL_SAMPLER_IMAGE_VIEW_INFO*)malloc(array_size);
581 for (uint32_t i = 0; i < ((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->count; i++) {
582 memcpy((XGL_SAMPLER_IMAGE_VIEW_INFO*)&((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->pSamplerImageViews[i], &((XGL_UPDATE_SAMPLER_TEXTURES*)pUpdate)->pSamplerImageViews[i], sizeof(XGL_SAMPLER_IMAGE_VIEW_INFO));
583 ((XGL_SAMPLER_IMAGE_VIEW_INFO*)((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->pSamplerImageViews)[i].pImageView = malloc(sizeof(XGL_IMAGE_VIEW_ATTACH_INFO));
584 memcpy((XGL_IMAGE_VIEW_ATTACH_INFO*)((XGL_UPDATE_SAMPLER_TEXTURES*)pNewNode)->pSamplerImageViews[i].pImageView, ((XGL_UPDATE_SAMPLER_TEXTURES*)pUpdate)->pSamplerImageViews[i].pImageView, sizeof(XGL_IMAGE_VIEW_ATTACH_INFO));
585 }
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700586 break;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700587 case XGL_STRUCTURE_TYPE_UPDATE_IMAGES:
588 pNewNode = (GENERIC_HEADER*)malloc(sizeof(XGL_UPDATE_IMAGES));
589 memcpy(pNewNode, pUpdate, sizeof(XGL_UPDATE_IMAGES));
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700590 size_t base_array_size = sizeof(XGL_IMAGE_VIEW_ATTACH_INFO*) * ((XGL_UPDATE_IMAGES*)pNewNode)->count;
591 size_t total_array_size = (sizeof(XGL_IMAGE_VIEW_ATTACH_INFO) * ((XGL_UPDATE_IMAGES*)pNewNode)->count) + base_array_size;
592 // TODO : Need to validate if this data structure is being copied correctly
593 XGL_IMAGE_VIEW_ATTACH_INFO*** pppLocalImageViews = (XGL_IMAGE_VIEW_ATTACH_INFO***)&((XGL_UPDATE_IMAGES*)pNewNode)->pImageViews;
594 *pppLocalImageViews = (XGL_IMAGE_VIEW_ATTACH_INFO**)malloc(total_array_size);
595 for (uint32_t i = 0; i < ((XGL_UPDATE_IMAGES*)pNewNode)->count; i++) {
596 //((XGL_UPDATE_IMAGES*)pNewNode)->pImageViews = (XGL_IMAGE_VIEW_ATTACH_INFO**)malloc(total_array_size);
597 *pppLocalImageViews[i] = *pppLocalImageViews + base_array_size + (i * sizeof(XGL_IMAGE_VIEW_ATTACH_INFO));
598 memcpy(*pppLocalImageViews[i], ((XGL_UPDATE_IMAGES*)pUpdate)->pImageViews[i], sizeof(XGL_IMAGE_VIEW_ATTACH_INFO));
599 }
600 break;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700601 case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS:
602 pNewNode = (GENERIC_HEADER*)malloc(sizeof(XGL_UPDATE_BUFFERS));
603 memcpy(pNewNode, pUpdate, sizeof(XGL_UPDATE_BUFFERS));
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700604 array_size = (sizeof(XGL_BUFFER_VIEW_ATTACH_INFO) + sizeof(XGL_BUFFER_VIEW_ATTACH_INFO*)) * ((XGL_UPDATE_BUFFERS*)pNewNode)->count;
605 // TODO : Dual-level copy required here. This is an array of pointers.
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700606 ((XGL_UPDATE_BUFFERS*)pNewNode)->pBufferViews = (XGL_BUFFER_VIEW_ATTACH_INFO*)malloc(array_size);
607 memcpy((XGL_BUFFER_VIEW_ATTACH_INFO*)((XGL_UPDATE_BUFFERS*)pNewNode)->pBufferViews, ((XGL_UPDATE_BUFFERS*)pUpdate)->pBufferViews, array_size);
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700608 break;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700609 case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY:
610 pNewNode = (GENERIC_HEADER*)malloc(sizeof(XGL_UPDATE_AS_COPY));
611 memcpy(pNewNode, pUpdate, sizeof(XGL_UPDATE_AS_COPY));
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700612 break;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700613 default:
614 // TODO : Flag specific error for this case
615 return NULL;
616 }
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700617 // Make sure that pNext for the end of shadow copy is NULL
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700618 pNewNode->pNext = NULL;
619 return pNewNode;
620}
621// For given ds, update it's mapping based on pUpdateChain linked-list
622static void dsUpdate(XGL_DESCRIPTOR_SET ds, GENERIC_HEADER* pUpdateChain)
623{
624 SET_NODE* pSet = getSetNode(ds);
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700625 LAYOUT_NODE* pLayout = NULL;
626 XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pLayoutCI;
627 // TODO : If pCIList is NULL, flag error
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700628 GENERIC_HEADER* pUpdates = pUpdateChain;
629 // Perform all updates
630 while (pUpdates) {
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700631 pLayout = pSet->pLayouts;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700632 // For each update first find the layout section that it overlaps
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700633 while (pLayout && (pLayout->startIndex > getUpdateIndex(pUpdates))) {
634 pLayout = pLayout->pPriorSetLayout;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700635 }
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700636 if (!pLayout) {
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700637 char str[1024];
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700638 sprintf(str, "Descriptor Set %p does not have index to match update index %u for update type %s!", ds, getUpdateIndex(pUpdates), string_XGL_STRUCTURE_TYPE(pUpdates->sType));
639 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_INVALID_UPDATE_INDEX, "DS", str);
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700640 }
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700641 else {
642 pLayoutCI = (XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO*)pLayout->pCreateInfoList;
643 // Now verify that update is of the right type
644 if (!validateUpdateType(pUpdates, pLayoutCI->descriptorType)) {
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700645 char str[1024];
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700646 sprintf(str, "Descriptor update type of %s does not match overlapping layout type of %s!", string_XGL_STRUCTURE_TYPE(pUpdates->sType), string_XGL_DESCRIPTOR_TYPE(pLayoutCI->descriptorType));
647 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_DESCRIPTOR_TYPE_MISMATCH, "DS", str);
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700648 }
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700649 else { // TODO : should we skip update on a type mismatch or force it?
650 // Next verify that update is correct size
651 if (!validateUpdateSize(pUpdates, pLayout->endIndex)) {
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700652 char str[1024];
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700653 sprintf(str, "Descriptor update type of %s is out of bounds for matching layout w/ CI:\n%s!", string_XGL_STRUCTURE_TYPE(pUpdates->sType), xgl_print_xgl_descriptor_set_layout_create_info(pLayoutCI, "{DS} "));
654 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_DESCRIPTOR_UPDATE_OUT_OF_BOUNDS, "DS", str);
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700655 }
656 else {
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700657 // Finally perform the update
658 // TODO : Info message that update successful
659 GENERIC_HEADER* pUpdateInsert = pSet->pUpdateStructs;
660 GENERIC_HEADER* pPrev = pUpdateInsert;
661 // Create new update struct for this set's shadow copy
662 GENERIC_HEADER* pNewNode = shadowUpdateNode(pUpdates);
663 if (NULL == pNewNode) {
664 char str[1024];
665 sprintf(str, "Out of memory while attempting to allocate UPDATE struct in xglUpdateDescriptors()");
666 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, ds, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str);
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700667 }
668 else {
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700669 if (!pUpdateInsert) {
670 pSet->pUpdateStructs = pNewNode;
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700671 }
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700672 else {
673 // Find either the existing, matching region, or end of list for initial update chain
674 // TODO : Need to validate this, I suspect there are holes in my algorithm
675 uint32_t totalIndex = 0;
676 while (pUpdateInsert && (getUpdateIndex(pUpdates) != totalIndex)) {
677 totalIndex = getUpdateUpperBound(pUpdates);
678 pPrev = pUpdateInsert;
679 pUpdateInsert = (GENERIC_HEADER*)pUpdateInsert->pNext;
680 }
681 pPrev->pNext = pNewNode;
682 }
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700683 }
684 }
685 }
686 }
687 pUpdates = (GENERIC_HEADER*)pUpdates->pNext;
688 }
689}
690// Free a shadowed update node
691static void freeShadowUpdateNode(GENERIC_HEADER* pUpdate)
692{
693 switch (pUpdate->sType)
694 {
695 case XGL_STRUCTURE_TYPE_UPDATE_SAMPLERS:
696 free((XGL_SAMPLER*)((XGL_UPDATE_SAMPLERS*)pUpdate)->pSamplers);
697 free(pUpdate);
698 break;
699 case XGL_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:
700 for (uint32_t i = 0; i < ((XGL_UPDATE_SAMPLER_TEXTURES*)pUpdate)->count; i++) {
701 free((XGL_IMAGE_VIEW_ATTACH_INFO*)(((XGL_UPDATE_SAMPLER_TEXTURES*)pUpdate)->pSamplerImageViews[i].pImageView));
702 }
703 free((XGL_SAMPLER_IMAGE_VIEW_INFO*)((XGL_UPDATE_SAMPLER_TEXTURES*)pUpdate)->pSamplerImageViews);
704 free(pUpdate);
705 break;
706 case XGL_STRUCTURE_TYPE_UPDATE_IMAGES:
707 free((XGL_IMAGE_VIEW_ATTACH_INFO*)((XGL_UPDATE_IMAGES*)pUpdate)->pImageViews);
708 free(pUpdate);
709 break;
710 case XGL_STRUCTURE_TYPE_UPDATE_BUFFERS:
711 free((XGL_BUFFER_VIEW_ATTACH_INFO*)((XGL_UPDATE_BUFFERS*)pUpdate)->pBufferViews);
712 free(pUpdate);
713 break;
714 case XGL_STRUCTURE_TYPE_UPDATE_AS_COPY:
715 free(pUpdate);
716 break;
717 default:
718 // TODO : Flag specific error for this case
719 break;
720 }
721}
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700722// Currently clearing a set is removing all previous updates to that set
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700723// TODO : Validate if this is correct clearing behavior
724static void clearDescriptorSet(XGL_DESCRIPTOR_SET set)
725{
726 SET_NODE* pSet = getSetNode(set);
727 if (!pSet) {
728 // TODO : Return error
729 }
730 else {
731 GENERIC_HEADER* pUpdate = pSet->pUpdateStructs;
732 GENERIC_HEADER* pFreeMe = pUpdate;
733 while (pUpdate) {
734 pFreeMe = pUpdate;
735 pUpdate = (GENERIC_HEADER*)pUpdate->pNext;
736 freeShadowUpdateNode(pFreeMe);
737 }
738 }
739}
740
741static void clearDescriptorRegion(XGL_DESCRIPTOR_REGION region)
742{
743 REGION_NODE* pRegion = getRegionNode(region);
744 if (!pRegion) {
745 char str[1024];
746 sprintf(str, "Unable to find region node for region %p specified in xglClearDescriptorRegion() call", (void*)region);
747 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, region, 0, DRAWSTATE_INVALID_REGION, "DS", str);
748 }
749 else
750 {
751 // For every set off of this region, clear it
752 SET_NODE* pSet = pRegion->pSets;
753 while (pSet) {
754 clearDescriptorSet(pSet->set);
755 }
756 }
757}
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600758
Tobin Ehlis56a61072014-11-21 08:58:46 -0700759// Print the last bound Gfx Pipeline
760static void printPipeline()
761{
762 PIPELINE_NODE *pPipeTrav = getPipeline(lastBoundPipeline);
763 if (!pPipeTrav) {
764 // nothing to print
765 }
766 else {
767 char* pipeStr = xgl_print_xgl_graphics_pipeline_create_info(pPipeTrav->pCreateTree, "{DS}");
768 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", pipeStr);
769 }
770}
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700771// Dump subgraph w/ DS info
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700772/*
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700773static void dsDumpDot(FILE* pOutFile)
774{
775 const int i = 0; // hard-coding to just the first DS index for now
776 uint32_t skipUnusedCount = 0; // track consecutive unused slots for minimal reporting
Tobin Ehlis2f3726c2015-01-15 17:51:52 -0700777 DS_LL_HEAD *pDS = getDS(lastBoundDS);
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700778 if (pDS) {
779 fprintf(pOutFile, "subgraph DS_SLOTS\n{\nlabel=\"DS0 Slots\"\n");
780 // First create simple array node as central DS reference point
781 fprintf(pOutFile, "\"DS0_MEMORY\" [\nlabel = <<TABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"> <TR><TD PORT=\"ds2\">DS0 Memory</TD></TR>");
782 uint32_t j;
783 char label[1024];
784 for (j = 0; j < pDS->numSlots; j++) {
Tobin Ehlisf1c468a2014-12-09 17:00:33 -0700785 // Don't draw unused slots
786 if (0 != pDS->dsSlot[j].activeMapping)
787 fprintf(pOutFile, "<TR><TD PORT=\"slot%u\">slot%u</TD></TR>", j, j);
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700788 }
789 fprintf(pOutFile, "</TABLE>>\n];\n");
790 // Now tie each slot to its info
791 for (j = 0; j < pDS->numSlots; j++) {
792 switch (pDS->dsSlot[j].activeMapping)
793 {
794 case MAPPING_MEMORY:
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700795 sprintf(label, "MemAttachInfo Slot%u", j);
Tobin Ehlis2f3726c2015-01-15 17:51:52 -0700796 fprintf(pOutFile, "%s", xgl_gv_print_xgl_memory_view_attach_info(&pDS->dsSlot[j].buffView, label));
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700797 fprintf(pOutFile, "\"DS0_MEMORY\":slot%u -> \"%s\" [];\n", j, label);
798 break;
799 case MAPPING_IMAGE:
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700800 sprintf(label, "ImageAttachInfo Slot%u", j);
801 fprintf(pOutFile, "%s", xgl_gv_print_xgl_image_view_attach_info(&pDS->dsSlot[j].imageView, label));
802 fprintf(pOutFile, "\"DS0_MEMORY\":slot%u -> \"%s\" [];\n", j, label);
803 break;
804 case MAPPING_SAMPLER:
Tobin Ehlis2836a7d2015-01-08 15:22:32 -0700805 sprintf(label, "SamplerAttachInfo Slot%u", j);
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700806 fprintf(pOutFile, "%s", xgl_gv_print_xgl_sampler_create_info(getSamplerCreateInfo(pDS->dsSlot[j].sampler), label));
807 fprintf(pOutFile, "\"DS0_MEMORY\":slot%u -> \"%s\" [];\n", j, label);
808 break;
809 default:
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700810 skipUnusedCount++;
811 break;
812 }
813
814 }
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700815 fprintf(pOutFile, "}\n");
816 }
817}
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700818*/
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700819// Dump a GraphViz dot file showing the pipeline
820static void dumpDotFile(char *outFileName)
821{
822 PIPELINE_NODE *pPipeTrav = getPipeline(lastBoundPipeline);
823 if (pPipeTrav) {
824 FILE* pOutFile;
825 pOutFile = fopen(outFileName, "w");
826 fprintf(pOutFile, "digraph g {\ngraph [\nrankdir = \"TB\"\n];\nnode [\nfontsize = \"16\"\nshape = \"plaintext\"\n];\nedge [\n];\n");
827 fprintf(pOutFile, "subgraph PipelineStateObject\n{\nlabel=\"Pipeline State Object\"\n");
828 fprintf(pOutFile, "%s", xgl_gv_print_xgl_graphics_pipeline_create_info(pPipeTrav->pCreateTree, "PSO HEAD"));
829 fprintf(pOutFile, "}\n");
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700830 fprintf(pOutFile, "subgraph dynamicState\n{\nlabel=\"Non-Orthogonal XGL State\"\n");
831 for (uint32_t i = 0; i < XGL_NUM_STATE_BIND_POINT; i++) {
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700832 if (g_pLastBoundDynamicState[i]) {
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700833 fprintf(pOutFile, "%s", dynamic_gv_display(g_pLastBoundDynamicState[i]->pCreateInfo, string_XGL_STATE_BIND_POINT(i)));
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700834 }
835 }
836 fprintf(pOutFile, "}\n"); // close dynamicState subgraph
Tobin Ehlis41415bb2015-01-22 10:45:21 -0700837 //dsDumpDot(pOutFile);
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700838 fprintf(pOutFile, "}\n"); // close main graph "g"
839 fclose(pOutFile);
840 }
841}
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600842// Synch up currently bound pipeline settings with DS mappings
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700843// TODO : Update name. We don't really have to "synch" the descriptors anymore and "mapping" is outdated as well.
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600844static void synchDSMapping()
845{
846 // First verify that we have a bound pipeline
847 PIPELINE_NODE *pPipeTrav = getPipeline(lastBoundPipeline);
Tobin Ehlise79df942014-11-18 16:38:08 -0700848 char str[1024];
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600849 if (!pPipeTrav) {
Tobin Ehlise79df942014-11-18 16:38:08 -0700850 sprintf(str, "Can't find last bound Pipeline %p!", (void*)lastBoundPipeline);
851 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NO_PIPELINE_BOUND, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600852 }
853 else {
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700854 // Verify Vtx binding
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700855 if (MAX_BINDING != g_lastVtxBinding) {
856 if (g_lastVtxBinding >= pPipeTrav->vtxBindingCount) {
857 sprintf(str, "Vtx binding Index of %u exceeds PSO pVertexBindingDescriptions max array index of %u.", g_lastVtxBinding, (pPipeTrav->vtxBindingCount - 1));
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700858 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", str);
859 }
860 else {
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700861 char *tmpStr = xgl_print_xgl_vertex_input_binding_description(&pPipeTrav->pVertexBindingDescriptions[g_lastVtxBinding], "{DS}INFO : ");
Tobin Ehlis1affd3c2014-11-25 10:24:15 -0700862 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmpStr);
863 free(tmpStr);
864 }
865 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600866 }
867}
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600868// Print details of DS config to stdout
869static void printDSConfig()
870{
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700871 //uint32_t skipUnusedCount = 0; // track consecutive unused slots for minimal reporting
Tobin Ehlise79df942014-11-18 16:38:08 -0700872 char tmp_str[1024];
873 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 Ehlis83ebbef2015-02-10 15:35:23 -0700874 // TODO : Update this for new DS model
875 REGION_NODE* pRegion = g_pRegionHead;
876 while (pRegion) {
877 // Print out region details
878 sprintf(tmp_str, "Details for region %p.", (void*)pRegion->region);
879 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str);
880 sprintf(ds_config_str, "%s", xgl_print_xgl_descriptor_region_create_info(&pRegion->createInfo, " "));
881 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str);
882 SET_NODE* pSet = pRegion->pSets;
883 while (pSet) {
884 // Print out set details
885 char prefix[10];
886 uint32_t index = 0;
887 sprintf(tmp_str, "Details for descriptor set %p.", (void*)pSet->set);
888 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str);
889 LAYOUT_NODE* pLayout = pSet->pLayouts;
890 while (pLayout) {
891 // Print layout details
892 sprintf(tmp_str, "Layout #%u, (object %p) for DS %p.", index+1, (void*)pLayout->layout, (void*)pSet->set);
893 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str);
894 sprintf(prefix, " [L%u] ", index);
895 sprintf(ds_config_str, "%s", xgl_print_xgl_descriptor_set_layout_create_info(&pLayout->pCreateInfoList[0], prefix));
896 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str);
897 pLayout = pLayout->pPriorSetLayout;
898 index++;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600899 }
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700900 index = 0;
901 GENERIC_HEADER* pUpdate = pSet->pUpdateStructs;
902 //while (pUpdate) {
903 // Print update details
904 sprintf(tmp_str, "Update Chain [UC] for descriptor set %p:", (void*)pSet->set);
905 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", tmp_str);
906 sprintf(prefix, " [UC] ");
907 sprintf(ds_config_str, "%s", dynamic_display(pUpdate, prefix));
908 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_NONE, "DS", ds_config_str);
909 // TODO : If there is a "view" associated with this update, print CI for that view
910 pUpdate = (GENERIC_HEADER*)pUpdate->pNext;
911 index++;
912 //}
913 pSet = pSet->pNext;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600914 }
Tobin Ehlis83ebbef2015-02-10 15:35:23 -0700915 pRegion = pRegion->pNext;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600916 }
917}
918
919static void synchAndPrintDSConfig()
920{
921 synchDSMapping();
922 printDSConfig();
Tobin Ehlis56a61072014-11-21 08:58:46 -0700923 printPipeline();
924 printDynamicState();
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700925 static int autoDumpOnce = 1;
926 if (autoDumpOnce) {
927 autoDumpOnce = 0;
928 dumpDotFile("pipeline_dump.dot");
Tobin Ehlis266473d2014-12-16 17:34:50 -0700929 // Convert dot to png if dot available
Ian Elliott81ac44c2015-01-13 17:52:38 -0700930#if defined(_WIN32)
931// FIXME: NEED WINDOWS EQUIVALENT
932#else // WIN32
Tobin Ehlis266473d2014-12-16 17:34:50 -0700933 if(access( "/usr/bin/dot", X_OK) != -1) {
934 system("/usr/bin/dot pipeline_dump.dot -Tpng -o pipeline_dump.png");
935 }
Ian Elliott81ac44c2015-01-13 17:52:38 -0700936#endif // WIN32
Tobin Ehlisa701ef02014-11-27 15:43:39 -0700937 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600938}
939
Jon Ashburn2e9b5612014-12-22 13:38:27 -0700940static void initDrawState()
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600941{
Jon Ashburn2e9b5612014-12-22 13:38:27 -0700942 const char *strOpt;
Tobin Ehlis5b7acaa2015-01-08 14:26:53 -0700943 // initialize DrawState options
Jon Ashburn2e9b5612014-12-22 13:38:27 -0700944 strOpt = getLayerOption("DrawStateReportLevel");
945 if (strOpt != NULL)
946 g_reportingLevel = atoi(strOpt);
Tobin Ehlis5b7acaa2015-01-08 14:26:53 -0700947
Jon Ashburn2e9b5612014-12-22 13:38:27 -0700948 strOpt = getLayerOption("DrawStateDebugAction");
949 if (strOpt != NULL)
Tobin Ehlis5b7acaa2015-01-08 14:26:53 -0700950 g_debugAction = atoi(strOpt);
951
Jon Ashburn2e9b5612014-12-22 13:38:27 -0700952 if (g_debugAction & XGL_DBG_LAYER_ACTION_LOG_MSG)
953 {
954 strOpt = getLayerOption("DrawStateLogFilename");
955 if (strOpt)
956 {
957 g_logFile = fopen(strOpt, "w");
Jon Ashburn2e9b5612014-12-22 13:38:27 -0700958 }
959 if (g_logFile == NULL)
960 g_logFile = stdout;
961 }
Jon Ashburn2e9b5612014-12-22 13:38:27 -0700962 // initialize Layer dispatch table
963 // TODO handle multiple GPUs
Mark Lobodzinski953a1692015-01-09 15:12:03 -0600964 xglGetProcAddrType fpNextGPA;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600965 fpNextGPA = pCurObj->pGPA;
966 assert(fpNextGPA);
967
Chia-I Wu0f65b1e2015-01-04 23:11:43 +0800968 layer_initialize_dispatch_table(&nextTable, fpNextGPA, (XGL_PHYSICAL_GPU) pCurObj->nextObject);
969
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600970 xglGetProcAddrType fpGetProcAddr = fpNextGPA((XGL_PHYSICAL_GPU) pCurObj->nextObject, (char *) "xglGetProcAddr");
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600971 nextTable.GetProcAddr = fpGetProcAddr;
Ian Elliott81ac44c2015-01-13 17:52:38 -0700972
973 if (!globalLockInitialized)
974 {
975 // TODO/TBD: Need to delete this mutex sometime. How??? One
976 // suggestion is to call this during xglCreateInstance(), and then we
977 // can clean it up during xglDestroyInstance(). However, that requires
978 // that the layer have per-instance locks. We need to come back and
979 // address this soon.
980 loader_platform_thread_create_mutex(&globalLock);
981 globalLockInitialized = 1;
982 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -0600983}
984
Tobin Ehlis84c521c2015-01-19 08:42:29 -0700985XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateInstance(const XGL_APPLICATION_INFO* pAppInfo, const XGL_ALLOC_CALLBACKS* pAllocCb, XGL_INSTANCE* pInstance)
986{
987 XGL_RESULT result = nextTable.CreateInstance(pAppInfo, pAllocCb, pInstance);
988 return result;
989}
990
991XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyInstance(XGL_INSTANCE instance)
992{
993 XGL_RESULT result = nextTable.DestroyInstance(instance);
994 return result;
995}
996
997XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateGpus(XGL_INSTANCE instance, uint32_t maxGpus, uint32_t* pGpuCount, XGL_PHYSICAL_GPU* pGpus)
998{
999 XGL_RESULT result = nextTable.EnumerateGpus(instance, maxGpus, pGpuCount, pGpus);
1000 return result;
1001}
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001002
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001003XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetGpuInfo(XGL_PHYSICAL_GPU gpu, XGL_PHYSICAL_GPU_INFO_TYPE infoType, size_t* pDataSize, void* pData)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001004{
1005 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001006 pCurObj = gpuw;
Ian Elliott81ac44c2015-01-13 17:52:38 -07001007 loader_platform_thread_once(&g_initOnce, initDrawState);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001008 XGL_RESULT result = nextTable.GetGpuInfo((XGL_PHYSICAL_GPU)gpuw->nextObject, infoType, pDataSize, pData);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001009 return result;
1010}
1011
1012XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreateInfo, XGL_DEVICE* pDevice)
1013{
1014 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001015 pCurObj = gpuw;
Ian Elliott81ac44c2015-01-13 17:52:38 -07001016 loader_platform_thread_once(&g_initOnce, initDrawState);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001017 XGL_RESULT result = nextTable.CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001018 return result;
1019}
1020
1021XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyDevice(XGL_DEVICE device)
1022{
1023 XGL_RESULT result = nextTable.DestroyDevice(device);
1024 return result;
1025}
1026
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001027XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu, const char* pExtName)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001028{
1029 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001030 pCurObj = gpuw;
Ian Elliott81ac44c2015-01-13 17:52:38 -07001031 loader_platform_thread_once(&g_initOnce, initDrawState);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001032 XGL_RESULT result = nextTable.GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001033 return result;
1034}
1035
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001036XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, size_t maxLayerCount, size_t maxStringSize, size_t* pOutLayerCount, char* const* pOutLayers, void* pReserved)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001037{
Jon Ashburn451c16f2014-11-25 11:08:42 -07001038 if (gpu != NULL)
1039 {
1040 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
1041 pCurObj = gpuw;
Ian Elliott81ac44c2015-01-13 17:52:38 -07001042 loader_platform_thread_once(&g_initOnce, initDrawState);
Mark Lobodzinski953a1692015-01-09 15:12:03 -06001043 XGL_RESULT result = nextTable.EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayerCount, pOutLayers, pReserved);
Jon Ashburn451c16f2014-11-25 11:08:42 -07001044 return result;
1045 } else
1046 {
1047 if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL)
1048 return XGL_ERROR_INVALID_POINTER;
1049 // This layer compatible with all GPUs
1050 *pOutLayerCount = 1;
Chia-I Wua837c522014-12-16 10:47:33 +08001051 strncpy((char *) pOutLayers[0], "DrawState", maxStringSize);
Jon Ashburn451c16f2014-11-25 11:08:42 -07001052 return XGL_SUCCESS;
1053 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001054}
1055
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001056XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetDeviceQueue(XGL_DEVICE device, XGL_QUEUE_TYPE queueType, uint32_t queueIndex, XGL_QUEUE* pQueue)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001057{
1058 XGL_RESULT result = nextTable.GetDeviceQueue(device, queueType, queueIndex, pQueue);
1059 return result;
1060}
1061
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001062XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueSubmit(XGL_QUEUE queue, uint32_t cmdBufferCount, const XGL_CMD_BUFFER* pCmdBuffers, uint32_t memRefCount, const XGL_MEMORY_REF* pMemRefs, XGL_FENCE fence)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001063{
1064 XGL_RESULT result = nextTable.QueueSubmit(queue, cmdBufferCount, pCmdBuffers, memRefCount, pMemRefs, fence);
1065 return result;
1066}
1067
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001068XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueSetGlobalMemReferences(XGL_QUEUE queue, uint32_t memRefCount, const XGL_MEMORY_REF* pMemRefs)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001069{
1070 XGL_RESULT result = nextTable.QueueSetGlobalMemReferences(queue, memRefCount, pMemRefs);
1071 return result;
1072}
1073
1074XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglQueueWaitIdle(XGL_QUEUE queue)
1075{
1076 XGL_RESULT result = nextTable.QueueWaitIdle(queue);
1077 return result;
1078}
1079
1080XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDeviceWaitIdle(XGL_DEVICE device)
1081{
1082 XGL_RESULT result = nextTable.DeviceWaitIdle(device);
1083 return result;
1084}
1085
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001086XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglAllocMemory(XGL_DEVICE device, const XGL_MEMORY_ALLOC_INFO* pAllocInfo, XGL_GPU_MEMORY* pMem)
1087{
1088 XGL_RESULT result = nextTable.AllocMemory(device, pAllocInfo, pMem);
1089 return result;
1090}
1091
1092XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglFreeMemory(XGL_GPU_MEMORY mem)
1093{
1094 XGL_RESULT result = nextTable.FreeMemory(mem);
1095 return result;
1096}
1097
1098XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSetMemoryPriority(XGL_GPU_MEMORY mem, XGL_MEMORY_PRIORITY priority)
1099{
1100 XGL_RESULT result = nextTable.SetMemoryPriority(mem, priority);
1101 return result;
1102}
1103
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001104XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglMapMemory(XGL_GPU_MEMORY mem, XGL_FLAGS flags, void** ppData)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001105{
1106 XGL_RESULT result = nextTable.MapMemory(mem, flags, ppData);
1107 return result;
1108}
1109
1110XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglUnmapMemory(XGL_GPU_MEMORY mem)
1111{
1112 XGL_RESULT result = nextTable.UnmapMemory(mem);
1113 return result;
1114}
1115
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001116XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglPinSystemMemory(XGL_DEVICE device, const void* pSysMem, size_t memSize, XGL_GPU_MEMORY* pMem)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001117{
1118 XGL_RESULT result = nextTable.PinSystemMemory(device, pSysMem, memSize, pMem);
1119 return result;
1120}
1121
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001122XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetMultiGpuCompatibility(XGL_PHYSICAL_GPU gpu0, XGL_PHYSICAL_GPU gpu1, XGL_GPU_COMPATIBILITY_INFO* pInfo)
1123{
1124 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu0;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001125 pCurObj = gpuw;
Ian Elliott81ac44c2015-01-13 17:52:38 -07001126 loader_platform_thread_once(&g_initOnce, initDrawState);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001127 XGL_RESULT result = nextTable.GetMultiGpuCompatibility((XGL_PHYSICAL_GPU)gpuw->nextObject, gpu1, pInfo);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001128 return result;
1129}
1130
1131XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenSharedMemory(XGL_DEVICE device, const XGL_MEMORY_OPEN_INFO* pOpenInfo, XGL_GPU_MEMORY* pMem)
1132{
1133 XGL_RESULT result = nextTable.OpenSharedMemory(device, pOpenInfo, pMem);
1134 return result;
1135}
1136
1137XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenSharedQueueSemaphore(XGL_DEVICE device, const XGL_QUEUE_SEMAPHORE_OPEN_INFO* pOpenInfo, XGL_QUEUE_SEMAPHORE* pSemaphore)
1138{
1139 XGL_RESULT result = nextTable.OpenSharedQueueSemaphore(device, pOpenInfo, pSemaphore);
1140 return result;
1141}
1142
1143XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenPeerMemory(XGL_DEVICE device, const XGL_PEER_MEMORY_OPEN_INFO* pOpenInfo, XGL_GPU_MEMORY* pMem)
1144{
1145 XGL_RESULT result = nextTable.OpenPeerMemory(device, pOpenInfo, pMem);
1146 return result;
1147}
1148
1149XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglOpenPeerImage(XGL_DEVICE device, const XGL_PEER_IMAGE_OPEN_INFO* pOpenInfo, XGL_IMAGE* pImage, XGL_GPU_MEMORY* pMem)
1150{
1151 XGL_RESULT result = nextTable.OpenPeerImage(device, pOpenInfo, pImage, pMem);
1152 return result;
1153}
1154
1155XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDestroyObject(XGL_OBJECT object)
1156{
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001157 // TODO : When wrapped objects (such as dynamic state) are destroyed, need to clean up memory
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001158 XGL_RESULT result = nextTable.DestroyObject(object);
1159 return result;
1160}
1161
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001162XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetObjectInfo(XGL_BASE_OBJECT object, XGL_OBJECT_INFO_TYPE infoType, size_t* pDataSize, void* pData)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001163{
1164 XGL_RESULT result = nextTable.GetObjectInfo(object, infoType, pDataSize, pData);
1165 return result;
1166}
1167
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001168XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBindObjectMemory(XGL_OBJECT object, uint32_t allocationIdx, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001169{
Jon Ashburned62b412015-01-15 10:39:19 -07001170 XGL_RESULT result = nextTable.BindObjectMemory(object, allocationIdx, mem, offset);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001171 return result;
1172}
1173
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001174XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBindObjectMemoryRange(XGL_OBJECT object, uint32_t allocationIdx, XGL_GPU_SIZE rangeOffset, XGL_GPU_SIZE rangeSize, XGL_GPU_MEMORY mem, XGL_GPU_SIZE memOffset)
1175{
1176 XGL_RESULT result = nextTable.BindObjectMemoryRange(object, allocationIdx, rangeOffset, rangeSize, mem, memOffset);
1177 return result;
1178}
1179
1180XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBindImageMemoryRange(XGL_IMAGE image, uint32_t allocationIdx, const XGL_IMAGE_MEMORY_BIND_INFO* bindInfo, XGL_GPU_MEMORY mem, XGL_GPU_SIZE memOffset)
1181{
1182 XGL_RESULT result = nextTable.BindImageMemoryRange(image, allocationIdx, bindInfo, mem, memOffset);
1183 return result;
1184}
1185
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001186XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateFence(XGL_DEVICE device, const XGL_FENCE_CREATE_INFO* pCreateInfo, XGL_FENCE* pFence)
1187{
1188 XGL_RESULT result = nextTable.CreateFence(device, pCreateInfo, pFence);
1189 return result;
1190}
1191
1192XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetFenceStatus(XGL_FENCE fence)
1193{
1194 XGL_RESULT result = nextTable.GetFenceStatus(fence);
1195 return result;
1196}
1197
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001198XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWaitForFences(XGL_DEVICE device, uint32_t fenceCount, const XGL_FENCE* pFences, bool32_t waitAll, uint64_t timeout)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001199{
1200 XGL_RESULT result = nextTable.WaitForFences(device, fenceCount, pFences, waitAll, timeout);
1201 return result;
1202}
1203
1204XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateQueueSemaphore(XGL_DEVICE device, const XGL_QUEUE_SEMAPHORE_CREATE_INFO* pCreateInfo, XGL_QUEUE_SEMAPHORE* pSemaphore)
1205{
1206 XGL_RESULT result = nextTable.CreateQueueSemaphore(device, pCreateInfo, pSemaphore);
1207 return result;
1208}
1209
1210XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSignalQueueSemaphore(XGL_QUEUE queue, XGL_QUEUE_SEMAPHORE semaphore)
1211{
1212 XGL_RESULT result = nextTable.SignalQueueSemaphore(queue, semaphore);
1213 return result;
1214}
1215
1216XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWaitQueueSemaphore(XGL_QUEUE queue, XGL_QUEUE_SEMAPHORE semaphore)
1217{
1218 XGL_RESULT result = nextTable.WaitQueueSemaphore(queue, semaphore);
1219 return result;
1220}
1221
1222XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateEvent(XGL_DEVICE device, const XGL_EVENT_CREATE_INFO* pCreateInfo, XGL_EVENT* pEvent)
1223{
1224 XGL_RESULT result = nextTable.CreateEvent(device, pCreateInfo, pEvent);
1225 return result;
1226}
1227
1228XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetEventStatus(XGL_EVENT event)
1229{
1230 XGL_RESULT result = nextTable.GetEventStatus(event);
1231 return result;
1232}
1233
1234XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSetEvent(XGL_EVENT event)
1235{
1236 XGL_RESULT result = nextTable.SetEvent(event);
1237 return result;
1238}
1239
1240XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglResetEvent(XGL_EVENT event)
1241{
1242 XGL_RESULT result = nextTable.ResetEvent(event);
1243 return result;
1244}
1245
1246XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateQueryPool(XGL_DEVICE device, const XGL_QUERY_POOL_CREATE_INFO* pCreateInfo, XGL_QUERY_POOL* pQueryPool)
1247{
1248 XGL_RESULT result = nextTable.CreateQueryPool(device, pCreateInfo, pQueryPool);
1249 return result;
1250}
1251
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001252XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetQueryPoolResults(XGL_QUERY_POOL queryPool, uint32_t startQuery, uint32_t queryCount, size_t* pDataSize, void* pData)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001253{
1254 XGL_RESULT result = nextTable.GetQueryPoolResults(queryPool, startQuery, queryCount, pDataSize, pData);
1255 return result;
1256}
1257
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001258XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetFormatInfo(XGL_DEVICE device, XGL_FORMAT format, XGL_FORMAT_INFO_TYPE infoType, size_t* pDataSize, void* pData)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001259{
1260 XGL_RESULT result = nextTable.GetFormatInfo(device, format, infoType, pDataSize, pData);
1261 return result;
1262}
1263
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001264XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateBuffer(XGL_DEVICE device, const XGL_BUFFER_CREATE_INFO* pCreateInfo, XGL_BUFFER* pBuffer)
1265{
1266 XGL_RESULT result = nextTable.CreateBuffer(device, pCreateInfo, pBuffer);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001267 if (XGL_SUCCESS == result) {
1268 pthread_mutex_lock(&globalLock);
1269 BUFFER_NODE *pNewNode = (BUFFER_NODE*)malloc(sizeof(BUFFER_NODE));
1270 pNewNode->buffer = *pBuffer;
1271 memcpy(&pNewNode->createInfo, pCreateInfo, sizeof(XGL_BUFFER_CREATE_INFO));
1272 pNewNode->pNext = g_pBufferHead;
1273 g_pBufferHead = pNewNode;
1274 pthread_mutex_unlock(&globalLock);
1275 }
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001276 return result;
1277}
1278
1279XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateBufferView(XGL_DEVICE device, const XGL_BUFFER_VIEW_CREATE_INFO* pCreateInfo, XGL_BUFFER_VIEW* pView)
1280{
1281 XGL_RESULT result = nextTable.CreateBufferView(device, pCreateInfo, pView);
1282 return result;
1283}
1284
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001285XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateImage(XGL_DEVICE device, const XGL_IMAGE_CREATE_INFO* pCreateInfo, XGL_IMAGE* pImage)
1286{
1287 XGL_RESULT result = nextTable.CreateImage(device, pCreateInfo, pImage);
1288 return result;
1289}
1290
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001291XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSetFastClearColor(XGL_IMAGE image, const float color[4])
1292{
1293 XGL_RESULT result = nextTable.SetFastClearColor(image, color);
1294 return result;
1295}
1296
1297XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglSetFastClearDepth(XGL_IMAGE image, float depth)
1298{
1299 XGL_RESULT result = nextTable.SetFastClearDepth(image, depth);
1300 return result;
1301}
1302
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001303XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetImageSubresourceInfo(XGL_IMAGE image, const XGL_IMAGE_SUBRESOURCE* pSubresource, XGL_SUBRESOURCE_INFO_TYPE infoType, size_t* pDataSize, void* pData)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001304{
1305 XGL_RESULT result = nextTable.GetImageSubresourceInfo(image, pSubresource, infoType, pDataSize, pData);
1306 return result;
1307}
1308
1309XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateImageView(XGL_DEVICE device, const XGL_IMAGE_VIEW_CREATE_INFO* pCreateInfo, XGL_IMAGE_VIEW* pView)
1310{
1311 XGL_RESULT result = nextTable.CreateImageView(device, pCreateInfo, pView);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001312 if (XGL_SUCCESS == result) {
1313 pthread_mutex_lock(&globalLock);
1314 IMAGE_NODE *pNewNode = (IMAGE_NODE*)malloc(sizeof(IMAGE_NODE));
1315 pNewNode->image = *pView;
1316 memcpy(&pNewNode->createInfo, pCreateInfo, sizeof(XGL_IMAGE_VIEW_CREATE_INFO));
1317 pNewNode->pNext = g_pImageHead;
1318 g_pImageHead = pNewNode;
1319 pthread_mutex_unlock(&globalLock);
1320 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001321 return result;
1322}
1323
1324XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateColorAttachmentView(XGL_DEVICE device, const XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO* pCreateInfo, XGL_COLOR_ATTACHMENT_VIEW* pView)
1325{
1326 XGL_RESULT result = nextTable.CreateColorAttachmentView(device, pCreateInfo, pView);
1327 return result;
1328}
1329
1330XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDepthStencilView(XGL_DEVICE device, const XGL_DEPTH_STENCIL_VIEW_CREATE_INFO* pCreateInfo, XGL_DEPTH_STENCIL_VIEW* pView)
1331{
1332 XGL_RESULT result = nextTable.CreateDepthStencilView(device, pCreateInfo, pView);
1333 return result;
1334}
1335
1336XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateShader(XGL_DEVICE device, const XGL_SHADER_CREATE_INFO* pCreateInfo, XGL_SHADER* pShader)
1337{
1338 XGL_RESULT result = nextTable.CreateShader(device, pCreateInfo, pShader);
1339 return result;
1340}
1341
1342XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateGraphicsPipeline(XGL_DEVICE device, const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo, XGL_PIPELINE* pPipeline)
1343{
1344 XGL_RESULT result = nextTable.CreateGraphicsPipeline(device, pCreateInfo, pPipeline);
1345 // Create LL HEAD for this Pipeline
Tobin Ehlise79df942014-11-18 16:38:08 -07001346 char str[1024];
1347 sprintf(str, "Created Gfx Pipeline %p", (void*)*pPipeline);
1348 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pPipeline, 0, DRAWSTATE_NONE, "DS", str);
Ian Elliott81ac44c2015-01-13 17:52:38 -07001349 loader_platform_thread_lock_mutex(&globalLock);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001350 PIPELINE_NODE *pTrav = g_pPipelineHead;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001351 if (pTrav) {
1352 while (pTrav->pNext)
1353 pTrav = pTrav->pNext;
1354 pTrav->pNext = (PIPELINE_NODE*)malloc(sizeof(PIPELINE_NODE));
1355 pTrav = pTrav->pNext;
1356 }
1357 else {
1358 pTrav = (PIPELINE_NODE*)malloc(sizeof(PIPELINE_NODE));
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001359 g_pPipelineHead = pTrav;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001360 }
1361 memset((void*)pTrav, 0, sizeof(PIPELINE_NODE));
1362 pTrav->pipeline = *pPipeline;
1363 initPipeline(pTrav, pCreateInfo);
Ian Elliott81ac44c2015-01-13 17:52:38 -07001364 loader_platform_thread_unlock_mutex(&globalLock);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001365 return result;
1366}
1367
1368XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateComputePipeline(XGL_DEVICE device, const XGL_COMPUTE_PIPELINE_CREATE_INFO* pCreateInfo, XGL_PIPELINE* pPipeline)
1369{
1370 XGL_RESULT result = nextTable.CreateComputePipeline(device, pCreateInfo, pPipeline);
1371 return result;
1372}
1373
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001374XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglStorePipeline(XGL_PIPELINE pipeline, size_t* pDataSize, void* pData)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001375{
1376 XGL_RESULT result = nextTable.StorePipeline(pipeline, pDataSize, pData);
1377 return result;
1378}
1379
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001380XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglLoadPipeline(XGL_DEVICE device, size_t dataSize, const void* pData, XGL_PIPELINE* pPipeline)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001381{
1382 XGL_RESULT result = nextTable.LoadPipeline(device, dataSize, pData, pPipeline);
1383 return result;
1384}
1385
1386XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreatePipelineDelta(XGL_DEVICE device, XGL_PIPELINE p1, XGL_PIPELINE p2, XGL_PIPELINE_DELTA* delta)
1387{
1388 XGL_RESULT result = nextTable.CreatePipelineDelta(device, p1, p2, delta);
1389 return result;
1390}
1391
1392XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateSampler(XGL_DEVICE device, const XGL_SAMPLER_CREATE_INFO* pCreateInfo, XGL_SAMPLER* pSampler)
1393{
1394 XGL_RESULT result = nextTable.CreateSampler(device, pCreateInfo, pSampler);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001395 if (XGL_SUCCESS == result) {
Ian Elliott81ac44c2015-01-13 17:52:38 -07001396 loader_platform_thread_lock_mutex(&globalLock);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001397 SAMPLER_NODE *pNewNode = (SAMPLER_NODE*)malloc(sizeof(SAMPLER_NODE));
1398 pNewNode->sampler = *pSampler;
1399 memcpy(&pNewNode->createInfo, pCreateInfo, sizeof(XGL_SAMPLER_CREATE_INFO));
1400 pNewNode->pNext = g_pSamplerHead;
1401 g_pSamplerHead = pNewNode;
Ian Elliott81ac44c2015-01-13 17:52:38 -07001402 loader_platform_thread_unlock_mutex(&globalLock);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001403 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001404 return result;
1405}
1406
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001407XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDescriptorSetLayout(XGL_DEVICE device, XGL_FLAGS stageFlags, const uint32_t* pSetBindPoints, XGL_DESCRIPTOR_SET_LAYOUT priorSetLayout, const XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO* pSetLayoutInfoList, XGL_DESCRIPTOR_SET_LAYOUT* pSetLayout)
1408{
1409 XGL_RESULT result = nextTable.CreateDescriptorSetLayout(device, stageFlags, pSetBindPoints, priorSetLayout, pSetLayoutInfoList, pSetLayout);
1410 if (XGL_SUCCESS == result) {
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001411 LAYOUT_NODE* pNewNode = (LAYOUT_NODE*)malloc(sizeof(LAYOUT_NODE));
1412 if (NULL == pNewNode) {
1413 char str[1024];
1414 sprintf(str, "Out of memory while attempting to allocate LAYOUT_NODE in xglCreateDescriptorSetLayout()");
1415 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, *pSetLayout, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str);
1416 }
1417 memset(pNewNode, 0, sizeof(LAYOUT_NODE));
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001418 // TODO : API Currently missing a count here that we should multiply by struct size
1419 pNewNode->pCreateInfoList = (XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO*)malloc(sizeof(XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO));
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001420 memcpy((void*)pNewNode->pCreateInfoList, pSetLayoutInfoList, sizeof(XGL_DESCRIPTOR_SET_LAYOUT_CREATE_INFO));
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001421 pNewNode->layout = *pSetLayout;
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001422 pNewNode->stageFlags = stageFlags;
1423 pNewNode->startIndex = 0;
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001424 LAYOUT_NODE* pPriorNode = getLayoutNode(priorSetLayout);
1425 // Point to prior node or NULL if no prior node
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001426 if (NULL != priorSetLayout && pPriorNode == NULL) {
1427 char str[1024];
1428 sprintf(str, "Invalid priorSetLayout of %p passed to xglCreateDescriptorSetLayout()", (void*)priorSetLayout);
1429 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, priorSetLayout, 0, DRAWSTATE_INVALID_LAYOUT, "DS", str);
1430 }
1431 else if (pPriorNode != NULL) { // We have a node for a valid prior layout
1432 // Get count for prior layout
1433 pNewNode->startIndex = pPriorNode->endIndex + 1;
1434 }
1435 pNewNode->endIndex = pNewNode->startIndex + pNewNode->pCreateInfoList[0].count - 1;
1436 assert(pNewNode->endIndex >= pNewNode->startIndex);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001437 pNewNode->pPriorSetLayout = pPriorNode;
1438 // Put new node at Head of global Layer list
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001439 pNewNode->pNext = g_pLayoutHead;
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001440 g_pLayoutHead = pNewNode;
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001441 }
1442 return result;
1443}
1444
1445XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBeginDescriptorRegionUpdate(XGL_DEVICE device, XGL_DESCRIPTOR_UPDATE_MODE updateMode)
1446{
1447 XGL_RESULT result = nextTable.BeginDescriptorRegionUpdate(device, updateMode);
1448 if (XGL_SUCCESS == result) {
1449 if (!g_pRegionHead) {
1450 char str[1024];
1451 sprintf(str, "No descriptor region found! Global descriptor region is NULL!");
1452 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, g_pRegionHead, 0, DRAWSTATE_NO_DS_REGION, "DS", str);
1453 }
1454 else {
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001455 REGION_NODE* pRegionNode = g_pRegionHead;
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001456 if (!pRegionNode) {
1457 char str[1024];
1458 sprintf(str, "Unable to find region node for global region head %p", (void*)g_pRegionHead);
1459 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, g_pRegionHead, 0, DRAWSTATE_INTERNAL_ERROR, "DS", str);
1460 }
1461 else {
1462 pRegionNode->updateActive = 1;
1463 }
1464 }
1465 }
1466 return result;
1467}
1468
1469XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEndDescriptorRegionUpdate(XGL_DEVICE device, XGL_CMD_BUFFER cmd)
1470{
1471 XGL_RESULT result = nextTable.EndDescriptorRegionUpdate(device, cmd);
1472 if (XGL_SUCCESS == result) {
1473 if (!g_pRegionHead) {
1474 char str[1024];
1475 sprintf(str, "No descriptor region found! Global descriptor region is NULL!");
1476 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, g_pRegionHead, 0, DRAWSTATE_NO_DS_REGION, "DS", str);
1477 }
1478 else {
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001479 REGION_NODE* pRegionNode = g_pRegionHead;
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001480 if (!pRegionNode) {
1481 char str[1024];
1482 sprintf(str, "Unable to find region node for global region head %p", (void*)g_pRegionHead);
1483 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, g_pRegionHead, 0, DRAWSTATE_INTERNAL_ERROR, "DS", str);
1484 }
1485 else {
1486 if (!pRegionNode->updateActive) {
1487 char str[1024];
1488 sprintf(str, "You must call xglBeginDescriptorRegionUpdate() before this call to xglEndDescriptorRegionUpdate()!");
1489 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, g_pRegionHead, 0, DRAWSTATE_DS_END_WITHOUT_BEGIN, "DS", str);
1490 }
1491 else {
1492 pRegionNode->updateActive = 0;
1493 }
1494 }
1495 }
1496 }
1497 return result;
1498}
1499
1500XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDescriptorRegion(XGL_DEVICE device, XGL_DESCRIPTOR_REGION_USAGE regionUsage, uint32_t maxSets, const XGL_DESCRIPTOR_REGION_CREATE_INFO* pCreateInfo, XGL_DESCRIPTOR_REGION* pDescriptorRegion)
1501{
1502 XGL_RESULT result = nextTable.CreateDescriptorRegion(device, regionUsage, maxSets, pCreateInfo, pDescriptorRegion);
1503 if (XGL_SUCCESS == result) {
1504 // Insert this region into Global Region LL at head
1505 char str[1024];
1506 sprintf(str, "Created Descriptor Region %p", (void*)*pDescriptorRegion);
1507 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pDescriptorRegion, 0, DRAWSTATE_NONE, "DS", str);
1508 pthread_mutex_lock(&globalLock);
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001509 REGION_NODE* pNewNode = (REGION_NODE*)malloc(sizeof(REGION_NODE));
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001510 if (NULL == pNewNode) {
1511 char str[1024];
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001512 sprintf(str, "Out of memory while attempting to allocate REGION_NODE in xglCreateDescriptorRegion()");
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001513 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, *pDescriptorRegion, 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str);
1514 }
1515 else {
1516 memset(pNewNode, 0, sizeof(REGION_NODE));
1517 pNewNode->pNext = g_pRegionHead;
1518 g_pRegionHead = pNewNode;
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001519 XGL_DESCRIPTOR_REGION_CREATE_INFO* pCI = (XGL_DESCRIPTOR_REGION_CREATE_INFO*)&pNewNode->createInfo;
1520 memcpy((void*)pCI, pCreateInfo, sizeof(XGL_DESCRIPTOR_REGION_CREATE_INFO));
1521 size_t typeCountSize = pNewNode->createInfo.count * sizeof(XGL_DESCRIPTOR_TYPE_COUNT);
1522 XGL_DESCRIPTOR_TYPE_COUNT** ppTypeCount = (XGL_DESCRIPTOR_TYPE_COUNT**)&pNewNode->createInfo.pTypeCount;
1523 *ppTypeCount = (XGL_DESCRIPTOR_TYPE_COUNT*)malloc(typeCountSize);
1524 memcpy((void*)*ppTypeCount, pCreateInfo->pTypeCount, typeCountSize);
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001525 pNewNode->regionUsage = regionUsage;
1526 pNewNode->updateActive = 0;
1527 pNewNode->maxSets = maxSets;
1528 pNewNode->region = *pDescriptorRegion;
1529 }
1530 pthread_mutex_unlock(&globalLock);
1531 }
1532 else {
1533 // Need to do anything if region create fails?
1534 }
1535 return result;
1536}
1537
1538XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglClearDescriptorRegion(XGL_DESCRIPTOR_REGION descriptorRegion)
1539{
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001540 XGL_RESULT result = nextTable.ClearDescriptorRegion(descriptorRegion);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001541 if (XGL_SUCCESS == result) {
1542 clearDescriptorRegion(descriptorRegion);
1543 }
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001544 return result;
1545}
1546
1547XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglAllocDescriptorSets(XGL_DESCRIPTOR_REGION descriptorRegion, XGL_DESCRIPTOR_SET_USAGE setUsage, uint32_t count, const XGL_DESCRIPTOR_SET_LAYOUT* pSetLayouts, XGL_DESCRIPTOR_SET* pDescriptorSets, uint32_t* pCount)
1548{
1549 XGL_RESULT result = nextTable.AllocDescriptorSets(descriptorRegion, setUsage, count, pSetLayouts, pDescriptorSets, pCount);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001550 if ((XGL_SUCCESS == result) || (*pCount > 0)) {
1551 REGION_NODE *pRegionNode = getRegionNode(descriptorRegion);
1552 if (!pRegionNode) {
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001553 char str[1024];
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001554 sprintf(str, "Unable to find region node for region %p specified in xglAllocDescriptorSets() call", (void*)descriptorRegion);
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001555 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorRegion, 0, DRAWSTATE_INVALID_REGION, "DS", str);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001556 }
1557 else {
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001558 for (uint32_t i = 0; i < *pCount; i++) {
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001559 char str[1024];
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001560 sprintf(str, "Created Descriptor Set %p", (void*)pDescriptorSets[i]);
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001561 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001562 // Create new set node and add to head of region nodes
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001563 SET_NODE* pNewNode = (SET_NODE*)malloc(sizeof(SET_NODE));
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001564 if (NULL == pNewNode) {
1565 char str[1024];
1566 sprintf(str, "Out of memory while attempting to allocate SET_NODE in xglAllocDescriptorSets()");
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001567 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pDescriptorSets[i], 0, DRAWSTATE_OUT_OF_MEMORY, "DS", str);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001568 }
1569 else {
1570 memset(pNewNode, 0, sizeof(SET_NODE));
1571 // Insert set at head of Set LL for this region
1572 pNewNode->pNext = pRegionNode->pSets;
1573 pRegionNode->pSets = pNewNode;
1574 LAYOUT_NODE* pLayout = getLayoutNode(pSetLayouts[i]);
1575 if (NULL == pLayout) {
1576 char str[1024];
1577 sprintf(str, "Unable to find set layout node for layout %p specified in xglAllocDescriptorSets() call", (void*)pSetLayouts[i]);
1578 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pSetLayouts[i], 0, DRAWSTATE_INVALID_LAYOUT, "DS", str);
1579 }
1580 pNewNode->pLayouts = pLayout;
1581 pNewNode->region = descriptorRegion;
1582 pNewNode->set = pDescriptorSets[i];
1583 pNewNode->setUsage = setUsage;
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001584 // TODO : Make sure to set this correctly
1585 pNewNode->descriptorCount = 0;
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001586 }
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001587 }
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001588 }
1589 }
1590 return result;
1591}
1592
1593XGL_LAYER_EXPORT void XGLAPI xglClearDescriptorSets(XGL_DESCRIPTOR_REGION descriptorRegion, uint32_t count, const XGL_DESCRIPTOR_SET* pDescriptorSets)
1594{
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001595 for (uint32_t i = 0; i < count; i++) {
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001596 clearDescriptorSet(pDescriptorSets[i]);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001597 }
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001598 nextTable.ClearDescriptorSets(descriptorRegion, count, pDescriptorSets);
1599}
1600
1601XGL_LAYER_EXPORT void XGLAPI xglUpdateDescriptors(XGL_DESCRIPTOR_SET descriptorSet, const void* pUpdateChain)
1602{
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001603 if (!dsUpdateActive(descriptorSet)) {
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001604 char str[1024];
1605 sprintf(str, "You must call xglBeginDescriptorRegionUpdate() before this call to xglUpdateDescriptors()!");
1606 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, g_pRegionHead, 0, DRAWSTATE_UPDATE_WITHOUT_BEGIN, "DS", str);
1607 }
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001608 else {
1609 // pUpdateChain is a Linked-list of XGL_UPDATE_* structures defining the mappings for the descriptors
1610 dsUpdate(descriptorSet, (GENERIC_HEADER*)pUpdateChain);
1611 }
1612
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001613 nextTable.UpdateDescriptors(descriptorSet, pUpdateChain);
1614}
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001615
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001616XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicViewportState(XGL_DEVICE device, const XGL_DYNAMIC_VP_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_VP_STATE_OBJECT* pState)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001617{
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001618 XGL_RESULT result = nextTable.CreateDynamicViewportState(device, pCreateInfo, pState);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001619 insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, XGL_STATE_BIND_VIEWPORT);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001620 return result;
1621}
1622
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001623XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicRasterState(XGL_DEVICE device, const XGL_DYNAMIC_RS_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_RS_STATE_OBJECT* pState)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001624{
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001625 XGL_RESULT result = nextTable.CreateDynamicRasterState(device, pCreateInfo, pState);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001626 insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, XGL_STATE_BIND_RASTER);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001627 return result;
1628}
1629
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001630XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicColorBlendState(XGL_DEVICE device, const XGL_DYNAMIC_CB_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_CB_STATE_OBJECT* pState)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001631{
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001632 XGL_RESULT result = nextTable.CreateDynamicColorBlendState(device, pCreateInfo, pState);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001633 insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, XGL_STATE_BIND_COLOR_BLEND);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001634 return result;
1635}
1636
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001637XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDynamicDepthStencilState(XGL_DEVICE device, const XGL_DYNAMIC_DS_STATE_CREATE_INFO* pCreateInfo, XGL_DYNAMIC_DS_STATE_OBJECT* pState)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001638{
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001639 XGL_RESULT result = nextTable.CreateDynamicDepthStencilState(device, pCreateInfo, pState);
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001640 insertDynamicState(*pState, (GENERIC_HEADER*)pCreateInfo, XGL_STATE_BIND_DEPTH_STENCIL);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001641 return result;
1642}
1643
1644XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateCommandBuffer(XGL_DEVICE device, const XGL_CMD_BUFFER_CREATE_INFO* pCreateInfo, XGL_CMD_BUFFER* pCmdBuffer)
1645{
1646 XGL_RESULT result = nextTable.CreateCommandBuffer(device, pCreateInfo, pCmdBuffer);
1647 return result;
1648}
1649
Jon Ashburn57ba18d2014-12-31 17:11:49 -07001650XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBeginCommandBuffer(XGL_CMD_BUFFER cmdBuffer, const XGL_CMD_BUFFER_BEGIN_INFO* pBeginInfo)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001651{
Jon Ashburn57ba18d2014-12-31 17:11:49 -07001652 XGL_RESULT result = nextTable.BeginCommandBuffer(cmdBuffer, pBeginInfo);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001653 return result;
1654}
1655
1656XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEndCommandBuffer(XGL_CMD_BUFFER cmdBuffer)
1657{
1658 XGL_RESULT result = nextTable.EndCommandBuffer(cmdBuffer);
1659 return result;
1660}
1661
1662XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglResetCommandBuffer(XGL_CMD_BUFFER cmdBuffer)
1663{
1664 XGL_RESULT result = nextTable.ResetCommandBuffer(cmdBuffer);
1665 return result;
1666}
1667
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001668XGL_LAYER_EXPORT void XGLAPI xglCmdBindPipeline(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE pipeline)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001669{
1670 if (getPipeline(pipeline)) {
1671 lastBoundPipeline = pipeline;
1672 }
1673 else {
Tobin Ehlise79df942014-11-18 16:38:08 -07001674 char str[1024];
1675 sprintf(str, "Attempt to bind Pipeline %p that doesn't exist!", (void*)pipeline);
1676 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, pipeline, 0, DRAWSTATE_INVALID_PIPELINE, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001677 }
1678 nextTable.CmdBindPipeline(cmdBuffer, pipelineBindPoint, pipeline);
1679}
1680
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001681XGL_LAYER_EXPORT void XGLAPI xglCmdBindPipelineDelta(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_PIPELINE_DELTA delta)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001682{
1683 nextTable.CmdBindPipelineDelta(cmdBuffer, pipelineBindPoint, delta);
1684}
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001685
1686XGL_LAYER_EXPORT void XGLAPI xglCmdBindDynamicStateObject(XGL_CMD_BUFFER cmdBuffer, XGL_STATE_BIND_POINT stateBindPoint, XGL_DYNAMIC_STATE_OBJECT state)
1687{
1688 setLastBoundDynamicState(state, stateBindPoint);
1689 nextTable.CmdBindDynamicStateObject(cmdBuffer, stateBindPoint, state);
1690}
1691
1692XGL_LAYER_EXPORT void XGLAPI xglCmdBindDescriptorSet(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, XGL_DESCRIPTOR_SET descriptorSet, const uint32_t* pUserData)
1693{
Tobin Ehlis41415bb2015-01-22 10:45:21 -07001694 // TODO : Improve this. Can track per-cmd buffer and store bind point and pUserData
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001695 if (getSetNode(descriptorSet)) {
1696 if (dsUpdateActive(descriptorSet)) {
1697 // TODO : Not sure if it's valid to made this check here. May need to make as QueueSubmit time
1698 char str[1024];
1699 sprintf(str, "You must call xglEndDescriptorRegionUpdate(%p) before this call to xglCmdBindDescriptorSet()!", (void*)descriptorSet);
1700 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_BINDING_DS_NO_END_UPDATE, "DS", str);
1701 }
1702 loader_platform_thread_lock_mutex(&globalLock);
1703 g_lastBoundDS = descriptorSet;
1704 loader_platform_thread_unlock_mutex(&globalLock);
1705 char str[1024];
1706 sprintf(str, "DS %p bound on pipeline %s", (void*)descriptorSet, string_XGL_PIPELINE_BIND_POINT(pipelineBindPoint));
1707 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_NONE, "DS", str);
1708 }
1709 else {
1710 char str[1024];
1711 sprintf(str, "Attempt to bind DS %p that doesn't exist!", (void*)descriptorSet);
1712 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, descriptorSet, 0, DRAWSTATE_INVALID_SET, "DS", str);
1713 }
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001714 nextTable.CmdBindDescriptorSet(cmdBuffer, pipelineBindPoint, descriptorSet, pUserData);
1715}
1716
1717XGL_LAYER_EXPORT void XGLAPI xglCmdBindIndexBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, XGL_INDEX_TYPE indexType)
1718{
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001719 nextTable.CmdBindIndexBuffer(cmdBuffer, buffer, offset, indexType);
1720}
1721
1722XGL_LAYER_EXPORT void XGLAPI xglCmdBindVertexBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, uint32_t binding)
Chia-I Wu3b04af52014-11-08 10:48:20 +08001723{
Tobin Ehlis83ebbef2015-02-10 15:35:23 -07001724 g_lastVtxBinding = binding;
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001725 nextTable.CmdBindVertexBuffer(cmdBuffer, buffer, offset, binding);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001726}
1727
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001728XGL_LAYER_EXPORT void XGLAPI xglCmdDraw(XGL_CMD_BUFFER cmdBuffer, uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001729{
Tobin Ehlise79df942014-11-18 16:38:08 -07001730 char str[1024];
1731 sprintf(str, "xglCmdDraw() call #%lu, reporting DS state:", drawCount[DRAW]++);
1732 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001733 synchAndPrintDSConfig();
1734 nextTable.CmdDraw(cmdBuffer, firstVertex, vertexCount, firstInstance, instanceCount);
1735}
1736
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001737XGL_LAYER_EXPORT void XGLAPI xglCmdDrawIndexed(XGL_CMD_BUFFER cmdBuffer, uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001738{
Tobin Ehlise79df942014-11-18 16:38:08 -07001739 char str[1024];
Tobin Ehlis62086412014-11-19 16:19:28 -07001740 sprintf(str, "xglCmdDrawIndexed() call #%lu, reporting DS state:", drawCount[DRAW_INDEXED]++);
Tobin Ehlise79df942014-11-18 16:38:08 -07001741 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlisb8154982014-10-27 14:53:17 -06001742 synchAndPrintDSConfig();
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001743 nextTable.CmdDrawIndexed(cmdBuffer, firstIndex, indexCount, vertexOffset, firstInstance, instanceCount);
1744}
1745
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001746XGL_LAYER_EXPORT void XGLAPI xglCmdDrawIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, uint32_t count, uint32_t stride)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001747{
Tobin Ehlise79df942014-11-18 16:38:08 -07001748 char str[1024];
Tobin Ehlis62086412014-11-19 16:19:28 -07001749 sprintf(str, "xglCmdDrawIndirect() call #%lu, reporting DS state:", drawCount[DRAW_INDIRECT]++);
Tobin Ehlise79df942014-11-18 16:38:08 -07001750 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlisb8154982014-10-27 14:53:17 -06001751 synchAndPrintDSConfig();
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001752 nextTable.CmdDrawIndirect(cmdBuffer, buffer, offset, count, stride);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001753}
1754
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001755XGL_LAYER_EXPORT void XGLAPI xglCmdDrawIndexedIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset, uint32_t count, uint32_t stride)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001756{
Tobin Ehlise79df942014-11-18 16:38:08 -07001757 char str[1024];
Tobin Ehlis62086412014-11-19 16:19:28 -07001758 sprintf(str, "xglCmdDrawIndexedIndirect() call #%lu, reporting DS state:", drawCount[DRAW_INDEXED_INDIRECT]++);
Tobin Ehlise79df942014-11-18 16:38:08 -07001759 layerCbMsg(XGL_DBG_MSG_UNKNOWN, XGL_VALIDATION_LEVEL_0, cmdBuffer, 0, DRAWSTATE_NONE, "DS", str);
Tobin Ehlisb8154982014-10-27 14:53:17 -06001760 synchAndPrintDSConfig();
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001761 nextTable.CmdDrawIndexedIndirect(cmdBuffer, buffer, offset, count, stride);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001762}
1763
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001764XGL_LAYER_EXPORT void XGLAPI xglCmdDispatch(XGL_CMD_BUFFER cmdBuffer, uint32_t x, uint32_t y, uint32_t z)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001765{
1766 nextTable.CmdDispatch(cmdBuffer, x, y, z);
1767}
1768
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001769XGL_LAYER_EXPORT void XGLAPI xglCmdDispatchIndirect(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER buffer, XGL_GPU_SIZE offset)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001770{
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001771 nextTable.CmdDispatchIndirect(cmdBuffer, buffer, offset);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001772}
1773
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001774XGL_LAYER_EXPORT void XGLAPI xglCmdCopyBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER srcBuffer, XGL_BUFFER destBuffer, uint32_t regionCount, const XGL_BUFFER_COPY* pRegions)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001775{
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001776 nextTable.CmdCopyBuffer(cmdBuffer, srcBuffer, destBuffer, regionCount, pRegions);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001777}
1778
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001779XGL_LAYER_EXPORT void XGLAPI xglCmdCopyImage(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_IMAGE destImage, uint32_t regionCount, const XGL_IMAGE_COPY* pRegions)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001780{
1781 nextTable.CmdCopyImage(cmdBuffer, srcImage, destImage, regionCount, pRegions);
1782}
1783
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001784XGL_LAYER_EXPORT void XGLAPI xglCmdCopyBufferToImage(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER srcBuffer, XGL_IMAGE destImage, uint32_t regionCount, const XGL_BUFFER_IMAGE_COPY* pRegions)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001785{
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001786 nextTable.CmdCopyBufferToImage(cmdBuffer, srcBuffer, destImage, regionCount, pRegions);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001787}
1788
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001789XGL_LAYER_EXPORT void XGLAPI xglCmdCopyImageToBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_BUFFER destBuffer, uint32_t regionCount, const XGL_BUFFER_IMAGE_COPY* pRegions)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001790{
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001791 nextTable.CmdCopyImageToBuffer(cmdBuffer, srcImage, destBuffer, regionCount, pRegions);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001792}
1793
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001794XGL_LAYER_EXPORT void XGLAPI xglCmdCloneImageData(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_IMAGE_LAYOUT srcImageLayout, XGL_IMAGE destImage, XGL_IMAGE_LAYOUT destImageLayout)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001795{
Mike Stroyan55658c22014-12-04 11:08:39 +00001796 nextTable.CmdCloneImageData(cmdBuffer, srcImage, srcImageLayout, destImage, destImageLayout);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001797}
1798
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001799XGL_LAYER_EXPORT void XGLAPI xglCmdUpdateBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER destBuffer, XGL_GPU_SIZE destOffset, XGL_GPU_SIZE dataSize, const uint32_t* pData)
1800{
1801 nextTable.CmdUpdateBuffer(cmdBuffer, destBuffer, destOffset, dataSize, pData);
1802}
1803
1804XGL_LAYER_EXPORT void XGLAPI xglCmdFillBuffer(XGL_CMD_BUFFER cmdBuffer, XGL_BUFFER destBuffer, XGL_GPU_SIZE destOffset, XGL_GPU_SIZE fillSize, uint32_t data)
1805{
1806 nextTable.CmdFillBuffer(cmdBuffer, destBuffer, destOffset, fillSize, data);
1807}
1808
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001809XGL_LAYER_EXPORT void XGLAPI xglCmdClearColorImage(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE image, const float color[4], uint32_t rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001810{
1811 nextTable.CmdClearColorImage(cmdBuffer, image, color, rangeCount, pRanges);
1812}
1813
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001814XGL_LAYER_EXPORT void XGLAPI xglCmdClearColorImageRaw(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE image, const uint32_t color[4], uint32_t rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001815{
1816 nextTable.CmdClearColorImageRaw(cmdBuffer, image, color, rangeCount, pRanges);
1817}
1818
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001819XGL_LAYER_EXPORT void XGLAPI xglCmdClearDepthStencil(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE image, float depth, uint32_t stencil, uint32_t rangeCount, const XGL_IMAGE_SUBRESOURCE_RANGE* pRanges)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001820{
1821 nextTable.CmdClearDepthStencil(cmdBuffer, image, depth, stencil, rangeCount, pRanges);
1822}
1823
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001824XGL_LAYER_EXPORT void XGLAPI xglCmdResolveImage(XGL_CMD_BUFFER cmdBuffer, XGL_IMAGE srcImage, XGL_IMAGE destImage, uint32_t rectCount, const XGL_IMAGE_RESOLVE* pRects)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001825{
1826 nextTable.CmdResolveImage(cmdBuffer, srcImage, destImage, rectCount, pRects);
1827}
1828
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001829XGL_LAYER_EXPORT void XGLAPI xglCmdSetEvent(XGL_CMD_BUFFER cmdBuffer, XGL_EVENT event, XGL_SET_EVENT pipeEvent)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001830{
Mike Stroyan55658c22014-12-04 11:08:39 +00001831 nextTable.CmdSetEvent(cmdBuffer, event, pipeEvent);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001832}
1833
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001834XGL_LAYER_EXPORT void XGLAPI xglCmdResetEvent(XGL_CMD_BUFFER cmdBuffer, XGL_EVENT event)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001835{
1836 nextTable.CmdResetEvent(cmdBuffer, event);
1837}
1838
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001839XGL_LAYER_EXPORT void XGLAPI xglCmdWaitEvents(XGL_CMD_BUFFER cmdBuffer, const XGL_EVENT_WAIT_INFO* pWaitInfo)
Mike Stroyan55658c22014-12-04 11:08:39 +00001840{
1841 nextTable.CmdWaitEvents(cmdBuffer, pWaitInfo);
1842}
1843
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001844XGL_LAYER_EXPORT void XGLAPI xglCmdPipelineBarrier(XGL_CMD_BUFFER cmdBuffer, const XGL_PIPELINE_BARRIER* pBarrier)
Mike Stroyan55658c22014-12-04 11:08:39 +00001845{
1846 nextTable.CmdPipelineBarrier(cmdBuffer, pBarrier);
1847}
1848
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001849XGL_LAYER_EXPORT void XGLAPI xglCmdBeginQuery(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, uint32_t slot, XGL_FLAGS flags)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001850{
1851 nextTable.CmdBeginQuery(cmdBuffer, queryPool, slot, flags);
1852}
1853
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001854XGL_LAYER_EXPORT void XGLAPI xglCmdEndQuery(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, uint32_t slot)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001855{
1856 nextTable.CmdEndQuery(cmdBuffer, queryPool, slot);
1857}
1858
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001859XGL_LAYER_EXPORT void XGLAPI xglCmdResetQueryPool(XGL_CMD_BUFFER cmdBuffer, XGL_QUERY_POOL queryPool, uint32_t startQuery, uint32_t queryCount)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001860{
1861 nextTable.CmdResetQueryPool(cmdBuffer, queryPool, startQuery, queryCount);
1862}
1863
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001864XGL_LAYER_EXPORT void XGLAPI xglCmdWriteTimestamp(XGL_CMD_BUFFER cmdBuffer, XGL_TIMESTAMP_TYPE timestampType, XGL_BUFFER destBuffer, XGL_GPU_SIZE destOffset)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001865{
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001866 nextTable.CmdWriteTimestamp(cmdBuffer, timestampType, destBuffer, destOffset);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001867}
1868
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001869XGL_LAYER_EXPORT void XGLAPI xglCmdInitAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, const uint32_t* pData)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001870{
1871 nextTable.CmdInitAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, pData);
1872}
1873
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001874XGL_LAYER_EXPORT void XGLAPI xglCmdLoadAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, XGL_BUFFER srcBuffer, XGL_GPU_SIZE srcOffset)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001875{
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001876 nextTable.CmdLoadAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, srcBuffer, srcOffset);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001877}
1878
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001879XGL_LAYER_EXPORT void XGLAPI xglCmdSaveAtomicCounters(XGL_CMD_BUFFER cmdBuffer, XGL_PIPELINE_BIND_POINT pipelineBindPoint, uint32_t startCounter, uint32_t counterCount, XGL_BUFFER destBuffer, XGL_GPU_SIZE destOffset)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001880{
Tobin Ehlis84c521c2015-01-19 08:42:29 -07001881 nextTable.CmdSaveAtomicCounters(cmdBuffer, pipelineBindPoint, startCounter, counterCount, destBuffer, destOffset);
1882}
1883
1884XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateFramebuffer(XGL_DEVICE device, const XGL_FRAMEBUFFER_CREATE_INFO* pCreateInfo, XGL_FRAMEBUFFER* pFramebuffer)
1885{
1886 XGL_RESULT result = nextTable.CreateFramebuffer(device, pCreateInfo, pFramebuffer);
1887 return result;
1888}
1889
1890XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateRenderPass(XGL_DEVICE device, const XGL_RENDER_PASS_CREATE_INFO* pCreateInfo, XGL_RENDER_PASS* pRenderPass)
1891{
1892 XGL_RESULT result = nextTable.CreateRenderPass(device, pCreateInfo, pRenderPass);
1893 return result;
1894}
1895
1896XGL_LAYER_EXPORT void XGLAPI xglCmdBeginRenderPass(XGL_CMD_BUFFER cmdBuffer, XGL_RENDER_PASS renderPass)
1897{
1898 nextTable.CmdBeginRenderPass(cmdBuffer, renderPass);
1899}
1900
1901XGL_LAYER_EXPORT void XGLAPI xglCmdEndRenderPass(XGL_CMD_BUFFER cmdBuffer, XGL_RENDER_PASS renderPass)
1902{
1903 nextTable.CmdEndRenderPass(cmdBuffer, renderPass);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001904}
1905
1906XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetValidationLevel(XGL_DEVICE device, XGL_VALIDATION_LEVEL validationLevel)
1907{
1908 XGL_RESULT result = nextTable.DbgSetValidationLevel(device, validationLevel);
1909 return result;
1910}
1911
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001912XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgRegisterMsgCallback(XGL_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback, void* pUserData)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001913{
Tobin Ehlise79df942014-11-18 16:38:08 -07001914 // This layer intercepts callbacks
1915 XGL_LAYER_DBG_FUNCTION_NODE *pNewDbgFuncNode = (XGL_LAYER_DBG_FUNCTION_NODE*)malloc(sizeof(XGL_LAYER_DBG_FUNCTION_NODE));
1916 if (!pNewDbgFuncNode)
1917 return XGL_ERROR_OUT_OF_MEMORY;
1918 pNewDbgFuncNode->pfnMsgCallback = pfnMsgCallback;
1919 pNewDbgFuncNode->pUserData = pUserData;
Jon Ashburn2e9b5612014-12-22 13:38:27 -07001920 pNewDbgFuncNode->pNext = g_pDbgFunctionHead;
1921 g_pDbgFunctionHead = pNewDbgFuncNode;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001922 XGL_RESULT result = nextTable.DbgRegisterMsgCallback(pfnMsgCallback, pUserData);
1923 return result;
1924}
1925
1926XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgUnregisterMsgCallback(XGL_DBG_MSG_CALLBACK_FUNCTION pfnMsgCallback)
1927{
Jon Ashburn2e9b5612014-12-22 13:38:27 -07001928 XGL_LAYER_DBG_FUNCTION_NODE *pTrav = g_pDbgFunctionHead;
Tobin Ehlise79df942014-11-18 16:38:08 -07001929 XGL_LAYER_DBG_FUNCTION_NODE *pPrev = pTrav;
1930 while (pTrav) {
1931 if (pTrav->pfnMsgCallback == pfnMsgCallback) {
1932 pPrev->pNext = pTrav->pNext;
Jon Ashburn2e9b5612014-12-22 13:38:27 -07001933 if (g_pDbgFunctionHead == pTrav)
1934 g_pDbgFunctionHead = pTrav->pNext;
Tobin Ehlise79df942014-11-18 16:38:08 -07001935 free(pTrav);
1936 break;
1937 }
1938 pPrev = pTrav;
1939 pTrav = pTrav->pNext;
1940 }
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001941 XGL_RESULT result = nextTable.DbgUnregisterMsgCallback(pfnMsgCallback);
1942 return result;
1943}
1944
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001945XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetMessageFilter(XGL_DEVICE device, int32_t msgCode, XGL_DBG_MSG_FILTER filter)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001946{
1947 XGL_RESULT result = nextTable.DbgSetMessageFilter(device, msgCode, filter);
1948 return result;
1949}
1950
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001951XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetObjectTag(XGL_BASE_OBJECT object, size_t tagSize, const void* pTag)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001952{
1953 XGL_RESULT result = nextTable.DbgSetObjectTag(object, tagSize, pTag);
1954 return result;
1955}
1956
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001957XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetGlobalOption(XGL_DBG_GLOBAL_OPTION dbgOption, size_t dataSize, const void* pData)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001958{
1959 XGL_RESULT result = nextTable.DbgSetGlobalOption(dbgOption, dataSize, pData);
1960 return result;
1961}
1962
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001963XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglDbgSetDeviceOption(XGL_DEVICE device, XGL_DBG_DEVICE_OPTION dbgOption, size_t dataSize, const void* pData)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001964{
1965 XGL_RESULT result = nextTable.DbgSetDeviceOption(device, dbgOption, dataSize, pData);
1966 return result;
1967}
1968
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001969XGL_LAYER_EXPORT void XGLAPI xglCmdDbgMarkerBegin(XGL_CMD_BUFFER cmdBuffer, const char* pMarker)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001970{
1971 nextTable.CmdDbgMarkerBegin(cmdBuffer, pMarker);
1972}
1973
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001974XGL_LAYER_EXPORT void XGLAPI xglCmdDbgMarkerEnd(XGL_CMD_BUFFER cmdBuffer)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001975{
1976 nextTable.CmdDbgMarkerEnd(cmdBuffer);
1977}
1978
Ian Elliott81ac44c2015-01-13 17:52:38 -07001979#if defined(WIN32)
1980// FIXME: NEED WINDOWS EQUIVALENT
1981#else // WIN32
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001982XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11AssociateConnection(XGL_PHYSICAL_GPU gpu, const XGL_WSI_X11_CONNECTION_INFO* pConnectionInfo)
1983{
1984 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001985 pCurObj = gpuw;
Ian Elliott81ac44c2015-01-13 17:52:38 -07001986 loader_platform_thread_once(&g_initOnce, initDrawState);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001987 XGL_RESULT result = nextTable.WsiX11AssociateConnection((XGL_PHYSICAL_GPU)gpuw->nextObject, pConnectionInfo);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001988 return result;
1989}
1990
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06001991XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11GetMSC(XGL_DEVICE device, xcb_window_t window, xcb_randr_crtc_t crtc, uint64_t* pMsc)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001992{
Chia-I Wu6204f342014-11-07 13:33:45 +08001993 XGL_RESULT result = nextTable.WsiX11GetMSC(device, window, crtc, pMsc);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06001994 return result;
1995}
1996
1997XGL_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)
1998{
1999 XGL_RESULT result = nextTable.WsiX11CreatePresentableImage(device, pCreateInfo, pImage, pMem);
2000 return result;
2001}
2002
2003XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglWsiX11QueuePresent(XGL_QUEUE queue, const XGL_WSI_X11_PRESENT_INFO* pPresentInfo, XGL_FENCE fence)
2004{
2005 XGL_RESULT result = nextTable.WsiX11QueuePresent(queue, pPresentInfo, fence);
2006 return result;
2007}
Ian Elliott81ac44c2015-01-13 17:52:38 -07002008#endif // WIN32
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002009
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06002010void drawStateDumpDotFile(char* outFileName)
Tobin Ehlisa701ef02014-11-27 15:43:39 -07002011{
2012 dumpDotFile(outFileName);
2013}
2014
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06002015void drawStateDumpPngFile(char* outFileName)
Tobin Ehlis266473d2014-12-16 17:34:50 -07002016{
Ian Elliott81ac44c2015-01-13 17:52:38 -07002017#if defined(_WIN32)
2018// FIXME: NEED WINDOWS EQUIVALENT
2019 char str[1024];
2020 sprintf(str, "Cannot execute dot program yet on Windows.");
2021 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_MISSING_DOT_PROGRAM, "DS", str);
2022#else // WIN32
Tobin Ehlis266473d2014-12-16 17:34:50 -07002023 char dotExe[32] = "/usr/bin/dot";
2024 if( access(dotExe, X_OK) != -1) {
2025 dumpDotFile("/tmp/tmp.dot");
2026 char dotCmd[1024];
2027 sprintf(dotCmd, "%s /tmp/tmp.dot -Tpng -o %s", dotExe, outFileName);
2028 system(dotCmd);
2029 remove("/tmp/tmp.dot");
2030 }
2031 else {
2032 char str[1024];
2033 sprintf(str, "Cannot execute dot program at (%s) to dump requested %s file.", dotExe, outFileName);
2034 layerCbMsg(XGL_DBG_MSG_ERROR, XGL_VALIDATION_LEVEL_0, NULL, 0, DRAWSTATE_MISSING_DOT_PROGRAM, "DS", str);
2035 }
Ian Elliott81ac44c2015-01-13 17:52:38 -07002036#endif // WIN32
Tobin Ehlis266473d2014-12-16 17:34:50 -07002037}
2038
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -06002039XGL_LAYER_EXPORT void* XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const char* funcName)
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002040{
2041 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
Chia-I Wu706533e2015-01-05 13:18:57 +08002042 void *addr;
2043
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002044 if (gpu == NULL)
2045 return NULL;
2046 pCurObj = gpuw;
Ian Elliott81ac44c2015-01-13 17:52:38 -07002047 loader_platform_thread_once(&g_initOnce, initDrawState);
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002048
Chia-I Wu706533e2015-01-05 13:18:57 +08002049 addr = layer_intercept_proc(funcName);
2050 if (addr)
2051 return addr;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002052 else if (!strncmp("drawStateDumpDotFile", funcName, sizeof("drawStateDumpDotFile")))
Tobin Ehlisa701ef02014-11-27 15:43:39 -07002053 return drawStateDumpDotFile;
Chia-I Wu7461fcf2014-12-27 15:16:07 +08002054 else if (!strncmp("drawStateDumpPngFile", funcName, sizeof("drawStateDumpPngFile")))
Tobin Ehlis266473d2014-12-16 17:34:50 -07002055 return drawStateDumpPngFile;
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002056 else {
Tobin Ehlis8726b9f2014-10-24 12:01:45 -06002057 if (gpuw->pGPA == NULL)
2058 return NULL;
2059 return gpuw->pGPA(gpuw->nextObject, funcName);
2060 }
2061}