Foramatting

This commit is contained in:
Zachary Levy
2026-04-19 07:06:42 -07:00
parent c786147720
commit 30b72128b2
3 changed files with 167 additions and 180 deletions

View File

@@ -58,8 +58,8 @@ Rectangle :: struct {
Sub_Batch_Kind :: enum u8 {
Shapes, // non-indexed, white texture, mode 0
Text, // indexed, atlas texture, mode 0
SDF, // instanced unit quad, white texture, mode 1
Text, // indexed, atlas texture, mode 0
SDF, // instanced unit quad, white texture, mode 1
}
Sub_Batch :: struct {
@@ -89,34 +89,34 @@ Scissor :: struct {
GLOB: Global
Global :: struct {
odin_context: runtime.Context,
pipeline_2d_base: Pipeline_2D_Base,
text_cache: Text_Cache,
layers: [dynamic]Layer,
scissors: [dynamic]Scissor,
tmp_shape_verts: [dynamic]Vertex,
tmp_text_verts: [dynamic]Vertex,
tmp_text_indices: [dynamic]c.int,
tmp_text_batches: [dynamic]TextBatch,
tmp_primitives: [dynamic]Primitive,
tmp_sub_batches: [dynamic]Sub_Batch,
clay_mem: [^]u8,
msaa_texture: ^sdl.GPUTexture,
curr_layer_index: uint,
max_layers: int,
max_scissors: int,
max_shape_verts: int,
max_text_verts: int,
max_text_indices: int,
max_text_batches: int,
max_primitives: int,
max_sub_batches: int,
dpi_scaling: f32,
msaa_w: u32,
msaa_h: u32,
sample_count: sdl.GPUSampleCount,
clay_z_index: i16,
cleared: bool,
odin_context: runtime.Context,
pipeline_2d_base: Pipeline_2D_Base,
text_cache: Text_Cache,
layers: [dynamic]Layer,
scissors: [dynamic]Scissor,
tmp_shape_verts: [dynamic]Vertex,
tmp_text_verts: [dynamic]Vertex,
tmp_text_indices: [dynamic]c.int,
tmp_text_batches: [dynamic]TextBatch,
tmp_primitives: [dynamic]Primitive,
tmp_sub_batches: [dynamic]Sub_Batch,
clay_mem: [^]u8,
msaa_texture: ^sdl.GPUTexture,
curr_layer_index: uint,
max_layers: int,
max_scissors: int,
max_shape_verts: int,
max_text_verts: int,
max_text_indices: int,
max_text_batches: int,
max_primitives: int,
max_sub_batches: int,
dpi_scaling: f32,
msaa_w: u32,
msaa_h: u32,
sample_count: sdl.GPUSampleCount,
clay_z_index: i16,
cleared: bool,
}
Init_Options :: struct {
@@ -186,8 +186,8 @@ init :: proc(
return true
}
// TODO every x frames nuke max values in case of edge cases where max gets set very high
// Called at the end of every frame
// TODO Either every x frames nuke max values in case of edge cases where max gets set very high
// or leave to application code to decide the right time for resize
resize_global :: proc() {
if len(GLOB.layers) > GLOB.max_layers do GLOB.max_layers = len(GLOB.layers)
shrink(&GLOB.layers, GLOB.max_layers)
@@ -546,11 +546,7 @@ prepare_clay_batch :: proc(
}
// Render primitives. clear_color is the background fill before any layers are drawn.
end :: proc(
device: ^sdl.GPUDevice,
window: ^sdl.Window,
clear_color: Color = BLACK,
) {
end :: proc(device: ^sdl.GPUDevice, window: ^sdl.Window, clear_color: Color = BLACK) {
cmd_buffer := sdl.AcquireGPUCommandBuffer(device)
if cmd_buffer == nil {
log.panicf("Failed to acquire GPU command buffer: %s", sdl.GetError())
@@ -561,10 +557,6 @@ end :: proc(
upload(device, copy_pass)
sdl.EndGPUCopyPass(copy_pass)
// Resize dynamic arrays
// TODO: This should only be called occasionally, not every frame.
resize_global()
swapchain_texture: ^sdl.GPUTexture
w, h: u32
if !sdl.WaitAndAcquireGPUSwapchainTexture(cmd_buffer, window, &swapchain_texture, &w, &h) {