blob: 57c865cc0e47cc8a8e1e598c1bf05e3055d2f695 [file] [log] [blame]
Jon Ashburn8d8dad02014-12-01 14:22:40 -07001/*
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 */
Jon Ashburn227a9422014-11-26 11:10:26 -070024#include <string.h>
25#include <stdlib.h>
26#include <assert.h>
27#include <unordered_map>
Chia-I Wu0f65b1e2015-01-04 23:11:43 +080028#include "xgl_dispatch_table_helper.h"
Jon Ashburn227a9422014-11-26 11:10:26 -070029#include "xglLayer.h"
30
31static std::unordered_map<XGL_VOID *, XGL_LAYER_DISPATCH_TABLE *> tableMap;
32
33static XGL_LAYER_DISPATCH_TABLE * initLayerTable(const XGL_BASE_LAYER_OBJECT *gpuw)
34{
35 GetProcAddrType fpGPA;
36 XGL_LAYER_DISPATCH_TABLE *pTable;
37
38 assert(gpuw);
39 std::unordered_map<XGL_VOID *, XGL_LAYER_DISPATCH_TABLE *>::const_iterator it = tableMap.find((XGL_VOID *) gpuw);
40 if (it == tableMap.end())
41 {
42 pTable = new XGL_LAYER_DISPATCH_TABLE;
43 tableMap[(XGL_VOID *) gpuw] = pTable;
44 } else
45 {
46 return it->second;
47 }
Chia-I Wu0f65b1e2015-01-04 23:11:43 +080048
49 layer_initialize_dispatch_table(pTable, gpuw->pGPA, (XGL_PHYSICAL_GPU) gpuw->nextObject);
50
Jon Ashburn227a9422014-11-26 11:10:26 -070051 return pTable;
52}
53
54XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglLayerExtension1(XGL_DEVICE device)
55{
56 printf("In xglLayerExtension1() call w/ device: %p\n", (void*)device);
57 printf("xglLayerExtension1 returning SUCCESS\n");
58 return XGL_SUCCESS;
59}
60
61XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetExtensionSupport(XGL_PHYSICAL_GPU gpu, const XGL_CHAR* pExtName)
62{
63 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
64 XGL_RESULT result;
65 XGL_LAYER_DISPATCH_TABLE* pTable = initLayerTable(gpuw);
66
67 printf("At start of wrapped xglGetExtensionSupport() call w/ gpu: %p\n", (void*)gpu);
Chia-I Wu7461fcf2014-12-27 15:16:07 +080068 if (!strncmp(pExtName, "xglLayerExtension1", strlen("xglLayerExtension1")))
Jon Ashburn227a9422014-11-26 11:10:26 -070069 result = XGL_SUCCESS;
70 else
71 result = pTable->GetExtensionSupport((XGL_PHYSICAL_GPU)gpuw->nextObject, pExtName);
72 printf("Completed wrapped xglGetExtensionSupport() call w/ gpu: %p\n", (void*)gpu);
73 return result;
74}
75
76XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglCreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreateInfo, XGL_DEVICE* pDevice)
77{
78 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
79 XGL_LAYER_DISPATCH_TABLE* pTable = initLayerTable(gpuw);
80
81 printf("At start of wrapped xglCreateDevice() call w/ gpu: %p\n", (void*)gpu);
82 XGL_RESULT result = pTable->CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice);
83 // create a mapping for the device object into the dispatch table
84 tableMap.emplace(*pDevice, pTable);
85 printf("Completed wrapped xglCreateDevice() call w/ pDevice, Device %p: %p\n", (void*)pDevice, (void *) *pDevice);
86 return result;
87}
88XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetFormatInfo(XGL_DEVICE device, XGL_FORMAT format, XGL_FORMAT_INFO_TYPE infoType, XGL_SIZE* pDataSize, XGL_VOID* pData)
89{
90 XGL_LAYER_DISPATCH_TABLE* pTable = tableMap[device];
91
92 printf("At start of wrapped xglGetFormatInfo() call w/ device: %p\n", (void*)device);
93 XGL_RESULT result = pTable->GetFormatInfo(device, format, infoType, pDataSize, pData);
94 printf("Completed wrapped xglGetFormatInfo() call w/ device: %p\n", (void*)device);
95 return result;
96}
97
98XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, XGL_SIZE maxLayerCount, XGL_SIZE maxStringSize, XGL_CHAR* const* pOutLayers, XGL_SIZE * pOutLayerCount, XGL_VOID* pReserved)
99{
100 if (gpu != NULL)
101 {
102 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
103 XGL_LAYER_DISPATCH_TABLE* pTable = initLayerTable(gpuw);
104
105 printf("At start of wrapped xglEnumerateLayers() call w/ gpu: %p\n", gpu);
106 XGL_RESULT result = pTable->EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayers, pOutLayerCount, pReserved);
107 return result;
108 } else
109 {
110 if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL || pReserved == NULL)
111 return XGL_ERROR_INVALID_POINTER;
112
113 // Example of a layer that is only compatible with Intel's GPUs
114 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT*) pReserved;
115 GetGpuInfoType fpGetGpuInfo;
116 XGL_PHYSICAL_GPU_PROPERTIES gpuProps;
117 XGL_SIZE dataSize = sizeof(XGL_PHYSICAL_GPU_PROPERTIES);
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800118 fpGetGpuInfo = (GetGpuInfoType) gpuw->pGPA((XGL_PHYSICAL_GPU) gpuw->nextObject, "xglGetGpuInfo");
Jon Ashburn227a9422014-11-26 11:10:26 -0700119 fpGetGpuInfo((XGL_PHYSICAL_GPU) gpuw->nextObject, XGL_INFO_TYPE_PHYSICAL_GPU_PROPERTIES, &dataSize, &gpuProps);
120 if (gpuProps.vendorId == 0x8086)
121 {
122 *pOutLayerCount = 1;
123 strncpy((char *) pOutLayers[0], "Basic", maxStringSize);
124 } else
125 {
126 *pOutLayerCount = 0;
127 }
128 return XGL_SUCCESS;
129 }
130}
131
Jon Ashburn8d8dad02014-12-01 14:22:40 -0700132XGL_LAYER_EXPORT XGL_VOID * XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const XGL_CHAR* pName)
133{
Jon Ashburn227a9422014-11-26 11:10:26 -0700134 XGL_LAYER_DISPATCH_TABLE* pTable;
Jon Ashburn8d8dad02014-12-01 14:22:40 -0700135
Jon Ashburn227a9422014-11-26 11:10:26 -0700136 if (gpu == NULL)
137 return NULL;
Jon Ashburn8d8dad02014-12-01 14:22:40 -0700138 pTable = initLayerTable((const XGL_BASE_LAYER_OBJECT *) gpu);
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800139 if (!strncmp("xglGetProcAddr", pName, sizeof("xglGetProcAddr")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700140 return (XGL_VOID *) xglGetProcAddr;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800141 else if (!strncmp("xglInitAndEnumerateGpus", pName, sizeof("xglInitAndEnumerateGpus")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700142 return (XGL_VOID *) pTable->InitAndEnumerateGpus;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800143 if (!strncmp("xglGetGpuInfo", pName, sizeof ("xglGetGpuInfo")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700144 return (XGL_VOID *) pTable->GetGpuInfo;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800145 else if (!strncmp("xglCreateDevice", pName, sizeof ("xglCreateDevice")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700146 return (XGL_VOID *) xglCreateDevice;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800147 else if (!strncmp("xglDestroyDevice", pName, sizeof ("xglDestroyDevice")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700148 return (XGL_VOID *) pTable->DestroyDevice;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800149 else if (!strncmp("xglGetExtensionSupport", pName, sizeof ("xglGetExtensionSupport")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700150 return (XGL_VOID *) xglGetExtensionSupport;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800151 else if (!strncmp("xglEnumerateLayers", pName, sizeof ("xglEnumerateLayers")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700152 return (XGL_VOID *) xglEnumerateLayers;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800153 else if (!strncmp("xglGetDeviceQueue", pName, sizeof ("xglGetDeviceQueue")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700154 return (XGL_VOID *) pTable->GetDeviceQueue;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800155 else if (!strncmp("xglQueueSubmit", pName, sizeof ("xglQueueSubmit")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700156 return (XGL_VOID *) pTable->QueueSubmit;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800157 else if (!strncmp("xglQueueSetGlobalMemReferences", pName, sizeof ("xglQueueSetGlobalMemReferences")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700158 return (XGL_VOID *) pTable->QueueSetGlobalMemReferences;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800159 else if (!strncmp("xglQueueWaitIdle", pName, sizeof ("xglQueueWaitIdle")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700160 return (XGL_VOID *) pTable->QueueWaitIdle;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800161 else if (!strncmp("xglDeviceWaitIdle", pName, sizeof ("xglDeviceWaitIdle")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700162 return (XGL_VOID *) pTable->DeviceWaitIdle;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800163 else if (!strncmp("xglGetMemoryHeapCount", pName, sizeof ("xglGetMemoryHeapCount")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700164 return (XGL_VOID *) pTable->GetMemoryHeapCount;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800165 else if (!strncmp("xglGetMemoryHeapInfo", pName, sizeof ("xglGetMemoryHeapInfo")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700166 return (XGL_VOID *) pTable->GetMemoryHeapInfo;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800167 else if (!strncmp("xglAllocMemory", pName, sizeof ("xglAllocMemory")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700168 return (XGL_VOID *) pTable->AllocMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800169 else if (!strncmp("xglFreeMemory", pName, sizeof ("xglFreeMemory")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700170 return (XGL_VOID *) pTable->FreeMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800171 else if (!strncmp("xglSetMemoryPriority", pName, sizeof ("xglSetMemoryPriority")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700172 return (XGL_VOID *) pTable->SetMemoryPriority;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800173 else if (!strncmp("xglMapMemory", pName, sizeof ("xglMapMemory")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700174 return (XGL_VOID *) pTable->MapMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800175 else if (!strncmp("xglUnmapMemory", pName, sizeof ("xglUnmapMemory")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700176 return (XGL_VOID *) pTable->UnmapMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800177 else if (!strncmp("xglPinSystemMemory", pName, sizeof ("xglPinSystemMemory")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700178 return (XGL_VOID *) pTable->PinSystemMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800179 else if (!strncmp("xglRemapVirtualMemoryPages", pName, sizeof ("xglRemapVirtualMemoryPages")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700180 return (XGL_VOID *) pTable->RemapVirtualMemoryPages;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800181 else if (!strncmp("xglGetMultiGpuCompatibility", pName, sizeof ("xglGetMultiGpuCompatibility")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700182 return (XGL_VOID *) pTable->GetMultiGpuCompatibility;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800183 else if (!strncmp("xglOpenSharedMemory", pName, sizeof ("xglOpenSharedMemory")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700184 return (XGL_VOID *) pTable->OpenSharedMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800185 else if (!strncmp("xglOpenSharedQueueSemaphore", pName, sizeof ("xglOpenSharedQueueSemaphore")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700186 return (XGL_VOID *) pTable->OpenSharedQueueSemaphore;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800187 else if (!strncmp("xglOpenPeerMemory", pName, sizeof ("xglOpenPeerMemory")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700188 return (XGL_VOID *) pTable->OpenPeerMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800189 else if (!strncmp("xglOpenPeerImage", pName, sizeof ("xglOpenPeerImage")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700190 return (XGL_VOID *) pTable->OpenPeerImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800191 else if (!strncmp("xglDestroyObject", pName, sizeof ("xglDestroyObject")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700192 return (XGL_VOID *) pTable->DestroyObject;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800193 else if (!strncmp("xglGetObjectInfo", pName, sizeof ("xglGetObjectInfo")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700194 return (XGL_VOID *) pTable->GetObjectInfo;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800195 else if (!strncmp("xglBindObjectMemory", pName, sizeof ("xglBindObjectMemory")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700196 return (XGL_VOID *) pTable->BindObjectMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800197 else if (!strncmp("xglCreateFence", pName, sizeof ("xgllCreateFence")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700198 return (XGL_VOID *) pTable->CreateFence;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800199 else if (!strncmp("xglGetFenceStatus", pName, sizeof ("xglGetFenceStatus")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700200 return (XGL_VOID *) pTable->GetFenceStatus;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800201 else if (!strncmp("xglWaitForFences", pName, sizeof ("xglWaitForFences")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700202 return (XGL_VOID *) pTable->WaitForFences;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800203 else if (!strncmp("xglCreateQueueSemaphore", pName, sizeof ("xgllCreateQueueSemaphore")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700204 return (XGL_VOID *) pTable->CreateQueueSemaphore;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800205 else if (!strncmp("xglSignalQueueSemaphore", pName, sizeof ("xglSignalQueueSemaphore")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700206 return (XGL_VOID *) pTable->SignalQueueSemaphore;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800207 else if (!strncmp("xglWaitQueueSemaphore", pName, sizeof ("xglWaitQueueSemaphore")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700208 return (XGL_VOID *) pTable->WaitQueueSemaphore;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800209 else if (!strncmp("xglCreateEvent", pName, sizeof ("xgllCreateEvent")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700210 return (XGL_VOID *) pTable->CreateEvent;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800211 else if (!strncmp("xglGetEventStatus", pName, sizeof ("xglGetEventStatus")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700212 return (XGL_VOID *) pTable->GetEventStatus;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800213 else if (!strncmp("xglSetEvent", pName, sizeof ("xglSetEvent")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700214 return (XGL_VOID *) pTable->SetEvent;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800215 else if (!strncmp("xglResetEvent", pName, sizeof ("xgllResetEvent")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700216 return (XGL_VOID *) pTable->ResetEvent;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800217 else if (!strncmp("xglCreateQueryPool", pName, sizeof ("xglCreateQueryPool")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700218 return (XGL_VOID *) pTable->CreateQueryPool;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800219 else if (!strncmp("xglGetQueryPoolResults", pName, sizeof ("xglGetQueryPoolResults")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700220 return (XGL_VOID *) pTable->GetQueryPoolResults;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800221 else if (!strncmp("xglGetFormatInfo", pName, sizeof ("xglGetFormatInfo")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700222 return (XGL_VOID *) xglGetFormatInfo;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800223 else if (!strncmp("xglCreateImage", pName, sizeof ("xglCreateImage")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700224 return (XGL_VOID *) pTable->CreateImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800225 else if (!strncmp("xglGetImageSubresourceInfo", pName, sizeof ("xglGetImageSubresourceInfo")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700226 return (XGL_VOID *) pTable->GetImageSubresourceInfo;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800227 else if (!strncmp("xglCreateImageView", pName, sizeof ("xglCreateImageView")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700228 return (XGL_VOID *) pTable->CreateImageView;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800229 else if (!strncmp("xglCreateColorAttachmentView", pName, sizeof ("xglCreateColorAttachmentView")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700230 return (XGL_VOID *) pTable->CreateColorAttachmentView;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800231 else if (!strncmp("xglCreateDepthStencilView", pName, sizeof ("xglCreateDepthStencilView")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700232 return (XGL_VOID *) pTable->CreateDepthStencilView;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800233 else if (!strncmp("xglCreateShader", pName, sizeof ("xglCreateShader")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700234 return (XGL_VOID *) pTable->CreateShader;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800235 else if (!strncmp("xglCreateGraphicsPipeline", pName, sizeof ("xglCreateGraphicsPipeline")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700236 return (XGL_VOID *) pTable->CreateGraphicsPipeline;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800237 else if (!strncmp("xglCreateComputePipeline", pName, sizeof ("xglCreateComputePipeline")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700238 return (XGL_VOID *) pTable->CreateComputePipeline;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800239 else if (!strncmp("xglStorePipeline", pName, sizeof ("xglStorePipeline")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700240 return (XGL_VOID *) pTable->StorePipeline;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800241 else if (!strncmp("xglLoadPipeline", pName, sizeof ("xglLoadPipeline")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700242 return (XGL_VOID *) pTable->LoadPipeline;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800243 else if (!strncmp("xglCreatePipelineDelta", pName, sizeof ("xglCreatePipelineDelta")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700244 return (XGL_VOID *) pTable->CreatePipelineDelta;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800245 else if (!strncmp("xglCreateSampler", pName, sizeof ("xglCreateSampler")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700246 return (XGL_VOID *) pTable->CreateSampler;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800247 else if (!strncmp("xglCreateDescriptorSet", pName, sizeof ("xglCreateDescriptorSet")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700248 return (XGL_VOID *) pTable->CreateDescriptorSet;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800249 else if (!strncmp("xglBeginDescriptorSetUpdate", pName, sizeof ("xglBeginDescriptorSetUpdate")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700250 return (XGL_VOID *) pTable->BeginDescriptorSetUpdate;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800251 else if (!strncmp("xglEndDescriptorSetUpdate", pName, sizeof ("xglEndDescriptorSetUpdate")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700252 return (XGL_VOID *) pTable->EndDescriptorSetUpdate;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800253 else if (!strncmp("xglAttachSamplerDescriptors", pName, sizeof ("xglAttachSamplerDescriptors")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700254 return (XGL_VOID *) pTable->AttachSamplerDescriptors;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800255 else if (!strncmp("xglAttachImageViewDescriptors", pName, sizeof ("xglAttachImageViewDescriptors")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700256 return (XGL_VOID *) pTable->AttachImageViewDescriptors;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800257 else if (!strncmp("xglAttachMemoryViewDescriptors", pName, sizeof ("xglAttachMemoryViewDescriptors")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700258 return (XGL_VOID *) pTable->AttachMemoryViewDescriptors;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800259 else if (!strncmp("xglAttachNestedDescriptors", pName, sizeof ("xglAttachNestedDescriptors")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700260 return (XGL_VOID *) pTable->AttachNestedDescriptors;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800261 else if (!strncmp("xglClearDescriptorSetSlots", pName, sizeof ("xglClearDescriptorSetSlots")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700262 return (XGL_VOID *) pTable->ClearDescriptorSetSlots;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800263 else if (!strncmp("xglCreateViewportState", pName, sizeof ("xglCreateViewportState")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700264 return (XGL_VOID *) pTable->CreateViewportState;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800265 else if (!strncmp("xglCreateRasterState", pName, sizeof ("xglCreateRasterState")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700266 return (XGL_VOID *) pTable->CreateRasterState;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800267 else if (!strncmp("xglCreateMsaaState", pName, sizeof ("xglCreateMsaaState")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700268 return (XGL_VOID *) pTable->CreateMsaaState;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800269 else if (!strncmp("xglCreateColorBlendState", pName, sizeof ("xglCreateColorBlendState")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700270 return (XGL_VOID *) pTable->CreateColorBlendState;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800271 else if (!strncmp("xglCreateDepthStencilState", pName, sizeof ("xglCreateDepthStencilState")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700272 return (XGL_VOID *) pTable->CreateDepthStencilState;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800273 else if (!strncmp("xglCreateCommandBuffer", pName, sizeof ("xglCreateCommandBuffer")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700274 return (XGL_VOID *) pTable->CreateCommandBuffer;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800275 else if (!strncmp("xglBeginCommandBuffer", pName, sizeof ("xglBeginCommandBuffer")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700276 return (XGL_VOID *) pTable->BeginCommandBuffer;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800277 else if (!strncmp("xglEndCommandBuffer", pName, sizeof ("xglEndCommandBuffer")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700278 return (XGL_VOID *) pTable->EndCommandBuffer;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800279 else if (!strncmp("xglResetCommandBuffer", pName, sizeof ("xglResetCommandBuffer")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700280 return (XGL_VOID *) pTable->ResetCommandBuffer;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800281 else if (!strncmp("xglCmdBindPipeline", pName, sizeof ("xglCmdBindPipeline")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700282 return (XGL_VOID *) pTable->CmdBindPipeline;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800283 else if (!strncmp("xglCmdBindPipelineDelta", pName, sizeof ("xglCmdBindPipelineDelta")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700284 return (XGL_VOID *) pTable->CmdBindPipelineDelta;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800285 else if (!strncmp("xglCmdBindStateObject", pName, sizeof ("xglCmdBindStateObject")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700286 return (XGL_VOID *) pTable->CmdBindStateObject;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800287 else if (!strncmp("xglCmdBindDescriptorSet", pName, sizeof ("xglCmdBindDescriptorSet")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700288 return (XGL_VOID *) pTable->CmdBindDescriptorSet;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800289 else if (!strncmp("xglCmdBindDynamicMemoryView", pName, sizeof ("xglCmdBindDynamicMemoryView")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700290 return (XGL_VOID *) pTable->CmdBindDynamicMemoryView;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800291 else if (!strncmp("xglCmdBindVertexData", pName, sizeof ("xglCmdBindVertexData")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700292 return (XGL_VOID *) pTable->CmdBindVertexData;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800293 else if (!strncmp("xglCmdBindIndexData", pName, sizeof ("xglCmdBindIndexData")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700294 return (XGL_VOID *) pTable->CmdBindIndexData;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800295 else if (!strncmp("xglCmdBindAttachments", pName, sizeof ("xglCmdBindAttachments")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700296 return (XGL_VOID *) pTable->CmdBindAttachments;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800297 else if (!strncmp("xglCmdPrepareMemoryRegions", pName, sizeof ("xglCmdPrepareMemoryRegions")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700298 return (XGL_VOID *) pTable->CmdPrepareMemoryRegions;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800299 else if (!strncmp("xglCmdPrepareImages", pName, sizeof ("xglCmdPrepareImages")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700300 return (XGL_VOID *) pTable->CmdPrepareImages;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800301 else if (!strncmp("xglCmdDraw", pName, sizeof ("xglCmdDraw")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700302 return (XGL_VOID *) pTable->CmdDraw;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800303 else if (!strncmp("xglCmdDrawIndexed", pName, sizeof ("xglCmdDrawIndexed")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700304 return (XGL_VOID *) pTable->CmdDrawIndexed;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800305 else if (!strncmp("xglCmdDrawIndirect", pName, sizeof ("xglCmdDrawIndirect")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700306 return (XGL_VOID *) pTable->CmdDrawIndirect;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800307 else if (!strncmp("xglCmdDrawIndexedIndirect", pName, sizeof ("xglCmdDrawIndexedIndirect")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700308 return (XGL_VOID *) pTable->CmdDrawIndexedIndirect;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800309 else if (!strncmp("xglCmdDispatch", pName, sizeof ("xglCmdDispatch")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700310 return (XGL_VOID *) pTable->CmdDispatch;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800311 else if (!strncmp("xglCmdDispatchIndirect", pName, sizeof ("xglCmdDispatchIndirect")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700312 return (XGL_VOID *) pTable->CmdDispatchIndirect;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800313 else if (!strncmp("xglCmdCopyMemory", pName, sizeof ("xglCmdCopyMemory")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700314 return (XGL_VOID *) pTable->CmdCopyMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800315 else if (!strncmp("xglCmdCopyImage", pName, sizeof ("xglCmdCopyImage")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700316 return (XGL_VOID *) pTable->CmdCopyImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800317 else if (!strncmp("xglCmdCopyMemoryToImage", pName, sizeof ("xglCmdCopyMemoryToImage")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700318 return (XGL_VOID *) pTable->CmdCopyMemoryToImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800319 else if (!strncmp("xglCmdCopyImageToMemory", pName, sizeof ("xglCmdCopyImageToMemory")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700320 return (XGL_VOID *) pTable->CmdCopyImageToMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800321 else if (!strncmp("xglCmdCloneImageData", pName, sizeof ("xglCmdCloneImageData")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700322 return (XGL_VOID *) pTable->CmdCloneImageData;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800323 else if (!strncmp("xglCmdUpdateMemory", pName, sizeof ("xglCmdUpdateMemory")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700324 return (XGL_VOID *) pTable->CmdUpdateMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800325 else if (!strncmp("xglCmdFillMemory", pName, sizeof ("xglCmdFillMemory")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700326 return (XGL_VOID *) pTable->CmdFillMemory;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800327 else if (!strncmp("xglCmdClearColorImage", pName, sizeof ("xglCmdClearColorImage")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700328 return (XGL_VOID *) pTable->CmdClearColorImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800329 else if (!strncmp("xglCmdClearColorImageRaw", pName, sizeof ("xglCmdClearColorImageRaw")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700330 return (XGL_VOID *) pTable->CmdClearColorImageRaw;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800331 else if (!strncmp("xglCmdClearDepthStencil", pName, sizeof ("xglCmdClearDepthStencil")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700332 return (XGL_VOID *) pTable->CmdClearDepthStencil;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800333 else if (!strncmp("xglCmdResolveImage", pName, sizeof ("xglCmdResolveImage")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700334 return (XGL_VOID *) pTable->CmdResolveImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800335 else if (!strncmp("xglCmdSetEvent", pName, sizeof ("xglCmdSetEvent")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700336 return (XGL_VOID *) pTable->CmdSetEvent;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800337 else if (!strncmp("xglCmdResetEvent", pName, sizeof ("xglCmdResetEvent")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700338 return (XGL_VOID *) pTable->CmdResetEvent;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800339 else if (!strncmp("xglCmdMemoryAtomic", pName, sizeof ("xglCmdMemoryAtomic")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700340 return (XGL_VOID *) pTable->CmdMemoryAtomic;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800341 else if (!strncmp("xglCmdBeginQuery", pName, sizeof ("xglCmdBeginQuery")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700342 return (XGL_VOID *) pTable->CmdBeginQuery;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800343 else if (!strncmp("xglCmdEndQuery", pName, sizeof ("xglCmdEndQuery")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700344 return (XGL_VOID *) pTable->CmdEndQuery;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800345 else if (!strncmp("xglCmdResetQueryPool", pName, sizeof ("xglCmdResetQueryPool")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700346 return (XGL_VOID *) pTable->CmdResetQueryPool;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800347 else if (!strncmp("xglCmdWriteTimestamp", pName, sizeof ("xglCmdWriteTimestamp")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700348 return (XGL_VOID *) pTable->CmdWriteTimestamp;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800349 else if (!strncmp("xglCmdInitAtomicCounters", pName, sizeof ("xglCmdInitAtomicCounters")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700350 return (XGL_VOID *) pTable->CmdInitAtomicCounters;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800351 else if (!strncmp("xglCmdLoadAtomicCounters", pName, sizeof ("xglCmdLoadAtomicCounters")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700352 return (XGL_VOID *) pTable->CmdLoadAtomicCounters;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800353 else if (!strncmp("xglCmdSaveAtomicCounters", pName, sizeof ("xglCmdSaveAtomicCounters")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700354 return (XGL_VOID *) pTable->CmdSaveAtomicCounters;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800355 else if (!strncmp("xglDbgSetValidationLevel", pName, sizeof ("xglDbgSetValidationLevel")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700356 return (XGL_VOID *) pTable->DbgSetValidationLevel;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800357 else if (!strncmp("xglDbgRegisterMsgCallback", pName, sizeof ("xglDbgRegisterMsgCallback")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700358 return (XGL_VOID *) pTable->DbgRegisterMsgCallback;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800359 else if (!strncmp("xglDbgUnregisterMsgCallback", pName, sizeof ("xglDbgUnregisterMsgCallback")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700360 return (XGL_VOID *) pTable->DbgUnregisterMsgCallback;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800361 else if (!strncmp("xglDbgSetMessageFilter", pName, sizeof ("xglDbgSetMessageFilter")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700362 return (XGL_VOID *) pTable->DbgSetMessageFilter;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800363 else if (!strncmp("xglDbgSetObjectTag", pName, sizeof ("xglDbgSetObjectTag")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700364 return (XGL_VOID *) pTable->DbgSetObjectTag;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800365 else if (!strncmp("xglDbgSetGlobalOption", pName, sizeof ("xglDbgSetGlobalOption")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700366 return (XGL_VOID *) pTable->DbgSetGlobalOption;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800367 else if (!strncmp("xglDbgSetDeviceOption", pName, sizeof ("xglDbgSetDeviceOption")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700368 return (XGL_VOID *) pTable->DbgSetDeviceOption;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800369 else if (!strncmp("xglCmdDbgMarkerBegin", pName, sizeof ("xglCmdDbgMarkerBegin")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700370 return (XGL_VOID *) pTable->CmdDbgMarkerBegin;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800371 else if (!strncmp("xglCmdDbgMarkerEnd", pName, sizeof ("xglCmdDbgMarkerEnd")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700372 return (XGL_VOID *) pTable->CmdDbgMarkerEnd;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800373 else if (!strncmp("xglWsiX11AssociateConnection", pName, sizeof("xglWsiX11AssociateConnection")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700374 return (XGL_VOID *) pTable->WsiX11AssociateConnection;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800375 else if (!strncmp("xglWsiX11GetMSC", pName, sizeof("xglWsiX11GetMSC")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700376 return (XGL_VOID *) pTable->WsiX11GetMSC;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800377 else if (!strncmp("xglWsiX11CreatePresentableImage", pName, sizeof("xglWsiX11CreatePresentableImage")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700378 return (XGL_VOID *) pTable->WsiX11CreatePresentableImage;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800379 else if (!strncmp("xglWsiX11QueuePresent", pName, sizeof("xglWsiX11QueuePresent")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700380 return (XGL_VOID *) pTable->WsiX11QueuePresent;
Chia-I Wu7461fcf2014-12-27 15:16:07 +0800381 else if (!strncmp("xglLayerExtension1", pName, sizeof("xglLayerExtension1")))
Jon Ashburn227a9422014-11-26 11:10:26 -0700382 return (XGL_VOID *) xglLayerExtension1;
383 else {
384 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
385 if (gpuw->pGPA == NULL)
386 return NULL;
387 return gpuw->pGPA((XGL_PHYSICAL_GPU) gpuw->nextObject, pName);
388 }
389}