-
Notifications
You must be signed in to change notification settings - Fork 4
/
application.go
116 lines (92 loc) · 2.43 KB
/
application.go
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
110
111
112
113
114
115
116
package asche
import vk "github.com/vulkan-go/vulkan"
type VulkanMode uint32
const (
VulkanNone VulkanMode = (1 << iota) >> 1
VulkanCompute
VulkanGraphics
VulkanPresent
)
func (v VulkanMode) Has(mode VulkanMode) bool {
return v&mode != 0
}
type Application interface {
VulkanInit(ctx Context) error
VulkanAPIVersion() vk.Version
VulkanAppVersion() vk.Version
VulkanAppName() string
VulkanMode() VulkanMode
VulkanSurface(instance vk.Instance) vk.Surface
VulkanInstanceExtensions() []string
VulkanDeviceExtensions() []string
VulkanDebug() bool
// DECORATORS:
// ApplicationSwapchainDimensions
// ApplicationVulkanLayers
// ApplicationContextPrepare
// ApplicationContextCleanup
// ApplicationContextInvalidate
}
type ApplicationSwapchainDimensions interface {
VulkanSwapchainDimensions() *SwapchainDimensions
}
type ApplicationVulkanLayers interface {
VulkanLayers() []string
}
type ApplicationContextPrepare interface {
VulkanContextPrepare() error
}
type ApplicationContextCleanup interface {
VulkanContextCleanup() error
}
type ApplicationContextInvalidate interface {
VulkanContextInvalidate(imageIdx int) error
}
var (
DefaultVulkanAppVersion = vk.MakeVersion(1, 0, 0)
DefaultVulkanAPIVersion = vk.MakeVersion(1, 0, 0)
DefaultVulkanMode = VulkanCompute | VulkanGraphics | VulkanPresent
)
// SwapchainDimensions describes the size and format of the swapchain.
type SwapchainDimensions struct {
// Width of the swapchain.
Width uint32
// Height of the swapchain.
Height uint32
// Format is the pixel format of the swapchain.
Format vk.Format
}
type BaseVulkanApp struct {
context Context
}
func (app *BaseVulkanApp) Context() Context {
return app.context
}
func (app *BaseVulkanApp) VulkanInit(ctx Context) error {
app.context = ctx
return nil
}
func (app *BaseVulkanApp) VulkanAPIVersion() vk.Version {
return vk.Version(vk.MakeVersion(1, 0, 0))
}
func (app *BaseVulkanApp) VulkanAppVersion() vk.Version {
return vk.Version(vk.MakeVersion(1, 0, 0))
}
func (app *BaseVulkanApp) VulkanAppName() string {
return "base"
}
func (app *BaseVulkanApp) VulkanMode() VulkanMode {
return DefaultVulkanMode
}
func (app *BaseVulkanApp) VulkanSurface(instance vk.Instance) vk.Surface {
return vk.NullSurface
}
func (app *BaseVulkanApp) VulkanInstanceExtensions() []string {
return nil
}
func (app *BaseVulkanApp) VulkanDeviceExtensions() []string {
return nil
}
func (app *BaseVulkanApp) VulkanDebug() bool {
return false
}