-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrenderpass.cpp
58 lines (51 loc) · 2.46 KB
/
renderpass.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
#include "precompiled.h"
VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer(VkDevice device,
const VkFramebufferCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkFramebuffer *pFramebuffer)
{
VkFramebuffer ret = new VkFramebuffer_T;
if(pCreateInfo->attachmentCount > 0)
ret->attachments.insert(ret->attachments.begin(), pCreateInfo->pAttachments,
pCreateInfo->pAttachments + pCreateInfo->attachmentCount);
*pFramebuffer = ret;
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer,
const VkAllocationCallbacks *pAllocator)
{
delete framebuffer;
}
VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(VkDevice device,
const VkRenderPassCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator,
VkRenderPass *pRenderPass)
{
VkRenderPass ret = new VkRenderPass_T;
ret->subpasses.reserve(pCreateInfo->subpassCount);
for(uint32_t i = 0; i < pCreateInfo->subpassCount; i++)
{
VkRenderPass_T::Subpass sub;
sub.colAttachments.resize(pCreateInfo->pSubpasses[i].colorAttachmentCount);
for(uint32_t a = 0; a < pCreateInfo->pSubpasses[i].colorAttachmentCount; a++)
{
sub.colAttachments[a].idx = (int32_t)pCreateInfo->pSubpasses[i].pColorAttachments[a].attachment;
sub.colAttachments[a].clear = (pCreateInfo->pAttachments[sub.colAttachments[a].idx].loadOp ==
VK_ATTACHMENT_LOAD_OP_CLEAR);
sub.depthAttachment.idx = -1;
if(pCreateInfo->pSubpasses[i].pDepthStencilAttachment)
sub.depthAttachment.idx = pCreateInfo->pSubpasses[i].pDepthStencilAttachment->attachment;
if(sub.depthAttachment.idx >= 0)
sub.depthAttachment.clear = (pCreateInfo->pAttachments[sub.depthAttachment.idx].loadOp ==
VK_ATTACHMENT_LOAD_OP_CLEAR);
}
ret->subpasses.emplace_back(sub);
}
*pRenderPass = ret;
return VK_SUCCESS;
}
VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
const VkAllocationCallbacks *pAllocator)
{
delete renderPass;
}