-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompositor.h
98 lines (76 loc) · 2.77 KB
/
compositor.h
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
/**
* Copyright (C) 2016 Nigel Williams
*
* Vulkan Free Surface Modeling Engine (VFSME) is free software:
* you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef compositor_h
#define compositor_h
#include <vulkan/vulkan.h>
#include "renderer.h"
#include "compute.h"
namespace vfsme
{
class Compositor
{
public:
explicit Compositor(const VkPhysicalDeviceMemoryProperties& memProperties);
~Compositor();
///@note Only define copy and move constructors and assignment operators if they are actually required
Compositor(const Compositor&) = delete;
Compositor(Compositor&&) = delete;
Compositor& operator=(const Compositor&) = delete;
Compositor& operator=(Compositor &&) = delete;
void Init(VkDevice& device,
const VkSurfaceKHR& surface,
uint32_t width,
uint32_t height,
uint32_t queueFamilyId,
uint32_t graphicsQueueIndex,
uint32_t presentQueueIndex,
uint32_t computeQueueIndex);
void Loop();
void Destroy(VkDevice& device);
inline VkFormat GetSurfaceFormat() const { return surfaceFormat; }
inline VkPresentModeKHR GetPresentMode() const { return presentMode; }
void Draw(VkDevice& device);
private:
void PrintCapabilities();
uint32_t imageCount;
uint32_t drawIndex;
Renderer* graphicsEngine;
Compute* computer;
VkSurfaceCapabilitiesKHR capabilities;
VkImage* images;
VkSemaphore waitSemaphore;
VkSemaphore signalSemaphore;
VkSwapchainKHR swapChain;
VkImageView* imageViews;
const VkPhysicalDeviceMemoryProperties& memProperties;
VkQueue presentQueue;
VkQueue graphicsQueue;
VkQueue computeQueue;
VkCommandBuffer* drawCommandBuffer;
VkCommandBuffer* transferCommandBuffer;
VkCommandBuffer* computeCommandBuffer;
const VkFormat surfaceFormat = VK_FORMAT_B8G8R8A8_UNORM;
const VkPresentModeKHR presentMode = VK_PRESENT_MODE_MAILBOX_KHR;
VkImage textureImage;
VkImageMemoryBarrier barrier;
///@note Grid dimensions are currently restricted by the max X and Y workgroup sizes of the device (32x32 on my hardware)
/// Needs to be changed to dynamic sizing in a future patchset by either spreading computation to the third workgroup
/// dimension or across multiple workgroups, or, at the very least, set dynamically to the physical device limits.
const VkExtent3D grid { 32, 32, 1 };
};
};
#endif