make alloc function names consistent
This commit is contained in:
parent
0be80e3a3e
commit
cd9e3bb36a
38
vulkan.d
38
vulkan.d
@ -512,7 +512,7 @@ Init(PlatformHandles platform_handles, u64 permanent_mem, u64 frame_mem)
|
|||||||
void
|
void
|
||||||
InitPipelines(Vulkan* vk)
|
InitPipelines(Vulkan* vk)
|
||||||
{
|
{
|
||||||
vk.pipeline_handles = AllocArray!(PipelineHandles)(&vk.arena, 128);
|
vk.pipeline_handles = Alloc!(PipelineHandles)(&vk.arena, 128);
|
||||||
vk.pipeline_count += 1;
|
vk.pipeline_count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,13 +568,13 @@ CreatePipelineLayout(T)(Vulkan* vk, T layouts, u32 push_const_size, bool compute
|
|||||||
|
|
||||||
static if(is(T: DescSetLayout))
|
static if(is(T: DescSetLayout))
|
||||||
{
|
{
|
||||||
desc_layouts = AllocArray!(DescSetLayout)(&vk.frame_arenas[vk.frame_index], 2);
|
desc_layouts = Alloc!(DescSetLayout)(&vk.frame_arenas[vk.frame_index], 2);
|
||||||
desc_layouts[0] = vk.global_set_layout;
|
desc_layouts[0] = 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 = AllocArray!(DescSetLayout)(&vk.frame_arenas[vk.frame_index], layouts.length + 1);
|
desc_layouts = Alloc!(DescSetLayout)(&vk.frame_arenas[vk.frame_index], layouts.length + 1);
|
||||||
desc_layouts[0] = vk.global_set_layout;
|
desc_layouts[0] = vk.global_set_layout;
|
||||||
|
|
||||||
foreach(i; 1 .. layouts.length)
|
foreach(i; 1 .. layouts.length)
|
||||||
@ -1500,7 +1500,7 @@ Bind(Vulkan* vk, Pipeline pipeline_handle, DescSet[] sets, bool compute = false)
|
|||||||
u32[] offsets;
|
u32[] offsets;
|
||||||
if(vk.global_set.dynamic_count > 0)
|
if(vk.global_set.dynamic_count > 0)
|
||||||
{
|
{
|
||||||
offsets = AllocArray!(u32)(&vk.frame_arenas[vk.frame_index], vk.global_set.dynamic_count);
|
offsets = Alloc!(u32)(&vk.frame_arenas[vk.frame_index], vk.global_set.dynamic_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
vkCmdBindDescriptorSets(
|
vkCmdBindDescriptorSets(
|
||||||
@ -1515,7 +1515,7 @@ Bind(Vulkan* vk, Pipeline pipeline_handle, DescSet[] sets, bool compute = false)
|
|||||||
);
|
);
|
||||||
|
|
||||||
u32 offset_count;
|
u32 offset_count;
|
||||||
VkDescriptorSet[] handles = AllocArray!(VkDescriptorSet)(&vk.frame_arenas[vk.frame_index], sets.length);
|
VkDescriptorSet[] handles = Alloc!(VkDescriptorSet)(&vk.frame_arenas[vk.frame_index], sets.length);
|
||||||
|
|
||||||
foreach(i, set; sets)
|
foreach(i, set; sets)
|
||||||
{
|
{
|
||||||
@ -1525,7 +1525,7 @@ Bind(Vulkan* vk, Pipeline pipeline_handle, DescSet[] sets, bool compute = false)
|
|||||||
|
|
||||||
if(offset_count > 0)
|
if(offset_count > 0)
|
||||||
{
|
{
|
||||||
offsets = AllocArray!(u32)(&vk.frame_arenas[vk.frame_index], offset_count);
|
offsets = Alloc!(u32)(&vk.frame_arenas[vk.frame_index], offset_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
vkCmdBindDescriptorSets(
|
vkCmdBindDescriptorSets(
|
||||||
@ -1562,7 +1562,7 @@ Bind(Vulkan* vk, Pipeline pipeline_handle, DescSet set, bool compute = false)
|
|||||||
u32[] offsets;
|
u32[] offsets;
|
||||||
if(vk.global_set.dynamic_count > 0)
|
if(vk.global_set.dynamic_count > 0)
|
||||||
{
|
{
|
||||||
offsets = AllocArray!(u32)(&vk.frame_arenas[vk.frame_index], vk.global_set.dynamic_count);
|
offsets = Alloc!(u32)(&vk.frame_arenas[vk.frame_index], vk.global_set.dynamic_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
vkCmdBindDescriptorSets(
|
vkCmdBindDescriptorSets(
|
||||||
@ -1578,7 +1578,7 @@ Bind(Vulkan* vk, Pipeline pipeline_handle, DescSet set, bool compute = false)
|
|||||||
|
|
||||||
if(set.dynamic_count > 0)
|
if(set.dynamic_count > 0)
|
||||||
{
|
{
|
||||||
offsets = AllocArray!(u32)(&vk.frame_arenas[vk.frame_index], set.dynamic_count);
|
offsets = Alloc!(u32)(&vk.frame_arenas[vk.frame_index], set.dynamic_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
vkCmdBindDescriptorSets(
|
vkCmdBindDescriptorSets(
|
||||||
@ -2456,7 +2456,7 @@ InitFrameStructures(Vulkan* vk)
|
|||||||
};
|
};
|
||||||
|
|
||||||
u32 sem_count = cast(u32)vk.present_images.length;
|
u32 sem_count = cast(u32)vk.present_images.length;
|
||||||
vk.submit_sems = AllocArray!(VkSemaphore)(arena, sem_count);
|
vk.submit_sems = Alloc!(VkSemaphore)(arena, sem_count);
|
||||||
|
|
||||||
foreach(i; 0 .. sem_count)
|
foreach(i; 0 .. sem_count)
|
||||||
{
|
{
|
||||||
@ -2598,12 +2598,12 @@ SelectSwapchainFormats(Vulkan* vk)
|
|||||||
|
|
||||||
u32 format_count;
|
u32 format_count;
|
||||||
vkGetPhysicalDeviceSurfaceFormatsKHR(vk.physical_device, vk.surface, &format_count, null);
|
vkGetPhysicalDeviceSurfaceFormatsKHR(vk.physical_device, vk.surface, &format_count, null);
|
||||||
VkSurfaceFormatKHR[] formats = AllocArray!(VkSurfaceFormatKHR)(arena, format_count);
|
VkSurfaceFormatKHR[] formats = Alloc!(VkSurfaceFormatKHR)(arena, format_count);
|
||||||
vkGetPhysicalDeviceSurfaceFormatsKHR(vk.physical_device, vk.surface, &format_count, formats.ptr);
|
vkGetPhysicalDeviceSurfaceFormatsKHR(vk.physical_device, vk.surface, &format_count, formats.ptr);
|
||||||
|
|
||||||
u32 mode_count;
|
u32 mode_count;
|
||||||
vkGetPhysicalDeviceSurfacePresentModesKHR(vk.physical_device, vk.surface, &mode_count, null);
|
vkGetPhysicalDeviceSurfacePresentModesKHR(vk.physical_device, vk.surface, &mode_count, null);
|
||||||
VkPresentModeKHR[] modes = AllocArray!(VkPresentModeKHR)(arena, mode_count);
|
VkPresentModeKHR[] modes = Alloc!(VkPresentModeKHR)(arena, mode_count);
|
||||||
vkGetPhysicalDeviceSurfacePresentModesKHR(vk.physical_device, vk.surface, &mode_count, modes.ptr);
|
vkGetPhysicalDeviceSurfacePresentModesKHR(vk.physical_device, vk.surface, &mode_count, modes.ptr);
|
||||||
|
|
||||||
VkPresentModeKHR present_mode = VK_PRESENT_MODE_FIFO_KHR;
|
VkPresentModeKHR present_mode = VK_PRESENT_MODE_FIFO_KHR;
|
||||||
@ -2671,11 +2671,11 @@ CreateSwapchain(Vulkan* vk)
|
|||||||
|
|
||||||
u32 count;
|
u32 count;
|
||||||
vkGetSwapchainImagesKHR(vk.device, vk.swapchain, &count, null);
|
vkGetSwapchainImagesKHR(vk.device, vk.swapchain, &count, null);
|
||||||
VkImage[] images = AllocArray!(VkImage)(arena, count);
|
VkImage[] images = Alloc!(VkImage)(arena, count);
|
||||||
vkGetSwapchainImagesKHR(vk.device, vk.swapchain, &count, images.ptr);
|
vkGetSwapchainImagesKHR(vk.device, vk.swapchain, &count, images.ptr);
|
||||||
VkImageView[] views = AllocArray!(VkImageView)(arena, count);
|
VkImageView[] views = Alloc!(VkImageView)(arena, count);
|
||||||
|
|
||||||
vk.present_images = AllocArray!(ImageView)(&vk.arena, count);
|
vk.present_images = Alloc!(ImageView)(&vk.arena, count);
|
||||||
|
|
||||||
VkImageViewCreateInfo view_info = {
|
VkImageViewCreateInfo view_info = {
|
||||||
sType: VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
sType: VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||||
@ -2789,7 +2789,7 @@ InitDevice(Vulkan* vk)
|
|||||||
|
|
||||||
u32 count;
|
u32 count;
|
||||||
vkEnumeratePhysicalDevices(vk.instance, &count, null);
|
vkEnumeratePhysicalDevices(vk.instance, &count, null);
|
||||||
VkPhysicalDevice[] devices = AllocArray!(VkPhysicalDevice)(arena, count);
|
VkPhysicalDevice[] devices = Alloc!(VkPhysicalDevice)(arena, count);
|
||||||
vkEnumeratePhysicalDevices(vk.instance, &count, devices.ptr);
|
vkEnumeratePhysicalDevices(vk.instance, &count, devices.ptr);
|
||||||
|
|
||||||
VkPhysicalDevice physical_device = null;
|
VkPhysicalDevice physical_device = null;
|
||||||
@ -2984,7 +2984,7 @@ CheckDeviceProperties(Arena *arena, VkPhysicalDevice device, VkSurfaceKHR surfac
|
|||||||
{
|
{
|
||||||
u32 ext_count;
|
u32 ext_count;
|
||||||
vkEnumerateDeviceExtensionProperties(device, null, &ext_count, null);
|
vkEnumerateDeviceExtensionProperties(device, null, &ext_count, null);
|
||||||
VkExtensionProperties[] ext_props = AllocArray!(VkExtensionProperties)(arena, ext_count);
|
VkExtensionProperties[] ext_props = Alloc!(VkExtensionProperties)(arena, ext_count);
|
||||||
vkEnumerateDeviceExtensionProperties(device, null, &ext_count, ext_props.ptr);
|
vkEnumerateDeviceExtensionProperties(device, null, &ext_count, ext_props.ptr);
|
||||||
|
|
||||||
i32 matched = 0;
|
i32 matched = 0;
|
||||||
@ -3030,7 +3030,7 @@ CheckQueueProperties(Arena *arena, VkPhysicalDevice device, VkSurfaceKHR surface
|
|||||||
|
|
||||||
u32 count;
|
u32 count;
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(device, &count, null);
|
vkGetPhysicalDeviceQueueFamilyProperties(device, &count, null);
|
||||||
VkQueueFamilyProperties[] properties = AllocArray!(VkQueueFamilyProperties)(arena, count);
|
VkQueueFamilyProperties[] properties = Alloc!(VkQueueFamilyProperties)(arena, count);
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties(device, &count, properties.ptr);
|
vkGetPhysicalDeviceQueueFamilyProperties(device, &count, properties.ptr);
|
||||||
|
|
||||||
if(count == 1 && properties[0].queueCount == 1 && BitEq(properties[0].queueFlags, T_BIT | C_BIT | G_BIT))
|
if(count == 1 && properties[0].queueCount == 1 && BitEq(properties[0].queueFlags, T_BIT | C_BIT | G_BIT))
|
||||||
@ -3287,7 +3287,7 @@ InitInstance(Vulkan* vk)
|
|||||||
|
|
||||||
u32 count;
|
u32 count;
|
||||||
vkEnumerateInstanceLayerProperties(&count, null);
|
vkEnumerateInstanceLayerProperties(&count, null);
|
||||||
VkLayerProperties[] layers = AllocArray!(VkLayerProperties)(arena, count);
|
VkLayerProperties[] layers = Alloc!(VkLayerProperties)(arena, count);
|
||||||
vkEnumerateInstanceLayerProperties(&count, layers.ptr);
|
vkEnumerateInstanceLayerProperties(&count, layers.ptr);
|
||||||
|
|
||||||
foreach(i, layer; layers)
|
foreach(i, layer; layers)
|
||||||
@ -3427,7 +3427,7 @@ PrintShaderDisassembly(Vulkan* vk, Pipeline pipeline_id, VkShaderStageFlagBits s
|
|||||||
VkResult result = vkGetShaderInfoAMD(vk.device, pipeline.handle, stage, VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD, &size, null);
|
VkResult result = vkGetShaderInfoAMD(vk.device, pipeline.handle, stage, VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD, &size, null);
|
||||||
if(result == VK_SUCCESS)
|
if(result == VK_SUCCESS)
|
||||||
{
|
{
|
||||||
u8[] buf = AllocArray!(u8)(&vk.frame_arenas[vk.frame_index], size);
|
u8[] buf = Alloc!(u8)(&vk.frame_arenas[vk.frame_index], size);
|
||||||
vkGetShaderInfoAMD(vk.device, pipeline.handle, stage, VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD, &size, buf.ptr);
|
vkGetShaderInfoAMD(vk.device, pipeline.handle, stage, VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD, &size, buf.ptr);
|
||||||
Logf("DISASSEMBLY:\n%r", buf);
|
Logf("DISASSEMBLY:\n%r", buf);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -182,7 +182,7 @@ Alloc(T)()
|
|||||||
}
|
}
|
||||||
|
|
||||||
T[]
|
T[]
|
||||||
AllocArray(T)(u64 count)
|
Alloc(T)(u64 count)
|
||||||
{
|
{
|
||||||
void* mem = MemAlloc(T.sizeof * count);
|
void* mem = MemAlloc(T.sizeof * count);
|
||||||
memset(mem, 0, T.sizeof * count);
|
memset(mem, 0, T.sizeof * count);
|
||||||
@ -190,7 +190,7 @@ AllocArray(T)(u64 count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FreeArray(T)(T[] arr)
|
Free(T)(T[] arr)
|
||||||
{
|
{
|
||||||
MemFree(cast(void*)arr.ptr);
|
MemFree(cast(void*)arr.ptr);
|
||||||
}
|
}
|
||||||
@ -223,7 +223,7 @@ CreateArena(u64 size)
|
|||||||
};
|
};
|
||||||
|
|
||||||
T[]
|
T[]
|
||||||
AllocArray(T)(Arena* arena, u64 count)
|
Alloc(T)(Arena* arena, u64 count)
|
||||||
{
|
{
|
||||||
void* mem = AllocAlign(arena, T.sizeof * count, DEFAULT_ALIGNMENT);
|
void* mem = AllocAlign(arena, T.sizeof * count, DEFAULT_ALIGNMENT);
|
||||||
memset(mem, 0, T.sizeof * count);
|
memset(mem, 0, T.sizeof * count);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user