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
|
/*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "GrVkFramebuffer.h"
#include "GrVkGpu.h"
#include "GrVkImageView.h"
#include "GrVkRenderPass.h"
GrVkFramebuffer* GrVkFramebuffer::Create(GrVkGpu* gpu,
int width, int height,
const GrVkRenderPass* renderPass,
const GrVkImageView* colorAttachment,
const GrVkImageView* stencilAttachment) {
// At the very least we need a renderPass and a colorAttachment
SkASSERT(renderPass);
SkASSERT(colorAttachment);
VkImageView attachments[3];
attachments[0] = colorAttachment->imageView();
int numAttachments = 1;
if (stencilAttachment) {
attachments[numAttachments++] = stencilAttachment->imageView();
}
VkFramebufferCreateInfo createInfo;
memset(&createInfo, 0, sizeof(VkFramebufferCreateInfo));
createInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
createInfo.pNext = nullptr;
createInfo.flags = 0;
createInfo.renderPass = renderPass->vkRenderPass();
createInfo.attachmentCount = numAttachments;
createInfo.pAttachments = attachments;
createInfo.width = width;
createInfo.height = height;
createInfo.layers = 1;
VkFramebuffer framebuffer;
VkResult err = GR_VK_CALL(gpu->vkInterface(), CreateFramebuffer(gpu->device(),
&createInfo,
nullptr,
&framebuffer));
if (err) {
return nullptr;
}
return new GrVkFramebuffer(framebuffer);
}
void GrVkFramebuffer::freeGPUData(const GrVkGpu* gpu) const {
SkASSERT(fFramebuffer);
GR_VK_CALL(gpu->vkInterface(), DestroyFramebuffer(gpu->device(), fFramebuffer, nullptr));
}
|