fixing example performance issues
Some checks failed
Build / build (push) Failing after 30s
Test / build (push) Failing after 54s

This commit is contained in:
2026-01-21 17:44:10 +01:00
parent 19687251b0
commit c175224a01
4 changed files with 28 additions and 23 deletions

View File

@@ -9,8 +9,11 @@ const screen_height = 480;
pub fn main() !void {
{
var gpa: std.heap.DebugAllocator(.{}) = .init;
defer _ = gpa.deinit();
//var gpa: std.heap.DebugAllocator(.{}) = .init;
//defer _ = gpa.deinit();
var gpa = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer gpa.deinit();
defer sdl3.shutdown();
const init_flags = sdl3.InitFlags{ .video = true };
@@ -22,7 +25,7 @@ pub fn main() !void {
const allocator = gpa.allocator();
var module = try spv.Module.init(allocator, @ptrCast(@alignCast(shader_source)));
var module = try spv.Module.init(allocator, @ptrCast(@alignCast(shader_source)), .{});
defer module.deinit(allocator);
const surface = try window.getSurface();
@@ -72,10 +75,10 @@ pub fn main() !void {
try rt.readOutput(f32, output[0..], color);
const rgba = surface.mapRgba(
@intFromFloat(output[0] * 255.0),
@intFromFloat(output[1] * 255.0),
@intFromFloat(output[2] * 255.0),
@intFromFloat(output[3] * 255.0),
@truncate(@as(u32, @intFromFloat(output[0] * 255.0))),
@truncate(@as(u32, @intFromFloat(output[1] * 255.0))),
@truncate(@as(u32, @intFromFloat(output[2] * 255.0))),
@truncate(@as(u32, @intFromFloat(output[3] * 255.0))),
);
pixel_map[(y * surface.getWidth()) + x] = rgba.value;