mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
only try to lock on main
This commit is contained in:
@ -59,7 +59,7 @@ fetch(url.href)
|
||||
|
||||
// Create our config
|
||||
const config_str = makeStr("font-family = monospace\nfont-size = 32\n");
|
||||
old(results);
|
||||
// old(results);
|
||||
setWasmModule(results.module);
|
||||
const stdin = new SharedArrayBuffer(1024);
|
||||
const files = {
|
||||
@ -81,20 +81,20 @@ fetch(url.href)
|
||||
Atomics.notify(n, 0);
|
||||
console.error("done storing");
|
||||
function drawing() {
|
||||
setTimeout(() => {
|
||||
requestAnimationFrame(() => {
|
||||
draw();
|
||||
drawing();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
}
|
||||
drawing()
|
||||
setTimeout(() => {
|
||||
const io = new Uint8ClampedArray(stdin, 4);
|
||||
const text = new TextEncoder().encode("🐏\n\r👍🏽\n\rM_ghostty\033[2;2H\033[48;2;240;40;40m\033[38;2;23;255;80mhello");
|
||||
io.set(text);
|
||||
const n = new Int32Array(stdin);
|
||||
console.error("storing");
|
||||
Atomics.store(n, 0, text.length)
|
||||
const place = Atomics.add(n, 0, text.length)
|
||||
const io = new Uint8ClampedArray(stdin, 4 + place);
|
||||
io.set(text);
|
||||
Atomics.notify(n, 0);
|
||||
console.error("done storing");
|
||||
}, 5000)
|
||||
|
@ -78,12 +78,11 @@ pub const std_options: std.Options = .{
|
||||
// Set our log level. We try to get as much logging as possible but in
|
||||
// ReleaseSmall mode where we're optimizing for space, we elevate the
|
||||
// log level.
|
||||
// .log_level = switch (builtin.mode) {
|
||||
// .Debug => .debug,
|
||||
// .ReleaseSmall => .warn,
|
||||
// else => .info,
|
||||
// },
|
||||
.log_level = .info,
|
||||
.log_level = switch (builtin.mode) {
|
||||
.Debug => .debug,
|
||||
.ReleaseSmall => .warn,
|
||||
else => .info,
|
||||
},
|
||||
|
||||
// Set our log function
|
||||
.logFn = @import("os/wasm/log.zig").log,
|
||||
|
@ -2182,7 +2182,6 @@ fn flushAtlasSingle(
|
||||
internal_format: gl.Texture.InternalFormat,
|
||||
format: gl.Texture.Format,
|
||||
) !void {
|
||||
std.log.err("starging flushing atlas", .{});
|
||||
// If the texture isn't modified we do nothing
|
||||
const new_modified = atlas.modified.load(.monotonic);
|
||||
if (new_modified <= modified.*) return;
|
||||
@ -2195,7 +2194,6 @@ fn flushAtlasSingle(
|
||||
defer texbind.unbind();
|
||||
|
||||
const new_resized = atlas.resized.load(.monotonic);
|
||||
std.log.err("flushing atlas", .{});
|
||||
if (new_resized > resized.*) {
|
||||
try texbind.image2D(
|
||||
0,
|
||||
@ -2231,9 +2229,15 @@ fn flushAtlasSingle(
|
||||
/// the cells.
|
||||
pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void {
|
||||
// If we're in single-threaded more we grab a lock since we use shared data.
|
||||
// wasm can't use a mutex on the main thread because it uses Atomic.wait
|
||||
if (single_threaded_draw and builtin.cpu.arch != .wasm32) self.draw_mutex.lock();
|
||||
defer if (single_threaded_draw and builtin.cpu.arch != .wasm32) self.draw_mutex.unlock();
|
||||
// wasm can't lock a mutex on the main thread because it uses Atomic.wait
|
||||
if (single_threaded_draw) {
|
||||
if (builtin.cpu.arch == .wasm32) {
|
||||
if (!self.draw_mutex.tryLock()) return;
|
||||
} else {
|
||||
self.draw_mutex.lock();
|
||||
}
|
||||
}
|
||||
defer if (single_threaded_draw) self.draw_mutex.unlock();
|
||||
const gl_state: *GLState = if (self.gl_state) |*v| v else return;
|
||||
|
||||
// Go through our images and see if we need to setup any textures.
|
||||
@ -2465,10 +2469,8 @@ fn drawCells(
|
||||
gl_state: *const GLState,
|
||||
cells: std.ArrayListUnmanaged(CellProgram.Cell),
|
||||
) !void {
|
||||
std.log.err("start drawing cells", .{});
|
||||
// If we have no cells to render, then we render nothing.
|
||||
if (cells.items.len == 0) return;
|
||||
std.log.err("have cells", .{});
|
||||
|
||||
// Todo: get rid of this completely
|
||||
self.gl_cells_written = 0;
|
||||
@ -2489,10 +2491,10 @@ fn drawCells(
|
||||
// Our allocated buffer on the GPU is smaller than our capacity.
|
||||
// We reallocate a new buffer with the full new capacity.
|
||||
if (self.gl_cells_size < cells.capacity) {
|
||||
log.info("reallocating GPU buffer old={} new={}", .{
|
||||
self.gl_cells_size,
|
||||
cells.capacity,
|
||||
});
|
||||
// log.info("reallocating GPU buffer old={} new={}", .{
|
||||
// self.gl_cells_size,
|
||||
// cells.capacity,
|
||||
// });
|
||||
|
||||
try bind.vbo.setDataNullManual(
|
||||
@sizeOf(CellProgram.Cell) * cells.capacity,
|
||||
@ -2506,7 +2508,7 @@ fn drawCells(
|
||||
// If we have data to write to the GPU, send it.
|
||||
if (self.gl_cells_written < cells.items.len) {
|
||||
const data = cells.items[self.gl_cells_written..];
|
||||
log.info("sending {} cells to GPU", .{data.len});
|
||||
// log.info("sending {} cells to GPU", .{data.len});
|
||||
try bind.vbo.setSubData(self.gl_cells_written * @sizeOf(CellProgram.Cell), data);
|
||||
|
||||
self.gl_cells_written += data.len;
|
||||
|
Reference in New Issue
Block a user