Hello ! I'm currently writing a renderer and I'm getting hardstuck on a memory issue.
In my init function of my renderer, I'm making a copy of the address of a struct
// init_default_data
self._default_data = self._metal_rough_material.write_material(self._device, material.MaterialPass.MainColor, &material_res, &_descriptor_pool);
std.debug.print("\nbefore insert\n\n", .{});
std.debug.print("opaque pipeline: {*}\n", .{self._default_data.pipeline.pipeline});
for (_test_meshes.items) |*mesh| {
var new_node: *m.Node = try std.heap.page_allocator.create(m.Node);
new_node.children = std.ArrayList(*m.Node).init(std.heap.page_allocator);
new_node.mesh = mesh;
new_node.local_transform = z.Mat4.identity().data;
new_node.world_transform = z.Mat4.identity().data;
for (new_node.mesh.surfaces.items) |*s| {
s.material = self._arena.allocator().create(loader.GLTFMaterial) catch @panic("OOM");
s.material.data = material.MaterialInstance{
.pipeline = self._default_data.pipeline,
.material_set = self._default_data.material_set,
.pass_type = self._default_data.pass_type,
};
std.debug.print("pipeline address {*}\n", .{self._default_data.pipeline.pipeline});
std.debug.print("ptr address {*}\n", .{self._default_data.pipeline });
}
// std.debug.print("name {s}, node {*}\n", .{ mesh.name, new_node });
self._loaded_nodes.append(.{ .key = mesh.name , .value = new_node }) catch @panic("OOM");
}```
I made sure the pipeline still exist after we have exited the init function but, for some reason, VkPipeline and VkPipelineLayout become instable/null once we exit renderer.init.