const AUTO
pub const AUTO = 0Purpose
Constant AUTO, defining protocol or algorithm parameters.
#gpu#gpu provides low-level device, buffer, texture, and command recording abstractions in the Xu standard library. It supports windowless devices, buffers, 2D textures and mips, samplers, shaders, graphics and compute pipelines, command encoders, fence synchronization, and byte readback.
All GPU resources support explicit idempotent close and automatic drop. Keep devices, resources, and borrows on the main thread; texture formats and layout rules are defined in gpu/layout.
@main
#gpu
fn main() {
$device := gpu.open(gpu.DeviceOptions{backend: gpu.AUTO, debug: false, shader_formats: 0}) or {
println("GPU backend unavailable")
return
}
$buffer := device.buffer(4, gpu.BUFFER_VERTEX) or >>
input := [u8(0), u8(127), u8(128), u8(255)]
device.upload(&buffer, 0, &input) or >>
$result := device.download(&buffer, 0, 4) or >>
result.wait() or >>
$output := [u8(0), u8(0), u8(0), u8(0)]
result.read($&output) or >>
println("downloaded byte:", output[3])
}Expected output: downloaded byte: 255.
const AUTOpub const AUTO = 0Constant AUTO, defining protocol or algorithm parameters.
const METALpub const METAL = 1Constant METAL, defining protocol or algorithm parameters.
const VULKANpub const VULKAN = 2Constant VULKAN, defining protocol or algorithm parameters.
const D3D12pub const D3D12 = 3Constant D3D12, defining protocol or algorithm parameters.
const SHADER_SPIRVpub const SHADER_SPIRV = 1Constant SHADER_SPIRV, defining protocol or algorithm parameters.
const SHADER_DXBCpub const SHADER_DXBC = 2Constant SHADER_DXBC, defining protocol or algorithm parameters.
const SHADER_DXILpub const SHADER_DXIL = 4Constant SHADER_DXIL, defining protocol or algorithm parameters.
const SHADER_MSLpub const SHADER_MSL = 8Constant SHADER_MSL, defining protocol or algorithm parameters.
const SHADER_METALLIBpub const SHADER_METALLIB = 16Constant SHADER_METALLIB, defining protocol or algorithm parameters.
const BUFFER_VERTEXpub const BUFFER_VERTEX = 1Constant BUFFER_VERTEX, defining protocol or algorithm parameters.
const BUFFER_INDEXpub const BUFFER_INDEX = 2Constant BUFFER_INDEX, defining protocol or algorithm parameters.
const BUFFER_INDIRECTpub const BUFFER_INDIRECT = 4Constant BUFFER_INDIRECT, defining protocol or algorithm parameters.
const BUFFER_GRAPHICS_STORAGE_READpub const BUFFER_GRAPHICS_STORAGE_READ = 8Constant BUFFER_GRAPHICS_STORAGE_READ, defining protocol or algorithm parameters.
const BUFFER_COMPUTE_STORAGE_READpub const BUFFER_COMPUTE_STORAGE_READ = 16Constant BUFFER_COMPUTE_STORAGE_READ, defining protocol or algorithm parameters.
const BUFFER_COMPUTE_STORAGE_WRITEpub const BUFFER_COMPUTE_STORAGE_WRITE = 32Constant BUFFER_COMPUTE_STORAGE_WRITE, defining protocol or algorithm parameters.
const TRANSFER_ALIGNMENTpub const TRANSFER_ALIGNMENT = 4Constant TRANSFER_ALIGNMENT, defining protocol or algorithm parameters.
struct DeviceOptionspub struct DeviceOptions {
pub backend int
pub debug bool
pub shader_formats int
}Gpu Configuration parameters and options set.
backend intdebug boolshader_formats intstruct Devicepub struct Device {
}Owning, main-thread resources. Device.close invalidates all children. IDs are private and never reused by the backend during the process lifetime.
This type has no public fields.
struct Bufferpub struct Buffer {
}Buffer context or state structure.
This type has no public fields.
struct Fencepub struct Fence {
}Fence context or state structure.
This type has no public fields.
struct Readbackpub struct Readback {
}Readback context or state structure.
This type has no public fields.
struct Statspub struct Stats {
pub buffer_count int
pub buffer_bytes int
pub submission_count int
pub staging_bytes int
pub texture_count int
pub texture_bytes int
pub sampler_count int
pub shader_count int
pub pipeline_count int
pub encoder_count int
pub render_pass_count int
pub compute_pipeline_count int
pub compute_pass_count int
pub surface_count int
pub frame_count int
}Logical requested bytes and live ownership counts, not driver allocations.
buffer_count intbuffer_bytes intsubmission_count intstaging_bytes inttexture_count inttexture_bytes intsampler_count intshader_count intpipeline_count intencoder_count intrender_pass_count intcompute_pipeline_count intcompute_pass_count intsurface_count intframe_count intis_availablepub fn is_available(options DeviceOptions) boolProbes whether a device can be opened for the given options without retaining it.
options DeviceOptionsbool — true or false
openpub fn open(options DeviceOptions) DeviceOpen resource or establish connection. Throws on failure; handle the error or propagate it to the caller.
options DeviceOptionsDevice — a value of this type
(&Device) backendpub fn (device &Device) backend() intExecute backend on &Device. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).int — a value of this type
(&Device) shader_formatspub fn (device &Device) shader_formats() intOperation on &Device: shader formats. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).int — a value of this type
(&Device) statspub fn (device &Device) stats() StatsExecute stats on &Device. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).Stats — a value of this type
(&Device) bufferpub fn (device &Device) buffer(size_bytes int, usage int) BufferExecute buffer on &Device. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).size_bytes intusage intBuffer — a value of this type
(&Buffer) size_bytespub fn (buffer &Buffer) size_bytes() intOperation on &Buffer: size bytes.
buffer &BufferBuffer instance used by this call (borrow).int — a value of this type
(&Device) uploadpub fn (device &Device) upload(buffer &Buffer, offset int, bytes &[]u8) FenceEach transfer is submitted before returning. Upload copies the borrowed bytes to owned staging synchronously; no Xu pointer survives the call. Fence.close releases ownership without waiting; SDL defers in-flight frees. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).buffer &Bufferoffset intbytes &[]u8Fence — a value of this type
(&Device) copypub fn (device &Device) copy(source &Buffer, source_offset int, destination &Buffer, destination_offset int, size_bytes int) FenceExecute copy on &Device. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).source &Buffersource_offset intdestination &Bufferdestination_offset intsize_bytes intFence — a value of this type
(&Device) downloadpub fn (device &Device) download(buffer &Buffer, offset int, size_bytes int) ReadbackExecute download on &Device. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).buffer &Bufferoffset intsize_bytes intReadback — a value of this type
(&Fence) readypub fn (fence &Fence) ready() boolExecute ready on &Fence. Throws on failure; handle the error or propagate it to the caller.
fence &FenceFence instance used by this call (borrow).bool — true or false
(&Fence) waitpub fn (fence &Fence) wait() intExecute wait on &Fence. Throws on failure; handle the error or propagate it to the caller.
fence &FenceFence instance used by this call (borrow).int — a value of this type
(&Readback) readypub fn (readback &Readback) ready() boolExecute ready on &Readback. Throws on failure; handle the error or propagate it to the caller.
readback &ReadbackReadback instance used by this call (borrow).bool — true or false
(&Readback) waitpub fn (readback &Readback) wait() intExecute wait on &Readback. Throws on failure; handle the error or propagate it to the caller.
readback &ReadbackReadback instance used by this call (borrow).int — a value of this type
(&Readback) size_bytespub fn (readback &Readback) size_bytes() intOperation on &Readback: size bytes.
readback &ReadbackReadback instance used by this call (borrow).int — a value of this type
(&Readback) readpub fn (readback &Readback) read(output $&[]u8) intRequires a completed submission and an exact-size destination. Failure leaves the byte array untouched. Waiting is explicit and may block. Throws on failure; handle the error or propagate it to the caller.
readback &ReadbackReadback instance used by this call (borrow).output $&[]u8int — a value of this type
($&Device) closepub fn (device $&Device) close() intOperation on $&Device: close the resource. Throws on failure; handle the error or propagate it to the caller.
device $&DeviceDevice instance used by this call (exclusive borrow).int — a value of this type
($&Buffer) closepub fn (buffer $&Buffer) close() intOperation on $&Buffer: close the resource. Throws on failure; handle the error or propagate it to the caller.
buffer $&BufferBuffer instance used by this call (exclusive borrow).int — a value of this type
($&Fence) closepub fn (fence $&Fence) close() intOperation on $&Fence: close the resource. Throws on failure; handle the error or propagate it to the caller.
fence $&FenceFence instance used by this call (exclusive borrow).int — a value of this type
($&Readback) closepub fn (readback $&Readback) close() intOperation on $&Readback: close the resource. Throws on failure; handle the error or propagate it to the caller.
readback $&ReadbackReadback instance used by this call (exclusive borrow).int — a value of this type
const LOADpub const LOAD = 0Constant LOAD, defining protocol or algorithm parameters.
const CLEARpub const CLEAR = 1Constant CLEAR, defining protocol or algorithm parameters.
const DISCARDpub const DISCARD = 2Constant DISCARD, defining protocol or algorithm parameters.
const STOREpub const STORE = 0Constant STORE, defining protocol or algorithm parameters.
const DONT_STOREpub const DONT_STORE = 1Constant DONT_STORE, defining protocol or algorithm parameters.
const INDEX16pub const INDEX16 = 2Constant INDEX16, defining protocol or algorithm parameters.
const INDEX32pub const INDEX32 = 4Constant INDEX32, defining protocol or algorithm parameters.
struct Colorpub struct Color {
pub r f64
pub g f64
pub b f64
pub a f64
}Structure encapsulating r, g, b, a.
r f64g f64b f64a f64struct ColorAttachmentpub struct ColorAttachment {
pub view TextureSlice
pub load int
pub store int
pub clear Color
}Structure encapsulating view, load, store, clear.
view TextureSliceload intstore intclear Colorstruct DepthAttachmentpub struct DepthAttachment {
}DepthAttachment context or state structure.
This type has no public fields.
no_depthpub fn no_depth() DepthAttachmentNo depth.
No arguments are required.
DepthAttachment — a value of this type
depth_attachmentpub fn depth_attachment(texture &Texture, load int, store int, clear f64) DepthAttachmentDepth attachment uses mip zero; its extent must match the color view.
texture &Textureload intstore intclear f64DepthAttachment — a value of this type
struct CommandEncoderpub struct CommandEncoder {
}CommandEncoder context or state structure.
This type has no public fields.
struct RenderPasspub struct RenderPass {
}RenderPass context or state structure.
This type has no public fields.
(&Device) command_encoderpub fn (device &Device) command_encoder() CommandEncoderOperation on &Device: command encoder. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).CommandEncoder — a value of this type
(&CommandEncoder) begin_renderpub fn (encoder &CommandEncoder) begin_render(color ColorAttachment, depth DepthAttachment) RenderPassOperation on &CommandEncoder: begin render. Throws on failure; handle the error or propagate it to the caller.
encoder &CommandEncoderCommandEncoder instance used by this call (borrow).color ColorAttachmentdepth DepthAttachmentRenderPass — a value of this type
($&CommandEncoder) submitpub fn (encoder $&CommandEncoder) submit() FenceSubmit requires all passes ended. Success consumes the native encoder failure may also consume it, so close/drop is idempotent on stale IDs. Throws on failure; handle the error or propagate it to the caller.
encoder $&CommandEncoderCommandEncoder instance used by this call (exclusive borrow).Fence — a value of this type
(&RenderPass) pipelinepub fn (pass &RenderPass) pipeline(pipeline &GraphicsPipeline) intExecute pipeline on &RenderPass. Throws on failure; handle the error or propagate it to the caller.
pass &RenderPassRenderPass instance used by this call (borrow).pipeline &GraphicsPipelineint — a value of this type
(&RenderPass) vertex_bufferpub fn (pass &RenderPass) vertex_buffer(slot int, buffer &Buffer, offset int) intSet the pipeline before bindings; a pipeline change resets required bindings. Throws on failure; handle the error or propagate it to the caller.
pass &RenderPassRenderPass instance used by this call (borrow).slot intbuffer &Bufferoffset intint — a value of this type
(&RenderPass) index_bufferpub fn (pass &RenderPass) index_buffer(buffer &Buffer, offset int, element_size int) intOperation on &RenderPass: index buffer. Throws on failure; handle the error or propagate it to the caller.
pass &RenderPassRenderPass instance used by this call (borrow).buffer &Bufferoffset intelement_size intint — index; see the description for its range and special values
(&RenderPass) samplerpub fn (pass &RenderPass) sampler(stage int, slot int, texture &Texture, sampler &Sampler) intExecute sampler on &RenderPass. Throws on failure; handle the error or propagate it to the caller.
pass &RenderPassRenderPass instance used by this call (borrow).stage intslot inttexture &Texturesampler &Samplerint — a value of this type
(&RenderPass) uniformpub fn (pass &RenderPass) uniform(stage int, slot int, bytes &[]u8) intExecute uniform on &RenderPass. Throws on failure; handle the error or propagate it to the caller.
pass &RenderPassRenderPass instance used by this call (borrow).stage intslot intbytes &[]u8int — a value of this type
(&RenderPass) viewportpub fn (pass &RenderPass) viewport(x int, y int, width int, height int) intExecute viewport on &RenderPass. Throws on failure; handle the error or propagate it to the caller.
pass &RenderPassRenderPass instance used by this call (borrow).x inty intwidth intheight intint — a value of this type
(&RenderPass) scissorpub fn (pass &RenderPass) scissor(x int, y int, width int, height int) intExecute scissor on &RenderPass. Throws on failure; handle the error or propagate it to the caller.
pass &RenderPassRenderPass instance used by this call (borrow).x inty intwidth intheight intint — a value of this type
(&RenderPass) drawpub fn (pass &RenderPass) draw(vertex_count int, first_vertex int, instance_count int, first_instance int) intExecute draw on &RenderPass. Throws on failure; handle the error or propagate it to the caller.
pass &RenderPassRenderPass instance used by this call (borrow).vertex_count intfirst_vertex intinstance_count intfirst_instance intint — a value of this type
(&RenderPass) draw_indexedpub fn (pass &RenderPass) draw_indexed(index_count int, first_index int, vertex_offset int, instance_count int, first_instance int) intIndex values and shader accesses must address valid vertex/storage data. The API checks the index-byte range without reading GPU buffers on the CPU. Throws on failure; handle the error or propagate it to the caller.
pass &RenderPassRenderPass instance used by this call (borrow).index_count intfirst_index intvertex_offset intinstance_count intfirst_instance intint — index; see the description for its range and special values
($&RenderPass) endpub fn (pass $&RenderPass) end() intExecute end on $&RenderPass. Throws on failure; handle the error or propagate it to the caller.
pass $&RenderPassRenderPass instance used by this call (exclusive borrow).int — a value of this type
($&CommandEncoder) closepub fn (encoder $&CommandEncoder) close() intCancel closes an active pass, discards recorded commands and frees references. Throws on failure; handle the error or propagate it to the caller.
encoder $&CommandEncoderCommandEncoder instance used by this call (exclusive borrow).int — a value of this type
const MAX_COMPUTE_STORAGE_BUFFERSpub const MAX_COMPUTE_STORAGE_BUFFERS = 8Constant MAX_COMPUTE_STORAGE_BUFFERS, defining protocol or algorithm parameters.
const MAX_COMPUTE_THREADSpub const MAX_COMPUTE_THREADS = 1024Constant MAX_COMPUTE_THREADS, defining protocol or algorithm parameters.
const MAX_COMPUTE_THREADS_Zpub const MAX_COMPUTE_THREADS_Z = 64Constant MAX_COMPUTE_THREADS_Z, defining protocol or algorithm parameters.
const MAX_COMPUTE_GROUPS_PER_DIMENSIONpub const MAX_COMPUTE_GROUPS_PER_DIMENSION = 65535Constant MAX_COMPUTE_GROUPS_PER_DIMENSION, defining protocol or algorithm parameters.
struct ComputePipelineDescpub struct ComputePipelineDesc {
pub format int
pub entrypoint string
pub read_buffers int
pub write_buffers int
pub uniform_sizes []int
pub threads_x int
pub threads_y int
pub threads_z int
}Buffer-only compute. Resource counts, uniforms and thread dimensions must match the shader; code is not reflected or sandboxed by the runtime.
format intentrypoint stringread_buffers intwrite_buffers intuniform_sizes []intthreads_x intthreads_y intthreads_z intstruct ComputePipelinepub struct ComputePipeline {
}ComputePipeline context or state structure.
This type has no public fields.
struct StorageBufferWritepub struct StorageBufferWrite {
}Non-owning write target. cycle=true discards prior contents when SDL cycles an in-use allocation. Use false when a later pass reads the previous result.
This type has no public fields.
write_bufferpub fn write_buffer(buffer &Buffer, cycle bool) StorageBufferWriteWrite buffer.
buffer &Buffercycle boolStorageBufferWrite — a value of this type
struct ComputePasspub struct ComputePass {
}ComputePass context or state structure.
This type has no public fields.
(&Device) compute_pipelinepub fn (device &Device) compute_pipeline(desc &ComputePipelineDesc, code &[]u8) ComputePipelineOperation on &Device: compute pipeline. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).desc &ComputePipelineDesccode &[]u8ComputePipeline — a value of this type
(&CommandEncoder) begin_computepub fn (encoder &CommandEncoder) begin_compute(writes &[]StorageBufferWrite) ComputePassWrite slots are fixed for the pass. End the pass between dependent dispatches: dispatches within one pass have no implicit memory barrier. Throws on failure; handle the error or propagate it to the caller.
encoder &CommandEncoderCommandEncoder instance used by this call (borrow).writes &[]StorageBufferWriteComputePass — a value of this type
(&ComputePass) pipelinepub fn (pass &ComputePass) pipeline(pipeline &ComputePipeline) intChanging the pipeline requires read buffers and uniforms to be rebound. Throws on failure; handle the error or propagate it to the caller.
pass &ComputePassComputePass instance used by this call (borrow).pipeline &ComputePipelineint — a value of this type
(&ComputePass) read_bufferpub fn (pass &ComputePass) read_buffer(slot int, buffer &Buffer) intOperation on &ComputePass: read buffer. Throws on failure; handle the error or propagate it to the caller.
pass &ComputePassComputePass instance used by this call (borrow).slot intbuffer &Bufferint — a value of this type
(&ComputePass) uniformpub fn (pass &ComputePass) uniform(slot int, bytes &[]u8) intExecute uniform on &ComputePass. Throws on failure; handle the error or propagate it to the caller.
pass &ComputePassComputePass instance used by this call (borrow).slot intbytes &[]u8int — a value of this type
(&ComputePass) dispatchpub fn (pass &ComputePass) dispatch(groups_x int, groups_y int, groups_z int) intGroup counts are 1...65535 per axis. Shader indexing and storage bounds remain the author's contract; GPU execution is asynchronous and unsandboxed. Throws on failure; handle the error or propagate it to the caller.
pass &ComputePassComputePass instance used by this call (borrow).groups_x intgroups_y intgroups_z intint — a value of this type
($&ComputePass) endpub fn (pass $&ComputePass) end() intExecute end on $&ComputePass. Throws on failure; handle the error or propagate it to the caller.
pass $&ComputePassComputePass instance used by this call (exclusive borrow).int — a value of this type
($&ComputePipeline) closepub fn (pipeline $&ComputePipeline) close() intOperation on $&ComputePipeline: close the resource. Throws on failure; handle the error or propagate it to the caller.
pipeline $&ComputePipelineComputePipeline instance used by this call (exclusive borrow).int — a value of this type
const VERTEXpub const VERTEX = 0Constant VERTEX, defining protocol or algorithm parameters.
const FRAGMENTpub const FRAGMENT = 1Constant FRAGMENT, defining protocol or algorithm parameters.
const NEARESTpub const NEAREST = 0Constant NEAREST, defining protocol or algorithm parameters.
const LINEARpub const LINEAR = 1Constant LINEAR, defining protocol or algorithm parameters.
const REPEATpub const REPEAT = 0Constant REPEAT, defining protocol or algorithm parameters.
const MIRRORED_REPEATpub const MIRRORED_REPEAT = 1Constant MIRRORED_REPEAT, defining protocol or algorithm parameters.
const CLAMP_TO_EDGEpub const CLAMP_TO_EDGE = 2Constant CLAMP_TO_EDGE, defining protocol or algorithm parameters.
const TRIANGLESpub const TRIANGLES = 0Constant TRIANGLES, defining protocol or algorithm parameters.
const TRIANGLE_STRIPpub const TRIANGLE_STRIP = 1Constant TRIANGLE_STRIP, defining protocol or algorithm parameters.
const LINESpub const LINES = 2Constant LINES, defining protocol or algorithm parameters.
const LINE_STRIPpub const LINE_STRIP = 3Constant LINE_STRIP, defining protocol or algorithm parameters.
const POINTSpub const POINTS = 4Constant POINTS, defining protocol or algorithm parameters.
const CULL_NONEpub const CULL_NONE = 0Constant CULL_NONE, defining protocol or algorithm parameters.
const CULL_FRONTpub const CULL_FRONT = 1Constant CULL_FRONT, defining protocol or algorithm parameters.
const CULL_BACKpub const CULL_BACK = 2Constant CULL_BACK, defining protocol or algorithm parameters.
const COUNTER_CLOCKWISEpub const COUNTER_CLOCKWISE = 0Constant COUNTER_CLOCKWISE, defining protocol or algorithm parameters.
const CLOCKWISEpub const CLOCKWISE = 1Constant CLOCKWISE, defining protocol or algorithm parameters.
const DEPTH_DISABLEDpub const DEPTH_DISABLED = 0Constant DEPTH_DISABLED, defining protocol or algorithm parameters.
const NEVERpub const NEVER = 1Constant NEVER, defining protocol or algorithm parameters.
const LESSpub const LESS = 2Constant LESS, defining protocol or algorithm parameters.
const EQUALpub const EQUAL = 3Constant EQUAL, defining protocol or algorithm parameters.
const LESS_EQUALpub const LESS_EQUAL = 4Constant LESS_EQUAL, defining protocol or algorithm parameters.
const GREATERpub const GREATER = 5Constant GREATER, defining protocol or algorithm parameters.
const NOT_EQUALpub const NOT_EQUAL = 6Constant NOT_EQUAL, defining protocol or algorithm parameters.
const GREATER_EQUALpub const GREATER_EQUAL = 7Constant GREATER_EQUAL, defining protocol or algorithm parameters.
const ALWAYSpub const ALWAYS = 8Constant ALWAYS, defining protocol or algorithm parameters.
const BLEND_DISABLEDpub const BLEND_DISABLED = 0Constant BLEND_DISABLED, defining protocol or algorithm parameters.
const BLEND_ALPHApub const BLEND_ALPHA = 1Constant BLEND_ALPHA, defining protocol or algorithm parameters.
const BLEND_PREMULTIPLIEDpub const BLEND_PREMULTIPLIED = 2Constant BLEND_PREMULTIPLIED, defining protocol or algorithm parameters.
const PER_VERTEXpub const PER_VERTEX = 0Constant PER_VERTEX, defining protocol or algorithm parameters.
const PER_INSTANCEpub const PER_INSTANCE = 1Constant PER_INSTANCE, defining protocol or algorithm parameters.
const FLOATpub const FLOAT = 1Constant FLOAT, defining protocol or algorithm parameters.
const FLOAT2pub const FLOAT2 = 2Constant FLOAT2, defining protocol or algorithm parameters.
const FLOAT3pub const FLOAT3 = 3Constant FLOAT3, defining protocol or algorithm parameters.
const FLOAT4pub const FLOAT4 = 4Constant FLOAT4, defining protocol or algorithm parameters.
const UNORM8X4pub const UNORM8X4 = 5Constant UNORM8X4, defining protocol or algorithm parameters.
const UINTpub const UINT = 6Constant UINT, defining protocol or algorithm parameters.
const UINT2pub const UINT2 = 7Constant UINT2, defining protocol or algorithm parameters.
const UINT3pub const UINT3 = 8Constant UINT3, defining protocol or algorithm parameters.
const UINT4pub const UINT4 = 9Constant UINT4, defining protocol or algorithm parameters.
struct SamplerDescpub struct SamplerDesc {
pub min_filter int
pub mag_filter int
pub mip_filter int
pub address_u int
pub address_v int
pub address_w int
pub min_lod f64
pub max_lod f64
}Structure encapsulating min_filter, mag_filter, mip_filter, address_u, address_v.
min_filter intmag_filter intmip_filter intaddress_u intaddress_v intaddress_w intmin_lod f64max_lod f64sampler_defaultspub fn sampler_defaults() SamplerDescSampler defaults.
No arguments are required.
SamplerDesc — a value of this type
struct ShaderDescpub struct ShaderDesc {
pub stage int
pub format int
pub entrypoint string
pub samplers int
pub uniform_sizes []int
}Structure encapsulating stage, format, entrypoint, samplers, uniform_sizes.
stage intformat intentrypoint stringsamplers intuniform_sizes []intstruct VertexBufferLayoutpub struct VertexBufferLayout {
pub slot int
pub stride int
pub rate int
}Structure encapsulating slot, stride, rate.
slot intstride intrate intstruct VertexAttributepub struct VertexAttribute {
pub location int
pub slot int
pub format int
pub offset int
}Structure encapsulating location, slot, format, offset.
location intslot intformat intoffset intstruct PipelineDescpub struct PipelineDesc {
pub color_format int
pub depth_format int
pub primitive int
pub cull int
pub front_face int
pub depth_compare int
pub depth_write bool
pub blend int
pub vertex_buffers []VertexBufferLayout
pub attributes []VertexAttribute
}Structure encapsulating color_format, depth_format, primitive, cull, front_face.
color_format intdepth_format intprimitive intcull intfront_face intdepth_compare intdepth_write boolblend intvertex_buffers []VertexBufferLayoutattributes []VertexAttributepipeline_defaultspub fn pipeline_defaults(color_format int) PipelineDescPipeline defaults.
color_format intPipelineDesc — a value of this type
struct Samplerpub struct Sampler {
}Sampler context or state structure.
This type has no public fields.
struct Shaderpub struct Shader {
}Shader context or state structure.
This type has no public fields.
struct GraphicsPipelinepub struct GraphicsPipeline {
}GraphicsPipeline context or state structure.
This type has no public fields.
(&Device) samplerpub fn (device &Device) sampler(desc SamplerDesc) SamplerExecute sampler on &Device. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).desc SamplerDescSampler — a value of this type
(&Device) shaderpub fn (device &Device) shader(desc &ShaderDesc, code &[]u8) ShaderExecute shader on &Device. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).desc &ShaderDesccode &[]u8Shader — a value of this type
(&Device) graphics_pipelinepub fn (device &Device) graphics_pipeline(vertex &Shader, fragment &Shader, desc &PipelineDesc) GraphicsPipelineOperation on &Device: graphics pipeline. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).vertex &Shaderfragment &Shaderdesc &PipelineDescGraphicsPipeline — a value of this type
($&Sampler) closepub fn (sampler $&Sampler) close() intOperation on $&Sampler: close the resource. Throws on failure; handle the error or propagate it to the caller.
sampler $&SamplerSampler instance used by this call (exclusive borrow).int — a value of this type
($&Shader) closepub fn (shader $&Shader) close() intOperation on $&Shader: close the resource. Throws on failure; handle the error or propagate it to the caller.
shader $&ShaderShader instance used by this call (exclusive borrow).int — a value of this type
($&GraphicsPipeline) closepub fn (pipeline $&GraphicsPipeline) close() intOperation on $&GraphicsPipeline: close the resource. Throws on failure; handle the error or propagate it to the caller.
pipeline $&GraphicsPipelineGraphicsPipeline instance used by this call (exclusive borrow).int — a value of this type
struct DeviceRefpub struct DeviceRef {
}Copyable, non-owning identities for retained draw lists and resource tables. They never extend owner lifetime. Validation and every binding check the backend's never-reused identity, including after the owner/device closes. Zero/default references are invalid; no raw platform handles are exposed.
This type has no public fields.
struct BufferRefpub struct BufferRef {
}BufferRef context or state structure.
This type has no public fields.
struct TextureRefpub struct TextureRef {
}TextureRef context or state structure.
This type has no public fields.
struct SamplerRefpub struct SamplerRef {
}SamplerRef context or state structure.
This type has no public fields.
(&Device) referencepub fn (device &Device) reference() DeviceRefExecute reference on &Device.
device &DeviceDevice instance used by this call (borrow).DeviceRef — a value of this type
(&Buffer) referencepub fn (buffer &Buffer) reference() BufferRefExecute reference on &Buffer.
buffer &BufferBuffer instance used by this call (borrow).BufferRef — a value of this type
(&Texture) referencepub fn (texture &Texture) reference() TextureRefExecute reference on &Texture.
texture &TextureTexture instance used by this call (borrow).TextureRef — a value of this type
(&Sampler) referencepub fn (sampler &Sampler) reference() SamplerRefExecute reference on &Sampler.
sampler &SamplerSampler instance used by this call (borrow).SamplerRef — a value of this type
(DeviceRef) samepub fn (reference DeviceRef) same(other DeviceRef) boolIdentity comparison does not assert liveness. Two zero references never match.
reference DeviceRefDeviceRef instance used by this call (value receiver).other DeviceRefbool — true or false
(DeviceRef) validatepub fn (reference DeviceRef) validate() intExecute validate on DeviceRef. Throws on failure; handle the error or propagate it to the caller.
reference DeviceRefDeviceRef instance used by this call (value receiver).int — a value of this type
(BufferRef) validatepub fn (reference BufferRef) validate() intExecute validate on BufferRef. Throws on failure; handle the error or propagate it to the caller.
reference BufferRefBufferRef instance used by this call (value receiver).int — a value of this type
(TextureRef) validatepub fn (reference TextureRef) validate() intExecute validate on TextureRef. Throws on failure; handle the error or propagate it to the caller.
reference TextureRefTextureRef instance used by this call (value receiver).int — a value of this type
(SamplerRef) validatepub fn (reference SamplerRef) validate() intExecute validate on SamplerRef. Throws on failure; handle the error or propagate it to the caller.
reference SamplerRefSamplerRef instance used by this call (value receiver).int — a value of this type
(BufferRef) size_bytespub fn (reference BufferRef) size_bytes() intOperation on BufferRef: size bytes.
reference BufferRefBufferRef instance used by this call (value receiver).int — a value of this type
(DeviceRef) validate_bufferpub fn (reference DeviceRef) validate_buffer(buffer BufferRef) intOperation on DeviceRef: validate buffer. Throws on failure; handle the error or propagate it to the caller.
reference DeviceRefDeviceRef instance used by this call (value receiver).buffer BufferRefint — a value of this type
(DeviceRef) validate_texturepub fn (reference DeviceRef) validate_texture(texture TextureRef) intOperation on DeviceRef: validate texture. Throws on failure; handle the error or propagate it to the caller.
reference DeviceRefDeviceRef instance used by this call (value receiver).texture TextureRefint — a value of this type
(DeviceRef) validate_samplerpub fn (reference DeviceRef) validate_sampler(sampler SamplerRef) intOperation on DeviceRef: validate sampler. Throws on failure; handle the error or propagate it to the caller.
reference DeviceRefDeviceRef instance used by this call (value receiver).sampler SamplerRefint — a value of this type
(&RenderPass) vertex_buffer_refpub fn (pass &RenderPass) vertex_buffer_ref(slot int, buffer BufferRef, offset int) intOperation on &RenderPass: vertex buffer ref. Throws on failure; handle the error or propagate it to the caller.
pass &RenderPassRenderPass instance used by this call (borrow).slot intbuffer BufferRefoffset intint — a value of this type
(&RenderPass) index_buffer_refpub fn (pass &RenderPass) index_buffer_ref(buffer BufferRef, offset int, element_size int) intOperation on &RenderPass: index buffer ref. Throws on failure; handle the error or propagate it to the caller.
pass &RenderPassRenderPass instance used by this call (borrow).buffer BufferRefoffset intelement_size intint — index; see the description for its range and special values
(&RenderPass) sampler_refpub fn (pass &RenderPass) sampler_ref(stage int, slot int, texture TextureRef, sampler SamplerRef) intOperation on &RenderPass: sampler ref. Throws on failure; handle the error or propagate it to the caller.
pass &RenderPassRenderPass instance used by this call (borrow).stage intslot inttexture TextureRefsampler SamplerRefint — a value of this type
struct SoftBlobpub struct SoftBlob {
}SoftBlob context or state structure.
This type has no public fields.
struct SoftBlobRefpub struct SoftBlobRef {
}SoftBlobRef context or state structure.
This type has no public fields.
soft_owner_newpub fn soft_owner_new() intAllocates an opaque soft-device owner id used by SoftBlobRef.validate. Throws on failure; handle the error or propagate it to the caller.
No arguments are required.
int — a value of this type
soft_owner_closepub fn soft_owner_close(owner int) intSoft owner close. Throws on failure; handle the error or propagate it to the caller.
owner intint — a value of this type
soft_blob_createpub fn soft_blob_create(owner int, bytes &[]u8) SoftBlobSoft blob create. Throws on failure; handle the error or propagate it to the caller.
owner intbytes &[]u8SoftBlob — a value of this type
empty_soft_blob_refpub fn empty_soft_blob_ref() SoftBlobRefEmpty soft blob ref.
No arguments are required.
SoftBlobRef — a value of this type
(&SoftBlob) referencepub fn (blob &SoftBlob) reference() SoftBlobRefExecute reference on &SoftBlob.
blob &SoftBlobSoftBlob instance used by this call (borrow).SoftBlobRef — a value of this type
($&SoftBlob) closepub fn (blob $&SoftBlob) close() intOperation on $&SoftBlob: close the resource. Throws on failure; handle the error or propagate it to the caller.
blob $&SoftBlobSoftBlob instance used by this call (exclusive borrow).int — a value of this type
(SoftBlobRef) validatepub fn (reference SoftBlobRef) validate(owner int) intExecute validate on SoftBlobRef. Throws on failure; handle the error or propagate it to the caller.
reference SoftBlobRefSoftBlobRef instance used by this call (value receiver).owner intint — a value of this type
(SoftBlobRef) read_u32pub fn (reference SoftBlobRef) read_u32(offset int) intOperation on SoftBlobRef: read u32. Throws on failure; handle the error or propagate it to the caller.
reference SoftBlobRefSoftBlobRef instance used by this call (value receiver).offset intint — a value of this type
(SoftBlobRef) read_f32pub fn (reference SoftBlobRef) read_f32(offset int) f64Operation on SoftBlobRef: read f32. Throws on failure; handle the error or propagate it to the caller.
reference SoftBlobRefSoftBlobRef instance used by this call (value receiver).offset intf64 — a value of this type
(SoftBlobRef) read_rgba8pub fn (reference SoftBlobRef) read_rgba8(index int) intPacked RGBA8 texel (R in the high 8 bits) matching game software sampling. Throws on failure; handle the error or propagate it to the caller.
reference SoftBlobRefSoftBlobRef instance used by this call (value receiver).index intint — a value of this type
const PRESENT_VSYNCpub const PRESENT_VSYNC = 0Constant PRESENT_VSYNC, defining protocol or algorithm parameters.
const PRESENT_IMMEDIATEpub const PRESENT_IMMEDIATE = 1Constant PRESENT_IMMEDIATE, defining protocol or algorithm parameters.
const PRESENT_MAILBOXpub const PRESENT_MAILBOX = 2Constant PRESENT_MAILBOX, defining protocol or algorithm parameters.
struct SurfaceOptionspub struct SurfaceOptions {
pub present_mode int
}Gpu Configuration parameters and options set.
present_mode intstruct Surfacepub struct Surface {
}Surface context or state structure.
This type has no public fields.
struct Framepub struct Frame {
}Gpu Protocol data frame encapsulation.
This type has no public fields.
(&Device) surfacepub fn (device &Device) surface(target &window.Window, options SurfaceOptions) SurfaceExecute surface on &Device. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).target &window.Windowoptions SurfaceOptionsSurface — a value of this type
(&Surface) formatpub fn (surface &Surface) format() intOperation on &Surface: format as a string. Throws on failure; handle the error or propagate it to the caller.
surface &SurfaceSurface instance used by this call (borrow).int — a value of this type
(&Surface) supports_present_modepub fn (surface &Surface) supports_present_mode(mode int) boolOperation on &Surface: supports present mode. Throws on failure; handle the error or propagate it to the caller.
surface &SurfaceSurface instance used by this call (borrow).mode intbool — true or false
(&Surface) set_present_modepub fn (surface &Surface) set_present_mode(mode int) intReconfiguration requires no acquired frame and may wait for GPU work. Throws on failure; handle the error or propagate it to the caller.
surface &SurfaceSurface instance used by this call (borrow).mode intint — a value of this type
(&Surface) acquirepub fn (surface &Surface) acquire() FrameA successful acquire can have no image (e.g. minimized). Test has_image before rendering. Dimensions/format describe this acquired image in pixels. Throws on failure; handle the error or propagate it to the caller.
surface &SurfaceSurface instance used by this call (borrow).Frame — a value of this type
(&Frame) has_imagepub fn (frame &Frame) has_image() boolOperation on &Frame: whether it has image.
frame &FrameFrame instance used by this call (borrow).bool — true or false
(&Frame) widthpub fn (frame &Frame) width() intExecute width on &Frame.
frame &FrameFrame instance used by this call (borrow).int — a value of this type
(&Frame) heightpub fn (frame &Frame) height() intExecute height on &Frame.
frame &FrameFrame instance used by this call (borrow).int — a value of this type
(&Frame) formatpub fn (frame &Frame) format() intOperation on &Frame: format as a string.
frame &FrameFrame instance used by this call (borrow).int — a value of this type
(&Frame) begin_renderpub fn (frame &Frame) begin_render(load int, clear Color, depth DepthAttachment) RenderPassSwapchain images are write-only, restricted to this frame, and always STORE. LOAD needs an earlier render pass in the same frame. No owning Texture/view or independent CommandEncoder can escape the acquired-image lifetime. Throws on failure; handle the error or propagate it to the caller.
frame &FrameFrame instance used by this call (borrow).load intclear Colordepth DepthAttachmentRenderPass — a value of this type
(&Frame) begin_computepub fn (frame &Frame) begin_compute(writes &[]StorageBufferWrite) ComputePassOperation on &Frame: begin compute. Throws on failure; handle the error or propagate it to the caller.
frame &FrameFrame instance used by this call (borrow).writes &[]StorageBufferWriteComputePass — a value of this type
($&Frame) presentpub fn (frame $&Frame) present() FenceEnd every active pass before presenting. Submission consumes the frame even on driver failure; close/drop is safe if a stale CPU owner remains afterward. Throws on failure; handle the error or propagate it to the caller.
frame $&FrameFrame instance used by this call (exclusive borrow).Fence — a value of this type
($&Frame) closepub fn (frame $&Frame) close() intAn acquired image cannot be cancelled. Abandonment ends active passes, clears opaque black and submits without a fence. Errors are reported teardown still consumes the command. No per-frame GPU-idle wait is added. Throws on failure; handle the error or propagate it to the caller.
frame $&FrameFrame instance used by this call (exclusive borrow).int — a value of this type
($&Surface) closepub fn (surface $&Surface) close() intClosing a surface safely finishes/invalidate its pending frame before unclaiming the window. Device/window closure also invalidates descendants. Throws on failure; handle the error or propagate it to the caller.
surface $&SurfaceSurface instance used by this call (exclusive borrow).int — a value of this type
const TEXTURE_SAMPLEDpub const TEXTURE_SAMPLED = 1Constant TEXTURE_SAMPLED, defining protocol or algorithm parameters.
const TEXTURE_COLOR_TARGETpub const TEXTURE_COLOR_TARGET = 2Constant TEXTURE_COLOR_TARGET, defining protocol or algorithm parameters.
const TEXTURE_DEPTH_TARGETpub const TEXTURE_DEPTH_TARGET = 4Constant TEXTURE_DEPTH_TARGET, defining protocol or algorithm parameters.
const MAX_TEXTURE_SIZE_2Dpub const MAX_TEXTURE_SIZE_2D = 16384SDL's portable 2D limit. Actual format/usage support is device-specific.
struct Texture2DDescpub struct Texture2DDesc {
pub format int
pub width int
pub height int
pub levels int
pub usage int
}Structure encapsulating format, width, height, levels, usage.
format intwidth intheight intlevels intusage intstruct Texturepub struct Texture {
}Texture context or state structure.
This type has no public fields.
struct TextureSlicepub struct TextureSlice {
}Non-owning subresource identity. Use after owner/device closure is rejected.
This type has no public fields.
(&Device) supports_texture_2dpub fn (device &Device) supports_texture_2d(format int, usage int) boolOperation on &Device: supports texture 2d. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).format intusage intbool — true or false
(&Device) texture_2dpub fn (device &Device) texture_2d(desc Texture2DDesc) TextureOperation on &Device: texture 2d. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).desc Texture2DDescTexture — a value of this type
(&Texture) level_countpub fn (texture &Texture) level_count() intOperation on &Texture: level count.
texture &TextureTexture instance used by this call (borrow).int — a value of this type
(&Texture) size_bytespub fn (texture &Texture) size_bytes() intOperation on &Texture: size bytes.
texture &TextureTexture instance used by this call (borrow).int — a value of this type
(&Texture) level_layoutpub fn (texture &Texture) level_layout(mip int) layout.Level2DOperation on &Texture: level layout. Throws on failure; handle the error or propagate it to the caller.
texture &TextureTexture instance used by this call (borrow).mip intlayout.Level2D — a value of this type
(&Texture) viewpub fn (texture &Texture) view(mip int) TextureSliceOperation on &Texture: view. Throws on failure; handle the error or propagate it to the caller.
texture &TextureTexture instance used by this call (borrow).mip intTextureSlice — a value of this type
(&Device) upload_texturepub fn (device &Device) upload_texture(texture &Texture, mip int, bytes &[]u8) FenceTransfers copy a complete tightly packed mip. Compression follows gpu/layout depth transfers are unsupported. Input bytes are copied before returning. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).texture &Texturemip intbytes &[]u8Fence — a value of this type
(&Device) download_texturepub fn (device &Device) download_texture(texture &Texture, mip int) ReadbackOperation on &Device: download texture. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).texture &Texturemip intReadback — a value of this type
(&Device) generate_mipspub fn (device &Device) generate_mips(texture &Texture) FenceOperation on &Device: generate mips. Throws on failure; handle the error or propagate it to the caller.
device &DeviceDevice instance used by this call (borrow).texture &TextureFence — a value of this type
($&Texture) closepub fn (texture $&Texture) close() intOperation on $&Texture: close the resource. Throws on failure; handle the error or propagate it to the caller.
texture $&TextureTexture instance used by this call (exclusive borrow).int — a value of this type