RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
native_gpu.h File Reference

Rounded native output uses fractional anti-aliasing, independently of the integer-coverage CPU renderer and exact command replay. More...

#include "draw_target.h"
#include <sokol_gfx.h>

Data Structures

struct  rmgui_native_status_t
 Last prepare result and used attempt counters, retained through cancel/consume until the next prepare. More...
struct  rmgui_native_pool_t
 One pool tier: count slots of width x height texels. More...
struct  rmgui_native_storage_desc_t
 Fixed create-time storage. More...
struct  rmgui_native_external_binding_t
 Borrowed sampled RGBA8 image replacing CPU upload for one pinned framebuffer identity. More...
struct  rmgui_native_external_t
 Borrowed image binding, immutable through consume/cancel. More...
struct  rmgui_native_desc_t
 GPU payload reservation (no driver alignment, metadata, handle pools, host targets, external images or CPU arrays): More...
struct  rmgui_native_prepare_desc_t
 Device-pixel frame inputs, borrowed through consume/cancel. More...
struct  rmgui_native_stats_t
 Last successfully consumed frame, except submissions/draws accumulate. More...

Typedefs

typedef rmgui_native_result_t(*) rmgui_native_readback_fn(void *userdata, sg_image image, rmgui_rect_t region, void *pixels, size_t stride)
 Host readback runs outside passes after GPU capture.
typedef struct rmgui_native rmgui_native_t
 Independent float GPU renderer.

Enumerations

enum  rmgui_native_result_t {
  RMGUI_NATIVE_OK , RMGUI_NATIVE_ARGS , RMGUI_NATIVE_STATE , RMGUI_NATIVE_STORAGE_EXHAUSTED ,
  RMGUI_NATIVE_INVALID , RMGUI_NATIVE_CHANGED , RMGUI_NATIVE_REFUSED , RMGUI_NATIVE_BACKEND ,
  RMGUI_NATIVE_ATLAS_FULL , RMGUI_NATIVE_GLYPH_TOO_LARGE
}
 Failures submit no consuming draws; prepare validates the complete stream before uploads or offscreen passes. More...
enum  rmgui_native_capacity_t {
  RMGUI_NATIVE_CAPACITY_NONE , RMGUI_NATIVE_CAPACITY_INSTANCES , RMGUI_NATIVE_CAPACITY_RESOURCES , RMGUI_NATIVE_CAPACITY_UPLOAD ,
  RMGUI_NATIVE_CAPACITY_IMAGES , RMGUI_NATIVE_CAPACITY_ATLAS , RMGUI_NATIVE_CAPACITY_STAGING , RMGUI_NATIVE_CAPACITY_GRADIENT_RAMPS
}
 Fixed storage that prevented prepare from completing; NONE for other errors. More...
enum  rmgui_native_alpha_t { RMGUI_NATIVE_STRAIGHT_RGBA , RMGUI_NATIVE_PREMULTIPLIED_RGBA , RMGUI_NATIVE_R8 }
 Encoded-space source representation; RGBA8 sampling never enables sRGB decode. More...
enum  { RMGUI_NATIVE_OPCODE_CAPACITY = RMGUI_CMD_COUNT , RMGUI_NATIVE_MEMORY_CLASSES = 8 , RMGUI_NATIVE_FLUSH_REASONS = 5 }

Functions

rmgui_native_result_t rmgui_native_create (rmgui_native_t **out, const rmgui_native_desc_t *desc)
 Allocate fixed CPU storage and backend handles outside passes.
rmgui_native_result_t rmgui_native_storage_bytes (const rmgui_native_desc_t *desc, size_t max_image_size_2d, size_t out_bytes[RMGUI_NATIVE_MEMORY_CLASSES])
 Pure, allocation-free GPU payload sizing; does not require sg_setup.
void rmgui_native_release (rmgui_native_t *native)
 Release owned handles/storage outside passes; NULL is a no-op.
rmgui_native_result_t rmgui_native_prepare (rmgui_native_t *native, rmgui_draw_stream_t *stream, const rmgui_native_prepare_desc_t *desc)
 Validate the complete sealed tree and all native capabilities before GPU work.
rmgui_native_result_t rmgui_native_consume (rmgui_native_t *native)
 Consume once inside a host single-sample RGBA8/no-depth pass.
void rmgui_native_cancel (rmgui_native_t *native)
 Cancel outside passes; release input and roll back pending atlas/captures.
rmgui_native_stats_t rmgui_native_stats (const rmgui_native_t *native)
 Return committed counters by value, or all zero for NULL.
rmgui_native_status_t rmgui_native_status (const rmgui_native_t *native)
 Last prepare diagnostic, retained through consume/cancel.

Detailed Description

Rounded native output uses fractional anti-aliasing, independently of the integer-coverage CPU renderer and exact command replay.

Native rounded acceptance compares independent AA geometry while retaining exact clipping.

Constants

Counter-array extent follows the complete public command vocabulary.

Typedef Documentation

◆ rmgui_native_readback_fn

typedef rmgui_native_result_t(*) rmgui_native_readback_fn(void *userdata, sg_image image, rmgui_rect_t region, void *pixels, size_t stride)

Host readback runs outside passes after GPU capture.

