diff --git a/src/binding/vk/attachment.zig b/src/binding/vk/attachment.zig index 40c88b2..13e3700 100644 --- a/src/binding/vk/attachment.zig +++ b/src/binding/vk/attachment.zig @@ -10,7 +10,7 @@ pub const Attachment = extern struct { flags: vk.Attachment.Description.Flags = 0, format: vk.Format, - samples: vk.SampleCount.Flags, + samples: vk.Sample.Count.Flags, load_op: vk.Attachment.LoadOp, store_op: vk.Attachment.StoreOp, stencil_load_op: vk.Attachment.LoadOp, diff --git a/src/binding/vk/command.zig b/src/binding/vk/command.zig new file mode 100644 index 0000000..0f8f5c6 --- /dev/null +++ b/src/binding/vk/command.zig @@ -0,0 +1,51 @@ +const std = @import ("std"); +const c = @import ("c"); + +const vk = @import ("vk"); +const raw = @import ("raw"); + +pub const Command = extern struct +{ + pub const Buffer = enum (usize) { NULL_HANDLE = vk.NULL_HANDLE, _, }; + + pub const Pool = enum (u64) + { + NULL_HANDLE = vk.NULL_HANDLE, _, + + pub const Create = extern struct + { + pub const Flags = u32; + + pub const Bit = enum (vk.Command.Pool.Create.Flags) + { + RESET_COMMAND_BUFFER = c.VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT, + TRANSIENT = c.VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, + }; + + pub const Info = extern struct + { + s_type: vk.StructureType = .COMMAND_POOL_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Command.Pool.Create.Flags = 0, + queue_family_index: u32, + }; + }; + + pub fn create (device: vk.Device, p_create_info: *const vk.Command.Pool.Create.Info, p_allocator: ?*const vk.AllocationCallbacks) !vk.Command.Pool + { + var command_pool: vk.Command.Pool = undefined; + const result = raw.prototypes.device.vkCreateCommandPool (device, p_create_info, p_allocator, &command_pool); + if (result > 0) + { + std.debug.print ("{s} failed with {} status code\n", .{ @typeName (@This ()) ++ "." ++ @src ().fn_name, result, }); + return error.UnexpectedResult; + } + return command_pool; + } + + pub fn destroy (device: vk.Device, command_pool: vk.Command.Pool, p_allocator: ?*const vk.AllocationCallbacks) void + { + raw.prototypes.device.vkDestroyCommandPool (device, command_pool, p_allocator); + } + }; +}; diff --git a/src/binding/vk/descriptor.zig b/src/binding/vk/descriptor.zig index a024247..7ea9682 100644 --- a/src/binding/vk/descriptor.zig +++ b/src/binding/vk/descriptor.zig @@ -21,7 +21,7 @@ pub const Descriptor = extern struct binding: u32, descriptor_type: vk.Descriptor.Type, descriptor_count: u32 = 0, - stage_flags: vk.ShaderStage.Flags, + stage_flags: vk.Shader.Stage.Flags, p_immutable_samplers: ?[*] const vk.Sampler = null, }; diff --git a/src/binding/vk/format.zig b/src/binding/vk/format.zig index a1932fd..47722f4 100644 --- a/src/binding/vk/format.zig +++ b/src/binding/vk/format.zig @@ -11,6 +11,7 @@ pub const Format = enum (u32) B8G8R8A8_UNORM = c.VK_FORMAT_B8G8R8A8_UNORM, R8G8B8_UNORM = c.VK_FORMAT_R8G8B8_UNORM, R8G8B8A8_UNORM = c.VK_FORMAT_R8G8B8A8_UNORM, + R32G32_SFLOAT = c.VK_FORMAT_R32G32_SFLOAT, _, pub const Feature = extern struct diff --git a/src/binding/vk/image.zig b/src/binding/vk/image.zig index 085d50b..37bfedf 100644 --- a/src/binding/vk/image.zig +++ b/src/binding/vk/image.zig @@ -32,7 +32,7 @@ pub const Image = enum (u64) extent: vk.Extent3D, mip_levels: u32, array_layers: u32, - samples: vk.SampleCount.Flags, + samples: vk.Sample.Count.Flags, tiling: vk.Image.Tiling, usage: vk.Image.Usage.Flags, sharing_mode: vk.SharingMode, diff --git a/src/binding/vk/physical_device.zig b/src/binding/vk/physical_device.zig index a8355d4..fcc6bee 100644 --- a/src/binding/vk/physical_device.zig +++ b/src/binding/vk/physical_device.zig @@ -169,16 +169,16 @@ pub const PhysicalDevice = enum (usize) max_framebuffer_width: u32, max_framebuffer_height: u32, max_framebuffer_layers: u32, - framebuffer_color_sample_counts: vk.SampleCount.Flags = 0, - framebuffer_depth_sample_counts: vk.SampleCount.Flags = 0, - framebuffer_stencil_sample_counts: vk.SampleCount.Flags = 0, - framebuffer_no_attachments_sample_counts: vk.SampleCount.Flags = 0, + framebuffer_color_sample_counts: vk.Sample.Count.Flags = 0, + framebuffer_depth_sample_counts: vk.Sample.Count.Flags = 0, + framebuffer_stencil_sample_counts: vk.Sample.Count.Flags = 0, + framebuffer_no_attachments_sample_counts: vk.Sample.Count.Flags = 0, max_color_attachments: u32, - sampled_image_color_sample_counts: vk.SampleCount.Flags = 0, - sampled_image_integer_sample_counts: vk.SampleCount.Flags = 0, - sampled_image_depth_sample_counts: vk.SampleCount.Flags = 0, - sampled_image_stencil_sample_counts: vk.SampleCount.Flags = 0, - storage_image_sample_counts: vk.SampleCount.Flags = 0, + sampled_image_color_sample_counts: vk.Sample.Count.Flags = 0, + sampled_image_integer_sample_counts: vk.Sample.Count.Flags = 0, + sampled_image_depth_sample_counts: vk.Sample.Count.Flags = 0, + sampled_image_stencil_sample_counts: vk.Sample.Count.Flags = 0, + storage_image_sample_counts: vk.Sample.Count.Flags = 0, max_sample_mask_words: u32, timestamp_compute_and_graphics: vk.Bool32, timestamp_period: f32, diff --git a/src/binding/vk/pipeline.zig b/src/binding/vk/pipeline.zig new file mode 100644 index 0000000..36b16d5 --- /dev/null +++ b/src/binding/vk/pipeline.zig @@ -0,0 +1,334 @@ +const std = @import ("std"); +const c = @import ("c"); + +const vk = @import ("vk"); +const raw = @import ("raw"); + +pub const Pipeline = enum (u64) +{ + NULL_HANDLE = vk.NULL_HANDLE, _, + + pub const Cache = enum (u64) { NULL_HANDLE = vk.NULL_HANDLE, _, }; + + + pub const ColorBlend = extern struct + { + pub const AttachmentState = extern struct + { + blend_enable: vk.Bool32, + src_color_blend_factor: vk.Blend.Factor, + dst_color_blend_factor: vk.Blend.Factor, + color_blend_op: vk.Blend.Op, + src_alpha_blend_factor: vk.Blend.Factor, + dst_alpha_blend_factor: vk.Blend.Factor, + alpha_blend_op: vk.Blend.Op, + color_write_mask: vk.ColorComponent.Flags = 0, + }; + + pub const State = extern struct + { + pub const Create = extern struct + { + pub const Flags = u32; + + pub const Info = extern struct + { + s_type: vk.StructureType = .PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Pipeline.ColorBlend.State.Create.Flags = 0, + logic_op_enable: vk.Bool32, + logic_op: vk.LogicOp, + attachment_count: u32 = 0, + p_attachments: ?[*] const vk.Pipeline.ColorBlend.AttachmentState = null, + blend_constants: [4] f32, + }; + }; + }; + }; + + pub const BindPoint = enum (i32) + { + GRAPHICS = c.VK_PIPELINE_BIND_POINT_GRAPHICS, + }; + + pub const Create = extern struct + { + pub const Flags = u32; + }; + + pub const DepthStencilState = extern struct + { + pub const Create = extern struct + { + pub const Flags = u32; + + pub const Info = extern struct + { + s_type: vk.StructureType = .PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Pipeline.DepthStencilState.Create.Flags = 0, + depth_test_enable: vk.Bool32, + depth_write_enable: vk.Bool32, + depth_compare_op: vk.CompareOp, + depth_bounds_test_enable: vk.Bool32, + stencil_test_enable: vk.Bool32, + front: vk.StencilOp.State, + back: vk.StencilOp.State, + min_depth_bounds: f32, + max_depth_bounds: f32, + }; + }; + }; + + pub const DynamicState = extern struct + { + pub const Create = extern struct + { + pub const Flags = u32; + + pub const Info = extern struct + { + s_type: vk.StructureType = .PIPELINE_DYNAMIC_STATE_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Pipeline.DynamicState.Create.Flags = 0, + dynamic_state_count: u32 = 0, + p_dynamic_states: ?[*] const vk.DynamicState = null, + }; + }; + }; + + pub const InputAssemblyState = extern struct + { + pub const Create = extern struct + { + pub const Flags = u32; + + pub const Info = extern struct + { + s_type: vk.StructureType = .PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Pipeline.InputAssemblyState.Create.Flags = 0, + topology: vk.PrimitiveTopology, + primitive_restart_enable: vk.Bool32, + }; + }; + }; + + pub const Layout = enum (u64) + { + NULL_HANDLE = vk.NULL_HANDLE, _, + + pub const Create = extern struct + { + pub const Flags = u32; + + pub const Info = extern struct + { + s_type: vk.StructureType = .PIPELINE_LAYOUT_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Pipeline.Layout.Create.Flags = 0, + set_layout_count: u32 = 0, + p_set_layouts: ?[*] const vk.Descriptor.Set.Layout = null, + push_constant_range_count: u32 = 0, + p_push_constant_ranges: ?[*] const vk.PushConstantRange = null, + }; + }; + + pub fn create (device: vk.Device, p_create_info: *const vk.Pipeline.Layout.Create.Info, p_allocator: ?*const vk.AllocationCallbacks) !vk.Pipeline.Layout + { + var pipeline_layout: vk.Pipeline.Layout = undefined; + const result = raw.prototypes.device.vkCreatePipelineLayout (device, p_create_info, p_allocator, &pipeline_layout); + if (result > 0) + { + std.debug.print ("{s} failed with {} status code\n", .{ @typeName (@This ()) ++ "." ++ @src ().fn_name, result, }); + return error.UnexpectedResult; + } + return pipeline_layout; + } + + pub fn destroy (device: vk.Device, pipeline_layout: vk.Pipeline.Layout, p_allocator: ?*const vk.AllocationCallbacks) void + { + raw.prototypes.device.vkDestroyPipelineLayout (device, pipeline_layout, p_allocator); + } + }; + + pub const MultisampleState = extern struct + { + pub const Create = extern struct + { + pub const Flags = u32; + + pub const Info = extern struct + { + s_type: vk.StructureType = .PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Pipeline.MultisampleState.Create.Flags = 0, + rasterization_samples: vk.Sample.Count.Flags, + sample_shading_enable: vk.Bool32, + min_sample_shading: f32, + p_sample_mask: ?[*] const vk.Sample.Mask = null, + alpha_to_coverage_enable: vk.Bool32, + alpha_to_one_enable: vk.Bool32, + }; + }; + }; + + pub const RasterizationState = extern struct + { + pub const Create = extern struct + { + pub const Flags = u32; + + pub const Info = extern struct + { + s_type: vk.StructureType = .PIPELINE_RASTERIZATION_STATE_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Pipeline.RasterizationState.Create.Flags = 0, + depth_clamp_enable: vk.Bool32, + rasterizer_discard_enable: vk.Bool32, + polygon_mode: vk.PolygonMode, + cull_mode: vk.CullMode.Flags = 0, + front_face: vk.FrontFace, + depth_bias_enable: vk.Bool32, + depth_bias_constant_factor: f32, + depth_bias_clamp: f32, + depth_bias_slope_factor: f32, + line_width: f32, + }; + }; + }; + + pub const ShaderStage = extern struct + { + pub const Create = extern struct + { + pub const Flags = u32; + + pub const Info = extern struct + { + s_type: vk.StructureType = .PIPELINE_SHADER_STAGE_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Pipeline.ShaderStage.Create.Flags = 0, + stage: vk.Shader.Stage.Flags, + module: vk.Shader.Module = .NULL_HANDLE, + p_name: [*:0] const u8, + p_specialization_info: ?*const vk.Specialization.Info = null, + }; + }; + }; + + pub const Stage = extern struct + { + pub const Flags = u32; + + pub const Bit = enum (vk.Pipeline.Stage.Flags) + { + COLOR_ATTACHMENT_OUTPUT = c.VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, + FRAGMENT_SHADER = c.VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, + }; + }; + + pub const TessellationState = extern struct + { + pub const Create = extern struct + { + pub const Flags = u32; + + pub const Info = extern struct + { + s_type: vk.StructureType = .PIPELINE_TESSELLATION_STATE_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Pipeline.TessellationState.Create.Flags = 0, + patch_control_points: u32, + }; + }; + }; + + pub const VertexInputState = extern struct + { + pub const Create = extern struct + { + pub const Flags = u32; + + pub const Info = extern struct + { + s_type: vk.StructureType = .PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Pipeline.VertexInputState.Create.Flags = 0, + vertex_binding_description_count: u32 = 0, + p_vertex_binding_descriptions: ?[*] const vk.VertexInput.BindingDescription = null, + vertex_attribute_description_count: u32 = 0, + p_vertex_attribute_descriptions: ?[*] const vk.VertexInput.AttributeDescription = null, + }; + }; + }; + + pub const ViewportState = extern struct + { + pub const Create = extern struct + { + pub const Flags = u32; + + pub const Info = extern struct + { + s_type: vk.StructureType = .PIPELINE_VIEWPORT_STATE_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Pipeline.ViewportState.Create.Flags = 0, + viewport_count: u32 = 0, + p_viewports: ?[*] const vk.Viewport = null, + scissor_count: u32 = 0, + p_scissors: ?[*] const vk.Rect2D = null, + }; + }; + }; + + pub fn destroy (device: vk.Device, pipeline: vk.Pipeline, p_allocator: ?*const vk.AllocationCallbacks) void + { + raw.prototypes.device.vkDestroyPipeline (device, pipeline, p_allocator); + } +}; + +pub const Graphics = extern struct +{ + pub const Pipeline = extern struct + { + pub const Create = extern struct + { + pub const Info = extern struct + { + s_type: vk.StructureType = .GRAPHICS_PIPELINE_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Pipeline.Create.Flags = 0, + stage_count: u32 = 0, + p_stages: ?[*] const vk.Pipeline.ShaderStage.Create.Info = null, + p_vertex_input_state: ?*const vk.Pipeline.VertexInputState.Create.Info = null, + p_input_assembly_state: ?*const vk.Pipeline.InputAssemblyState.Create.Info = null, + p_tessellation_state: ?*const vk.Pipeline.TessellationState.Create.Info = null, + p_viewport_state: ?*const vk.Pipeline.ViewportState.Create.Info = null, + p_rasterization_state: ?*const vk.Pipeline.RasterizationState.Create.Info = null, + p_multisample_state: ?*const vk.Pipeline.MultisampleState.Create.Info = null, + p_depth_stencil_state: ?*const vk.Pipeline.DepthStencilState.Create.Info = null, + p_color_blend_state: ?*const vk.Pipeline.ColorBlend.State.Create.Info = null, + p_dynamic_state: ?*const vk.Pipeline.DynamicState.Create.Info = null, + layout: vk.Pipeline.Layout = .NULL_HANDLE, + render_pass: vk.RenderPass = .NULL_HANDLE, + subpass: u32, + base_pipeline_handle: vk.Pipeline = .NULL_HANDLE, + base_pipeline_index: i32, + }; + }; + }; + + pub const Pipelines = extern struct + { + pub fn create (device: vk.Device, pipeline_cache: vk.Pipeline.Cache, create_info_count: u32, p_create_infos: [*] const vk.Graphics.Pipeline.Create.Info, p_allocator: ?*const vk.AllocationCallbacks, p_pipelines: [*] vk.Pipeline) !void + { + const result = raw.prototypes.device.vkCreateGraphicsPipelines (device, pipeline_cache, create_info_count, p_create_infos, p_allocator, p_pipelines); + if (result > 0) + { + std.debug.print ("{s} failed with {} status code\n", .{ @typeName (@This ()) ++ "." ++ @src ().fn_name, result, }); + return error.UnexpectedResult; + } + } + }; +}; diff --git a/src/binding/vk/raw.zig b/src/binding/vk/raw.zig index aa8bee6..7ab368c 100644 --- a/src/binding/vk/raw.zig +++ b/src/binding/vk/raw.zig @@ -72,7 +72,7 @@ const Prototypes = struct fn Dispatch (comptime T: std.meta.DeclEnum (literals)) type { - @setEvalBranchQuota (10_000); + @setEvalBranchQuota (100_000); const size = @typeInfo (@field (literals, @tagName (T))).Enum.fields.len; var fields: [size] std.builtin.Type.StructField = undefined; for (@typeInfo (@field (literals, @tagName (T))).Enum.fields, 0 ..) |*field, i| diff --git a/src/binding/vk/shader.zig b/src/binding/vk/shader.zig new file mode 100644 index 0000000..396cd38 --- /dev/null +++ b/src/binding/vk/shader.zig @@ -0,0 +1,55 @@ +const std = @import ("std"); +const c = @import ("c"); + +const vk = @import ("vk"); +const raw = @import ("raw"); + +pub const Shader = extern struct +{ + pub const Module = enum (u64) + { + NULL_HANDLE = vk.NULL_HANDLE, _, + + pub const Create = extern struct + { + pub const Flags = u32; + + pub const Info = extern struct + { + s_type: vk.StructureType = .SHADER_MODULE_CREATE_INFO, + p_next: ?*const anyopaque = null, + flags: vk.Shader.Module.Create.Flags = 0, + code_size: usize, + p_code: [*] const u32, + }; + }; + + pub fn create (device: vk.Device, p_create_info: *const vk.Shader.Module.Create.Info, p_allocator: ?*const vk.AllocationCallbacks) !vk.Shader.Module + { + var shader_module: vk.Shader.Module = undefined; + const result = raw.prototypes.device.vkCreateShaderModule (device, p_create_info, p_allocator, &shader_module); + if (result > 0) + { + std.debug.print ("{s} failed with {} status code\n", .{ @typeName (@This ()) ++ "." ++ @src ().fn_name, result, }); + return error.UnexpectedResult; + } + return shader_module; + } + + pub fn destroy (device: vk.Device, shader_module: vk.Shader.Module, p_allocator: ?*const vk.AllocationCallbacks) void + { + raw.prototypes.device.vkDestroyShaderModule (device, shader_module, p_allocator); + } + }; + + pub const Stage = extern struct + { + pub const Flags = u32; + + pub const Bit = enum (vk.Shader.Stage.Flags) + { + FRAGMENT = c.VK_SHADER_STAGE_FRAGMENT_BIT, + VERTEX = c.VK_SHADER_STAGE_VERTEX_BIT, + }; + }; +}; diff --git a/src/binding/vk/vk.zig b/src/binding/vk/vk.zig index 42177ae..24c78cd 100644 --- a/src/binding/vk/vk.zig +++ b/src/binding/vk/vk.zig @@ -88,6 +88,20 @@ pub const Bool32 = u32; pub const TRUE = c.VK_TRUE; pub const FALSE = c.VK_FALSE; +pub const Blend = extern struct +{ + pub const Factor = enum (i32) + { + ONE = c.VK_BLEND_FACTOR_ONE, + ZERO = c.VK_BLEND_FACTOR_ZERO, + }; + + pub const Op = enum (i32) + { + ADD = c.VK_BLEND_OP_ADD, + }; +}; + pub const BorderColor = enum (i32) { FLOAT_OPAQUE_BLACK = c.VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK, @@ -95,12 +109,21 @@ pub const BorderColor = enum (i32) pub const Buffer = enum (u64) { NULL_HANDLE = vk.NULL_HANDLE, _, }; -pub const Command = extern struct +pub const ColorComponent = extern struct { - pub const Buffer = enum (usize) { NULL_HANDLE = vk.NULL_HANDLE, _, }; - pub const Pool = enum (u64) { NULL_HANDLE = vk.NULL_HANDLE, _, }; + pub const Flags = u32; + + pub const Bit = enum (vk.ColorComponent.Flags) + { + A = c.VK_COLOR_COMPONENT_A_BIT, + B = c.VK_COLOR_COMPONENT_B_BIT, + G = c.VK_COLOR_COMPONENT_G_BIT, + R = c.VK_COLOR_COMPONENT_R_BIT, + }; }; +pub const Command = @import ("command").Command; + pub const CompareOp = enum (i32) { ALWAYS = c.VK_COMPARE_OP_ALWAYS, @@ -122,6 +145,16 @@ pub const Component = extern struct }; }; +pub const CullMode = extern struct +{ + pub const Flags = u32; + + pub const Bit = enum (vk.CullMode.Flags) + { + BACK = c.VK_CULL_MODE_BACK_BIT, + }; +}; + pub const Dependency = extern struct { pub const Flags = u32; @@ -135,6 +168,12 @@ pub const Dependency = extern struct pub const Descriptor = @import ("descriptor").Descriptor; pub const Device = @import ("device").Device; +pub const DynamicState = enum (i32) +{ + SCISSOR = c.VK_DYNAMIC_STATE_SCISSOR, + VIEWPORT = c.VK_DYNAMIC_STATE_VIEWPORT, +}; + pub const ExtensionProperties = extern struct { extension_name: [vk.MAX_EXTENSION_NAME_SIZE] u8, @@ -163,6 +202,14 @@ pub const Filter = enum (i32) pub const Format = @import ("format").Format; pub const Framebuffer = @import ("framebuffer").Framebuffer; + +pub const FrontFace = enum (i32) +{ + CLOCKWISE = c.VK_FRONT_FACE_CLOCKWISE, +}; + +pub const Graphics = @import ("pipeline").Graphics; + pub const Image = @import ("image").Image; pub const Instance = @import ("instance").Instance; @@ -176,11 +223,16 @@ pub const LayerProperties = extern struct description: [vk.MAX_DESCRIPTION_SIZE] u8, }; +pub const LogicOp = enum (i32) +{ + COPY = c.VK_LOGIC_OP_COPY, +}; + pub const Memory = @import ("memory").Memory; pub const ObjectType = enum (i32) { - unknown = 0, + UNKNOWN = c.VK_OBJECT_TYPE_UNKNOWN, }; pub const Offset2D = extern struct @@ -204,27 +256,23 @@ pub const PhysicalDevices = extern struct } }; -pub const Pipeline = enum (u64) -{ - NULL_HANDLE = vk.NULL_HANDLE, _, - - pub const BindPoint = enum (i32) - { - GRAPHICS = c.VK_PIPELINE_BIND_POINT_GRAPHICS, - }; +pub const Pipeline = @import ("pipeline").Pipeline; - pub const Layout = enum (u64) { NULL_HANDLE = vk.NULL_HANDLE, _, }; +pub const PolygonMode = enum (i32) +{ + FILL = c.VK_POLYGON_MODE_FILL, +}; - pub const Stage = extern struct - { - pub const Flags = u32; +pub const PrimitiveTopology = enum (i32) +{ + TRIANGLE_LIST = c.VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, +}; - pub const Bit = enum (vk.Pipeline.Stage.Flags) - { - COLOR_ATTACHMENT_OUTPUT = c.VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, - FRAGMENT_SHADER = c.VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, - }; - }; +pub const PushConstantRange = extern struct +{ + stage_flags: vk.Shader.Stage.Flags, + offset: u32, + size: u32, }; pub const Queue = enum (usize) @@ -262,37 +310,67 @@ pub const RenderPass = @import ("render_pass").RenderPass; pub const Sampler = @import ("sampler").Sampler; -pub const SampleCount = extern struct +pub const Sample = extern struct { - pub const Flags = u32; - - pub const Bit = enum (vk.SampleCount.Flags) + pub const Count = extern struct { - @"1" = c.VK_SAMPLE_COUNT_1_BIT, + pub const Flags = u32; + + pub const Bit = enum (vk.Sample.Count.Flags) + { + @"1" = c.VK_SAMPLE_COUNT_1_BIT, + }; }; + + pub const Mask = u32; }; pub const Semaphore = enum (u64) { NULL_HANDLE = vk.NULL_HANDLE, _, }; -pub const ShaderStage = extern struct +pub const Shader = @import ("shader").Shader; + +pub const SharingMode = enum (i32) { - pub const Flags = u32; + EXCLUSIVE = c.VK_SHARING_MODE_EXCLUSIVE, + CONCURRENT = c.VK_SHARING_MODE_CONCURRENT, +}; - pub const Bit = enum (vk.ShaderStage.Flags) +pub const Specialization = extern struct +{ + pub const Info = extern struct { - FRAGMENT = c.VK_SHADER_STAGE_FRAGMENT_BIT, + map_entry_count: u32 = 0, + p_map_entries: ?[*] const vk.Specialization.MapEntry = null, + data_size: usize = 0, + p_data: ?*const anyopaque = null, + }; + + pub const MapEntry = extern struct + { + constant_id: u32, + offset: u32, + size: usize, }; }; -pub const SharingMode = enum (i32) +pub const StencilOp = enum (i32) { - EXCLUSIVE = c.VK_SHARING_MODE_EXCLUSIVE, - CONCURRENT = c.VK_SHARING_MODE_CONCURRENT, + pub const State = extern struct + { + fail_op: vk.StencilOp, + pass_op: vk.StencilOp, + depth_fail_op: vk.StencilOp, + compare_op: vk.CompareOp, + compare_mask: u32, + write_mask: u32, + reference: u32, + }; }; pub const StructureType = enum (i32) { APPLICATION_INFO = c.VK_STRUCTURE_TYPE_APPLICATION_INFO, + COMMAND_POOL_CREATE_INFO = c.VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, DEBUG_UTILS_LABEL_EXT = c.VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT, DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT = c.VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT, DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT = c.VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT, @@ -301,12 +379,25 @@ pub const StructureType = enum (i32) DEVICE_CREATE_INFO = c.VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, DEVICE_QUEUE_CREATE_INFO = c.VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO, FRAMEBUFFER_CREATE_INFO = c.VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, + GRAPHICS_PIPELINE_CREATE_INFO = c.VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, IMAGE_CREATE_INFO = c.VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, IMAGE_VIEW_CREATE_INFO = c.VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, INSTANCE_CREATE_INFO = c.VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, MEMORY_ALLOCATE_INFO = c.VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, + PIPELINE_COLOR_BLEND_STATE_CREATE_INFO = c.VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, + PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO = c.VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, + PIPELINE_DYNAMIC_STATE_CREATE_INFO = c.VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, + PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = c.VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, + PIPELINE_LAYOUT_CREATE_INFO = c.VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, + PIPELINE_MULTISAMPLE_STATE_CREATE_INFO = c.VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, + PIPELINE_RASTERIZATION_STATE_CREATE_INFO = c.VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, + PIPELINE_SHADER_STAGE_CREATE_INFO = c.VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, + PIPELINE_TESSELLATION_STATE_CREATE_INFO = c.VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, + PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = c.VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, + PIPELINE_VIEWPORT_STATE_CREATE_INFO = c.VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, RENDER_PASS_CREATE_INFO = c.VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO, SAMPLER_CREATE_INFO = c.VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, + SHADER_MODULE_CREATE_INFO = c.VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO, SWAPCHAIN_CREATE_INFO_KHR = c.VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR, VALIDATION_FEATURES_EXT = c.VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT, }; @@ -343,6 +434,29 @@ pub const Subpass = extern struct pub const SystemAllocationScope = enum (i32) {}; +pub const VertexInput = extern struct +{ + pub const AttributeDescription = extern struct + { + location: u32, + binding: u32, + format: vk.Format, + offset: u32, + }; + + pub const BindingDescription = extern struct + { + binding: u32, + stride: u32, + input_rate: vk.VertexInput.Rate, + }; + + pub const Rate = enum (i32) + { + VERTEX = c.VK_VERTEX_INPUT_RATE_VERTEX, + }; +}; + pub const Viewport = extern struct { x: f32, diff --git a/src/vk/context.zig b/src/vk/context.zig index 1d2be6b..a991004 100644 --- a/src/vk/context.zig +++ b/src/vk/context.zig @@ -684,7 +684,7 @@ pub const Context = struct { .{ .format = self.surface_format.format, - .samples = @intFromEnum (vk.SampleCount.Bit.@"1"), + .samples = @intFromEnum (vk.Sample.Count.Bit.@"1"), .load_op = .CLEAR, .store_op = .STORE, .stencil_load_op = .DONT_CARE, @@ -765,7 +765,7 @@ pub const Context = struct }, .mip_levels = 1, .array_layers = 1, - .samples = @intFromEnum (vk.SampleCount.Bit.@"1"), + .samples = @intFromEnum (vk.Sample.Count.Bit.@"1"), .tiling = .OPTIMAL, .usage = @intFromEnum (vk.Image.Usage.Bit.COLOR_ATTACHMENT) | @intFromEnum (vk.Image.Usage.Bit.SAMPLED), @@ -835,7 +835,7 @@ pub const Context = struct { .{ .format = .R8G8B8A8_UNORM, - .samples = @intFromEnum (vk.SampleCount.Bit.@"1"), + .samples = @intFromEnum (vk.Sample.Count.Bit.@"1"), .load_op = .CLEAR, .store_op = .STORE, .stencil_load_op = .DONT_CARE, @@ -920,13 +920,13 @@ pub const Context = struct .binding = 0, .descriptor_type = .UNIFORM_BUFFER, .descriptor_count = 1, - .stage_flags = @intFromEnum (vk.ShaderStage.Bit.FRAGMENT), + .stage_flags = @intFromEnum (vk.Shader.Stage.Bit.FRAGMENT), .p_immutable_samplers = null, }, .{ .binding = 1, .descriptor_type = .COMBINED_IMAGE_SAMPLER, .descriptor_count = 1, - .stage_flags = @intFromEnum (vk.ShaderStage.Bit.FRAGMENT), + .stage_flags = @intFromEnum (vk.Shader.Stage.Bit.FRAGMENT), .p_immutable_samplers = null, }, }; @@ -937,7 +937,7 @@ pub const Context = struct .binding = 0, .descriptor_type = .UNIFORM_BUFFER, .descriptor_count = 1, - .stage_flags = @intFromEnum (vk.ShaderStage.Bit.FRAGMENT), + .stage_flags = @intFromEnum (vk.Shader.Stage.Bit.FRAGMENT), .p_immutable_samplers = null, }, }; @@ -964,54 +964,50 @@ pub const Context = struct try self.logger.app (.DEBUG, "init Vulkan descriptor set layout OK", .{}); } - fn init_shader_module (self: @This (), resource: [] const u8) !vk.ShaderModule + fn init_shader_module (self: @This (), resource: [] const u8) !vk.Shader.Module { - const create_info = vk.ShaderModuleCreateInfo + const create_info = vk.Shader.Module.Create.Info { .code_size = resource.len, .p_code = @ptrCast (@alignCast (resource.ptr)), }; - return try self.device_dispatch.createShaderModule (self.logical_device, &create_info, null); - + return try vk.Shader.Module.create (self.logical_device, &create_info, null); } fn init_graphics_pipeline (self: *@This ()) !void { const vertex = try self.init_shader_module (shader.main.vert [0 ..]); - defer self.device_dispatch.destroyShaderModule (self.logical_device, vertex, null); + defer vk.Shader.Module.destroy (self.logical_device, vertex, null); const fragment = try self.init_shader_module (shader.main.frag [0 ..]); - defer self.device_dispatch.destroyShaderModule (self.logical_device, fragment, null); + defer vk.Shader.Module.destroy (self.logical_device, fragment, null); const offscreen_fragment = try self.init_shader_module (shader.offscreen.frag [0 ..]); - defer self.device_dispatch.destroyShaderModule (self.logical_device, offscreen_fragment, null); + defer vk.Shader.Module.destroy (self.logical_device, offscreen_fragment, null); - var shader_stage = [_] vk.PipelineShaderStageCreateInfo + var shader_stage = [_] vk.Pipeline.ShaderStage.Create.Info { - vk.PipelineShaderStageCreateInfo - { - .stage = vk.ShaderStageFlags { .vertex_bit = true }, + .{ + .stage = @intFromEnum (vk.Shader.Stage.Bit.VERTEX), .module = vertex, .p_name = "main", .p_specialization_info = null, - }, - vk.PipelineShaderStageCreateInfo - { - .stage = vk.ShaderStageFlags { .fragment_bit = true }, + }, .{ + .stage = @intFromEnum (vk.Shader.Stage.Bit.FRAGMENT), .module = fragment, .p_name = "main", .p_specialization_info = null, }, }; - const dynamic_states = [_] vk.DynamicState { .viewport, .scissor }; + const dynamic_states = [_] vk.DynamicState { .VIEWPORT, .SCISSOR }; - const dynamic_state = vk.PipelineDynamicStateCreateInfo + const dynamic_state = vk.Pipeline.DynamicState.Create.Info { .dynamic_state_count = dynamic_states.len, .p_dynamic_states = &dynamic_states, }; - const vertex_input_state = vk.PipelineVertexInputStateCreateInfo + const vertex_input_state = vk.Pipeline.VertexInputState.Create.Info { .vertex_binding_description_count = vertex_vk.binding_description.len, .p_vertex_binding_descriptions = &(vertex_vk.binding_description), @@ -1019,35 +1015,33 @@ pub const Context = struct .p_vertex_attribute_descriptions = &(vertex_vk.attribute_description), }; - const input_assembly = vk.PipelineInputAssemblyStateCreateInfo + const input_assembly = vk.Pipeline.InputAssemblyState.Create.Info { - .topology = vk.PrimitiveTopology.triangle_list, + .topology = .TRIANGLE_LIST, .primitive_restart_enable = vk.FALSE, }; self.viewport = [_] vk.Viewport { - vk.Viewport - { - .x = 0, - .y = 0, - .width = @floatFromInt(self.extent.width), - .height = @floatFromInt(self.extent.height), - .min_depth = 0, - .max_depth = 1, - }, + .{ + .x = 0, + .y = 0, + .width = @floatFromInt (self.extent.width), + .height = @floatFromInt (self.extent.height), + .min_depth = 0, + .max_depth = 1, + }, }; self.scissor = [_] vk.Rect2D { - vk.Rect2D - { - .offset = vk.Offset2D { .x = 0, .y = 0 }, - .extent = self.extent, - }, + .{ + .offset = vk.Offset2D { .x = 0, .y = 0 }, + .extent = self.extent, + }, }; - const viewport_state = vk.PipelineViewportStateCreateInfo + const viewport_state = vk.Pipeline.ViewportState.Create.Info { .viewport_count = self.viewport.len, .p_viewports = &(self.viewport), @@ -1055,110 +1049,105 @@ pub const Context = struct .p_scissors = &(self.scissor), }; - const rasterizer = vk.PipelineRasterizationStateCreateInfo + const rasterizer = vk.Pipeline.RasterizationState.Create.Info { .depth_clamp_enable = vk.FALSE, .rasterizer_discard_enable = vk.FALSE, - .polygon_mode = vk.PolygonMode.fill, + .polygon_mode = .FILL, .line_width = 1, - .cull_mode = vk.CullModeFlags { .back_bit = true }, - .front_face = vk.FrontFace.clockwise, + .cull_mode = @intFromEnum (vk.CullMode.Bit.BACK), + .front_face = .CLOCKWISE, .depth_bias_enable = vk.FALSE, .depth_bias_constant_factor = 0, .depth_bias_clamp = 0, .depth_bias_slope_factor = 0, }; - const multisampling = vk.PipelineMultisampleStateCreateInfo + const multisampling = vk.Pipeline.MultisampleState.Create.Info { .sample_shading_enable = vk.FALSE, - .rasterization_samples = vk.SampleCountFlags { .@"1_bit" = true }, + .rasterization_samples = @intFromEnum (vk.Sample.Count.Bit.@"1"), .min_sample_shading = 1, .p_sample_mask = null, .alpha_to_coverage_enable = vk.FALSE, .alpha_to_one_enable = vk.FALSE, }; - const blend_attachment = [_] vk.PipelineColorBlendAttachmentState + const blend_attachment = [_] vk.Pipeline.ColorBlend.AttachmentState { - vk.PipelineColorBlendAttachmentState - { - .color_write_mask = vk.ColorComponentFlags - { - .r_bit = true, - .g_bit = true, - .b_bit = true, - .a_bit = true, - }, - .blend_enable = vk.FALSE, - .src_color_blend_factor = vk.BlendFactor.one, - .dst_color_blend_factor = vk.BlendFactor.zero, - .color_blend_op = vk.BlendOp.add, - .src_alpha_blend_factor = vk.BlendFactor.one, - .dst_alpha_blend_factor = vk.BlendFactor.zero, - .alpha_blend_op = vk.BlendOp.add, - }, + .{ + .color_write_mask = @intFromEnum (vk.ColorComponent.Bit.R) | + @intFromEnum (vk.ColorComponent.Bit.G) | + @intFromEnum (vk.ColorComponent.Bit.B) | + @intFromEnum (vk.ColorComponent.Bit.A), + .blend_enable = vk.FALSE, + .src_color_blend_factor = .ONE, + .dst_color_blend_factor = .ZERO, + .color_blend_op = .ADD, + .src_alpha_blend_factor = .ONE, + .dst_alpha_blend_factor = .ZERO, + .alpha_blend_op = .ADD, + }, }; - const blend_state = vk.PipelineColorBlendStateCreateInfo + const blend_state = vk.Pipeline.ColorBlend.State.Create.Info { .logic_op_enable = vk.FALSE, - .logic_op = vk.LogicOp.copy, + .logic_op = .COPY, .attachment_count = blend_attachment.len, .p_attachments = &blend_attachment, .blend_constants = [_] f32 { 0, 0, 0, 0 }, }; - var layout_create_info = vk.PipelineLayoutCreateInfo + var layout_create_info = vk.Pipeline.Layout.Create.Info { - .set_layout_count = @intCast(self.descriptor_set_layout.len), + .set_layout_count = @intCast (self.descriptor_set_layout.len), .p_set_layouts = self.descriptor_set_layout.ptr, .push_constant_range_count = 0, .p_push_constant_ranges = undefined, }; - self.pipeline_layout = try self.device_dispatch.createPipelineLayout (self.logical_device, &layout_create_info, null); - errdefer self.device_dispatch.destroyPipelineLayout (self.logical_device, self.pipeline_layout, null); + self.pipeline_layout = try vk.Pipeline.Layout.create (self.logical_device, &layout_create_info, null); + errdefer vk.Pipeline.Layout.destroy (self.logical_device, self.pipeline_layout, null); layout_create_info.set_layout_count = @intCast (self.offscreen_descriptor_set_layout.len); layout_create_info.p_set_layouts = self.offscreen_descriptor_set_layout.ptr; - self.offscreen_pipeline_layout = try self.device_dispatch.createPipelineLayout (self.logical_device, &layout_create_info, null); - errdefer self.device_dispatch.destroyPipelineLayout (self.logical_device, self.offscreen_pipeline_layout, null); + self.offscreen_pipeline_layout = try vk.Pipeline.Layout.create (self.logical_device, &layout_create_info, null); + errdefer vk.Pipeline.Layout.destroy (self.logical_device, self.offscreen_pipeline_layout, null); - var pipeline_create_info = [_] vk.GraphicsPipelineCreateInfo + var pipeline_create_info = [_] vk.Graphics.Pipeline.Create.Info { - vk.GraphicsPipelineCreateInfo - { - .stage_count = shader_stage.len, - .p_stages = &shader_stage, - .p_vertex_input_state = &vertex_input_state, - .p_input_assembly_state = &input_assembly, - .p_tessellation_state = null, - .p_viewport_state = &viewport_state, - .p_rasterization_state = &rasterizer, - .p_multisample_state = &multisampling, - .p_depth_stencil_state = null, - .p_color_blend_state = &blend_state, - .p_dynamic_state = &dynamic_state, - .layout = self.pipeline_layout, - .render_pass = self.render_pass, - .subpass = 0, - .base_pipeline_handle = vk.Pipeline.null_handle, - .base_pipeline_index = -1, - }, + .{ + .stage_count = shader_stage.len, + .p_stages = &shader_stage, + .p_vertex_input_state = &vertex_input_state, + .p_input_assembly_state = &input_assembly, + .p_tessellation_state = null, + .p_viewport_state = &viewport_state, + .p_rasterization_state = &rasterizer, + .p_multisample_state = &multisampling, + .p_depth_stencil_state = null, + .p_color_blend_state = &blend_state, + .p_dynamic_state = &dynamic_state, + .layout = self.pipeline_layout, + .render_pass = self.render_pass, + .subpass = 0, + .base_pipeline_handle = .NULL_HANDLE, + .base_pipeline_index = -1, + }, }; self.pipelines = try self.logger.allocator.alloc (vk.Pipeline, 1); - _ = try self.device_dispatch.createGraphicsPipelines (self.logical_device, vk.PipelineCache.null_handle, pipeline_create_info.len, &pipeline_create_info, null, self.pipelines.ptr); + try vk.Graphics.Pipelines.create (self.logical_device, .NULL_HANDLE, pipeline_create_info.len, &pipeline_create_info, null, self.pipelines.ptr); errdefer { var index: u32 = 0; while (index < self.pipelines.len) { - self.device_dispatch.destroyPipeline (self.logical_device, self.pipelines [index], null); + vk.Pipeline.destroy (self.logical_device, self.pipelines [index], null); index += 1; } } @@ -1169,14 +1158,14 @@ pub const Context = struct self.offscreen_pipelines = try self.logger.allocator.alloc (vk.Pipeline, 1); - _ = try self.device_dispatch.createGraphicsPipelines (self.logical_device, vk.PipelineCache.null_handle, pipeline_create_info.len, &pipeline_create_info, null, self.offscreen_pipelines.ptr); + try vk.Graphics.Pipelines.create (self.logical_device, .NULL_HANDLE, pipeline_create_info.len, &pipeline_create_info, null, self.offscreen_pipelines.ptr); errdefer { var index: u32 = 0; while (index < self.offscreen_pipelines.len) { - self.device_dispatch.destroyPipeline (self.logical_device, self.offscreen_pipelines [index], null); + vk.Pipeline.destroy (self.logical_device, self.offscreen_pipelines [index], null); index += 1; } } @@ -1189,22 +1178,22 @@ pub const Context = struct self.framebuffers = try self.logger.allocator.alloc (vk.Framebuffer, self.views.len); var index: usize = 0; - var create_info: vk.FramebufferCreateInfo = undefined; + var create_info: vk.Framebuffer.Create.Info = undefined; for (self.framebuffers) |*framebuffer| { - create_info = vk.FramebufferCreateInfo + create_info = vk.Framebuffer.Create.Info { .render_pass = self.render_pass, .attachment_count = 1, - .p_attachments = &[_] vk.ImageView { self.views [index] }, + .p_attachments = &[_] vk.Image.View { self.views [index] }, .width = self.extent.width, .height = self.extent.height, .layers = 1, }; - framebuffer.* = try self.device_dispatch.createFramebuffer (self.logical_device, &create_info, null); - errdefer self.device_dispatch.destroyFramebuffer (self.logical_device, framebuffer.*, null); + framebuffer.* = try vk.Framebuffer.create (self.logical_device, &create_info, null); + errdefer vk.Framebuffer.destroy (self.logical_device, framebuffer.*, null); index += 1; } @@ -1214,23 +1203,24 @@ pub const Context = struct fn init_command_pools (self: *@This ()) !void { - const create_info = vk.CommandPoolCreateInfo + const create_info = vk.Command.Pool.Create.Info { - .flags = vk.CommandPoolCreateFlags { .reset_command_buffer_bit = true, }, + .flags = @intFromEnum (vk.Command.Pool.Create.Bit.RESET_COMMAND_BUFFER), .queue_family_index = self.candidate.graphics_family, }; - self.command_pool = try self.device_dispatch.createCommandPool (self.logical_device, &create_info, null); - errdefer self.device_dispatch.destroyCommandPool (self.logical_device, self.command_pool, null); + self.command_pool = try vk.Command.Pool.create (self.logical_device, &create_info, null); + errdefer vk.Command.Pool.destroy (self.logical_device, self.command_pool, null); - const buffers_create_info = vk.CommandPoolCreateInfo + const buffers_create_info = vk.Command.Pool.Create.Info { - .flags = vk.CommandPoolCreateFlags { .reset_command_buffer_bit = true, .transient_bit = true, }, + .flags = @intFromEnum (vk.Command.Pool.Create.Bit.RESET_COMMAND_BUFFER) | + @intFromEnum (vk.Command.Pool.Create.Bit.TRANSIENT), .queue_family_index = self.candidate.graphics_family, }; - self.buffers_command_pool = try self.device_dispatch.createCommandPool (self.logical_device, &buffers_create_info, null); - errdefer self.device_dispatch.destroyCommandPool (self.logical_device, self.buffers_command_pool, null); + self.buffers_command_pool = try vk.Command.Pool.create (self.logical_device, &buffers_create_info, null); + errdefer vk.Command.Pool.destroy (self.logical_device, self.buffers_command_pool, null); try self.logger.app (.DEBUG, "init Vulkan command pools OK", .{}); } @@ -1910,7 +1900,7 @@ pub const Context = struct }, .mip_levels = 1, .array_layers = 1, - .samples = vk.SampleCountFlags { .@"1_bit" = true, }, + .samples = vk.Sample.Count.Flags { .@"1_bit" = true, }, .tiling = vk.ImageTiling.linear, .usage = vk.ImageUsageFlags { .transfer_dst_bit = true, }, .sharing_mode = vk.SharingMode.exclusive, diff --git a/src/vk/vertex.zig b/src/vk/vertex.zig index 0b228c0..ffdb97a 100644 --- a/src/vk/vertex.zig +++ b/src/vk/vertex.zig @@ -4,24 +4,22 @@ pub const vertex_vk = struct { pos: [2] f32, - pub const binding_description = [_] vk.VertexInputBindingDescription + pub const binding_description = [_] vk.VertexInput.BindingDescription { - vk.VertexInputBindingDescription - { - .binding = 0, - .stride = @sizeOf (@This ()), - .input_rate = vk.VertexInputRate.vertex, - }, + .{ + .binding = 0, + .stride = @sizeOf (@This ()), + .input_rate = .VERTEX, + }, }; - pub const attribute_description = [_] vk.VertexInputAttributeDescription + pub const attribute_description = [_] vk.VertexInput.AttributeDescription { - vk.VertexInputAttributeDescription - { - .binding = 0, - .location = 0, - .format = vk.Format.r32g32_sfloat, - .offset = @offsetOf (@This (), "pos"), - }, + .{ + .binding = 0, + .location = 0, + .format = .R32G32_SFLOAT, + .offset = @offsetOf (@This (), "pos"), + }, }; };