This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
command_barrier.go
104 lines (85 loc) · 3.49 KB
/
command_barrier.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
package core1_0
/*
#include <stdlib.h>
#include "vulkan/vulkan.h"
*/
import "C"
import (
"github.com/CannibalVox/VKng/core/common"
"github.com/CannibalVox/cgoparam"
"unsafe"
)
type MemoryBarrier struct {
SrcAccessMask AccessFlags
DstAccessMask AccessFlags
common.NextOptions
}
func (o MemoryBarrier) PopulateCPointer(allocator *cgoparam.Allocator, preallocatedPointer unsafe.Pointer, next unsafe.Pointer) (unsafe.Pointer, error) {
if preallocatedPointer == unsafe.Pointer(nil) {
preallocatedPointer = allocator.Malloc(C.sizeof_struct_VkMemoryBarrier)
}
createInfo := (*C.VkMemoryBarrier)(preallocatedPointer)
createInfo.sType = C.VK_STRUCTURE_TYPE_MEMORY_BARRIER
createInfo.pNext = next
createInfo.srcAccessMask = C.VkAccessFlags(o.SrcAccessMask)
createInfo.dstAccessMask = C.VkAccessFlags(o.DstAccessMask)
return preallocatedPointer, nil
}
type BufferMemoryBarrier struct {
SrcAccessMask AccessFlags
DstAccessMask AccessFlags
SrcQueueFamilyIndex int
DstQueueFamilyIndex int
Buffer Buffer
Offset int
Size int
common.NextOptions
}
func (o BufferMemoryBarrier) PopulateCPointer(allocator *cgoparam.Allocator, preallocatedPointer unsafe.Pointer, next unsafe.Pointer) (unsafe.Pointer, error) {
if preallocatedPointer == unsafe.Pointer(nil) {
preallocatedPointer = allocator.Malloc(C.sizeof_struct_VkBufferMemoryBarrier)
}
createInfo := (*C.VkBufferMemoryBarrier)(preallocatedPointer)
createInfo.sType = C.VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER
createInfo.pNext = next
createInfo.srcAccessMask = C.VkAccessFlags(o.SrcAccessMask)
createInfo.dstAccessMask = C.VkAccessFlags(o.DstAccessMask)
createInfo.srcQueueFamilyIndex = C.uint32_t(o.SrcQueueFamilyIndex)
createInfo.dstQueueFamilyIndex = C.uint32_t(o.DstQueueFamilyIndex)
createInfo.buffer = C.VkBuffer(unsafe.Pointer(o.Buffer.Handle()))
createInfo.offset = C.VkDeviceSize(o.Offset)
createInfo.size = C.VkDeviceSize(o.Size)
return preallocatedPointer, nil
}
type ImageMemoryBarrier struct {
SrcAccessMask AccessFlags
DstAccessMask AccessFlags
OldLayout ImageLayout
NewLayout ImageLayout
SrcQueueFamilyIndex int
DstQueueFamilyIndex int
Image Image
SubresourceRange ImageSubresourceRange
common.NextOptions
}
func (o ImageMemoryBarrier) PopulateCPointer(allocator *cgoparam.Allocator, preallocatedPointer unsafe.Pointer, next unsafe.Pointer) (unsafe.Pointer, error) {
if preallocatedPointer == unsafe.Pointer(nil) {
preallocatedPointer = allocator.Malloc(C.sizeof_struct_VkImageMemoryBarrier)
}
createInfo := (*C.VkImageMemoryBarrier)(preallocatedPointer)
createInfo.sType = C.VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER
createInfo.pNext = next
createInfo.srcAccessMask = C.VkAccessFlags(o.SrcAccessMask)
createInfo.dstAccessMask = C.VkAccessFlags(o.DstAccessMask)
createInfo.oldLayout = C.VkImageLayout(o.OldLayout)
createInfo.newLayout = C.VkImageLayout(o.NewLayout)
createInfo.srcQueueFamilyIndex = C.uint32_t(o.SrcQueueFamilyIndex)
createInfo.dstQueueFamilyIndex = C.uint32_t(o.DstQueueFamilyIndex)
createInfo.image = C.VkImage(unsafe.Pointer(o.Image.Handle()))
createInfo.subresourceRange.aspectMask = C.VkImageAspectFlags(o.SubresourceRange.AspectMask)
createInfo.subresourceRange.baseMipLevel = C.uint32_t(o.SubresourceRange.BaseMipLevel)
createInfo.subresourceRange.levelCount = C.uint32_t(o.SubresourceRange.LevelCount)
createInfo.subresourceRange.baseArrayLayer = C.uint32_t(o.SubresourceRange.BaseArrayLayer)
createInfo.subresourceRange.layerCount = C.uint32_t(o.SubresourceRange.LayerCount)
return preallocatedPointer, nil
}