1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package parity_common
import "core:os"
import app "../../app"
import gpu "../.."
Runtime :: struct {
app_state: app.State,
headless: bool,
}
init_runtime :: proc(width, height: u32, title: cstring) -> (runtime: Runtime, ok: bool) {
runtime.headless = os.get_env("GPU_PROOF_HEADLESS", context.allocator) == "1"
if runtime.headless {
if !gpu.init_headless(width, height, title) {
return runtime, false
}
return runtime, true
}
state, app_ok := app.init_window(i32(width), i32(height), title)
if !app_ok {
return runtime, false
}
runtime.app_state = state
return runtime, true
}
shutdown_runtime :: proc(runtime: ^Runtime) {
if runtime == nil do return
if runtime.headless {
gpu.shutdown()
return
}
app.shutdown(&runtime.app_state)
}