Skip to content

Commit

Permalink
[progress #146] custom bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
tiawl committed Apr 4, 2024
1 parent c4fb972 commit 82b561a
Show file tree
Hide file tree
Showing 12 changed files with 716 additions and 173 deletions.
2 changes: 1 addition & 1 deletion src/binding/vk/attachment.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
51 changes: 51 additions & 0 deletions src/binding/vk/command.zig
Original file line number Diff line number Diff line change
@@ -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);
}
};
};
2 changes: 1 addition & 1 deletion src/binding/vk/descriptor.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
1 change: 1 addition & 0 deletions src/binding/vk/format.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/binding/vk/image.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions src/binding/vk/physical_device.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 82b561a

Please sign in to comment.