-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbootstrap.go
More file actions
108 lines (100 loc) · 2.98 KB
/
bootstrap.go
File metadata and controls
108 lines (100 loc) · 2.98 KB
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
package core
import (
"unsafe"
"github.com/vkngwrapper/core/v3/common"
"github.com/vkngwrapper/core/v3/core1_0"
"github.com/vkngwrapper/core/v3/internal/impl1_0"
"github.com/vkngwrapper/core/v3/internal/impl1_1"
"github.com/vkngwrapper/core/v3/internal/impl1_2"
"github.com/vkngwrapper/core/v3/loader"
)
func CreateDriverFromProcAddr(procAddr unsafe.Pointer) (core1_0.GlobalDriver, error) {
loaderObj, err := loader.CreateLoaderFromProcAddr(procAddr)
if err != nil {
return nil, err
}
return &impl1_0.GlobalVulkanDriver{
LoaderObj: loaderObj,
InstanceDriverFactory: buildInstanceDriver,
DeviceDriverFactory: buildDeviceDriver,
}, nil
}
func buildInstanceDriver(driver *impl1_0.GlobalVulkanDriver, instance core1_0.Instance) (core1_0.CoreInstanceDriver, error) {
loaderObj, err := driver.LoaderObj.CreateInstanceLoader(instance.Handle())
if err != nil {
return nil, err
}
switch instance.APIVersion() {
case common.Vulkan1_2:
return &impl1_2.InstanceVulkanDriver{
InstanceVulkanDriver: impl1_1.InstanceVulkanDriver{
InstanceVulkanDriver: impl1_0.InstanceVulkanDriver{
GlobalVulkanDriver: impl1_0.GlobalVulkanDriver{
LoaderObj: loaderObj,
InstanceDriverFactory: buildInstanceDriver,
DeviceDriverFactory: buildDeviceDriver,
},
InstanceObj: instance,
},
},
}, nil
case common.Vulkan1_1:
return &impl1_1.InstanceVulkanDriver{
InstanceVulkanDriver: impl1_0.InstanceVulkanDriver{
GlobalVulkanDriver: impl1_0.GlobalVulkanDriver{
LoaderObj: loaderObj,
InstanceDriverFactory: buildInstanceDriver,
DeviceDriverFactory: buildDeviceDriver,
},
InstanceObj: instance,
},
}, nil
default:
return &impl1_0.InstanceVulkanDriver{
GlobalVulkanDriver: impl1_0.GlobalVulkanDriver{
LoaderObj: loaderObj,
InstanceDriverFactory: buildInstanceDriver,
DeviceDriverFactory: buildDeviceDriver,
},
InstanceObj: instance,
}, nil
}
}
func buildDeviceDriver(driver core1_0.CoreInstanceDriver, device core1_0.Device) (core1_0.CoreDeviceDriver, error) {
loaderObj, err := driver.Loader().CreateDeviceLoader(device.Handle())
if err != nil {
return nil, err
}
switch device.APIVersion() {
case common.Vulkan1_2:
return &impl1_2.CoreVulkanDriver{
InstanceDriverObj: driver,
DeviceVulkanDriver: impl1_2.DeviceVulkanDriver{
DeviceVulkanDriver: impl1_1.DeviceVulkanDriver{
DeviceVulkanDriver: impl1_0.DeviceVulkanDriver{
LoaderObj: loaderObj,
DeviceObj: device,
},
},
},
}, nil
case common.Vulkan1_1:
return &impl1_1.CoreVulkanDriver{
InstanceDriverObj: driver,
DeviceVulkanDriver: impl1_1.DeviceVulkanDriver{
DeviceVulkanDriver: impl1_0.DeviceVulkanDriver{
LoaderObj: loaderObj,
DeviceObj: device,
},
},
}, nil
default:
return &impl1_0.CoreVulkanDriver{
InstanceDriverObj: driver,
DeviceVulkanDriver: impl1_0.DeviceVulkanDriver{
LoaderObj: loaderObj,
DeviceObj: device,
},
}, nil
}
}