mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-05 19:08:17 +00:00
renderer: disable multi-buffering for OpenGL
Frames are sequential for OpenGL since the completion handler always calls `glFinish`, so the extra buffers do nothing but waste memory.
This commit is contained in:
@@ -29,6 +29,10 @@ pub const imagepkg = @import("opengl/image.zig");
|
||||
|
||||
pub const custom_shader_target: shadertoy.Target = .glsl;
|
||||
|
||||
/// Because OpenGL's frame completion is always
|
||||
/// sync, we have no need for multi-buffering.
|
||||
pub const swap_chain_count = 1;
|
||||
|
||||
const log = std.log.scoped(.opengl);
|
||||
|
||||
/// We require at least OpenGL 4.3
|
||||
|
@@ -204,8 +204,15 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
|
||||
// If this is one then we don't do any double+ buffering at all.
|
||||
// This is comptime because there isn't a good reason to change
|
||||
// this at runtime and there is a lot of complexity to support it.
|
||||
// For comptime, this is useful for debugging.
|
||||
const buf_count = 3;
|
||||
const buf_count = count: {
|
||||
if (@hasDecl(GraphicsAPI, "swap_chain_count")) {
|
||||
break :count GraphicsAPI.swap_chain_count;
|
||||
}
|
||||
|
||||
// Default to triple buffering if
|
||||
// graphics API has no preference.
|
||||
break :count 3;
|
||||
};
|
||||
|
||||
/// `buf_count` structs that can hold the
|
||||
/// data needed by the GPU to draw a frame.
|
||||
|
Reference in New Issue
Block a user