-
Notifications
You must be signed in to change notification settings - Fork 10
/
descriptors.cpp
109 lines (99 loc) · 4.41 KB
/
descriptors.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
#include "precompiled.h"
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout(
VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pDescriptorSetLayout)
{
VkDescriptorSetLayout ret = new VkDescriptorSetLayout_T;
ret->bindingCount = pCreateInfo->bindingCount;
*pDescriptorSetLayout = ret;
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout(VkDevice device,
VkDescriptorSetLayout descriptorSetLayout,
const VkAllocationCallbacks *pAllocator)
{
// nothing to do
}
VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout(VkDevice device,
const VkPipelineLayoutCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkPipelineLayout *pPipelineLayout)
{
// TODO but for now return unique values
static uint64_t nextPipelineLayout = 1;
*pPipelineLayout = (VkPipelineLayout)(nextPipelineLayout++);
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout,
const VkAllocationCallbacks *pAllocator)
{
// nothing to do
}
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool(VkDevice device,
const VkDescriptorPoolCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkDescriptorPool *pDescriptorPool)
{
// TODO but for now return unique values
static uint64_t nextDescriptorPool = 1;
*pDescriptorPool = (VkDescriptorPool)(nextDescriptorPool++);
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool sampler,
const VkAllocationCallbacks *pAllocator)
{
// nothing to do
}
VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets(VkDevice device,
const VkDescriptorSetAllocateInfo *pAllocateInfo,
VkDescriptorSet *pDescriptorSets)
{
for(uint32_t i = 0; i < pAllocateInfo->descriptorSetCount; i++)
{
pDescriptorSets[0] = new VkDescriptorSet_T;
pDescriptorSets[0]->binds =
new VkDescriptorSet_T::Bind[pAllocateInfo->pSetLayouts[i]->bindingCount];
}
return VK_SUCCESS;
}
VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
uint32_t descriptorSetCount,
const VkDescriptorSet *pDescriptorSets)
{
for(uint32_t i = 0; i < descriptorSetCount; i++)
{
delete[] pDescriptorSets[i]->binds;
delete pDescriptorSets[i];
}
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
const VkWriteDescriptorSet *pDescriptorWrites,
uint32_t descriptorCopyCount,
const VkCopyDescriptorSet *pDescriptorCopies)
{
for(uint32_t i = 0; i < descriptorWriteCount; i++)
{
const VkWriteDescriptorSet &w = pDescriptorWrites[i];
VkDescriptorSet_T::Bind &bind = w.dstSet->binds[w.dstBinding];
bind.type = w.descriptorType;
switch(w.descriptorType)
{
case VK_DESCRIPTOR_TYPE_SAMPLER:
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT: bind.data.imageInfo = w.pImageInfo[0]; break;
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
bind.data.texelBufferView = w.pTexelBufferView[0];
break;
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
bind.data.bufferInfo = w.pBufferInfo[0];
break;
}
}
}