fixing dangling pointer
This commit is contained in:
@@ -92,7 +92,8 @@ fn taskRunner(self: *Self, info: Interface.SubmitInfo, p_fence: ?*base.Fence, ru
|
|||||||
command_buffers.deinit(soft_device.device_allocator.allocator());
|
command_buffers.deinit(soft_device.device_allocator.allocator());
|
||||||
}
|
}
|
||||||
|
|
||||||
var execution_device: ExecutionDevice = .init(soft_device);
|
var execution_device: ExecutionDevice = undefined;
|
||||||
|
execution_device.init(soft_device);
|
||||||
defer execution_device.deinit();
|
defer execution_device.deinit();
|
||||||
|
|
||||||
for (info.command_buffers.items) |command_buffer| {
|
for (info.command_buffers.items) |command_buffer| {
|
||||||
|
|||||||
@@ -63,9 +63,7 @@ pub fn dispatch(self: *Self, group_count_x: u32, group_count_y: u32, group_count
|
|||||||
|
|
||||||
var wg: std.Io.Group = .init;
|
var wg: std.Io.Group = .init;
|
||||||
for (0..@min(self.batch_size, group_count)) |batch_id| {
|
for (0..@min(self.batch_size, group_count)) |batch_id| {
|
||||||
if (base.config.single_threaded_compute) {
|
if (comptime base.config.single_threaded_compute) {
|
||||||
@branchHint(.cold); // Should only be reached for debugging
|
|
||||||
|
|
||||||
runWrapper(
|
runWrapper(
|
||||||
RunData{
|
RunData{
|
||||||
.self = self,
|
.self = self,
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ renderer: Renderer,
|
|||||||
/// .compute = 1
|
/// .compute = 1
|
||||||
pipeline_states: [2]PipelineState,
|
pipeline_states: [2]PipelineState,
|
||||||
|
|
||||||
pub fn init(device: *SoftDevice) Self {
|
/// Initializating an execution device and
|
||||||
var self: Self = undefined;
|
/// not creating one to avoid dangling pointers
|
||||||
|
pub fn init(self: *Self, device: *SoftDevice) void {
|
||||||
for (self.pipeline_states[0..]) |*state| {
|
for (self.pipeline_states[0..]) |*state| {
|
||||||
state.* = .{
|
state.* = .{
|
||||||
.pipeline = null,
|
.pipeline = null,
|
||||||
@@ -38,8 +38,6 @@ pub fn init(device: *SoftDevice) Self {
|
|||||||
}
|
}
|
||||||
self.compute = .init(device, &self.pipeline_states[@intFromEnum(vk.PipelineBindPoint.compute)]);
|
self.compute = .init(device, &self.pipeline_states[@intFromEnum(vk.PipelineBindPoint.compute)]);
|
||||||
self.renderer = .init();
|
self.renderer = .init();
|
||||||
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn deinit(self: *Self) void {
|
pub fn deinit(self: *Self) void {
|
||||||
|
|||||||
Reference in New Issue
Block a user