GUI: Box drawing

This commit is contained in:
2026-05-13 05:40:31 +02:00
parent 79c62141df
commit bce62feb09
24 changed files with 747 additions and 62 deletions

View File

@@ -186,6 +186,10 @@ pub fn copyBufferToImage(
self.proxy.copyBufferToImage(src_buffer, dst_image, dst_image_layout, regions);
}
pub fn nextSubpass(self: CommandBuffer, contents: vk.SubpassContents) void {
self.proxy.nextSubpass(contents);
}
pub fn pipelineBarrier(self: CommandBuffer, barrier: PipelineBarrier) void {
self.proxy.pipelineBarrier(
barrier.src_stage_mask,

View File

@@ -771,24 +771,7 @@ pub fn deinit(self: *Skybox, engine: *Engine) void {
engine.destroyImage(self.image);
}
pub fn bind(self: *const Skybox, command_buffer: CommandBuffer, extent: vk.Extent2D) !void {
command_buffer.setViewport(0, &.{
.{
.x = 0,
.y = 0,
.width = @floatFromInt(extent.width),
.height = @floatFromInt(extent.height),
.min_depth = 0,
.max_depth = 1,
},
});
command_buffer.setScissor(0, &.{
.{
.offset = .{ .x = 0, .y = 0 },
.extent = extent,
},
});
command_buffer.bindPipeline(.graphics, self.pipeline);
pub fn draw(self: *const Skybox, command_buffer: CommandBuffer) !void {
try command_buffer.bindVertexBuffers(0, &.{
.{
.buffer = self.vertex_buffer.buffer,
@@ -796,9 +779,8 @@ pub fn bind(self: *const Skybox, command_buffer: CommandBuffer, extent: vk.Exten
},
});
command_buffer.bindIndexBuffer(self.index_buffer.buffer, 0, .uint16);
}
pub fn draw(self: *const Skybox, command_buffer: CommandBuffer) void {
command_buffer.bindPipeline(.graphics, self.pipeline);
command_buffer.bindDescriptorSet(.graphics, self.pipeline_layout, 0, self.descriptor_set, null);
command_buffer.drawIndexed(.{ .index_count = 36 });
}

View File

@@ -52,6 +52,7 @@ pub fn init(engine: *Engine) !Swapchain {
},
},
.subpasses = &.{
// Main
.{
.pipeline_bind_point = .graphics,
.color_attachments = &.{
@@ -65,6 +66,16 @@ pub fn init(engine: *Engine) !Swapchain {
.layout = .depth_stencil_attachment_optimal,
},
},
// GUI
.{
.pipeline_bind_point = .graphics,
.color_attachments = &.{
.{
.attachment = 0,
.layout = .color_attachment_optimal,
},
},
},
},
.dependencies = &.{
.{
@@ -89,6 +100,25 @@ pub fn init(engine: *Engine) !Swapchain {
.by_region_bit = true,
},
},
.{
.src_subpass = 0,
.dst_subpass = 1,
.src_stage_mask = .{
.color_attachment_output_bit = true,
},
.dst_stage_mask = .{
.color_attachment_output_bit = true,
},
.src_access_mask = .{
.color_attachment_write_bit = true,
},
.dst_access_mask = .{
.color_attachment_write_bit = true,
},
.dependency_flags = .{
.by_region_bit = true,
},
},
},
});
errdefer engine.destroyRenderPass(render_pass);
@@ -129,6 +159,8 @@ pub fn deinit(self: *Swapchain, engine: *Engine) void {
}
pub fn recreate(self: *Swapchain, engine: *Engine) !void {
try engine.deviceWaitIdle(); // TODO LMAO
const mode = &engine.mode.surface;
const allocator = engine.vk_allocator.allocator;

View File

@@ -132,7 +132,7 @@ fn freeFunction(
const self: *VkAllocator = @ptrCast(@alignCast(p_user_data.?));
if (maybe_p_memory) |p_memory| {
self.mutex.lockUncancelable();
self.mutex.lockUncancelable(self.io);
defer self.mutex.unlock(self.io);
const size = self.allocations.fetchRemove(p_memory).?.value;