region uses top-left image coordinates, pixels is renderer-owned writable RGBA8 staging with stride bytes per row, not the caller's capture framebuffer. Return OK only after pixels are complete; this callback may synchronize the GPU and stall. It must not commit, allocate renderer storage or retain pointers.

◆ rmgui_native_t

typedef struct rmgui_native rmgui_native_t

Independent float GPU renderer.

All calls run on the host sg thread; create, prepare, cancel and release run outside passes. Release before sg_shutdown.

Enumeration Type Documentation

◆ rmgui_native_result_t

Failures submit no consuming draws; prepare validates the complete stream before uploads or offscreen passes.

REFUSED identifies an unsupported op.

Enumerator
RMGUI_NATIVE_OK 
RMGUI_NATIVE_ARGS 
RMGUI_NATIVE_STATE 
RMGUI_NATIVE_STORAGE_EXHAUSTED 
RMGUI_NATIVE_INVALID 
RMGUI_NATIVE_CHANGED 
RMGUI_NATIVE_REFUSED 
RMGUI_NATIVE_BACKEND 
RMGUI_NATIVE_ATLAS_FULL 
RMGUI_NATIVE_GLYPH_TOO_LARGE 

◆ rmgui_native_capacity_t

Fixed storage that prevented prepare from completing; NONE for other errors.

Enumerator
RMGUI_NATIVE_CAPACITY_NONE 
RMGUI_NATIVE_CAPACITY_INSTANCES 
RMGUI_NATIVE_CAPACITY_RESOURCES 
RMGUI_NATIVE_CAPACITY_UPLOAD 
RMGUI_NATIVE_CAPACITY_IMAGES 
RMGUI_NATIVE_CAPACITY_ATLAS 
RMGUI_NATIVE_CAPACITY_STAGING 
RMGUI_NATIVE_CAPACITY_GRADIENT_RAMPS 

◆ rmgui_native_alpha_t

Encoded-space source representation; RGBA8 sampling never enables sRGB decode.

Straight sources preserve hidden RGB for nearest copy; filtered compositing requires premultiplied data. R8 denotes coverage, not an RGBA color.

Enumerator
RMGUI_NATIVE_STRAIGHT_RGBA 
RMGUI_NATIVE_PREMULTIPLIED_RGBA 
RMGUI_NATIVE_R8 

◆ anonymous enum

anonymous enum
Enumerator
RMGUI_NATIVE_OPCODE_CAPACITY 
RMGUI_NATIVE_MEMORY_CLASSES 
RMGUI_NATIVE_FLUSH_REASONS 

Function Documentation

◆ rmgui_native_create()

rmgui_native_result_t rmgui_native_create ( rmgui_native_t ** out,
const rmgui_native_desc_t * desc )

Allocate fixed CPU storage and backend handles outside passes.

Positive, overflow-safe capacities required. Failure leaves *out unchanged.

◆ rmgui_native_storage_bytes()

rmgui_native_result_t rmgui_native_storage_bytes ( const rmgui_native_desc_t * desc,
size_t max_image_size_2d,
size_t out_bytes[RMGUI_NATIVE_MEMORY_CLASSES] )

Pure, allocation-free GPU payload sizing; does not require sg_setup.

max_image_size_2d is the backend limit (at least 1024). Uses the same validated layout as create and committed gpu_bytes. Failure leaves out_bytes unchanged. Classes match stats; unused surfaces are layer, retained field root is geometry. Consume may reclassify surface bytes as root/blur without changing the sum. Staging is included: this is not resident VRAM or a promise about driver usage.

◆ rmgui_native_release()

void rmgui_native_release ( rmgui_native_t * native)

Release owned handles/storage outside passes; NULL is a no-op.

◆ rmgui_native_prepare()

rmgui_native_result_t rmgui_native_prepare ( rmgui_native_t * native,
rmgui_draw_stream_t * stream,
const rmgui_native_prepare_desc_t * desc )

Validate the complete sealed tree and all native capabilities before GPU work.

No silent fallback. Failure releases the stream and preserves capture outputs. Stream/source/table lifetimes extend through consume/cancel. Uploads/offscreen work require a host commit before another prepare.

◆ rmgui_native_consume()

rmgui_native_result_t rmgui_native_consume ( rmgui_native_t * native)

Consume once inside a host single-sample RGBA8/no-depth pass.

No allocation. Crossing a host commit or mutating sealed input refuses before any draws. Successful consume publishes CPU captures and commits frame counters.

◆ rmgui_native_cancel()

void rmgui_native_cancel ( rmgui_native_t * native)

Cancel outside passes; release input and roll back pending atlas/captures.

After GPU work a host commit is still required. NULL is a no-op.

◆ rmgui_native_stats()

rmgui_native_stats_t rmgui_native_stats ( const rmgui_native_t * native)

Return committed counters by value, or all zero for NULL.

◆ rmgui_native_status()

rmgui_native_status_t rmgui_native_status ( const rmgui_native_t * native)

Last prepare diagnostic, retained through consume/cancel.

Command index is local to the identified opcode's stream. NULL/before prepare returns ARGS, capacity NONE, RMGUI_CMD_COUNT/SIZE_MAX and zero attempted counters.