Luce packages
LuceLuce BaseLuciaOS

dymokomi/luced-3d

Source of release 0.11.7

0.11.7 / tools / timing.lucb

import time
from luce_gpu import gpu
import interop

## Standalone GPU-backed target to time command recording without presentation.
pub struct GpuRecorder:
    var device: gpu.Device
    var texture: gpu.Texture

    pub func init() -> !:
        var device = try gpu.Device.open()
        errdefer device.destroy()
        let texture = try gpu.Texture.create(device, 1400, 900, gpu.Format.rgba8)
        self.device = device
        self.texture = texture

    pub func frame() -> interop.Reference[gpu.Frame]!:
        return try self.texture.frame()

    pub func close():
        self.texture.destroy()
        self.device.destroy()

pub let gpu_recorder_type: interop.Type[GpuRecorder] = interop.Type[GpuRecorder]("GpuRecorder", GpuRecorder.close, main_thread = true, closeable = true)

pub func now() -> f64:
    return (f64)time.now() / 1000000.0