mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
wgpu: update to v24.0.0
This commit is contained in:
Vendored
+2
-2
@@ -11,8 +11,8 @@ Have a look at the `example/` directory for the rendering of a basic triangle.
|
|||||||
## Getting the wgpu-native libraries
|
## Getting the wgpu-native libraries
|
||||||
|
|
||||||
For native support (not the browser), some libraries are required. Fortunately this is
|
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),
|
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 v22.1.0.1 at the moment.
|
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).
|
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`),
|
By default it will look for a static release version (`wgpu-OS-ARCH-release.a|lib`),
|
||||||
|
|||||||
Vendored
+9
-9
@@ -35,18 +35,18 @@ main :: proc() {
|
|||||||
}
|
}
|
||||||
state.surface = os_get_surface(&state.os, state.instance)
|
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
|
context = state.ctx
|
||||||
if status != .Success || adapter == nil {
|
if status != .Success || adapter == nil {
|
||||||
fmt.panicf("request adapter failure: [%v] %s", status, message)
|
fmt.panicf("request adapter failure: [%v] %s", status, message)
|
||||||
}
|
}
|
||||||
state.adapter = adapter
|
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
|
context = state.ctx
|
||||||
if status != .Success || device == nil {
|
if status != .Success || device == nil {
|
||||||
fmt.panicf("request device failure: [%v] %s", status, message)
|
fmt.panicf("request device failure: [%v] %s", status, message)
|
||||||
@@ -82,8 +82,8 @@ main :: proc() {
|
|||||||
}`
|
}`
|
||||||
|
|
||||||
state.module = wgpu.DeviceCreateShaderModule(state.device, &{
|
state.module = wgpu.DeviceCreateShaderModule(state.device, &{
|
||||||
nextInChain = &wgpu.ShaderModuleWGSLDescriptor{
|
nextInChain = &wgpu.ShaderSourceWGSL{
|
||||||
sType = .ShaderModuleWGSLDescriptor,
|
sType = .ShaderSourceWGSL,
|
||||||
code = shader,
|
code = shader,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -130,8 +130,8 @@ frame :: proc "c" (dt: f32) {
|
|||||||
|
|
||||||
surface_texture := wgpu.SurfaceGetCurrentTexture(state.surface)
|
surface_texture := wgpu.SurfaceGetCurrentTexture(state.surface)
|
||||||
switch surface_texture.status {
|
switch surface_texture.status {
|
||||||
case .Success:
|
case .SuccessOptimal, .SuccessSuboptimal:
|
||||||
// All good, could check for `surface_texture.suboptimal` here.
|
// All good, could handle suboptimal here.
|
||||||
case .Timeout, .Outdated, .Lost:
|
case .Timeout, .Outdated, .Lost:
|
||||||
// Skip this frame, and re-configure surface.
|
// Skip this frame, and re-configure surface.
|
||||||
if surface_texture.texture != nil {
|
if surface_texture.texture != nil {
|
||||||
@@ -139,7 +139,7 @@ frame :: proc "c" (dt: f32) {
|
|||||||
}
|
}
|
||||||
resize()
|
resize()
|
||||||
return
|
return
|
||||||
case .OutOfMemory, .DeviceLost:
|
case .OutOfMemory, .DeviceLost, .Error:
|
||||||
// Fatal error
|
// Fatal error
|
||||||
fmt.panicf("[triangle] get_current_texture status=%v", surface_texture.status)
|
fmt.panicf("[triangle] get_current_texture status=%v", surface_texture.status)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ os_init :: proc(os: ^OS) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
os_run :: proc(os: ^OS) {
|
os_run :: proc(os: ^OS) {
|
||||||
dt: f32
|
dt: f32
|
||||||
|
|
||||||
for !glfw.WindowShouldClose(os.window) {
|
for !glfw.WindowShouldClose(os.window) {
|
||||||
start := time.tick_now()
|
start := time.tick_now()
|
||||||
|
|||||||
Vendored
+2
-2
@@ -30,8 +30,8 @@ os_get_surface :: proc(os: ^OS, instance: wgpu.Instance) -> wgpu.Surface {
|
|||||||
return wgpu.InstanceCreateSurface(
|
return wgpu.InstanceCreateSurface(
|
||||||
instance,
|
instance,
|
||||||
&wgpu.SurfaceDescriptor{
|
&wgpu.SurfaceDescriptor{
|
||||||
nextInChain = &wgpu.SurfaceDescriptorFromCanvasHTMLSelector{
|
nextInChain = &wgpu.SurfaceSourceCanvasHTMLSelector{
|
||||||
sType = .SurfaceDescriptorFromCanvasHTMLSelector,
|
sType = .SurfaceSourceCanvasHTMLSelector,
|
||||||
selector = "#wgpu-canvas",
|
selector = "#wgpu-canvas",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Vendored
+9
-9
@@ -35,18 +35,18 @@ main :: proc() {
|
|||||||
}
|
}
|
||||||
state.surface = os_get_surface(&state.os, state.instance)
|
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
|
context = state.ctx
|
||||||
if status != .Success || adapter == nil {
|
if status != .Success || adapter == nil {
|
||||||
fmt.panicf("request adapter failure: [%v] %s", status, message)
|
fmt.panicf("request adapter failure: [%v] %s", status, message)
|
||||||
}
|
}
|
||||||
state.adapter = adapter
|
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
|
context = state.ctx
|
||||||
if status != .Success || device == nil {
|
if status != .Success || device == nil {
|
||||||
fmt.panicf("request device failure: [%v] %s", status, message)
|
fmt.panicf("request device failure: [%v] %s", status, message)
|
||||||
@@ -82,8 +82,8 @@ main :: proc() {
|
|||||||
}`
|
}`
|
||||||
|
|
||||||
state.module = wgpu.DeviceCreateShaderModule(state.device, &{
|
state.module = wgpu.DeviceCreateShaderModule(state.device, &{
|
||||||
nextInChain = &wgpu.ShaderModuleWGSLDescriptor{
|
nextInChain = &wgpu.ShaderSourceWGSL{
|
||||||
sType = .ShaderModuleWGSLDescriptor,
|
sType = .ShaderSourceWGSL,
|
||||||
code = shader,
|
code = shader,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -130,8 +130,8 @@ frame :: proc "c" (dt: f32) {
|
|||||||
|
|
||||||
surface_texture := wgpu.SurfaceGetCurrentTexture(state.surface)
|
surface_texture := wgpu.SurfaceGetCurrentTexture(state.surface)
|
||||||
switch surface_texture.status {
|
switch surface_texture.status {
|
||||||
case .Success:
|
case .SuccessOptimal, .SuccessSuboptimal:
|
||||||
// All good, could check for `surface_texture.suboptimal` here.
|
// All good, could handle suboptimal here.
|
||||||
case .Timeout, .Outdated, .Lost:
|
case .Timeout, .Outdated, .Lost:
|
||||||
// Skip this frame, and re-configure surface.
|
// Skip this frame, and re-configure surface.
|
||||||
if surface_texture.texture != nil {
|
if surface_texture.texture != nil {
|
||||||
@@ -139,7 +139,7 @@ frame :: proc "c" (dt: f32) {
|
|||||||
}
|
}
|
||||||
resize()
|
resize()
|
||||||
return
|
return
|
||||||
case .OutOfMemory, .DeviceLost:
|
case .OutOfMemory, .DeviceLost, .Error:
|
||||||
// Fatal error
|
// Fatal error
|
||||||
fmt.panicf("[triangle] get_current_texture status=%v", surface_texture.status)
|
fmt.panicf("[triangle] get_current_texture status=%v", surface_texture.status)
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
-2
@@ -30,8 +30,8 @@ os_get_surface :: proc(os: ^OS, instance: wgpu.Instance) -> wgpu.Surface {
|
|||||||
return wgpu.InstanceCreateSurface(
|
return wgpu.InstanceCreateSurface(
|
||||||
instance,
|
instance,
|
||||||
&wgpu.SurfaceDescriptor{
|
&wgpu.SurfaceDescriptor{
|
||||||
nextInChain = &wgpu.SurfaceDescriptorFromCanvasHTMLSelector{
|
nextInChain = &wgpu.SurfaceSourceCanvasHTMLSelector{
|
||||||
sType = .SurfaceDescriptorFromCanvasHTMLSelector,
|
sType = .SurfaceSourceCanvasHTMLSelector,
|
||||||
selector = "#wgpu-canvas",
|
selector = "#wgpu-canvas",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
+2
-2
@@ -12,9 +12,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: glfw.WindowHandle) -> wgpu.S
|
|||||||
return wgpu.InstanceCreateSurface(
|
return wgpu.InstanceCreateSurface(
|
||||||
instance,
|
instance,
|
||||||
&wgpu.SurfaceDescriptor{
|
&wgpu.SurfaceDescriptor{
|
||||||
nextInChain = &wgpu.SurfaceDescriptorFromMetalLayer{
|
nextInChain = &wgpu.SurfaceSourceMetalLayer{
|
||||||
chain = wgpu.ChainedStruct{
|
chain = wgpu.ChainedStruct{
|
||||||
sType = .SurfaceDescriptorFromMetalLayer,
|
sType = .SurfaceSourceMetalLayer,
|
||||||
},
|
},
|
||||||
layer = rawptr(metal_layer),
|
layer = rawptr(metal_layer),
|
||||||
},
|
},
|
||||||
|
|||||||
Vendored
+4
-4
@@ -11,9 +11,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: glfw.WindowHandle) -> wgpu.S
|
|||||||
return wgpu.InstanceCreateSurface(
|
return wgpu.InstanceCreateSurface(
|
||||||
instance,
|
instance,
|
||||||
&wgpu.SurfaceDescriptor{
|
&wgpu.SurfaceDescriptor{
|
||||||
nextInChain = &wgpu.SurfaceDescriptorFromWaylandSurface{
|
nextInChain = &wgpu.SurfaceSourceWaylandSurface{
|
||||||
chain = {
|
chain = {
|
||||||
sType = .SurfaceDescriptorFromWaylandSurface,
|
sType = .SurfaceSourceWaylandSurface,
|
||||||
},
|
},
|
||||||
display = display,
|
display = display,
|
||||||
surface = surface,
|
surface = surface,
|
||||||
@@ -32,9 +32,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: glfw.WindowHandle) -> wgpu.S
|
|||||||
return wgpu.InstanceCreateSurface(
|
return wgpu.InstanceCreateSurface(
|
||||||
instance,
|
instance,
|
||||||
&wgpu.SurfaceDescriptor{
|
&wgpu.SurfaceDescriptor{
|
||||||
nextInChain = &wgpu.SurfaceDescriptorFromXlibWindow{
|
nextInChain = &wgpu.SurfaceSourceXlibWindow{
|
||||||
chain = {
|
chain = {
|
||||||
sType = .SurfaceDescriptorFromXlibWindow,
|
sType = .SurfaceSourceXlibWindow,
|
||||||
},
|
},
|
||||||
display = display,
|
display = display,
|
||||||
window = u64(window),
|
window = u64(window),
|
||||||
|
|||||||
+2
-2
@@ -11,9 +11,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: glfw.WindowHandle) -> wgpu.S
|
|||||||
return wgpu.InstanceCreateSurface(
|
return wgpu.InstanceCreateSurface(
|
||||||
instance,
|
instance,
|
||||||
&wgpu.SurfaceDescriptor{
|
&wgpu.SurfaceDescriptor{
|
||||||
nextInChain = &wgpu.SurfaceDescriptorFromWindowsHWND{
|
nextInChain = &wgpu.SurfaceSourceWindowsHWND{
|
||||||
chain = wgpu.ChainedStruct{
|
chain = wgpu.ChainedStruct{
|
||||||
sType = .SurfaceDescriptorFromWindowsHWND,
|
sType = .SurfaceSourceWindowsHWND,
|
||||||
},
|
},
|
||||||
hinstance = rawptr(hinstance),
|
hinstance = rawptr(hinstance),
|
||||||
hwnd = rawptr(hwnd),
|
hwnd = rawptr(hwnd),
|
||||||
|
|||||||
+2
-2
@@ -14,9 +14,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: ^sdl2.Window) -> wgpu.Surfac
|
|||||||
return wgpu.InstanceCreateSurface(
|
return wgpu.InstanceCreateSurface(
|
||||||
instance,
|
instance,
|
||||||
&wgpu.SurfaceDescriptor{
|
&wgpu.SurfaceDescriptor{
|
||||||
nextInChain = &wgpu.SurfaceDescriptorFromMetalLayer{
|
nextInChain = &wgpu.SurfaceSourceMetalLayer{
|
||||||
chain = wgpu.ChainedStruct{
|
chain = wgpu.ChainedStruct{
|
||||||
sType = .SurfaceDescriptorFromMetalLayer,
|
sType = .SurfaceSourceMetalLayer,
|
||||||
},
|
},
|
||||||
layer = rawptr(metal_layer),
|
layer = rawptr(metal_layer),
|
||||||
},
|
},
|
||||||
|
|||||||
Vendored
+4
-4
@@ -14,9 +14,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: ^sdl2.Window) -> wgpu.Surfac
|
|||||||
return wgpu.InstanceCreateSurface(
|
return wgpu.InstanceCreateSurface(
|
||||||
instance,
|
instance,
|
||||||
&wgpu.SurfaceDescriptor{
|
&wgpu.SurfaceDescriptor{
|
||||||
nextInChain = &wgpu.SurfaceDescriptorFromWaylandSurface{
|
nextInChain = &wgpu.SurfaceSourceWaylandSurface{
|
||||||
chain = {
|
chain = {
|
||||||
sType = .SurfaceDescriptorFromWaylandSurface,
|
sType = .SurfaceSourceWaylandSurface,
|
||||||
},
|
},
|
||||||
display = display,
|
display = display,
|
||||||
surface = surface,
|
surface = surface,
|
||||||
@@ -29,9 +29,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: ^sdl2.Window) -> wgpu.Surfac
|
|||||||
return wgpu.InstanceCreateSurface(
|
return wgpu.InstanceCreateSurface(
|
||||||
instance,
|
instance,
|
||||||
&wgpu.SurfaceDescriptor{
|
&wgpu.SurfaceDescriptor{
|
||||||
nextInChain = &wgpu.SurfaceDescriptorFromXlibWindow{
|
nextInChain = &wgpu.SurfaceSourceXlibWindow{
|
||||||
chain = {
|
chain = {
|
||||||
sType = .SurfaceDescriptorFromXlibWindow,
|
sType = .SurfaceSourceXlibWindow,
|
||||||
},
|
},
|
||||||
display = display,
|
display = display,
|
||||||
window = u64(window),
|
window = u64(window),
|
||||||
|
|||||||
+2
-2
@@ -13,9 +13,9 @@ GetSurface :: proc(instance: wgpu.Instance, window: ^sdl2.Window) -> wgpu.Surfac
|
|||||||
return wgpu.InstanceCreateSurface(
|
return wgpu.InstanceCreateSurface(
|
||||||
instance,
|
instance,
|
||||||
&wgpu.SurfaceDescriptor{
|
&wgpu.SurfaceDescriptor{
|
||||||
nextInChain = &wgpu.SurfaceDescriptorFromWindowsHWND{
|
nextInChain = &wgpu.SurfaceSourceWindowsHWND{
|
||||||
chain = wgpu.ChainedStruct{
|
chain = wgpu.ChainedStruct{
|
||||||
sType = .SurfaceDescriptorFromWindowsHWND,
|
sType = .SurfaceSourceWindowsHWND,
|
||||||
},
|
},
|
||||||
hinstance = rawptr(hinstance),
|
hinstance = rawptr(hinstance),
|
||||||
hwnd = rawptr(hwnd),
|
hwnd = rawptr(hwnd),
|
||||||
|
|||||||
Vendored
+6
-6
@@ -1,6 +1,6 @@
|
|||||||
#+build !linux
|
#+build !linux
|
||||||
#+build !windows
|
#+build !windows
|
||||||
#+build !darwin
|
#+build !darwin
|
||||||
package wgpu_sdl3_glue
|
package wgpu_sdl3_glue
|
||||||
|
|
||||||
#panic("package wgpu/sdl3glue is not supported on the current target")
|
#panic("package wgpu/sdl3glue is not supported on the current target")
|
||||||
|
|||||||
+21
-18
@@ -1,18 +1,21 @@
|
|||||||
package wgpu_sdl3_glue
|
package wgpu_sdl3_glue
|
||||||
|
|
||||||
import "vendor:sdl3"
|
import "vendor:sdl3"
|
||||||
import "vendor:wgpu"
|
import "vendor:wgpu"
|
||||||
|
|
||||||
GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
|
GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
|
||||||
view := sdl3.Metal_CreateView(window)
|
view := sdl3.Metal_CreateView(window)
|
||||||
metal_layer := sdl3.Metal_GetLayer(view)
|
layer := sdl3.Metal_GetLayer(view)
|
||||||
return wgpu.InstanceCreateSurface(
|
|
||||||
instance,
|
return wgpu.InstanceCreateSurface(
|
||||||
&wgpu.SurfaceDescriptor {
|
instance,
|
||||||
nextInChain = &wgpu.SurfaceDescriptorFromMetalLayer {
|
&wgpu.SurfaceDescriptor{
|
||||||
chain = wgpu.ChainedStruct{sType = .SurfaceDescriptorFromMetalLayer},
|
nextInChain = &wgpu.SurfaceSourceMetalLayer{
|
||||||
layer = metal_layer,
|
chain = wgpu.ChainedStruct{
|
||||||
},
|
sType = .SurfaceSourceMetalLayer,
|
||||||
},
|
},
|
||||||
)
|
layer = layer,
|
||||||
}
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
Vendored
+37
-54
@@ -1,54 +1,37 @@
|
|||||||
package wgpu_sdl3_glue
|
package wgpu_sdl3_glue
|
||||||
|
|
||||||
import "vendor:sdl3"
|
import "vendor:sdl3"
|
||||||
import "vendor:wgpu"
|
import "vendor:wgpu"
|
||||||
|
|
||||||
|
GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
|
||||||
GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
|
switch sdl3.GetCurrentVideoDriver() {
|
||||||
switch sdl3.GetCurrentVideoDriver() {
|
case "wayland":
|
||||||
case "x11":
|
return wgpu.InstanceCreateSurface(
|
||||||
display := sdl3.GetPointerProperty(
|
instance,
|
||||||
sdl3.GetWindowProperties(window),
|
&wgpu.SurfaceDescriptor{
|
||||||
sdl3.PROP_WINDOW_X11_DISPLAY_POINTER,
|
nextInChain = &wgpu.SurfaceSourceWaylandSurface{
|
||||||
nil,
|
chain = {
|
||||||
)
|
sType = .SurfaceSourceWaylandSurface,
|
||||||
x_window := sdl3.GetNumberProperty(
|
},
|
||||||
sdl3.GetWindowProperties(window),
|
display = sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_WAYLAND_DISPLAY_POINTER, nil),
|
||||||
sdl3.PROP_WINDOW_X11_WINDOW_NUMBER,
|
surface = sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_WAYLAND_SURFACE_POINTER, nil),
|
||||||
0,
|
},
|
||||||
)
|
},
|
||||||
return wgpu.InstanceCreateSurface(
|
)
|
||||||
instance,
|
case "x11":
|
||||||
&wgpu.SurfaceDescriptor {
|
return wgpu.InstanceCreateSurface(
|
||||||
nextInChain = &wgpu.SurfaceDescriptorFromXlibWindow {
|
instance,
|
||||||
chain = {sType = .SurfaceDescriptorFromXlibWindow},
|
&wgpu.SurfaceDescriptor{
|
||||||
display = display,
|
nextInChain = &wgpu.SurfaceSourceXlibWindow{
|
||||||
window = u64(x_window),
|
chain = {
|
||||||
},
|
sType = .SurfaceSourceXlibWindow,
|
||||||
},
|
},
|
||||||
)
|
display = sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_X11_DISPLAY_POINTER, nil),
|
||||||
case "wayland":
|
window = cast(u64)sdl3.GetNumberProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_X11_WINDOW_NUMBER, 0),
|
||||||
display := sdl3.GetPointerProperty(
|
},
|
||||||
sdl3.GetWindowProperties(window),
|
},
|
||||||
sdl3.PROP_WINDOW_WAYLAND_DISPLAY_POINTER,
|
)
|
||||||
nil,
|
case:
|
||||||
)
|
panic("wgpu sdl3 glue: unsupported video driver, expected Wayland or X11")
|
||||||
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")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
+19
-29
@@ -1,29 +1,19 @@
|
|||||||
package wgpu_sdl3_glue
|
package wgpu_sdl3_glue
|
||||||
|
|
||||||
import win "core:sys/windows"
|
import "vendor:sdl3"
|
||||||
|
import "vendor:wgpu"
|
||||||
import "vendor:sdl3"
|
|
||||||
import "vendor:wgpu"
|
GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
|
||||||
|
return wgpu.InstanceCreateSurface(
|
||||||
GetSurface :: proc(instance: wgpu.Instance, window: ^sdl3.Window) -> wgpu.Surface {
|
instance,
|
||||||
hwnd := sdl3.GetPointerProperty(
|
&wgpu.SurfaceDescriptor{
|
||||||
sdl3.GetWindowProperties(window),
|
nextInChain = &wgpu.SurfaceSourceWindowsHWND{
|
||||||
sdl3.PROP_WINDOW_WIN32_HWND_POINTER,
|
chain = wgpu.ChainedStruct{
|
||||||
nil,
|
sType = .SurfaceSourceWindowsHWND,
|
||||||
)
|
},
|
||||||
hinstance := sdl3.GetPointerProperty(
|
hinstance = sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_WIN32_INSTANCE_POINTER, nil),
|
||||||
sdl3.GetWindowProperties(window),
|
hwnd = sdl3.GetPointerProperty(sdl3.GetWindowProperties(window), sdl3.PROP_WINDOW_WIN32_HWND_POINTER, nil),
|
||||||
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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|||||||
Vendored
+1021
-664
File diff suppressed because it is too large
Load Diff
Vendored
+582
-505
File diff suppressed because it is too large
Load Diff
Vendored
+57
@@ -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))
|
||||||
|
}
|
||||||
Vendored
+20
-28
@@ -2,6 +2,9 @@ package wgpu
|
|||||||
|
|
||||||
import "base:runtime"
|
import "base:runtime"
|
||||||
|
|
||||||
|
BINDINGS_VERSION :: [4]u8{24, 0, 1, 0}
|
||||||
|
BINDINGS_VERSION_STRING :: "24.0.1"
|
||||||
|
|
||||||
LogLevel :: enum i32 {
|
LogLevel :: enum i32 {
|
||||||
Off,
|
Off,
|
||||||
Error,
|
Error,
|
||||||
@@ -59,30 +62,21 @@ InstanceExtras :: struct {
|
|||||||
flags: InstanceFlags,
|
flags: InstanceFlags,
|
||||||
dx12ShaderCompiler: Dx12Compiler,
|
dx12ShaderCompiler: Dx12Compiler,
|
||||||
gles3MinorVersion: Gles3MinorVersion,
|
gles3MinorVersion: Gles3MinorVersion,
|
||||||
dxilPath: cstring,
|
dxilPath: StringView,
|
||||||
dxcPath: cstring,
|
dxcPath: StringView,
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceExtras :: struct {
|
DeviceExtras :: struct {
|
||||||
using chain: ChainedStruct,
|
using chain: ChainedStruct,
|
||||||
tracePath: cstring,
|
tracePath: StringView,
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeLimits :: struct {
|
NativeLimits :: struct {
|
||||||
|
chain: ChainedStructOut,
|
||||||
maxPushConstantSize: u32,
|
maxPushConstantSize: u32,
|
||||||
maxNonSamplerBindings: u32,
|
maxNonSamplerBindings: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
RequiredLimitsExtras :: struct {
|
|
||||||
using chain: ChainedStruct,
|
|
||||||
limits: NativeLimits,
|
|
||||||
}
|
|
||||||
|
|
||||||
SupportedLimitsExtras :: struct {
|
|
||||||
using chain: ChainedStructOut,
|
|
||||||
limits: NativeLimits,
|
|
||||||
}
|
|
||||||
|
|
||||||
PushConstantRange :: struct {
|
PushConstantRange :: struct {
|
||||||
stages: ShaderStageFlags,
|
stages: ShaderStageFlags,
|
||||||
start: u32,
|
start: u32,
|
||||||
@@ -97,29 +91,29 @@ PipelineLayoutExtras :: struct {
|
|||||||
|
|
||||||
SubmissionIndex :: distinct u64
|
SubmissionIndex :: distinct u64
|
||||||
|
|
||||||
WrappedSubmissionIndex :: struct {
|
|
||||||
queue: Queue,
|
|
||||||
submissionIndex: SubmissionIndex,
|
|
||||||
}
|
|
||||||
|
|
||||||
ShaderDefine :: struct {
|
ShaderDefine :: struct {
|
||||||
name: cstring,
|
name: StringView,
|
||||||
value: cstring,
|
value: StringView,
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderModuleGLSLDescriptor :: struct {
|
ShaderModuleGLSLDescriptor :: struct {
|
||||||
using chain: ChainedStruct,
|
using chain: ChainedStruct,
|
||||||
stage: ShaderStage,
|
stage: ShaderStage,
|
||||||
code: cstring,
|
code: StringView,
|
||||||
defineCount: uint,
|
defineCount: uint,
|
||||||
defines: [^]ShaderDefine `fmt:"v,defineCount"`,
|
defines: [^]ShaderDefine `fmt:"v,defineCount"`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ShaderModuleDescriptorSpirV :: struct {
|
||||||
|
label: StringView,
|
||||||
|
sourceSize: u32,
|
||||||
|
source: [^]u32 `fmt:"v,sourceSize"`,
|
||||||
|
}
|
||||||
|
|
||||||
RegistryReport :: struct {
|
RegistryReport :: struct {
|
||||||
numAllocated: uint,
|
numAllocated: uint,
|
||||||
numKeptFromUser: uint,
|
numKeptFromUser: uint,
|
||||||
numReleasedFromUser: uint,
|
numReleasedFromUser: uint,
|
||||||
numErrors: uint,
|
|
||||||
elementSize: uint,
|
elementSize: uint,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,6 +129,7 @@ HubReport :: struct {
|
|||||||
renderBundles: RegistryReport,
|
renderBundles: RegistryReport,
|
||||||
renderPipelines: RegistryReport,
|
renderPipelines: RegistryReport,
|
||||||
computePipelines: RegistryReport,
|
computePipelines: RegistryReport,
|
||||||
|
pipelineCaches: RegistryReport,
|
||||||
querySets: RegistryReport,
|
querySets: RegistryReport,
|
||||||
buffers: RegistryReport,
|
buffers: RegistryReport,
|
||||||
textures: RegistryReport,
|
textures: RegistryReport,
|
||||||
@@ -144,11 +139,7 @@ HubReport :: struct {
|
|||||||
|
|
||||||
GlobalReport :: struct {
|
GlobalReport :: struct {
|
||||||
surfaces: RegistryReport,
|
surfaces: RegistryReport,
|
||||||
backendType: BackendType,
|
hub: HubReport,
|
||||||
vulkan: HubReport,
|
|
||||||
metal: HubReport,
|
|
||||||
dx12: HubReport,
|
|
||||||
gl: HubReport,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceEnumerateAdapterOptions :: struct {
|
InstanceEnumerateAdapterOptions :: struct {
|
||||||
@@ -182,7 +173,7 @@ SurfaceConfigurationExtras :: struct {
|
|||||||
desiredMaximumFrameLatency: i32,
|
desiredMaximumFrameLatency: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
LogCallback :: #type proc "c" (level: LogLevel, message: cstring, userdata: rawptr)
|
LogCallback :: #type proc "c" (level: LogLevel, message: StringView, userdata: rawptr)
|
||||||
|
|
||||||
// Wrappers
|
// Wrappers
|
||||||
|
|
||||||
@@ -210,3 +201,4 @@ ConvertLogLevel :: proc {
|
|||||||
ConvertOdinToWGPULogLevel,
|
ConvertOdinToWGPULogLevel,
|
||||||
ConvertWGPUToOdinLogLevel,
|
ConvertWGPUToOdinLogLevel,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user