-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathextensions.go
More file actions
64 lines (54 loc) · 1.66 KB
/
extensions.go
File metadata and controls
64 lines (54 loc) · 1.66 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
package vk
// #include "vk.h"
// #include <stdlib.h>
import "C"
import "unsafe"
type Extension interface {
isExtension()
externalize(a *allocator) unsafe.Pointer
internalize(unsafe.Pointer)
}
type structHeader struct {
Type StructureType
Next unsafe.Pointer
}
func buildChain(a *allocator, exs []Extension) unsafe.Pointer {
var next unsafe.Pointer
for i := len(exs) - 1; i >= 0; i-- {
cex := exs[i].externalize(a)
(*structHeader)(cex).Next = next
next = cex
}
return next
}
func internalizeChain(exs []Extension, chain unsafe.Pointer) {
if chain == nil {
return
}
for _, ex := range exs {
ex.internalize(chain)
next := (*structHeader)(chain).Next
chain = next
}
}
type PhysicalDeviceIDProperties struct {
DeviceUUID [C.VK_UUID_SIZE]byte
DriverUUID [C.VK_UUID_SIZE]byte
DeviceLUID [C.VK_UUID_SIZE]byte
DeviceNodeMask uint32
DeviceLUIDValid bool
}
func (*PhysicalDeviceIDProperties) isExtension() {}
func (prop *PhysicalDeviceIDProperties) externalize(a *allocator) unsafe.Pointer {
cprop := alloc[C.VkPhysicalDeviceIDProperties](a)
cprop.sType = C.VkStructureType(StructureTypePhysicalDeviceIdProperties)
return unsafe.Pointer(cprop)
}
func (prop *PhysicalDeviceIDProperties) internalize(ptr unsafe.Pointer) {
cprop := (*C.VkPhysicalDeviceIDProperties)(ptr)
copy(prop.DeviceUUID[:], (*[C.VK_UUID_SIZE]byte)(unsafe.Pointer(&cprop.deviceUUID))[:])
copy(prop.DriverUUID[:], (*[C.VK_UUID_SIZE]byte)(unsafe.Pointer(&cprop.driverUUID))[:])
copy(prop.DeviceLUID[:], (*[C.VK_UUID_SIZE]byte)(unsafe.Pointer(&cprop.deviceLUID))[:])
prop.DeviceNodeMask = uint32(cprop.deviceNodeMask)
prop.DeviceLUIDValid = cprop.deviceLUIDValid == C.VK_TRUE
}