mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 13:00:28 +00:00
wgpu: update to v24.0.0
This commit is contained in:
4
vendor/wgpu/README.md
vendored
4
vendor/wgpu/README.md
vendored
@@ -11,8 +11,8 @@ Have a look at the `example/` directory for the rendering of a basic triangle.
|
||||
## Getting the wgpu-native libraries
|
||||
|
||||
For native support (not the browser), some libraries are required. Fortunately this is
|
||||
extremely easy, just download them from the [releases on GitHub](https://github.com/gfx-rs/wgpu-native/releases/tag/v22.1.0.1),
|
||||
the bindings are for v22.1.0.1 at the moment.
|
||||
extremely easy, just download them from the [releases on GitHub](https://github.com/gfx-rs/wgpu-native/releases/tag/v24.0.1),
|
||||
the bindings are for v24.0.1 at the moment.
|
||||
|
||||
These are expected in the `lib` folder under the same name as they are released (just unzipped).
|
||||
By default it will look for a static release version (`wgpu-OS-ARCH-release.a|lib`),
|
||||
|
||||
18
vendor/wgpu/examples/glfw/main.odin
vendored
18
vendor/wgpu/examples/glfw/main.odin
vendored
@@ -35,18 +35,18 @@ main :: proc() {
|
||||
}
|
||||
state.surface = os_get_surface(&state.os, state.instance)
|
||||
|
||||
wgpu.InstanceRequestAdapter(state.instance, &{ compatibleSurface = state.surface }, on_adapter, nil)
|
||||
wgpu.InstanceRequestAdapter(state.instance, &{ compatibleSurface = state.surface }, { callback = on_adapter })
|
||||
|
||||
on_adapter :: proc "c" (status: wgpu.RequestAdapterStatus, adapter: wgpu.Adapter, message: cstring, userdata: rawptr) {
|
||||
on_adapter :: proc "c" (status: wgpu.RequestAdapterStatus, adapter: wgpu.Adapter, message: string, userdata1: rawptr, userdata2: rawptr) {
|
||||
context = state.ctx
|
||||
if status != .Success || adapter == nil {
|
||||
fmt.panicf("request adapter failure: [%v] %s", status, message)
|
||||
}
|
||||
state.adapter = adapter
|
||||
wgpu.AdapterRequestDevice(adapter, nil, on_device)
|
||||
wgpu.AdapterRequestDevice(adapter, nil, { callback = on_device })
|
||||
}
|
||||
|
||||
on_device :: proc "c" (status: wgpu.RequestDeviceStatus, device: wgpu.Device, message: cstring, userdata: rawptr) {
|
||||
on_device :: proc "c" (status: wgpu.RequestDeviceStatus, device: wgpu.Device, message: string, userdata1: rawptr, userdata2: rawptr) {
|
||||
context = state.ctx
|
||||
if status != .Success || device == nil {
|
||||
fmt.panicf("request device failure: [%v] %s", status, message)
|
||||
@@ -82,8 +82,8 @@ main :: proc() {
|
||||
}`
|
||||
|
||||
state.module = wgpu.DeviceCreateShaderModule(state.device, &{
|
||||
nextInChain = &wgpu.ShaderModuleWGSLDescriptor{
|
||||
sType = .ShaderModuleWGSLDescriptor,
|
||||
nextInChain = &wgpu.ShaderSourceWGSL{
|
||||
sType = .ShaderSourceWGSL,
|
||||
code = shader,
|
||||
},
|
||||
})
|
||||
@@ -130,8 +130,8 @@ frame :: proc "c" (dt: f32) {
|
||||
|
||||
surface_texture := wgpu.SurfaceGetCurrentTexture(state.surface)
|
||||
switch surface_texture.status {
|
||||
case .Success:
|
||||
// All good, could check for `surface_texture.suboptimal` here.
|
||||
case .SuccessOptimal, .SuccessSuboptimal:
|
||||
// All good, could handle suboptimal here.
|
||||
case .Timeout, .Outdated, .Lost:
|
||||
// Skip this frame, and re-configure surface.
|
||||
if surface_texture.texture != nil {
|
||||
@@ -139,7 +139,7 @@ frame :: proc "c" (dt: f32) {
|
||||
}
|
||||
resize()
|
||||
return
|
||||
case .OutOfMemory, .DeviceLost:
|
||||
case .OutOfMemory, .DeviceLost, .Error:
|
||||
// Fatal error
|
||||
fmt.panicf("[triangle] get_current_texture status=%v", surface_texture.status)
|
||||
}
|
||||
|
||||
2
vendor/wgpu/examples/glfw/os_glfw.odin
vendored
2
vendor/wgpu/examples/glfw/os_glfw.odin
vendored
@@ -23,7 +23,7 @@ os_init :: proc(os: ^OS) {
|
||||
}
|
||||
|
||||
os_run :: proc(os: ^OS) {
|
||||
dt: f32
|
||||
dt: f32
|
||||
|
||||
for !glfw.WindowShouldClose(os.window) {
|
||||
start := time.tick_now()
|
||||
|
||||
4
vendor/wgpu/examples/glfw/os_js.odin
vendored
4
vendor/wgpu/examples/glfw/os_js.odin
vendored
@@ -30,8 +30,8 @@ os_get_surface :: proc(os: ^OS, instance: wgpu.Instance) -> wgpu.Surface {
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromCanvasHTMLSelector{
|
||||
sType = .SurfaceDescriptorFromCanvasHTMLSelector,
|
||||
nextInChain = &wgpu.SurfaceSourceCanvasHTMLSelector{
|
||||
sType = .SurfaceSourceCanvasHTMLSelector,
|
||||
selector = "#wgpu-canvas",
|
||||
},
|
||||
},
|
||||
|
||||
18
vendor/wgpu/examples/sdl2/main.odin
vendored
18
vendor/wgpu/examples/sdl2/main.odin
vendored
@@ -35,18 +35,18 @@ main :: proc() {
|
||||
}
|
||||
state.surface = os_get_surface(&state.os, state.instance)
|
||||
|
||||
wgpu.InstanceRequestAdapter(state.instance, &{ compatibleSurface = state.surface }, on_adapter, nil)
|
||||
wgpu.InstanceRequestAdapter(state.instance, &{ compatibleSurface = state.surface }, { callback = on_adapter })
|
||||
|
||||
on_adapter :: proc "c" (status: wgpu.RequestAdapterStatus, adapter: wgpu.Adapter, message: cstring, userdata: rawptr) {
|
||||
on_adapter :: proc "c" (status: wgpu.RequestAdapterStatus, adapter: wgpu.Adapter, message: string, userdata1, userdata2: rawptr) {
|
||||
context = state.ctx
|
||||
if status != .Success || adapter == nil {
|
||||
fmt.panicf("request adapter failure: [%v] %s", status, message)
|
||||
}
|
||||
state.adapter = adapter
|
||||
wgpu.AdapterRequestDevice(adapter, nil, on_device)
|
||||
wgpu.AdapterRequestDevice(adapter, nil, { callback = on_device })
|
||||
}
|
||||
|
||||
on_device :: proc "c" (status: wgpu.RequestDeviceStatus, device: wgpu.Device, message: cstring, userdata: rawptr) {
|
||||
on_device :: proc "c" (status: wgpu.RequestDeviceStatus, device: wgpu.Device, message: string, userdata1, userdata2: rawptr) {
|
||||
context = state.ctx
|
||||
if status != .Success || device == nil {
|
||||
fmt.panicf("request device failure: [%v] %s", status, message)
|
||||
@@ -82,8 +82,8 @@ main :: proc() {
|
||||
}`
|
||||
|
||||
state.module = wgpu.DeviceCreateShaderModule(state.device, &{
|
||||
nextInChain = &wgpu.ShaderModuleWGSLDescriptor{
|
||||
sType = .ShaderModuleWGSLDescriptor,
|
||||
nextInChain = &wgpu.ShaderSourceWGSL{
|
||||
sType = .ShaderSourceWGSL,
|
||||
code = shader,
|
||||
},
|
||||
})
|
||||
@@ -130,8 +130,8 @@ frame :: proc "c" (dt: f32) {
|
||||
|
||||
surface_texture := wgpu.SurfaceGetCurrentTexture(state.surface)
|
||||
switch surface_texture.status {
|
||||
case .Success:
|
||||
// All good, could check for `surface_texture.suboptimal` here.
|
||||
case .SuccessOptimal, .SuccessSuboptimal:
|
||||
// All good, could handle suboptimal here.
|
||||
case .Timeout, .Outdated, .Lost:
|
||||
// Skip this frame, and re-configure surface.
|
||||
if surface_texture.texture != nil {
|
||||
@@ -139,7 +139,7 @@ frame :: proc "c" (dt: f32) {
|
||||
}
|
||||
resize()
|
||||
return
|
||||
case .OutOfMemory, .DeviceLost:
|
||||
case .OutOfMemory, .DeviceLost, .Error:
|
||||
// Fatal error
|
||||
fmt.panicf("[triangle] get_current_texture status=%v", surface_texture.status)
|
||||
}
|
||||
|
||||
4
vendor/wgpu/examples/sdl2/os_js.odin
vendored
4
vendor/wgpu/examples/sdl2/os_js.odin
vendored
@@ -30,8 +30,8 @@ os_get_surface :: proc(os: ^OS, instance: wgpu.Instance) -> wgpu.Surface {
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromCanvasHTMLSelector{
|
||||
sType = .SurfaceDescriptorFromCanvasHTMLSelector,
|
||||
nextInChain = &wgpu.SurfaceSourceCanvasHTMLSelector{
|
||||
sType = .SurfaceSourceCanvasHTMLSelector,
|
||||
selector = "#wgpu-canvas",
|
||||
},
|
||||
},
|
||||
|
||||
4
vendor/wgpu/glfwglue/glue_darwin.odin
vendored
4
vendor/wgpu/glfwglue/glue_darwin.odin
vendored
@@ -12,9 +12,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: glfw.WindowHandle) -> wgpu.S
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromMetalLayer{
|
||||
nextInChain = &wgpu.SurfaceSourceMetalLayer{
|
||||
chain = wgpu.ChainedStruct{
|
||||
sType = .SurfaceDescriptorFromMetalLayer,
|
||||
sType = .SurfaceSourceMetalLayer,
|
||||
},
|
||||
layer = rawptr(metal_layer),
|
||||
},
|
||||
|
||||
8
vendor/wgpu/glfwglue/glue_linux.odin
vendored
8
vendor/wgpu/glfwglue/glue_linux.odin
vendored
@@ -11,9 +11,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: glfw.WindowHandle) -> wgpu.S
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromWaylandSurface{
|
||||
nextInChain = &wgpu.SurfaceSourceWaylandSurface{
|
||||
chain = {
|
||||
sType = .SurfaceDescriptorFromWaylandSurface,
|
||||
sType = .SurfaceSourceWaylandSurface,
|
||||
},
|
||||
display = display,
|
||||
surface = surface,
|
||||
@@ -32,9 +32,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: glfw.WindowHandle) -> wgpu.S
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromXlibWindow{
|
||||
nextInChain = &wgpu.SurfaceSourceXlibWindow{
|
||||
chain = {
|
||||
sType = .SurfaceDescriptorFromXlibWindow,
|
||||
sType = .SurfaceSourceXlibWindow,
|
||||
},
|
||||
display = display,
|
||||
window = u64(window),
|
||||
|
||||
4
vendor/wgpu/glfwglue/glue_windows.odin
vendored
4
vendor/wgpu/glfwglue/glue_windows.odin
vendored
@@ -11,9 +11,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: glfw.WindowHandle) -> wgpu.S
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromWindowsHWND{
|
||||
nextInChain = &wgpu.SurfaceSourceWindowsHWND{
|
||||
chain = wgpu.ChainedStruct{
|
||||
sType = .SurfaceDescriptorFromWindowsHWND,
|
||||
sType = .SurfaceSourceWindowsHWND,
|
||||
},
|
||||
hinstance = rawptr(hinstance),
|
||||
hwnd = rawptr(hwnd),
|
||||
|
||||
4
vendor/wgpu/sdl2glue/glue_darwin.odin
vendored
4
vendor/wgpu/sdl2glue/glue_darwin.odin
vendored
@@ -14,9 +14,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: ^sdl2.Window) -> wgpu.Surfac
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromMetalLayer{
|
||||
nextInChain = &wgpu.SurfaceSourceMetalLayer{
|
||||
chain = wgpu.ChainedStruct{
|
||||
sType = .SurfaceDescriptorFromMetalLayer,
|
||||
sType = .SurfaceSourceMetalLayer,
|
||||
},
|
||||
layer = rawptr(metal_layer),
|
||||
},
|
||||
|
||||
8
vendor/wgpu/sdl2glue/glue_linux.odin
vendored
8
vendor/wgpu/sdl2glue/glue_linux.odin
vendored
@@ -14,9 +14,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: ^sdl2.Window) -> wgpu.Surfac
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromWaylandSurface{
|
||||
nextInChain = &wgpu.SurfaceSourceWaylandSurface{
|
||||
chain = {
|
||||
sType = .SurfaceDescriptorFromWaylandSurface,
|
||||
sType = .SurfaceSourceWaylandSurface,
|
||||
},
|
||||
display = display,
|
||||
surface = surface,
|
||||
@@ -29,9 +29,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: ^sdl2.Window) -> wgpu.Surfac
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromXlibWindow{
|
||||
nextInChain = &wgpu.SurfaceSourceXlibWindow{
|
||||
chain = {
|
||||
sType = .SurfaceDescriptorFromXlibWindow,
|
||||
sType = .SurfaceSourceXlibWindow,
|
||||
},
|
||||
display = display,
|
||||
window = u64(window),
|
||||
|
||||
4
vendor/wgpu/sdl2glue/glue_windows.odin
vendored
4
vendor/wgpu/sdl2glue/glue_windows.odin
vendored
@@ -13,9 +13,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: ^sdl2.Window) -> wgpu.Surfac
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromWindowsHWND{
|
||||
nextInChain = &wgpu.SurfaceSourceWindowsHWND{
|
||||
chain = wgpu.ChainedStruct{
|
||||
sType = .SurfaceDescriptorFromWindowsHWND,
|
||||
sType = .SurfaceSourceWindowsHWND,
|
||||
},
|
||||
hinstance = rawptr(hinstance),
|
||||
hwnd = rawptr(hwnd),
|
||||
|
||||
12
vendor/wgpu/sdl3glue/glue.odin
vendored
12
vendor/wgpu/sdl3glue/glue.odin
vendored
@@ -1,6 +1,6 @@
|
||||
#+build !linux
|
||||
#+build !windows
|
||||
#+build !darwin
|
||||
package wgpu_sdl3_glue
|
||||
|
||||
#panic("package wgpu/sdl3glue is not supported on the current target")
|
||||
#+build !linux
|
||||
#+build !windows
|
||||
#+build !darwin
|
||||
package wgpu_sdl3_glue
|
||||
|
||||
#panic("package wgpu/sdl3glue is not supported on the current target")
|
||||
|
||||
39
vendor/wgpu/sdl3glue/glue_darwin.odin
vendored
39
vendor/wgpu/sdl3glue/glue_darwin.odin
vendored
@@ -1,18 +1,21 @@
|
||||
package wgpu_sdl3_glue
|
||||
|
||||
import "vendor:sdl3"
|
||||
import "vendor:wgpu"
|
||||
|
||||
GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
|
||||
view := sdl3.Metal_CreateView(window)
|
||||
metal_layer := sdl3.Metal_GetLayer(view)
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor {
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromMetalLayer {
|
||||
chain = wgpu.ChainedStruct{sType = .SurfaceDescriptorFromMetalLayer},
|
||||
layer = metal_layer,
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
package wgpu_sdl3_glue
|
||||
|
||||
import "vendor:sdl3"
|
||||
import "vendor:wgpu"
|
||||
|
||||
GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
|
||||
view := sdl3.Metal_CreateView(window)
|
||||
layer := sdl3.Metal_GetLayer(view)
|
||||
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceSourceMetalLayer{
|
||||
chain = wgpu.ChainedStruct{
|
||||
sType = .SurfaceSourceMetalLayer,
|
||||
},
|
||||
layer = layer,
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
91
vendor/wgpu/sdl3glue/glue_linux.odin
vendored
91
vendor/wgpu/sdl3glue/glue_linux.odin
vendored
@@ -1,54 +1,37 @@
|
||||
package wgpu_sdl3_glue
|
||||
|
||||
import "vendor:sdl3"
|
||||
import "vendor:wgpu"
|
||||
|
||||
|
||||
GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
|
||||
switch sdl3.GetCurrentVideoDriver() {
|
||||
case "x11":
|
||||
display := sdl3.GetPointerProperty(
|
||||
sdl3.GetWindowProperties(window),
|
||||
sdl3.PROP_WINDOW_X11_DISPLAY_POINTER,
|
||||
nil,
|
||||
)
|
||||
x_window := sdl3.GetNumberProperty(
|
||||
sdl3.GetWindowProperties(window),
|
||||
sdl3.PROP_WINDOW_X11_WINDOW_NUMBER,
|
||||
0,
|
||||
)
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor {
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromXlibWindow {
|
||||
chain = {sType = .SurfaceDescriptorFromXlibWindow},
|
||||
display = display,
|
||||
window = u64(x_window),
|
||||
},
|
||||
},
|
||||
)
|
||||
case "wayland":
|
||||
display := sdl3.GetPointerProperty(
|
||||
sdl3.GetWindowProperties(window),
|
||||
sdl3.PROP_WINDOW_WAYLAND_DISPLAY_POINTER,
|
||||
nil,
|
||||
)
|
||||
w_surface := sdl3.GetPointerProperty(
|
||||
sdl3.GetWindowProperties(window),
|
||||
sdl3.PROP_WINDOW_WAYLAND_SURFACE_POINTER,
|
||||
nil,
|
||||
)
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor {
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromWaylandSurface {
|
||||
chain = {sType = .SurfaceDescriptorFromWaylandSurface},
|
||||
display = display,
|
||||
surface = w_surface,
|
||||
},
|
||||
},
|
||||
)
|
||||
case:
|
||||
panic("wgpu sdl3 glue: unsupported platform, expected Wayland or X11")
|
||||
}
|
||||
}
|
||||
package wgpu_sdl3_glue
|
||||
|
||||
import "vendor:sdl3"
|
||||
import "vendor:wgpu"
|
||||
|
||||
GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
|
||||
switch sdl3.GetCurrentVideoDriver() {
|
||||
case "wayland":
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceSourceWaylandSurface{
|
||||
chain = {
|
||||
sType = .SurfaceSourceWaylandSurface,
|
||||
},
|
||||
display = sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_WAYLAND_DISPLAY_POINTER, nil),
|
||||
surface = sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_WAYLAND_SURFACE_POINTER, nil),
|
||||
},
|
||||
},
|
||||
)
|
||||
case "x11":
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceSourceXlibWindow{
|
||||
chain = {
|
||||
sType = .SurfaceSourceXlibWindow,
|
||||
},
|
||||
display = sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_X11_DISPLAY_POINTER, nil),
|
||||
window = cast(u64)sdl3.GetNumberProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_X11_WINDOW_NUMBER, 0),
|
||||
},
|
||||
},
|
||||
)
|
||||
case:
|
||||
panic("wgpu sdl3 glue: unsupported video driver, expected Wayland or X11")
|
||||
}
|
||||
}
|
||||
|
||||
48
vendor/wgpu/sdl3glue/glue_windows.odin
vendored
48
vendor/wgpu/sdl3glue/glue_windows.odin
vendored
@@ -1,29 +1,19 @@
|
||||
package wgpu_sdl3_glue
|
||||
|
||||
import win "core:sys/windows"
|
||||
|
||||
import "vendor:sdl3"
|
||||
import "vendor:wgpu"
|
||||
|
||||
GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
|
||||
hwnd := sdl3.GetPointerProperty(
|
||||
sdl3.GetWindowProperties(window),
|
||||
sdl3.PROP_WINDOW_WIN32_HWND_POINTER,
|
||||
nil,
|
||||
)
|
||||
hinstance := sdl3.GetPointerProperty(
|
||||
sdl3.GetWindowProperties(window),
|
||||
sdl3.PROP_WINDOW_WIN32_INSTANCE_POINTER,
|
||||
nil,
|
||||
)
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor {
|
||||
nextInChain = &wgpu.SurfaceDescriptorFromWindowsHWND {
|
||||
chain = wgpu.ChainedStruct{sType = .SurfaceDescriptorFromWindowsHWND},
|
||||
hinstance = hinstance,
|
||||
hwnd = hwnd,
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
package wgpu_sdl3_glue
|
||||
|
||||
import "vendor:sdl3"
|
||||
import "vendor:wgpu"
|
||||
|
||||
GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
|
||||
return wgpu.InstanceCreateSurface(
|
||||
instance,
|
||||
&wgpu.SurfaceDescriptor{
|
||||
nextInChain = &wgpu.SurfaceSourceWindowsHWND{
|
||||
chain = wgpu.ChainedStruct{
|
||||
sType = .SurfaceSourceWindowsHWND,
|
||||
},
|
||||
hinstance = sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_WIN32_INSTANCE_POINTER, nil),
|
||||
hwnd = sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_WIN32_HWND_POINTER, nil),
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
1685
vendor/wgpu/wgpu.js
vendored
1685
vendor/wgpu/wgpu.js
vendored
File diff suppressed because it is too large
Load Diff
1087
vendor/wgpu/wgpu.odin
vendored
1087
vendor/wgpu/wgpu.odin
vendored
File diff suppressed because it is too large
Load Diff
57
vendor/wgpu/wgpu_native.odin
vendored
Normal file
57
vendor/wgpu/wgpu_native.odin
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
#+build !js
|
||||
package wgpu
|
||||
|
||||
@(link_prefix="wgpu")
|
||||
foreign libwgpu {
|
||||
@(link_name="wgpuGenerateReport")
|
||||
RawGenerateReport :: proc(instance: Instance, report: ^GlobalReport) ---
|
||||
@(link_name="wgpuInstanceEnumerateAdapters")
|
||||
RawInstanceEnumerateAdapters :: proc(instance: Instance, /* NULLABLE */ options: /* const */ ^InstanceEnumerateAdapterOptions, adapters: [^]Adapter) -> uint ---
|
||||
|
||||
@(link_name="wgpuQueueSubmitForIndex")
|
||||
RawQueueSubmitForIndex :: proc(queue: Queue, commandCount: uint, commands: [^]CommandBuffer) -> SubmissionIndex ---
|
||||
|
||||
// Returns true if the queue is empty, or false if there are more queue submissions still in flight.
|
||||
DevicePoll :: proc(device: Device, wait: b32, /* NULLABLE */ wrappedSubmissionIndex: /* const */ ^SubmissionIndex = nil) -> b32 ---
|
||||
DeviceCreateShaderModuleSpirV :: proc(device: Device, descriptor: ^ShaderModuleDescriptorSpirV) -> ShaderModule ---
|
||||
|
||||
SetLogCallback :: proc(callback: LogCallback, userdata: rawptr) ---
|
||||
|
||||
SetLogLevel :: proc(level: LogLevel) ---
|
||||
|
||||
GetVersion :: proc() -> u32 ---
|
||||
|
||||
RenderPassEncoderSetPushConstants :: proc(encoder: RenderPassEncoder, stages: ShaderStageFlags, offset: u32, sizeBytes: u32, data: rawptr) ---
|
||||
ComputePassEncoderSetPushConstants :: proc(encoder: ComputePassEncoder, offset: u32, sizeBytes: u32, data: rawptr) ---
|
||||
RenderBundleEncoderSetPushConstants :: proc(encoder: RenderBundleEncoder, stages: ShaderStageFlags, offset: u32, sizeBytes: u32, data: rawptr) ---
|
||||
|
||||
RenderPassEncoderMultiDrawIndirect :: proc(encoder: RenderPassEncoder, buffer: Buffer, offset: u64, count: u32) ---
|
||||
RenderPassEncoderMultiDrawIndexedIndirect :: proc(encoder: RenderPassEncoder, buffer: Buffer, offset: u64, count: u32) ---
|
||||
|
||||
RenderPassEncoderMultiDrawIndirectCount :: proc(encoder: RenderPassEncoder, buffer: Buffer, offset: u64, count_buffer: Buffer, count_buffer_offset: u64, max_count: u32) ---
|
||||
RenderPassEncoderMultiDrawIndexedIndirectCount :: proc(encoder: RenderPassEncoder, buffer: Buffer, offset: u64, count_buffer: Buffer, count_buffer_offset: u64, max_count: u32) ---
|
||||
|
||||
ComputePassEncoderBeginPipelineStatisticsQuery :: proc(computePassEncoder: ComputePassEncoder, querySet: QuerySet, queryIndex: u32) ---
|
||||
ComputePassEncoderEndPipelineStatisticsQuery :: proc(computePassEncoder: ComputePassEncoder) ---
|
||||
RenderPassEncoderBeginPipelineStatisticsQuery :: proc(renderPassEncoder: RenderPassEncoder, querySet: QuerySet, queryIndex: u32) ---
|
||||
RenderPassEncoderEndPipelineStatisticsQuery :: proc(renderPassEncoder: RenderPassEncoder) ---
|
||||
|
||||
ComputePassEncoderWriteTimestamp :: proc(computePassEncoder: ComputePassEncoder, querySet: QuerySet, queryIndex: u32) ---
|
||||
RenderPassEncoderWriteTimestamp :: proc(renderPassEncoder: RenderPassEncoder, querySet: QuerySet, queryIndex: u32) ---
|
||||
}
|
||||
|
||||
GenerateReport :: proc "c" (instance: Instance) -> (report: GlobalReport) {
|
||||
RawGenerateReport(instance, &report)
|
||||
return
|
||||
}
|
||||
|
||||
InstanceEnumerateAdapters :: proc(instance: Instance, options: ^InstanceEnumerateAdapterOptions = nil, allocator := context.allocator) -> (adapters: []Adapter) {
|
||||
count := RawInstanceEnumerateAdapters(instance, options, nil)
|
||||
adapters = make([]Adapter, count, allocator)
|
||||
RawInstanceEnumerateAdapters(instance, options, raw_data(adapters))
|
||||
return
|
||||
}
|
||||
|
||||
QueueSubmitForIndex :: proc "c" (queue: Queue, commands: []CommandBuffer) -> SubmissionIndex {
|
||||
return RawQueueSubmitForIndex(queue, len(commands), raw_data(commands))
|
||||
}
|
||||
48
vendor/wgpu/wgpu_native_types.odin
vendored
48
vendor/wgpu/wgpu_native_types.odin
vendored
@@ -2,6 +2,9 @@ package wgpu
|
||||
|
||||
import "base:runtime"
|
||||
|
||||
BINDINGS_VERSION :: [4]u8{24, 0, 1, 0}
|
||||
BINDINGS_VERSION_STRING :: "24.0.1"
|
||||
|
||||
LogLevel :: enum i32 {
|
||||
Off,
|
||||
Error,
|
||||
@@ -59,30 +62,21 @@ InstanceExtras :: struct {
|
||||
flags: InstanceFlags,
|
||||
dx12ShaderCompiler: Dx12Compiler,
|
||||
gles3MinorVersion: Gles3MinorVersion,
|
||||
dxilPath: cstring,
|
||||
dxcPath: cstring,
|
||||
dxilPath: StringView,
|
||||
dxcPath: StringView,
|
||||
}
|
||||
|
||||
DeviceExtras :: struct {
|
||||
using chain: ChainedStruct,
|
||||
tracePath: cstring,
|
||||
tracePath: StringView,
|
||||
}
|
||||
|
||||
NativeLimits :: struct {
|
||||
chain: ChainedStructOut,
|
||||
maxPushConstantSize: u32,
|
||||
maxNonSamplerBindings: u32,
|
||||
}
|
||||
|
||||
RequiredLimitsExtras :: struct {
|
||||
using chain: ChainedStruct,
|
||||
limits: NativeLimits,
|
||||
}
|
||||
|
||||
SupportedLimitsExtras :: struct {
|
||||
using chain: ChainedStructOut,
|
||||
limits: NativeLimits,
|
||||
}
|
||||
|
||||
PushConstantRange :: struct {
|
||||
stages: ShaderStageFlags,
|
||||
start: u32,
|
||||
@@ -97,29 +91,29 @@ PipelineLayoutExtras :: struct {
|
||||
|
||||
SubmissionIndex :: distinct u64
|
||||
|
||||
WrappedSubmissionIndex :: struct {
|
||||
queue: Queue,
|
||||
submissionIndex: SubmissionIndex,
|
||||
}
|
||||
|
||||
ShaderDefine :: struct {
|
||||
name: cstring,
|
||||
value: cstring,
|
||||
name: StringView,
|
||||
value: StringView,
|
||||
}
|
||||
|
||||
ShaderModuleGLSLDescriptor :: struct {
|
||||
using chain: ChainedStruct,
|
||||
stage: ShaderStage,
|
||||
code: cstring,
|
||||
code: StringView,
|
||||
defineCount: uint,
|
||||
defines: [^]ShaderDefine `fmt:"v,defineCount"`,
|
||||
}
|
||||
|
||||
ShaderModuleDescriptorSpirV :: struct {
|
||||
label: StringView,
|
||||
sourceSize: u32,
|
||||
source: [^]u32 `fmt:"v,sourceSize"`,
|
||||
}
|
||||
|
||||
RegistryReport :: struct {
|
||||
numAllocated: uint,
|
||||
numKeptFromUser: uint,
|
||||
numReleasedFromUser: uint,
|
||||
numErrors: uint,
|
||||
elementSize: uint,
|
||||
}
|
||||
|
||||
@@ -135,6 +129,7 @@ HubReport :: struct {
|
||||
renderBundles: RegistryReport,
|
||||
renderPipelines: RegistryReport,
|
||||
computePipelines: RegistryReport,
|
||||
pipelineCaches: RegistryReport,
|
||||
querySets: RegistryReport,
|
||||
buffers: RegistryReport,
|
||||
textures: RegistryReport,
|
||||
@@ -144,11 +139,7 @@ HubReport :: struct {
|
||||
|
||||
GlobalReport :: struct {
|
||||
surfaces: RegistryReport,
|
||||
backendType: BackendType,
|
||||
vulkan: HubReport,
|
||||
metal: HubReport,
|
||||
dx12: HubReport,
|
||||
gl: HubReport,
|
||||
hub: HubReport,
|
||||
}
|
||||
|
||||
InstanceEnumerateAdapterOptions :: struct {
|
||||
@@ -182,7 +173,7 @@ SurfaceConfigurationExtras :: struct {
|
||||
desiredMaximumFrameLatency: i32,
|
||||
}
|
||||
|
||||
LogCallback :: #type proc "c" (level: LogLevel, message: cstring, userdata: rawptr)
|
||||
LogCallback :: #type proc "c" (level: LogLevel, message: StringView, userdata: rawptr)
|
||||
|
||||
// Wrappers
|
||||
|
||||
@@ -210,3 +201,4 @@ ConvertLogLevel :: proc {
|
||||
ConvertOdinToWGPULogLevel,
|
||||
ConvertWGPUToOdinLogLevel,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user