C API: Rendering quality¶
What the web SDK does against white specks on small avatars: multisampling in the main pass (with centroid sampling and a coverage-aware present), mip chains for item textures, and coverage-preserving mips for cut-out colour textures. The guide, with the speck counts, is Rendering quality.
sona_quality holds msaa and flags, 8 bytes. msaa is SONA_MSAA_AUTO (0: 4 samples on a hardware GPU, 1 on a software rasteriser), or 1 (off), 2, 4 or 8. flags are SONA_QUALITY_MIPS (1: item textures carry mip chains and are filtered between levels) and SONA_QUALITY_CUTOUT_MIPS (2: cut-out colour textures get edge bleed and coverage-preserving mips; only with SONA_QUALITY_MIPS).
A renderer starts with sona_quality_defaults. A frame over 4096 x 4096 / samples halves its samples until it fits, as the web does.
sona_quality_defaults¶
void sona_quality_defaults(sona_quality *q);
| Parameter and type | Meaning |
|---|---|
qsona_quality * |
The sona_quality to fill with the defaults (required) |
Returns Nothing.
Example (also in Rendering quality):
void sona_quality_defaults(sona_quality *q);
The web SDK's defaults: msaa = SONA_MSAA_AUTO, flags = SONA_QUALITY_MIPS | SONA_QUALITY_CUTOUT_MIPS. NULL does nothing.
sona_renderer_set_quality¶
sona_result sona_renderer_set_quality(sona_renderer *r,
const sona_quality *q);
| Parameter and type | Meaning |
|---|---|
rsona_renderer * |
The renderer (required) |
qconst sona_quality * |
A sona_quality (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).
Example (also in Rendering quality):
sona_result sona_renderer_set_quality(sona_renderer *r,
const sona_quality *q);
Sets the quality from the next sona_draw or sona_snapshot. NULL q means the defaults. More samples than the device has are clamped to the most it has. A change of mip flags uploads each avatar's textures again at its next draw. SONA_E_ARGUMENT for a NULL renderer, another msaa value, or an unknown flag; the renderer keeps its old quality then. sona_renderer_reset keeps the quality and works out the sample count again for the new device.
sona_renderer_quality¶
sona_result sona_renderer_quality(const sona_renderer *r,
sona_quality *out);
| Parameter and type | Meaning |
|---|---|
rconst sona_renderer * |
The renderer (required) |
outsona_quality * |
Receives the sona_quality (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).
Example (also in Rendering quality):
sona_result sona_renderer_quality(const sona_renderer *r,
sona_quality *out);
What the renderer draws with. out->msaa is the sample count the backend really uses, asked of it at each call: never SONA_MSAA_AUTO, and 1 when the device cannot multisample. When a backend cannot make its multisampled target it logs once and draws one sample from then on, and out->msaa is 1 after that. After a frame over the 4096 x 4096 budget it is the halved count that frame used. out->flags are the flags as set, with SONA_QUALITY_CUTOUT_MIPS cleared when SONA_QUALITY_MIPS is not set. SONA_E_ARGUMENT when r or out is NULL.
sona_renderer_vk_features¶
sona_result sona_renderer_vk_features(sona_renderer *r, uint32_t features);
| Parameter and type | Meaning |
|---|---|
rsona_renderer * |
The renderer (required) |
featuresuint32_t |
SONA_VK_FEATURE_* bits the host's device has enabled |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_UNSUPPORTED (what each means).
Example:
sona_result result = sona_renderer_vk_features(r, 0);
if (result != SONA_OK) printf("sona_renderer_vk_features: %s\n",
sona_result_name(result));
Vulkan only: the optional VkPhysicalDeviceFeatures the host enabled when it created sona_device_desc.u.vk.device, which the backend cannot ask the device for. SONA_VK_FEATURE_BINDLESS (1, shaderSampledImageArrayDynamicIndexing) puts every texture in one descriptor set, so a pass binds one set and the draws only draw; SONA_VK_FEATURE_MULTI_DRAW (2, multiDrawIndirect and drawIndirectFirstInstance, only with BINDLESS) makes each run of draws one vkCmdDrawIndexedIndirect. The picture is the same byte for byte; the CPU time to record a frame drops (the guide has the numbers). From the next frame; 0 goes back to a set per draw. A renderer starts with 0, and again after sona_renderer_reset. SONA_E_UNSUPPORTED on any other backend or when the physical device lacks a feature (nothing changes), SONA_E_ARGUMENT for a NULL renderer, an unknown bit, or MULTI_DRAW without BINDLESS. The guide: Vulkan.
sona_tier_defaults¶
void sona_tier_defaults(sona_tier_options *o);
| Parameter and type | Meaning |
|---|---|
osona_tier_options * |
The sona_tier_options to fill with the defaults (required) |
Returns Nothing.
Example (also in Quality tiers):
void sona_tier_defaults(sona_tier_options *o);
size set; target_fps 60, avatars 20.
sona_tier_apply¶
sona_result sona_tier_apply(sona_ctx *ctx, sona_renderer *r,
const sona_tier_options *o);
| Parameter and type | Meaning |
|---|---|
ctxsona_ctx * |
The context (required) |
rsona_renderer * |
The renderer (required) |
oconst sona_tier_options * |
The options, a sona_tier_options (NULL: the defaults) |
Returns SONA_OK. Errors SONA_E_ARGUMENT, SONA_E_MEMORY (what each means).
Example (also in Quality tiers):
sona_result sona_tier_apply(sona_ctx *ctx, sona_renderer *r,
const sona_tier_options *o);
r NULL: the ctx's side only. o NULL: the defaults.
sona_tier_detect¶
sona_result sona_tier_detect(const sona_renderer *r, uint32_t *out);
| Parameter and type | Meaning |
|---|---|
rconst sona_renderer * |
The renderer (required) |
outuint32_t * |
Receives the values (required) |
Returns SONA_OK. Errors SONA_E_ARGUMENT (what each means).
Example (also in Quality tiers):
sona_result sona_tier_detect(const sona_renderer *r, uint32_t *out);
The tier the device behind r suits: SONA_TIER_LOW .. SONA_TIER_HIGH.
This page as Markdown · All the docs as one file (llms-full.txt)