.allocator.alloc_fn 0 (in this case, malloc() will be called)
.allocator.free_fn 0 (in this case, free() will be called)
.allocator.user_data 0
.environment.defaults.color_format: default value depends on selected backend:
all GL backends: SG_PIXELFORMAT_RGBA8
Metal and D3D11: SG_PIXELFORMAT_BGRA8
WebGPU: *no default* (must be queried from WebGPU swapchain object)
.environment.defaults.depth_format: SG_PIXELFORMAT_DEPTH_STENCIL
.environment.defaults.sample_count: 1
Metal specific:
(NOTE: All Objective-C object references are transferred through
a bridged cast (__bridge const void*) to sokol_gfx, which will use an
unretained bridged cast (__bridge id<xxx>) to retrieve the Objective-C
references back. Since the bridge cast is unretained, the caller
must hold a strong reference to the Objective-C object until sg_setup()
returns.
.mtl_force_managed_storage_mode
when enabled, Metal buffers and texture resources are created in managed storage
mode, otherwise sokol-gfx will decide whether to create buffers and
textures in managed or shared storage mode (this is mainly a debugging option)
.mtl_use_command_buffer_with_retained_references
when true, the sokol-gfx Metal backend will use Metal command buffers which
bump the reference count of resource objects as long as they are inflight,
this is slower than the default command-buffer-with-unretained-references
method, this may be a workaround when confronted with lifetime validation
errors from the Metal validation layer until a proper fix has been implemented
.environment.metal.device
a pointer to the MTLDevice object
D3D11 specific:
.environment.d3d11.device
a pointer to the ID3D11Device object, this must have been created
before sg_setup() is called
.environment.d3d11.device_context
a pointer to the ID3D11DeviceContext object
.d3d11_shader_debugging
set this to true to compile shaders which are provided as HLSL source
code with debug information and without optimization, this allows
shader debugging in tools like RenderDoc, to output source code
instead of byte code from sokol-shdc, omit the --binary cmdline
option
WebGPU specific:
.wgpu_disable_bindgroups_cache
When this is true, the WebGPU backend will create and immediately
release a BindGroup object in the sg_apply_bindings() call, only
use this for debugging purposes.
.wgpu_bindgroups_cache_size
The size of the bindgroups cache for re-using BindGroup objects
between sg_apply_bindings() calls. The smaller the cache size,
the more likely are cache slot collisions which will cause
a BindGroups object to be destroyed and a new one created.
Use the information returned by sg_query_stats() to check
if this is a frequent occurrence, and increase the cache size as
needed (the default is 1024).
NOTE: wgpu_bindgroups_cache_size must be a power-of-2 number!
.environment.wgpu.device
a WGPUDevice handle
When using sokol_gfx.h and sokol_app.h together, consider using the
helper function sglue_environment() in the sokol_glue.h header to
initialize the sg_desc.environment nested struct. sglue_environment() returns
a completely initialized sg_environment struct with information
provided by sokol_app.h
sg_desc
The sg_desc struct contains configuration values for sokol_gfx, it is used as parameter to the sg_setup() call.
The default configuration is:
.buffer_pool_size 128 .image_pool_size 128 .sampler_pool_size 64 .shader_pool_size 32 .pipeline_pool_size 64 .pass_pool_size 16 .uniform_buffer_size 4 MB (4*1024*1024) .max_commit_listeners 1024 .disable_validation false .mtl_force_managed_storage_mode false .wgpu_disable_bindgroups_cache false .wgpu_bindgroups_cache_size 1024
.allocator.alloc_fn 0 (in this case, malloc() will be called) .allocator.free_fn 0 (in this case, free() will be called) .allocator.user_data 0
.environment.defaults.color_format: default value depends on selected backend: all GL backends: SG_PIXELFORMAT_RGBA8 Metal and D3D11: SG_PIXELFORMAT_BGRA8 WebGPU: *no default* (must be queried from WebGPU swapchain object) .environment.defaults.depth_format: SG_PIXELFORMAT_DEPTH_STENCIL .environment.defaults.sample_count: 1
Metal specific: (NOTE: All Objective-C object references are transferred through a bridged cast (__bridge const void*) to sokol_gfx, which will use an unretained bridged cast (__bridge id<xxx>) to retrieve the Objective-C references back. Since the bridge cast is unretained, the caller must hold a strong reference to the Objective-C object until sg_setup() returns.
.mtl_force_managed_storage_mode when enabled, Metal buffers and texture resources are created in managed storage mode, otherwise sokol-gfx will decide whether to create buffers and textures in managed or shared storage mode (this is mainly a debugging option) .mtl_use_command_buffer_with_retained_references when true, the sokol-gfx Metal backend will use Metal command buffers which bump the reference count of resource objects as long as they are inflight, this is slower than the default command-buffer-with-unretained-references method, this may be a workaround when confronted with lifetime validation errors from the Metal validation layer until a proper fix has been implemented .environment.metal.device a pointer to the MTLDevice object
D3D11 specific: .environment.d3d11.device a pointer to the ID3D11Device object, this must have been created before sg_setup() is called .environment.d3d11.device_context a pointer to the ID3D11DeviceContext object .d3d11_shader_debugging set this to true to compile shaders which are provided as HLSL source code with debug information and without optimization, this allows shader debugging in tools like RenderDoc, to output source code instead of byte code from sokol-shdc, omit the --binary cmdline option
WebGPU specific: .wgpu_disable_bindgroups_cache When this is true, the WebGPU backend will create and immediately release a BindGroup object in the sg_apply_bindings() call, only use this for debugging purposes. .wgpu_bindgroups_cache_size The size of the bindgroups cache for re-using BindGroup objects between sg_apply_bindings() calls. The smaller the cache size, the more likely are cache slot collisions which will cause a BindGroups object to be destroyed and a new one created. Use the information returned by sg_query_stats() to check if this is a frequent occurrence, and increase the cache size as needed (the default is 1024). NOTE: wgpu_bindgroups_cache_size must be a power-of-2 number! .environment.wgpu.device a WGPUDevice handle
When using sokol_gfx.h and sokol_app.h together, consider using the helper function sglue_environment() in the sokol_glue.h header to initialize the sg_desc.environment nested struct. sglue_environment() returns a completely initialized sg_environment struct with information provided by sokol_app.h