Compare commits

...

2 commits
main ... origin

3 changed files with 11 additions and 6 deletions

View file

@ -18,7 +18,7 @@ pub const Entity = struct {
color: u32, color: u32,
}; };
pub const MAX_ENTITIES: usize = 1_000_000; pub const MAX_ENTITIES: usize = 10_000_000;
pub const Entities = struct { pub const Entities = struct {
items: []Entity, items: []Entity,

View file

@ -20,7 +20,7 @@ const TEXTURE_SIZE: i32 = 16; // must be >= 2 * radius
const MESH_SIZE: f32 = @floatFromInt(TEXTURE_SIZE); // match texture size const MESH_SIZE: f32 = @floatFromInt(TEXTURE_SIZE); // match texture size
// logging thresholds // logging thresholds
const TARGET_FRAME_MS: f32 = 16.7; // 60fps const TARGET_FRAME_MS: f32 = 8.33; // 120fps
const THRESHOLD_MARGIN: f32 = 2.0; // hysteresis margin to avoid bounce const THRESHOLD_MARGIN: f32 = 2.0; // hysteresis margin to avoid bounce
const JUMP_THRESHOLD_MS: f32 = 5.0; // log if frame time jumps by this much const JUMP_THRESHOLD_MS: f32 = 5.0; // log if frame time jumps by this much
const HEARTBEAT_INTERVAL: f32 = 10.0; // seconds between periodic logs const HEARTBEAT_INTERVAL: f32 = 10.0; // seconds between periodic logs
@ -156,6 +156,7 @@ pub fn main() !void {
var bench_mode = false; var bench_mode = false;
var use_instancing = false; var use_instancing = false;
var use_ssbo = true; var use_ssbo = true;
var use_vsync = false;
var args = try std.process.argsWithAllocator(std.heap.page_allocator); var args = try std.process.argsWithAllocator(std.heap.page_allocator);
defer args.deinit(); defer args.deinit();
_ = args.skip(); // skip program name _ = args.skip(); // skip program name
@ -167,12 +168,16 @@ pub fn main() !void {
use_ssbo = false; // legacy GPU instancing path use_ssbo = false; // legacy GPU instancing path
} else if (std.mem.eql(u8, arg, "--legacy")) { } else if (std.mem.eql(u8, arg, "--legacy")) {
use_ssbo = false; // legacy rlgl batched path use_ssbo = false; // legacy rlgl batched path
} else if (std.mem.eql(u8, arg, "--vsync")) {
use_vsync = true;
} }
} }
if (use_vsync) {
rl.setConfigFlags(.{ .vsync_hint = true });
}
rl.initWindow(@intCast(SCREEN_WIDTH), @intCast(SCREEN_HEIGHT), "lofivor sandbox"); rl.initWindow(@intCast(SCREEN_WIDTH), @intCast(SCREEN_HEIGHT), "lofivor sandbox");
defer rl.closeWindow(); defer rl.closeWindow();
rl.setTargetFPS(60);
// use larger batch buffer: 16384 elements vs default 8192 // use larger batch buffer: 16384 elements vs default 8192
// fewer flushes = less driver overhead per frame // fewer flushes = less driver overhead per frame
@ -397,7 +402,7 @@ var sub_timer: f32 = 0;
fn handleInput(entities: *sandbox.Entities, rng: *std.Random, paused: *bool) void { fn handleInput(entities: *sandbox.Entities, rng: *std.Random, paused: *bool) void {
const dt = rl.getFrameTime(); const dt = rl.getFrameTime();
const shift = rl.isKeyDown(.left_shift) or rl.isKeyDown(.right_shift); const shift = rl.isKeyDown(.left_shift) or rl.isKeyDown(.right_shift);
const add_count: usize = if (shift) 10000 else 1000; const add_count: usize = if (shift) 50_000 else 10_000;
const add_held = rl.isKeyDown(.equal) or rl.isKeyDown(.kp_add); const add_held = rl.isKeyDown(.equal) or rl.isKeyDown(.kp_add);
const sub_held = rl.isKeyDown(.minus) or rl.isKeyDown(.kp_subtract); const sub_held = rl.isKeyDown(.minus) or rl.isKeyDown(.kp_subtract);

View file

@ -82,8 +82,8 @@ fn drawControls(font: rl.Font, metrics_bottom: i32) void {
var y: f32 = @as(f32, @floatFromInt(ctrl_box_y)) + box_padding; var y: f32 = @as(f32, @floatFromInt(ctrl_box_y)) + box_padding;
const controls = [_][]const u8{ const controls = [_][]const u8{
"+/-: 1000 entities", "+/-: 10k entities",
"shift +/-: 10000", "shift +/-: 50k",
"space: pause", "space: pause",
"r: reset", "r: reset",
}; };