2 #include <kiba/gpu/shader.h>
3 #include <kiba/gpu/vulkan/allocator.h>
4 #include <kiba/gpu/vulkan/device.h>
5 #include <kiba/gpu/vulkan/util.h>
10 usize size_in_bytes = 0;
11 if (desc.code ==
KB_NULL || (size_in_bytes = array_size(desc.code)) == 0) {
12 KB_ERROR(
"provided invalid shader code");
15 u32 code_size = (size_in_bytes + 3u) & ~3u;
16 array_of(u32) vk_code = array_create(u32, code_size /
sizeof(u32), &
vk_alloc.kiba_alloc);
18 KB_ERROR(
"cannot reserve memory to transfer shader code");
23 VkShaderModuleCreateInfo shader_info = {
24 .sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
25 .codeSize = code_size,
29 VK_CALL_B8(vkCreateShaderModule(device->logical, &shader_info, &
vk_alloc.vulkan_callbacks, &shader->raw));
30 array_destroy(&vk_code);
31 vk_device_set_object_name(device->logical, VK_OBJECT_TYPE_SHADER_MODULE, shader->raw, desc.label);
36 if (shader->raw != VK_NULL_HANDLE) {
37 vkDestroyShaderModule(device->logical, shader->raw, &
vk_alloc.vulkan_callbacks);
38 shader->raw = VK_NULL_HANDLE;
void * memory_copy(void *dst, const void *src, usize size)
Copy memory.
Lightweight layer between platform and other engine components to enable tracing/monitoring.
#define KB_NULL
Value of an invalid ptr (nullptr).
#define KB_ERROR(...)
Log entry with error log level.