-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathicd_stubs.cpp
155 lines (133 loc) · 5.1 KB
/
icd_stubs.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#include "precompiled.h"
#include "gpu.h"
#include "spirv_compile.h"
VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkInstance *pInstance)
{
*pInstance = (VkInstance) new VK_LOADER_DATA;
set_loader_magic_value(*pInstance);
InitFrameStats();
InitRasterThreads();
InitLLVM();
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(VkInstance instance,
const VkAllocationCallbacks *pAllocator)
{
ShutdownRasterThreads();
ShutdownFrameStats();
delete(VK_LOADER_DATA *)instance;
}
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkDevice *pDevice)
{
VkDevice dev = new VkDevice_T;
assert((void *)dev == &dev->loaderMagic);
set_loader_magic_value(dev);
// we only have 1 queue family, there should only be 1 info
assert(pCreateInfo->queueCreateInfoCount == 1);
dev->queues.resize(pCreateInfo->pQueueCreateInfos[0].queueCount);
for(uint32_t i = 0; i < pCreateInfo->pQueueCreateInfos[0].queueCount; i++)
{
dev->queues[i] = new VK_LOADER_DATA;
set_loader_magic_value(dev->queues[i]);
}
*pDevice = dev;
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator)
{
for(VK_LOADER_DATA *q : device->queues)
delete q;
delete device;
}
VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex,
uint32_t queueIndex, VkQueue *pQueue)
{
assert(queueFamilyIndex == 0);
*pQueue = (VkQueue)device->queues[queueIndex];
}
VKAPI_ATTR VkResult VKAPI_CALL vkCreateFence(VkDevice device, const VkFenceCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkFence *pFence)
{
// TODO but for now return unique values
static uint64_t nextFence = 1;
*pFence = (VkFence)(nextFence++);
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL vkDestroyFence(VkDevice device, VkFence fence,
const VkAllocationCallbacks *pAllocator)
{
// nothing to do
}
VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore(VkDevice device,
const VkSemaphoreCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkSemaphore *pSemaphore)
{
// TODO but for now return unique values
static uint64_t nextSemaphore = 1;
*pSemaphore = (VkSemaphore)(nextSemaphore++);
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore(VkDevice device, VkSemaphore semaphore,
const VkAllocationCallbacks *pAllocator)
{
// nothing to do
}
VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(VkDevice device,
const VkSamplerCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkSampler *pSampler)
{
// TODO but for now return unique values
static uint64_t nextSampler = 1;
*pSampler = (VkSampler)(nextSampler++);
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL vkDestroySampler(VkDevice device, VkSampler sampler,
const VkAllocationCallbacks *pAllocator)
{
// nothing to do
}
VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(VkDevice device,
const VkPipelineCacheCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkPipelineCache *pPipelineCache)
{
// TODO but for now return unique values
static uint64_t nextPipelineCache = 1;
*pPipelineCache = (VkPipelineCache)(nextPipelineCache++);
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache(VkDevice device, VkPipelineCache pipelineCache,
const VkAllocationCallbacks *pAllocator)
{
// nothing to do
}
VKAPI_ATTR VkResult VKAPI_CALL vkWaitForFences(VkDevice device, uint32_t fenceCount,
const VkFence *pFences, VkBool32 waitAll,
uint64_t timeout)
{
// TODO
return VK_SUCCESS;
}
VKAPI_ATTR VkResult VKAPI_CALL vkResetFences(VkDevice device, uint32_t fenceCount,
const VkFence *pFences)
{
// TODO
return VK_SUCCESS;
}
VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle(VkDevice device)
{
// TODO
return VK_SUCCESS;
}
VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle(VkQueue queue)
{
// TODO
return VK_SUCCESS;
}