blob: e9839ee731562317a13f3475cf93b89172f55fca [file] [log] [blame]
Alexis Hetu8f631c82018-11-15 15:11:36 -05001// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef VK_FRAMEBUFFER_HPP_
16#define VK_FRAMEBUFFER_HPP_
17
18#include "VkObject.hpp"
19
Nicolas Capens157ba262019-12-10 17:49:14 -050020namespace vk {
Alexis Hetu8f631c82018-11-15 15:11:36 -050021
Alexis Hetu9fbaf692018-11-19 11:30:43 -050022class ImageView;
Alexis Hetu1cd31ea2019-01-17 17:14:57 -050023class RenderPass;
Alexis Hetu9fbaf692018-11-19 11:30:43 -050024
Alexis Hetu8f631c82018-11-15 15:11:36 -050025class Framebuffer : public Object<Framebuffer, VkFramebuffer>
26{
27public:
Ben Clayton2ed93ab2019-12-17 20:38:03 +000028 Framebuffer(const VkFramebufferCreateInfo *pCreateInfo, void *mem);
29 void destroy(const VkAllocationCallbacks *pAllocator);
Alexis Hetu8f631c82018-11-15 15:11:36 -050030
Ben Clayton2ed93ab2019-12-17 20:38:03 +000031 void clear(const RenderPass *renderPass, uint32_t clearValueCount, const VkClearValue *pClearValues, const VkRect2D &renderArea);
32 void clearAttachment(const RenderPass *renderPass, uint32_t subpassIndex, const VkClearAttachment &attachment, const VkClearRect &rect);
Alexis Hetu9fbaf692018-11-19 11:30:43 -050033
Ben Clayton2ed93ab2019-12-17 20:38:03 +000034 static size_t ComputeRequiredAllocationSize(const VkFramebufferCreateInfo *pCreateInfo);
Chris Forbes7c33e882019-02-21 14:58:28 -080035 ImageView *getAttachment(uint32_t index) const;
Ben Clayton2ed93ab2019-12-17 20:38:03 +000036 void resolve(const RenderPass *renderPass, uint32_t subpassIndex);
Alexis Hetu8f631c82018-11-15 15:11:36 -050037
Ben Clayton2ed93ab2019-12-17 20:38:03 +000038 const VkExtent3D &getExtent() const { return extent; }
Alexis Hetud9ed1c22019-11-07 13:51:51 -050039
Alexis Hetu8f631c82018-11-15 15:11:36 -050040private:
Ben Clayton2ed93ab2019-12-17 20:38:03 +000041 uint32_t attachmentCount = 0;
42 ImageView **attachments = nullptr;
Alexis Hetud9ed1c22019-11-07 13:51:51 -050043 const VkExtent3D extent = {};
Alexis Hetu8f631c82018-11-15 15:11:36 -050044};
45
Ben Clayton2ed93ab2019-12-17 20:38:03 +000046static inline Framebuffer *Cast(VkFramebuffer object)
Alexis Hetu8f631c82018-11-15 15:11:36 -050047{
Alexis Hetubd4cf812019-06-14 15:14:07 -040048 return Framebuffer::Cast(object);
Alexis Hetu8f631c82018-11-15 15:11:36 -050049}
50
Nicolas Capens157ba262019-12-10 17:49:14 -050051} // namespace vk
Alexis Hetu8f631c82018-11-15 15:11:36 -050052
Ben Clayton2ed93ab2019-12-17 20:38:03 +000053#endif // VK_FRAMEBUFFER_HPP_