mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-01 10:52:19 +00:00
28 lines
601 B
Odin
28 lines
601 B
Odin
package wgpu
|
|
|
|
import "base:runtime"
|
|
|
|
g_context: runtime.Context
|
|
|
|
@(private="file", init)
|
|
wgpu_init_allocator :: proc "contextless" () {
|
|
if g_context.allocator.procedure == nil {
|
|
g_context = runtime.default_context()
|
|
}
|
|
}
|
|
|
|
@(private="file", export)
|
|
wgpu_alloc :: proc "contextless" (size: i32) -> [^]byte {
|
|
context = g_context
|
|
bytes, err := runtime.mem_alloc(int(size), 16)
|
|
assert(err == nil, "wgpu_alloc failed")
|
|
return raw_data(bytes)
|
|
}
|
|
|
|
@(private="file", export)
|
|
wgpu_free :: proc "contextless" (ptr: rawptr) {
|
|
context = g_context
|
|
err := free(ptr)
|
|
assert(err == nil, "wgpu_free failed")
|
|
}
|