aboutsummaryrefslogtreecommitdiff
path: root/vendor/wgpu/wgpu_js.odin
blob: 3217a97dc7525d5e21e2c09119195fa799c6501a (plain)
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
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")
}