blob: 6d43ea0791fdda7c5602ff75cbcf1fec7c6a7233 [file] [log] [blame]
Jon Ashburn79113cc2014-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 *
24 */
25
26#include <string.h>
27#include <stdlib.h>
28#include <assert.h>
29#include <unordered_map>
Chia-I Wuaa4121f2015-01-04 23:11:43 +080030#include "xgl_dispatch_table_helper.h"
Jon Ashburn79113cc2014-12-01 14:22:40 -070031#include "xglLayer.h"
32
33static void initLayerTable(const XGL_BASE_LAYER_OBJECT *gpuw, XGL_LAYER_DISPATCH_TABLE *pTable, const unsigned int layerNum);
34
35/******************************** Layer multi1 functions **************************/
36static std::unordered_map<XGL_VOID *, XGL_LAYER_DISPATCH_TABLE *> tableMap1;
37static bool layer1_first_activated = false;
38
39static XGL_LAYER_DISPATCH_TABLE * getLayer1Table(const XGL_BASE_LAYER_OBJECT *gpuw)
40{
41 XGL_LAYER_DISPATCH_TABLE *pTable;
42
43 assert(gpuw);
44 std::unordered_map<XGL_VOID *, XGL_LAYER_DISPATCH_TABLE *>::const_iterator it = tableMap1.find((XGL_VOID *) gpuw);
45 if (it == tableMap1.end())
46 {
47 pTable = new XGL_LAYER_DISPATCH_TABLE;
48 tableMap1[(XGL_VOID *) gpuw] = pTable;
49 initLayerTable(gpuw, pTable, 1);
50 return pTable;
51 } else
52 {
53 return it->second;
54 }
55}
56#ifdef __cplusplus
57extern "C" {
58#endif
59
60
61XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi1CreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreateInfo,
62 XGL_DEVICE* pDevice)
63{
64 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
65 XGL_LAYER_DISPATCH_TABLE* pTable = getLayer1Table(gpuw);
66
67 printf("At start of multi1 layer xglCreateDevice()\n");
68 XGL_RESULT result = pTable->CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice);
69 // create a mapping for the device object into the dispatch table
70 tableMap1.emplace(*pDevice, pTable);
71 printf("Completed multi1 layer xglCreateDevice()\n");
72 return result;
73}
74
75XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi1CreateGraphicsPipeline(XGL_DEVICE device, const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo,
76 XGL_PIPELINE* pPipeline)
77{
78 XGL_LAYER_DISPATCH_TABLE* pTable = tableMap1[device];
79
80 printf("At start of multi1 layer xglCreateGraphicsPipeline()\n");
81 XGL_RESULT result = pTable->CreateGraphicsPipeline(device, pCreateInfo, pPipeline);
82 // create a mapping for the pipeline object into the dispatch table
83 tableMap1.emplace(*pPipeline, pTable);
84 printf("Completed multi1 layer xglCreateGraphicsPipeline()\n");
85 return result;
86}
87
88XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi1StorePipeline(XGL_PIPELINE pipeline, XGL_SIZE* pDataSize, XGL_VOID* pData)
89{
90 XGL_LAYER_DISPATCH_TABLE* pTable = tableMap1[pipeline];
91
92 printf("At start of multi1 layer xglStorePipeline()\n");
93 XGL_RESULT result = pTable->StorePipeline(pipeline, pDataSize, pData);
94 printf("Completed multi1 layer xglStorePipeline()\n");
95 return result;
96}
97
98XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi1EnumerateLayers(XGL_PHYSICAL_GPU gpu, XGL_SIZE maxLayerCount, XGL_SIZE maxStringSize,
99 XGL_CHAR* const* pOutLayers, XGL_SIZE * pOutLayerCount,
100 XGL_VOID* pReserved)
101{
102 if (gpu == NULL)
103 return xglEnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayers, pOutLayerCount, pReserved);
104
105 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
106 XGL_LAYER_DISPATCH_TABLE* pTable = getLayer1Table(gpuw);
107
108 printf("At start of multi1 layer xglEnumerateLayers()\n");
109 XGL_RESULT result = pTable->EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayers, pOutLayerCount, pReserved);
110 printf("Completed multi1 layer xglEnumerateLayers()\n");
111 return result;
112}
113
114XGL_LAYER_EXPORT XGL_VOID * XGLAPI multi1GetProcAddr(XGL_PHYSICAL_GPU gpu, const XGL_CHAR* pName)
115{
116 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
117 if (gpu == NULL)
118 return NULL;
119 XGL_LAYER_DISPATCH_TABLE* pTable;
120 pTable = getLayer1Table(gpuw);
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800121 if (!strncmp("xglInitAndEnumerateGpus", pName, sizeof("xglInitAndEnumerateGpus")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700122 return (XGL_VOID *) pTable->InitAndEnumerateGpus;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800123 else if (!strncmp("xglGetGpuInfo", pName, sizeof ("xglGetGpuInfo")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700124 return (XGL_VOID *) pTable->GetGpuInfo;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800125 else if (!strncmp("xglCreateDevice", pName, sizeof ("xglCreateDevice")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700126 return (XGL_VOID *) multi1CreateDevice;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800127 else if (!strncmp("xglDestroyDevice", pName, sizeof ("xglDestroyDevice")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700128 return (XGL_VOID *) pTable->DestroyDevice;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800129 else if (!strncmp("xglGetExtensionSupport", pName, sizeof ("xglGetExtensionSupport")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700130 return (XGL_VOID *) pTable->GetExtensionSupport;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800131 else if (!strncmp("xglEnumerateLayers", pName, sizeof ("xglEnumerateLayers")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700132 return (XGL_VOID *) multi1EnumerateLayers;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800133 else if (!strncmp("xglGetDeviceQueue", pName, sizeof ("xglGetDeviceQueue")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700134 return (XGL_VOID *) pTable->GetDeviceQueue;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800135 else if (!strncmp("xglQueueSubmit", pName, sizeof ("xglQueueSubmit")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700136 return (XGL_VOID *) pTable->QueueSubmit;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800137 else if (!strncmp("xglQueueSetGlobalMemReferences", pName, sizeof ("xglQueueSetGlobalMemReferences")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700138 return (XGL_VOID *) pTable->QueueSetGlobalMemReferences;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800139 else if (!strncmp("xglQueueWaitIdle", pName, sizeof ("xglQueueWaitIdle")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700140 return (XGL_VOID *) pTable->QueueWaitIdle;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800141 else if (!strncmp("xglDeviceWaitIdle", pName, sizeof ("xglDeviceWaitIdle")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700142 return (XGL_VOID *) pTable->DeviceWaitIdle;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800143 else if (!strncmp("xglGetMemoryHeapCount", pName, sizeof ("xglGetMemoryHeapCount")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700144 return (XGL_VOID *) pTable->GetMemoryHeapCount;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800145 else if (!strncmp("xglGetMemoryHeapInfo", pName, sizeof ("xglGetMemoryHeapInfo")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700146 return (XGL_VOID *) pTable->GetMemoryHeapInfo;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800147 else if (!strncmp("xglAllocMemory", pName, sizeof ("xglAllocMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700148 return (XGL_VOID *) pTable->AllocMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800149 else if (!strncmp("xglFreeMemory", pName, sizeof ("xglFreeMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700150 return (XGL_VOID *) pTable->FreeMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800151 else if (!strncmp("xglSetMemoryPriority", pName, sizeof ("xglSetMemoryPriority")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700152 return (XGL_VOID *) pTable->SetMemoryPriority;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800153 else if (!strncmp("xglMapMemory", pName, sizeof ("xglMapMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700154 return (XGL_VOID *) pTable->MapMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800155 else if (!strncmp("xglUnmapMemory", pName, sizeof ("xglUnmapMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700156 return (XGL_VOID *) pTable->UnmapMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800157 else if (!strncmp("xglPinSystemMemory", pName, sizeof ("xglPinSystemMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700158 return (XGL_VOID *) pTable->PinSystemMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800159 else if (!strncmp("xglRemapVirtualMemoryPages", pName, sizeof ("xglRemapVirtualMemoryPages")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700160 return (XGL_VOID *) pTable->RemapVirtualMemoryPages;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800161 else if (!strncmp("xglGetMultiGpuCompatibility", pName, sizeof ("xglGetMultiGpuCompatibility")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700162 return (XGL_VOID *) pTable->GetMultiGpuCompatibility;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800163 else if (!strncmp("xglOpenSharedMemory", pName, sizeof ("xglOpenSharedMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700164 return (XGL_VOID *) pTable->OpenSharedMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800165 else if (!strncmp("xglOpenSharedQueueSemaphore", pName, sizeof ("xglOpenSharedQueueSemaphore")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700166 return (XGL_VOID *) pTable->OpenSharedQueueSemaphore;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800167 else if (!strncmp("xglOpenPeerMemory", pName, sizeof ("xglOpenPeerMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700168 return (XGL_VOID *) pTable->OpenPeerMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800169 else if (!strncmp("xglOpenPeerImage", pName, sizeof ("xglOpenPeerImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700170 return (XGL_VOID *) pTable->OpenPeerImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800171 else if (!strncmp("xglDestroyObject", pName, sizeof ("xglDestroyObject")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700172 return (XGL_VOID *) pTable->DestroyObject;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800173 else if (!strncmp("xglGetObjectInfo", pName, sizeof ("xglGetObjectInfo")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700174 return (XGL_VOID *) pTable->GetObjectInfo;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800175 else if (!strncmp("xglBindObjectMemory", pName, sizeof ("xglBindObjectMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700176 return (XGL_VOID *) pTable->BindObjectMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800177 else if (!strncmp("xglCreateFence", pName, sizeof ("xgllCreateFence")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700178 return (XGL_VOID *) pTable->CreateFence;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800179 else if (!strncmp("xglGetFenceStatus", pName, sizeof ("xglGetFenceStatus")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700180 return (XGL_VOID *) pTable->GetFenceStatus;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800181 else if (!strncmp("xglWaitForFences", pName, sizeof ("xglWaitForFences")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700182 return (XGL_VOID *) pTable->WaitForFences;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800183 else if (!strncmp("xglCreateQueueSemaphore", pName, sizeof ("xgllCreateQueueSemaphore")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700184 return (XGL_VOID *) pTable->CreateQueueSemaphore;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800185 else if (!strncmp("xglSignalQueueSemaphore", pName, sizeof ("xglSignalQueueSemaphore")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700186 return (XGL_VOID *) pTable->SignalQueueSemaphore;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800187 else if (!strncmp("xglWaitQueueSemaphore", pName, sizeof ("xglWaitQueueSemaphore")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700188 return (XGL_VOID *) pTable->WaitQueueSemaphore;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800189 else if (!strncmp("xglCreateEvent", pName, sizeof ("xgllCreateEvent")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700190 return (XGL_VOID *) pTable->CreateEvent;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800191 else if (!strncmp("xglGetEventStatus", pName, sizeof ("xglGetEventStatus")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700192 return (XGL_VOID *) pTable->GetEventStatus;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800193 else if (!strncmp("xglSetEvent", pName, sizeof ("xglSetEvent")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700194 return (XGL_VOID *) pTable->SetEvent;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800195 else if (!strncmp("xglResetEvent", pName, sizeof ("xgllResetEvent")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700196 return (XGL_VOID *) pTable->ResetEvent;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800197 else if (!strncmp("xglCreateQueryPool", pName, sizeof ("xglCreateQueryPool")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700198 return (XGL_VOID *) pTable->CreateQueryPool;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800199 else if (!strncmp("xglGetQueryPoolResults", pName, sizeof ("xglGetQueryPoolResults")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700200 return (XGL_VOID *) pTable->GetQueryPoolResults;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800201 else if (!strncmp("xglGetFormatInfo", pName, sizeof ("xglGetFormatInfo")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700202 return (XGL_VOID *) pTable->GetFormatInfo;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800203 else if (!strncmp("xglCreateImage", pName, sizeof ("xglCreateImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700204 return (XGL_VOID *) pTable->CreateImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800205 else if (!strncmp("xglGetImageSubresourceInfo", pName, sizeof ("xglGetImageSubresourceInfo")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700206 return (XGL_VOID *) pTable->GetImageSubresourceInfo;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800207 else if (!strncmp("xglCreateImageView", pName, sizeof ("xglCreateImageView")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700208 return (XGL_VOID *) pTable->CreateImageView;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800209 else if (!strncmp("xglCreateColorAttachmentView", pName, sizeof ("xglCreateColorAttachmentView")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700210 return (XGL_VOID *) pTable->CreateColorAttachmentView;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800211 else if (!strncmp("xglCreateDepthStencilView", pName, sizeof ("xglCreateDepthStencilView")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700212 return (XGL_VOID *) pTable->CreateDepthStencilView;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800213 else if (!strncmp("xglCreateShader", pName, sizeof ("xglCreateShader")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700214 return (XGL_VOID *) pTable->CreateShader;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800215 else if (!strncmp("xglCreateGraphicsPipeline", pName, sizeof ("xglCreateGraphicsPipeline")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700216 return (XGL_VOID *) multi1CreateGraphicsPipeline;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800217 else if (!strncmp("xglCreateComputePipeline", pName, sizeof ("xglCreateComputePipeline")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700218 return (XGL_VOID *) pTable->CreateComputePipeline;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800219 else if (!strncmp("xglStorePipeline", pName, sizeof ("xglStorePipeline")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700220 return (XGL_VOID *) multi1StorePipeline;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800221 else if (!strncmp("xglLoadPipeline", pName, sizeof ("xglLoadPipeline")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700222 return (XGL_VOID *) pTable->LoadPipeline;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800223 else if (!strncmp("xglCreatePipelineDelta", pName, sizeof ("xglCreatePipelineDelta")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700224 return (XGL_VOID *) pTable->CreatePipelineDelta;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800225 else if (!strncmp("xglCreateSampler", pName, sizeof ("xglCreateSampler")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700226 return (XGL_VOID *) pTable->CreateSampler;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800227 else if (!strncmp("xglCreateDescriptorSet", pName, sizeof ("xglCreateDescriptorSet")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700228 return (XGL_VOID *) pTable->CreateDescriptorSet;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800229 else if (!strncmp("xglBeginDescriptorSetUpdate", pName, sizeof ("xglBeginDescriptorSetUpdate")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700230 return (XGL_VOID *) pTable->BeginDescriptorSetUpdate;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800231 else if (!strncmp("xglEndDescriptorSetUpdate", pName, sizeof ("xglEndDescriptorSetUpdate")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700232 return (XGL_VOID *) pTable->EndDescriptorSetUpdate;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800233 else if (!strncmp("xglAttachSamplerDescriptors", pName, sizeof ("xglAttachSamplerDescriptors")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700234 return (XGL_VOID *) pTable->AttachSamplerDescriptors;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800235 else if (!strncmp("xglAttachImageViewDescriptors", pName, sizeof ("xglAttachImageViewDescriptors")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700236 return (XGL_VOID *) pTable->AttachImageViewDescriptors;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800237 else if (!strncmp("xglAttachMemoryViewDescriptors", pName, sizeof ("xglAttachMemoryViewDescriptors")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700238 return (XGL_VOID *) pTable->AttachMemoryViewDescriptors;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800239 else if (!strncmp("xglAttachNestedDescriptors", pName, sizeof ("xglAttachNestedDescriptors")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700240 return (XGL_VOID *) pTable->AttachNestedDescriptors;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800241 else if (!strncmp("xglClearDescriptorSetSlots", pName, sizeof ("xglClearDescriptorSetSlots")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700242 return (XGL_VOID *) pTable->ClearDescriptorSetSlots;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800243 else if (!strncmp("xglCreateViewportState", pName, sizeof ("xglCreateViewportState")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700244 return (XGL_VOID *) pTable->CreateViewportState;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800245 else if (!strncmp("xglCreateRasterState", pName, sizeof ("xglCreateRasterState")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700246 return (XGL_VOID *) pTable->CreateRasterState;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800247 else if (!strncmp("xglCreateMsaaState", pName, sizeof ("xglCreateMsaaState")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700248 return (XGL_VOID *) pTable->CreateMsaaState;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800249 else if (!strncmp("xglCreateColorBlendState", pName, sizeof ("xglCreateColorBlendState")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700250 return (XGL_VOID *) pTable->CreateColorBlendState;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800251 else if (!strncmp("xglCreateDepthStencilState", pName, sizeof ("xglCreateDepthStencilState")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700252 return (XGL_VOID *) pTable->CreateDepthStencilState;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800253 else if (!strncmp("xglCreateCommandBuffer", pName, sizeof ("xglCreateCommandBuffer")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700254 return (XGL_VOID *) pTable->CreateCommandBuffer;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800255 else if (!strncmp("xglBeginCommandBuffer", pName, sizeof ("xglBeginCommandBuffer")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700256 return (XGL_VOID *) pTable->BeginCommandBuffer;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800257 else if (!strncmp("xglEndCommandBuffer", pName, sizeof ("xglEndCommandBuffer")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700258 return (XGL_VOID *) pTable->EndCommandBuffer;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800259 else if (!strncmp("xglResetCommandBuffer", pName, sizeof ("xglResetCommandBuffer")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700260 return (XGL_VOID *) pTable->ResetCommandBuffer;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800261 else if (!strncmp("xglCmdBindPipeline", pName, sizeof ("xglCmdBindPipeline")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700262 return (XGL_VOID *) pTable->CmdBindPipeline;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800263 else if (!strncmp("xglCmdBindPipelineDelta", pName, sizeof ("xglCmdBindPipelineDelta")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700264 return (XGL_VOID *) pTable->CmdBindPipelineDelta;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800265 else if (!strncmp("xglCmdBindStateObject", pName, sizeof ("xglCmdBindStateObject")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700266 return (XGL_VOID *) pTable->CmdBindStateObject;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800267 else if (!strncmp("xglCmdBindDescriptorSet", pName, sizeof ("xglCmdBindDescriptorSet")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700268 return (XGL_VOID *) pTable->CmdBindDescriptorSet;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800269 else if (!strncmp("xglCmdBindDynamicMemoryView", pName, sizeof ("xglCmdBindDynamicMemoryView")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700270 return (XGL_VOID *) pTable->CmdBindDynamicMemoryView;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800271 else if (!strncmp("xglCmdBindVertexData", pName, sizeof ("xglCmdBindVertexData")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700272 return (XGL_VOID *) pTable->CmdBindVertexData;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800273 else if (!strncmp("xglCmdBindIndexData", pName, sizeof ("xglCmdBindIndexData")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700274 return (XGL_VOID *) pTable->CmdBindIndexData;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800275 else if (!strncmp("xglCmdBindAttachments", pName, sizeof ("xglCmdBindAttachments")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700276 return (XGL_VOID *) pTable->CmdBindAttachments;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800277 else if (!strncmp("xglCmdPrepareMemoryRegions", pName, sizeof ("xglCmdPrepareMemoryRegions")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700278 return (XGL_VOID *) pTable->CmdPrepareMemoryRegions;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800279 else if (!strncmp("xglCmdPrepareImages", pName, sizeof ("xglCmdPrepareImages")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700280 return (XGL_VOID *) pTable->CmdPrepareImages;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800281 else if (!strncmp("xglCmdDraw", pName, sizeof ("xglCmdDraw")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700282 return (XGL_VOID *) pTable->CmdDraw;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800283 else if (!strncmp("xglCmdDrawIndexed", pName, sizeof ("xglCmdDrawIndexed")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700284 return (XGL_VOID *) pTable->CmdDrawIndexed;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800285 else if (!strncmp("xglCmdDrawIndirect", pName, sizeof ("xglCmdDrawIndirect")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700286 return (XGL_VOID *) pTable->CmdDrawIndirect;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800287 else if (!strncmp("xglCmdDrawIndexedIndirect", pName, sizeof ("xglCmdDrawIndexedIndirect")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700288 return (XGL_VOID *) pTable->CmdDrawIndexedIndirect;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800289 else if (!strncmp("xglCmdDispatch", pName, sizeof ("xglCmdDispatch")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700290 return (XGL_VOID *) pTable->CmdDispatch;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800291 else if (!strncmp("xglCmdDispatchIndirect", pName, sizeof ("xglCmdDispatchIndirect")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700292 return (XGL_VOID *) pTable->CmdDispatchIndirect;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800293 else if (!strncmp("xglCmdCopyMemory", pName, sizeof ("xglCmdCopyMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700294 return (XGL_VOID *) pTable->CmdCopyMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800295 else if (!strncmp("xglCmdCopyImage", pName, sizeof ("xglCmdCopyImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700296 return (XGL_VOID *) pTable->CmdCopyImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800297 else if (!strncmp("xglCmdCopyMemoryToImage", pName, sizeof ("xglCmdCopyMemoryToImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700298 return (XGL_VOID *) pTable->CmdCopyMemoryToImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800299 else if (!strncmp("xglCmdCopyImageToMemory", pName, sizeof ("xglCmdCopyImageToMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700300 return (XGL_VOID *) pTable->CmdCopyImageToMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800301 else if (!strncmp("xglCmdCloneImageData", pName, sizeof ("xglCmdCloneImageData")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700302 return (XGL_VOID *) pTable->CmdCloneImageData;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800303 else if (!strncmp("xglCmdUpdateMemory", pName, sizeof ("xglCmdUpdateMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700304 return (XGL_VOID *) pTable->CmdUpdateMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800305 else if (!strncmp("xglCmdFillMemory", pName, sizeof ("xglCmdFillMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700306 return (XGL_VOID *) pTable->CmdFillMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800307 else if (!strncmp("xglCmdClearColorImage", pName, sizeof ("xglCmdClearColorImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700308 return (XGL_VOID *) pTable->CmdClearColorImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800309 else if (!strncmp("xglCmdClearColorImageRaw", pName, sizeof ("xglCmdClearColorImageRaw")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700310 return (XGL_VOID *) pTable->CmdClearColorImageRaw;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800311 else if (!strncmp("xglCmdClearDepthStencil", pName, sizeof ("xglCmdClearDepthStencil")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700312 return (XGL_VOID *) pTable->CmdClearDepthStencil;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800313 else if (!strncmp("xglCmdResolveImage", pName, sizeof ("xglCmdResolveImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700314 return (XGL_VOID *) pTable->CmdResolveImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800315 else if (!strncmp("xglCmdSetEvent", pName, sizeof ("xglCmdSetEvent")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700316 return (XGL_VOID *) pTable->CmdSetEvent;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800317 else if (!strncmp("xglCmdResetEvent", pName, sizeof ("xglCmdResetEvent")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700318 return (XGL_VOID *) pTable->CmdResetEvent;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800319 else if (!strncmp("xglCmdMemoryAtomic", pName, sizeof ("xglCmdMemoryAtomic")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700320 return (XGL_VOID *) pTable->CmdMemoryAtomic;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800321 else if (!strncmp("xglCmdBeginQuery", pName, sizeof ("xglCmdBeginQuery")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700322 return (XGL_VOID *) pTable->CmdBeginQuery;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800323 else if (!strncmp("xglCmdEndQuery", pName, sizeof ("xglCmdEndQuery")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700324 return (XGL_VOID *) pTable->CmdEndQuery;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800325 else if (!strncmp("xglCmdResetQueryPool", pName, sizeof ("xglCmdResetQueryPool")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700326 return (XGL_VOID *) pTable->CmdResetQueryPool;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800327 else if (!strncmp("xglCmdWriteTimestamp", pName, sizeof ("xglCmdWriteTimestamp")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700328 return (XGL_VOID *) pTable->CmdWriteTimestamp;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800329 else if (!strncmp("xglCmdInitAtomicCounters", pName, sizeof ("xglCmdInitAtomicCounters")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700330 return (XGL_VOID *) pTable->CmdInitAtomicCounters;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800331 else if (!strncmp("xglCmdLoadAtomicCounters", pName, sizeof ("xglCmdLoadAtomicCounters")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700332 return (XGL_VOID *) pTable->CmdLoadAtomicCounters;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800333 else if (!strncmp("xglCmdSaveAtomicCounters", pName, sizeof ("xglCmdSaveAtomicCounters")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700334 return (XGL_VOID *) pTable->CmdSaveAtomicCounters;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800335 else if (!strncmp("xglDbgSetValidationLevel", pName, sizeof ("xglDbgSetValidationLevel")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700336 return (XGL_VOID *) pTable->DbgSetValidationLevel;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800337 else if (!strncmp("xglDbgRegisterMsgCallback", pName, sizeof ("xglDbgRegisterMsgCallback")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700338 return (XGL_VOID *) pTable->DbgRegisterMsgCallback;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800339 else if (!strncmp("xglDbgUnregisterMsgCallback", pName, sizeof ("xglDbgUnregisterMsgCallback")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700340 return (XGL_VOID *) pTable->DbgUnregisterMsgCallback;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800341 else if (!strncmp("xglDbgSetMessageFilter", pName, sizeof ("xglDbgSetMessageFilter")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700342 return (XGL_VOID *) pTable->DbgSetMessageFilter;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800343 else if (!strncmp("xglDbgSetObjectTag", pName, sizeof ("xglDbgSetObjectTag")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700344 return (XGL_VOID *) pTable->DbgSetObjectTag;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800345 else if (!strncmp("xglDbgSetGlobalOption", pName, sizeof ("xglDbgSetGlobalOption")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700346 return (XGL_VOID *) pTable->DbgSetGlobalOption;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800347 else if (!strncmp("xglDbgSetDeviceOption", pName, sizeof ("xglDbgSetDeviceOption")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700348 return (XGL_VOID *) pTable->DbgSetDeviceOption;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800349 else if (!strncmp("xglCmdDbgMarkerBegin", pName, sizeof ("xglCmdDbgMarkerBegin")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700350 return (XGL_VOID *) pTable->CmdDbgMarkerBegin;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800351 else if (!strncmp("xglCmdDbgMarkerEnd", pName, sizeof ("xglCmdDbgMarkerEnd")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700352 return (XGL_VOID *) pTable->CmdDbgMarkerEnd;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800353 else if (!strncmp("xglWsiX11AssociateConnection", pName, sizeof("xglWsiX11AssociateConnection")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700354 return (XGL_VOID *) pTable->WsiX11AssociateConnection;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800355 else if (!strncmp("xglWsiX11GetMSC", pName, sizeof("xglWsiX11GetMSC")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700356 return (XGL_VOID *) pTable->WsiX11GetMSC;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800357 else if (!strncmp("xglWsiX11CreatePresentableImage", pName, sizeof("xglWsiX11CreatePresentableImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700358 return (XGL_VOID *) pTable->WsiX11CreatePresentableImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800359 else if (!strncmp("xglWsiX11QueuePresent", pName, sizeof("xglWsiX11QueuePresent")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700360 return (XGL_VOID *) pTable->WsiX11QueuePresent;
361 else {
362 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
363 if (gpuw->pGPA == NULL)
364 return NULL;
365 return gpuw->pGPA((XGL_PHYSICAL_GPU) gpuw->nextObject, pName);
366 }
367
368}
369
370/******************************** Layer multi2 functions **************************/
371static std::unordered_map<XGL_VOID *, XGL_LAYER_DISPATCH_TABLE *> tableMap2;
372static bool layer2_first_activated = false;
373
374static XGL_LAYER_DISPATCH_TABLE * getLayer2Table(const XGL_BASE_LAYER_OBJECT *gpuw)
375{
376 XGL_LAYER_DISPATCH_TABLE *pTable;
377
378 assert(gpuw);
379 std::unordered_map<XGL_VOID *, XGL_LAYER_DISPATCH_TABLE *>::const_iterator it = tableMap2.find((XGL_VOID *) gpuw);
380 if (it == tableMap2.end())
381 {
382 pTable = new XGL_LAYER_DISPATCH_TABLE;
383 tableMap2[(XGL_VOID *) gpuw] = pTable;
384 initLayerTable(gpuw, pTable, 2);
385 return pTable;
386 } else
387 {
388 return it->second;
389 }
390}
391
392XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi2CreateDevice(XGL_PHYSICAL_GPU gpu, const XGL_DEVICE_CREATE_INFO* pCreateInfo,
393 XGL_DEVICE* pDevice)
394{
395 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
396 XGL_LAYER_DISPATCH_TABLE* pTable = getLayer2Table(gpuw);
397
398 printf("At start of multi2 xglCreateDevice()\n");
399 XGL_RESULT result = pTable->CreateDevice((XGL_PHYSICAL_GPU)gpuw->nextObject, pCreateInfo, pDevice);
400 // create a mapping for the device object into the dispatch table for layer2
401 tableMap2.emplace(*pDevice, pTable);
402 printf("Completed multi2 layer xglCreateDevice()\n");
403 return result;
404}
405
406XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi2CreateCommandBuffer(XGL_DEVICE device, const XGL_CMD_BUFFER_CREATE_INFO* pCreateInfo,
407 XGL_CMD_BUFFER* pCmdBuffer)
408{
409 XGL_LAYER_DISPATCH_TABLE* pTable = tableMap2[device];
410
411 printf("At start of multi2 layer xglCreateCommandBuffer()\n");
412 XGL_RESULT result = pTable->CreateCommandBuffer(device, pCreateInfo, pCmdBuffer);
413 // create a mapping for CmdBuffer object into the dispatch table for layer 2
414 tableMap2.emplace(*pCmdBuffer, pTable);
415 printf("Completed multi2 layer xglCreateCommandBuffer()\n");
416 return result;
417}
418
419XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi2BeginCommandBuffer( XGL_CMD_BUFFER cmdBuffer, XGL_FLAGS flags)
420{
421 XGL_LAYER_DISPATCH_TABLE* pTable = tableMap2[cmdBuffer];
422
423 printf("At start of multi2 layer xglBeginCommandBuffer()\n");
424 XGL_RESULT result = pTable->BeginCommandBuffer(cmdBuffer, flags);
425 printf("Completed multi2 layer xglBeginCommandBuffer()\n");
426 return result;
427
428}
429
430XGL_LAYER_EXPORT XGL_RESULT XGLAPI multi2EnumerateLayers(XGL_PHYSICAL_GPU gpu, XGL_SIZE maxLayerCount, XGL_SIZE maxStringSize,
431 XGL_CHAR* const* pOutLayers, XGL_SIZE * pOutLayerCount,
432 XGL_VOID* pReserved)
433{
434 if (gpu == NULL)
435 return xglEnumerateLayers(gpu, maxLayerCount, maxStringSize, pOutLayers, pOutLayerCount, pReserved);
436
437 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
438 XGL_LAYER_DISPATCH_TABLE* pTable = getLayer2Table(gpuw);
439
440 printf("At start of multi2 layer xglEnumerateLayers()\n");
441 XGL_RESULT result = pTable->EnumerateLayers((XGL_PHYSICAL_GPU)gpuw->nextObject, maxLayerCount, maxStringSize, pOutLayers, pOutLayerCount, pReserved);
442 printf("Completed multi2 layer xglEnumerateLayers()\n");
443 return result;
444}
445
446XGL_LAYER_EXPORT XGL_VOID * XGLAPI multi2GetProcAddr(XGL_PHYSICAL_GPU gpu, const XGL_CHAR* pName)
447{
448 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
449 if (gpu == NULL)
450 return NULL;
451 XGL_LAYER_DISPATCH_TABLE* pTable;
452 pTable = getLayer2Table(gpuw);
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800453 if (!strncmp("xglInitAndEnumerateGpus", pName, sizeof("xglInitAndEnumerateGpus")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700454 return (XGL_VOID *) pTable->InitAndEnumerateGpus;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800455 else if (!strncmp("xglGetGpuInfo", pName, sizeof ("xglGetGpuInfo")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700456 return (XGL_VOID *) pTable->GetGpuInfo;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800457 else if (!strncmp("xglCreateDevice", pName, sizeof ("xglCreateDevice")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700458 return (XGL_VOID *) multi2CreateDevice;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800459 else if (!strncmp("xglDestroyDevice", pName, sizeof ("xglDestroyDevice")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700460 return (XGL_VOID *) pTable->DestroyDevice;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800461 else if (!strncmp("xglGetExtensionSupport", pName, sizeof ("xglGetExtensionSupport")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700462 return (XGL_VOID *) pTable->GetExtensionSupport;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800463 else if (!strncmp("xglEnumerateLayers", pName, sizeof ("xglEnumerateLayers")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700464 return (XGL_VOID *) multi2EnumerateLayers;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800465 else if (!strncmp("xglGetDeviceQueue", pName, sizeof ("xglGetDeviceQueue")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700466 return (XGL_VOID *) pTable->GetDeviceQueue;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800467 else if (!strncmp("xglQueueSubmit", pName, sizeof ("xglQueueSubmit")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700468 return (XGL_VOID *) pTable->QueueSubmit;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800469 else if (!strncmp("xglQueueSetGlobalMemReferences", pName, sizeof ("xglQueueSetGlobalMemReferences")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700470 return (XGL_VOID *) pTable->QueueSetGlobalMemReferences;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800471 else if (!strncmp("xglQueueWaitIdle", pName, sizeof ("xglQueueWaitIdle")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700472 return (XGL_VOID *) pTable->QueueWaitIdle;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800473 else if (!strncmp("xglDeviceWaitIdle", pName, sizeof ("xglDeviceWaitIdle")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700474 return (XGL_VOID *) pTable->DeviceWaitIdle;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800475 else if (!strncmp("xglGetMemoryHeapCount", pName, sizeof ("xglGetMemoryHeapCount")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700476 return (XGL_VOID *) pTable->GetMemoryHeapCount;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800477 else if (!strncmp("xglGetMemoryHeapInfo", pName, sizeof ("xglGetMemoryHeapInfo")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700478 return (XGL_VOID *) pTable->GetMemoryHeapInfo;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800479 else if (!strncmp("xglAllocMemory", pName, sizeof ("xglAllocMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700480 return (XGL_VOID *) pTable->AllocMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800481 else if (!strncmp("xglFreeMemory", pName, sizeof ("xglFreeMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700482 return (XGL_VOID *) pTable->FreeMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800483 else if (!strncmp("xglSetMemoryPriority", pName, sizeof ("xglSetMemoryPriority")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700484 return (XGL_VOID *) pTable->SetMemoryPriority;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800485 else if (!strncmp("xglMapMemory", pName, sizeof ("xglMapMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700486 return (XGL_VOID *) pTable->MapMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800487 else if (!strncmp("xglUnmapMemory", pName, sizeof ("xglUnmapMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700488 return (XGL_VOID *) pTable->UnmapMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800489 else if (!strncmp("xglPinSystemMemory", pName, sizeof ("xglPinSystemMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700490 return (XGL_VOID *) pTable->PinSystemMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800491 else if (!strncmp("xglRemapVirtualMemoryPages", pName, sizeof ("xglRemapVirtualMemoryPages")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700492 return (XGL_VOID *) pTable->RemapVirtualMemoryPages;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800493 else if (!strncmp("xglGetMultiGpuCompatibility", pName, sizeof ("xglGetMultiGpuCompatibility")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700494 return (XGL_VOID *) pTable->GetMultiGpuCompatibility;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800495 else if (!strncmp("xglOpenSharedMemory", pName, sizeof ("xglOpenSharedMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700496 return (XGL_VOID *) pTable->OpenSharedMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800497 else if (!strncmp("xglOpenSharedQueueSemaphore", pName, sizeof ("xglOpenSharedQueueSemaphore")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700498 return (XGL_VOID *) pTable->OpenSharedQueueSemaphore;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800499 else if (!strncmp("xglOpenPeerMemory", pName, sizeof ("xglOpenPeerMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700500 return (XGL_VOID *) pTable->OpenPeerMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800501 else if (!strncmp("xglOpenPeerImage", pName, sizeof ("xglOpenPeerImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700502 return (XGL_VOID *) pTable->OpenPeerImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800503 else if (!strncmp("xglDestroyObject", pName, sizeof ("xglDestroyObject")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700504 return (XGL_VOID *) pTable->DestroyObject;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800505 else if (!strncmp("xglGetObjectInfo", pName, sizeof ("xglGetObjectInfo")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700506 return (XGL_VOID *) pTable->GetObjectInfo;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800507 else if (!strncmp("xglBindObjectMemory", pName, sizeof ("xglBindObjectMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700508 return (XGL_VOID *) pTable->BindObjectMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800509 else if (!strncmp("xglCreateFence", pName, sizeof ("xgllCreateFence")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700510 return (XGL_VOID *) pTable->CreateFence;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800511 else if (!strncmp("xglGetFenceStatus", pName, sizeof ("xglGetFenceStatus")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700512 return (XGL_VOID *) pTable->GetFenceStatus;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800513 else if (!strncmp("xglWaitForFences", pName, sizeof ("xglWaitForFences")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700514 return (XGL_VOID *) pTable->WaitForFences;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800515 else if (!strncmp("xglCreateQueueSemaphore", pName, sizeof ("xgllCreateQueueSemaphore")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700516 return (XGL_VOID *) pTable->CreateQueueSemaphore;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800517 else if (!strncmp("xglSignalQueueSemaphore", pName, sizeof ("xglSignalQueueSemaphore")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700518 return (XGL_VOID *) pTable->SignalQueueSemaphore;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800519 else if (!strncmp("xglWaitQueueSemaphore", pName, sizeof ("xglWaitQueueSemaphore")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700520 return (XGL_VOID *) pTable->WaitQueueSemaphore;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800521 else if (!strncmp("xglCreateEvent", pName, sizeof ("xgllCreateEvent")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700522 return (XGL_VOID *) pTable->CreateEvent;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800523 else if (!strncmp("xglGetEventStatus", pName, sizeof ("xglGetEventStatus")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700524 return (XGL_VOID *) pTable->GetEventStatus;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800525 else if (!strncmp("xglSetEvent", pName, sizeof ("xglSetEvent")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700526 return (XGL_VOID *) pTable->SetEvent;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800527 else if (!strncmp("xglResetEvent", pName, sizeof ("xgllResetEvent")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700528 return (XGL_VOID *) pTable->ResetEvent;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800529 else if (!strncmp("xglCreateQueryPool", pName, sizeof ("xglCreateQueryPool")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700530 return (XGL_VOID *) pTable->CreateQueryPool;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800531 else if (!strncmp("xglGetQueryPoolResults", pName, sizeof ("xglGetQueryPoolResults")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700532 return (XGL_VOID *) pTable->GetQueryPoolResults;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800533 else if (!strncmp("xglGetFormatInfo", pName, sizeof ("xglGetFormatInfo")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700534 return (XGL_VOID *) pTable->GetFormatInfo;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800535 else if (!strncmp("xglCreateImage", pName, sizeof ("xglCreateImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700536 return (XGL_VOID *) pTable->CreateImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800537 else if (!strncmp("xglGetImageSubresourceInfo", pName, sizeof ("xglGetImageSubresourceInfo")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700538 return (XGL_VOID *) pTable->GetImageSubresourceInfo;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800539 else if (!strncmp("xglCreateImageView", pName, sizeof ("xglCreateImageView")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700540 return (XGL_VOID *) pTable->CreateImageView;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800541 else if (!strncmp("xglCreateColorAttachmentView", pName, sizeof ("xglCreateColorAttachmentView")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700542 return (XGL_VOID *) pTable->CreateColorAttachmentView;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800543 else if (!strncmp("xglCreateDepthStencilView", pName, sizeof ("xglCreateDepthStencilView")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700544 return (XGL_VOID *) pTable->CreateDepthStencilView;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800545 else if (!strncmp("xglCreateShader", pName, sizeof ("xglCreateShader")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700546 return (XGL_VOID *) pTable->CreateShader;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800547 else if (!strncmp("xglCreateGraphicsPipeline", pName, sizeof ("xglCreateGraphicsPipeline")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700548 return (XGL_VOID *) pTable->CreateGraphicsPipeline;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800549 else if (!strncmp("xglCreateComputePipeline", pName, sizeof ("xglCreateComputePipeline")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700550 return (XGL_VOID *) pTable->CreateComputePipeline;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800551 else if (!strncmp("xglStorePipeline", pName, sizeof ("xglStorePipeline")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700552 return (XGL_VOID *) pTable->StorePipeline;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800553 else if (!strncmp("xglLoadPipeline", pName, sizeof ("xglLoadPipeline")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700554 return (XGL_VOID *) pTable->LoadPipeline;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800555 else if (!strncmp("xglCreatePipelineDelta", pName, sizeof ("xglCreatePipelineDelta")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700556 return (XGL_VOID *) pTable->CreatePipelineDelta;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800557 else if (!strncmp("xglCreateSampler", pName, sizeof ("xglCreateSampler")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700558 return (XGL_VOID *) pTable->CreateSampler;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800559 else if (!strncmp("xglCreateDescriptorSet", pName, sizeof ("xglCreateDescriptorSet")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700560 return (XGL_VOID *) pTable->CreateDescriptorSet;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800561 else if (!strncmp("xglBeginDescriptorSetUpdate", pName, sizeof ("xglBeginDescriptorSetUpdate")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700562 return (XGL_VOID *) pTable->BeginDescriptorSetUpdate;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800563 else if (!strncmp("xglEndDescriptorSetUpdate", pName, sizeof ("xglEndDescriptorSetUpdate")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700564 return (XGL_VOID *) pTable->EndDescriptorSetUpdate;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800565 else if (!strncmp("xglAttachSamplerDescriptors", pName, sizeof ("xglAttachSamplerDescriptors")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700566 return (XGL_VOID *) pTable->AttachSamplerDescriptors;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800567 else if (!strncmp("xglAttachImageViewDescriptors", pName, sizeof ("xglAttachImageViewDescriptors")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700568 return (XGL_VOID *) pTable->AttachImageViewDescriptors;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800569 else if (!strncmp("xglAttachMemoryViewDescriptors", pName, sizeof ("xglAttachMemoryViewDescriptors")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700570 return (XGL_VOID *) pTable->AttachMemoryViewDescriptors;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800571 else if (!strncmp("xglAttachNestedDescriptors", pName, sizeof ("xglAttachNestedDescriptors")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700572 return (XGL_VOID *) pTable->AttachNestedDescriptors;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800573 else if (!strncmp("xglClearDescriptorSetSlots", pName, sizeof ("xglClearDescriptorSetSlots")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700574 return (XGL_VOID *) pTable->ClearDescriptorSetSlots;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800575 else if (!strncmp("xglCreateViewportState", pName, sizeof ("xglCreateViewportState")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700576 return (XGL_VOID *) pTable->CreateViewportState;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800577 else if (!strncmp("xglCreateRasterState", pName, sizeof ("xglCreateRasterState")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700578 return (XGL_VOID *) pTable->CreateRasterState;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800579 else if (!strncmp("xglCreateMsaaState", pName, sizeof ("xglCreateMsaaState")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700580 return (XGL_VOID *) pTable->CreateMsaaState;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800581 else if (!strncmp("xglCreateColorBlendState", pName, sizeof ("xglCreateColorBlendState")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700582 return (XGL_VOID *) pTable->CreateColorBlendState;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800583 else if (!strncmp("xglCreateDepthStencilState", pName, sizeof ("xglCreateDepthStencilState")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700584 return (XGL_VOID *) pTable->CreateDepthStencilState;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800585 else if (!strncmp("xglCreateCommandBuffer", pName, sizeof ("xglCreateCommandBuffer")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700586 return (XGL_VOID *) multi2CreateCommandBuffer;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800587 else if (!strncmp("xglBeginCommandBuffer", pName, sizeof ("xglBeginCommandBuffer")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700588 return (XGL_VOID *) multi2BeginCommandBuffer;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800589 else if (!strncmp("xglEndCommandBuffer", pName, sizeof ("xglEndCommandBuffer")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700590 return (XGL_VOID *) pTable->EndCommandBuffer;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800591 else if (!strncmp("xglResetCommandBuffer", pName, sizeof ("xglResetCommandBuffer")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700592 return (XGL_VOID *) pTable->ResetCommandBuffer;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800593 else if (!strncmp("xglCmdBindPipeline", pName, sizeof ("xglCmdBindPipeline")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700594 return (XGL_VOID *) pTable->CmdBindPipeline;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800595 else if (!strncmp("xglCmdBindPipelineDelta", pName, sizeof ("xglCmdBindPipelineDelta")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700596 return (XGL_VOID *) pTable->CmdBindPipelineDelta;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800597 else if (!strncmp("xglCmdBindStateObject", pName, sizeof ("xglCmdBindStateObject")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700598 return (XGL_VOID *) pTable->CmdBindStateObject;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800599 else if (!strncmp("xglCmdBindDescriptorSet", pName, sizeof ("xglCmdBindDescriptorSet")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700600 return (XGL_VOID *) pTable->CmdBindDescriptorSet;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800601 else if (!strncmp("xglCmdBindDynamicMemoryView", pName, sizeof ("xglCmdBindDynamicMemoryView")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700602 return (XGL_VOID *) pTable->CmdBindDynamicMemoryView;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800603 else if (!strncmp("xglCmdBindVertexData", pName, sizeof ("xglCmdBindVertexData")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700604 return (XGL_VOID *) pTable->CmdBindVertexData;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800605 else if (!strncmp("xglCmdBindIndexData", pName, sizeof ("xglCmdBindIndexData")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700606 return (XGL_VOID *) pTable->CmdBindIndexData;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800607 else if (!strncmp("xglCmdBindAttachments", pName, sizeof ("xglCmdBindAttachments")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700608 return (XGL_VOID *) pTable->CmdBindAttachments;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800609 else if (!strncmp("xglCmdPrepareMemoryRegions", pName, sizeof ("xglCmdPrepareMemoryRegions")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700610 return (XGL_VOID *) pTable->CmdPrepareMemoryRegions;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800611 else if (!strncmp("xglCmdPrepareImages", pName, sizeof ("xglCmdPrepareImages")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700612 return (XGL_VOID *) pTable->CmdPrepareImages;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800613 else if (!strncmp("xglCmdDraw", pName, sizeof ("xglCmdDraw")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700614 return (XGL_VOID *) pTable->CmdDraw;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800615 else if (!strncmp("xglCmdDrawIndexed", pName, sizeof ("xglCmdDrawIndexed")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700616 return (XGL_VOID *) pTable->CmdDrawIndexed;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800617 else if (!strncmp("xglCmdDrawIndirect", pName, sizeof ("xglCmdDrawIndirect")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700618 return (XGL_VOID *) pTable->CmdDrawIndirect;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800619 else if (!strncmp("xglCmdDrawIndexedIndirect", pName, sizeof ("xglCmdDrawIndexedIndirect")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700620 return (XGL_VOID *) pTable->CmdDrawIndexedIndirect;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800621 else if (!strncmp("xglCmdDispatch", pName, sizeof ("xglCmdDispatch")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700622 return (XGL_VOID *) pTable->CmdDispatch;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800623 else if (!strncmp("xglCmdDispatchIndirect", pName, sizeof ("xglCmdDispatchIndirect")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700624 return (XGL_VOID *) pTable->CmdDispatchIndirect;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800625 else if (!strncmp("xglCmdCopyMemory", pName, sizeof ("xglCmdCopyMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700626 return (XGL_VOID *) pTable->CmdCopyMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800627 else if (!strncmp("xglCmdCopyImage", pName, sizeof ("xglCmdCopyImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700628 return (XGL_VOID *) pTable->CmdCopyImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800629 else if (!strncmp("xglCmdCopyMemoryToImage", pName, sizeof ("xglCmdCopyMemoryToImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700630 return (XGL_VOID *) pTable->CmdCopyMemoryToImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800631 else if (!strncmp("xglCmdCopyImageToMemory", pName, sizeof ("xglCmdCopyImageToMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700632 return (XGL_VOID *) pTable->CmdCopyImageToMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800633 else if (!strncmp("xglCmdCloneImageData", pName, sizeof ("xglCmdCloneImageData")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700634 return (XGL_VOID *) pTable->CmdCloneImageData;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800635 else if (!strncmp("xglCmdUpdateMemory", pName, sizeof ("xglCmdUpdateMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700636 return (XGL_VOID *) pTable->CmdUpdateMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800637 else if (!strncmp("xglCmdFillMemory", pName, sizeof ("xglCmdFillMemory")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700638 return (XGL_VOID *) pTable->CmdFillMemory;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800639 else if (!strncmp("xglCmdClearColorImage", pName, sizeof ("xglCmdClearColorImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700640 return (XGL_VOID *) pTable->CmdClearColorImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800641 else if (!strncmp("xglCmdClearColorImageRaw", pName, sizeof ("xglCmdClearColorImageRaw")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700642 return (XGL_VOID *) pTable->CmdClearColorImageRaw;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800643 else if (!strncmp("xglCmdClearDepthStencil", pName, sizeof ("xglCmdClearDepthStencil")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700644 return (XGL_VOID *) pTable->CmdClearDepthStencil;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800645 else if (!strncmp("xglCmdResolveImage", pName, sizeof ("xglCmdResolveImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700646 return (XGL_VOID *) pTable->CmdResolveImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800647 else if (!strncmp("xglCmdSetEvent", pName, sizeof ("xglCmdSetEvent")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700648 return (XGL_VOID *) pTable->CmdSetEvent;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800649 else if (!strncmp("xglCmdResetEvent", pName, sizeof ("xglCmdResetEvent")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700650 return (XGL_VOID *) pTable->CmdResetEvent;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800651 else if (!strncmp("xglCmdMemoryAtomic", pName, sizeof ("xglCmdMemoryAtomic")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700652 return (XGL_VOID *) pTable->CmdMemoryAtomic;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800653 else if (!strncmp("xglCmdBeginQuery", pName, sizeof ("xglCmdBeginQuery")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700654 return (XGL_VOID *) pTable->CmdBeginQuery;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800655 else if (!strncmp("xglCmdEndQuery", pName, sizeof ("xglCmdEndQuery")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700656 return (XGL_VOID *) pTable->CmdEndQuery;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800657 else if (!strncmp("xglCmdResetQueryPool", pName, sizeof ("xglCmdResetQueryPool")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700658 return (XGL_VOID *) pTable->CmdResetQueryPool;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800659 else if (!strncmp("xglCmdWriteTimestamp", pName, sizeof ("xglCmdWriteTimestamp")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700660 return (XGL_VOID *) pTable->CmdWriteTimestamp;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800661 else if (!strncmp("xglCmdInitAtomicCounters", pName, sizeof ("xglCmdInitAtomicCounters")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700662 return (XGL_VOID *) pTable->CmdInitAtomicCounters;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800663 else if (!strncmp("xglCmdLoadAtomicCounters", pName, sizeof ("xglCmdLoadAtomicCounters")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700664 return (XGL_VOID *) pTable->CmdLoadAtomicCounters;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800665 else if (!strncmp("xglCmdSaveAtomicCounters", pName, sizeof ("xglCmdSaveAtomicCounters")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700666 return (XGL_VOID *) pTable->CmdSaveAtomicCounters;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800667 else if (!strncmp("xglDbgSetValidationLevel", pName, sizeof ("xglDbgSetValidationLevel")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700668 return (XGL_VOID *) pTable->DbgSetValidationLevel;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800669 else if (!strncmp("xglDbgRegisterMsgCallback", pName, sizeof ("xglDbgRegisterMsgCallback")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700670 return (XGL_VOID *) pTable->DbgRegisterMsgCallback;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800671 else if (!strncmp("xglDbgUnregisterMsgCallback", pName, sizeof ("xglDbgUnregisterMsgCallback")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700672 return (XGL_VOID *) pTable->DbgUnregisterMsgCallback;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800673 else if (!strncmp("xglDbgSetMessageFilter", pName, sizeof ("xglDbgSetMessageFilter")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700674 return (XGL_VOID *) pTable->DbgSetMessageFilter;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800675 else if (!strncmp("xglDbgSetObjectTag", pName, sizeof ("xglDbgSetObjectTag")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700676 return (XGL_VOID *) pTable->DbgSetObjectTag;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800677 else if (!strncmp("xglDbgSetGlobalOption", pName, sizeof ("xglDbgSetGlobalOption")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700678 return (XGL_VOID *) pTable->DbgSetGlobalOption;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800679 else if (!strncmp("xglDbgSetDeviceOption", pName, sizeof ("xglDbgSetDeviceOption")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700680 return (XGL_VOID *) pTable->DbgSetDeviceOption;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800681 else if (!strncmp("xglCmdDbgMarkerBegin", pName, sizeof ("xglCmdDbgMarkerBegin")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700682 return (XGL_VOID *) pTable->CmdDbgMarkerBegin;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800683 else if (!strncmp("xglCmdDbgMarkerEnd", pName, sizeof ("xglCmdDbgMarkerEnd")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700684 return (XGL_VOID *) pTable->CmdDbgMarkerEnd;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800685 else if (!strncmp("xglWsiX11AssociateConnection", pName, sizeof("xglWsiX11AssociateConnection")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700686 return (XGL_VOID *) pTable->WsiX11AssociateConnection;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800687 else if (!strncmp("xglWsiX11GetMSC", pName, sizeof("xglWsiX11GetMSC")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700688 return (XGL_VOID *) pTable->WsiX11GetMSC;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800689 else if (!strncmp("xglWsiX11CreatePresentableImage", pName, sizeof("xglWsiX11CreatePresentableImage")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700690 return (XGL_VOID *) pTable->WsiX11CreatePresentableImage;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800691 else if (!strncmp("xglWsiX11QueuePresent", pName, sizeof("xglWsiX11QueuePresent")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700692 return (XGL_VOID *) pTable->WsiX11QueuePresent;
693 else {
694 XGL_BASE_LAYER_OBJECT* gpuw = (XGL_BASE_LAYER_OBJECT *) gpu;
695 if (gpuw->pGPA == NULL)
696 return NULL;
697 return gpuw->pGPA((XGL_PHYSICAL_GPU) gpuw->nextObject, pName);
698 }
699
700}
701
702/********************************* Common functions ********************************/
703XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglEnumerateLayers(XGL_PHYSICAL_GPU gpu, XGL_SIZE maxLayerCount, XGL_SIZE maxStringSize,
704 XGL_CHAR* const* pOutLayers, XGL_SIZE * pOutLayerCount,
705 XGL_VOID* pReserved)
706{
707 if (pOutLayerCount == NULL || pOutLayers == NULL || pOutLayers[0] == NULL || pOutLayers[1] == NULL || pReserved == NULL)
708 return XGL_ERROR_INVALID_POINTER;
709
710 if (maxLayerCount < 2)
711 return XGL_ERROR_INITIALIZATION_FAILED;
712 *pOutLayerCount = 2;
713 strncpy((char *) pOutLayers[0], "multi1", maxStringSize);
714 strncpy((char *) pOutLayers[1], "multi2", maxStringSize);
715 return XGL_SUCCESS;
716}
717
718XGL_LAYER_EXPORT XGL_VOID * XGLAPI xglGetProcAddr(XGL_PHYSICAL_GPU gpu, const XGL_CHAR* pName)
719{
720 // to find each layers GPA routine Loader will search via "<layerName>GetProcAddr"
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800721 if (!strncmp("multi1GetProcAddr", pName, sizeof("multi1GetProcAddr")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700722 return (XGL_VOID *) multi1GetProcAddr;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800723 else if (!strncmp("multi2GetProcAddr", pName, sizeof("multi2GetProcAddr")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700724 return (XGL_VOID *) multi2GetProcAddr;
Chia-I Wuf1a5a742014-12-27 15:16:07 +0800725 else if (!strncmp("xglGetProcAddr", pName, sizeof("xglGetProcAddr")))
Jon Ashburn79113cc2014-12-01 14:22:40 -0700726 return (XGL_VOID *) xglGetProcAddr;
727
728 // use first layer activated as GPA dispatch table activation happens in order
729 else if (layer1_first_activated)
730 return multi1GetProcAddr(gpu, pName);
731 else if (layer2_first_activated)
732 return multi2GetProcAddr(gpu, pName);
733 else
734 return NULL;
735
736}
737
738#ifdef __cplusplus
739} //extern "C"
740#endif
741
742static void initLayerTable(const XGL_BASE_LAYER_OBJECT *gpuw, XGL_LAYER_DISPATCH_TABLE *pTable, const unsigned int layerNum)
743{
Jon Ashburn79113cc2014-12-01 14:22:40 -0700744 if (layerNum == 2 && layer1_first_activated == false)
745 layer2_first_activated = true;
746 if (layerNum == 1 && layer2_first_activated == false)
747 layer1_first_activated = true;
748
Chia-I Wuaa4121f2015-01-04 23:11:43 +0800749 layer_initialize_dispatch_table(pTable, gpuw->pGPA, (XGL_PHYSICAL_GPU) gpuw->nextObject);
Jon Ashburn79113cc2014-12-01 14:22:40 -0700750}