Hi, sorry for the bad title, couldn't think of a good one.
im having trouble, im trying to replace @embedfile with runtime known code, that way i don't have to recompile every time i change shader code.
var shader_modules: [2]vk.ShaderModule = undefined;
for (shader_paths, 0..) |s, i| {
const shader_file = try std.fs.cwd().openFile(s, .{});
defer shader_file.close();
const spirv: []u8 align(@alignOf(u32)) = try allocator.alloc(u8, try shader_file.getEndPos());
defer allocator.free(spirv);
const shader_len = try shader_file.readAll(spirv);
std.debug.assert(shader_len == spirv.len);
const shader_mod = try gc.dev.createShaderModule(&.{
.code_size = spirv.len,
.p_code = @ptrCast(&spirv),
}, null);
shader_modules[i] = shader_mod;
}
defer gc.dev.destroyShaderModule(shader_modules[0], null);
defer gc.dev.destroyShaderModule(shader_modules[1], null);
this code is for a vulkan shader module, the problem is, it expects a ?[*]const u32 array, but due to alignemnt or some other reason. the SPIRV code seems to be wrong.
readall expects a []u8, so i can't supply it with a []u32, i tried aligning as you see in the code, but it doesn't work either.
this is the vulkan error, although im not sure if it'll be much of help
VUID-VkShaderModuleCreateInfo-pCode-07912(ERROR / SPEC): msgNum: 979894520 - Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-07912 ] | MessageID = 0x3a6800f8 | vkCreateShaderModule(): pCreateInfo->pCode doesn't point to a SPIR-V module. The Vulkan spec states: If the VK_NV_glsl_shader extension is not enabled, pCode must be a pointer to SPIR-V code (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkShaderModuleCreateInfo-pCode-07912)
Objects: 0