Free wgpu capabilities memory
This commit is contained in:
+12
-7
@@ -26,7 +26,7 @@ state: struct {
|
|||||||
pipeline_layout: wgpu.PipelineLayout,
|
pipeline_layout: wgpu.PipelineLayout,
|
||||||
pipeline: wgpu.RenderPipeline,
|
pipeline: wgpu.RenderPipeline,
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
present_modes: []wgpu.PresentMode,
|
capabilities: wgpu.SurfaceCapabilities,
|
||||||
vsync: bool,
|
vsync: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,6 +69,7 @@ instance_destroy :: proc() {
|
|||||||
wgpu.ShaderModuleRelease(state.module)
|
wgpu.ShaderModuleRelease(state.module)
|
||||||
wgpu.QueueRelease(state.queue)
|
wgpu.QueueRelease(state.queue)
|
||||||
wgpu.DeviceRelease(state.device)
|
wgpu.DeviceRelease(state.device)
|
||||||
|
wgpu.SurfaceCapabilitiesFreeMembers(state.capabilities)
|
||||||
wgpu.AdapterRelease(state.adapter)
|
wgpu.AdapterRelease(state.adapter)
|
||||||
wgpu.SurfaceRelease(state.surface)
|
wgpu.SurfaceRelease(state.surface)
|
||||||
wgpu.InstanceRelease(state.instance)
|
wgpu.InstanceRelease(state.instance)
|
||||||
@@ -260,25 +261,29 @@ get_present_modes :: proc() {
|
|||||||
if status != .Success {
|
if status != .Success {
|
||||||
fmt.panicf("[wgpu] surface capabilities failure: [%v]", status)
|
fmt.panicf("[wgpu] surface capabilities failure: [%v]", status)
|
||||||
}
|
}
|
||||||
state.present_modes = capabilities.presentModes[:capabilities.presentModeCount]
|
state.capabilities = capabilities
|
||||||
fmt.println("[wgpu] supported present modes", state.present_modes)
|
|
||||||
|
present_modes := capabilities.presentModes[:capabilities.presentModeCount]
|
||||||
|
fmt.println("[wgpu] supported present modes", present_modes)
|
||||||
}
|
}
|
||||||
|
|
||||||
@(private = "file")
|
@(private = "file")
|
||||||
pick_present_mode :: proc(vsync: bool) -> wgpu.PresentMode {
|
pick_present_mode :: proc(vsync: bool) -> wgpu.PresentMode {
|
||||||
if len(state.present_modes) == 0 do return .Fifo
|
present_modes := state.capabilities.presentModes[:state.capabilities.presentModeCount]
|
||||||
|
|
||||||
|
if len(present_modes) == 0 do return .Fifo
|
||||||
|
|
||||||
// Mimmick wgpu auto Vsync behavior
|
// Mimmick wgpu auto Vsync behavior
|
||||||
// https://docs.rs/wgpu/latest/wgpu/enum.PresentMode.html
|
// https://docs.rs/wgpu/latest/wgpu/enum.PresentMode.html
|
||||||
if vsync {
|
if vsync {
|
||||||
if slice.contains(state.present_modes, wgpu.PresentMode.FifoRelaxed) {
|
if slice.contains(present_modes, wgpu.PresentMode.FifoRelaxed) {
|
||||||
return .FifoRelaxed // Adaptive Vsync
|
return .FifoRelaxed // Adaptive Vsync
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if slice.contains(state.present_modes, wgpu.PresentMode.Immediate) {
|
if slice.contains(present_modes, wgpu.PresentMode.Immediate) {
|
||||||
return .Immediate // Vsync Off
|
return .Immediate // Vsync Off
|
||||||
}
|
}
|
||||||
if slice.contains(state.present_modes, wgpu.PresentMode.Mailbox) {
|
if slice.contains(present_modes, wgpu.PresentMode.Mailbox) {
|
||||||
return .Mailbox // Fast Vsync
|
return .Mailbox // Fast Vsync
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user