├── .gitignore
├── .gitmodules
├── Package.resolved
├── Package.swift
├── README.md
├── Sources
├── Generator
│ ├── EnumGenerator.swift
│ ├── FlagsGenerator.swift
│ ├── Mapping.swift
│ ├── Registry.swift
│ ├── Resources
│ │ └── vk.xml
│ ├── StructGenerator.swift
│ ├── SwiftKeywordEscaping.swift
│ ├── Utils.swift
│ └── main.swift
└── Vulkan
│ ├── BeginInfo
│ ├── CommandBufferBeginInfo.swift
│ └── _oldRenderPassBeginInfo.swift
│ ├── Buffer.swift
│ ├── BufferView.swift
│ ├── CommandBuffer.swift
│ ├── CommandPool.swift
│ ├── CreateInfo
│ ├── FenceCreateInfo.swift
│ ├── ShaderModuleCreateInfo.swift
│ ├── _oldPipelineColorBlendStateCreateInfo.swift
│ ├── _oldPipelineDynamicStateCreateInfo.swift
│ ├── _oldPipelineInputAssemblyStateCreateInfo.swift
│ ├── _oldPipelineMultisampleStateCreateInfo.swift
│ ├── _oldPipelineRasterizationStateCreateInfo.swift
│ ├── _oldPipelineShaderStageCreateInfo.swift
│ ├── _oldPipelineVertexInputStateCreateInfo.swift
│ ├── _oldPipelineViewportStateCreateInfo.swift
│ └── _old_GraphicsPipelineCreateInfo.swift
│ ├── Debugging.swift
│ ├── DescriptorPool.swift
│ ├── DescriptorSet.swift
│ ├── DescriptorSetLayout.swift
│ ├── Device.swift
│ ├── DeviceMemory.swift
│ ├── Enumerations.swift
│ ├── Enums
│ ├── BlendFactor.swift
│ ├── ColorComponentFlag.swift
│ ├── CullMode.swift
│ ├── Format.swift
│ ├── FrontFace.swift
│ ├── LogicOp.swift
│ ├── PipelineBindPoint.swift
│ ├── PolygonMode.swift
│ ├── SampleCount.swift
│ ├── SubpassContents.swift
│ ├── VertexInputRate.swift
│ └── _oldDynamicState.swift
│ ├── Event.swift
│ ├── Extensions.swift
│ ├── Extensions
│ ├── Bool+Conversion.swift
│ ├── DeviceSize+Conversion.swift
│ ├── Float+Conversion.swift
│ ├── Int+Conversion.swift
│ ├── Int32+Conversion.swift
│ ├── String+Conversion.swift
│ ├── UInt32+Conversion.swift
│ └── UInt64+WrapperStruct.swift
│ ├── Fence.swift
│ ├── Framebuffer.swift
│ ├── Generated
│ ├── AccelerationStructureBuildGeometryInfoKHR.swift
│ ├── AccelerationStructureBuildRangeInfoKHR.swift
│ ├── AccelerationStructureBuildSizesInfoKHR.swift
│ ├── AccelerationStructureBuildTypeKHR.swift
│ ├── AccelerationStructureCreateFlagsKHR.swift
│ ├── AccelerationStructureDeviceAddressInfoKHR.swift
│ ├── AccelerationStructureGeometryAabbsDataKHR.swift
│ ├── AccelerationStructureGeometryInstancesDataKHR.swift
│ ├── AccelerationStructureGeometryKHR.swift
│ ├── AccelerationStructureGeometryTrianglesDataKHR.swift
│ ├── AccelerationStructureInstanceKHR.swift
│ ├── AccelerationStructureTypeKHR.swift
│ ├── AccessFlags.swift
│ ├── ApplicationInfo.swift
│ ├── BlendOp.swift
│ ├── BorderColor.swift
│ ├── BufferCopy.swift
│ ├── BufferDeviceAddressInfo.swift
│ ├── BufferImageCopy.swift
│ ├── BufferMemoryBarrier.swift
│ ├── BuildAccelerationStructureFlagsKHR.swift
│ ├── BuildAccelerationStructureModeKHR.swift
│ ├── ColorComponentFlags.swift
│ ├── CompareOp.swift
│ ├── ComponentMapping.swift
│ ├── CullModeFlags.swift
│ ├── DescriptorBufferInfo.swift
│ ├── DescriptorImageInfo.swift
│ ├── DescriptorPoolCreateInfo.swift
│ ├── DescriptorPoolSize.swift
│ ├── DescriptorSetAllocateInfo.swift
│ ├── DescriptorSetLayoutBinding.swift
│ ├── DescriptorSetLayoutCreateInfo.swift
│ ├── DynamicState.swift
│ ├── EventCreateFlags.swift
│ ├── EventCreateInfo.swift
│ ├── Filter.swift
│ ├── FramebufferCreateInfo.swift
│ ├── GeometryFlagsKHR.swift
│ ├── GeometryInstanceFlagsKHR.swift
│ ├── GeometryTypeKHR.swift
│ ├── GraphicsPipelineCreateInfo.swift
│ ├── ImageAspectFlags.swift
│ ├── ImageMemoryBarrier.swift
│ ├── ImageSubresourceLayers.swift
│ ├── ImageSubresourceRange.swift
│ ├── ImageUsageFlags.swift
│ ├── ImageViewCreateFlags.swift
│ ├── ImageViewCreateInfo.swift
│ ├── IndexType.swift
│ ├── MemoryBarrier.swift
│ ├── Offset3D.swift
│ ├── PhysicalDeviceLimits.swift
│ ├── PhysicalDeviceProperties.swift
│ ├── PhysicalDeviceSparseProperties.swift
│ ├── PhysicalDeviceType.swift
│ ├── PipelineColorBlendAttachmentState.swift
│ ├── PipelineColorBlendStateCreateFlags.swift
│ ├── PipelineColorBlendStateCreateInfo.swift
│ ├── PipelineCreateFlags.swift
│ ├── PipelineDepthStencilStateCreateFlags.swift
│ ├── PipelineDepthStencilStateCreateInfo.swift
│ ├── PipelineDynamicStateCreateFlags.swift
│ ├── PipelineDynamicStateCreateInfo.swift
│ ├── PipelineInputAssemblyStateCreateFlags.swift
│ ├── PipelineInputAssemblyStateCreateInfo.swift
│ ├── PipelineLayoutCreateFlags.swift
│ ├── PipelineLayoutCreateInfo.swift
│ ├── PipelineMultisampleStateCreateFlags.swift
│ ├── PipelineMultisampleStateCreateInfo.swift
│ ├── PipelineRasterizationStateCreateFlags.swift
│ ├── PipelineRasterizationStateCreateInfo.swift
│ ├── PipelineShaderStageCreateFlags.swift
│ ├── PipelineShaderStageCreateInfo.swift
│ ├── PipelineTessellationStateCreateFlags.swift
│ ├── PipelineTessellationStateCreateInfo.swift
│ ├── PipelineVertexInputStateCreateFlags.swift
│ ├── PipelineVertexInputStateCreateInfo.swift
│ ├── PipelineViewportStateCreateFlags.swift
│ ├── PipelineViewportStateCreateInfo.swift
│ ├── PrimitiveTopology.swift
│ ├── PushConstantRange.swift
│ ├── Rect2D.swift
│ ├── SampleCountFlags.swift
│ ├── SamplerAddressMode.swift
│ ├── SamplerCreateFlags.swift
│ ├── SamplerCreateInfo.swift
│ ├── SamplerMipmapMode.swift
│ ├── ShaderStageFlags.swift
│ ├── SpecializationMapEntry.swift
│ ├── StencilOp.swift
│ ├── StencilOpState.swift
│ ├── VertexInputAttributeDescription.swift
│ ├── VertexInputBindingDescription.swift
│ ├── Viewport.swift
│ ├── WriteDescriptorSet.swift
│ └── WriteDescriptorSetAccelerationStructureKHR.swift
│ ├── Helpers
│ ├── Array+VulkanEnumTypeWrapper.swift
│ ├── Array+VulkanHandleTypeWrapper.swift
│ ├── Array+VulkanTypeWrapper.swift
│ ├── Array+WrapperStruct.swift
│ ├── HandleObjectWrapper.swift
│ ├── VkResult+WrapperStruct.swift
│ ├── VulkanEnumTypeWrapper.swift
│ ├── VulkanHandleTypeWrapper.swift
│ ├── VulkanTypeWrapper.swift
│ ├── WrapperFlag.swift
│ └── WrapperStruct.swift
│ ├── Image.swift
│ ├── ImageView.swift
│ ├── Instance.swift
│ ├── Manual
│ ├── AccelerationStructureGeometryDataKHR.swift
│ ├── ClearValue.swift
│ ├── ComponentMapping+identity.swift
│ ├── DeviceAddress.swift
│ ├── DeviceOrHostAddressConstKHR.swift
│ ├── DeviceOrHostAddressKHR.swift
│ ├── Flags
│ │ ├── BufferUsageFlags.swift
│ │ └── ShaderStageFlags+Raytracing.swift
│ ├── HandleTypes
│ │ └── AccelerationStructureKHR.swift
│ ├── RenderPassBeginInfo.swift
│ ├── SizeT.swift
│ ├── SpecializationInfo.swift
│ ├── StencilOpState+DontCare.swift
│ └── StructTypes
│ │ ├── AccelerationStructureCreateInfoKHR.swift
│ │ └── TransformMatrixKHR.swift
│ ├── Other
│ ├── AttachmentDescription.swift
│ ├── AttachmentReference.swift
│ ├── DescriptorSetLayoutCreateFlags.swift
│ ├── Extent2D.swift
│ ├── FramebufferCreateFlags.swift
│ ├── Offset2D.swift
│ ├── PresentInfoKHR.swift
│ ├── Result.swift
│ ├── SampleMask.swift
│ ├── SubmitInfo.swift
│ ├── SubpassDependency.swift
│ ├── SubpassDescription.swift
│ ├── _oldPipelineColorBlendAttachmentState.swift
│ └── _oldViewport.swift
│ ├── PhysicalDevice.swift
│ ├── Pipeline.swift
│ ├── PipelineLayout.swift
│ ├── Queue.swift
│ ├── RenderPass.swift
│ ├── Sampler.swift
│ ├── Semaphore.swift
│ ├── ShaderModule.swift
│ ├── Structures.swift
│ ├── SurfaceKHR.swift
│ ├── Swapchain.swift
│ └── Utils.swift
└── demo.png
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /.build
3 | /Packages
4 | /*.xcodeproj
5 | xcuserdata/
6 | .vscode
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "skia"]
2 | path = skia
3 | url = git@github.com:google/skia.git
4 |
--------------------------------------------------------------------------------
/Package.resolved:
--------------------------------------------------------------------------------
1 | {
2 | "object": {
3 | "pins": [
4 | {
5 | "package": "CVulkan",
6 | "repositoryURL": "https://github.com/UnGast/CVulkan.git",
7 | "state": {
8 | "branch": "master",
9 | "revision": "b9c2763af6281cc5949483cf9abff35f35f5d2aa",
10 | "version": null
11 | }
12 | },
13 | {
14 | "package": "Regex",
15 | "repositoryURL": "https://github.com/sharplet/Regex.git",
16 | "state": {
17 | "branch": null,
18 | "revision": "76c2b73d4281d77fc3118391877efd1bf972f515",
19 | "version": "2.1.1"
20 | }
21 | },
22 | {
23 | "package": "swift-argument-parser",
24 | "repositoryURL": "https://github.com/apple/swift-argument-parser",
25 | "state": {
26 | "branch": null,
27 | "revision": "831ed5e860a70e745bc1337830af4786b2576881",
28 | "version": "0.4.1"
29 | }
30 | },
31 | {
32 | "package": "SwiftyXMLParser",
33 | "repositoryURL": "https://github.com/yahoojapan/SwiftyXMLParser.git",
34 | "state": {
35 | "branch": "master",
36 | "revision": "ec7f183642adf429babd867d1a38c5c6912408ba",
37 | "version": null
38 | }
39 | }
40 | ]
41 | },
42 | "version": 1
43 | }
44 |
--------------------------------------------------------------------------------
/Package.swift:
--------------------------------------------------------------------------------
1 | // swift-tools-version:5.3
2 | import PackageDescription
3 |
4 | let package = Package(
5 | name: "Vulkan",
6 | products: [
7 | .library(name: "Vulkan", targets: ["Vulkan"]),
8 | .executable(
9 | name: "Generator",
10 | targets: ["Generator"]
11 | )
12 | ],
13 | dependencies: [
14 | .package(url: "https://github.com/UnGast/CVulkan.git", .branch("master")),
15 | .package(url: "https://github.com/yahoojapan/SwiftyXMLParser.git", .branch("master")),
16 | .package(url: "https://github.com/sharplet/Regex.git", from: "2.1.0"),
17 | .package(url: "https://github.com/apple/swift-argument-parser", from: "0.4.0"),
18 | ],
19 | targets: [
20 | .target(
21 | name: "Generator",
22 | dependencies: ["SwiftyXMLParser", "Regex", .product(name: "ArgumentParser", package: "swift-argument-parser")],
23 | resources: [.process("Resources/vk.xml")]),
24 | .target(name: "Vulkan", dependencies: ["CVulkan"])
25 | ]
26 | )
27 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Not maintained anymore
2 |
3 | The approach used in these bindings generates lots of compiler warnings, because of the way pointers to Vulkan API structs are generated under the hood.
4 |
5 | In future projects I will use the pure Vulkan API. It works well enough with Swift's C interop. Currently it's not worth the effort for me to work on these bindings.
6 |
7 |
8 |
9 | # Vulkan + Swift
10 |
11 | This library contains Swift bindings for Vulkan that are largely generated.
12 |
13 | You can find a demo application here: [SwiftVulkanDemo](https://github.com/UnGast/SwiftVulkanDemo).
14 |
15 |
16 |
17 |
18 |
19 | There are still some types and functions for which there is no binding. I'm adding as I need them for my projects.
20 |
21 |
22 |
23 | Documentation will be written later. If you have question or problems just open an issue.
24 |
25 |
26 |
27 | The general approach and a good amount of bindings have been taken from: [alexanderuv/vulkanSwift](https://github.com/alexanderuv/vulkanSwift).
28 |
29 |
30 |
31 |
32 | # List of things that could cause bugs / lead to confusion
33 |
34 | - uint32_t type fields that are marked as optional will get a value of 0 if not specified
35 | - this could overwrite the default value of the specification (if there is any)
36 | - but something like this is necessary because some fields are marked as optional, but they are not recognized as optional when imported into swift
37 | - example: DescriptorSetLayoutBinding.descriptorCount
38 | - DeviceMemory.free calls DeviceMemory.destroy which calls vkFreeMemory
39 | - there is no vkDestroyMemory, but the base class for the wrappers requires a destroy function to call when it is deinitialized
40 | - there are no VK_API_VERSION_X_X constants, because they are implemented as macros which are not available in swift; use vkMakeApiVersion(x, x, x) instead
--------------------------------------------------------------------------------
/Sources/Generator/EnumGenerator.swift:
--------------------------------------------------------------------------------
1 | import Regex
2 | import SwiftyXMLParser
3 |
4 | public class EnumGenerator {
5 | private let xml: XML.Accessor
6 | private var rawTypeName: String = ""
7 | private var mappedTypeName: String = ""
8 | private var cases: [String] = []
9 |
10 | public init(fromXml xml: XML.Accessor) {
11 | self.xml = xml
12 | }
13 |
14 | public func generate() -> (String, String) {
15 | rawTypeName = xml.attributes["name"]!
16 | mappedTypeName = mapTypeNameToSwift(rawTypeName)
17 |
18 | extractCases()
19 |
20 | let typeDefinition = generateTypeDefinition()
21 |
22 | return (mappedTypeName, typeDefinition)
23 | }
24 |
25 | private func extractCases() {
26 | var caseNameBase = rawTypeName.camelCaseToSnakeCase()
27 |
28 | for enumCase in xml.enum {
29 | guard let rawName = enumCase.attributes["name"] else {
30 | continue
31 | }
32 | guard let value = enumCase.attributes["value"] else {
33 | continue
34 | }
35 | var mappedName = rawName.replacingOccurrences(of: caseNameBase, with: "").snakeCaseToCamelCase()
36 | mappedName = escapeIfSwiftKeyword(mappedName)
37 | cases.append("\(mappedName) = \(value)")
38 | }
39 | }
40 |
41 | private func generateTypeDefinition() -> String {
42 | """
43 | import CVulkan
44 |
45 | public enum \(mappedTypeName): UInt32, VulkanEnumTypeWrapper {
46 | case \(cases.joined(separator: ",\n"))
47 |
48 | public init(fromVulkan: \(rawTypeName)) {
49 | self.init(rawValue: fromVulkan.rawValue)!
50 | }
51 |
52 | public var vulkan: \(rawTypeName) {
53 | \(rawTypeName)(rawValue)
54 | }
55 | }
56 | """
57 | }
58 | }
--------------------------------------------------------------------------------
/Sources/Generator/Registry.swift:
--------------------------------------------------------------------------------
1 | import SwiftyXMLParser
2 |
3 | public class Registry {
4 | public var constants: [String: String] = [:]
5 |
6 | public var types: [String: XML.Accessor] = [:]
7 |
8 | public init(fromXml xml: XML.Accessor) {
9 | for type in xml.types.type {
10 | if let name = type.attributes["name"] ?? type["name"].text {
11 | types[name] = type
12 | }
13 | }
14 | for enumType in xml.enums {
15 | if let name = enumType.attributes["name"] {
16 | if name == "API Constants" {
17 | print("GOT API CONSTANTS")
18 | for constant in enumType.enum {
19 | if let constantName = constant.attributes["name"], let constantValue = constant.attributes["value"] {
20 | print("CONSTANT", constantName, constantValue)
21 | constants[constantName] = constantValue
22 | }
23 | }
24 | } else {
25 | types[name] = enumType
26 | }
27 | }
28 | }
29 | }
30 |
31 | public func isStruct(typeName: String) -> Bool {
32 | if let xml = types[typeName] {
33 | return xml.attributes["category"] == "struct"
34 | }
35 | return false
36 | }
37 |
38 | public func isHandle(typeName: String) -> Bool {
39 | if let xml = types[typeName] {
40 | return xml.attributes["category"] == "handle"
41 | }
42 | return false
43 | }
44 |
45 | public func isBitmask(typeName: String) -> Bool {
46 | if let xml = types[typeName] {
47 | return xml.attributes["category"] == "bitmask"
48 | }
49 | return false
50 | }
51 | }
--------------------------------------------------------------------------------
/Sources/Generator/SwiftKeywordEscaping.swift:
--------------------------------------------------------------------------------
1 | private var swiftKeywords = [
2 | "repeat"
3 | ]
4 |
5 | func escapeIfSwiftKeyword(_ name: String) -> String {
6 | if swiftKeywords.contains(name) {
7 | return "`\(name)`"
8 | }
9 | return name
10 | }
--------------------------------------------------------------------------------
/Sources/Generator/Utils.swift:
--------------------------------------------------------------------------------
1 | extension String {
2 | public func snakeCaseToCamelCase() -> String {
3 | var camel = ""
4 |
5 | for (index, part) in self.split(separator: "_").enumerated() {
6 | if index == 0 {
7 | camel += part.lowercased()
8 | } else {
9 | camel += String(part.first!) + String(part.dropFirst()).lowercased()
10 | }
11 | }
12 |
13 | return camel
14 | }
15 |
16 | public func camelCaseToSnakeCase() -> String {
17 | var snake = ""
18 |
19 | for character in self {
20 | if character.isLetter && character.isUppercase {
21 | snake += "_" + String(character)
22 | } else {
23 | snake += character.uppercased()
24 | }
25 | }
26 | snake.removeFirst()
27 |
28 | return snake
29 | }
30 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/BeginInfo/CommandBufferBeginInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct CommandBufferBeginInfo: WrapperStruct {
4 | public var flags: Flags
5 | public var inheritanceInfo: Void?
6 |
7 | public init(flags: Flags, inheritanceInfo: Void?) {
8 | self.flags = flags
9 | self.inheritanceInfo = inheritanceInfo
10 | }
11 |
12 | public var vulkan: VkCommandBufferBeginInfo {
13 | VkCommandBufferBeginInfo(
14 | sType: VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
15 | pNext: nil,
16 | flags: flags.rawValue,
17 | pInheritanceInfo: nil
18 | )
19 | }
20 |
21 | public struct Flags: OptionSet {
22 | public var rawValue: UInt32
23 |
24 | public init(rawValue: UInt32) {
25 | self.rawValue = rawValue
26 | }
27 |
28 | public static let oneTimeSubmit = Flags(rawValue: 0x00000001)
29 | public static let renderPassContinue = Flags(rawValue: 0x00000002)
30 | public static let simultaneousUse = Flags(rawValue: 0x00000004)
31 | }
32 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/BeginInfo/_oldRenderPassBeginInfo.swift:
--------------------------------------------------------------------------------
1 | /*
2 | import CVulkan
3 |
4 | public struct RenderPassBeginInfo: WrapperStruct {
5 | public var renderPass: RenderPass
6 | public var framebuffer: Framebuffer
7 | public var renderArea: Rect2D
8 | public var clearValues: [AnyClearValue]
9 |
10 | public init(
11 | renderPass: RenderPass,
12 | framebuffer: Framebuffer,
13 | renderArea: Rect2D,
14 | clearValues: [AnyClearValue]
15 | ) {
16 | self.renderPass = renderPass
17 | self.framebuffer = framebuffer
18 | self.renderArea = renderArea
19 | self.clearValues = clearValues
20 | }
21 |
22 | public var vulkan: VkRenderPassBeginInfo {
23 | VkRenderPassBeginInfo(
24 | sType: VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
25 | pNext: nil,
26 | renderPass: renderPass.vulkan,
27 | framebuffer: framebuffer.pointer,
28 | renderArea: renderArea.vulkan,
29 | clearValueCount: UInt32(clearValues.count),
30 | pClearValues: clearValues.vulkanPointer
31 | )
32 | }
33 | }*/
--------------------------------------------------------------------------------
/Sources/Vulkan/BufferView.swift:
--------------------------------------------------------------------------------
1 |
2 | import CVulkan
3 |
4 | public class BufferView: VulkanHandleTypeWrapper, WrapperStruct {
5 | let pointer: VkBufferView
6 | let device: Device
7 |
8 | init(pointer: VkBufferView, device: Device) {
9 | self.pointer = pointer
10 | self.device = device
11 | }
12 |
13 | override public func destroyUnderlying() {
14 | vkDestroyBufferView(device.pointer, pointer, nil)
15 | }
16 |
17 | public var vulkan: VkBufferView? {
18 | pointer
19 | }
20 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/CommandPool.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Alexander Ubillus. All rights reserved.
3 | // Licensed under the MIT License. See LICENSE file in the project root for full license information.
4 | //
5 |
6 | import CVulkan
7 |
8 | public class CommandPoolCreateInfo {
9 | public var flags: Flags
10 | public var queueFamilyIndex: UInt32
11 |
12 | public init(flags: Flags,
13 | queueFamilyIndex: UInt32) {
14 | self.flags = flags
15 | self.queueFamilyIndex = queueFamilyIndex
16 | }
17 |
18 | public struct Flags: OptionSet {
19 | public let rawValue: UInt32
20 |
21 | public init(rawValue: UInt32) {
22 | self.rawValue = rawValue
23 | }
24 |
25 | public static let none = Flags(rawValue: 0)
26 | public static let transient = Flags(rawValue: 1 << 0)
27 | public static let resetCommandBuffer = Flags(rawValue: 1 << 1)
28 | public static let protected = Flags(rawValue: 1 << 2)
29 | }
30 |
31 | func toVulkan() -> VkCommandPoolCreateInfo {
32 | return VkCommandPoolCreateInfo(
33 | sType: VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
34 | pNext: nil,
35 | flags: self.flags.rawValue,
36 | queueFamilyIndex: self.queueFamilyIndex
37 | )
38 | }
39 | }
40 |
41 | public class CommandPool {
42 | private let device: Device
43 | public let pointer: VkCommandPool
44 |
45 | public init(device: Device, pointer: VkCommandPool) {
46 | self.device = device
47 | self.pointer = pointer
48 | }
49 |
50 | public class func create(from device: Device, info: CommandPoolCreateInfo) throws -> CommandPool {
51 | var cCommandPool = VkCommandPool(bitPattern: 0)
52 | var opResult = VK_SUCCESS
53 |
54 | withUnsafePointer(to: info.toVulkan()) {
55 | opResult = vkCreateCommandPool(device.pointer, $0, nil, &cCommandPool)
56 | }
57 |
58 | guard opResult == VK_SUCCESS else {
59 | throw opResult.toResult()
60 | }
61 |
62 | return CommandPool(
63 | device: device,
64 | pointer: cCommandPool!
65 | )
66 | }
67 |
68 | deinit {
69 | print("Destroying command pool")
70 | vkDestroyCommandPool(device.pointer, pointer, nil)
71 | }
72 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/CreateInfo/FenceCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct FenceCreateInfo: WrapperStruct {
4 | public var flags: Set
5 |
6 | public init(flags: Set) {
7 | self.flags = flags
8 | }
9 |
10 | public var vulkan: VkFenceCreateInfo {
11 | VkFenceCreateInfo(
12 | sType: VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
13 | pNext: nil,
14 | flags: flags.vulkan
15 | )
16 | }
17 |
18 | public struct Flag: WrapperFlag {
19 | public let value: UInt32
20 |
21 | public init(integerLiteral value: UInt32) {
22 | self.value = value
23 | }
24 |
25 | public static let signaled: Flag = 0x00000001
26 | }
27 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/CreateInfo/ShaderModuleCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 |
3 | public struct ShaderModuleCreateInfo {
4 | public let code: Data
5 |
6 | public init(
7 | code: Data
8 | ) {
9 | self.code = code
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Sources/Vulkan/CreateInfo/_oldPipelineColorBlendStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | /*import CVulkan
2 |
3 | public struct PipelineColorBlendStateCreateInfo: WrapperStruct {
4 | public let logicOpEnable: Bool
5 | public let logicOp: LogicOp
6 | public let attachments: [PipelineColorBlendAttachmentState]
7 | public let blendConstants: (Float, Float, Float, Float)
8 |
9 | public init(
10 | logicOpEnable: Bool,
11 | logicOp: LogicOp,
12 | attachments: [PipelineColorBlendAttachmentState],
13 | blendConstants: (Float, Float, Float, Float)
14 | ) {
15 | self.logicOpEnable = logicOpEnable
16 | self.logicOp = logicOp
17 | self.attachments = attachments
18 | self.blendConstants = blendConstants
19 | }
20 |
21 | public var vulkan: VkPipelineColorBlendStateCreateInfo {
22 | VkPipelineColorBlendStateCreateInfo(
23 | sType: VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
24 | pNext: nil,
25 | flags: 0,
26 | logicOpEnable: logicOpEnable.vulkan,
27 | logicOp: logicOp.vulkan,
28 | attachmentCount: UInt32(attachments.count),
29 | pAttachments: attachments.vulkanPointer,
30 | blendConstants: blendConstants
31 | )
32 | }
33 | }*/
--------------------------------------------------------------------------------
/Sources/Vulkan/CreateInfo/_oldPipelineDynamicStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | /*
2 | import CVulkan
3 |
4 | public struct PipelineDynamicStateCreateInfo: WrapperStruct {
5 | public let dynamicStates: [DynamicState]
6 |
7 | public init(dynamicStates: [DynamicState]) {
8 | self.dynamicStates = dynamicStates
9 | }
10 |
11 | public var vulkan: VkPipelineDynamicStateCreateInfo {
12 | VkPipelineDynamicStateCreateInfo(
13 | sType: VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
14 | pNext: nil,
15 | flags: 0,
16 | dynamicStateCount: UInt32(dynamicStates.count),
17 | pDynamicStates: dynamicStates.vulkanPointer
18 | )
19 | }
20 | }*/
--------------------------------------------------------------------------------
/Sources/Vulkan/CreateInfo/_oldPipelineInputAssemblyStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | /*
2 | import CVulkan
3 |
4 | public struct PipelineInputAssemblyStateCreateInfo: WrapperStruct {
5 | public let topology: Topology
6 | public let primitiveRestartEnable: Bool
7 |
8 | public init(topology: Topology, primitiveRestartEnable: Bool) {
9 | self.topology = topology
10 | self.primitiveRestartEnable = primitiveRestartEnable
11 | }
12 |
13 | public var vulkan: VkPipelineInputAssemblyStateCreateInfo {
14 | var info = VkPipelineInputAssemblyStateCreateInfo()
15 | info.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO
16 | info.pNext = nil
17 | info.topology = topology.vulkan
18 | info.primitiveRestartEnable = primitiveRestartEnable.vulkan
19 | return info
20 | }
21 |
22 | public enum Topology {
23 | case triangleList
24 |
25 | public var vulkan: VkPrimitiveTopology {
26 | switch self {
27 | case .triangleList:
28 | return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
29 | }
30 | }
31 | }
32 | }*/
--------------------------------------------------------------------------------
/Sources/Vulkan/CreateInfo/_oldPipelineMultisampleStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | /*
2 | import CVulkan
3 |
4 | public struct PipelineMultisampleStateCreateInfo: WrapperStruct {
5 | public let rasterizationSamples: SampleCountFlags
6 | public let sampleShadingEnable: Bool
7 | public let minSampleShading: Float
8 | public let sampleMask: SampleMask?
9 | public let alphaToCoverageEnable: Bool
10 | public let alphaToOneEnable: Bool
11 |
12 | public init(
13 | rasterizationSamples: SampleCountFlags,
14 | sampleShadingEnable: Bool,
15 | minSampleShading: Float,
16 | sampleMask: SampleMask?,
17 | alphaToCoverageEnable: Bool,
18 | alphaToOneEnable: Bool
19 | ) {
20 | self.rasterizationSamples = rasterizationSamples
21 | self.sampleShadingEnable = sampleShadingEnable
22 | self.minSampleShading = minSampleShading
23 | self.sampleMask = sampleMask
24 | self.alphaToCoverageEnable = alphaToCoverageEnable
25 | self.alphaToOneEnable = alphaToOneEnable
26 | }
27 |
28 | public var vulkan: VkPipelineMultisampleStateCreateInfo {
29 | VkPipelineMultisampleStateCreateInfo(
30 | sType: VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
31 | pNext: nil,
32 | flags: 0,
33 | rasterizationSamples: rasterizationSamples.vulkanValue,
34 | sampleShadingEnable: sampleShadingEnable.vulkan,
35 | minSampleShading: minSampleShading,
36 | pSampleMask: nil,
37 | alphaToCoverageEnable: alphaToCoverageEnable.vulkan,
38 | alphaToOneEnable: alphaToOneEnable.vulkan
39 | )
40 | }
41 | }*/
--------------------------------------------------------------------------------
/Sources/Vulkan/CreateInfo/_oldPipelineRasterizationStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | /*
2 | import CVulkan
3 |
4 | public struct PipelineRasterizationStateCreateInfo: WrapperStruct {
5 | public let depthClampEnable: Bool
6 | public let rasterizerDiscardEnable: Bool
7 | public let polygonMode: PolygonMode
8 | public let cullMode: CullMode
9 | public let frontFace: FrontFace
10 | public let depthBiasEnable: Bool
11 | public let depthBiasConstantFactor: Float
12 | public let depthBiasClamp: Float
13 | public let depthBiasSlopeFactor: Float
14 | public let lineWidth: Float
15 |
16 | public init(
17 | depthClampEnable: Bool,
18 | rasterizerDiscardEnable: Bool,
19 | polygonMode: PolygonMode,
20 | cullMode: CullMode,
21 | frontFace: FrontFace,
22 | depthBiasEnable: Bool,
23 | depthBiasConstantFactor: Float,
24 | depthBiasClamp: Float,
25 | depthBiasSlopeFactor: Float,
26 | lineWidth: Float
27 | ) {
28 | self.depthClampEnable = depthClampEnable
29 | self.rasterizerDiscardEnable = rasterizerDiscardEnable
30 | self.polygonMode = polygonMode
31 | self.cullMode = cullMode
32 | self.frontFace = frontFace
33 | self.depthBiasEnable = depthBiasEnable
34 | self.depthBiasConstantFactor = depthBiasConstantFactor
35 | self.depthBiasClamp = depthBiasClamp
36 | self.depthBiasSlopeFactor = depthBiasSlopeFactor
37 | self.lineWidth = lineWidth
38 | }
39 |
40 | public var vulkan: VkPipelineRasterizationStateCreateInfo {
41 | VkPipelineRasterizationStateCreateInfo(
42 | sType: VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
43 | pNext: nil,
44 | flags: 0,
45 | depthClampEnable: depthClampEnable.vulkan,
46 | rasterizerDiscardEnable: rasterizerDiscardEnable.vulkan,
47 | polygonMode: polygonMode.vulkan,
48 | cullMode: cullMode.vulkan,
49 | frontFace: frontFace.vulkan,
50 | depthBiasEnable: depthBiasEnable.vulkan,
51 | depthBiasConstantFactor: depthBiasConstantFactor,
52 | depthBiasClamp: depthBiasClamp,
53 | depthBiasSlopeFactor: depthBiasSlopeFactor,
54 | lineWidth: lineWidth
55 | )
56 | }
57 | }
58 | */
--------------------------------------------------------------------------------
/Sources/Vulkan/CreateInfo/_oldPipelineShaderStageCreateInfo.swift:
--------------------------------------------------------------------------------
1 | /*
2 | import CVulkan
3 |
4 | public struct PipelineShaderStageCreateInfo: WrapperStruct {
5 | public let flags: Flags
6 | public let stage: ShaderStageFlags
7 | public let module: ShaderModule
8 | public let name: String
9 | public let specializationInfo: SpecializationInfo?
10 |
11 | public init(flags: Flags,
12 | stage: ShaderStageFlags,
13 | module: ShaderModule,
14 | name: String,
15 | specializationInfo: SpecializationInfo?) {
16 | self.flags = flags
17 | self.stage = stage
18 | self.module = module
19 | self.name = name
20 | self.specializationInfo = specializationInfo
21 | }
22 |
23 | public struct Flags: OptionSet {
24 | public let rawValue: UInt32
25 |
26 | public init(rawValue: UInt32) {
27 | self.rawValue = rawValue
28 | }
29 |
30 | public static let none = Flags(rawValue: 0)
31 | }
32 |
33 | public var vulkan: VkPipelineShaderStageCreateInfo {
34 | return VkPipelineShaderStageCreateInfo(
35 | sType: VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
36 | pNext: nil,
37 | flags: flags.rawValue,
38 | stage: VkShaderStageFlagBits(stage.rawValue),
39 | module: module.pointer,
40 | pName: name.vulkan,
41 | pSpecializationInfo: nil)
42 | }
43 | }*/
--------------------------------------------------------------------------------
/Sources/Vulkan/CreateInfo/_oldPipelineVertexInputStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | /*
2 | import CVulkan
3 |
4 | public struct PipelineVertexInputStateCreateInfo: WrapperStruct {
5 | public var vertexBindingDescriptions: [VertexInputBindingDescription]?
6 | public var vertexAttributeDescriptions: [VertexInputAttributeDescription]?
7 |
8 | var vVertexBindingDescriptions: [VkVertexInputBindingDescription]? = nil
9 | var vVertexAttributeDescriptions: [VkVertexInputAttributeDescription]? = nil
10 |
11 | public init(vertexBindingDescriptions: [VertexInputBindingDescription]?, vertexAttributeDescriptions: [VertexInputAttributeDescription]?) {
12 | self.vertexBindingDescriptions = vertexBindingDescriptions
13 | self.vertexAttributeDescriptions = vertexAttributeDescriptions
14 | }
15 |
16 | public var vulkan: VkPipelineVertexInputStateCreateInfo {
17 | return VkPipelineVertexInputStateCreateInfo(
18 | sType: VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
19 | pNext: nil,
20 | flags: 0,
21 | vertexBindingDescriptionCount: UInt32(vertexBindingDescriptions?.count ?? 0),
22 | pVertexBindingDescriptions: vertexBindingDescriptions?.vulkanPointer,
23 | vertexAttributeDescriptionCount: UInt32(vertexAttributeDescriptions?.count ?? 0),
24 | pVertexAttributeDescriptions: vertexAttributeDescriptions?.vulkanPointer
25 | )
26 | }
27 |
28 | public var expVulkan: VkPipelineVertexInputStateCreateInfo {
29 | mutating get {
30 | vVertexBindingDescriptions = vertexBindingDescriptions?.vulkanArray
31 | vVertexAttributeDescriptions = vertexAttributeDescriptions?.vulkanArray
32 |
33 | return VkPipelineVertexInputStateCreateInfo(
34 | sType: VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
35 | pNext: nil,
36 | flags: 0,
37 | vertexBindingDescriptionCount: UInt32(vertexBindingDescriptions?.count ?? 0),
38 | pVertexBindingDescriptions: vVertexBindingDescriptions,
39 | vertexAttributeDescriptionCount: UInt32(vertexAttributeDescriptions?.count ?? 0),
40 | pVertexAttributeDescriptions: vVertexAttributeDescriptions
41 | )
42 | }
43 | }
44 | }*/
--------------------------------------------------------------------------------
/Sources/Vulkan/CreateInfo/_oldPipelineViewportStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | /*
2 | import CVulkan
3 |
4 | public struct PipelineViewportStateCreateInfo: WrapperStruct {
5 | public let viewports: [Viewport]
6 | public let scissors: [Rect2D]
7 |
8 | public init(viewports: [Viewport], scissors: [Rect2D]) {
9 | self.viewports = viewports
10 | self.scissors = scissors
11 | }
12 |
13 | public var vulkan: VkPipelineViewportStateCreateInfo {
14 | return VkPipelineViewportStateCreateInfo(
15 | sType: VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
16 | pNext: nil,
17 | flags: 0,
18 | viewportCount: UInt32(viewports.count),
19 | pViewports: viewports.vulkanPointer,
20 | scissorCount: UInt32(scissors.count),
21 | pScissors: scissors.vulkanPointer
22 | )
23 | }
24 | }*/
--------------------------------------------------------------------------------
/Sources/Vulkan/Debugging.swift:
--------------------------------------------------------------------------------
1 |
2 | import CVulkan
3 |
4 | func debugger(messageSeverity: VkDebugUtilsMessageSeverityFlagBitsEXT,
5 | messageType: VkDebugUtilsMessageTypeFlagsEXT,
6 | callbackData: UnsafePointer,
7 | pUserData: UnsafeRawPointer) -> UInt32 {
8 | print("You've got mail!")
9 |
10 | return 0
11 | }
12 |
13 | func enableDebugging2(createDebugUtilsMessengerEXT: PFN_vkCreateDebugUtilsMessengerEXT,
14 | instance: Instance) throws -> VkDebugUtilsMessengerEXT {
15 | let x = VkDebugUtilsMessengerCreateInfoEXT(
16 |
17 | )
18 |
19 | var result = VkDebugUtilsMessengerEXT(bitPattern: 0)
20 |
21 | var opResult = VK_SUCCESS
22 | withUnsafePointer(to: x) {
23 | opResult = createDebugUtilsMessengerEXT(instance.pointer, $0, nil, &result)
24 | }
25 |
26 | guard opResult == VK_SUCCESS else {
27 | throw opResult.toResult()
28 | }
29 |
30 | return result!
31 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/DescriptorPool.swift:
--------------------------------------------------------------------------------
1 |
2 | import CVulkan
3 |
4 | /*public class DescriptorPoolCreateInfo: WrapperStruct {
5 | public var flags: Flags
6 | public var maxSets: UInt32
7 | public let poolSizes: [DescriptorPoolSize]
8 |
9 | public init(flags: Flags,
10 | maxSets: UInt32,
11 | poolSizes: [DescriptorPoolSize]) {
12 | self.flags = flags
13 | self.maxSets = maxSets
14 | self.poolSizes = poolSizes
15 | }
16 |
17 | public var value: VkDescriptorPoolCreateInfo {
18 | VkDescriptorPoolCreateInfo(
19 | sType: VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
20 | pNext: nil,
21 | flags: createInfo.flags.rawValue,
22 | maxSets: createInfo.maxSets,
23 | poolSizeCount: UInt32(createInfo.poolSizes.count),
24 | pPoolSizes: poolSizes
25 | )
26 | }
27 |
28 | public struct Flags: OptionSet {
29 | public let rawValue: UInt32
30 |
31 | public init(rawValue: UInt32) {
32 | self.rawValue = rawValue
33 | }
34 |
35 | public static let none = Flags(rawValue: 0)
36 | public static let freeDescriptorSet = Flags(rawValue: 0x00000001)
37 | public static let updateAfterBind = Flags(rawValue: 0x00000002)
38 | }
39 | }*/
40 |
41 | public struct DescriptorPoolCreateFlags: OptionSet, WrapperStruct {
42 | public let rawValue: UInt32
43 |
44 | public init(rawValue: UInt32) {
45 | self.rawValue = rawValue
46 | }
47 |
48 | public var vulkan: UInt32 {
49 | rawValue
50 | }
51 |
52 | public static let none = Self(rawValue: 0)
53 | public static let freeDescriptorSet = Self(rawValue: 0x00000001)
54 | public static let updateAfterBind = Self(rawValue: 0x00000002)
55 | }
56 |
57 | public class DescriptorPool: VulkanHandleTypeWrapper, WrapperStruct {
58 |
59 | public let pointer: VkDescriptorPool
60 | public let device: Device
61 |
62 | init(pointer: VkDescriptorPool, device: Device) {
63 | self.pointer = pointer
64 | self.device = device
65 | }
66 |
67 | public var vulkan: VkDescriptorPool {
68 | pointer
69 | }
70 |
71 | public class func create(device: Device, createInfo: DescriptorPoolCreateInfo) throws -> DescriptorPool {
72 | var createInfo = createInfo
73 |
74 | var pool = VkDescriptorPool(bitPattern: 0)
75 |
76 | let opResult = withUnsafePointer(to: createInfo.vulkan) {
77 | return vkCreateDescriptorPool(device.pointer, $0, nil, &pool)
78 | }
79 |
80 | guard opResult == VK_SUCCESS else {
81 | throw opResult.toResult()
82 | }
83 |
84 | return DescriptorPool(pointer: pool!, device: device)
85 | }
86 |
87 | override public func destroyUnderlying() {
88 | vkDestroyDescriptorPool(device.pointer, self.pointer, nil)
89 | }
90 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/DescriptorSet.swift:
--------------------------------------------------------------------------------
1 |
2 | import CVulkan
3 |
4 | public class DescriptorSet: WrapperStruct {
5 |
6 | public let pointer: VkDescriptorSet
7 | public let device: Device
8 |
9 | init(pointer: VkDescriptorSet,
10 | device: Device) {
11 | self.pointer = pointer
12 | self.device = device
13 | }
14 |
15 | public var vulkan: VkDescriptorSet? {
16 | pointer
17 | }
18 |
19 | public class func allocate(device: Device, allocateInfo: DescriptorSetAllocateInfo) -> [DescriptorSet] {
20 | var allocateInfo = allocateInfo
21 | var pointers: [VkDescriptorSet?] = Array(repeating: nil, count: Int(allocateInfo.descriptorSetCount))
22 |
23 | vkAllocateDescriptorSets(
24 | device.pointer,
25 | [allocateInfo.vulkan],
26 | &pointers)
27 |
28 | return pointers.map {
29 | DescriptorSet(pointer: $0!, device: device)
30 | }
31 | }
32 |
33 | public class func update(
34 | device: Device,
35 | descriptorWrites: [WriteDescriptorSet]? = nil,
36 | descriptorCopies: [CopyDescriptorSet]? = nil
37 | ) {
38 | var descriptorWrites = descriptorWrites
39 |
40 | if descriptorCopies != nil {
41 | fatalError("IMPLEMENT descriptorCopies")
42 | }
43 |
44 | vkUpdateDescriptorSets(
45 | device.pointer,
46 | UInt32(descriptorWrites?.count ?? 0), descriptorWrites?.vulkanArray,
47 | 0, nil)
48 | /*UInt32(descriptorCopies?.count ?? 0), descriptorCopies?.vulkanPointer)*/
49 | }
50 |
51 | public class func free(device: Device, descriptorPool: DescriptorPool, descriptorSets: [DescriptorSet]) {
52 | vkFreeDescriptorSets(device.pointer, descriptorPool.pointer, UInt32(descriptorSets.count), descriptorSets.vulkan)
53 | }
54 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/DescriptorSetLayout.swift:
--------------------------------------------------------------------------------
1 |
2 | import CVulkan
3 |
4 | public class DescriptorSetLayout: VulkanHandleTypeWrapper, WrapperStruct {
5 | public let pointer: VkDescriptorSetLayout
6 | public let device: Device
7 |
8 | init(pointer: VkDescriptorSetLayout,
9 | device: Device) {
10 | self.pointer = pointer
11 | self.device = device
12 | }
13 |
14 | public class func create(
15 | device: Device,
16 | createInfo: DescriptorSetLayoutCreateInfo) throws -> DescriptorSetLayout {
17 | var createInfo = createInfo
18 |
19 | var layout = VkDescriptorSetLayout(bitPattern: 0)
20 | let opResult: VkResult = withUnsafePointer(to: createInfo.vulkan) {
21 | return vkCreateDescriptorSetLayout(device.pointer, $0, nil, &layout)
22 | }
23 |
24 | guard opResult == VK_SUCCESS else {
25 | throw opResult.toResult()
26 | }
27 |
28 | return DescriptorSetLayout(pointer: layout!, device: device)
29 | }
30 |
31 | public var vulkan: Optional {
32 | Optional(pointer)
33 | }
34 |
35 | override public func destroyUnderlying() {
36 | vkDestroyDescriptorSetLayout(device.pointer, self.pointer, nil)
37 | }
38 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Device.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Alexander Ubillus. All rights reserved.
3 | // Licensed under the MIT License. See LICENSE file in the project root for full license information.
4 | //
5 |
6 | import CVulkan
7 |
8 | public class Device {
9 |
10 | public let instance: Instance
11 | public let pointer: VkDevice
12 |
13 | public init(instance: Instance,
14 | pointer: VkDevice) {
15 | self.instance = instance
16 | self.pointer = pointer
17 | }
18 |
19 | public func allocateDescriptorSets(allocateInfo info: DescriptorSetAllocateInfo) throws -> DescriptorSet {
20 | var descriptor = VkDescriptorSet(bitPattern: 0)
21 |
22 | let ai = VkDescriptorSetAllocateInfo(
23 | sType: VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
24 | pNext: nil,
25 | descriptorPool: info.descriptorPool.pointer,
26 | descriptorSetCount: info.descriptorSetCount,
27 | pSetLayouts: info.setLayouts.vulkanPointer
28 | )
29 |
30 | let opResult = withUnsafePointer(to: ai) {
31 | return vkAllocateDescriptorSets(self.pointer, $0, &descriptor)
32 | }
33 |
34 | guard opResult == VK_SUCCESS else {
35 | throw opResult.toResult()
36 | }
37 |
38 | return DescriptorSet(pointer: descriptor!, device: self)
39 | }
40 |
41 | public func updateDescriptorSets(
42 | descriptorWrites: [WriteDescriptorSet]?,
43 | descriptorCopies: [CopyDescriptorSet]?
44 | ) {
45 | var descriptorWrites = descriptorWrites
46 |
47 | if descriptorCopies != nil {
48 | fatalError("IMPLEMENT descriptorCopies")
49 | }
50 |
51 | vkUpdateDescriptorSets(
52 | self.pointer,
53 | UInt32(descriptorWrites?.count ?? 0), descriptorWrites?.vulkanArray,
54 | 0, nil)
55 | /*UInt32(descriptorCopies?.count ?? 0), descriptorCopies?.vulkanPointer)*/
56 | }
57 |
58 | public func waitIdle() {
59 | vkDeviceWaitIdle(pointer)
60 | }
61 |
62 | deinit {
63 | print("Destroying device")
64 | vkDestroyDevice(pointer, nil)
65 | }
66 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/DeviceMemory.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public class DeviceMemory: VulkanHandleTypeWrapper {
4 | private let device: Device
5 | public let pointer: VkDeviceMemory
6 |
7 | init(_ pointer: VkDeviceMemory,
8 | device: Device) {
9 | self.pointer = pointer
10 | self.device = device
11 | }
12 |
13 | public class func allocateMemory(
14 | inDevice device: Device,
15 | allocInfo allocateInfo: MemoryAllocateInfo) throws -> DeviceMemory {
16 |
17 | var deviceMemory = VkDeviceMemory(bitPattern: 0)
18 | let opResult = withUnsafePointer(to: allocateInfo.vulkan) {
19 | return vkAllocateMemory(device.pointer, $0, nil, &deviceMemory)
20 | }
21 |
22 | return DeviceMemory(deviceMemory!, device: device)
23 | }
24 |
25 | public func free() {
26 | destroy()
27 | }
28 |
29 | @available(*, deprecated, message: "use mapMemory -> UnsafeMutableRawPointer")
30 | public func mapMemory(offset: DeviceSize, size: DeviceSize, flags: MemoryMapFlags, data: inout UnsafeMutableRawPointer?) throws {
31 | let opResult = withUnsafeMutablePointer(to: &data) { ptr in
32 | return vkMapMemory(device.pointer, self.pointer, offset, size, flags.vulkan, ptr)
33 | }
34 |
35 | guard opResult == VK_SUCCESS && data != nil else {
36 | throw opResult.toResult()
37 | }
38 | }
39 |
40 | public func mapMemory(offset: DeviceSize, size: DeviceSize, flags: MemoryMapFlags) throws -> UnsafeMutableRawPointer {
41 | var result: UnsafeMutableRawPointer?
42 | try mapMemory(offset: offset, size: size, flags: flags, data: &result)
43 | return result!
44 | }
45 |
46 | public func unmapMemory() {
47 | vkUnmapMemory(device.pointer, self.pointer)
48 | }
49 |
50 | public override func destroyUnderlying() {
51 | print("freeing memory: \(self)")
52 | vkFreeMemory(device.pointer, self.pointer, nil)
53 | }
54 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Enums/BlendFactor.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum BlendFactor: UInt32 {
4 | case zero = 0
5 | case one = 1
6 | case srcColor = 2
7 | case oneMinusSrcColor = 3
8 | case dstColor = 4
9 | case oneMinusDstColor = 5
10 | case srcAlpha = 6
11 | case oneMinusSrcAlpha = 7
12 | case dstAlpha = 8
13 | case oneMinusDstAlpha = 9
14 | case constantColor = 10
15 | case oneMinusConstantColor = 11
16 | case constantAlpha = 12
17 | case oneMinusConstantAlpha = 13
18 | case alphaSaturate = 14
19 | case src1Color = 15
20 | case oneMinusSrc1Color = 16
21 | case src1Alpha = 17
22 | case oneMinusSrc1Alpha = 18
23 |
24 | public var vulkan: VkBlendFactor {
25 | VkBlendFactor(rawValue: self.rawValue)
26 | }
27 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Enums/ColorComponentFlag.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum ColorComponentFlag {
4 | case r, g, b, a
5 | }
6 |
7 | extension Set where Element == ColorComponentFlag {
8 | public var vulkan: VkColorComponentFlags {
9 | var flags: VkColorComponentFlags = 0
10 | if contains(.r) {
11 | flags = flags | VK_COLOR_COMPONENT_R_BIT.rawValue
12 | }
13 | if contains(.g) {
14 | flags = flags | VK_COLOR_COMPONENT_G_BIT.rawValue
15 | }
16 | if contains(.b) {
17 | flags = flags | VK_COLOR_COMPONENT_B_BIT.rawValue
18 | }
19 | if contains(.a) {
20 | flags = flags | VK_COLOR_COMPONENT_A_BIT.rawValue
21 | }
22 | return flags
23 | }
24 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Enums/CullMode.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum CullMode {
4 | case none
5 | case front
6 | case back
7 | case frontAndBack
8 |
9 | public var vulkan: VkCullModeFlags {
10 | let bit: VkCullModeFlagBits
11 | switch self {
12 | case .none:
13 | bit = VK_CULL_MODE_NONE
14 | case .front:
15 | bit = VK_CULL_MODE_FRONT_BIT
16 | case .back:
17 | bit = VK_CULL_MODE_BACK_BIT
18 | case .frontAndBack:
19 | bit = VK_CULL_MODE_FRONT_AND_BACK
20 | }
21 |
22 | return VkCullModeFlags(bit.rawValue)
23 | }
24 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Enums/FrontFace.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum FrontFace: UInt32 {
4 | case counterClockwise = 0
5 | case clockwise = 1
6 |
7 | public var vulkan: VkFrontFace {
8 | VkFrontFace(self.rawValue)
9 | }
10 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Enums/LogicOp.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum LogicOp: UInt32 {
4 | case clear = 0
5 | case and = 1
6 | case andReverse = 2
7 | case copy = 3
8 | case andInverted = 4
9 | case noOp = 5
10 | case xor = 6
11 | case or = 7
12 | case nor = 8
13 | case equivalent = 9
14 | case invert = 10
15 | case orReverse = 11
16 | case copyInverted = 12
17 | case orInverted = 13
18 | case nand = 14
19 | case `set` = 15
20 |
21 | public var vulkan: VkLogicOp {
22 | VkLogicOp(rawValue: self.rawValue)
23 | }
24 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Enums/PipelineBindPoint.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum PipelineBindPoint: UInt32 {
4 | case graphics = 0,
5 | compute = 1,
6 | pointRayTracing = 2
7 |
8 | var vulkan: VkPipelineBindPoint {
9 | return VkPipelineBindPoint(self.rawValue)
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Enums/PolygonMode.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum PolygonMode: UInt32 {
4 | case fill = 0
5 | case line = 1
6 | case point = 2
7 | case fillRectangleNv = 1000153000
8 |
9 | public var vulkan: VkPolygonMode {
10 | VkPolygonMode(self.rawValue)
11 | }
12 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Enums/SampleCount.swift:
--------------------------------------------------------------------------------
1 | public enum SampleCount {
2 | case c1, c2, c4, c8, c16, c32, c64
3 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Enums/SubpassContents.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum SubpassContents: UInt32 {
4 | case inline = 0,
5 | secondaryCommandBuffers = 1
6 |
7 | public var vulkan: VkSubpassContents {
8 | VkSubpassContents(self.rawValue)
9 | }
10 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Enums/VertexInputRate.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum VertexInputRate: UInt32, WrapperStruct {
4 | case vertex = 0, instance = 1
5 |
6 | public var vulkan: VkVertexInputRate {
7 | VkVertexInputRate(rawValue)
8 | }
9 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Enums/_oldDynamicState.swift:
--------------------------------------------------------------------------------
1 | /*
2 | import CVulkan
3 |
4 | public enum DynamicState: UInt32, WrapperStruct {
5 | case VIEWPORT = 0,
6 | SCISSOR = 1,
7 | LINE_WIDTH = 2,
8 | DEPTH_BIAS = 3,
9 | BLEND_CONSTANTS = 4,
10 | DEPTH_BOUNDS = 5,
11 | STENCIL_COMPARE_MASK = 6,
12 | STENCIL_WRITE_MASK = 7,
13 | STENCIL_REFERENCE = 8,
14 | // Provided by VK_NV_clip_space_w_scaling
15 | VIEWPORT_W_SCALING_NV = 1000087000,
16 | // Provided by VK_EXT_discard_rectangles
17 | DISCARD_RECTANGLE_EXT = 1000099000,
18 | // Provided by VK_EXT_sample_locations
19 | SAMPLE_LOCATIONS_EXT = 1000143000,
20 | // Provided by VK_KHR_ray_tracing_pipeline
21 | RAY_TRACING_PIPELINE_STACK_SIZE_KHR = 1000347000,
22 | // Provided by VK_NV_shading_rate_image
23 | VIEWPORT_SHADING_RATE_PALETTE_NV = 1000164004,
24 | // Provided by VK_NV_shading_rate_image
25 | VIEWPORT_COARSE_SAMPLE_ORDER_NV = 1000164006,
26 | // Provided by VK_NV_scissor_exclusive
27 | EXCLUSIVE_SCISSOR_NV = 1000205001,
28 | // Provided by VK_KHR_fragment_shading_rate
29 | FRAGMENT_SHADING_RATE_KHR = 1000226000,
30 | // Provided by VK_EXT_line_rasterization
31 | LINE_STIPPLE_EXT = 1000259000,
32 | // Provided by VK_EXT_extended_dynamic_state
33 | CULL_MODE_EXT = 1000267000,
34 | // Provided by VK_EXT_extended_dynamic_state
35 | FRONT_FACE_EXT = 1000267001,
36 | // Provided by VK_EXT_extended_dynamic_state
37 | PRIMITIVE_TOPOLOGY_EXT = 1000267002,
38 | // Provided by VK_EXT_extended_dynamic_state
39 | VIEWPORT_WITH_COUNT_EXT = 1000267003,
40 | // Provided by VK_EXT_extended_dynamic_state
41 | SCISSOR_WITH_COUNT_EXT = 1000267004,
42 | // Provided by VK_EXT_extended_dynamic_state
43 | VERTEX_INPUT_BINDING_STRIDE_EXT = 1000267005,
44 | // Provided by VK_EXT_extended_dynamic_state
45 | DEPTH_TEST_ENABLE_EXT = 1000267006,
46 | // Provided by VK_EXT_extended_dynamic_state
47 | DEPTH_WRITE_ENABLE_EXT = 1000267007,
48 | // Provided by VK_EXT_extended_dynamic_state
49 | DEPTH_COMPARE_OP_EXT = 1000267008,
50 | // Provided by VK_EXT_extended_dynamic_state
51 | DEPTH_BOUNDS_TEST_ENABLE_EXT = 1000267009,
52 | // Provided by VK_EXT_extended_dynamic_state
53 | STENCIL_TEST_ENABLE_EXT = 1000267010,
54 | // Provided by VK_EXT_extended_dynamic_state
55 | STENCIL_OP_EXT = 1000267011
56 |
57 | public var vulkan: VkDynamicState {
58 | VkDynamicState(self.rawValue)
59 | }
60 | }*/
--------------------------------------------------------------------------------
/Sources/Vulkan/Event.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public class Event: VulkanHandleTypeWrapper {
4 | public let pointer: VkEvent
5 | public let device: Device
6 |
7 | init(device: Device, pointer: VkEvent) {
8 | self.pointer = pointer
9 | self.device = device
10 | }
11 |
12 | public convenience init(device: Device, createInfo: EventCreateInfo) throws {
13 | var createInfo = createInfo
14 | var pointer: VkEvent?
15 |
16 | let opResult = withUnsafePointer(to: createInfo.vulkan) {
17 | return vkCreateEvent(device.pointer, $0, nil, &pointer)
18 | }
19 |
20 | guard opResult == VK_SUCCESS else {
21 | throw opResult.toResult()
22 | }
23 |
24 | self.init(device: device, pointer: pointer!)
25 | }
26 |
27 | public var status: Result {
28 | vkGetEventStatus(device.pointer, pointer).toResult()
29 | }
30 |
31 | public override func destroyUnderlying() {
32 | vkDestroyEvent(device.pointer, pointer, nil)
33 | }
34 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Extensions.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Alexander Ubillus. All rights reserved.
3 | // Licensed under the MIT License. See LICENSE file in the project root for full license information.
4 | //
5 |
6 | import CVulkan
7 | import Foundation
8 |
9 | extension VkExtent3D {
10 | func swiftVersion() -> Extent3D {
11 | return Extent3D(
12 | width: self.width,
13 | height: self.height,
14 | depth: self.depth
15 | )
16 | }
17 | }
18 |
19 | extension String {
20 | public func asCString() -> UnsafePointer? {
21 | let nsVal = self as NSString
22 | return nsVal.cString(using: String.Encoding.utf8.rawValue)
23 | }
24 |
25 | public var vulkan: UnsafePointer? {
26 | asCString()
27 | }
28 | }
29 |
30 | extension Bool {
31 | var vulkan: VkBool32 {
32 | return self ? 1 : 0
33 | }
34 | func toUInt32() -> UInt32 {
35 | return self ? 1 : 0
36 | }
37 | }
38 |
39 | extension UInt32 {
40 | func toBool() -> Bool {
41 | return self > 0
42 | }
43 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Extensions/Bool+Conversion.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | extension Bool {
4 | public init(fromVulkan: VkBool32) {
5 | self = fromVulkan > 0
6 | }
7 |
8 | public init?(fromVulkan: VkBool32?) {
9 | if let fromVulkan = fromVulkan {
10 | self = fromVulkan > 0
11 | } else {
12 | return nil
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Extensions/DeviceSize+Conversion.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | extension DeviceSize {
4 | public init(fromVulkan: DeviceSize) {
5 | self = fromVulkan
6 | }
7 |
8 | public init?(fromVulkan: DeviceSize?) {
9 | if fromVulkan != nil {
10 | self = fromVulkan!
11 | } else {
12 | return nil
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Extensions/Float+Conversion.swift:
--------------------------------------------------------------------------------
1 | extension Float {
2 | public init(fromVulkan: Self) {
3 | self = fromVulkan
4 | }
5 |
6 | public init?(fromVulkan: Self?) {
7 | if let fromVulkan = fromVulkan {
8 | self = fromVulkan
9 | } else {
10 | return nil
11 | }
12 | }
13 |
14 | public var vulkan: Float {
15 | self
16 | }
17 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Extensions/Int+Conversion.swift:
--------------------------------------------------------------------------------
1 | extension Int {
2 | public init(fromVulkan: Self) {
3 | self = fromVulkan
4 | }
5 |
6 | public init?(fromVulkan: Self?) {
7 | if let fromVulkan = fromVulkan {
8 | self = fromVulkan
9 | } else {
10 | return nil
11 | }
12 | }
13 |
14 | public var vulkan: Int {
15 | self
16 | }
17 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Extensions/Int32+Conversion.swift:
--------------------------------------------------------------------------------
1 | extension Int32 {
2 | public init(fromVulkan: Self) {
3 | self = fromVulkan
4 | }
5 |
6 | public init?(fromVulkan: Self?) {
7 | if let fromVulkan = fromVulkan {
8 | self = fromVulkan
9 | } else {
10 | return nil
11 | }
12 | }
13 |
14 |
15 | public var vulkan: Int32 {
16 | self
17 | }
18 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Extensions/String+Conversion.swift:
--------------------------------------------------------------------------------
1 | extension String {
2 | public init(fromVulkan: UnsafePointer) {
3 | self.init(cString: fromVulkan)
4 | }
5 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Extensions/UInt32+Conversion.swift:
--------------------------------------------------------------------------------
1 | extension UInt32: WrapperStruct {
2 | public init(fromVulkan: Self) {
3 | self = fromVulkan
4 | }
5 |
6 | public init?(fromVulkan: Self?) {
7 | if let fromVulkan = fromVulkan {
8 | self = fromVulkan
9 | } else {
10 | return nil
11 | }
12 | }
13 |
14 | public var vulkan: UInt32 {
15 | self
16 | }
17 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Extensions/UInt64+WrapperStruct.swift:
--------------------------------------------------------------------------------
1 | extension UInt64: WrapperStruct {
2 | public var vulkan: UInt64 {
3 | self
4 | }
5 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Fence.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Alexander Ubillus on 2019-02-04.
3 | //
4 |
5 | import Foundation
6 | import CVulkan
7 |
8 | public class Fence: WrapperStruct {
9 | public let device: Device
10 | public let pointer: VkFence
11 |
12 | init(device: Device, pointer: VkFence) {
13 | self.device = device
14 | self.pointer = pointer
15 | }
16 |
17 | public convenience init(device: Device, createInfo: FenceCreateInfo) throws {
18 | var fencePointer = VkFence(bitPattern: 0)
19 |
20 | var opResult = VK_SUCCESS
21 | withUnsafePointer(to: createInfo.vulkan) {
22 | opResult = vkCreateFence(device.pointer, $0, nil, &fencePointer)
23 | }
24 |
25 | if opResult == VK_SUCCESS {
26 | self.init(device: device, pointer: fencePointer!)
27 | return
28 | }
29 |
30 | throw opResult.toResult()
31 | }
32 |
33 | public var status: Result {
34 | vkGetFenceStatus(device.pointer, pointer).toResult()
35 | }
36 |
37 | public var vulkan: Optional {
38 | Optional(pointer)
39 | }
40 |
41 | public func wait(timeout: UInt64) {
42 | Fence.wait(for: [self], waitAll: true, timeout: timeout)
43 | }
44 |
45 | public static func wait(for fences: [Fence], waitAll: Bool, timeout: UInt64) {
46 | vkWaitForFences(fences[0].device.pointer, UInt32(fences.count), fences.vulkanPointer, waitAll.vulkan, timeout)
47 | }
48 |
49 | public func reset() {
50 | Fence.reset(fences: [self])
51 | }
52 |
53 | public static func reset(fences: [Fence]) {
54 | vkResetFences(fences[0].device.pointer, UInt32(fences.count), fences.vulkanPointer)
55 | }
56 |
57 | deinit {
58 | vkDestroyFence(device.pointer, pointer, nil)
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Framebuffer.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public class Framebuffer: VulkanHandleTypeWrapper {
4 |
5 | public let pointer: VkFramebuffer
6 | public let device: Device
7 |
8 | init(rawFramebuffer: VkFramebuffer, device: Device) {
9 | self.pointer = rawFramebuffer
10 | self.device = device
11 | }
12 |
13 | public convenience init(device: Device, createInfo: FramebufferCreateInfo) throws {
14 | var createInfo = createInfo
15 |
16 | var rawFramebuffer = VkFramebuffer(bitPattern: 0)
17 |
18 | var opResult = VK_ERROR_INITIALIZATION_FAILED
19 | withUnsafePointer(to: createInfo.vulkan) {
20 | opResult = vkCreateFramebuffer(device.pointer, $0, nil, &rawFramebuffer)
21 | }
22 |
23 | if opResult == VK_SUCCESS {
24 | self.init(rawFramebuffer: rawFramebuffer!, device: device)
25 | return
26 | }
27 |
28 | throw opResult.toResult()
29 | }
30 |
31 | public var vulkan: Optional {
32 | pointer
33 | }
34 |
35 | override public func destroyUnderlying() {
36 | vkDestroyFramebuffer(device.pointer, self.pointer, nil)
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/AccelerationStructureBuildGeometryInfoKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct AccelerationStructureBuildGeometryInfoKHR: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var type: AccelerationStructureTypeKHR
6 | public var flags: BuildAccelerationStructureFlagsKHR?
7 | public var mode: BuildAccelerationStructureModeKHR
8 | public var srcAccelerationStructure: AccelerationStructureKHR?
9 | public var dstAccelerationStructure: AccelerationStructureKHR?
10 | public var geometryCount: UInt32?
11 | public var geometries: [AccelerationStructureGeometryKHR]?
12 | public var scratchData: DeviceOrHostAddressKHR
13 |
14 | var vNext: [Any]? = nil
15 | var vGeometries: [VkAccelerationStructureGeometryKHR]? = nil
16 |
17 | public init(
18 | next: Any? = nil,
19 | type: AccelerationStructureTypeKHR,
20 | flags: BuildAccelerationStructureFlagsKHR? = nil,
21 | mode: BuildAccelerationStructureModeKHR,
22 | srcAccelerationStructure: AccelerationStructureKHR? = nil,
23 | dstAccelerationStructure: AccelerationStructureKHR? = nil,
24 | geometryCount: UInt32? = nil,
25 | geometries: [AccelerationStructureGeometryKHR]? = nil,
26 | scratchData: DeviceOrHostAddressKHR
27 | ) {
28 | self.next = next
29 | self.type = type
30 | self.flags = flags
31 | self.mode = mode
32 | self.srcAccelerationStructure = srcAccelerationStructure
33 | self.dstAccelerationStructure = dstAccelerationStructure
34 | self.geometryCount = geometryCount
35 | self.geometries = geometries
36 | self.scratchData = scratchData
37 | }
38 |
39 | public var vulkan: VkAccelerationStructureBuildGeometryInfoKHR {
40 | mutating get {
41 | vNext = next == nil ? nil : [next!]
42 | vGeometries = geometries?.vulkanArray
43 | return VkAccelerationStructureBuildGeometryInfoKHR(
44 | sType: VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR,
45 | pNext: vNext,
46 | type: type.vulkan,
47 | flags: flags?.vulkan ?? 0,
48 | mode: mode.vulkan,
49 | srcAccelerationStructure: srcAccelerationStructure?.vulkan,
50 | dstAccelerationStructure: dstAccelerationStructure?.vulkan,
51 | geometryCount: geometryCount?.vulkan ?? 0,
52 | pGeometries: vGeometries,
53 | ppGeometries: nil,
54 | scratchData: scratchData.vulkan
55 | )
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/AccelerationStructureBuildRangeInfoKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct AccelerationStructureBuildRangeInfoKHR: VulkanTypeWrapper {
4 | public var primitiveCount: UInt32
5 | public var primitiveOffset: UInt32
6 | public var firstVertex: UInt32
7 | public var transformOffset: UInt32
8 |
9 |
10 |
11 | public init(
12 | primitiveCount: UInt32,
13 | primitiveOffset: UInt32,
14 | firstVertex: UInt32,
15 | transformOffset: UInt32
16 | ) {
17 | self.primitiveCount = primitiveCount
18 | self.primitiveOffset = primitiveOffset
19 | self.firstVertex = firstVertex
20 | self.transformOffset = transformOffset
21 | }
22 |
23 | public var vulkan: VkAccelerationStructureBuildRangeInfoKHR {
24 | mutating get {
25 |
26 | return VkAccelerationStructureBuildRangeInfoKHR(
27 | primitiveCount: primitiveCount.vulkan,
28 | primitiveOffset: primitiveOffset.vulkan,
29 | firstVertex: firstVertex.vulkan,
30 | transformOffset: transformOffset.vulkan
31 | )
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/AccelerationStructureBuildSizesInfoKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct AccelerationStructureBuildSizesInfoKHR: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var accelerationStructureSize: DeviceSize
6 | public var updateScratchSize: DeviceSize
7 | public var buildScratchSize: DeviceSize
8 |
9 | var vNext: [Any]? = nil
10 |
11 | public init(
12 | next: Any? = nil,
13 | accelerationStructureSize: DeviceSize,
14 | updateScratchSize: DeviceSize,
15 | buildScratchSize: DeviceSize
16 | ) {
17 | self.next = next
18 | self.accelerationStructureSize = accelerationStructureSize
19 | self.updateScratchSize = updateScratchSize
20 | self.buildScratchSize = buildScratchSize
21 | }
22 |
23 | public var vulkan: VkAccelerationStructureBuildSizesInfoKHR {
24 | mutating get {
25 | vNext = next == nil ? nil : [next!]
26 | return VkAccelerationStructureBuildSizesInfoKHR(
27 | sType: VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR,
28 | pNext: vNext,
29 | accelerationStructureSize: accelerationStructureSize.vulkan,
30 | updateScratchSize: updateScratchSize.vulkan,
31 | buildScratchSize: buildScratchSize.vulkan
32 | )
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/AccelerationStructureBuildTypeKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum AccelerationStructureBuildTypeKHR: UInt32, VulkanEnumTypeWrapper {
4 | case vkAccelerationStructureBuildTypeHostKhr = 0,
5 | vkAccelerationStructureBuildTypeDeviceKhr = 1,
6 | vkAccelerationStructureBuildTypeHostOrDeviceKhr = 2
7 |
8 | public init(fromVulkan: VkAccelerationStructureBuildTypeKHR) {
9 | self.init(rawValue: fromVulkan.rawValue)!
10 | }
11 |
12 | public var vulkan: VkAccelerationStructureBuildTypeKHR {
13 | VkAccelerationStructureBuildTypeKHR(rawValue)
14 | }
15 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/AccelerationStructureCreateFlagsKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct AccelerationStructureCreateFlagsKHR: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkAccelerationStructureCreateFlagsKHR {
7 | VkAccelerationStructureCreateFlagsKHR(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkAccelerationStructureCreateFlagsKHR) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkAccelerationStructureCreateFlagsKHR?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 | public static let vkAccelerationStructureCreateDeviceAddressCaptureReplayKhr = Self(rawValue: 1 << 0)
27 | }
28 |
29 | public struct AccelerationStructureCreateFlagBitsKHR: OptionSet {
30 | public var rawValue: UInt32
31 |
32 | public init(rawValue: UInt32) {
33 | self.rawValue = rawValue
34 | }
35 |
36 | public var vulkan: VkAccelerationStructureCreateFlagBitsKHR {
37 | VkAccelerationStructureCreateFlagBitsKHR(rawValue)
38 | }
39 |
40 | public static let vkAccelerationStructureCreateDeviceAddressCaptureReplayKhr = Self(rawValue: 1 << 0)
41 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/AccelerationStructureDeviceAddressInfoKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct AccelerationStructureDeviceAddressInfoKHR: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var accelerationStructure: AccelerationStructureKHR
6 |
7 | var vNext: [Any]? = nil
8 |
9 | public init(
10 | next: Any? = nil,
11 | accelerationStructure: AccelerationStructureKHR
12 | ) {
13 | self.next = next
14 | self.accelerationStructure = accelerationStructure
15 | }
16 |
17 | public var vulkan: VkAccelerationStructureDeviceAddressInfoKHR {
18 | mutating get {
19 | vNext = next == nil ? nil : [next!]
20 | return VkAccelerationStructureDeviceAddressInfoKHR(
21 | sType: VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR,
22 | pNext: vNext,
23 | accelerationStructure: accelerationStructure.vulkan
24 | )
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/AccelerationStructureGeometryAabbsDataKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct AccelerationStructureGeometryAabbsDataKHR: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var data: DeviceOrHostAddressConstKHR
6 | public var stride: DeviceSize
7 |
8 | var vNext: [Any]? = nil
9 |
10 | public init(
11 | next: Any? = nil,
12 | data: DeviceOrHostAddressConstKHR,
13 | stride: DeviceSize
14 | ) {
15 | self.next = next
16 | self.data = data
17 | self.stride = stride
18 | }
19 |
20 | public var vulkan: VkAccelerationStructureGeometryAabbsDataKHR {
21 | mutating get {
22 | vNext = next == nil ? nil : [next!]
23 | return VkAccelerationStructureGeometryAabbsDataKHR(
24 | sType: VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR,
25 | pNext: vNext,
26 | data: data.vulkan,
27 | stride: stride.vulkan
28 | )
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/AccelerationStructureGeometryInstancesDataKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct AccelerationStructureGeometryInstancesDataKHR: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var arrayOfPointers: Bool
6 | public var data: DeviceOrHostAddressConstKHR
7 |
8 | var vNext: [Any]? = nil
9 |
10 | public init(
11 | next: Any? = nil,
12 | arrayOfPointers: Bool,
13 | data: DeviceOrHostAddressConstKHR
14 | ) {
15 | self.next = next
16 | self.arrayOfPointers = arrayOfPointers
17 | self.data = data
18 | }
19 |
20 | public var vulkan: VkAccelerationStructureGeometryInstancesDataKHR {
21 | mutating get {
22 | vNext = next == nil ? nil : [next!]
23 | return VkAccelerationStructureGeometryInstancesDataKHR(
24 | sType: VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR,
25 | pNext: vNext,
26 | arrayOfPointers: arrayOfPointers.vulkan,
27 | data: data.vulkan
28 | )
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/AccelerationStructureGeometryKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct AccelerationStructureGeometryKHR: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var geometryType: GeometryTypeKHR
6 | public var geometry: AccelerationStructureGeometryDataKHR
7 | public var flags: GeometryFlagsKHR?
8 |
9 | var vNext: [Any]? = nil
10 |
11 | public init(
12 | next: Any? = nil,
13 | geometryType: GeometryTypeKHR,
14 | geometry: AccelerationStructureGeometryDataKHR,
15 | flags: GeometryFlagsKHR? = nil
16 | ) {
17 | self.next = next
18 | self.geometryType = geometryType
19 | self.geometry = geometry
20 | self.flags = flags
21 | }
22 |
23 | public var vulkan: VkAccelerationStructureGeometryKHR {
24 | mutating get {
25 | vNext = next == nil ? nil : [next!]
26 | return VkAccelerationStructureGeometryKHR(
27 | sType: VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR,
28 | pNext: vNext,
29 | geometryType: geometryType.vulkan,
30 | geometry: geometry.vulkan,
31 | flags: flags?.vulkan ?? 0
32 | )
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/AccelerationStructureGeometryTrianglesDataKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct AccelerationStructureGeometryTrianglesDataKHR: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var vertexFormat: Format
6 | public var vertexData: DeviceOrHostAddressConstKHR
7 | public var vertexStride: DeviceSize
8 | public var maxVertex: UInt32
9 | public var indexType: IndexType
10 | public var indexData: DeviceOrHostAddressConstKHR
11 | public var transformData: DeviceOrHostAddressConstKHR
12 |
13 | var vNext: [Any]? = nil
14 |
15 | public init(
16 | next: Any? = nil,
17 | vertexFormat: Format,
18 | vertexData: DeviceOrHostAddressConstKHR,
19 | vertexStride: DeviceSize,
20 | maxVertex: UInt32,
21 | indexType: IndexType,
22 | indexData: DeviceOrHostAddressConstKHR,
23 | transformData: DeviceOrHostAddressConstKHR
24 | ) {
25 | self.next = next
26 | self.vertexFormat = vertexFormat
27 | self.vertexData = vertexData
28 | self.vertexStride = vertexStride
29 | self.maxVertex = maxVertex
30 | self.indexType = indexType
31 | self.indexData = indexData
32 | self.transformData = transformData
33 | }
34 |
35 | public var vulkan: VkAccelerationStructureGeometryTrianglesDataKHR {
36 | mutating get {
37 | vNext = next == nil ? nil : [next!]
38 | return VkAccelerationStructureGeometryTrianglesDataKHR(
39 | sType: VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR,
40 | pNext: vNext,
41 | vertexFormat: vertexFormat.vulkan,
42 | vertexData: vertexData.vulkan,
43 | vertexStride: vertexStride.vulkan,
44 | maxVertex: maxVertex.vulkan,
45 | indexType: indexType.vulkan,
46 | indexData: indexData.vulkan,
47 | transformData: transformData.vulkan
48 | )
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/AccelerationStructureInstanceKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct AccelerationStructureInstanceKHR: VulkanTypeWrapper {
4 | public var transform: TransformMatrixKHR
5 | public var instanceCustomIndex: UInt32
6 | public var mask: UInt32
7 | public var instanceShaderBindingTableRecordOffset: UInt32
8 | public var flags: GeometryInstanceFlagsKHR?
9 | public var accelerationStructureReference: UInt64
10 |
11 |
12 |
13 | public init(
14 | transform: TransformMatrixKHR,
15 | instanceCustomIndex: UInt32,
16 | mask: UInt32,
17 | instanceShaderBindingTableRecordOffset: UInt32,
18 | flags: GeometryInstanceFlagsKHR? = nil,
19 | accelerationStructureReference: UInt64
20 | ) {
21 | self.transform = transform
22 | self.instanceCustomIndex = instanceCustomIndex
23 | self.mask = mask
24 | self.instanceShaderBindingTableRecordOffset = instanceShaderBindingTableRecordOffset
25 | self.flags = flags
26 | self.accelerationStructureReference = accelerationStructureReference
27 | }
28 |
29 | public var vulkan: VkAccelerationStructureInstanceKHR {
30 | mutating get {
31 |
32 | return VkAccelerationStructureInstanceKHR(
33 | transform: transform.vulkan,
34 | instanceCustomIndex: instanceCustomIndex.vulkan,
35 | mask: mask.vulkan,
36 | instanceShaderBindingTableRecordOffset: instanceShaderBindingTableRecordOffset.vulkan,
37 | flags: flags?.vulkan ?? 0,
38 | accelerationStructureReference: accelerationStructureReference.vulkan
39 | )
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/AccelerationStructureTypeKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum AccelerationStructureTypeKHR: UInt32, VulkanEnumTypeWrapper {
4 | case vkAccelerationStructureTypeTopLevelKhr = 0,
5 | vkAccelerationStructureTypeBottomLevelKhr = 1,
6 | vkAccelerationStructureTypeGenericKhr = 2
7 |
8 | public init(fromVulkan: VkAccelerationStructureTypeKHR) {
9 | self.init(rawValue: fromVulkan.rawValue)!
10 | }
11 |
12 | public var vulkan: VkAccelerationStructureTypeKHR {
13 | VkAccelerationStructureTypeKHR(rawValue)
14 | }
15 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/ApplicationInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct ApplicationInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var pApplicationName: String?
6 | public var applicationVersion: UInt32
7 | public var pEngineName: String?
8 | public var engineVersion: UInt32
9 | public var apiVersion: UInt32
10 |
11 | var vNext: [Any]? = nil
12 |
13 | public init(
14 | next: Any? = nil,
15 | pApplicationName: String? = nil,
16 | applicationVersion: UInt32,
17 | pEngineName: String? = nil,
18 | engineVersion: UInt32,
19 | apiVersion: UInt32
20 | ) {
21 | self.next = next
22 | self.pApplicationName = pApplicationName
23 | self.applicationVersion = applicationVersion
24 | self.pEngineName = pEngineName
25 | self.engineVersion = engineVersion
26 | self.apiVersion = apiVersion
27 | }
28 |
29 | public var vulkan: VkApplicationInfo {
30 | mutating get {
31 | vNext = next == nil ? nil : [next!]
32 | return VkApplicationInfo(
33 | sType: VK_STRUCTURE_TYPE_APPLICATION_INFO,
34 | pNext: vNext,
35 | pApplicationName: pApplicationName?.vulkan,
36 | applicationVersion: applicationVersion.vulkan,
37 | pEngineName: pEngineName?.vulkan,
38 | engineVersion: engineVersion.vulkan,
39 | apiVersion: apiVersion.vulkan
40 | )
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/BlendOp.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum BlendOp: UInt32, VulkanEnumTypeWrapper {
4 | case add = 0,
5 | subtract = 1,
6 | reverseSubtract = 2,
7 | min = 3,
8 | max = 4
9 |
10 | public init(fromVulkan: VkBlendOp) {
11 | self.init(rawValue: fromVulkan.rawValue)!
12 | }
13 |
14 | public var vulkan: VkBlendOp {
15 | VkBlendOp(rawValue)
16 | }
17 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/BorderColor.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum BorderColor: UInt32, VulkanEnumTypeWrapper {
4 | case floatTransparentBlack = 0,
5 | intTransparentBlack = 1,
6 | floatOpaqueBlack = 2,
7 | intOpaqueBlack = 3,
8 | floatOpaqueWhite = 4,
9 | intOpaqueWhite = 5
10 |
11 | public init(fromVulkan: VkBorderColor) {
12 | self.init(rawValue: fromVulkan.rawValue)!
13 | }
14 |
15 | public var vulkan: VkBorderColor {
16 | VkBorderColor(rawValue)
17 | }
18 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/BufferCopy.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct BufferCopy: VulkanTypeWrapper {
4 | /** Specified in bytes */
5 | public var srcOffset: DeviceSize
6 | /** Specified in bytes */
7 | public var dstOffset: DeviceSize
8 | /** Specified in bytes */
9 | public var size: DeviceSize
10 |
11 |
12 |
13 | public init(
14 | srcOffset: DeviceSize,
15 | dstOffset: DeviceSize,
16 | size: DeviceSize
17 | ) {
18 | self.srcOffset = srcOffset
19 | self.dstOffset = dstOffset
20 | self.size = size
21 | }
22 |
23 | public var vulkan: VkBufferCopy {
24 | mutating get {
25 |
26 | return VkBufferCopy(
27 | srcOffset: srcOffset.vulkan,
28 | dstOffset: dstOffset.vulkan,
29 | size: size.vulkan
30 | )
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/BufferDeviceAddressInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct BufferDeviceAddressInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var buffer: Buffer
6 |
7 | var vNext: [Any]? = nil
8 |
9 | public init(
10 | next: Any? = nil,
11 | buffer: Buffer
12 | ) {
13 | self.next = next
14 | self.buffer = buffer
15 | }
16 |
17 | public var vulkan: VkBufferDeviceAddressInfo {
18 | mutating get {
19 | vNext = next == nil ? nil : [next!]
20 | return VkBufferDeviceAddressInfo(
21 | sType: VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO,
22 | pNext: vNext,
23 | buffer: buffer.vulkan
24 | )
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/BufferImageCopy.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct BufferImageCopy: VulkanTypeWrapper {
4 | /** Specified in bytes */
5 | public var bufferOffset: DeviceSize
6 | /** Specified in texels */
7 | public var bufferRowLength: UInt32
8 | public var bufferImageHeight: UInt32
9 | public var imageSubresource: ImageSubresourceLayers
10 | /** Specified in pixels for both compressed and uncompressed images */
11 | public var imageOffset: Offset3D
12 | /** Specified in pixels for both compressed and uncompressed images */
13 | public var imageExtent: Extent3D
14 |
15 |
16 |
17 | public init(
18 | bufferOffset: DeviceSize,
19 | bufferRowLength: UInt32,
20 | bufferImageHeight: UInt32,
21 | imageSubresource: ImageSubresourceLayers,
22 | imageOffset: Offset3D,
23 | imageExtent: Extent3D
24 | ) {
25 | self.bufferOffset = bufferOffset
26 | self.bufferRowLength = bufferRowLength
27 | self.bufferImageHeight = bufferImageHeight
28 | self.imageSubresource = imageSubresource
29 | self.imageOffset = imageOffset
30 | self.imageExtent = imageExtent
31 | }
32 |
33 | public var vulkan: VkBufferImageCopy {
34 | mutating get {
35 |
36 | return VkBufferImageCopy(
37 | bufferOffset: bufferOffset.vulkan,
38 | bufferRowLength: bufferRowLength.vulkan,
39 | bufferImageHeight: bufferImageHeight.vulkan,
40 | imageSubresource: imageSubresource.vulkan,
41 | imageOffset: imageOffset.vulkan,
42 | imageExtent: imageExtent.vulkan
43 | )
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/BufferMemoryBarrier.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct BufferMemoryBarrier: VulkanTypeWrapper {
4 | public var next: Any?
5 | /** Memory accesses from the source of the dependency to synchronize */
6 | public var srcAccessMask: AccessFlags
7 | /** Memory accesses from the destination of the dependency to synchronize */
8 | public var dstAccessMask: AccessFlags
9 | /** Queue family to transition ownership from */
10 | public var srcQueueFamilyIndex: UInt32
11 | /** Queue family to transition ownership to */
12 | public var dstQueueFamilyIndex: UInt32
13 | /** Buffer to sync */
14 | public var buffer: Buffer
15 | /** Offset within the buffer to sync */
16 | public var offset: DeviceSize
17 | /** Amount of bytes to sync */
18 | public var size: DeviceSize
19 |
20 | var vNext: [Any]? = nil
21 |
22 | public init(
23 | next: Any? = nil,
24 | srcAccessMask: AccessFlags,
25 | dstAccessMask: AccessFlags,
26 | srcQueueFamilyIndex: UInt32,
27 | dstQueueFamilyIndex: UInt32,
28 | buffer: Buffer,
29 | offset: DeviceSize,
30 | size: DeviceSize
31 | ) {
32 | self.next = next
33 | self.srcAccessMask = srcAccessMask
34 | self.dstAccessMask = dstAccessMask
35 | self.srcQueueFamilyIndex = srcQueueFamilyIndex
36 | self.dstQueueFamilyIndex = dstQueueFamilyIndex
37 | self.buffer = buffer
38 | self.offset = offset
39 | self.size = size
40 | }
41 |
42 | public var vulkan: VkBufferMemoryBarrier {
43 | mutating get {
44 | vNext = next == nil ? nil : [next!]
45 | return VkBufferMemoryBarrier(
46 | sType: VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
47 | pNext: vNext,
48 | srcAccessMask: srcAccessMask.vulkan,
49 | dstAccessMask: dstAccessMask.vulkan,
50 | srcQueueFamilyIndex: srcQueueFamilyIndex.vulkan,
51 | dstQueueFamilyIndex: dstQueueFamilyIndex.vulkan,
52 | buffer: buffer.vulkan,
53 | offset: offset.vulkan,
54 | size: size.vulkan
55 | )
56 | }
57 | }
58 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/BuildAccelerationStructureFlagsKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct BuildAccelerationStructureFlagsKHR: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkBuildAccelerationStructureFlagsKHR {
7 | VkBuildAccelerationStructureFlagsKHR(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkBuildAccelerationStructureFlagsKHR) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkBuildAccelerationStructureFlagsKHR?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 | public static let vkBuildAccelerationStructureAllowUpdateKhr = Self(rawValue: 1 << 0)
27 | public static let vkBuildAccelerationStructureAllowCompactionKhr = Self(rawValue: 1 << 1)
28 | public static let vkBuildAccelerationStructurePreferFastTraceKhr = Self(rawValue: 1 << 2)
29 | public static let vkBuildAccelerationStructurePreferFastBuildKhr = Self(rawValue: 1 << 3)
30 | public static let vkBuildAccelerationStructureLowMemoryKhr = Self(rawValue: 1 << 4)
31 | }
32 |
33 | public struct BuildAccelerationStructureFlagBitsKHR: OptionSet {
34 | public var rawValue: UInt32
35 |
36 | public init(rawValue: UInt32) {
37 | self.rawValue = rawValue
38 | }
39 |
40 | public var vulkan: VkBuildAccelerationStructureFlagBitsKHR {
41 | VkBuildAccelerationStructureFlagBitsKHR(rawValue)
42 | }
43 |
44 | public static let vkBuildAccelerationStructureAllowUpdateKhr = Self(rawValue: 1 << 0)
45 | public static let vkBuildAccelerationStructureAllowCompactionKhr = Self(rawValue: 1 << 1)
46 | public static let vkBuildAccelerationStructurePreferFastTraceKhr = Self(rawValue: 1 << 2)
47 | public static let vkBuildAccelerationStructurePreferFastBuildKhr = Self(rawValue: 1 << 3)
48 | public static let vkBuildAccelerationStructureLowMemoryKhr = Self(rawValue: 1 << 4)
49 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/BuildAccelerationStructureModeKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum BuildAccelerationStructureModeKHR: UInt32, VulkanEnumTypeWrapper {
4 | case vkBuildAccelerationStructureModeBuildKhr = 0,
5 | vkBuildAccelerationStructureModeUpdateKhr = 1
6 |
7 | public init(fromVulkan: VkBuildAccelerationStructureModeKHR) {
8 | self.init(rawValue: fromVulkan.rawValue)!
9 | }
10 |
11 | public var vulkan: VkBuildAccelerationStructureModeKHR {
12 | VkBuildAccelerationStructureModeKHR(rawValue)
13 | }
14 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/ColorComponentFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct ColorComponentFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkColorComponentFlags {
7 | VkColorComponentFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkColorComponentFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkColorComponentFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 | public static let r = Self(rawValue: 1 << 0)
27 | public static let g = Self(rawValue: 1 << 1)
28 | public static let b = Self(rawValue: 1 << 2)
29 | public static let a = Self(rawValue: 1 << 3)
30 | }
31 |
32 | public struct ColorComponentFlagBits: OptionSet {
33 | public var rawValue: UInt32
34 |
35 | public init(rawValue: UInt32) {
36 | self.rawValue = rawValue
37 | }
38 |
39 | public var vulkan: VkColorComponentFlagBits {
40 | VkColorComponentFlagBits(rawValue)
41 | }
42 |
43 | public static let r = Self(rawValue: 1 << 0)
44 | public static let g = Self(rawValue: 1 << 1)
45 | public static let b = Self(rawValue: 1 << 2)
46 | public static let a = Self(rawValue: 1 << 3)
47 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/CompareOp.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum CompareOp: UInt32, VulkanEnumTypeWrapper {
4 | case never = 0,
5 | less = 1,
6 | equal = 2,
7 | lessOrEqual = 3,
8 | greater = 4,
9 | notEqual = 5,
10 | greaterOrEqual = 6,
11 | always = 7
12 |
13 | public init(fromVulkan: VkCompareOp) {
14 | self.init(rawValue: fromVulkan.rawValue)!
15 | }
16 |
17 | public var vulkan: VkCompareOp {
18 | VkCompareOp(rawValue)
19 | }
20 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/ComponentMapping.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct ComponentMapping: VulkanTypeWrapper {
4 | public var r: ComponentSwizzle
5 | public var g: ComponentSwizzle
6 | public var b: ComponentSwizzle
7 | public var a: ComponentSwizzle
8 |
9 |
10 |
11 | public init(
12 | r: ComponentSwizzle,
13 | g: ComponentSwizzle,
14 | b: ComponentSwizzle,
15 | a: ComponentSwizzle
16 | ) {
17 | self.r = r
18 | self.g = g
19 | self.b = b
20 | self.a = a
21 | }
22 |
23 | public var vulkan: VkComponentMapping {
24 | mutating get {
25 |
26 | return VkComponentMapping(
27 | r: r.vulkan,
28 | g: g.vulkan,
29 | b: b.vulkan,
30 | a: a.vulkan
31 | )
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/CullModeFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct CullModeFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkCullModeFlags {
7 | VkCullModeFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkCullModeFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkCullModeFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 | public static let front = Self(rawValue: 1 << 0)
27 | public static let back = Self(rawValue: 1 << 1)
28 | }
29 |
30 | public struct CullModeFlagBits: OptionSet {
31 | public var rawValue: UInt32
32 |
33 | public init(rawValue: UInt32) {
34 | self.rawValue = rawValue
35 | }
36 |
37 | public var vulkan: VkCullModeFlagBits {
38 | VkCullModeFlagBits(rawValue)
39 | }
40 |
41 | public static let front = Self(rawValue: 1 << 0)
42 | public static let back = Self(rawValue: 1 << 1)
43 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/DescriptorBufferInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct DescriptorBufferInfo: VulkanTypeWrapper {
4 | /** Buffer used for this descriptor slot. */
5 | public var buffer: Buffer?
6 | /** Base offset from buffer start in bytes to update in the descriptor set. */
7 | public var offset: DeviceSize
8 | /** Size in bytes of the buffer resource for this descriptor update. */
9 | public var range: DeviceSize
10 |
11 |
12 |
13 | public init(
14 | buffer: Buffer? = nil,
15 | offset: DeviceSize,
16 | range: DeviceSize
17 | ) {
18 | self.buffer = buffer
19 | self.offset = offset
20 | self.range = range
21 | }
22 |
23 | public var vulkan: VkDescriptorBufferInfo {
24 | mutating get {
25 |
26 | return VkDescriptorBufferInfo(
27 | buffer: buffer?.vulkan,
28 | offset: offset.vulkan,
29 | range: range.vulkan
30 | )
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/DescriptorImageInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct DescriptorImageInfo: VulkanTypeWrapper {
4 | /** Sampler to write to the descriptor in case it is a SAMPLER or COMBINED_IMAGE_SAMPLER descriptor. Ignored otherwise. */
5 | public var sampler: Sampler
6 | /** Image view to write to the descriptor in case it is a SAMPLED_IMAGE, STORAGE_IMAGE, COMBINED_IMAGE_SAMPLER, or INPUT_ATTACHMENT descriptor. Ignored otherwise. */
7 | public var imageView: ImageView
8 | /** Layout the image is expected to be in when accessed using this descriptor (only used if imageView is not VK_NULL_HANDLE). */
9 | public var imageLayout: ImageLayout
10 |
11 |
12 |
13 | public init(
14 | sampler: Sampler,
15 | imageView: ImageView,
16 | imageLayout: ImageLayout
17 | ) {
18 | self.sampler = sampler
19 | self.imageView = imageView
20 | self.imageLayout = imageLayout
21 | }
22 |
23 | public var vulkan: VkDescriptorImageInfo {
24 | mutating get {
25 |
26 | return VkDescriptorImageInfo(
27 | sampler: sampler.vulkan,
28 | imageView: imageView.vulkan,
29 | imageLayout: imageLayout.vulkan
30 | )
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/DescriptorPoolCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct DescriptorPoolCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: DescriptorPoolCreateFlags?
6 | public var maxSets: UInt32
7 | public var poolSizes: [DescriptorPoolSize]
8 |
9 | var vNext: [Any]? = nil
10 | var vPoolSizes: [VkDescriptorPoolSize]? = nil
11 |
12 | public init(
13 | next: Any? = nil,
14 | flags: DescriptorPoolCreateFlags? = nil,
15 | maxSets: UInt32,
16 | poolSizes: [DescriptorPoolSize]
17 | ) {
18 | self.next = next
19 | self.flags = flags
20 | self.maxSets = maxSets
21 | self.poolSizes = poolSizes
22 | }
23 |
24 | public var vulkan: VkDescriptorPoolCreateInfo {
25 | mutating get {
26 | vNext = next == nil ? nil : [next!]
27 | vPoolSizes = poolSizes.vulkanArray
28 | return VkDescriptorPoolCreateInfo(
29 | sType: VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
30 | pNext: vNext,
31 | flags: flags?.vulkan ?? 0,
32 | maxSets: maxSets.vulkan,
33 | poolSizeCount: UInt32(poolSizes.count),
34 | pPoolSizes: vPoolSizes
35 | )
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/DescriptorPoolSize.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct DescriptorPoolSize: VulkanTypeWrapper {
4 | public var type: DescriptorType
5 | public var descriptorCount: UInt32
6 |
7 |
8 |
9 | public init(
10 | type: DescriptorType,
11 | descriptorCount: UInt32
12 | ) {
13 | self.type = type
14 | self.descriptorCount = descriptorCount
15 | }
16 |
17 | public var vulkan: VkDescriptorPoolSize {
18 | mutating get {
19 |
20 | return VkDescriptorPoolSize(
21 | type: type.vulkan,
22 | descriptorCount: descriptorCount.vulkan
23 | )
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/DescriptorSetAllocateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct DescriptorSetAllocateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var descriptorPool: DescriptorPool
6 | public var descriptorSetCount: UInt32
7 | public var setLayouts: [DescriptorSetLayout]
8 |
9 | var vNext: [Any]? = nil
10 | var vSetLayouts: [VkDescriptorSetLayout?]? = nil
11 |
12 | public init(
13 | next: Any? = nil,
14 | descriptorPool: DescriptorPool,
15 | descriptorSetCount: UInt32,
16 | setLayouts: [DescriptorSetLayout]
17 | ) {
18 | self.next = next
19 | self.descriptorPool = descriptorPool
20 | self.descriptorSetCount = descriptorSetCount
21 | self.setLayouts = setLayouts
22 | }
23 |
24 | public var vulkan: VkDescriptorSetAllocateInfo {
25 | mutating get {
26 | vNext = next == nil ? nil : [next!]
27 | vSetLayouts = setLayouts.vulkanArray
28 | return VkDescriptorSetAllocateInfo(
29 | sType: VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
30 | pNext: vNext,
31 | descriptorPool: descriptorPool.vulkan,
32 | descriptorSetCount: descriptorSetCount.vulkan,
33 | pSetLayouts: vSetLayouts
34 | )
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/DescriptorSetLayoutBinding.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct DescriptorSetLayoutBinding: VulkanTypeWrapper {
4 | /** Binding number for this entry */
5 | public var binding: UInt32
6 | /** Type of the descriptors in this binding */
7 | public var descriptorType: DescriptorType
8 | /** Number of descriptors in this binding */
9 | public var descriptorCount: UInt32?
10 | /** Shader stages this binding is visible to */
11 | public var stageFlags: ShaderStageFlags
12 | public var immutableSamplers: [Sampler]?
13 |
14 | var vImmutableSamplers: [VkSampler?]? = nil
15 |
16 | public init(
17 | binding: UInt32,
18 | descriptorType: DescriptorType,
19 | descriptorCount: UInt32? = nil,
20 | stageFlags: ShaderStageFlags,
21 | immutableSamplers: [Sampler]? = nil
22 | ) {
23 | self.binding = binding
24 | self.descriptorType = descriptorType
25 | self.descriptorCount = descriptorCount
26 | self.stageFlags = stageFlags
27 | self.immutableSamplers = immutableSamplers
28 | }
29 |
30 | public var vulkan: VkDescriptorSetLayoutBinding {
31 | mutating get {
32 | vImmutableSamplers = immutableSamplers?.vulkanArray
33 | return VkDescriptorSetLayoutBinding(
34 | binding: binding.vulkan,
35 | descriptorType: descriptorType.vulkan,
36 | descriptorCount: descriptorCount?.vulkan ?? 0,
37 | stageFlags: stageFlags.vulkan,
38 | pImmutableSamplers: vImmutableSamplers
39 | )
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/DescriptorSetLayoutCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct DescriptorSetLayoutCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: DescriptorSetLayoutCreateFlags?
6 | public var bindings: [DescriptorSetLayoutBinding]
7 |
8 | var vNext: [Any]? = nil
9 | var vBindings: [VkDescriptorSetLayoutBinding]? = nil
10 |
11 | public init(
12 | next: Any? = nil,
13 | flags: DescriptorSetLayoutCreateFlags? = nil,
14 | bindings: [DescriptorSetLayoutBinding]
15 | ) {
16 | self.next = next
17 | self.flags = flags
18 | self.bindings = bindings
19 | }
20 |
21 | public var vulkan: VkDescriptorSetLayoutCreateInfo {
22 | mutating get {
23 | vNext = next == nil ? nil : [next!]
24 | vBindings = bindings.vulkanArray
25 | return VkDescriptorSetLayoutCreateInfo(
26 | sType: VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
27 | pNext: vNext,
28 | flags: flags?.vulkan ?? 0,
29 | bindingCount: UInt32(bindings.count),
30 | pBindings: vBindings
31 | )
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/DynamicState.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum DynamicState: UInt32, VulkanEnumTypeWrapper {
4 | case viewport = 0,
5 | scissor = 1,
6 | lineWidth = 2,
7 | depthBias = 3,
8 | blendConstants = 4,
9 | depthBounds = 5,
10 | stencilCompareMask = 6,
11 | stencilWriteMask = 7,
12 | stencilReference = 8
13 |
14 | public init(fromVulkan: VkDynamicState) {
15 | self.init(rawValue: fromVulkan.rawValue)!
16 | }
17 |
18 | public var vulkan: VkDynamicState {
19 | VkDynamicState(rawValue)
20 | }
21 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/EventCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct EventCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkEventCreateFlags {
7 | VkEventCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkEventCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkEventCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 | public struct EventCreateFlagBits: OptionSet {
30 | public var rawValue: UInt32
31 |
32 | public init(rawValue: UInt32) {
33 | self.rawValue = rawValue
34 | }
35 |
36 | public var vulkan: VkEventCreateFlagBits {
37 | VkEventCreateFlagBits(rawValue)
38 | }
39 |
40 |
41 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/EventCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct EventCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | /** Event creation flags */
6 | public var flags: EventCreateFlags?
7 |
8 | var vNext: [Any]? = nil
9 |
10 | public init(
11 | next: Any? = nil,
12 | flags: EventCreateFlags? = nil
13 | ) {
14 | self.next = next
15 | self.flags = flags
16 | }
17 |
18 | public var vulkan: VkEventCreateInfo {
19 | mutating get {
20 | vNext = next == nil ? nil : [next!]
21 | return VkEventCreateInfo(
22 | sType: VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
23 | pNext: vNext,
24 | flags: flags?.vulkan ?? 0
25 | )
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/Filter.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum Filter: UInt32, VulkanEnumTypeWrapper {
4 | case nearest = 0,
5 | linear = 1
6 |
7 | public init(fromVulkan: VkFilter) {
8 | self.init(rawValue: fromVulkan.rawValue)!
9 | }
10 |
11 | public var vulkan: VkFilter {
12 | VkFilter(rawValue)
13 | }
14 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/FramebufferCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct FramebufferCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: FramebufferCreateFlags?
6 | public var renderPass: RenderPass
7 | public var attachments: [ImageView]
8 | public var width: UInt32
9 | public var height: UInt32
10 | public var layers: UInt32
11 |
12 | var vNext: [Any]? = nil
13 | var vAttachments: [VkImageView?]? = nil
14 |
15 | public init(
16 | next: Any? = nil,
17 | flags: FramebufferCreateFlags? = nil,
18 | renderPass: RenderPass,
19 | attachments: [ImageView],
20 | width: UInt32,
21 | height: UInt32,
22 | layers: UInt32
23 | ) {
24 | self.next = next
25 | self.flags = flags
26 | self.renderPass = renderPass
27 | self.attachments = attachments
28 | self.width = width
29 | self.height = height
30 | self.layers = layers
31 | }
32 |
33 | public var vulkan: VkFramebufferCreateInfo {
34 | mutating get {
35 | vNext = next == nil ? nil : [next!]
36 | vAttachments = attachments.vulkanArray
37 | return VkFramebufferCreateInfo(
38 | sType: VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
39 | pNext: vNext,
40 | flags: flags?.vulkan ?? 0,
41 | renderPass: renderPass.vulkan,
42 | attachmentCount: UInt32(attachments.count),
43 | pAttachments: vAttachments,
44 | width: width.vulkan,
45 | height: height.vulkan,
46 | layers: layers.vulkan
47 | )
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/GeometryFlagsKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct GeometryFlagsKHR: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkGeometryFlagsKHR {
7 | VkGeometryFlagsKHR(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkGeometryFlagsKHR) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkGeometryFlagsKHR?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 | public static let vkGeometryOpaqueKhr = Self(rawValue: 1 << 0)
27 | public static let vkGeometryNoDuplicateAnyHitInvocationKhr = Self(rawValue: 1 << 1)
28 | }
29 |
30 | public struct GeometryFlagBitsKHR: OptionSet {
31 | public var rawValue: UInt32
32 |
33 | public init(rawValue: UInt32) {
34 | self.rawValue = rawValue
35 | }
36 |
37 | public var vulkan: VkGeometryFlagBitsKHR {
38 | VkGeometryFlagBitsKHR(rawValue)
39 | }
40 |
41 | public static let vkGeometryOpaqueKhr = Self(rawValue: 1 << 0)
42 | public static let vkGeometryNoDuplicateAnyHitInvocationKhr = Self(rawValue: 1 << 1)
43 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/GeometryInstanceFlagsKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct GeometryInstanceFlagsKHR: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkGeometryInstanceFlagsKHR {
7 | VkGeometryInstanceFlagsKHR(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkGeometryInstanceFlagsKHR) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkGeometryInstanceFlagsKHR?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 | public static let vkGeometryInstanceTriangleFacingCullDisableKhr = Self(rawValue: 1 << 0)
27 | public static let vkGeometryInstanceTriangleFrontCounterclockwiseKhr = Self(rawValue: 1 << 1)
28 | public static let vkGeometryInstanceForceOpaqueKhr = Self(rawValue: 1 << 2)
29 | public static let vkGeometryInstanceForceNoOpaqueKhr = Self(rawValue: 1 << 3)
30 | }
31 |
32 | public struct GeometryInstanceFlagBitsKHR: OptionSet {
33 | public var rawValue: UInt32
34 |
35 | public init(rawValue: UInt32) {
36 | self.rawValue = rawValue
37 | }
38 |
39 | public var vulkan: VkGeometryInstanceFlagBitsKHR {
40 | VkGeometryInstanceFlagBitsKHR(rawValue)
41 | }
42 |
43 | public static let vkGeometryInstanceTriangleFacingCullDisableKhr = Self(rawValue: 1 << 0)
44 | public static let vkGeometryInstanceTriangleFrontCounterclockwiseKhr = Self(rawValue: 1 << 1)
45 | public static let vkGeometryInstanceForceOpaqueKhr = Self(rawValue: 1 << 2)
46 | public static let vkGeometryInstanceForceNoOpaqueKhr = Self(rawValue: 1 << 3)
47 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/GeometryTypeKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum GeometryTypeKHR: UInt32, VulkanEnumTypeWrapper {
4 | case vkGeometryTypeTrianglesKhr = 0,
5 | vkGeometryTypeAabbsKhr = 1,
6 | vkGeometryTypeInstancesKhr = 2
7 |
8 | public init(fromVulkan: VkGeometryTypeKHR) {
9 | self.init(rawValue: fromVulkan.rawValue)!
10 | }
11 |
12 | public var vulkan: VkGeometryTypeKHR {
13 | VkGeometryTypeKHR(rawValue)
14 | }
15 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/ImageAspectFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct ImageAspectFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkImageAspectFlags {
7 | VkImageAspectFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkImageAspectFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkImageAspectFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 | public static let color = Self(rawValue: 1 << 0)
27 | public static let depth = Self(rawValue: 1 << 1)
28 | public static let stencil = Self(rawValue: 1 << 2)
29 | public static let metadata = Self(rawValue: 1 << 3)
30 | }
31 |
32 | public struct ImageAspectFlagBits: OptionSet {
33 | public var rawValue: UInt32
34 |
35 | public init(rawValue: UInt32) {
36 | self.rawValue = rawValue
37 | }
38 |
39 | public var vulkan: VkImageAspectFlagBits {
40 | VkImageAspectFlagBits(rawValue)
41 | }
42 |
43 | public static let color = Self(rawValue: 1 << 0)
44 | public static let depth = Self(rawValue: 1 << 1)
45 | public static let stencil = Self(rawValue: 1 << 2)
46 | public static let metadata = Self(rawValue: 1 << 3)
47 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/ImageMemoryBarrier.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct ImageMemoryBarrier: VulkanTypeWrapper {
4 | public var next: Any?
5 | /** Memory accesses from the source of the dependency to synchronize */
6 | public var srcAccessMask: AccessFlags
7 | /** Memory accesses from the destination of the dependency to synchronize */
8 | public var dstAccessMask: AccessFlags
9 | /** Current layout of the image */
10 | public var oldLayout: ImageLayout
11 | /** New layout to transition the image to */
12 | public var newLayout: ImageLayout
13 | /** Queue family to transition ownership from */
14 | public var srcQueueFamilyIndex: UInt32
15 | /** Queue family to transition ownership to */
16 | public var dstQueueFamilyIndex: UInt32
17 | /** Image to sync */
18 | public var image: Image
19 | /** Subresource range to sync */
20 | public var subresourceRange: ImageSubresourceRange
21 |
22 | var vNext: [Any]? = nil
23 |
24 | public init(
25 | next: Any? = nil,
26 | srcAccessMask: AccessFlags,
27 | dstAccessMask: AccessFlags,
28 | oldLayout: ImageLayout,
29 | newLayout: ImageLayout,
30 | srcQueueFamilyIndex: UInt32,
31 | dstQueueFamilyIndex: UInt32,
32 | image: Image,
33 | subresourceRange: ImageSubresourceRange
34 | ) {
35 | self.next = next
36 | self.srcAccessMask = srcAccessMask
37 | self.dstAccessMask = dstAccessMask
38 | self.oldLayout = oldLayout
39 | self.newLayout = newLayout
40 | self.srcQueueFamilyIndex = srcQueueFamilyIndex
41 | self.dstQueueFamilyIndex = dstQueueFamilyIndex
42 | self.image = image
43 | self.subresourceRange = subresourceRange
44 | }
45 |
46 | public var vulkan: VkImageMemoryBarrier {
47 | mutating get {
48 | vNext = next == nil ? nil : [next!]
49 | return VkImageMemoryBarrier(
50 | sType: VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
51 | pNext: vNext,
52 | srcAccessMask: srcAccessMask.vulkan,
53 | dstAccessMask: dstAccessMask.vulkan,
54 | oldLayout: oldLayout.vulkan,
55 | newLayout: newLayout.vulkan,
56 | srcQueueFamilyIndex: srcQueueFamilyIndex.vulkan,
57 | dstQueueFamilyIndex: dstQueueFamilyIndex.vulkan,
58 | image: image.vulkan,
59 | subresourceRange: subresourceRange.vulkan
60 | )
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/ImageSubresourceLayers.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct ImageSubresourceLayers: VulkanTypeWrapper {
4 | public var aspectMask: ImageAspectFlags
5 | public var mipLevel: UInt32
6 | public var baseArrayLayer: UInt32
7 | public var layerCount: UInt32
8 |
9 |
10 |
11 | public init(
12 | aspectMask: ImageAspectFlags,
13 | mipLevel: UInt32,
14 | baseArrayLayer: UInt32,
15 | layerCount: UInt32
16 | ) {
17 | self.aspectMask = aspectMask
18 | self.mipLevel = mipLevel
19 | self.baseArrayLayer = baseArrayLayer
20 | self.layerCount = layerCount
21 | }
22 |
23 | public var vulkan: VkImageSubresourceLayers {
24 | mutating get {
25 |
26 | return VkImageSubresourceLayers(
27 | aspectMask: aspectMask.vulkan,
28 | mipLevel: mipLevel.vulkan,
29 | baseArrayLayer: baseArrayLayer.vulkan,
30 | layerCount: layerCount.vulkan
31 | )
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/ImageSubresourceRange.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct ImageSubresourceRange: VulkanTypeWrapper {
4 | public var aspectMask: ImageAspectFlags
5 | public var baseMipLevel: UInt32
6 | public var levelCount: UInt32
7 | public var baseArrayLayer: UInt32
8 | public var layerCount: UInt32
9 |
10 |
11 |
12 | public init(
13 | aspectMask: ImageAspectFlags,
14 | baseMipLevel: UInt32,
15 | levelCount: UInt32,
16 | baseArrayLayer: UInt32,
17 | layerCount: UInt32
18 | ) {
19 | self.aspectMask = aspectMask
20 | self.baseMipLevel = baseMipLevel
21 | self.levelCount = levelCount
22 | self.baseArrayLayer = baseArrayLayer
23 | self.layerCount = layerCount
24 | }
25 |
26 | public var vulkan: VkImageSubresourceRange {
27 | mutating get {
28 |
29 | return VkImageSubresourceRange(
30 | aspectMask: aspectMask.vulkan,
31 | baseMipLevel: baseMipLevel.vulkan,
32 | levelCount: levelCount.vulkan,
33 | baseArrayLayer: baseArrayLayer.vulkan,
34 | layerCount: layerCount.vulkan
35 | )
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/ImageUsageFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct ImageUsageFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkImageUsageFlags {
7 | VkImageUsageFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkImageUsageFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkImageUsageFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 | public static let transferSrc = Self(rawValue: 1 << 0)
27 | public static let transferDst = Self(rawValue: 1 << 1)
28 | public static let sampled = Self(rawValue: 1 << 2)
29 | public static let storage = Self(rawValue: 1 << 3)
30 | public static let colorAttachment = Self(rawValue: 1 << 4)
31 | public static let depthStencilAttachment = Self(rawValue: 1 << 5)
32 | public static let transientAttachment = Self(rawValue: 1 << 6)
33 | public static let inputAttachment = Self(rawValue: 1 << 7)
34 | }
35 |
36 | public struct ImageUsageFlagBits: OptionSet {
37 | public var rawValue: UInt32
38 |
39 | public init(rawValue: UInt32) {
40 | self.rawValue = rawValue
41 | }
42 |
43 | public var vulkan: VkImageUsageFlagBits {
44 | VkImageUsageFlagBits(rawValue)
45 | }
46 |
47 | public static let transferSrc = Self(rawValue: 1 << 0)
48 | public static let transferDst = Self(rawValue: 1 << 1)
49 | public static let sampled = Self(rawValue: 1 << 2)
50 | public static let storage = Self(rawValue: 1 << 3)
51 | public static let colorAttachment = Self(rawValue: 1 << 4)
52 | public static let depthStencilAttachment = Self(rawValue: 1 << 5)
53 | public static let transientAttachment = Self(rawValue: 1 << 6)
54 | public static let inputAttachment = Self(rawValue: 1 << 7)
55 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/ImageViewCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct ImageViewCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkImageViewCreateFlags {
7 | VkImageViewCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkImageViewCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkImageViewCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 | public struct ImageViewCreateFlagBits: OptionSet {
30 | public var rawValue: UInt32
31 |
32 | public init(rawValue: UInt32) {
33 | self.rawValue = rawValue
34 | }
35 |
36 | public var vulkan: VkImageViewCreateFlagBits {
37 | VkImageViewCreateFlagBits(rawValue)
38 | }
39 |
40 |
41 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/ImageViewCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct ImageViewCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: ImageViewCreateFlags?
6 | public var image: Image
7 | public var viewType: ImageViewType
8 | public var format: Format
9 | public var components: ComponentMapping
10 | public var subresourceRange: ImageSubresourceRange
11 |
12 | var vNext: [Any]? = nil
13 |
14 | public init(
15 | next: Any? = nil,
16 | flags: ImageViewCreateFlags? = nil,
17 | image: Image,
18 | viewType: ImageViewType,
19 | format: Format,
20 | components: ComponentMapping,
21 | subresourceRange: ImageSubresourceRange
22 | ) {
23 | self.next = next
24 | self.flags = flags
25 | self.image = image
26 | self.viewType = viewType
27 | self.format = format
28 | self.components = components
29 | self.subresourceRange = subresourceRange
30 | }
31 |
32 | public var vulkan: VkImageViewCreateInfo {
33 | mutating get {
34 | vNext = next == nil ? nil : [next!]
35 | return VkImageViewCreateInfo(
36 | sType: VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
37 | pNext: vNext,
38 | flags: flags?.vulkan ?? 0,
39 | image: image.vulkan,
40 | viewType: viewType.vulkan,
41 | format: format.vulkan,
42 | components: components.vulkan,
43 | subresourceRange: subresourceRange.vulkan
44 | )
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/IndexType.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum IndexType: UInt32, VulkanEnumTypeWrapper {
4 | case uint16 = 0,
5 | uint32 = 1
6 |
7 | public init(fromVulkan: VkIndexType) {
8 | self.init(rawValue: fromVulkan.rawValue)!
9 | }
10 |
11 | public var vulkan: VkIndexType {
12 | VkIndexType(rawValue)
13 | }
14 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/MemoryBarrier.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct MemoryBarrier: VulkanTypeWrapper {
4 | public var next: Any?
5 | /** Memory accesses from the source of the dependency to synchronize */
6 | public var srcAccessMask: AccessFlags?
7 | /** Memory accesses from the destination of the dependency to synchronize */
8 | public var dstAccessMask: AccessFlags?
9 |
10 | var vNext: [Any]? = nil
11 |
12 | public init(
13 | next: Any? = nil,
14 | srcAccessMask: AccessFlags? = nil,
15 | dstAccessMask: AccessFlags? = nil
16 | ) {
17 | self.next = next
18 | self.srcAccessMask = srcAccessMask
19 | self.dstAccessMask = dstAccessMask
20 | }
21 |
22 | public var vulkan: VkMemoryBarrier {
23 | mutating get {
24 | vNext = next == nil ? nil : [next!]
25 | return VkMemoryBarrier(
26 | sType: VK_STRUCTURE_TYPE_MEMORY_BARRIER,
27 | pNext: vNext,
28 | srcAccessMask: srcAccessMask?.vulkan ?? 0,
29 | dstAccessMask: dstAccessMask?.vulkan ?? 0
30 | )
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/Offset3D.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct Offset3D: VulkanTypeWrapper {
4 | public var x: Int32
5 | public var y: Int32
6 | public var z: Int32
7 |
8 |
9 |
10 | public init(
11 | x: Int32,
12 | y: Int32,
13 | z: Int32
14 | ) {
15 | self.x = x
16 | self.y = y
17 | self.z = z
18 | }
19 |
20 | public var vulkan: VkOffset3D {
21 | mutating get {
22 |
23 | return VkOffset3D(
24 | x: x.vulkan,
25 | y: y.vulkan,
26 | z: z.vulkan
27 | )
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PhysicalDeviceProperties.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PhysicalDeviceProperties: VulkanTypeWrapper {
4 | public var apiVersion: UInt32
5 | public var driverVersion: UInt32
6 | public var vendorID: UInt32
7 | public var deviceID: UInt32
8 | public var deviceType: PhysicalDeviceType
9 | public var deviceName: String
10 | public var pipelineCacheUUID: [UInt8]
11 | public var limits: PhysicalDeviceLimits
12 | public var sparseProperties: PhysicalDeviceSparseProperties
13 |
14 |
15 |
16 | public init(
17 | apiVersion: UInt32,
18 | driverVersion: UInt32,
19 | vendorID: UInt32,
20 | deviceID: UInt32,
21 | deviceType: PhysicalDeviceType,
22 | deviceName: String,
23 | pipelineCacheUUID: [UInt8],
24 | limits: PhysicalDeviceLimits,
25 | sparseProperties: PhysicalDeviceSparseProperties
26 | ) {
27 | self.apiVersion = apiVersion
28 | self.driverVersion = driverVersion
29 | self.vendorID = vendorID
30 | self.deviceID = deviceID
31 | self.deviceType = deviceType
32 | self.deviceName = deviceName
33 | self.pipelineCacheUUID = pipelineCacheUUID
34 | self.limits = limits
35 | self.sparseProperties = sparseProperties
36 | }
37 |
38 | public init(fromVulkan vulkan: VkPhysicalDeviceProperties) {
39 | self.init(
40 | apiVersion: UInt32(fromVulkan: vulkan.apiVersion),
41 | driverVersion: UInt32(fromVulkan: vulkan.driverVersion),
42 | vendorID: UInt32(fromVulkan: vulkan.vendorID),
43 | deviceID: UInt32(fromVulkan: vulkan.deviceID),
44 | deviceType: PhysicalDeviceType(fromVulkan: vulkan.deviceType),
45 | deviceName: "FIXED LENGTH STRING CONVERSION NOT IMPLEMENTED",
46 | pipelineCacheUUID: convertTupleToArray(vulkan.pipelineCacheUUID),
47 | limits: PhysicalDeviceLimits(fromVulkan: vulkan.limits),
48 | sparseProperties: PhysicalDeviceSparseProperties(fromVulkan: vulkan.sparseProperties)
49 | )
50 | }
51 |
52 | public var vulkan: VkPhysicalDeviceProperties {
53 | mutating get {
54 | fatalError("PhysicalDeviceProperties is a return-only type")
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PhysicalDeviceSparseProperties.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PhysicalDeviceSparseProperties: VulkanTypeWrapper {
4 | /** Sparse resources support: GPU will access all 2D (single sample) sparse resources using the standard sparse image block shapes (based on pixel format) */
5 | public var residencyStandard2DBlockShape: Bool
6 | /** Sparse resources support: GPU will access all 2D (multisample) sparse resources using the standard sparse image block shapes (based on pixel format) */
7 | public var residencyStandard2DMultisampleBlockShape: Bool
8 | /** Sparse resources support: GPU will access all 3D sparse resources using the standard sparse image block shapes (based on pixel format) */
9 | public var residencyStandard3DBlockShape: Bool
10 | /** Sparse resources support: Images with mip level dimensions that are NOT a multiple of the sparse image block dimensions will be placed in the mip tail */
11 | public var residencyAlignedMipSize: Bool
12 | /** Sparse resources support: GPU can consistently access non-resident regions of a resource, all reads return as if data is 0, writes are discarded */
13 | public var residencyNonResidentStrict: Bool
14 |
15 |
16 |
17 | public init(
18 | residencyStandard2DBlockShape: Bool,
19 | residencyStandard2DMultisampleBlockShape: Bool,
20 | residencyStandard3DBlockShape: Bool,
21 | residencyAlignedMipSize: Bool,
22 | residencyNonResidentStrict: Bool
23 | ) {
24 | self.residencyStandard2DBlockShape = residencyStandard2DBlockShape
25 | self.residencyStandard2DMultisampleBlockShape = residencyStandard2DMultisampleBlockShape
26 | self.residencyStandard3DBlockShape = residencyStandard3DBlockShape
27 | self.residencyAlignedMipSize = residencyAlignedMipSize
28 | self.residencyNonResidentStrict = residencyNonResidentStrict
29 | }
30 |
31 | public init(fromVulkan vulkan: VkPhysicalDeviceSparseProperties) {
32 | self.init(
33 | residencyStandard2DBlockShape: Bool(fromVulkan: vulkan.residencyStandard2DBlockShape),
34 | residencyStandard2DMultisampleBlockShape: Bool(fromVulkan: vulkan.residencyStandard2DMultisampleBlockShape),
35 | residencyStandard3DBlockShape: Bool(fromVulkan: vulkan.residencyStandard3DBlockShape),
36 | residencyAlignedMipSize: Bool(fromVulkan: vulkan.residencyAlignedMipSize),
37 | residencyNonResidentStrict: Bool(fromVulkan: vulkan.residencyNonResidentStrict)
38 | )
39 | }
40 |
41 | public var vulkan: VkPhysicalDeviceSparseProperties {
42 | mutating get {
43 | fatalError("PhysicalDeviceSparseProperties is a return-only type")
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PhysicalDeviceType.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum PhysicalDeviceType: UInt32, VulkanEnumTypeWrapper {
4 | case other = 0,
5 | integratedGpu = 1,
6 | discreteGpu = 2,
7 | virtualGpu = 3,
8 | cpu = 4
9 |
10 | public init(fromVulkan: VkPhysicalDeviceType) {
11 | self.init(rawValue: fromVulkan.rawValue)!
12 | }
13 |
14 | public var vulkan: VkPhysicalDeviceType {
15 | VkPhysicalDeviceType(rawValue)
16 | }
17 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineColorBlendAttachmentState.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineColorBlendAttachmentState: VulkanTypeWrapper {
4 | public var blendEnable: Bool
5 | public var srcColorBlendFactor: BlendFactor
6 | public var dstColorBlendFactor: BlendFactor
7 | public var colorBlendOp: BlendOp
8 | public var srcAlphaBlendFactor: BlendFactor
9 | public var dstAlphaBlendFactor: BlendFactor
10 | public var alphaBlendOp: BlendOp
11 | public var colorWriteMask: ColorComponentFlags?
12 |
13 |
14 |
15 | public init(
16 | blendEnable: Bool,
17 | srcColorBlendFactor: BlendFactor,
18 | dstColorBlendFactor: BlendFactor,
19 | colorBlendOp: BlendOp,
20 | srcAlphaBlendFactor: BlendFactor,
21 | dstAlphaBlendFactor: BlendFactor,
22 | alphaBlendOp: BlendOp,
23 | colorWriteMask: ColorComponentFlags? = nil
24 | ) {
25 | self.blendEnable = blendEnable
26 | self.srcColorBlendFactor = srcColorBlendFactor
27 | self.dstColorBlendFactor = dstColorBlendFactor
28 | self.colorBlendOp = colorBlendOp
29 | self.srcAlphaBlendFactor = srcAlphaBlendFactor
30 | self.dstAlphaBlendFactor = dstAlphaBlendFactor
31 | self.alphaBlendOp = alphaBlendOp
32 | self.colorWriteMask = colorWriteMask
33 | }
34 |
35 | public var vulkan: VkPipelineColorBlendAttachmentState {
36 | mutating get {
37 |
38 | return VkPipelineColorBlendAttachmentState(
39 | blendEnable: blendEnable.vulkan,
40 | srcColorBlendFactor: srcColorBlendFactor.vulkan,
41 | dstColorBlendFactor: dstColorBlendFactor.vulkan,
42 | colorBlendOp: colorBlendOp.vulkan,
43 | srcAlphaBlendFactor: srcAlphaBlendFactor.vulkan,
44 | dstAlphaBlendFactor: dstAlphaBlendFactor.vulkan,
45 | alphaBlendOp: alphaBlendOp.vulkan,
46 | colorWriteMask: colorWriteMask?.vulkan ?? 0
47 | )
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineColorBlendStateCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineColorBlendStateCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkPipelineColorBlendStateCreateFlags {
7 | VkPipelineColorBlendStateCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkPipelineColorBlendStateCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkPipelineColorBlendStateCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineColorBlendStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineColorBlendStateCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: PipelineColorBlendStateCreateFlags?
6 | public var logicOpEnable: Bool
7 | public var logicOp: LogicOp
8 | public var attachments: [PipelineColorBlendAttachmentState]
9 | public var blendConstants: (Float, Float, Float, Float)
10 |
11 | var vNext: [Any]? = nil
12 | var vAttachments: [VkPipelineColorBlendAttachmentState]? = nil
13 |
14 | public init(
15 | next: Any? = nil,
16 | flags: PipelineColorBlendStateCreateFlags? = nil,
17 | logicOpEnable: Bool,
18 | logicOp: LogicOp,
19 | attachments: [PipelineColorBlendAttachmentState],
20 | blendConstants: (Float, Float, Float, Float)
21 | ) {
22 | self.next = next
23 | self.flags = flags
24 | self.logicOpEnable = logicOpEnable
25 | self.logicOp = logicOp
26 | self.attachments = attachments
27 | self.blendConstants = blendConstants
28 | }
29 |
30 | public var vulkan: VkPipelineColorBlendStateCreateInfo {
31 | mutating get {
32 | vNext = next == nil ? nil : [next!]
33 | vAttachments = attachments.vulkanArray
34 | return VkPipelineColorBlendStateCreateInfo(
35 | sType: VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
36 | pNext: vNext,
37 | flags: flags?.vulkan ?? 0,
38 | logicOpEnable: logicOpEnable.vulkan,
39 | logicOp: logicOp.vulkan,
40 | attachmentCount: UInt32(attachments.count),
41 | pAttachments: vAttachments,
42 | blendConstants: blendConstants
43 | )
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkPipelineCreateFlags {
7 | VkPipelineCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkPipelineCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkPipelineCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 | public static let disableOptimization = Self(rawValue: 1 << 0)
27 | public static let allowDerivatives = Self(rawValue: 1 << 1)
28 | public static let derivative = Self(rawValue: 1 << 2)
29 | }
30 |
31 | public struct PipelineCreateFlagBits: OptionSet {
32 | public var rawValue: UInt32
33 |
34 | public init(rawValue: UInt32) {
35 | self.rawValue = rawValue
36 | }
37 |
38 | public var vulkan: VkPipelineCreateFlagBits {
39 | VkPipelineCreateFlagBits(rawValue)
40 | }
41 |
42 | public static let disableOptimization = Self(rawValue: 1 << 0)
43 | public static let allowDerivatives = Self(rawValue: 1 << 1)
44 | public static let derivative = Self(rawValue: 1 << 2)
45 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineDepthStencilStateCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineDepthStencilStateCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkPipelineDepthStencilStateCreateFlags {
7 | VkPipelineDepthStencilStateCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkPipelineDepthStencilStateCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkPipelineDepthStencilStateCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineDepthStencilStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineDepthStencilStateCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: PipelineDepthStencilStateCreateFlags?
6 | public var depthTestEnable: Bool
7 | public var depthWriteEnable: Bool
8 | public var depthCompareOp: CompareOp
9 | /** optional (depth_bounds_test) */
10 | public var depthBoundsTestEnable: Bool
11 | public var stencilTestEnable: Bool
12 | public var front: StencilOpState
13 | public var back: StencilOpState
14 | public var minDepthBounds: Float
15 | public var maxDepthBounds: Float
16 |
17 | var vNext: [Any]? = nil
18 |
19 | public init(
20 | next: Any? = nil,
21 | flags: PipelineDepthStencilStateCreateFlags? = nil,
22 | depthTestEnable: Bool,
23 | depthWriteEnable: Bool,
24 | depthCompareOp: CompareOp,
25 | depthBoundsTestEnable: Bool,
26 | stencilTestEnable: Bool,
27 | front: StencilOpState,
28 | back: StencilOpState,
29 | minDepthBounds: Float,
30 | maxDepthBounds: Float
31 | ) {
32 | self.next = next
33 | self.flags = flags
34 | self.depthTestEnable = depthTestEnable
35 | self.depthWriteEnable = depthWriteEnable
36 | self.depthCompareOp = depthCompareOp
37 | self.depthBoundsTestEnable = depthBoundsTestEnable
38 | self.stencilTestEnable = stencilTestEnable
39 | self.front = front
40 | self.back = back
41 | self.minDepthBounds = minDepthBounds
42 | self.maxDepthBounds = maxDepthBounds
43 | }
44 |
45 | public var vulkan: VkPipelineDepthStencilStateCreateInfo {
46 | mutating get {
47 | vNext = next == nil ? nil : [next!]
48 | return VkPipelineDepthStencilStateCreateInfo(
49 | sType: VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
50 | pNext: vNext,
51 | flags: flags?.vulkan ?? 0,
52 | depthTestEnable: depthTestEnable.vulkan,
53 | depthWriteEnable: depthWriteEnable.vulkan,
54 | depthCompareOp: depthCompareOp.vulkan,
55 | depthBoundsTestEnable: depthBoundsTestEnable.vulkan,
56 | stencilTestEnable: stencilTestEnable.vulkan,
57 | front: front.vulkan,
58 | back: back.vulkan,
59 | minDepthBounds: minDepthBounds.vulkan,
60 | maxDepthBounds: maxDepthBounds.vulkan
61 | )
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineDynamicStateCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineDynamicStateCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkPipelineDynamicStateCreateFlags {
7 | VkPipelineDynamicStateCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkPipelineDynamicStateCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkPipelineDynamicStateCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineDynamicStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineDynamicStateCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: PipelineDynamicStateCreateFlags?
6 | public var dynamicStates: [DynamicState]
7 |
8 | var vNext: [Any]? = nil
9 | var vDynamicStates: [VkDynamicState]? = nil
10 |
11 | public init(
12 | next: Any? = nil,
13 | flags: PipelineDynamicStateCreateFlags? = nil,
14 | dynamicStates: [DynamicState]
15 | ) {
16 | self.next = next
17 | self.flags = flags
18 | self.dynamicStates = dynamicStates
19 | }
20 |
21 | public var vulkan: VkPipelineDynamicStateCreateInfo {
22 | mutating get {
23 | vNext = next == nil ? nil : [next!]
24 | vDynamicStates = dynamicStates.vulkanArray
25 | return VkPipelineDynamicStateCreateInfo(
26 | sType: VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
27 | pNext: vNext,
28 | flags: flags?.vulkan ?? 0,
29 | dynamicStateCount: UInt32(dynamicStates.count),
30 | pDynamicStates: vDynamicStates
31 | )
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineInputAssemblyStateCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineInputAssemblyStateCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkPipelineInputAssemblyStateCreateFlags {
7 | VkPipelineInputAssemblyStateCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkPipelineInputAssemblyStateCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkPipelineInputAssemblyStateCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineInputAssemblyStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineInputAssemblyStateCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: PipelineInputAssemblyStateCreateFlags?
6 | public var topology: PrimitiveTopology
7 | public var primitiveRestartEnable: Bool
8 |
9 | var vNext: [Any]? = nil
10 |
11 | public init(
12 | next: Any? = nil,
13 | flags: PipelineInputAssemblyStateCreateFlags? = nil,
14 | topology: PrimitiveTopology,
15 | primitiveRestartEnable: Bool
16 | ) {
17 | self.next = next
18 | self.flags = flags
19 | self.topology = topology
20 | self.primitiveRestartEnable = primitiveRestartEnable
21 | }
22 |
23 | public var vulkan: VkPipelineInputAssemblyStateCreateInfo {
24 | mutating get {
25 | vNext = next == nil ? nil : [next!]
26 | return VkPipelineInputAssemblyStateCreateInfo(
27 | sType: VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
28 | pNext: vNext,
29 | flags: flags?.vulkan ?? 0,
30 | topology: topology.vulkan,
31 | primitiveRestartEnable: primitiveRestartEnable.vulkan
32 | )
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineLayoutCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineLayoutCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkPipelineLayoutCreateFlags {
7 | VkPipelineLayoutCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkPipelineLayoutCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkPipelineLayoutCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineLayoutCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineLayoutCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: PipelineLayoutCreateFlags?
6 | public var setLayouts: [DescriptorSetLayout]
7 | public var pushConstantRanges: [PushConstantRange]
8 |
9 | var vNext: [Any]? = nil
10 | var vSetLayouts: [VkDescriptorSetLayout?]? = nil
11 | var vPushConstantRanges: [VkPushConstantRange]? = nil
12 |
13 | public init(
14 | next: Any? = nil,
15 | flags: PipelineLayoutCreateFlags? = nil,
16 | setLayouts: [DescriptorSetLayout],
17 | pushConstantRanges: [PushConstantRange]
18 | ) {
19 | self.next = next
20 | self.flags = flags
21 | self.setLayouts = setLayouts
22 | self.pushConstantRanges = pushConstantRanges
23 | }
24 |
25 | public var vulkan: VkPipelineLayoutCreateInfo {
26 | mutating get {
27 | vNext = next == nil ? nil : [next!]
28 | vSetLayouts = setLayouts.vulkanArray
29 | vPushConstantRanges = pushConstantRanges.vulkanArray
30 | return VkPipelineLayoutCreateInfo(
31 | sType: VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
32 | pNext: vNext,
33 | flags: flags?.vulkan ?? 0,
34 | setLayoutCount: UInt32(setLayouts.count),
35 | pSetLayouts: vSetLayouts,
36 | pushConstantRangeCount: UInt32(pushConstantRanges.count),
37 | pPushConstantRanges: vPushConstantRanges
38 | )
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineMultisampleStateCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineMultisampleStateCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkPipelineMultisampleStateCreateFlags {
7 | VkPipelineMultisampleStateCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkPipelineMultisampleStateCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkPipelineMultisampleStateCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineMultisampleStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineMultisampleStateCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: PipelineMultisampleStateCreateFlags?
6 | /** Number of samples used for rasterization */
7 | public var rasterizationSamples: SampleCountFlagBits
8 | /** optional (GL45) */
9 | public var sampleShadingEnable: Bool
10 | /** optional (GL45) */
11 | public var minSampleShading: Float
12 | public var sampleMask: [SampleMask]?
13 | public var alphaToCoverageEnable: Bool
14 | public var alphaToOneEnable: Bool
15 |
16 | var vNext: [Any]? = nil
17 | var vSampleMask: [VkSampleMask]? = nil
18 |
19 | public init(
20 | next: Any? = nil,
21 | flags: PipelineMultisampleStateCreateFlags? = nil,
22 | rasterizationSamples: SampleCountFlagBits,
23 | sampleShadingEnable: Bool,
24 | minSampleShading: Float,
25 | sampleMask: [SampleMask]? = nil,
26 | alphaToCoverageEnable: Bool,
27 | alphaToOneEnable: Bool
28 | ) {
29 | self.next = next
30 | self.flags = flags
31 | self.rasterizationSamples = rasterizationSamples
32 | self.sampleShadingEnable = sampleShadingEnable
33 | self.minSampleShading = minSampleShading
34 | self.sampleMask = sampleMask
35 | self.alphaToCoverageEnable = alphaToCoverageEnable
36 | self.alphaToOneEnable = alphaToOneEnable
37 | }
38 |
39 | public var vulkan: VkPipelineMultisampleStateCreateInfo {
40 | mutating get {
41 | vNext = next == nil ? nil : [next!]
42 | vSampleMask = sampleMask?.vulkanArray
43 | return VkPipelineMultisampleStateCreateInfo(
44 | sType: VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
45 | pNext: vNext,
46 | flags: flags?.vulkan ?? 0,
47 | rasterizationSamples: rasterizationSamples.vulkan,
48 | sampleShadingEnable: sampleShadingEnable.vulkan,
49 | minSampleShading: minSampleShading.vulkan,
50 | pSampleMask: vSampleMask,
51 | alphaToCoverageEnable: alphaToCoverageEnable.vulkan,
52 | alphaToOneEnable: alphaToOneEnable.vulkan
53 | )
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineRasterizationStateCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineRasterizationStateCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkPipelineRasterizationStateCreateFlags {
7 | VkPipelineRasterizationStateCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkPipelineRasterizationStateCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkPipelineRasterizationStateCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineRasterizationStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineRasterizationStateCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: PipelineRasterizationStateCreateFlags?
6 | public var depthClampEnable: Bool
7 | public var rasterizerDiscardEnable: Bool
8 | /** optional (GL45) */
9 | public var polygonMode: PolygonMode
10 | public var cullMode: CullModeFlags?
11 | public var frontFace: FrontFace
12 | public var depthBiasEnable: Bool
13 | public var depthBiasConstantFactor: Float
14 | public var depthBiasClamp: Float
15 | public var depthBiasSlopeFactor: Float
16 | public var lineWidth: Float
17 |
18 | var vNext: [Any]? = nil
19 |
20 | public init(
21 | next: Any? = nil,
22 | flags: PipelineRasterizationStateCreateFlags? = nil,
23 | depthClampEnable: Bool,
24 | rasterizerDiscardEnable: Bool,
25 | polygonMode: PolygonMode,
26 | cullMode: CullModeFlags? = nil,
27 | frontFace: FrontFace,
28 | depthBiasEnable: Bool,
29 | depthBiasConstantFactor: Float,
30 | depthBiasClamp: Float,
31 | depthBiasSlopeFactor: Float,
32 | lineWidth: Float
33 | ) {
34 | self.next = next
35 | self.flags = flags
36 | self.depthClampEnable = depthClampEnable
37 | self.rasterizerDiscardEnable = rasterizerDiscardEnable
38 | self.polygonMode = polygonMode
39 | self.cullMode = cullMode
40 | self.frontFace = frontFace
41 | self.depthBiasEnable = depthBiasEnable
42 | self.depthBiasConstantFactor = depthBiasConstantFactor
43 | self.depthBiasClamp = depthBiasClamp
44 | self.depthBiasSlopeFactor = depthBiasSlopeFactor
45 | self.lineWidth = lineWidth
46 | }
47 |
48 | public var vulkan: VkPipelineRasterizationStateCreateInfo {
49 | mutating get {
50 | vNext = next == nil ? nil : [next!]
51 | return VkPipelineRasterizationStateCreateInfo(
52 | sType: VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
53 | pNext: vNext,
54 | flags: flags?.vulkan ?? 0,
55 | depthClampEnable: depthClampEnable.vulkan,
56 | rasterizerDiscardEnable: rasterizerDiscardEnable.vulkan,
57 | polygonMode: polygonMode.vulkan,
58 | cullMode: cullMode?.vulkan ?? 0,
59 | frontFace: frontFace.vulkan,
60 | depthBiasEnable: depthBiasEnable.vulkan,
61 | depthBiasConstantFactor: depthBiasConstantFactor.vulkan,
62 | depthBiasClamp: depthBiasClamp.vulkan,
63 | depthBiasSlopeFactor: depthBiasSlopeFactor.vulkan,
64 | lineWidth: lineWidth.vulkan
65 | )
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineShaderStageCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineShaderStageCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkPipelineShaderStageCreateFlags {
7 | VkPipelineShaderStageCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkPipelineShaderStageCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkPipelineShaderStageCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 | public struct PipelineShaderStageCreateFlagBits: OptionSet {
30 | public var rawValue: UInt32
31 |
32 | public init(rawValue: UInt32) {
33 | self.rawValue = rawValue
34 | }
35 |
36 | public var vulkan: VkPipelineShaderStageCreateFlagBits {
37 | VkPipelineShaderStageCreateFlagBits(rawValue)
38 | }
39 |
40 |
41 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineShaderStageCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineShaderStageCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: PipelineShaderStageCreateFlags?
6 | /** Shader stage */
7 | public var stage: ShaderStageFlagBits
8 | /** Module containing entry point */
9 | public var module: ShaderModule
10 | /** Null-terminated entry point name */
11 | public var pName: String
12 | public var specializationInfo: SpecializationInfo?
13 |
14 | var vNext: [Any]? = nil
15 | var vSpecializationInfo: [VkSpecializationInfo]? = nil
16 |
17 | public init(
18 | next: Any? = nil,
19 | flags: PipelineShaderStageCreateFlags? = nil,
20 | stage: ShaderStageFlagBits,
21 | module: ShaderModule,
22 | pName: String,
23 | specializationInfo: SpecializationInfo? = nil
24 | ) {
25 | self.next = next
26 | self.flags = flags
27 | self.stage = stage
28 | self.module = module
29 | self.pName = pName
30 | self.specializationInfo = specializationInfo
31 | }
32 |
33 | public var vulkan: VkPipelineShaderStageCreateInfo {
34 | mutating get {
35 | vNext = next == nil ? nil : [next!]
36 | vSpecializationInfo = specializationInfo?.vulkanArray
37 | return VkPipelineShaderStageCreateInfo(
38 | sType: VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
39 | pNext: vNext,
40 | flags: flags?.vulkan ?? 0,
41 | stage: stage.vulkan,
42 | module: module.vulkan,
43 | pName: pName.vulkan,
44 | pSpecializationInfo: vSpecializationInfo
45 | )
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineTessellationStateCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineTessellationStateCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkPipelineTessellationStateCreateFlags {
7 | VkPipelineTessellationStateCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkPipelineTessellationStateCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkPipelineTessellationStateCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineTessellationStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineTessellationStateCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: PipelineTessellationStateCreateFlags?
6 | public var patchControlPoints: UInt32
7 |
8 | var vNext: [Any]? = nil
9 |
10 | public init(
11 | next: Any? = nil,
12 | flags: PipelineTessellationStateCreateFlags? = nil,
13 | patchControlPoints: UInt32
14 | ) {
15 | self.next = next
16 | self.flags = flags
17 | self.patchControlPoints = patchControlPoints
18 | }
19 |
20 | public var vulkan: VkPipelineTessellationStateCreateInfo {
21 | mutating get {
22 | vNext = next == nil ? nil : [next!]
23 | return VkPipelineTessellationStateCreateInfo(
24 | sType: VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO,
25 | pNext: vNext,
26 | flags: flags?.vulkan ?? 0,
27 | patchControlPoints: patchControlPoints.vulkan
28 | )
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineVertexInputStateCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineVertexInputStateCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkPipelineVertexInputStateCreateFlags {
7 | VkPipelineVertexInputStateCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkPipelineVertexInputStateCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkPipelineVertexInputStateCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineVertexInputStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineVertexInputStateCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: PipelineVertexInputStateCreateFlags?
6 | public var vertexBindingDescriptions: [VertexInputBindingDescription]
7 | public var vertexAttributeDescriptions: [VertexInputAttributeDescription]
8 |
9 | var vNext: [Any]? = nil
10 | var vVertexBindingDescriptions: [VkVertexInputBindingDescription]? = nil
11 | var vVertexAttributeDescriptions: [VkVertexInputAttributeDescription]? = nil
12 |
13 | public init(
14 | next: Any? = nil,
15 | flags: PipelineVertexInputStateCreateFlags? = nil,
16 | vertexBindingDescriptions: [VertexInputBindingDescription],
17 | vertexAttributeDescriptions: [VertexInputAttributeDescription]
18 | ) {
19 | self.next = next
20 | self.flags = flags
21 | self.vertexBindingDescriptions = vertexBindingDescriptions
22 | self.vertexAttributeDescriptions = vertexAttributeDescriptions
23 | }
24 |
25 | public var vulkan: VkPipelineVertexInputStateCreateInfo {
26 | mutating get {
27 | vNext = next == nil ? nil : [next!]
28 | vVertexBindingDescriptions = vertexBindingDescriptions.vulkanArray
29 | vVertexAttributeDescriptions = vertexAttributeDescriptions.vulkanArray
30 | return VkPipelineVertexInputStateCreateInfo(
31 | sType: VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
32 | pNext: vNext,
33 | flags: flags?.vulkan ?? 0,
34 | vertexBindingDescriptionCount: UInt32(vertexBindingDescriptions.count),
35 | pVertexBindingDescriptions: vVertexBindingDescriptions,
36 | vertexAttributeDescriptionCount: UInt32(vertexAttributeDescriptions.count),
37 | pVertexAttributeDescriptions: vVertexAttributeDescriptions
38 | )
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineViewportStateCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineViewportStateCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkPipelineViewportStateCreateFlags {
7 | VkPipelineViewportStateCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkPipelineViewportStateCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkPipelineViewportStateCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PipelineViewportStateCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PipelineViewportStateCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: PipelineViewportStateCreateFlags?
6 | public var viewports: [Viewport]?
7 | public var scissors: [Rect2D]?
8 |
9 | var vNext: [Any]? = nil
10 | var vViewports: [VkViewport]? = nil
11 | var vScissors: [VkRect2D]? = nil
12 |
13 | public init(
14 | next: Any? = nil,
15 | flags: PipelineViewportStateCreateFlags? = nil,
16 | viewports: [Viewport]? = nil,
17 | scissors: [Rect2D]? = nil
18 | ) {
19 | self.next = next
20 | self.flags = flags
21 | self.viewports = viewports
22 | self.scissors = scissors
23 | }
24 |
25 | public var vulkan: VkPipelineViewportStateCreateInfo {
26 | mutating get {
27 | vNext = next == nil ? nil : [next!]
28 | vViewports = viewports?.vulkanArray
29 | vScissors = scissors?.vulkanArray
30 | return VkPipelineViewportStateCreateInfo(
31 | sType: VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
32 | pNext: vNext,
33 | flags: flags?.vulkan ?? 0,
34 | viewportCount: UInt32(viewports?.count ?? 0),
35 | pViewports: vViewports,
36 | scissorCount: UInt32(scissors?.count ?? 0),
37 | pScissors: vScissors
38 | )
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PrimitiveTopology.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum PrimitiveTopology: UInt32, VulkanEnumTypeWrapper {
4 | case pointList = 0,
5 | lineList = 1,
6 | lineStrip = 2,
7 | triangleList = 3,
8 | triangleStrip = 4,
9 | triangleFan = 5,
10 | lineListWithAdjacency = 6,
11 | lineStripWithAdjacency = 7,
12 | triangleListWithAdjacency = 8,
13 | triangleStripWithAdjacency = 9,
14 | patchList = 10
15 |
16 | public init(fromVulkan: VkPrimitiveTopology) {
17 | self.init(rawValue: fromVulkan.rawValue)!
18 | }
19 |
20 | public var vulkan: VkPrimitiveTopology {
21 | VkPrimitiveTopology(rawValue)
22 | }
23 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/PushConstantRange.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct PushConstantRange: VulkanTypeWrapper {
4 | /** Which stages use the range */
5 | public var stageFlags: ShaderStageFlags
6 | /** Start of the range, in bytes */
7 | public var offset: UInt32
8 | /** Size of the range, in bytes */
9 | public var size: UInt32
10 |
11 |
12 |
13 | public init(
14 | stageFlags: ShaderStageFlags,
15 | offset: UInt32,
16 | size: UInt32
17 | ) {
18 | self.stageFlags = stageFlags
19 | self.offset = offset
20 | self.size = size
21 | }
22 |
23 | public var vulkan: VkPushConstantRange {
24 | mutating get {
25 |
26 | return VkPushConstantRange(
27 | stageFlags: stageFlags.vulkan,
28 | offset: offset.vulkan,
29 | size: size.vulkan
30 | )
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/Rect2D.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct Rect2D: VulkanTypeWrapper {
4 | public var offset: Offset2D
5 | public var extent: Extent2D
6 |
7 |
8 |
9 | public init(
10 | offset: Offset2D,
11 | extent: Extent2D
12 | ) {
13 | self.offset = offset
14 | self.extent = extent
15 | }
16 |
17 | public var vulkan: VkRect2D {
18 | mutating get {
19 |
20 | return VkRect2D(
21 | offset: offset.vulkan,
22 | extent: extent.vulkan
23 | )
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/SampleCountFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct SampleCountFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkSampleCountFlags {
7 | VkSampleCountFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkSampleCountFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkSampleCountFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 | public static let _1 = Self(rawValue: 1 << 0)
27 | public static let _2 = Self(rawValue: 1 << 1)
28 | public static let _4 = Self(rawValue: 1 << 2)
29 | public static let _8 = Self(rawValue: 1 << 3)
30 | public static let _16 = Self(rawValue: 1 << 4)
31 | public static let _32 = Self(rawValue: 1 << 5)
32 | public static let _64 = Self(rawValue: 1 << 6)
33 | }
34 |
35 | public struct SampleCountFlagBits: OptionSet {
36 | public var rawValue: UInt32
37 |
38 | public init(rawValue: UInt32) {
39 | self.rawValue = rawValue
40 | }
41 |
42 | public var vulkan: VkSampleCountFlagBits {
43 | VkSampleCountFlagBits(rawValue)
44 | }
45 |
46 | public static let _1 = Self(rawValue: 1 << 0)
47 | public static let _2 = Self(rawValue: 1 << 1)
48 | public static let _4 = Self(rawValue: 1 << 2)
49 | public static let _8 = Self(rawValue: 1 << 3)
50 | public static let _16 = Self(rawValue: 1 << 4)
51 | public static let _32 = Self(rawValue: 1 << 5)
52 | public static let _64 = Self(rawValue: 1 << 6)
53 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/SamplerAddressMode.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum SamplerAddressMode: UInt32, VulkanEnumTypeWrapper {
4 | case `repeat` = 0,
5 | mirroredRepeat = 1,
6 | clampToEdge = 2,
7 | clampToBorder = 3
8 |
9 | public init(fromVulkan: VkSamplerAddressMode) {
10 | self.init(rawValue: fromVulkan.rawValue)!
11 | }
12 |
13 | public var vulkan: VkSamplerAddressMode {
14 | VkSamplerAddressMode(rawValue)
15 | }
16 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/SamplerCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct SamplerCreateFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkSamplerCreateFlags {
7 | VkSamplerCreateFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkSamplerCreateFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkSamplerCreateFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 |
27 | }
28 |
29 | public struct SamplerCreateFlagBits: OptionSet {
30 | public var rawValue: UInt32
31 |
32 | public init(rawValue: UInt32) {
33 | self.rawValue = rawValue
34 | }
35 |
36 | public var vulkan: VkSamplerCreateFlagBits {
37 | VkSamplerCreateFlagBits(rawValue)
38 | }
39 |
40 |
41 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/SamplerCreateInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct SamplerCreateInfo: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var flags: SamplerCreateFlags?
6 | /** Filter mode for magnification */
7 | public var magFilter: Filter
8 | /** Filter mode for minifiation */
9 | public var minFilter: Filter
10 | /** Mipmap selection mode */
11 | public var mipmapMode: SamplerMipmapMode
12 | public var addressModeU: SamplerAddressMode
13 | public var addressModeV: SamplerAddressMode
14 | public var addressModeW: SamplerAddressMode
15 | public var mipLodBias: Float
16 | public var anisotropyEnable: Bool
17 | public var maxAnisotropy: Float
18 | public var compareEnable: Bool
19 | public var compareOp: CompareOp
20 | public var minLod: Float
21 | public var maxLod: Float
22 | public var borderColor: BorderColor
23 | public var unnormalizedCoordinates: Bool
24 |
25 | var vNext: [Any]? = nil
26 |
27 | public init(
28 | next: Any? = nil,
29 | flags: SamplerCreateFlags? = nil,
30 | magFilter: Filter,
31 | minFilter: Filter,
32 | mipmapMode: SamplerMipmapMode,
33 | addressModeU: SamplerAddressMode,
34 | addressModeV: SamplerAddressMode,
35 | addressModeW: SamplerAddressMode,
36 | mipLodBias: Float,
37 | anisotropyEnable: Bool,
38 | maxAnisotropy: Float,
39 | compareEnable: Bool,
40 | compareOp: CompareOp,
41 | minLod: Float,
42 | maxLod: Float,
43 | borderColor: BorderColor,
44 | unnormalizedCoordinates: Bool
45 | ) {
46 | self.next = next
47 | self.flags = flags
48 | self.magFilter = magFilter
49 | self.minFilter = minFilter
50 | self.mipmapMode = mipmapMode
51 | self.addressModeU = addressModeU
52 | self.addressModeV = addressModeV
53 | self.addressModeW = addressModeW
54 | self.mipLodBias = mipLodBias
55 | self.anisotropyEnable = anisotropyEnable
56 | self.maxAnisotropy = maxAnisotropy
57 | self.compareEnable = compareEnable
58 | self.compareOp = compareOp
59 | self.minLod = minLod
60 | self.maxLod = maxLod
61 | self.borderColor = borderColor
62 | self.unnormalizedCoordinates = unnormalizedCoordinates
63 | }
64 |
65 | public var vulkan: VkSamplerCreateInfo {
66 | mutating get {
67 | vNext = next == nil ? nil : [next!]
68 | return VkSamplerCreateInfo(
69 | sType: VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
70 | pNext: vNext,
71 | flags: flags?.vulkan ?? 0,
72 | magFilter: magFilter.vulkan,
73 | minFilter: minFilter.vulkan,
74 | mipmapMode: mipmapMode.vulkan,
75 | addressModeU: addressModeU.vulkan,
76 | addressModeV: addressModeV.vulkan,
77 | addressModeW: addressModeW.vulkan,
78 | mipLodBias: mipLodBias.vulkan,
79 | anisotropyEnable: anisotropyEnable.vulkan,
80 | maxAnisotropy: maxAnisotropy.vulkan,
81 | compareEnable: compareEnable.vulkan,
82 | compareOp: compareOp.vulkan,
83 | minLod: minLod.vulkan,
84 | maxLod: maxLod.vulkan,
85 | borderColor: borderColor.vulkan,
86 | unnormalizedCoordinates: unnormalizedCoordinates.vulkan
87 | )
88 | }
89 | }
90 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/SamplerMipmapMode.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum SamplerMipmapMode: UInt32, VulkanEnumTypeWrapper {
4 | case nearest = 0,
5 | linear = 1
6 |
7 | public init(fromVulkan: VkSamplerMipmapMode) {
8 | self.init(rawValue: fromVulkan.rawValue)!
9 | }
10 |
11 | public var vulkan: VkSamplerMipmapMode {
12 | VkSamplerMipmapMode(rawValue)
13 | }
14 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/ShaderStageFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct ShaderStageFlags: OptionSet {
4 | public var rawValue: UInt32
5 |
6 | public var vulkan: VkShaderStageFlags {
7 | VkShaderStageFlags(rawValue)
8 | }
9 |
10 | public init(rawValue: UInt32) {
11 | self.rawValue = rawValue
12 | }
13 |
14 | public init(fromVulkan: VkShaderStageFlags) {
15 | self.rawValue = fromVulkan
16 | }
17 |
18 | public init?(fromVulkan: VkShaderStageFlags?) {
19 | if let fromVulkan = fromVulkan {
20 | self.rawValue = fromVulkan
21 | } else {
22 | return nil
23 | }
24 | }
25 |
26 | public static let vertex = Self(rawValue: 1 << 0)
27 | public static let tessellationControl = Self(rawValue: 1 << 1)
28 | public static let tessellationEvaluation = Self(rawValue: 1 << 2)
29 | public static let geometry = Self(rawValue: 1 << 3)
30 | public static let fragment = Self(rawValue: 1 << 4)
31 | public static let compute = Self(rawValue: 1 << 5)
32 | }
33 |
34 | public struct ShaderStageFlagBits: OptionSet {
35 | public var rawValue: UInt32
36 |
37 | public init(rawValue: UInt32) {
38 | self.rawValue = rawValue
39 | }
40 |
41 | public var vulkan: VkShaderStageFlagBits {
42 | VkShaderStageFlagBits(rawValue)
43 | }
44 |
45 | public static let vertex = Self(rawValue: 1 << 0)
46 | public static let tessellationControl = Self(rawValue: 1 << 1)
47 | public static let tessellationEvaluation = Self(rawValue: 1 << 2)
48 | public static let geometry = Self(rawValue: 1 << 3)
49 | public static let fragment = Self(rawValue: 1 << 4)
50 | public static let compute = Self(rawValue: 1 << 5)
51 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/SpecializationMapEntry.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct SpecializationMapEntry: VulkanTypeWrapper {
4 | /** The SpecConstant ID specified in the BIL */
5 | public var constantID: UInt32
6 | /** Offset of the value in the data block */
7 | public var offset: UInt32
8 | /** Size in bytes of the SpecConstant */
9 | public var size: SizeT
10 |
11 |
12 |
13 | public init(
14 | constantID: UInt32,
15 | offset: UInt32,
16 | size: SizeT
17 | ) {
18 | self.constantID = constantID
19 | self.offset = offset
20 | self.size = size
21 | }
22 |
23 | public var vulkan: VkSpecializationMapEntry {
24 | mutating get {
25 |
26 | return VkSpecializationMapEntry(
27 | constantID: constantID.vulkan,
28 | offset: offset.vulkan,
29 | size: size.vulkan
30 | )
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/StencilOp.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum StencilOp: UInt32, VulkanEnumTypeWrapper {
4 | case keep = 0,
5 | zero = 1,
6 | replace = 2,
7 | incrementAndClamp = 3,
8 | decrementAndClamp = 4,
9 | invert = 5,
10 | incrementAndWrap = 6,
11 | decrementAndWrap = 7
12 |
13 | public init(fromVulkan: VkStencilOp) {
14 | self.init(rawValue: fromVulkan.rawValue)!
15 | }
16 |
17 | public var vulkan: VkStencilOp {
18 | VkStencilOp(rawValue)
19 | }
20 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/StencilOpState.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct StencilOpState: VulkanTypeWrapper {
4 | public var failOp: StencilOp
5 | public var passOp: StencilOp
6 | public var depthFailOp: StencilOp
7 | public var compareOp: CompareOp
8 | public var compareMask: UInt32
9 | public var writeMask: UInt32
10 | public var reference: UInt32
11 |
12 |
13 |
14 | public init(
15 | failOp: StencilOp,
16 | passOp: StencilOp,
17 | depthFailOp: StencilOp,
18 | compareOp: CompareOp,
19 | compareMask: UInt32,
20 | writeMask: UInt32,
21 | reference: UInt32
22 | ) {
23 | self.failOp = failOp
24 | self.passOp = passOp
25 | self.depthFailOp = depthFailOp
26 | self.compareOp = compareOp
27 | self.compareMask = compareMask
28 | self.writeMask = writeMask
29 | self.reference = reference
30 | }
31 |
32 | public var vulkan: VkStencilOpState {
33 | mutating get {
34 |
35 | return VkStencilOpState(
36 | failOp: failOp.vulkan,
37 | passOp: passOp.vulkan,
38 | depthFailOp: depthFailOp.vulkan,
39 | compareOp: compareOp.vulkan,
40 | compareMask: compareMask.vulkan,
41 | writeMask: writeMask.vulkan,
42 | reference: reference.vulkan
43 | )
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/VertexInputAttributeDescription.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct VertexInputAttributeDescription: VulkanTypeWrapper {
4 | /** location of the shader vertex attrib */
5 | public var location: UInt32
6 | /** Vertex buffer binding id */
7 | public var binding: UInt32
8 | /** format of source data */
9 | public var format: Format
10 | /** Offset of first element in bytes from base of vertex */
11 | public var offset: UInt32
12 |
13 |
14 |
15 | public init(
16 | location: UInt32,
17 | binding: UInt32,
18 | format: Format,
19 | offset: UInt32
20 | ) {
21 | self.location = location
22 | self.binding = binding
23 | self.format = format
24 | self.offset = offset
25 | }
26 |
27 | public var vulkan: VkVertexInputAttributeDescription {
28 | mutating get {
29 |
30 | return VkVertexInputAttributeDescription(
31 | location: location.vulkan,
32 | binding: binding.vulkan,
33 | format: format.vulkan,
34 | offset: offset.vulkan
35 | )
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/VertexInputBindingDescription.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct VertexInputBindingDescription: VulkanTypeWrapper {
4 | /** Vertex buffer binding id */
5 | public var binding: UInt32
6 | /** Distance between vertices in bytes (0 = no advancement) */
7 | public var stride: UInt32
8 | /** The rate at which the vertex data is consumed */
9 | public var inputRate: VertexInputRate
10 |
11 |
12 |
13 | public init(
14 | binding: UInt32,
15 | stride: UInt32,
16 | inputRate: VertexInputRate
17 | ) {
18 | self.binding = binding
19 | self.stride = stride
20 | self.inputRate = inputRate
21 | }
22 |
23 | public var vulkan: VkVertexInputBindingDescription {
24 | mutating get {
25 |
26 | return VkVertexInputBindingDescription(
27 | binding: binding.vulkan,
28 | stride: stride.vulkan,
29 | inputRate: inputRate.vulkan
30 | )
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/Viewport.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct Viewport: VulkanTypeWrapper {
4 | public var x: Float
5 | public var y: Float
6 | public var width: Float
7 | public var height: Float
8 | public var minDepth: Float
9 | public var maxDepth: Float
10 |
11 |
12 |
13 | public init(
14 | x: Float,
15 | y: Float,
16 | width: Float,
17 | height: Float,
18 | minDepth: Float,
19 | maxDepth: Float
20 | ) {
21 | self.x = x
22 | self.y = y
23 | self.width = width
24 | self.height = height
25 | self.minDepth = minDepth
26 | self.maxDepth = maxDepth
27 | }
28 |
29 | public var vulkan: VkViewport {
30 | mutating get {
31 |
32 | return VkViewport(
33 | x: x.vulkan,
34 | y: y.vulkan,
35 | width: width.vulkan,
36 | height: height.vulkan,
37 | minDepth: minDepth.vulkan,
38 | maxDepth: maxDepth.vulkan
39 | )
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/WriteDescriptorSet.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct WriteDescriptorSet: VulkanTypeWrapper {
4 | public var next: Any?
5 | /** Destination descriptor set */
6 | public var dstSet: DescriptorSet
7 | /** Binding within the destination descriptor set to write */
8 | public var dstBinding: UInt32
9 | /** Array element within the destination binding to write */
10 | public var dstArrayElement: UInt32
11 | /** Number of descriptors to write (determines the size of the array pointed by pDescriptors) */
12 | public var descriptorCount: UInt32
13 | /** Descriptor type to write (determines which members of the array pointed by pDescriptors are going to be used) */
14 | public var descriptorType: DescriptorType
15 | public var imageInfo: [DescriptorImageInfo]
16 | public var bufferInfo: [DescriptorBufferInfo]
17 | public var texelBufferView: [BufferView]
18 |
19 | var vNext: [Any]? = nil
20 | var vImageInfo: [VkDescriptorImageInfo]? = nil
21 | var vBufferInfo: [VkDescriptorBufferInfo]? = nil
22 | var vTexelBufferView: [VkBufferView?]? = nil
23 |
24 | public init(
25 | next: Any? = nil,
26 | dstSet: DescriptorSet,
27 | dstBinding: UInt32,
28 | dstArrayElement: UInt32,
29 | descriptorCount: UInt32,
30 | descriptorType: DescriptorType,
31 | imageInfo: [DescriptorImageInfo],
32 | bufferInfo: [DescriptorBufferInfo],
33 | texelBufferView: [BufferView]
34 | ) {
35 | self.next = next
36 | self.dstSet = dstSet
37 | self.dstBinding = dstBinding
38 | self.dstArrayElement = dstArrayElement
39 | self.descriptorCount = descriptorCount
40 | self.descriptorType = descriptorType
41 | self.imageInfo = imageInfo
42 | self.bufferInfo = bufferInfo
43 | self.texelBufferView = texelBufferView
44 | }
45 |
46 | public var vulkan: VkWriteDescriptorSet {
47 | mutating get {
48 | vNext = next == nil ? nil : [next!]
49 | vImageInfo = imageInfo.vulkanArray
50 | vBufferInfo = bufferInfo.vulkanArray
51 | vTexelBufferView = texelBufferView.vulkanArray
52 | return VkWriteDescriptorSet(
53 | sType: VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
54 | pNext: vNext,
55 | dstSet: dstSet.vulkan,
56 | dstBinding: dstBinding.vulkan,
57 | dstArrayElement: dstArrayElement.vulkan,
58 | descriptorCount: descriptorCount.vulkan,
59 | descriptorType: descriptorType.vulkan,
60 | pImageInfo: vImageInfo,
61 | pBufferInfo: vBufferInfo,
62 | pTexelBufferView: vTexelBufferView
63 | )
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Generated/WriteDescriptorSetAccelerationStructureKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct WriteDescriptorSetAccelerationStructureKHR: VulkanTypeWrapper {
4 | public var next: Any?
5 | public var accelerationStructures: [AccelerationStructureKHR]
6 |
7 | var vNext: [Any]? = nil
8 | var vAccelerationStructures: [VkAccelerationStructureKHR?]? = nil
9 |
10 | public init(
11 | next: Any? = nil,
12 | accelerationStructures: [AccelerationStructureKHR]
13 | ) {
14 | self.next = next
15 | self.accelerationStructures = accelerationStructures
16 | }
17 |
18 | public var vulkan: VkWriteDescriptorSetAccelerationStructureKHR {
19 | mutating get {
20 | vNext = next == nil ? nil : [next!]
21 | vAccelerationStructures = accelerationStructures.vulkanArray
22 | return VkWriteDescriptorSetAccelerationStructureKHR(
23 | sType: VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR,
24 | pNext: vNext,
25 | accelerationStructureCount: UInt32(accelerationStructures.count),
26 | pAccelerationStructures: vAccelerationStructures
27 | )
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Helpers/Array+VulkanEnumTypeWrapper.swift:
--------------------------------------------------------------------------------
1 | extension Array where Element: VulkanEnumTypeWrapper {
2 | public var vulkan: [Element.Wrapped] {
3 | get {
4 | var result = [Element.Wrapped]()
5 | for index in 0.. {
11 | let result = UnsafeMutableBufferPointer.allocate(capacity: count)
12 | _ = result.initialize(from: self.vulkan)
13 | return UnsafePointer(result.baseAddress!)
14 | }
15 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Helpers/HandleObjectWrapper.swift:
--------------------------------------------------------------------------------
1 | public class HandleObjectWrapper: WrapperStruct {
2 | public var underlyingHandle: UnderlyingHandle
3 | public private(set) var destroyed = false
4 |
5 | public init(underlyingHandle: UnderlyingHandle) {
6 | self.underlyingHandle = underlyingHandle
7 | }
8 |
9 | public final func destroy() {
10 | destroyUnderlying()
11 | destroyed = true
12 | }
13 |
14 | public func destroyUnderlying() {
15 | fatalError("destroyUnderlying() not implemented")
16 | }
17 |
18 | public var vulkan: UnderlyingHandle? {
19 | underlyingHandle
20 | }
21 |
22 | deinit {
23 | if !destroyed {
24 | print("a wrapper class got deinitialized before the underlying vulkan object was explicitly destroyed: \(self)")
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Helpers/VkResult+WrapperStruct.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | extension VkResult: WrapperStruct {
4 | public var vulkan: VkResult {
5 | self
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Helpers/VulkanEnumTypeWrapper.swift:
--------------------------------------------------------------------------------
1 | public protocol VulkanEnumTypeWrapper {
2 | associatedtype Wrapped
3 |
4 | var vulkan: Wrapped { get }
5 | var vulkanArray: [Wrapped] { get }
6 | }
7 |
8 | extension VulkanEnumTypeWrapper {
9 | public var vulkan: Wrapped {
10 | get {
11 | fatalError("expVulkan not implemented")
12 | }
13 | }
14 |
15 | public var vulkanArray: [Wrapped] {
16 | get {
17 | [vulkan]
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Helpers/VulkanHandleTypeWrapper.swift:
--------------------------------------------------------------------------------
1 | public class VulkanHandleTypeWrapper {
2 | public private(set) var destroyed = false
3 |
4 | public final func destroy() {
5 | if !destroyed {
6 | destroyUnderlying()
7 | destroyed = true
8 | }
9 | }
10 |
11 | public func destroyUnderlying() {
12 | fatalError("destroyUnderlying() not implemented")
13 | }
14 |
15 | deinit {
16 | if !destroyed {
17 | print("a wrapper class got deinitialized before the underlying vulkan object was explicitly destroyed: \(self)")
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Helpers/VulkanTypeWrapper.swift:
--------------------------------------------------------------------------------
1 | public protocol AnyVulkanTypeWrapper {
2 | var anyVulkan: Any { mutating get }
3 | var anyVulkanArray: [Any] { mutating get }
4 | }
5 |
6 | public protocol VulkanTypeWrapper: AnyVulkanTypeWrapper {
7 | associatedtype Wrapped
8 |
9 | var vulkan: Wrapped { mutating get }
10 | var vulkanArray: [Wrapped] { mutating get }
11 | }
12 |
13 | extension VulkanTypeWrapper {
14 | public var vulkan: Wrapped {
15 | mutating get {
16 | fatalError("expVulkan not implemented")
17 | }
18 | }
19 |
20 | public var anyVulkan: Any {
21 | mutating get {
22 | vulkan
23 | }
24 | }
25 |
26 | public var vulkanArray: [Wrapped] {
27 | mutating get {
28 | [vulkan]
29 | }
30 | }
31 |
32 | public var anyVulkanArray: [Any] {
33 | mutating get {
34 | vulkanArray
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Helpers/WrapperFlag.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public protocol WrapperFlag: ExpressibleByIntegerLiteral, Hashable {
4 | var value: UInt32 { get }
5 |
6 | init(integerLiteral value: UInt32)
7 | }
8 |
9 | extension Set: WrapperStruct where Element: WrapperFlag {
10 | public var vulkan: VkFlags {
11 | VkFlags(reduce(0 as UInt32) { $0 | $1.value })
12 | }
13 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Helpers/WrapperStruct.swift:
--------------------------------------------------------------------------------
1 | @available(deprecated, message: "use VulkanTypeWrapper")
2 | public protocol WrapperStruct {
3 | associatedtype Wrapped
4 |
5 | var vulkan: Wrapped { get }
6 | var expVulkan: Wrapped { mutating get }
7 |
8 | func withVulkan(_ block: (Wrapped) -> ())
9 | }
10 |
11 | extension WrapperStruct {
12 | public var vulkanPointer: UnsafePointer {
13 | let result = UnsafeMutablePointer.allocate(capacity: 1)
14 | result.initialize(to: vulkan)
15 | return UnsafePointer(result)
16 | }
17 |
18 | public var expVulkan: Wrapped {
19 | mutating get {
20 | fatalError("expVulkan not implemented")
21 | }
22 | }
23 |
24 | public var vulkanArray: [Wrapped] {
25 | mutating get {
26 | [expVulkan]
27 | }
28 | }
29 |
30 | public func withVulkan(_ block: (Wrapped) -> ()) {
31 | fatalError("withVulkan() not implemented for: \(self)")
32 | }
33 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Image.swift:
--------------------------------------------------------------------------------
1 |
2 | import CVulkan
3 |
4 | public class Image: VulkanHandleTypeWrapper {
5 | public let pointer: VkImage
6 | public let device: Device
7 | let swapchain: Swapchain?
8 |
9 | var boundMemory: DeviceMemory? = nil
10 |
11 | init(fromVulkan pointer: VkImage,
12 | device: Device,
13 | swapchain: Swapchain?) {
14 | self.pointer = pointer
15 | self.device = device
16 | self.swapchain = swapchain
17 | }
18 |
19 | public var vulkan: VkImage {
20 | pointer
21 | }
22 |
23 | public class func create(withInfo createInfo: ImageCreateInfo,
24 | device: Device) throws -> Image {
25 |
26 | var image = VkImage(bitPattern: 0)
27 | let opResult = withUnsafePointer(to: createInfo.vulkan) {
28 | return vkCreateImage(device.pointer, $0, nil, &image)
29 | }
30 |
31 | guard opResult == VK_SUCCESS else {
32 | throw opResult.toResult()
33 | }
34 |
35 | return Image(fromVulkan: image!, device: device, swapchain: nil)
36 | }
37 |
38 | public func bindMemory(memory: DeviceMemory) throws {
39 | let opResult = vkBindImageMemory(self.device.pointer, self.pointer, memory.pointer, 0)
40 |
41 | guard opResult == VK_SUCCESS else {
42 | throw opResult.toResult()
43 | }
44 |
45 | self.boundMemory = memory
46 | }
47 |
48 | public lazy var memoryRequirements: MemoryRequirements = {
49 | var memReqs = [VkMemoryRequirements()]
50 | vkGetImageMemoryRequirements(self.device.pointer, self.pointer, &memReqs)
51 |
52 | return MemoryRequirements(memReqs[0])
53 | }()
54 |
55 | override public func destroyUnderlying() {
56 | // if this image belongs to a swapchain, it will be destroyed along with it
57 | vkDestroyImage(self.device.pointer, self.pointer, nil)
58 | }
59 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/ImageView.swift:
--------------------------------------------------------------------------------
1 |
2 | import CVulkan
3 |
4 | public class ImageView: VulkanHandleTypeWrapper, WrapperStruct {
5 | public let pointer: VkImageView
6 | public let device: Device
7 |
8 | private var image: Image
9 |
10 | init(pointer: VkImageView,
11 | device: Device,
12 | image: Image) {
13 | self.pointer = pointer
14 | self.device = device
15 | self.image = image
16 | }
17 |
18 | public class func create(device dev: Device,
19 | createInfo: ImageViewCreateInfo) throws -> ImageView {
20 | var imageView = VkImageView(bitPattern: 0)
21 |
22 | var mutCreateInfo = createInfo
23 | let opResult = withUnsafePointer(to: mutCreateInfo.vulkan) {
24 | return vkCreateImageView(dev.pointer, $0, nil, &imageView)
25 | }
26 |
27 | guard opResult == VK_SUCCESS else {
28 | throw opResult.toResult()
29 | }
30 |
31 | return ImageView(pointer: imageView!, device: dev, image: createInfo.image)
32 | }
33 |
34 | public var vulkan: VkImageView? {
35 | Optional(pointer)
36 | }
37 |
38 | override public func destroyUnderlying() {
39 | vkDestroyImageView(self.device.pointer, self.pointer, nil)
40 | }
41 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/AccelerationStructureGeometryDataKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum AccelerationStructureGeometryDataKHR: VulkanTypeWrapper {
4 | case triangles(AccelerationStructureGeometryTrianglesDataKHR)
5 | case aabbs(AccelerationStructureGeometryAabbsDataKHR)
6 | case instances(AccelerationStructureGeometryInstancesDataKHR)
7 |
8 |
9 |
10 | public var vulkan: VkAccelerationStructureGeometryDataKHR {
11 | mutating get {
12 | switch self {
13 | case var .triangles(value):
14 | return VkAccelerationStructureGeometryDataKHR(triangles: value.vulkan)
15 | case var .aabbs(value):
16 | return VkAccelerationStructureGeometryDataKHR(aabbs: value.vulkan)
17 | case var .instances(value):
18 | return VkAccelerationStructureGeometryDataKHR(instances: value.vulkan)
19 | }
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/ClearValue.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public protocol ClearValue: VulkanTypeWrapper {
4 | }
5 |
6 | extension ClearValue where Wrapped == VkClearValue {
7 | public func eraseToAny() -> AnyClearValue {
8 | AnyClearValue(self)
9 | }
10 | }
11 |
12 | public struct AnyClearValue: ClearValue {
13 | private let getVulkan: () -> VkClearValue
14 |
15 | public init(_ wrapped: T) where T.Wrapped == VkClearValue {
16 | var wrapped = wrapped
17 | self.getVulkan = { wrapped.vulkan }
18 | }
19 |
20 | public var vulkan: VkClearValue {
21 | getVulkan()
22 | }
23 | }
24 |
25 | public enum ClearColorValue: ClearValue {
26 | case float32(Float, Float, Float, Float),
27 | int32(Int32, Int32, Int32, Int32),
28 | uint32(UInt32, UInt32, UInt32, UInt32)
29 |
30 | public var vulkan: VkClearValue {
31 | switch self {
32 | case let .float32(f1, f2, f3, f4):
33 | return VkClearValue(color: VkClearColorValue(
34 | float32: (f1, f2, f3, f4)
35 | ))
36 | case let .int32(f1, f2, f3, f4):
37 | return VkClearValue(color: VkClearColorValue(
38 | int32: (f1, f2, f3, f4)
39 | ))
40 | case let .uint32(f1, f2, f3, f4):
41 | return VkClearValue(color: VkClearColorValue(
42 | uint32: (f1, f2, f3, f4)
43 | ))
44 | }
45 | }
46 | }
47 |
48 | public struct ClearDepthStencilValue: ClearValue {
49 | public var depth: Float
50 | public var stencil: UInt32
51 |
52 | public init(
53 | depth: Float,
54 | stencil: UInt32
55 | ) {
56 | self.depth = depth
57 | self.stencil = stencil
58 | }
59 |
60 | public var vulkan: VkClearValue {
61 | VkClearValue(depthStencil: VkClearDepthStencilValue(
62 | depth: depth,
63 | stencil: stencil
64 | ))
65 | }
66 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/ComponentMapping+identity.swift:
--------------------------------------------------------------------------------
1 | extension ComponentMapping {
2 | public static var identity: ComponentMapping {
3 | ComponentMapping(r: .r, g: .g, b: .b, a: .a)
4 | }
5 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/DeviceAddress.swift:
--------------------------------------------------------------------------------
1 | public typealias DeviceAddress = UInt64
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/DeviceOrHostAddressConstKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum DeviceOrHostAddressConstKHR: VulkanTypeWrapper {
4 | case none
5 | case device(DeviceAddress)
6 | case host(UnsafeRawPointer?)
7 |
8 | public var vulkan: VkDeviceOrHostAddressConstKHR {
9 | mutating get {
10 | switch self {
11 | case .none:
12 | return VkDeviceOrHostAddressConstKHR()
13 | case let .device(addr):
14 | return VkDeviceOrHostAddressConstKHR(
15 | deviceAddress: addr)
16 | case let .host(addr):
17 | return VkDeviceOrHostAddressConstKHR(
18 | hostAddress: addr)
19 | }
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/DeviceOrHostAddressKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum DeviceOrHostAddressKHR: VulkanTypeWrapper {
4 | case none
5 | case device(DeviceAddress)
6 | case host(UnsafeMutableRawPointer?)
7 |
8 | public var vulkan: VkDeviceOrHostAddressKHR {
9 | mutating get {
10 | switch self {
11 | case .none:
12 | return VkDeviceOrHostAddressKHR()
13 | case let .device(addr):
14 | return VkDeviceOrHostAddressKHR(
15 | deviceAddress: addr)
16 | case let .host(addr):
17 | return VkDeviceOrHostAddressKHR(
18 | hostAddress: addr)
19 | }
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/Flags/BufferUsageFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct BufferUsageFlags: OptionSet {
4 | public let rawValue: UInt32
5 |
6 | public init(rawValue: UInt32) {
7 | self.rawValue = rawValue
8 | }
9 |
10 | public static let none = BufferUsageFlags(rawValue: 0)
11 | public static let transferSrc = BufferUsageFlags(rawValue: 0x00000001)
12 | public static let transferDst = BufferUsageFlags(rawValue: 0x00000002)
13 | public static let uniformTexelBuffer = BufferUsageFlags(rawValue: 0x00000004)
14 | public static let storageTexelBuffer = BufferUsageFlags(rawValue: 0x00000008)
15 | public static let uniformBuffer = BufferUsageFlags(rawValue: 0x00000010)
16 | public static let storageBuffer = BufferUsageFlags(rawValue: 0x00000020)
17 | public static let indexBuffer = BufferUsageFlags(rawValue: 0x00000040)
18 | public static let vertexBuffer = BufferUsageFlags(rawValue: 0x00000080)
19 | public static let indirectBuffer = BufferUsageFlags(rawValue: 0x00000100)
20 | public static let transformFeedbackBuffer = BufferUsageFlags(rawValue: 0x00000800)
21 | public static let transformFeedbackCounterBuffer = BufferUsageFlags(rawValue: 0x00001000)
22 | public static let conditionalRendering = BufferUsageFlags(rawValue: 0x00000200)
23 | public static let rayTracing = BufferUsageFlags(rawValue: 0x00000400)
24 | public static let shaderDeviceAddress = BufferUsageFlags(rawValue: 0x00020000)
25 | public static let accelerationStructureStorageKhr = BufferUsageFlags(rawValue: 0x00100000)
26 | public static let accelerationStructureBuildInputReadOnlyKhr = BufferUsageFlags(rawValue: 0x00080000)
27 |
28 | public var vulkan: VkBufferUsageFlags {
29 | return VkBufferUsageFlags(self.rawValue)
30 | }
31 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/Flags/ShaderStageFlags+Raytracing.swift:
--------------------------------------------------------------------------------
1 | extension ShaderStageFlags {
2 | public static var raygenKhr: Self {
3 | Self(rawValue: 0x00000100)
4 | }
5 |
6 | public static var closestHitKhr: Self {
7 | Self(rawValue: 0x00000400)
8 | }
9 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/RenderPassBeginInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct RenderPassBeginInfo: VulkanTypeWrapper {
4 | public var renderPass: RenderPass
5 | public var framebuffer: Framebuffer
6 | public var renderArea: Rect2D
7 | public var clearValues: [AnyClearValue]
8 |
9 | var vClearValues: [VkClearValue]? = nil
10 |
11 | public init(
12 | renderPass: RenderPass,
13 | framebuffer: Framebuffer,
14 | renderArea: Rect2D,
15 | clearValues: [AnyClearValue]
16 | ) {
17 | self.renderPass = renderPass
18 | self.framebuffer = framebuffer
19 | self.renderArea = renderArea
20 | self.clearValues = clearValues
21 | }
22 |
23 | public var vulkan: VkRenderPassBeginInfo {
24 | mutating get {
25 | vClearValues = clearValues.vulkanArray
26 | return VkRenderPassBeginInfo(
27 | sType: VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
28 | pNext: nil,
29 | renderPass: renderPass.vulkan,
30 | framebuffer: framebuffer.vulkan,
31 | renderArea: renderArea.vulkan,
32 | clearValueCount: UInt32(clearValues.count),
33 | pClearValues: vClearValues
34 | )
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/SizeT.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public typealias SizeT = Int
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/SpecializationInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct SpecializationInfo: VulkanTypeWrapper {
4 | /** Number of entries in the map */
5 | public var mapEntryCount: UInt32?
6 | public var mapEntries: [SpecializationMapEntry]
7 | /** Size in bytes of pData */
8 |
9 |
10 | var vMapEntries: [VkSpecializationMapEntry]? = nil
11 |
12 | public init(
13 | mapEntryCount: UInt32? = nil,
14 | mapEntries: [SpecializationMapEntry]
15 | ) {
16 | self.mapEntryCount = mapEntryCount
17 | self.mapEntries = mapEntries
18 | }
19 |
20 | public var vulkan: VkSpecializationInfo {
21 | mutating get {
22 | vMapEntries = mapEntries.vulkanArray
23 | return VkSpecializationInfo(
24 | mapEntryCount: mapEntryCount?.vulkan ?? 0,
25 | pMapEntries: vMapEntries,
26 | dataSize: 0,
27 | pData: nil
28 | )
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/StencilOpState+DontCare.swift:
--------------------------------------------------------------------------------
1 | extension StencilOpState {
2 | /** can use this value if the stencil op state does not need
3 | to be explicitly configured */
4 | public static var dontCare: StencilOpState {
5 | StencilOpState(
6 | failOp: .zero,
7 | passOp: .zero,
8 | depthFailOp: .zero,
9 | compareOp: .never,
10 | compareMask: 0,
11 | writeMask: 0,
12 | reference: 0
13 | )
14 | }
15 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/StructTypes/AccelerationStructureCreateInfoKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct AccelerationStructureCreateInfoKHR: VulkanTypeWrapper {
4 | public var createFlags: AccelerationStructureCreateFlagsKHR?
5 | public var buffer: Buffer
6 | /** Specified in bytes */
7 | public var offset: DeviceSize
8 | public var size: DeviceSize
9 | public var type: AccelerationStructureTypeKHR
10 | public var deviceAddress: DeviceAddress?
11 |
12 |
13 |
14 | public init(
15 | createFlags: AccelerationStructureCreateFlagsKHR? = nil,
16 | buffer: Buffer,
17 | offset: DeviceSize,
18 | size: DeviceSize,
19 | type: AccelerationStructureTypeKHR,
20 | deviceAddress: DeviceAddress? = nil
21 | ) {
22 | self.createFlags = createFlags
23 | self.buffer = buffer
24 | self.offset = offset
25 | self.size = size
26 | self.type = type
27 | self.deviceAddress = deviceAddress
28 | }
29 |
30 | public var vulkan: VkAccelerationStructureCreateInfoKHR {
31 | mutating get {
32 |
33 | return VkAccelerationStructureCreateInfoKHR(
34 | sType: VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_KHR,
35 | pNext: nil,
36 | createFlags: createFlags?.vulkan ?? 0,
37 | buffer: buffer.vulkan,
38 | offset: offset.vulkan,
39 | size: size.vulkan,
40 | type: type.vulkan,
41 | deviceAddress: deviceAddress?.vulkan ?? 0
42 | )
43 | }
44 | }
45 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Manual/StructTypes/TransformMatrixKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct TransformMatrixKHR: VulkanTypeWrapper {
4 | public var matrix: [[Float]] {
5 | didSet {
6 | assertSize()
7 | }
8 | }
9 |
10 | public init(matrix: [[Float]]) {
11 | self.matrix = matrix
12 | assertSize()
13 | }
14 |
15 | private func assertSize() {
16 | assert(matrix.count == 3, "matrix must have 3 rows, has \(matrix.count)")
17 | for i in 0..<3 {
18 | assert(matrix[i].count == 4, "matrix row \(i) has \(matrix[i].count) columns instead of 4")
19 | }
20 | }
21 |
22 | public var vulkan: VkTransformMatrixKHR {
23 | VkTransformMatrixKHR(matrix: (
24 | (matrix[0][0], matrix[0][1], matrix[0][2], matrix[0][3]),
25 | (matrix[1][0], matrix[1][1], matrix[1][2], matrix[1][3]),
26 | (matrix[2][0], matrix[2][1], matrix[2][2], matrix[2][3])
27 | ))
28 | }
29 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/AttachmentDescription.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct AttachmentDescription: WrapperStruct {
4 | public var flags: AttachmentDescriptionFlags
5 | public var format: Format
6 | public var samples: OldSampleCountFlags
7 | public var loadOp: AttachmentLoadOp
8 | public var storeOp: AttachmentStoreOp
9 | public var stencilLoadOp: AttachmentLoadOp
10 | public var stencilStoreOp: AttachmentStoreOp
11 | public var initialLayout: ImageLayout
12 | public var finalLayout: ImageLayout
13 |
14 | public init(flags: AttachmentDescriptionFlags,
15 | format: Format,
16 | samples: OldSampleCountFlags,
17 | loadOp: AttachmentLoadOp,
18 | storeOp: AttachmentStoreOp,
19 | stencilLoadOp: AttachmentLoadOp,
20 | stencilStoreOp: AttachmentStoreOp,
21 | initialLayout: ImageLayout,
22 | finalLayout: ImageLayout) {
23 | self.flags = flags
24 | self.format = format
25 | self.samples = samples
26 | self.loadOp = loadOp
27 | self.storeOp = storeOp
28 | self.stencilLoadOp = stencilLoadOp
29 | self.stencilStoreOp = stencilStoreOp
30 | self.initialLayout = initialLayout
31 | self.finalLayout = finalLayout
32 | }
33 |
34 | public var vulkan: VkAttachmentDescription {
35 | return VkAttachmentDescription(
36 | flags: self.flags.vulkanValue,
37 | format: self.format.vulkan,
38 | samples: self.samples.vulkanValue,
39 | loadOp: self.loadOp.vulkanValue,
40 | storeOp: self.storeOp.vulkanValue,
41 | stencilLoadOp: self.stencilLoadOp.vulkanValue,
42 | stencilStoreOp: self.stencilStoreOp.vulkanValue,
43 | initialLayout: self.initialLayout.vulkan,
44 | finalLayout: self.finalLayout.vulkan
45 | )
46 | }
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/AttachmentReference.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct AttachmentReference: WrapperStruct {
4 | public let attachment: UInt32
5 | public let layout: ImageLayout
6 |
7 | public init(attachment: UInt32, layout: ImageLayout) {
8 | self.attachment = attachment
9 | self.layout = layout
10 | }
11 |
12 | public var vulkan: VkAttachmentReference {
13 | VkAttachmentReference(attachment: self.attachment, layout: self.layout.vulkan)
14 | }
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/DescriptorSetLayoutCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct DescriptorSetLayoutCreateFlags: OptionSet {
4 | public let rawValue: UInt32
5 |
6 | public init(rawValue: UInt32) {
7 | self.rawValue = rawValue
8 | }
9 |
10 | public var vulkan: UInt32 {
11 | rawValue
12 | }
13 |
14 | public static let none = Self(rawValue: 0)
15 | public static let pushDescriptor = Self(rawValue: 0x00000001)
16 | public static let updateAfterBindPool = Self(rawValue: 0x00000002)
17 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/Extent2D.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct Extent2D: WrapperStruct {
4 | public var width: UInt32
5 | public var height: UInt32
6 |
7 | public init() {
8 | self.width = 0
9 | self.height = 0
10 | }
11 |
12 | public init(width: UInt32, height: UInt32) {
13 | self.width = width
14 | self.height = height
15 | }
16 |
17 | init(fromVulkan extent: VkExtent2D) {
18 | self.width = extent.width
19 | self.height = extent.height
20 | }
21 |
22 | public var vulkan: VkExtent2D {
23 | return VkExtent2D(width: self.width, height: self.height)
24 | }
25 |
26 | public func to3D(withDepth depth: UInt32) -> Extent3D {
27 | return Extent3D(width: self.width, height: self.height, depth: depth)
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/FramebufferCreateFlags.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct FramebufferCreateFlag: WrapperFlag {
4 | public let value: UInt32
5 |
6 | public init(integerLiteral value: UInt32) {
7 | self.value = value
8 | }
9 |
10 | public static let imageless = Self(integerLiteral: VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT.rawValue)
11 | public static let imagelessKhr = Self(integerLiteral: VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR.rawValue)
12 | }
13 |
14 | public typealias FramebufferCreateFlags = Set
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/Offset2D.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct Offset2D: WrapperStruct {
4 | public let x: Int32
5 | public let y: Int32
6 |
7 | public init(x: Int32, y: Int32) {
8 | self.x = x
9 | self.y = y
10 | }
11 |
12 | public var vulkan: VkOffset2D {
13 | VkOffset2D(
14 | x: x,
15 | y: y
16 | )
17 | }
18 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/PresentInfoKHR.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public class PresentInfoKHR: WrapperStruct {
4 | public var waitSemaphores: [Semaphore]
5 | public var swapchains: [Swapchain]
6 | public var imageIndices: [UInt32]
7 | public var results: Void
8 |
9 | public init(
10 | waitSemaphores: [Semaphore],
11 | swapchains: [Swapchain],
12 | imageIndices: [UInt32],
13 | results: Void
14 | ) {
15 | self.waitSemaphores = waitSemaphores
16 | self.swapchains = swapchains
17 | self.imageIndices = imageIndices
18 | self.results = results
19 | }
20 |
21 | public var vulkan: VkPresentInfoKHR {
22 | VkPresentInfoKHR(
23 | sType: VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
24 | pNext: nil,
25 | waitSemaphoreCount: UInt32(waitSemaphores.count),
26 | pWaitSemaphores: waitSemaphores.vulkanPointer,
27 | swapchainCount: UInt32(swapchains.count),
28 | pSwapchains: swapchains.vulkanPointer,
29 | pImageIndices: imageIndices.vulkanPointer,
30 | pResults: nil
31 | )
32 | }
33 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/Result.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public enum Result: Int32, Error {
4 | case success = 0,
5 | notReady = 1,
6 | timeout = 2,
7 | eventSet = 3,
8 | eventReset = 4,
9 | incomplete = 5,
10 | errorOutOfHostMemory = -1,
11 | errorOutOfDeviceMemory = -2,
12 | errorInitializationFailed = -3,
13 | errorDeviceLost = -4,
14 | errorMemoryMapFailed = -5,
15 | errorLayerNotPresent = -6,
16 | errorExtensionNotPresent = -7,
17 | errorFeatureNotPresent = -8,
18 | errorIncompatibleDriver = -9,
19 | errorTooManyObjects = -10,
20 | errorFormatNotSupported = -11,
21 | errorFragmentedPool = -12,
22 | errorOutOfPoolMemory = -1000069000,
23 | errorInvalidExternalHandle = -1000072003,
24 | errorSurfaceLostKhr = -1000000000,
25 | errorNativeWindowInUseKhr = -1000000001,
26 | suboptimalKhr = 1000001003,
27 | errorOutOfDateKhr = -1000001004,
28 | errorIncompatibleDisplayKhr = -1000003001,
29 | errorValidationFailedExt = -1000011001,
30 | errorInvalidShaderNv = -1000012000,
31 | errorInvalidDrmFormatModifierPlaneLayoutExt = -1000158000,
32 | errorFragmentationExt = -1000161000,
33 | errorNotPermittedExt = -1000174001
34 |
35 | // synonyms
36 | static let errorOutOfPoolMemoryKhr = errorOutOfPoolMemory
37 | static let errorInvalidExternalHandleKhr = errorInvalidExternalHandle
38 | }
39 |
40 | extension VkResult {
41 | @available(deprecated, message: "use .toSwift()")
42 | public func toResult() -> Result {
43 | return Result(rawValue: self.rawValue)!
44 | }
45 |
46 | public func toSwift() -> Result {
47 | toResult()
48 | }
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/SampleMask.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct SampleMask: VulkanTypeWrapper {
4 | public var rawValue: UInt32
5 |
6 | public init(_ rawValue: UInt32) {
7 | self.rawValue = rawValue
8 | }
9 |
10 | public var vulkan: VkSampleMask {
11 | mutating get {
12 | VkSampleMask(rawValue)
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/SubmitInfo.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct SubmitInfo: WrapperStruct {
4 | public var waitSemaphores: [Semaphore]
5 | public var waitDstStageMask: [PipelineStageFlags]?
6 | public var commandBuffers: [CommandBuffer]
7 | public var signalSemaphores: [Semaphore]
8 |
9 | public init(
10 | waitSemaphores: [Semaphore],
11 | waitDstStageMask: [PipelineStageFlags]?,
12 | commandBuffers: [CommandBuffer],
13 | signalSemaphores: [Semaphore]
14 | ) {
15 | self.waitSemaphores = waitSemaphores
16 | self.waitDstStageMask = waitDstStageMask
17 | self.commandBuffers = commandBuffers
18 | self.signalSemaphores = signalSemaphores
19 | }
20 |
21 | public var vulkan: VkSubmitInfo {
22 | let test = VkSubmitInfo(
23 | sType: VK_STRUCTURE_TYPE_SUBMIT_INFO,
24 | pNext: nil,
25 | waitSemaphoreCount: UInt32(waitSemaphores.count),
26 | pWaitSemaphores: waitSemaphores.vulkanPointer,
27 | pWaitDstStageMask: waitDstStageMask?.vulkanPointer,
28 | commandBufferCount: UInt32(commandBuffers.count),
29 | pCommandBuffers: commandBuffers.vulkanPointer,
30 | signalSemaphoreCount: UInt32(signalSemaphores.count),
31 | pSignalSemaphores: signalSemaphores.vulkanPointer
32 | )
33 |
34 | return test
35 | }
36 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/SubpassDependency.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public struct SubpassDependency: WrapperStruct {
4 | public let srcSubpass: UInt32
5 | public let dstSubpass: UInt32
6 | public let srcStageMask: PipelineStageFlags
7 | public let dstStageMask: PipelineStageFlags
8 | public let srcAccessMask: AccessFlags
9 | public let dstAccessMask: AccessFlags
10 | public let dependencyFlags: DependencyFlags
11 |
12 | public init(srcSubpass: UInt32,
13 | dstSubpass: UInt32,
14 | srcStageMask: PipelineStageFlags,
15 | dstStageMask: PipelineStageFlags,
16 | srcAccessMask: AccessFlags,
17 | dstAccessMask: AccessFlags,
18 | dependencyFlags: DependencyFlags) {
19 | self.srcSubpass = srcSubpass
20 | self.dstSubpass = dstSubpass
21 | self.srcStageMask = srcStageMask
22 | self.dstStageMask = dstStageMask
23 | self.srcAccessMask = srcAccessMask
24 | self.dstAccessMask = dstAccessMask
25 | self.dependencyFlags = dependencyFlags
26 | }
27 |
28 | public var vulkan: VkSubpassDependency {
29 | return VkSubpassDependency(
30 | srcSubpass: self.srcSubpass,
31 | dstSubpass: self.dstSubpass,
32 | srcStageMask: self.srcStageMask.rawValue,
33 | dstStageMask: self.dstStageMask.rawValue,
34 | srcAccessMask: self.srcAccessMask.rawValue,
35 | dstAccessMask: self.dstAccessMask.rawValue,
36 | dependencyFlags: self.dependencyFlags.rawValue
37 | )
38 | }
39 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/SubpassDescription.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public class SubpassDescription: WrapperStruct {
4 | public let flags: SubpassDescriptionFlags
5 | public let pipelineBindPoint: PipelineBindPoint
6 | public let inputAttachments: [AttachmentReference]?
7 | public let colorAttachments: [AttachmentReference]?
8 | public let resolveAttachments: [AttachmentReference]?
9 | public let depthStencilAttachment: AttachmentReference?
10 | public let preserveAttachments: [UInt32]?
11 |
12 | public init(flags: SubpassDescriptionFlags,
13 | pipelineBindPoint: PipelineBindPoint,
14 | inputAttachments: [AttachmentReference]?,
15 | colorAttachments: [AttachmentReference]?,
16 | resolveAttachments: [AttachmentReference]?,
17 | depthStencilAttachment: AttachmentReference?,
18 | preserveAttachments: [UInt32]?) {
19 | self.flags = flags
20 | self.pipelineBindPoint = pipelineBindPoint
21 | self.inputAttachments = inputAttachments
22 | self.colorAttachments = colorAttachments
23 | self.resolveAttachments = resolveAttachments
24 | self.depthStencilAttachment = depthStencilAttachment
25 | self.preserveAttachments = preserveAttachments
26 | }
27 |
28 | public var vulkan: VkSubpassDescription {
29 | VkSubpassDescription(
30 | flags: self.flags.rawValue,
31 | pipelineBindPoint: self.pipelineBindPoint.vulkan,
32 | inputAttachmentCount: UInt32(self.inputAttachments?.count ?? 0),
33 | pInputAttachments: inputAttachments?.vulkanPointer,
34 | colorAttachmentCount: UInt32(self.colorAttachments?.count ?? 0),
35 | pColorAttachments: colorAttachments?.vulkanPointer,
36 | pResolveAttachments: resolveAttachments?.vulkanPointer,
37 | pDepthStencilAttachment: depthStencilAttachment?.vulkanPointer,
38 | preserveAttachmentCount: UInt32(self.preserveAttachments?.count ?? 0),
39 | pPreserveAttachments: preserveAttachments?.vulkanPointer
40 | )
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/_oldPipelineColorBlendAttachmentState.swift:
--------------------------------------------------------------------------------
1 | /*import CVulkan
2 |
3 | public struct PipelineColorBlendAttachmentState: WrapperStruct {
4 | public let blendEnable: Bool
5 | public let srcColorBlendFactor: BlendFactor
6 | public let dstColorBlendFactor: BlendFactor
7 | public let colorBlendOp: VkBlendOp
8 | public let srcAlphaBlendFactor: BlendFactor
9 | public let dstAlphaBlendFactor: BlendFactor
10 | public let alphaBlendOp: VkBlendOp
11 | public let colorWriteMask: Set
12 |
13 | public init(
14 | blendEnable: Bool,
15 | srcColorBlendFactor: BlendFactor,
16 | dstColorBlendFactor: BlendFactor,
17 | colorBlendOp: VkBlendOp,
18 | srcAlphaBlendFactor: BlendFactor,
19 | dstAlphaBlendFactor: BlendFactor,
20 | alphaBlendOp: VkBlendOp,
21 | colorWriteMask: Set
22 | ) {
23 | self.blendEnable = blendEnable
24 | self.srcColorBlendFactor = srcColorBlendFactor
25 | self.dstColorBlendFactor = dstColorBlendFactor
26 | self.colorBlendOp = colorBlendOp
27 | self.srcAlphaBlendFactor = srcAlphaBlendFactor
28 | self.dstAlphaBlendFactor = dstAlphaBlendFactor
29 | self.alphaBlendOp = alphaBlendOp
30 | self.colorWriteMask = colorWriteMask
31 | }
32 |
33 | public var vulkan: VkPipelineColorBlendAttachmentState {
34 | VkPipelineColorBlendAttachmentState(
35 | blendEnable: blendEnable.vulkan,
36 | srcColorBlendFactor: srcColorBlendFactor.vulkan,
37 | dstColorBlendFactor: dstColorBlendFactor.vulkan,
38 | colorBlendOp: colorBlendOp,
39 | srcAlphaBlendFactor: srcAlphaBlendFactor.vulkan,
40 | dstAlphaBlendFactor: dstAlphaBlendFactor.vulkan,
41 | alphaBlendOp: alphaBlendOp,
42 | colorWriteMask: colorWriteMask.vulkan
43 | )
44 | }
45 | }*/
--------------------------------------------------------------------------------
/Sources/Vulkan/Other/_oldViewport.swift:
--------------------------------------------------------------------------------
1 | /*
2 | import CVulkan
3 |
4 | public struct Viewport: WrapperStruct {
5 | public let x: Float
6 | public let y: Float
7 | public let width: Float
8 | public let height: Float
9 | public let minDepth: Float
10 | public let maxDepth: Float
11 |
12 | public init(x: Float, y: Float, width: Float, height: Float, minDepth: Float, maxDepth: Float) {
13 | self.x = x
14 | self.y = y
15 | self.width = width
16 | self.height = height
17 | self.minDepth = minDepth
18 | self.maxDepth = maxDepth
19 | }
20 |
21 | public var vulkan: VkViewport {
22 | VkViewport(
23 | x: x,
24 | y: y,
25 | width: width,
26 | height: height,
27 | minDepth: minDepth,
28 | maxDepth: maxDepth
29 | )
30 | }
31 | }*/
--------------------------------------------------------------------------------
/Sources/Vulkan/Pipeline.swift:
--------------------------------------------------------------------------------
1 | import CVulkan
2 |
3 | public class Pipeline: VulkanHandleTypeWrapper {
4 | public let pointer: VkPipeline
5 | public let device: Device
6 |
7 | private init(pointer: VkPipeline, device: Device) {
8 | self.pointer = pointer
9 | self.device = device
10 | }
11 |
12 | public var vulkan: VkPipeline {
13 | pointer
14 | }
15 |
16 | public convenience init(device: Device, createInfo: GraphicsPipelineCreateInfo) throws {
17 | var createInfo = createInfo
18 | var pipelinePointer = VkPipeline(bitPattern: 0)
19 |
20 | var opResult = VK_ERROR_INITIALIZATION_FAILED
21 | withUnsafePointer(to: createInfo.vulkan) {
22 | opResult = vkCreateGraphicsPipelines(device.pointer, nil, 1, $0, nil, &pipelinePointer)
23 | }
24 |
25 | if opResult == VK_SUCCESS {
26 | self.init(pointer: pipelinePointer!, device: device)
27 | return
28 | }
29 |
30 | throw opResult.toResult()
31 | }
32 |
33 | override public func destroyUnderlying() {
34 | vkDestroyPipeline(device.pointer, pointer, nil)
35 | }
36 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/PipelineLayout.swift:
--------------------------------------------------------------------------------
1 |
2 | import CVulkan
3 |
4 | public class PipelineLayout: WrapperStruct {
5 | public var pointer: VkPipelineLayout
6 | public var device: Device
7 |
8 | init(pointer: VkPipelineLayout,
9 | device: Device) {
10 | self.pointer = pointer
11 | self.device = device
12 | }
13 |
14 | public class func create(device: Device, createInfo: PipelineLayoutCreateInfo) throws -> PipelineLayout {
15 | var createInfo = createInfo
16 |
17 | var pipelineLayout = VkPipelineLayout(bitPattern: 0)
18 |
19 | let opResult = withUnsafePointer(to: createInfo.vulkan) {
20 | return vkCreatePipelineLayout(device.pointer, $0, nil, &pipelineLayout)
21 | }
22 |
23 | guard opResult == VK_SUCCESS else {
24 | throw opResult.toResult()
25 | }
26 |
27 | return PipelineLayout(pointer: pipelineLayout!, device: device)
28 | }
29 |
30 | public var vulkan: VkPipelineLayout? {
31 | pointer
32 | }
33 |
34 | deinit {
35 | vkDestroyPipelineLayout(self.device.pointer, self.pointer, nil)
36 | }
37 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Queue.swift:
--------------------------------------------------------------------------------
1 |
2 | import CVulkan
3 |
4 | public class Queue {
5 | public let pointer: VkQueue
6 |
7 | public init(pointer: VkQueue) {
8 | self.pointer = pointer
9 | }
10 |
11 | public class func create(fromDevice device: Device, presentFamilyIndex: UInt32) -> Queue {
12 | var queueArr = [VkQueue?](repeating: VkQueue(bitPattern: 0), count: 1)
13 | vkGetDeviceQueue(device.pointer, UInt32(presentFamilyIndex), 0, &queueArr)
14 |
15 | return Queue(pointer: queueArr[0]!)
16 | }
17 |
18 | public func submit(submits: [SubmitInfo], fence: Fence?) throws {
19 | vkQueueSubmit(pointer, UInt32(submits.count), submits.vulkanPointer, fence?.pointer)
20 | }
21 |
22 | public func present(presentInfo: PresentInfoKHR) -> Result {
23 | vkQueuePresentKHR(pointer, presentInfo.vulkanPointer).toResult()
24 | }
25 |
26 | public func waitIdle() {
27 | vkQueueWaitIdle(pointer)
28 | }
29 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/RenderPass.swift:
--------------------------------------------------------------------------------
1 |
2 | import CVulkan
3 |
4 | public class RenderPass: HandleObjectWrapper {
5 | public let device: Device
6 |
7 | init(underlyingHandle: VkRenderPass, device: Device) {
8 | self.device = device
9 | super.init(underlyingHandle: underlyingHandle)
10 | }
11 |
12 | public class func create(createInfo: RenderPassCreateInfo, device: Device) throws -> RenderPass {
13 | var handle = VkRenderPass(bitPattern: 0)
14 | var vulkanCreateInfo = createInfo
15 | let opResult = withUnsafePointer(to: vulkanCreateInfo.toVulkan()) {
16 | return vkCreateRenderPass(device.pointer, $0, nil, &handle)
17 | }
18 |
19 | guard opResult == VK_SUCCESS else {
20 | throw opResult.toResult()
21 | }
22 |
23 | return RenderPass(underlyingHandle: handle!, device: device)
24 | }
25 |
26 | override public func destroyUnderlying() {
27 | vkDestroyRenderPass(device.pointer, underlyingHandle, nil)
28 | }
29 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Sampler.swift:
--------------------------------------------------------------------------------
1 |
2 | import CVulkan
3 |
4 | public class Sampler: VulkanHandleTypeWrapper, WrapperStruct {
5 | public let pointer: VkSampler
6 | public let device: Device
7 |
8 | init(pointer: VkSampler, device: Device) {
9 | self.pointer = pointer
10 | self.device = device
11 | }
12 |
13 | public convenience init(device: Device, createInfo: SamplerCreateInfo) throws {
14 | var createInfo = createInfo
15 | var pointer = VkInstance(bitPattern: 0)
16 |
17 | var opResult = VK_ERROR_INITIALIZATION_FAILED
18 | withUnsafePointer(to: createInfo.vulkan) {
19 | opResult = vkCreateSampler(device.pointer, $0, nil, &pointer)
20 | }
21 |
22 | if opResult == VK_SUCCESS {
23 | self.init(pointer: pointer!, device: device)
24 | return
25 | }
26 |
27 | throw opResult.toResult()
28 | }
29 |
30 | override public func destroyUnderlying() {
31 | vkDestroySampler(device.pointer, pointer, nil)
32 | }
33 |
34 | public var vulkan: Optional {
35 | Optional(pointer)
36 | }
37 | }
--------------------------------------------------------------------------------
/Sources/Vulkan/Semaphore.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Created by Alexander Ubillus on 2019-02-04.
3 | //
4 |
5 | import Foundation
6 | import CVulkan
7 |
8 | public class Semaphore: WrapperStruct {
9 | public let vulkanValue: VkSemaphore
10 | public let device: Device
11 |
12 | public init(vulkanValue: VkSemaphore, device: Device) {
13 | self.vulkanValue = vulkanValue
14 | self.device = device
15 | }
16 |
17 | public class func create(info: SemaphoreCreateInfo, device: Device) throws -> Semaphore {
18 | var semaphore = VkSemaphore(bitPattern: 0)
19 | let opResult = withUnsafePointer(to: info.vulkan) {
20 | return vkCreateSemaphore(device.pointer, $0, nil, &semaphore)
21 | }
22 |
23 | guard opResult == VK_SUCCESS else {
24 | throw opResult.toResult()
25 | }
26 |
27 | return Semaphore(vulkanValue: semaphore!, device: device)
28 | }
29 |
30 | public var vulkan: Optional {
31 | Optional(vulkanValue)
32 | }
33 |
34 | deinit {
35 | vkDestroySemaphore(self.device.pointer, self.vulkanValue, nil)
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Sources/Vulkan/ShaderModule.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 | import CVulkan
3 |
4 | public class ShaderModule: VulkanHandleTypeWrapper {
5 | public let pointer: VkShaderModule
6 |
7 | let device: Device
8 |
9 | init(rawModule: VkShaderModule, device: Device) {
10 | self.pointer = rawModule
11 | self.device = device
12 | }
13 |
14 | public convenience init(device: Device, createInfo: ShaderModuleCreateInfo) throws {
15 | var vkCreateInfo = VkShaderModuleCreateInfo()
16 | vkCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO
17 | vkCreateInfo.pNext = nil
18 | vkCreateInfo.codeSize = createInfo.code.count
19 |
20 | let codePtr = UnsafeMutableBufferPointer.allocate(capacity: createInfo.code.count / 4)
21 | let copiedCount = createInfo.code.copyBytes(to: codePtr)
22 | vkCreateInfo.pCode = UnsafePointer(codePtr.baseAddress)
23 |
24 | var shaderModulePtr = VkShaderModule(bitPattern: 0)
25 | var opResult = VK_ERROR_INITIALIZATION_FAILED
26 | withUnsafePointer(to: vkCreateInfo) {
27 | opResult = vkCreateShaderModule(device.pointer, $0, nil, &shaderModulePtr)
28 | }
29 |
30 | if opResult == VK_SUCCESS {
31 | self.init(rawModule: shaderModulePtr!, device: device)
32 | return
33 | }
34 |
35 | throw opResult.toResult()
36 | }
37 |
38 | public var vulkan: Optional {
39 | pointer
40 | }
41 |
42 | deinit {
43 | vkDestroyShaderModule(device.pointer, pointer, nil)
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Sources/Vulkan/SurfaceKHR.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Alexander Ubillus. All rights reserved.
3 | // Licensed under the MIT License. See LICENSE file in the project root for full license information.
4 | //
5 |
6 | import CVulkan
7 |
8 | public class SurfaceKHR {
9 |
10 | public let instance: Instance
11 | public let pointer: VkSurfaceKHR
12 |
13 | public init(instance: Instance, pointer: VkSurfaceKHR) {
14 | self.instance = instance
15 | self.pointer = pointer
16 | }
17 |
18 | deinit {
19 | print("Destroying surface")
20 | vkDestroySurfaceKHR(instance.pointer, pointer, nil)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Swapchain.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Alexander Ubillus. All rights reserved.
3 | // Licensed under the MIT License. See LICENSE file in the project root for full license information.
4 | //
5 |
6 | import CVulkan
7 | import Dispatch
8 |
9 | public class Swapchain: VulkanHandleTypeWrapper, WrapperStruct {
10 | public let pointer: VkSwapchainKHR
11 | public let device: Device
12 |
13 | private let surface: SurfaceKHR
14 |
15 | public init(device: Device, pointer: VkSwapchainKHR, surface: SurfaceKHR) {
16 | self.pointer = pointer
17 | self.device = device
18 | self.surface = surface
19 | }
20 |
21 | public var vulkan: Optional {
22 | Optional(pointer)
23 | }
24 |
25 | public class func create(inDevice: Device, createInfo: SwapchainCreateInfo) throws -> Swapchain {
26 | var swapchain = VkSwapchainKHR(bitPattern: 0)
27 |
28 | var opResult = VK_SUCCESS
29 | var infoArr = [createInfo.toVulkan()]
30 |
31 | opResult = vkCreateSwapchainKHR(inDevice.pointer, &infoArr, nil, &swapchain)
32 |
33 | guard opResult == VK_SUCCESS else {
34 | throw opResult.toResult()
35 | }
36 |
37 | return Swapchain(device: inDevice, pointer: swapchain!, surface: createInfo.surface)
38 | }
39 |
40 | public func acquireNextImage(timeout: UInt64, semaphore: Semaphore?,
41 | fence: Fence?) throws -> (UInt32, Result) {
42 | var localImageIndex: UInt32 = 0
43 | let vkResult = vkAcquireNextImageKHR(
44 | self.device.pointer, self.pointer, timeout,
45 | semaphore?.vulkanValue, fence?.pointer, &localImageIndex)
46 |
47 | return (localImageIndex, vkResult.toResult())
48 | }
49 |
50 | public func getSwapchainImages() throws -> [Image] {
51 | var countArr: [UInt32] = [0]
52 | var opResult = vkGetSwapchainImagesKHR(self.device.pointer, self.pointer, &countArr, nil)
53 |
54 | guard opResult == VK_SUCCESS else {
55 | throw opResult.toResult()
56 | }
57 |
58 | var images = [VkImage?](repeating: VkImage(bitPattern: 0), count: Int(countArr[0]))
59 | opResult = vkGetSwapchainImagesKHR(self.device.pointer, self.pointer, &countArr, &images)
60 |
61 | return images.map { Image(fromVulkan: $0!, device: self.device, swapchain: self) }
62 | }
63 |
64 | override public func destroyUnderlying() {
65 | vkDestroySwapchainKHR(device.pointer, self.pointer, nil)
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/Sources/Vulkan/Utils.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) Alexander Ubillus. All rights reserved.
3 | // Licensed under the MIT License. See LICENSE file in the project root for full license information.
4 | //
5 |
6 | import Foundation
7 | import CVulkan
8 |
9 | func convertTupleToString(_ tuple: T) -> String {
10 | let tupleMirror = Mirror(reflecting: tuple)
11 | let data = tupleMirror.children.map({ $0.value as! Int8 })
12 | return String(cString: UnsafePointer(data))
13 | }
14 |
15 | func convertTupleToByteArray(_ tuple: T) -> [UInt8] {
16 | let tupleMirror = Mirror(reflecting: tuple)
17 | return tupleMirror.children.map({ $0.value as! UInt8 })
18 | }
19 |
20 | func convertTupleToArray(_ tuple: T) -> [K] {
21 | let tupleMirror = Mirror(reflecting: tuple)
22 | return tupleMirror.children.map({ $0.value as! K })
23 | }
24 |
25 | func withArrayOfCStrings(
26 | _ args: [String], _ body: ([UnsafePointer?]) -> R
27 | ) -> R {
28 | let argsCounts = Array(args.map { $0.utf8.count + 1 })
29 | let argsOffsets = [ 0 ] + scan(argsCounts, 0, +)
30 | let argsBufferSize = argsOffsets.last!
31 |
32 | var argsBuffer: [UInt8] = []
33 | argsBuffer.reserveCapacity(argsBufferSize)
34 | for arg in args {
35 | argsBuffer.append(contentsOf: arg.utf8)
36 | argsBuffer.append(0)
37 | }
38 |
39 | return argsBuffer.withUnsafeMutableBufferPointer { argsBuffer in
40 | let ptr = UnsafeRawPointer(argsBuffer.baseAddress!).bindMemory(
41 | to: CChar.self, capacity: argsBuffer.count)
42 | var cStrings: [UnsafePointer?] = argsOffsets.map { ptr + $0 }
43 | cStrings[cStrings.count - 1] = nil
44 | return body(cStrings)
45 | }
46 | }
47 |
48 | func scan<
49 | S : Sequence, U
50 | >(_ seq: S, _ initial: U, _ combine: (U, S.Iterator.Element) -> U) -> [U] {
51 | var result: [U] = []
52 | result.reserveCapacity(seq.underestimatedCount)
53 | var runningResult = initial
54 | for element in seq {
55 | runningResult = combine(runningResult, element)
56 | result.append(runningResult)
57 | }
58 | return result
59 | }
--------------------------------------------------------------------------------
/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/UnGast/SwiftVulkan/b12acb927795cb1f7e46b1b5ff326897995304f2/demo.png
--------------------------------------------------------------------------------