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
|
// Create our config
|
||||||
const config_str = makeStr("font-family = monospace\nfont-size = 32\n");
|
const config_str = makeStr("font-family = monospace\nfont-size = 32\n");
|
||||||
old(results);
|
// old(results);
|
||||||
setWasmModule(results.module);
|
setWasmModule(results.module);
|
||||||
const stdin = new SharedArrayBuffer(1024);
|
const stdin = new SharedArrayBuffer(1024);
|
||||||
const files = {
|
const files = {
|
||||||
@ -81,20 +81,20 @@ fetch(url.href)
|
|||||||
Atomics.notify(n, 0);
|
Atomics.notify(n, 0);
|
||||||
console.error("done storing");
|
console.error("done storing");
|
||||||
function drawing() {
|
function drawing() {
|
||||||
setTimeout(() => {
|
requestAnimationFrame(() => {
|
||||||
draw();
|
draw();
|
||||||
drawing();
|
drawing();
|
||||||
}, 100);
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
drawing()
|
drawing()
|
||||||
setTimeout(() => {
|
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");
|
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);
|
const n = new Int32Array(stdin);
|
||||||
console.error("storing");
|
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);
|
Atomics.notify(n, 0);
|
||||||
console.error("done storing");
|
console.error("done storing");
|
||||||
}, 5000)
|
}, 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
|
// 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
|
// ReleaseSmall mode where we're optimizing for space, we elevate the
|
||||||
// log level.
|
// log level.
|
||||||
// .log_level = switch (builtin.mode) {
|
.log_level = switch (builtin.mode) {
|
||||||
// .Debug => .debug,
|
.Debug => .debug,
|
||||||
// .ReleaseSmall => .warn,
|
.ReleaseSmall => .warn,
|
||||||
// else => .info,
|
else => .info,
|
||||||
// },
|
},
|
||||||
.log_level = .info,
|
|
||||||
|
|
||||||
// Set our log function
|
// Set our log function
|
||||||
.logFn = @import("os/wasm/log.zig").log,
|
.logFn = @import("os/wasm/log.zig").log,
|
||||||
|
@ -2182,7 +2182,6 @@ fn flushAtlasSingle(
|
|||||||
internal_format: gl.Texture.InternalFormat,
|
internal_format: gl.Texture.InternalFormat,
|
||||||
format: gl.Texture.Format,
|
format: gl.Texture.Format,
|
||||||
) !void {
|
) !void {
|
||||||
std.log.err("starging flushing atlas", .{});
|
|
||||||
// If the texture isn't modified we do nothing
|
// If the texture isn't modified we do nothing
|
||||||
const new_modified = atlas.modified.load(.monotonic);
|
const new_modified = atlas.modified.load(.monotonic);
|
||||||
if (new_modified <= modified.*) return;
|
if (new_modified <= modified.*) return;
|
||||||
@ -2195,7 +2194,6 @@ fn flushAtlasSingle(
|
|||||||
defer texbind.unbind();
|
defer texbind.unbind();
|
||||||
|
|
||||||
const new_resized = atlas.resized.load(.monotonic);
|
const new_resized = atlas.resized.load(.monotonic);
|
||||||
std.log.err("flushing atlas", .{});
|
|
||||||
if (new_resized > resized.*) {
|
if (new_resized > resized.*) {
|
||||||
try texbind.image2D(
|
try texbind.image2D(
|
||||||
0,
|
0,
|
||||||
@ -2231,9 +2229,15 @@ fn flushAtlasSingle(
|
|||||||
/// the cells.
|
/// the cells.
|
||||||
pub fn drawFrame(self: *OpenGL, surface: *apprt.Surface) !void {
|
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.
|
// 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
|
// wasm can't lock a mutex on the main thread because it uses Atomic.wait
|
||||||
if (single_threaded_draw and builtin.cpu.arch != .wasm32) self.draw_mutex.lock();
|
if (single_threaded_draw) {
|
||||||
defer if (single_threaded_draw and builtin.cpu.arch != .wasm32) self.draw_mutex.unlock();
|
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;
|
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.
|
// Go through our images and see if we need to setup any textures.
|
||||||
@ -2465,10 +2469,8 @@ fn drawCells(
|
|||||||
gl_state: *const GLState,
|
gl_state: *const GLState,
|
||||||
cells: std.ArrayListUnmanaged(CellProgram.Cell),
|
cells: std.ArrayListUnmanaged(CellProgram.Cell),
|
||||||
) !void {
|
) !void {
|
||||||
std.log.err("start drawing cells", .{});
|
|
||||||
// If we have no cells to render, then we render nothing.
|
// If we have no cells to render, then we render nothing.
|
||||||
if (cells.items.len == 0) return;
|
if (cells.items.len == 0) return;
|
||||||
std.log.err("have cells", .{});
|
|
||||||
|
|
||||||
// Todo: get rid of this completely
|
// Todo: get rid of this completely
|
||||||
self.gl_cells_written = 0;
|
self.gl_cells_written = 0;
|
||||||
@ -2489,10 +2491,10 @@ fn drawCells(
|
|||||||
// Our allocated buffer on the GPU is smaller than our capacity.
|
// Our allocated buffer on the GPU is smaller than our capacity.
|
||||||
// We reallocate a new buffer with the full new capacity.
|
// We reallocate a new buffer with the full new capacity.
|
||||||
if (self.gl_cells_size < cells.capacity) {
|
if (self.gl_cells_size < cells.capacity) {
|
||||||
log.info("reallocating GPU buffer old={} new={}", .{
|
// log.info("reallocating GPU buffer old={} new={}", .{
|
||||||
self.gl_cells_size,
|
// self.gl_cells_size,
|
||||||
cells.capacity,
|
// cells.capacity,
|
||||||
});
|
// });
|
||||||
|
|
||||||
try bind.vbo.setDataNullManual(
|
try bind.vbo.setDataNullManual(
|
||||||
@sizeOf(CellProgram.Cell) * cells.capacity,
|
@sizeOf(CellProgram.Cell) * cells.capacity,
|
||||||
@ -2506,7 +2508,7 @@ fn drawCells(
|
|||||||
// If we have data to write to the GPU, send it.
|
// If we have data to write to the GPU, send it.
|
||||||
if (self.gl_cells_written < cells.items.len) {
|
if (self.gl_cells_written < cells.items.len) {
|
||||||
const data = cells.items[self.gl_cells_written..];
|
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);
|
try bind.vbo.setSubData(self.gl_cells_written * @sizeOf(CellProgram.Cell), data);
|
||||||
|
|
||||||
self.gl_cells_written += data.len;
|
self.gl_cells_written += data.len;
|
||||||
|
Reference in New Issue
Block a user