iOS lock step keyboard + metal
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#import "modules/gpu/types.sx";
|
||||
#import "modules/gpu/api.sx";
|
||||
#import "modules/stb_truetype.sx";
|
||||
#import "modules/stb.sx";
|
||||
#import "modules/ui/types.sx";
|
||||
|
||||
// Cached glyph data with UV coordinates into the atlas texture
|
||||
@@ -426,17 +427,26 @@ GlyphCache :: struct {
|
||||
context.allocator.dealloc(old_vals);
|
||||
}
|
||||
|
||||
// Upload dirty atlas to GPU
|
||||
// Upload dirty atlas to GPU. On the Metal path, defer the upload to
|
||||
// end-of-frame (`upload_atlas_to_gpu`) — calling `replaceRegion:` against
|
||||
// the same R8 MTLTexture multiple times within one frame garbles the
|
||||
// contents on iOS-sim Metal. The dirty flag carries over so the final
|
||||
// end-of-frame upload picks up every rasterization that happened during
|
||||
// the frame's render pass.
|
||||
flush :: (self: *GlyphCache) {
|
||||
if self.dirty == false { return; }
|
||||
if self.has_gpu {
|
||||
self.gpu.update_texture_region(self.texture_id, 0, 0,
|
||||
self.atlas_width, self.atlas_height, xx self.bitmap);
|
||||
} else {
|
||||
glBindTexture(GL_TEXTURE_2D, self.texture_id);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, self.atlas_width, self.atlas_height, GL_RED, GL_UNSIGNED_BYTE, self.bitmap);
|
||||
}
|
||||
if self.has_gpu { return; }
|
||||
glBindTexture(GL_TEXTURE_2D, self.texture_id);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, self.atlas_width, self.atlas_height, GL_RED, GL_UNSIGNED_BYTE, self.bitmap);
|
||||
self.dirty = false;
|
||||
}
|
||||
|
||||
upload_atlas_to_gpu :: (self: *GlyphCache) {
|
||||
if self.has_gpu == false { return; }
|
||||
if self.dirty == false { return; }
|
||||
self.gpu.update_texture_region(self.texture_id, 0, 0,
|
||||
self.atlas_width, self.atlas_height, xx self.bitmap);
|
||||
self.dirty = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user