Skip to content

Commit c381851

Browse files
gajopclaude
andcommitted
Note the blocking texture-export TODO at its source
Diffuse/shading PNG export runs on the draw thread via the engine's save_image (GL read + encode + write in one blocking call), freezing the editor during export. Document the off-thread fix (read_pixels on the draw thread, tiled, then encode in an IoJob) at the site so it is discoverable. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e8c9804 commit c381851

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

native/src/sbc/textures/project.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ fn load_textures(ctx: &mut Context, paths: &ProjectPaths) {
4444
log_result("load textures", &dir, result);
4545
}
4646

47+
// TODO(perf): these run on the draw thread and freeze the editor during export.
48+
// `save_texture_png` calls the engine's `gfx().save_image`, which reads the GL
49+
// texture AND encodes+writes the PNG in one blocking call. The heightmap/metal/
50+
// grass exports already encode off-thread (`*::jobs::export`); the diffuse and
51+
// shading textures should too: read the pixels on the draw thread via
52+
// `gfx().read_pixels` (only the GL read must be here), then hand the buffer to an
53+
// IoJob that encodes with `io::write::save_png`. Do it in tiles — a full-map
54+
// diffuse read back as `read_pixels`' f32 RGBA is ~1 GB at 8K, so a naive
55+
// whole-texture buffer would OOM on large maps.
4756
fn export_map_textures(ctx: &mut Context, output_dir: &Path, _options: &MapExportOptions) {
4857
let interface = *ctx.interface;
4958
let diffuse = output_dir.join("diffuse.png");

0 commit comments

Comments
 (0)