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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
|
// Copyright (c) 2017 Eric Mellino
// Copyright (c) 2019 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
using System.Runtime.InteropServices;
namespace Vulkan
{
public partial struct VkClearValue
{
public VkClearValue(float r, float g, float b)
{
depthStencil = default(VkClearDepthStencilValue);
color = new VkClearColorValue(r, g, b);
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 16)]
public struct VkClearColorValue
{
public Span<float> floats
{
get
{
Span<VkClearColorValue> valSpan = MemoryMarshal.CreateSpan(ref this, 1);
return MemoryMarshal.Cast<VkClearColorValue, float>(valSpan);
}
}
public Span<int> ints
{
get
{
Span<VkClearColorValue> valSpan = MemoryMarshal.CreateSpan(ref this, 1);
return MemoryMarshal.Cast<VkClearColorValue, int>(valSpan);
}
}
public Span<uint> uints
{
get
{
Span<VkClearColorValue> valSpan = MemoryMarshal.CreateSpan(ref this, 1);
return MemoryMarshal.Cast<VkClearColorValue, uint>(valSpan);
}
}
public VkClearColorValue(float r, float g, float b, float a = 1.0f) : this()
{
floats[0] = r;
floats[1] = g;
floats[2] = b;
floats[3] = a;
}
public VkClearColorValue(int r, int g, int b, int a = 255) : this()
{
ints[0] = r;
ints[1] = g;
ints[2] = b;
ints[3] = a;
}
public VkClearColorValue(uint r, uint g, uint b, uint a = 255) : this()
{
uints[0] = r;
uints[1] = g;
uints[2] = b;
uints[3] = a;
}
}
/// <summary>
/// Structure specifying a 3x4 row-major affine transformation matrix.
/// </summary>
[StructLayout(LayoutKind.Sequential, Size = 48)]
public struct VkTransformMatrixKHR
{
/// <summary>
/// Get row by index.
/// </summary>
/// <returns>The span of the row.</returns>
public Span<float> this[int i] => AsSpan.Slice(i * 4, 3);
/// <summary>
/// Get the whole matrix as a single span of floats.
/// </summary>
/// <value>The span of the matrix.</value>
public Span<float> AsSpan
{
get
{
Span<VkTransformMatrixKHR> valSpan = MemoryMarshal.CreateSpan(ref this, 1);
return MemoryMarshal.Cast<VkTransformMatrixKHR, float>(valSpan);
}
}
}
public partial struct VkClearDepthStencilValue
{
public VkClearDepthStencilValue(float depth, uint stencil)
{
this.depth = depth;
this.stencil = stencil;
}
}
public partial struct VkOffset3D
{
public VkOffset3D(int _x = 0, int _y = 0, int _z = 0)
{
x = _x; y = _y; z = _z;
}
}
public partial struct VkImageSubresourceLayers
{
public VkImageSubresourceLayers(VkImageAspectFlags _aspectMask = VkImageAspectFlags.Color,
uint _layerCount = 1, uint _mipLevel = 0, uint _baseArrayLayer = 0)
{
aspectMask = _aspectMask;
layerCount = _layerCount;
mipLevel = _mipLevel;
baseArrayLayer = _baseArrayLayer;
}
}
public partial struct VkImageSubresourceRange
{
public VkImageSubresourceRange(
VkImageAspectFlags aspectMask,
uint baseMipLevel = 0, uint levelCount = 1,
uint baseArrayLayer = 0, uint layerCount = 1)
{
this.aspectMask = aspectMask;
this.baseMipLevel = baseMipLevel;
this.levelCount = levelCount;
this.baseArrayLayer = baseArrayLayer;
this.layerCount = layerCount;
}
}
public partial struct VkDescriptorSetLayoutBinding
{
public VkDescriptorSetLayoutBinding(uint _binding, VkShaderStageFlags _stageFlags, VkDescriptorType _descriptorType, uint _descriptorCount = 1)
{
binding = _binding;
this._descriptorType = (int)_descriptorType;
descriptorCount = _descriptorCount;
stageFlags = _stageFlags;
pImmutableSamplers = (IntPtr)0;
}
}
public partial struct VkDescriptorSetLayoutCreateInfo
{
public VkDescriptorSetLayoutCreateInfo(VkDescriptorSetLayoutCreateFlags flags, uint bindingCount, IntPtr pBindings)
{
this._sType = (int)VkStructureType.DescriptorSetLayoutCreateInfo;
pNext = IntPtr.Zero;
this.flags = flags;
this.bindingCount = bindingCount;
this.pBindings = pBindings;
}
}
public partial struct VkVertexInputBindingDescription
{
public VkVertexInputBindingDescription(uint _binding, uint _stride, VkVertexInputRate _inputRate = VkVertexInputRate.Vertex)
{
binding = _binding;
stride = _stride;
this._inputRate = (int)_inputRate;
}
}
public partial struct VkVertexInputAttributeDescription
{
public VkVertexInputAttributeDescription(uint _binding, uint _location, VkFormat _format, uint _offset = 0)
{
location = _location;
binding = _binding;
this._format = (int)_format;
offset = _offset;
}
public VkVertexInputAttributeDescription(uint _location, VkFormat _format, uint _offset = 0)
{
location = _location;
binding = 0;
this._format = (int)_format;
offset = _offset;
}
}
public partial struct VkPipelineColorBlendAttachmentState
{
public VkPipelineColorBlendAttachmentState(VkBool32 blendEnable,
VkBlendFactor srcColorBlendFactor = VkBlendFactor.SrcAlpha,
VkBlendFactor dstColorBlendFactor = VkBlendFactor.OneMinusSrcAlpha,
VkBlendOp colorBlendOp = VkBlendOp.Add,
VkBlendFactor srcAlphaBlendFactor = VkBlendFactor.OneMinusSrcAlpha,
VkBlendFactor dstAlphaBlendFactor = VkBlendFactor.Zero,
VkBlendOp alphaBlendOp = VkBlendOp.Add,
VkColorComponentFlags colorWriteMask = VkColorComponentFlags.R | VkColorComponentFlags.G | VkColorComponentFlags.B | VkColorComponentFlags.A)
{
this.blendEnable = blendEnable;
this._srcColorBlendFactor = (int)srcColorBlendFactor;
this._dstColorBlendFactor = (int)dstColorBlendFactor;
this._colorBlendOp = (int)colorBlendOp;
this._srcAlphaBlendFactor = (int)srcAlphaBlendFactor;
this._dstAlphaBlendFactor = (int)dstAlphaBlendFactor;
this._alphaBlendOp = (int)alphaBlendOp;
this.colorWriteMask = colorWriteMask;
}
}
public partial struct VkPushConstantRange
{
public VkPushConstantRange(VkShaderStageFlags stageFlags, uint size, uint offset = 0)
{
this.stageFlags = stageFlags;
this.size = size;
this.offset = offset;
}
}
public partial struct VkCommandBufferBeginInfo
{
public VkCommandBufferBeginInfo(VkCommandBufferUsageFlags usage = (VkCommandBufferUsageFlags)0)
{
this._sType = (int)VkStructureType.CommandBufferBeginInfo;
pNext = pInheritanceInfo = IntPtr.Zero;
flags = usage;
}
}
public partial struct VkQueryPoolCreateInfo
{
public static VkQueryPoolCreateInfo New(VkQueryType queryType,
VkQueryPipelineStatisticFlags statisticFlags = (VkQueryPipelineStatisticFlags)0, uint count = 1)
{
VkQueryPoolCreateInfo ret = new VkQueryPoolCreateInfo();
ret.sType = VkStructureType.QueryPoolCreateInfo;
ret.pipelineStatistics = statisticFlags;
ret.queryType = queryType;
ret.queryCount = count;
return ret;
}
}
public partial struct VkDebugMarkerObjectNameInfoEXT
{
public VkDebugMarkerObjectNameInfoEXT(VkDebugReportObjectTypeEXT objectType, ulong handle)
{
this._sType = (int)VkStructureType.DebugMarkerObjectNameInfoEXT;
pNext = IntPtr.Zero;
this._objectType = (int)objectType;
_object = handle;
pObjectName = IntPtr.Zero;
}
}
public partial struct VkDebugUtilsObjectNameInfoEXT
{
public VkDebugUtilsObjectNameInfoEXT(VkObjectType objectType, ulong handle)
{
this._sType = (int)VkStructureType.DebugUtilsObjectNameInfoEXT;
pNext = IntPtr.Zero;
this._objectType = (int)objectType;
objectHandle = handle;
pObjectName = IntPtr.Zero;
}
}
public partial struct VkDescriptorPoolSize
{
public VkDescriptorPoolSize(VkDescriptorType descriptorType, uint count = 1)
{
this._type = (int)descriptorType;
descriptorCount = count;
}
}
public unsafe partial struct VkAttachmentReference
{
public VkAttachmentReference(uint attachment, VkImageLayout layout)
{
this.attachment = attachment;
this._layout = (int)layout;
}
}
}
|