// Opaque handles owned by the RHI core.
//
// They must live in this package rather than in `types`: MoonBit only allows
// defining methods on a type in the package that declares it, and the generated
// forwarding methods are `pub fn Buffer::upload(...)`. Descriptors therefore
// carry `UInt64` ids for the two fields that reference a handle
// (`PipelineDesc.bindless_heap`, `RayInstanceDesc.blas`), and the core resolves
// them before calling the backend.
//
// `id` stays private, so a handle cannot be confused with a bare id or with a
// handle of another kind.

pub struct Device {
  priv id : UInt64
}

pub struct Swapchain {
  priv id : UInt64
}

pub struct Pipeline {
  priv id : UInt64
}

pub struct Buffer {
  priv id : UInt64
}

pub struct Texture {
  priv id : UInt64
}

pub struct Sampler {
  priv id : UInt64
}

pub struct CommandBuffer {
  priv id : UInt64
}

pub struct TimestampPool {
  priv id : UInt64
}

pub struct AccelStruct {
  priv id : UInt64
}

pub struct BindlessHeap {
  priv id : UInt64
}

pub struct ComputePass {
  priv id : UInt64
}

pub struct RenderPass {
  priv id : UInt64
}

pub struct Fence {
  priv id : UInt64
}

///|
/// Raw handle id. Needed by descriptors that traffic in ids (`RenderTargetDesc`,
/// `DepthTargetDesc`, `PipelineDesc::bindless_heap`), which the core resolves
/// before the backend sees them.
pub fn Texture::id(self : Texture) -> UInt64 {
  self.id
}

///|
pub fn Buffer::id(self : Buffer) -> UInt64 {
  self.id
}

///|
pub fn Pipeline::id(self : Pipeline) -> UInt64 {
  self.id
}

///|
pub fn Swapchain::id(self : Swapchain) -> UInt64 {
  self.id
}

///|
pub fn BindlessHeap::id(self : BindlessHeap) -> UInt64 {
  self.id
}

///|
pub fn AccelStruct::id(self : AccelStruct) -> UInt64 {
  self.id
}