This commit is contained in:
Matthew 2026-06-14 14:47:30 +10:00
parent 5dc8d777a6
commit 7c01b68d36

View File

@ -541,77 +541,18 @@ struct Vulkan
f32[4] color_clear; f32[4] color_clear;
f32[4] depth_clear; f32[4] depth_clear;
@property VkCommandPool @property VkCommandPool cmd_pool() => this.cmd_pools[this.frame_index];
cmd_pool() @property VkCommandBuffer cmd() => this.cmds[this.frame_index];
{ @property VkSemaphore acquire_sem() => this.acquire_sems[this.frame_index];
return this.cmd_pools[this.frame_index]; @property VkSemaphore* acquire_sem_ptr() => this.acquire_sems.ptr + this.frame_index;
} @property VkFence render_fence() => this.render_fences[this.frame_index];
@property VkFence* render_fence_ptr() => this.render_fences.ptr + this.frame_index;
@property VkCommandBuffer @property VkPipeline last_pipeline() => this.last_pipelines[this.frame_index];
cmd() @property VkPipeline last_pipeline(VkPipeline pipeline) => this.last_pipelines[this.frame_index] = pipeline;
{ @property VkSemaphore submit_sem() => this.submit_sems[this.image_index];
return this.cmds[this.frame_index]; @property ref Descriptor present_image() => this.present_images[this.image_index];
} @property Descriptor* present_image_ptr() => this.present_images.ptr + this.image_index;
@property Arena* frame_arena() => &this.frame_arenas[this.frame_index];
@property VkSemaphore
acquire_sem()
{
return this.acquire_sems[this.frame_index];
}
@property VkSemaphore*
acquire_sem_ptr()
{
return this.acquire_sems.ptr + this.frame_index;
}
@property VkFence
render_fence()
{
return this.render_fences[this.frame_index];
}
@property VkFence*
render_fence_ptr()
{
return this.render_fences.ptr + this.frame_index;
}
@property VkPipeline
last_pipeline()
{
return this.last_pipelines[this.frame_index];
}
@property VkPipeline
last_pipeline(VkPipeline pipeline)
{
return this.last_pipelines[this.frame_index] = pipeline;
}
@property VkSemaphore
submit_sem()
{
return this.submit_sems[this.image_index];
}
@property ref Descriptor
present_image()
{
return this.present_images[this.image_index];
}
@property Descriptor*
present_image_ptr()
{
return this.present_images.ptr + this.image_index;
}
Arena*
FrameArena()
{
return &this.frame_arenas[this.frame_index];
}
alias queues this; alias queues this;
} }
@ -697,13 +638,13 @@ CreatePipelineLayout(T)(T layouts, u32 push_const_size, bool compute = false) if
static if(is(T: DescSetLayout)) static if(is(T: DescSetLayout))
{ {
desc_layouts = Alloc!(DescSetLayout)(g_vk.FrameArena(), 2); desc_layouts = Alloc!(DescSetLayout)(g_vk.frame_arena, 2);
desc_layouts[0] = g_vk.global_set_layout; desc_layouts[0] = g_vk.global_set_layout;
desc_layouts[1] = layouts; desc_layouts[1] = layouts;
} }
else static if(is(T: DescSetLayout[])) else static if(is(T: DescSetLayout[]))
{ {
desc_layouts = Alloc!(DescSetLayout)(g_vk.FrameArena(), layouts.length + 1); desc_layouts = Alloc!(DescSetLayout)(g_vk.frame_arena, layouts.length + 1);
desc_layouts[0] = g_vk.global_set_layout; desc_layouts[0] = g_vk.global_set_layout;
foreach(i; 0 .. layouts.length) foreach(i; 0 .. layouts.length)
@ -831,7 +772,7 @@ BeginFrame()
result = vkResetFences(g_vk.device, 1, g_vk.render_fence_ptr); result = vkResetFences(g_vk.device, 1, g_vk.render_fence_ptr);
VkCheckA("BeginFrame failure: vkResetFences error", result); VkCheckA("BeginFrame failure: vkResetFences error", result);
Reset(g_vk.FrameArena()); Reset(g_vk.frame_arena);
// ?? dont know why this is 3 (should have commented it) // ?? dont know why this is 3 (should have commented it)
for(u64 i = 0; i < 3; i += 1) for(u64 i = 0; i < 3; i += 1)
@ -1585,7 +1526,7 @@ Bind(Pipeline pipeline_handle, DescSet[] sets, bool compute = false)
u32[] offsets; u32[] offsets;
if(g_vk.global_set.dynamic_count > 0) if(g_vk.global_set.dynamic_count > 0)
{ {
offsets = Alloc!(u32)(g_vk.FrameArena(), g_vk.global_set.dynamic_count); offsets = Alloc!(u32)(g_vk.frame_arena, g_vk.global_set.dynamic_count);
} }
vkCmdBindDescriptorSets( vkCmdBindDescriptorSets(
@ -1600,7 +1541,7 @@ Bind(Pipeline pipeline_handle, DescSet[] sets, bool compute = false)
); );
u32 offset_count; u32 offset_count;
VkDescriptorSet[] handles = Alloc!(VkDescriptorSet)(g_vk.FrameArena(), sets.length); VkDescriptorSet[] handles = Alloc!(VkDescriptorSet)(g_vk.frame_arena, sets.length);
foreach(i, set; sets) foreach(i, set; sets)
{ {
@ -1610,7 +1551,7 @@ Bind(Pipeline pipeline_handle, DescSet[] sets, bool compute = false)
if(offset_count > 0) if(offset_count > 0)
{ {
offsets = Alloc!(u32)(g_vk.FrameArena(), offset_count); offsets = Alloc!(u32)(g_vk.frame_arena, offset_count);
} }
vkCmdBindDescriptorSets( vkCmdBindDescriptorSets(
@ -1647,7 +1588,7 @@ Bind(Pipeline pipeline_handle, DescSet set, bool compute = false)
u32[] offsets; u32[] offsets;
if(g_vk.global_set.dynamic_count > 0) if(g_vk.global_set.dynamic_count > 0)
{ {
offsets = Alloc!(u32)(g_vk.FrameArena(), g_vk.global_set.dynamic_count); offsets = Alloc!(u32)(g_vk.frame_arena, g_vk.global_set.dynamic_count);
} }
vkCmdBindDescriptorSets( vkCmdBindDescriptorSets(
@ -1663,7 +1604,7 @@ Bind(Pipeline pipeline_handle, DescSet set, bool compute = false)
if(set.dynamic_count > 0) if(set.dynamic_count > 0)
{ {
offsets = Alloc!(u32)(g_vk.FrameArena(), set.dynamic_count); offsets = Alloc!(u32)(g_vk.frame_arena, set.dynamic_count);
} }
vkCmdBindDescriptorSets( vkCmdBindDescriptorSets(
@ -2153,7 +2094,7 @@ PushDescriptorPool()
void void
PrepareWrite(VkWriteDescriptorSet* write, DescSet set, Descriptor* desc) PrepareWrite(VkWriteDescriptorSet* write, DescSet set, Descriptor* desc)
{ {
Arena* arena = g_vk.FrameArena(); Arena* arena = g_vk.frame_arena;
write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
write.descriptorType = desc.type; write.descriptorType = desc.type;
@ -2199,7 +2140,7 @@ PrepareWrite(VkWriteDescriptorSet* write, DescSet set, Descriptor* desc)
void void
Write(DescSet set, Descriptor[] descs) Write(DescSet set, Descriptor[] descs)
{ {
Arena* arena = g_vk.FrameArena(); Arena* arena = g_vk.frame_arena;
VkWriteDescriptorSet[] writes = Alloc!(VkWriteDescriptorSet)(arena, descs.length); VkWriteDescriptorSet[] writes = Alloc!(VkWriteDescriptorSet)(arena, descs.length);
@ -2433,7 +2374,7 @@ bool
CreateSwapchain() CreateSwapchain()
{ {
bool success = true; bool success = true;
Arena* arena = g_vk.FrameArena(); Arena* arena = g_vk.frame_arena;
VkSurfaceCapabilitiesKHR cap; VkSurfaceCapabilitiesKHR cap;
vkGetPhysicalDeviceSurfaceCapabilitiesKHR(g_vk.physical_device, g_vk.surface, &cap); vkGetPhysicalDeviceSurfaceCapabilitiesKHR(g_vk.physical_device, g_vk.surface, &cap);
@ -2681,7 +2622,7 @@ PrintShaderDisassembly(Pipeline pipeline_id, VkShaderStageFlagBits stage)
VkResult result = vkGetShaderInfoAMD(g_vk.device, pipeline.handle, stage, VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD, &size, null); VkResult result = vkGetShaderInfoAMD(g_vk.device, pipeline.handle, stage, VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD, &size, null);
if(result == VK_SUCCESS) if(result == VK_SUCCESS)
{ {
u8[] buf = Alloc!(u8)(g_vk.FrameArena(), size); u8[] buf = Alloc!(u8)(g_vk.frame_arena, size);
vkGetShaderInfoAMD(g_vk.device, pipeline.handle, stage, VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD, &size, buf.ptr); vkGetShaderInfoAMD(g_vk.device, pipeline.handle, stage, VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD, &size, buf.ptr);
Logf("DISASSEMBLY:\n%r", buf); Logf("DISASSEMBLY:\n%r", buf);
} }