sokol.gfx #
Constants #
const sg_max_mipmaps = 16
const sg_cubeface_num = 6
const version = 1
fn append_buffer #
fn append_buffer(buf Buffer, data &Range) int
fn apply_bindings #
fn apply_bindings(bindings &Bindings)
fn apply_pipeline #
fn apply_pipeline(pip Pipeline)
fn apply_scissor_rect #
fn apply_scissor_rect(x int, y int, width int, height int, origin_top_left bool)
fn apply_uniforms #
fn apply_uniforms(stage ShaderStage, ub_index int, data &Range)
fn apply_viewport #
fn apply_viewport(x int, y int, width int, height int, origin_top_left bool)
fn begin_default_pass #
fn begin_default_pass(actions &PassAction, width int, height int)
rendering functions
fn begin_pass #
fn begin_pass(const_pass &Pass)
begin_pass begins a rendering pass. See also: documentation at the top of thirdparty/sokol/sokol_gfx.h
fn commit #
fn commit()
fn create_clear_pass #
fn create_clear_pass(r f32, g f32, b f32, a f32) PassAction
fn create_clear_pass_action #
fn create_clear_pass_action(r f32, g f32, b f32, a f32) PassAction
create_clear_pass_action returns a clearing PassAction
that clears the Pass
with the color defined by the color components r
ed,g
reen, b
lue and a
lpha.
fn destroy_attachments #
fn destroy_attachments(atts Attachments)
destroy_attachments destroys the atts
Attachments
See also: documentation at the top of thirdparty/sokol/sokol_gfx.h
fn destroy_buffer #
fn destroy_buffer(buf Buffer)
fn destroy_image #
fn destroy_image(img Image)
fn destroy_pipeline #
fn destroy_pipeline(pip Pipeline)
fn destroy_sampler #
fn destroy_sampler(smp Sampler)
fn destroy_shader #
fn destroy_shader(shd Shader)
fn disable_frame_stats #
fn disable_frame_stats()
disable_frame_stats disables the sokol frame statistics.
fn draw #
fn draw(base_element int, num_elements int, num_instances int)
fn enable_frame_stats #
fn enable_frame_stats()
enable_frame_stats enables the sokol frame statistics.
fn end_pass #
fn end_pass()
fn frame_stats_enabled #
fn frame_stats_enabled() bool
frame_stats_enabled returns true
if the sokol frame statistics is enabled.
fn is_valid #
fn is_valid() bool
fn make_attachments #
fn make_attachments(const_desc &AttachmentsDesc) Attachments
make_attachments creates an Attachments
instance from const_desc
. See also: documentation at the top of thirdparty/sokol/sokol_gfx.h
fn make_buffer #
fn make_buffer(desc &BufferDesc) Buffer
resource creation, destruction and updating
fn make_image #
fn make_image(desc &ImageDesc) Image
fn make_pipeline #
fn make_pipeline(desc &PipelineDesc) Pipeline
fn make_sampler #
fn make_sampler(desc &SamplerDesc) Sampler
fn make_shader #
fn make_shader(desc &ShaderDesc) Shader
fn query_attachments_defaults #
fn query_attachments_defaults(desc &AttachmentsDesc) AttachmentsDesc
query_attachments_defaults returns AttachmentsDesc
with default values replaced. See also: documentation at the top of thirdparty/sokol/sokol_gfx.h
fn query_attachments_info #
fn query_attachments_info(atts Attachments) AttachmentsInfo
query_attachments_info returns runtime information about the atts
/ Attachments
. See also: documentation at the top of thirdparty/sokol/sokol_gfx.h
fn query_attachments_state #
fn query_attachments_state(atts Attachments) ResourceState
query_attachments_state returns the current state of a resource (INITIAL, ALLOC, VALID, FAILED, INVALID) See also: documentation at the top of thirdparty/sokol/sokol_gfx.h
fn query_backend #
fn query_backend() Backend
fn query_buffer_defaults #
fn query_buffer_defaults(desc &Buffer) BufferDesc
get resource creation desc struct with their default values replaced
fn query_buffer_info #
fn query_buffer_info(buf Buffer) BufferInfo
get runtime information about a resource
fn query_buffer_overflow #
fn query_buffer_overflow(buf Buffer) bool
fn query_buffer_state #
fn query_buffer_state(buf Buffer) ResourceState
get current state of a resource (INITIAL, ALLOC, VALID, FAILED, INVALID)
fn query_desc #
fn query_desc() Desc
getting information
fn query_features #
fn query_features() Features
fn query_frame_stats #
fn query_frame_stats() FrameStats
query_frame_stats returns the sokol frame statistics for the current frame.
fn query_image_defaults #
fn query_image_defaults(desc &Image) ImageDesc
fn query_image_info #
fn query_image_info(img Image) ImageInfo
fn query_image_state #
fn query_image_state(img Image) ResourceState
fn query_limits #
fn query_limits() Limits
fn query_pipeline_defaults #
fn query_pipeline_defaults(desc &Pipeline) PipelineDesc
fn query_pipeline_info #
fn query_pipeline_info(pip Pipeline) PipelineInfo
fn query_pipeline_state #
fn query_pipeline_state(pip Pipeline) ResourceState
fn query_pixelformat #
fn query_pixelformat(fmt PixelFormat) PixelFormatInfo
fn query_shader_defaults #
fn query_shader_defaults(desc &Shader) ShaderDesc
fn query_shader_info #
fn query_shader_info(shd Shader) ShaderInfo
fn query_shader_state #
fn query_shader_state(shd Shader) ResourceState
fn reset_state_cache #
fn reset_state_cache()
fn setup #
fn setup(desc &Desc)
setup initialises the SOKOL's gfx library, based on the information passed in desc
fn shutdown #
fn shutdown()
shutdown tells the SOKOL's gfx library to shutdown, and release the resources it is using
fn update_buffer #
fn update_buffer(buf Buffer, data &Range)
fn update_image #
fn update_image(img Image, data &ImageData)
type AttachmentDesc #
type AttachmentDesc = C.sg_attachment_desc
type Attachments #
type Attachments = C.sg_attachments
Attachments represents data that can be attached to a render pass. See also: documentation at the top of thirdparty/sokol/sokol_gfx.h
type AttachmentsDesc #
type AttachmentsDesc = C.sg_attachments_desc
type AttachmentsInfo #
type AttachmentsInfo = C.sg_attachments_info
type Bindings #
type Bindings = C.sg_bindings
fn (Bindings) set_vert_image #
fn (mut b Bindings) set_vert_image(index int, img Image)
fn (Bindings) set_frag_image #
fn (mut b Bindings) set_frag_image(index int, img Image)
fn (Bindings) update_vert_buffer #
fn (b &Bindings) update_vert_buffer(index int, data voidptr, element_size int, element_count int)
fn (Bindings) append_vert_buffer #
fn (b &Bindings) append_vert_buffer(index int, data voidptr, element_size int, element_count int) int
fn (Bindings) update_index_buffer #
fn (b &Bindings) update_index_buffer(data voidptr, element_size int, element_count int)
fn (Bindings) append_index_buffer #
fn (b &Bindings) append_index_buffer(data voidptr, element_size int, element_count int) int
type BlendState #
type BlendState = C.sg_blend_state
type Buffer #
type Buffer = C.sg_buffer
fn (Buffer) free #
fn (mut b Buffer) free()
type BufferDesc #
type BufferDesc = C.sg_buffer_desc
type BufferInfo #
type BufferInfo = C.sg_buffer_info
type Color #
type Color = C.sg_color
type ColorAttachmentAction #
type ColorAttachmentAction = C.sg_color_attachment_action
type ColorTargetState #
type ColorTargetState = C.sg_color_target_state
type CommitListener #
type CommitListener = C.sg_commit_listener
type D3d11Environment #
type D3d11Environment = C.sg_d3d11_environment
type D3d11Swapchain #
type D3d11Swapchain = C.sg_d3d11_swapchain
type DepthAttachmentAction #
type DepthAttachmentAction = C.sg_depth_attachment_action
type DepthState #
type DepthState = C.sg_depth_state
type Desc #
type Desc = C.sg_desc
type Environment #
type Environment = C.sg_environment
type EnvironmentDefaults #
type EnvironmentDefaults = C.sg_environment_defaults
type Features #
type Features = C.sg_features
type FrameStats #
type FrameStats = C.sg_frame_stats
type FrameStatsD3D11 #
type FrameStatsD3D11 = C.sg_frame_stats_d3d11
type FrameStatsD3D11Bindings #
type FrameStatsD3D11Bindings = C.sg_frame_stats_d3d11_bindings
type FrameStatsD3D11Draw #
type FrameStatsD3D11Draw = C.sg_frame_stats_d3d11_draw
type FrameStatsD3D11Pass #
type FrameStatsD3D11Pass = C.sg_frame_stats_d3d11_pass
type FrameStatsD3D11Pipeline #
type FrameStatsD3D11Pipeline = C.sg_frame_stats_d3d11_pipeline
type FrameStatsD3D11Uniforms #
type FrameStatsD3D11Uniforms = C.sg_frame_stats_d3d11_uniforms
type FrameStatsGL #
type FrameStatsGL = C.sg_frame_stats_gl
type FrameStatsMetal #
type FrameStatsMetal = C.sg_frame_stats_metal
type FrameStatsMetalBindings #
type FrameStatsMetalBindings = C.sg_frame_stats_metal_bindings
type FrameStatsMetalIdpool #
type FrameStatsMetalIdpool = C.sg_frame_stats_metal_idpool
type FrameStatsMetalPipeline #
type FrameStatsMetalPipeline = C.sg_frame_stats_metal_pipeline
type FrameStatsMetalUniforms #
type FrameStatsMetalUniforms = C.sg_frame_stats_metal_uniforms
type FrameStatsWGPU #
type FrameStatsWGPU = C.sg_frame_stats_wgpu
type FrameStatsWGPUBindings #
type FrameStatsWGPUBindings = C.sg_frame_stats_wgpu_bindings
type FrameStatsWGPUUniforms #
type FrameStatsWGPUUniforms = C.sg_frame_stats_wgpu_uniforms
type GlSwapchain #
type GlSwapchain = C.sg_gl_swapchain
type Image #
type Image = C.sg_image
fn (Image) free #
fn (mut i Image) free()
type ImageData #
type ImageData = C.sg_image_data
type ImageDesc #
type ImageDesc = C.sg_image_desc
type ImageInfo #
type ImageInfo = C.sg_image_info
type Limits #
type Limits = C.sg_limits
type MetalEnvironment #
type MetalEnvironment = C.sg_metal_environment
type MetalSwapchain #
type MetalSwapchain = C.sg_metal_swapchain
type Pass #
type Pass = C.sg_pass
type PassAction #
type PassAction = C.sg_pass_action
type Pipeline #
type Pipeline = C.sg_pipeline
type PipelineDesc #
type PipelineDesc = C.sg_pipeline_desc
type PipelineInfo #
type PipelineInfo = C.sg_pipeline_info
type PixelFormatInfo #
type PixelFormatInfo = C.sg_pixelformat_info
type Range #
type Range = C.sg_range
type Sampler #
type Sampler = C.sg_sampler
type SamplerDesc #
type SamplerDesc = C.sg_sampler_desc
type Shader #
type Shader = C.sg_shader
fn (Shader) free #
fn (mut s Shader) free()
type ShaderAttrDesc #
type ShaderAttrDesc = C.sg_shader_attr_desc
type ShaderDesc #
type ShaderDesc = C.sg_shader_desc
fn (ShaderDesc) make_shader #
fn (desc &ShaderDesc) make_shader() Shader
type ShaderImageDesc #
type ShaderImageDesc = C.sg_shader_image_desc
type ShaderImageSamplerPairDesc #
type ShaderImageSamplerPairDesc = C.sg_shader_image_sampler_pair_desc
type ShaderInfo #
type ShaderInfo = C.sg_shader_info
type ShaderSamplerDesc #
type ShaderSamplerDesc = C.sg_shader_sampler_desc
type ShaderStageDesc #
type ShaderStageDesc = C.sg_shader_stage_desc
fn (ShaderStageDesc) set_image #
fn (mut desc ShaderStageDesc) set_image(index int, name string) ShaderStageDesc
type ShaderStorageBufferDesc #
type ShaderStorageBufferDesc = C.sg_shader_storage_buffer_desc
type ShaderUniformBlockDesc #
type ShaderUniformBlockDesc = C.sg_shader_uniform_block_desc
type ShaderUniformDesc #
type ShaderUniformDesc = C.sg_shader_uniform_desc
type SlotInfo #
type SlotInfo = C.sg_slot_info
type StageBindings #
type StageBindings = C.sg_stage_bindings
type StencilAttachmentAction #
type StencilAttachmentAction = C.sg_stencil_attachment_action
type StencilFaceState #
type StencilFaceState = C.sg_stencil_face_state
type StencilState #
type StencilState = C.sg_stencil_state
type Swapchain #
type Swapchain = C.sg_swapchain
type VertexAttrDesc #
type VertexAttrDesc = C.sg_vertex_attr_state
type VertexBufferLayoutState #
type VertexBufferLayoutState = C.sg_vertex_buffer_layout_state
type VertexLayoutState #
type VertexLayoutState = C.sg_vertex_layout_state
type WgpuEnvironment #
type WgpuEnvironment = C.sg_wgpu_environment
type WgpuSwapchain #
type WgpuSwapchain = C.sg_wgpu_swapchain
enum Backend #
enum Backend {
glcore33
gles3
d3d11
metal_ios
metal_macos
metal_simulator
wgpu
dummy
}
enum BlendFactor #
enum BlendFactor as u32 {
_default // value 0 reserved for default-init
zero
one
src_color
one_minus_src_color
src_alpha
one_minus_src_alpha
dst_color
one_minus_dst_color
dst_alpha
one_minus_dst_alpha
src_alpha_saturated
blend_color
one_minus_blend_color
blend_alpha
one_minus_blend_alpha
_num
_force_u32 = 0x7FFFFFFF
}
enum BlendOp #
enum BlendOp as u32 {
_default // value 0 reserved for default-init
add
subtract
reverse_subtract
_num
_force_u32 = 0x7FFFFFFF
}
enum BorderColor #
enum BorderColor as u32 {
_default // value 0 reserved for default-init
transparent_black
opaque_black
opaque_white
_num
_force_u32 = 0x7FFFFFFF
}
enum BufferType #
enum BufferType as u32 {
_default // value 0 reserved for default-init
vertexbuffer
indexbuffer
storagebuffer
_num
_force_u32 = 0x7FFFFFFF
}
enum ColorMask #
enum ColorMask as u32 {
_default = 0 // value 0 reserved for default-init
none = 0x10 // special value for 'all channels disabled
r = 1
g = 2
rg = 3
b = 4
rb = 5
gb = 6
rgb = 7
a = 8
ra = 9
ga = 0xa
rga = 0xb
ba = 0xc
rba = 0xd
gba = 0xe
rgba = 0xf
_force_u32 = 0x7FFFFFFF
}
enum CompareFunc #
enum CompareFunc as u32 {
_default // value 0 reserved for default-init
never
less
equal
less_equal
greater
not_equal
greater_equal
always
_num
_force_u32 = 0x7FFFFFFF
}
enum CubeFace #
enum CubeFace as u32 {
pos_x
neg_x
pos_y
neg_y
pos_z
neg_z
num
_force_u32 = 0x7fffffff
}
enum CullMode #
enum CullMode as u32 {
_default // value 0 reserved for default-init
none
front
back
_num
_force_u32 = 0x7FFFFFFF
}
enum FaceWinding #
enum FaceWinding as u32 {
default // value 0 reserved for default-init
ccw
cw
num
force_u32 = 0x7FFFFFFF
}
FaceWindin is C.sg_face_winding
enum Filter #
enum Filter as u32 {
_default // value 0 reserved for default-init
none
nearest
linear
_num
_force_u32 = 0x7fffffff
}
enum ImageSampleType #
enum ImageSampleType as u32 {
_default // value 0 reserved for default-init
float
depth
sint
uint
unfilterable_float
_num
_force_u32 = 0x7FFFFFFF
}
enum ImageType #
enum ImageType as u32 {
_default // value 0 reserved for default-init
_2d
cube
_3d
array
_num
_force_u32 = 0x7FFFFFFF
}
enum IndexType #
enum IndexType as u32 {
_default // value 0 reserved for default-init
none
uint16
uint32
_num
_force_u32 = 0x7FFFFFFF
}
enum LoadAction #
enum LoadAction as u32 {
_default
clear
load
dontcare
_force_u32 = 0x7FFFFFFF
}
enum PixelFormat #
enum PixelFormat as u32 {
_default // value 0 reserved for default-init
none
r8
r8sn
r8ui
r8si
r16
r16sn
r16ui
r16si
r16f
rg8
rg8sn
rg8ui
rg8si
r32ui
r32si
r32f
rg16
rg16sn
rg16ui
rg16si
rg16f
rgba8
srgb8a8
rgba8sn
rgba8ui
rgba8si
bgra8
rgb10a2
rg11b10f
rgb9e5
rg32ui
rg32si
rg32f
rgba16
rgba16sn
rgba16ui
rgba16si
rgba16f
rgba32ui
rgba32si
rgba32f
depth
depth_stencil
bc1_rgba
bc2_rgba
bc3_rgba
bc3_srgba
bc4_r
bc4_rsn
bc5_rg
bc5_rgsn
bc6h_rgbf
bc6h_rgbuf
bc7_rgba
bc7_srgba
pvrtc_rgb_2bpp // deprecated
pvrtc_rgb_4bpp // deprecated
pvrtc_rgba_2bpp // deprecated
pvrtc_rgba_4bpp // deprecated
etc2_rgb8
etc2_srgb8
etc2_rgb8a1
etc2_rgba8
etc2_srgb8a8
eac_r11
eac_r11sn
eac_rg11
eac_rg11sn
astc_4x4_rgba
astc_4x4_srgba
_num
_force_u32 = 0x7FFFFFFF
}
PixelFormat is C.sg_pixel_format
enum PrimitiveType #
enum PrimitiveType as u32 {
_default // value 0 reserved for default-init
points
lines
line_strip
triangles
triangle_strip
_num
_force_u32 = 0x7FFFFFFF
}
enum ResourceState #
enum ResourceState as u32 {
initial
alloc
valid
failed
invalid
_force_u32 = 0x7FFFFFFF
}
enum SamplerType #
enum SamplerType as u32 {
_default
filtering
nonfiltering
comparison
_num
_force_u32 = 0x7FFFFFFF
}
enum ShaderStage #
enum ShaderStage as u32 {
vs
fs
_force_u32 = 0x7FFFFFFF
}
enum StencilOp #
enum StencilOp as u32 {
_default // value 0 reserved for default-init
keep
zero
replace
incr_clamp
decr_clamp
invert
incr_wrap
decr_wrap
_num
_force_u32 = 0x7FFFFFFF
}
enum StoreAction #
enum StoreAction as u32 {
_default
store
dontcare
_force_u32 = 0x7FFFFFFF
}
enum UniformLayout #
enum UniformLayout as u32 {
uniformlayout_default = 0 // value 0 reserved for default-init
uniformlayout_native // default: layout depends on currently active backend
uniformlayout_std140 // std140: memory layout according to std140
_num
_force_u32 = 0x7FFFFFFF
}
enum UniformType #
enum UniformType as u32 {
invalid
float
float2
float3
float4
int
int2
int3
int4
mat4
_num
_force_u32 = 0x7FFFFFFF
}
enum Usage #
enum Usage as u32 {
_default // value 0 reserved for default-init
immutable
dynamic
stream
_num
_force_u32 = 0x7FFFFFFF
}
enum VertexFormat #
enum VertexFormat as u32 {
invalid
float
float2
float3
float4
byte4
byte4n // normalized
ubyte4
ubyte4n
short2
short2n
ushort2n
short4
short4n
ushort4n
uint10_n2
half2
half4
_num
_force_u32 = 0x7FFFFFFF
}
enum VertexStep #
enum VertexStep as u32 {
_default // value 0 reserved for default-init
per_vertex
per_instance
_num
_force_u32 = 0x7FFFFFFF
}
enum Wrap #
enum Wrap as u32 {
_default // value 0 reserved for default-init
repeat // The default wrap mode.
clamp_to_edge
clamp_to_border // not supported on all backends and platforms. To check for support, call sg_query_features(), and check the "clamp_to_border" boolean in the returned sg_features struct. Platforms which don't support SG_WRAP_CLAMP_TO_BORDER will silently fall back to clamp_to_edge without a validation error.
mirrored_repeat
_num
_force_u32 = 0x7FFFFFFF
}
struct C.sg_allocator #
struct C.sg_allocator {
pub mut:
alloc_fn memory.FnAllocatorAlloc = unsafe { nil }
free_fn memory.FnAllocatorFree = unsafe { nil }
user_data voidptr
}
struct C.sg_attachment_desc #
struct C.sg_attachment_desc {
pub mut:
image Image
mip_level int
slice int
}
struct C.sg_attachments #
struct C.sg_attachments {
id u32
}
fn (C.sg_attachments) free #
fn (mut a C.sg_attachments) free()
free frees the resources occupied by the struct
struct C.sg_attachments_desc #
struct C.sg_attachments_desc {
pub mut:
_start_canary u32
colors [4]AttachmentDesc
resolves [4]AttachmentDesc
depth_stencil AttachmentDesc
label &char = unsafe { nil }
_end_canary u32
}
struct C.sg_attachments_info #
struct C.sg_attachments_info {
pub mut:
slot SlotInfo // resource pool slot info
}
struct C.sg_bindings #
struct C.sg_bindings {
pub mut:
_start_canary u32
vertex_buffers [8]Buffer
vertex_buffer_offsets [8]int
index_buffer Buffer
index_buffer_offset int
vs StageBindings
fs StageBindings
_end_canary u32
// vs_images [8]Image // old
// fs_images [8]Image // old
}
struct C.sg_blend_state #
struct C.sg_blend_state {
pub mut:
enabled bool
src_factor_rgb BlendFactor
dst_factor_rgb BlendFactor
op_rgb BlendOp
src_factor_alpha BlendFactor
dst_factor_alpha BlendFactor
op_alpha BlendOp
}
struct C.sg_buffer #
struct C.sg_buffer {
id u32
}
struct C.sg_buffer_desc #
struct C.sg_buffer_desc {
pub mut:
size usize
type BufferType
usage Usage
data Range
label &char
// backend-specific resources
gl_buffers [2]u32
mtl_buffers [2]voidptr
d3d11_buffer voidptr
wgpu_buffer voidptr
}
struct C.sg_buffer_info #
struct C.sg_buffer_info {
pub:
slot SlotInfo
update_frame_index u32
append_frame_index u32
append_pos int
append_overflow bool
num_slots int
active_slot int
}
struct C.sg_color #
struct C.sg_color {
pub mut:
r f32
g f32
b f32
a f32
}
struct C.sg_color_attachment_action #
struct C.sg_color_attachment_action {
pub mut:
load_action LoadAction
store_action StoreAction
clear_value Color
}
struct C.sg_color_target_state #
struct C.sg_color_target_state {
pub mut:
pixel_format PixelFormat
write_mask ColorMask
blend BlendState
}
struct C.sg_commit_listener #
struct C.sg_commit_listener {
pub:
func fn (user_data voidptr)
user_data voidptr
}
C.sg_commit_listener is used with sg_add_commit_listener, to add a callback, which will be called in sg_commit(). This is useful for libraries building on top of sokol-gfx to be notified about when a frame ends (instead of having to guess, or add a manual 'new-frame' function).
struct C.sg_d3d11_environment #
struct C.sg_d3d11_environment {
pub mut:
device voidptr
device_context voidptr
}
struct C.sg_d3d11_swapchain #
struct C.sg_d3d11_swapchain {
pub mut:
render_view voidptr // ID3D11RenderTargetView
resolve_view voidptr // ID3D11RenderTargetView
depth_stencil_view voidptr // ID3D11DepthStencilView
}
struct C.sg_depth_attachment_action #
struct C.sg_depth_attachment_action {
pub mut:
load_action LoadAction
store_action StoreAction
clear_value f32
}
struct C.sg_depth_state #
struct C.sg_depth_state {
pixel_format PixelFormat
compare CompareFunc
write_enabled bool
bias f32
bias_slope_scale f32
bias_clamp f32
}
struct C.sg_desc #
struct C.sg_desc {
pub mut:
_start_canary u32
buffer_pool_size int
image_pool_size int
sampler_pool_size int
shader_pool_size int
pipeline_pool_size int
attachments_pool_size int
uniform_buffer_size int
max_commit_listeners int
disable_validation bool // disable validation layer even in debug mode, useful for tests
mtl_force_managed_storage_mode bool // for debugging: use Metal managed storage mode for resources even with UMA
mtl_use_command_buffer_with_retained_references bool // Metal: use a managed MTLCommandBuffer which ref-counts used resources
wgpu_disable_bindgroups_cache bool // set to true to disable the WebGPU backend BindGroup cache
wgpu_bindgroups_cache_size int // number of slots in the WebGPU bindgroup cache (must be 2^N)
allocator C.sg_allocator
logger C.sg_logger // optional log function override
environment C.sg_environment
_end_canary u32
}
C.sg_desc describes
struct C.sg_environment #
struct C.sg_environment {
pub mut:
defaults EnvironmentDefaults
metal MetalEnvironment
d3d11 D3d11Environment
wgpu WgpuEnvironment
}
struct C.sg_environment_defaults #
struct C.sg_environment_defaults {
pub mut:
color_format PixelFormat
depth_format PixelFormat
sample_count int
}
struct C.sg_features #
struct C.sg_features {
pub:
origin_top_left bool // framebuffer and texture origin is in top left corner
image_clamp_to_border bool // border color and clamp-to-border UV-wrap mode is supported
mrt_independent_blend_state bool // multiple-render-target rendering can use per-render-target blend state
mrt_independent_write_mask bool // multiple-render-target rendering can use per-render-target color write masks
storage_buffer bool // storage buffers are supported
}
struct C.sg_frame_stats #
struct C.sg_frame_stats {
frame_index u32 // current frame counter, starts at 0
num_passes u32
num_apply_viewport u32
num_apply_scissor_rect u32
num_apply_pipeline u32
num_apply_bindings u32
num_apply_uniforms u32
num_draw u32
num_update_buffer u32
num_append_buffer u32
num_update_image u32
size_apply_uniforms u32
size_update_buffer u32
size_append_buffer u32
size_update_image u32
gl FrameStatsGL
d3d11 FrameStatsD3D11
metal FrameStatsMetal
wgpu FrameStatsWGPU
}
struct C.sg_frame_stats_d3d11 #
struct C.sg_frame_stats_d3d11 {
pass FrameStatsD3D11Pass
pipeline FrameStatsD3D11Pipeline
bindings FrameStatsD3D11Bindings
uniforms FrameStatsD3D11Uniforms
draw FrameStatsD3D11Draw
num_map u32
num_unmap u32
}
struct C.sg_frame_stats_d3d11_bindings #
struct C.sg_frame_stats_d3d11_bindings {
num_ia_set_vertex_buffers u32
num_ia_set_index_buffer u32
num_vs_set_shader_resources u32
num_ps_set_shader_resources u32
num_vs_set_samplers u32
num_ps_set_samplers u32
}
struct C.sg_frame_stats_d3d11_draw #
struct C.sg_frame_stats_d3d11_draw {
num_draw_indexed_instanced u32
num_draw_indexed u32
num_draw_instanced u32
num_draw u32
}
struct C.sg_frame_stats_d3d11_pass #
struct C.sg_frame_stats_d3d11_pass {
num_om_set_render_targets u32
num_clear_render_target_view u32
num_clear_depth_stencil_view u32
num_resolve_subresource u32
}
struct C.sg_frame_stats_d3d11_pipeline #
struct C.sg_frame_stats_d3d11_pipeline {
num_rs_set_state u32
num_om_set_depth_stencil_state u32
num_om_set_blend_state u32
num_ia_set_primitive_topology u32
num_ia_set_input_layout u32
num_vs_set_shader u32
num_vs_set_constant_buffers u32
num_ps_set_shader u32
num_ps_set_constant_buffers u32
}
struct C.sg_frame_stats_d3d11_uniforms #
struct C.sg_frame_stats_d3d11_uniforms {
num_update_subresource u32
}
struct C.sg_frame_stats_gl #
struct C.sg_frame_stats_gl {
num_bind_buffer u32
num_active_texture u32
num_bind_texture u32
num_bind_sampler u32
num_use_program u32
num_render_state u32
num_vertex_attrib_pointer u32
num_vertex_attrib_divisor u32
num_enable_vertex_attrib_array u32
num_disable_vertex_attrib_array u32
num_uniform u32
}
struct C.sg_frame_stats_metal #
struct C.sg_frame_stats_metal {
idpool FrameStatsMetalIdpool
pipeline FrameStatsMetalPipeline
bindings FrameStatsMetalBindings
uniforms FrameStatsMetalUniforms
}
struct C.sg_frame_stats_metal_bindings #
struct C.sg_frame_stats_metal_bindings {
num_set_vertex_buffer u32
num_set_vertex_texture u32
num_set_vertex_sampler_state u32
num_set_fragment_buffer u32
num_set_fragment_texture u32
num_set_fragment_sampler_state u32
}
struct C.sg_frame_stats_metal_idpool #
struct C.sg_frame_stats_metal_idpool {
num_added u32
num_released u32
num_garbage_collected u32
}
struct C.sg_frame_stats_metal_pipeline #
struct C.sg_frame_stats_metal_pipeline {
num_set_blend_color u32
num_set_cull_mode u32
num_set_front_facing_winding u32
num_set_stencil_reference_value u32
num_set_depth_bias u32
num_set_render_pipeline_state u32
num_set_depth_stencil_state u32
}
struct C.sg_frame_stats_metal_uniforms #
struct C.sg_frame_stats_metal_uniforms {
num_set_vertex_buffer_offset u32
num_set_fragment_buffer_offset u32
}
struct C.sg_frame_stats_wgpu #
struct C.sg_frame_stats_wgpu {
uniforms FrameStatsWGPUUniforms
bindings FrameStatsWGPUBindings
}
struct C.sg_frame_stats_wgpu_bindings #
struct C.sg_frame_stats_wgpu_bindings {
num_set_vertex_buffer u32
num_skip_redundant_vertex_buffer u32
num_set_index_buffer u32
num_skip_redundant_index_buffer u32
num_create_bindgroup u32
num_discard_bindgroup u32
num_set_bindgroup u32
num_skip_redundant_bindgroup u32
num_bindgroup_cache_hits u32
num_bindgroup_cache_misses u32
num_bindgroup_cache_collisions u32
num_bindgroup_cache_hash_vs_key_mismatch u32
}
struct C.sg_frame_stats_wgpu_uniforms #
struct C.sg_frame_stats_wgpu_uniforms {
num_set_bindgroup u32
size_write_buffer u32
}
struct C.sg_gl_swapchain #
struct C.sg_gl_swapchain {
pub mut:
framebuffer u32
}
struct C.sg_image #
struct C.sg_image {
pub mut:
id u32
}
struct C.sg_image_data #
struct C.sg_image_data {
pub mut:
subimage [sg_cubeface_num][sg_max_mipmaps]Range
}
struct C.sg_image_desc #
struct C.sg_image_desc {
pub mut:
type ImageType
render_target bool
width int
height int
num_slices int
num_mipmaps int
usage Usage
pixel_format PixelFormat
sample_count int
// min_filter Filter
// mag_filter Filter
// wrap_u Wrap
// wrap_v Wrap
// wrap_w Wrap
// border_color BorderColor
// max_anisotropy u32
// min_lod f32
// max_lod f32
data ImageData
label &char
// backend-specific resources
gl_textures [2]u32
gl_texture_target u32
mtl_textures [2]voidptr
d3d11_texture voidptr
d3d11_shader_resource_view voidptr
wgpu_texture voidptr
}
struct C.sg_image_info #
struct C.sg_image_info {
pub mut:
slot SlotInfo // resource pool slot info
upd_frame_index u32 // frame index of last sg_update_image()
num_slots int // number of renaming-slots for dynamically updated images
active_slot int // currently active write-slot for dynamically updated images
}
struct C.sg_limits #
struct C.sg_limits {
pub:
max_image_size_2d int // max width/height of SG_IMAGETYPE_2D images
max_image_size_cube int // max width/height of SG_IMAGETYPE_CUBE images
max_image_size_3d int // max width/height/depth of SG_IMAGETYPE_3D images
max_image_size_array int // max width/height pf SG_IMAGETYPE_ARRAY images
max_image_array_layers int // max number of layers in SG_IMAGETYPE_ARRAY images
max_vertex_attrs int // <= SG_MAX_VERTEX_ATTRIBUTES (only on some GLES2 impls)
gl_max_vertex_uniform_components int // <= GL_MAX_VERTEX_UNIFORM_COMPONENTS (only on GL backends)
gl_max_combined_texture_image_units int // <= GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS (only on GL backends)
}
struct C.sg_logger #
struct C.sg_logger {
pub mut:
func memory.FnLogCb = unsafe { nil }
user_data voidptr
}
struct C.sg_metal_environment #
struct C.sg_metal_environment {
pub mut:
device voidptr
}
struct C.sg_metal_swapchain #
struct C.sg_metal_swapchain {
pub mut:
current_drawable voidptr
depth_stencil_texture voidptr // MTLTexture
msaa_color_texture voidptr // MTLTexture
}
struct C.sg_pass #
struct C.sg_pass {
pub mut:
_start_canary u32
action PassAction
attachments Attachments
swapchain Swapchain
label &char = unsafe { nil }
_end_canary u32
}
struct C.sg_pass_action #
struct C.sg_pass_action {
pub mut:
colors [4]ColorAttachmentAction
depth DepthAttachmentAction
stencil StencilAttachmentAction
}
struct C.sg_pipeline #
struct C.sg_pipeline {
pub:
id u32
}
fn (C.sg_pipeline) free #
fn (mut p C.sg_pipeline) free()
struct C.sg_pipeline_desc #
struct C.sg_pipeline_desc {
pub mut:
shader Shader
layout VertexLayoutState
depth DepthState
stencil StencilState
color_count int
colors [4]ColorTargetState // C.SG_MAX_COLOR_ATTACHMENTS
primitive_type PrimitiveType
index_type IndexType
cull_mode CullMode
face_winding FaceWinding
sample_count int
blend_color Color
alpha_to_coverage_enabled bool
label &char = &char(0)
}
struct C.sg_pipeline_info #
struct C.sg_pipeline_info {
pub:
slot SlotInfo
}
struct C.sg_pixelformat_info #
struct C.sg_pixelformat_info {
pub:
sample bool // pixel format can be sampled in shaders
filter bool // pixel format can be sampled with filtering
render bool // pixel format can be used as render target
blend bool // alpha-blending is supported
msaa bool // pixel format can be used as MSAA render target
depth bool // pixel format is a depth format
}
struct C.sg_range #
struct C.sg_range {
pub mut:
ptr voidptr
size usize
}
struct C.sg_sampler #
struct C.sg_sampler {
pub mut:
id u32
}
struct C.sg_sampler_desc #
struct C.sg_sampler_desc {
min_filter Filter
mag_filter Filter
mipmap_filter Filter
wrap_u Wrap
wrap_v Wrap
wrap_w Wrap
min_lod f32
max_lod f32
border_color BorderColor
compare CompareFunc
max_anisotropy u32
label &char
// backend-specific resources
gl_sampler u32
mtl_sampler voidptr
d3d11_sampler voidptr
wgpu_sampler voidptr
}
struct C.sg_sampler_info #
struct C.sg_sampler_info {}
pub struct C.sg_resource_state {} enum
struct C.sg_shader #
struct C.sg_shader {
pub:
id u32
}
struct C.sg_shader_attr_desc #
struct C.sg_shader_attr_desc {
pub mut:
name &char // GLSL vertex attribute name (only required for GLES2)
sem_name &char // HLSL semantic name
sem_index int // HLSL semantic index
}
struct C.sg_shader_desc #
struct C.sg_shader_desc {
pub mut:
attrs [16]ShaderAttrDesc
vs ShaderStageDesc
fs ShaderStageDesc
label &char
}
fn (C.sg_shader_desc) set_vert_src #
fn (mut desc C.sg_shader_desc) set_vert_src(src string) &ShaderDesc
fn (C.sg_shader_desc) set_frag_src #
fn (mut desc C.sg_shader_desc) set_frag_src(src string) &ShaderDesc
fn (C.sg_shader_desc) set_vert_image #
fn (mut desc C.sg_shader_desc) set_vert_image(index int, name string) &ShaderDesc
fn (C.sg_shader_desc) set_frag_image #
fn (mut desc C.sg_shader_desc) set_frag_image(index int, name string) &ShaderDesc
fn (C.sg_shader_desc) set_vert_uniform_block_size #
fn (mut desc C.sg_shader_desc) set_vert_uniform_block_size(block_index int, size usize) &ShaderDesc
fn (C.sg_shader_desc) set_frag_uniform_block_size #
fn (mut desc C.sg_shader_desc) set_frag_uniform_block_size(block_index int, size usize) &ShaderDesc
fn (C.sg_shader_desc) set_vert_uniform #
fn (mut desc C.sg_shader_desc) set_vert_uniform(block_index int, uniform_index int, name string, typ UniformType,
array_count int) &ShaderDesc
fn (C.sg_shader_desc) set_frag_uniform #
fn (mut desc C.sg_shader_desc) set_frag_uniform(block_index int, uniform_index int, name string, typ UniformType,
array_count int) &ShaderDesc
struct C.sg_shader_image_desc #
struct C.sg_shader_image_desc {
pub mut:
used bool
multisampled bool
// name &char
image_type ImageType
sample_type ImageSampleType
}
struct C.sg_shader_image_sampler_pair_desc #
struct C.sg_shader_image_sampler_pair_desc {
pub mut:
used bool
image_slot int
sampler_slot int
glsl_name &char
}
struct C.sg_shader_info #
struct C.sg_shader_info {
pub:
slot SlotInfo
}
struct C.sg_shader_sampler_desc #
struct C.sg_shader_sampler_desc {
pub mut:
used bool
sampler_type SamplerType
}
struct C.sg_shader_stage_desc #
struct C.sg_shader_stage_desc {
pub mut:
source &char
bytecode Range
entry &char
d3d11_target &char
uniform_blocks [4]ShaderUniformBlockDesc
storage_buffers [8]ShaderStorageBufferDesc
images [12]ShaderImageDesc
samplers [8]ShaderSamplerDesc
image_sampler_pairs [12]ShaderImageSamplerPairDesc
}
struct C.sg_shader_storage_buffer_desc #
struct C.sg_shader_storage_buffer_desc {
pub mut:
used bool
readonly bool
}
struct C.sg_shader_uniform_block_desc #
struct C.sg_shader_uniform_block_desc {
pub mut:
size usize
layout UniformLayout
uniforms [16]ShaderUniformDesc
}
struct C.sg_shader_uniform_desc #
struct C.sg_shader_uniform_desc {
pub mut:
name &char
type UniformType
array_count int
}
struct C.sg_slot_info #
struct C.sg_slot_info {
state ResourceState
res_id u32
ctx_id u32
}
struct C.sg_stage_bindings #
struct C.sg_stage_bindings {
pub mut:
images [12]Image
samplers [8]Sampler
}
struct C.sg_stencil_attachment_action #
struct C.sg_stencil_attachment_action {
pub mut:
load_action LoadAction
store_action StoreAction
clear_value u8
}
struct C.sg_stencil_face_state #
struct C.sg_stencil_face_state {
compare CompareFunc
fail_op StencilOp
depth_fail_op StencilOp
pass_op StencilOp
}
struct C.sg_stencil_state #
struct C.sg_stencil_state {
enabled bool
front StencilFaceState
back StencilFaceState
read_mask u8
write_mask u8
ref u8
}
struct C.sg_swapchain #
struct C.sg_swapchain {
pub mut:
width int
height int
sample_count int
color_format PixelFormat
depth_format PixelFormat
metal MetalSwapchain
d3d11 D3d11Swapchain
wgpu WgpuSwapchain
gl GlSwapchain
}
struct C.sg_trace_hooks #
struct C.sg_trace_hooks {}
struct C.sg_vertex_attr_state #
struct C.sg_vertex_attr_state {
pub mut:
buffer_index int
offset int
format VertexFormat
}
struct C.sg_vertex_buffer_layout_state #
struct C.sg_vertex_buffer_layout_state {
pub mut:
stride int
step_func VertexStep
step_rate int
}
struct C.sg_vertex_layout_state #
struct C.sg_vertex_layout_state {
pub mut:
buffers [8]VertexBufferLayoutState
attrs [16]VertexAttrDesc
}
struct C.sg_wgpu_environment #
struct C.sg_wgpu_environment {
pub mut:
device voidptr
}
struct C.sg_wgpu_swapchain #
struct C.sg_wgpu_swapchain {
pub mut:
render_view voidptr // WGPUTextureView
resolve_view voidptr // WGPUTextureView
depth_stencil_view voidptr // WGPUTextureView
}
- Constants
- fn append_buffer
- fn apply_bindings
- fn apply_pipeline
- fn apply_scissor_rect
- fn apply_uniforms
- fn apply_viewport
- fn begin_default_pass
- fn begin_pass
- fn commit
- fn create_clear_pass
- fn create_clear_pass_action
- fn destroy_attachments
- fn destroy_buffer
- fn destroy_image
- fn destroy_pipeline
- fn destroy_sampler
- fn destroy_shader
- fn disable_frame_stats
- fn draw
- fn enable_frame_stats
- fn end_pass
- fn frame_stats_enabled
- fn is_valid
- fn make_attachments
- fn make_buffer
- fn make_image
- fn make_pipeline
- fn make_sampler
- fn make_shader
- fn query_attachments_defaults
- fn query_attachments_info
- fn query_attachments_state
- fn query_backend
- fn query_buffer_defaults
- fn query_buffer_info
- fn query_buffer_overflow
- fn query_buffer_state
- fn query_desc
- fn query_features
- fn query_frame_stats
- fn query_image_defaults
- fn query_image_info
- fn query_image_state
- fn query_limits
- fn query_pipeline_defaults
- fn query_pipeline_info
- fn query_pipeline_state
- fn query_pixelformat
- fn query_shader_defaults
- fn query_shader_info
- fn query_shader_state
- fn reset_state_cache
- fn setup
- fn shutdown
- fn update_buffer
- fn update_image
- type AttachmentDesc
- type Attachments
- type AttachmentsDesc
- type AttachmentsInfo
- type Bindings
- type BlendState
- type Buffer
- type BufferDesc
- type BufferInfo
- type Color
- type ColorAttachmentAction
- type ColorTargetState
- type CommitListener
- type D3d11Environment
- type D3d11Swapchain
- type DepthAttachmentAction
- type DepthState
- type Desc
- type Environment
- type EnvironmentDefaults
- type Features
- type FrameStats
- type FrameStatsD3D11
- type FrameStatsD3D11Bindings
- type FrameStatsD3D11Draw
- type FrameStatsD3D11Pass
- type FrameStatsD3D11Pipeline
- type FrameStatsD3D11Uniforms
- type FrameStatsGL
- type FrameStatsMetal
- type FrameStatsMetalBindings
- type FrameStatsMetalIdpool
- type FrameStatsMetalPipeline
- type FrameStatsMetalUniforms
- type FrameStatsWGPU
- type FrameStatsWGPUBindings
- type FrameStatsWGPUUniforms
- type GlSwapchain
- type Image
- type ImageData
- type ImageDesc
- type ImageInfo
- type Limits
- type MetalEnvironment
- type MetalSwapchain
- type Pass
- type PassAction
- type Pipeline
- type PipelineDesc
- type PipelineInfo
- type PixelFormatInfo
- type Range
- type Sampler
- type SamplerDesc
- type Shader
- type ShaderAttrDesc
- type ShaderDesc
- type ShaderImageDesc
- type ShaderImageSamplerPairDesc
- type ShaderInfo
- type ShaderSamplerDesc
- type ShaderStageDesc
- type ShaderStorageBufferDesc
- type ShaderUniformBlockDesc
- type ShaderUniformDesc
- type SlotInfo
- type StageBindings
- type StencilAttachmentAction
- type StencilFaceState
- type StencilState
- type Swapchain
- type VertexAttrDesc
- type VertexBufferLayoutState
- type VertexLayoutState
- type WgpuEnvironment
- type WgpuSwapchain
- enum Backend
- enum BlendFactor
- enum BlendOp
- enum BorderColor
- enum BufferType
- enum ColorMask
- enum CompareFunc
- enum CubeFace
- enum CullMode
- enum FaceWinding
- enum Filter
- enum ImageSampleType
- enum ImageType
- enum IndexType
- enum LoadAction
- enum PixelFormat
- enum PrimitiveType
- enum ResourceState
- enum SamplerType
- enum ShaderStage
- enum StencilOp
- enum StoreAction
- enum UniformLayout
- enum UniformType
- enum Usage
- enum VertexFormat
- enum VertexStep
- enum Wrap
- struct C.sg_allocator
- struct C.sg_attachment_desc
- struct C.sg_attachments
- struct C.sg_attachments_desc
- struct C.sg_attachments_info
- struct C.sg_bindings
- struct C.sg_blend_state
- struct C.sg_buffer
- struct C.sg_buffer_desc
- struct C.sg_buffer_info
- struct C.sg_color
- struct C.sg_color_attachment_action
- struct C.sg_color_target_state
- struct C.sg_commit_listener
- struct C.sg_d3d11_environment
- struct C.sg_d3d11_swapchain
- struct C.sg_depth_attachment_action
- struct C.sg_depth_state
- struct C.sg_desc
- struct C.sg_environment
- struct C.sg_environment_defaults
- struct C.sg_features
- struct C.sg_frame_stats
- struct C.sg_frame_stats_d3d11
- struct C.sg_frame_stats_d3d11_bindings
- struct C.sg_frame_stats_d3d11_draw
- struct C.sg_frame_stats_d3d11_pass
- struct C.sg_frame_stats_d3d11_pipeline
- struct C.sg_frame_stats_d3d11_uniforms
- struct C.sg_frame_stats_gl
- struct C.sg_frame_stats_metal
- struct C.sg_frame_stats_metal_bindings
- struct C.sg_frame_stats_metal_idpool
- struct C.sg_frame_stats_metal_pipeline
- struct C.sg_frame_stats_metal_uniforms
- struct C.sg_frame_stats_wgpu
- struct C.sg_frame_stats_wgpu_bindings
- struct C.sg_frame_stats_wgpu_uniforms
- struct C.sg_gl_swapchain
- struct C.sg_image
- struct C.sg_image_data
- struct C.sg_image_desc
- struct C.sg_image_info
- struct C.sg_limits
- struct C.sg_logger
- struct C.sg_metal_environment
- struct C.sg_metal_swapchain
- struct C.sg_pass
- struct C.sg_pass_action
- struct C.sg_pipeline
- struct C.sg_pipeline_desc
- struct C.sg_pipeline_info
- struct C.sg_pixelformat_info
- struct C.sg_range
- struct C.sg_sampler
- struct C.sg_sampler_desc
- struct C.sg_sampler_info
- struct C.sg_shader
- struct C.sg_shader_attr_desc
- struct C.sg_shader_desc
- struct C.sg_shader_image_desc
- struct C.sg_shader_image_sampler_pair_desc
- struct C.sg_shader_info
- struct C.sg_shader_sampler_desc
- struct C.sg_shader_stage_desc
- struct C.sg_shader_storage_buffer_desc
- struct C.sg_shader_uniform_block_desc
- struct C.sg_shader_uniform_desc
- struct C.sg_slot_info
- struct C.sg_stage_bindings
- struct C.sg_stencil_attachment_action
- struct C.sg_stencil_face_state
- struct C.sg_stencil_state
- struct C.sg_swapchain
- struct C.sg_trace_hooks
- struct C.sg_vertex_attr_state
- struct C.sg_vertex_buffer_layout_state
- struct C.sg_vertex_layout_state
- struct C.sg_wgpu_environment
- struct C.sg_wgpu_swapchain