Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wgpu/microui: update to v24.0.0.2 #110

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions wgpu/microui/os_js.odin
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ os_get_surface :: proc(instance: wgpu.Instance) -> wgpu.Surface {
return wgpu.InstanceCreateSurface(
instance,
&wgpu.SurfaceDescriptor{
nextInChain = &wgpu.SurfaceDescriptorFromCanvasHTMLSelector{
sType = .SurfaceDescriptorFromCanvasHTMLSelector,
nextInChain = &wgpu.SurfaceSourceCanvasHTMLSelector{
sType = .SurfaceSourceCanvasHTMLSelector,
selector = "#wgpu-canvas",
},
},
Expand Down
21 changes: 12 additions & 9 deletions wgpu/microui/renderer.odin
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ r_init_and_run :: proc() {
r.instance = wgpu.CreateInstance(nil)
r.surface = os_get_surface(r.instance)

wgpu.InstanceRequestAdapter(r.instance, &{ compatibleSurface = r.surface }, handle_request_adapter, nil)
wgpu.InstanceRequestAdapter(r.instance, &{ compatibleSurface = r.surface }, { callback = handle_request_adapter })
}

@(private="file")
handle_request_adapter :: proc "c" (status: wgpu.RequestAdapterStatus, adapter: wgpu.Adapter, message: cstring, userdata: rawptr) {
handle_request_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.renderer.adapter = adapter
wgpu.AdapterRequestDevice(adapter, nil, handle_request_device, nil)
wgpu.AdapterRequestDevice(adapter, nil, { callback = handle_request_device })
}

@(private="file")
handle_request_device :: proc "c" (status: wgpu.RequestDeviceStatus, device: wgpu.Device, message: cstring, userdata: rawptr) {
handle_request_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)
Expand Down Expand Up @@ -201,8 +201,8 @@ on_adapter_and_device :: proc() {
})

r.module = wgpu.DeviceCreateShaderModule(r.device, &{
nextInChain = &wgpu.ShaderModuleWGSLDescriptor{
sType = .ShaderModuleWGSLDescriptor,
nextInChain = &wgpu.ShaderSourceWGSL{
sType = .ShaderSourceWGSL,
code = #load("shader.wgsl"),
},
})
Expand All @@ -219,6 +219,7 @@ on_adapter_and_device :: proc() {
bufferCount = 3,
buffers = raw_data([]wgpu.VertexBufferLayout{
{
stepMode = .Vertex,
arrayStride = 8,
attributeCount = 1,
attributes = &wgpu.VertexAttribute{
Expand All @@ -227,6 +228,7 @@ on_adapter_and_device :: proc() {
},
},
{
stepMode = .Vertex,
arrayStride = 8,
attributeCount = 1,
attributes = &wgpu.VertexAttribute{
Expand All @@ -235,6 +237,7 @@ on_adapter_and_device :: proc() {
},
},
{
stepMode = .Vertex,
arrayStride = 4,
attributeCount = 1,
attributes = &wgpu.VertexAttribute{
Expand Down Expand Up @@ -326,15 +329,15 @@ r_clear :: proc(color: mu.Color) -> bool {

r.curr_texture = wgpu.SurfaceGetCurrentTexture(r.surface)
switch r.curr_texture.status {
case .Success:
// All good, could check for `r.curr_texture.suboptimal` here.
case .SuccessOptimal, .SuccessSuboptimal:
// All good, could handle suboptimal here.
case .Timeout, .Outdated, .Lost:
if r.curr_texture.texture != nil {
wgpu.TextureRelease(r.curr_texture.texture)
}
r_resize()
return false
case .OutOfMemory, .DeviceLost:
case .OutOfMemory, .DeviceLost, .Error:
fmt.panicf("get_current_texture status=%v", r.curr_texture.status)
}

Expand Down
Loading