# render_command_buffer.h ## Index
`tm_renderer_command_buffer_o`
`tm_renderer_resource_command_buffer_o`
`enum tm_renderer_command`
`enum tm_renderer_map_flags`
`enum tm_renderer_statistics_flags`
`struct tm_renderer_commands_t`

`struct tm_renderer_command_buffer_api`
`bind_render_pass()`
`set_viewports()`
`set_scissor_rects()`
`draw_calls()`
`bind_queue()`
`begin_statistics_scope()`
`end_statistics_scope()`
`compute_dispatches()`
`transition_resources()`
`copy_image()`
`copy_buffer()`
`trace_dispatches()`
`read_image()`
`read_buffer()`
`num_commands()`
`commands()`
`user_data()`
`set_backend_allocator()`
`append_buffers()`

`struct tm_renderer_command_buffer_pool_api`
`create()`
`destroy()`
`user_data_size()`

`tm_renderer_create_command_buffer_pool()`
`tm_renderer_destroy_command_buffer_pool()`

`struct tm_renderer_command_buffer_sort_api`
`sort_memory_needed()`
`sort_commands()`

`enum tm_renderer_resource`
`struct tm_renderer_resource_commands_t`

`struct tm_renderer_resource_command_buffer_api`
`create_buffer()`
`map_create_buffer()`
`resize_buffer()`
`update_buffer()`
`create_image()`
`map_create_image()`
`update_image()`
`create_image_views()`
`create_shader()`
`create_sampler()`
`create_shader_state_override()`
`create_queue_fence()`
`create_resource_binder()`
`create_ray_tracing_pipeline()`
`create_shader_binding_table()`
`create_top_level_acceleration_structure()`
`create_bottom_level_acceleration_structure()`
`set_resource()`
`set_array_resources()`
`destroy_resource()`
`num_commands()`
`commands()`
`user_data()`
`set_backend_allocators()`
`append_buffers()`

`struct tm_renderer_resource_command_buffer_pool_api`
`create()`
`destroy()`
`user_data_size()`

## API
### `tm_renderer_command_buffer_o`
~~~c typedef struct tm_renderer_command_buffer_o tm_renderer_command_buffer_o; ~~~
### `tm_renderer_resource_command_buffer_o`
~~~c typedef struct tm_renderer_resource_command_buffer_o tm_renderer_resource_command_buffer_o; ~~~
### `enum tm_renderer_command`
~~~c enum tm_renderer_command { // Command describing binding of a set of render targets for writing, `data` points to [[tm_renderer_render_pass_bind_t]]. TM_RENDERER_COMMAND_BIND_RENDER_PASS, // Command describing setting a number of viewports. 'data' points to [[tm_renderer_set_viewports_t]]. TM_RENDERER_COMMAND_SET_VIEWPORTS, // Command describing setting a number of scissor rects. 'data' points to [[tm_renderer_set_scissor_rects_t]]. TM_RENDERER_COMMAND_SET_SCISSOR_RECTS, // Command describing a draw call, `data` points to a [[tm_renderer_draw_call_info_t]]. TM_RENDERER_COMMAND_DRAW_CALL, // Command describing the start of a statistics scope, `data` points to a [[tm_renderer_begin_statistics_t]]. TM_RENDERER_COMMAND_BEGIN_STATISTICS, // Command describing the end of a statistics scope, `data` points to a [[tm_renderer_end_statistics_t]]. TM_RENDERER_COMMAND_END_STATISTICS, // Command describing switching command execution to happen on a different command queue. TM_RENDERER_COMMAND_BIND_QUEUE, // Command describing a compute kernel dispatch, `data` points to a [[tm_renderer_compute_info_t]]. TM_RENDERER_COMMAND_COMPUTE, // Command describing a resource barrier, `data` points to a [[tm_renderer_resource_barrier_header_t]]. TM_RENDERER_COMMAND_TRANSITION_RESOURCES, // Command describing a image buffer copy, `data` points to a [[tm_renderer_copy_image_t]]. TM_RENDERER_COMMAND_COPY_IMAGE, // Command describing a buffer copy, `data` points to a [[tm_renderer_copy_buffer_t]]. TM_RENDERER_COMMAND_COPY_BUFFER, // Command describing a image buffer read back. `data` points to a // [[tm_renderer_read_image_t]] follow by an auxiliary `uint32_t` used to identify the read // request in the backend. TM_RENDERER_COMMAND_READ_IMAGE, // Command describing a buffer readback. `data` points to a [[tm_renderer_read_buffer_t]] follow // by an auxiliary `uint32_t` used to identify the read request in the backend. TM_RENDERER_COMMAND_READ_BUFFER, // Command descibing a ray tracing dispatch, `data` points to a [[tm_renderer_trace_call_t]]. TM_RENDERER_COMMAND_TRACE, }; ~~~
### `enum tm_renderer_map_flags`
~~~c enum tm_renderer_map_flags { // If `CPU_CACHED` flag is set, the memory returned from `map_create_` is guaranteed to go through the CPU cache hierarchy // typically this adds an overhead in the form of extra buffer copies or similar. Only use this flag if you need to // read from the returned memory in `data`. // // !!! note: Note: // Not specifying this flag does not guarantee that the returned pointer will be uncached or in write-combined memory, // but assume that it might be. TM_RENDERER_MAP_FLAGS_CPU_CACHED = 0x1 }; ~~~
### `enum tm_renderer_statistics_flags`
~~~c enum tm_renderer_statistics_flags { // Query GPU timings. Resulting timing values are automatically fed to the profiler. TM_RENDERER_GPU_TIMINGS = 0x1 }; ~~~
### `struct tm_renderer_commands_t`
Render command header, used for ordering commands in a render command buffer. ~~~c typedef struct tm_renderer_commands_t { // `sort_key` is used for ordering commands internally and across multiple [[tm_renderer_command_buffer_o]] // before becoming consumed by the backend. uint64_t *sort_keys; // Command type, one of [[enum tm_renderer_command]]. uint32_t *types; // Pointer to the command data. void **data; } tm_renderer_commands_t; ~~~
### `struct tm_renderer_command_buffer_api`
Interface for submitting commands to the rendering backend. Free-threaded, any number of these can be in-flight simultaneously #### `bind_render_pass()` ~~~c void (*bind_render_pass)(struct tm_renderer_command_buffer_o *inst, uint64_t sort_key, const struct tm_renderer_render_pass_bind_t *render_pass); ~~~ Binds color targets and depth stencil target for writing. #### `set_viewports()` ~~~c void (*set_viewports)(struct tm_renderer_command_buffer_o *inst, uint64_t sort_key, const struct tm_renderer_set_viewports_t *viewports); ~~~ Sets the specified viewports. The viewports will be active until the next `TM_RENDERER_COMMAND_SET_VIEWPORTS`- or `TM_RENDERER_COMMAND_BIND_RENDER_PASS` message is encountered. #### `set_scissor_rects()` ~~~c void (*set_scissor_rects)(struct tm_renderer_command_buffer_o *inst, uint64_t sort_key, const struct tm_renderer_set_scissor_rects_t *rects); ~~~ Sets the specified scissor rects. The scissor rects will be active until the next `TM_RENDERER_COMMAND_SET_SCISSOR_RECTS`- or `TM_RENDERER_COMMAND_BIND_RENDER_PASS` message is encountered. #### `draw_calls()` ~~~c void (*draw_calls)(struct tm_renderer_command_buffer_o *inst, const uint64_t *sort_keys, const struct tm_renderer_draw_call_info_t *draw_calls, const struct tm_renderer_shader_info_t *shaders, uint32_t num_draw_calls); ~~~ Issue draw calls #### `bind_queue()` ~~~c void (*bind_queue)(struct tm_renderer_command_buffer_o *inst, uint64_t sort_key, const struct tm_renderer_queue_bind_t *queue_bind); ~~~ Switch execution of compute dispatches, resource transitions and/or read operations to happen on another command queue. #### `begin_statistics_scope()` ~~~c uint64_t (*begin_statistics_scope)(struct tm_renderer_command_buffer_o *inst, uint64_t sort_key, const char *category, const char *name, uint32_t flags); ~~~ Begins a named statistics scope collecting data specified in `flags` and returns a unique ID identifying the scope. #### `end_statistics_scope()` ~~~c void (*end_statistics_scope)(struct tm_renderer_command_buffer_o *inst, uint64_t sort_key, uint64_t statistics_scope); ~~~ Ends a statistics scope. `statistics_scope` is the unique ID returned by `begin_statistics_scope()`. #### `compute_dispatches()` ~~~c void (*compute_dispatches)(struct tm_renderer_command_buffer_o *inst, const uint64_t *sort_keys, const struct tm_renderer_compute_info_t *compute_dispatches, const struct tm_renderer_shader_info_t *shaders, uint32_t num_compute_dispatches); ~~~ Dispatch compute work. #### `transition_resources()` ~~~c void (*transition_resources)(struct tm_renderer_command_buffer_o *inst, uint64_t sort_key, const struct tm_renderer_resource_barrier_t *barriers, uint32_t num_barriers); ~~~ Resource barrier. #### `copy_image()` ~~~c void (*copy_image)(struct tm_renderer_command_buffer_o *inst, uint64_t sort_key, const struct tm_renderer_copy_image_t *copy_image); ~~~ Copy image buffer. #### `copy_buffer()` ~~~c void (*copy_buffer)(struct tm_renderer_command_buffer_o *inst, uint64_t sort_key, const struct tm_renderer_copy_buffer_t *copy_buffer); ~~~ Copy buffer. #### `trace_dispatches()` ~~~c void (*trace_dispatches)(struct tm_renderer_command_buffer_o *inst, const uint64_t *sort_keys, const struct tm_renderer_trace_call_t *trace_calls, uint32_t num_trace_calls); ~~~ Dispatch ray tracing. #### `read_image()` ~~~c uint32_t (*read_image)(struct tm_renderer_command_buffer_o *inst, uint64_t sort_key, const struct tm_renderer_read_image_t *read_image); ~~~ Returns a handle to the readback that can be polled to see if the transfer has completed using `tm_renderer_backend_i->read_complete()`. !!! note: Note: Until the readback has completed the memory pointed to by `bits` in `tm_renderer_read_image_t` must not be freed. !!! note: TODO: Maybe expose an additional interface for peeking directly at the staging resource avoiding a redundant memcpy into bits? #### `read_buffer()` ~~~c uint32_t (*read_buffer)(struct tm_renderer_command_buffer_o *inst, uint64_t sort_key, const struct tm_renderer_read_buffer_t *read_buffer); ~~~ Returns a handle to the readback that can be polled to see if the transfer has completed using `tm_renderer_backend_i->read_complete()`. !!! note: Note: Until the readback has completed the memory pointed to by `bits` in `tm_renderer_read_buffer_t` must not be freed. !!! note: TODO: Maybe expose an additional interface for peeking directly at the staging resource avoiding a redundant memcpy into bits? !!! note: Note: Returned ID should never be 0. Render backends implementing GPU resource readbacks needs to respect that. #### `num_commands()` ~~~c uint32_t (*num_commands)(const struct tm_renderer_command_buffer_o *inst); ~~~ Returns number of commands in buffer. #### `commands()` ~~~c tm_renderer_commands_t (*commands)(const struct tm_renderer_command_buffer_o *inst); ~~~ Returns structure-of-arrays header to first command in buffer. Use 'num_commands()' to query number of commands in arrays. #### `user_data()` ~~~c void *(*user_data)(struct tm_renderer_command_buffer_o *inst); ~~~ Returns a `void*` to a user data memory block that can be used for backends to associate various data with the command buffer. Size of the `user_data` blob is specified when creating the command buffer pool. #### `set_backend_allocator()` ~~~c void (*set_backend_allocator)(struct tm_renderer_command_buffer_o *inst, struct tm_renderer_device_memory_allocator_i *memory_allocator); ~~~ Associate backend allocator with this buffer. #### `append_buffers()` ~~~c void (*append_buffers)(struct tm_renderer_command_buffer_o *inst, struct tm_renderer_command_buffer_o **buffers, uint32_t num_buffers); ~~~ Append the contents of `buffers` to `inst`. Ownership of the block allocated contents of `buffers` will be moved to `inst`. `buffers` will be marked as empty when the function returns.
### `struct tm_renderer_command_buffer_pool_api`
Interface for efficient management of `tm_renderer_command_buffer_o`. #### `create()` ~~~c struct tm_renderer_command_buffer_o *(*create)(struct tm_renderer_command_buffer_pool_o *inst); ~~~ #### `destroy()` ~~~c void (*destroy)(struct tm_renderer_command_buffer_pool_o *inst, struct tm_renderer_command_buffer_o *buffer); ~~~ #### `user_data_size()` ~~~c uint64_t (*user_data_size)(struct tm_renderer_command_buffer_pool_o *inst); ~~~
### `tm_renderer_create_command_buffer_pool()`
~~~c struct tm_renderer_command_buffer_pool_o *tm_renderer_create_command_buffer_pool(struct tm_renderer_memory_block_pool_o *backing_memory_block_pool, uint64_t user_data_size, struct tm_allocator_i *allocator, uint32_t memory_tracker_scope); ~~~
### `tm_renderer_destroy_command_buffer_pool()`
~~~c void tm_renderer_destroy_command_buffer_pool(struct tm_renderer_command_buffer_pool_o *pool, struct tm_allocator_i *allocator, uint32_t memory_tracker_scope); ~~~
### `struct tm_renderer_command_buffer_sort_api`
API for sorting commands in one or many `tm_renderer_command_buffer_o`. This API is used by the render backends when implementing `tm_renderer_backend_i->submit_command_buffers()`. #### `sort_memory_needed()` ~~~c uint64_t (*sort_memory_needed)(const struct tm_renderer_command_buffer_o **buffers, uint32_t num_buffers); ~~~ Returns total number of bytes needed to run `sort_commands`. #### `sort_commands()` ~~~c void (*sort_commands)(const struct tm_renderer_command_buffer_o **buffers, uint32_t num_buffers, void *sort_memory, tm_renderer_commands_t **sorted_output, uint32_t *num_commands); ~~~ Sorts commands according to their `sort_key` in one or many command buffers. `sort_memory` should point to a block of memory that is at least the size returned from `sort_memory_needed()`. The sorted result is returned in `sorted_output`, memory to back the result comes from `sort_memory`.
### `enum tm_renderer_resource`
~~~c enum tm_renderer_resource { TM_RENDERER_RESOURCE_CREATE_BUFFER, TM_RENDERER_RESOURCE_MAP_CREATE_BUFFER, TM_RENDERER_RESOURCE_RESIZE_BUFFER, TM_RENDERER_RESOURCE_UPDATE_BUFFER, TM_RENDERER_RESOURCE_CREATE_IMAGE, TM_RENDERER_RESOURCE_MAP_CREATE_IMAGE, TM_RENDERER_RESOURCE_UPDATE_IMAGE, TM_RENDERER_RESOURCE_CREATE_IMAGE_VIEWS, TM_RENDERER_RESOURCE_CREATE_SHADER, TM_RENDERER_RESOURCE_CREATE_SHADER_STATE_OVERRIDE, TM_RENDERER_RESOURCE_CREATE_SAMPLER, TM_RENDERER_RESOURCE_CREATE_QUEUE_FENCE, TM_RENDERER_RESOURCE_CREATE_RESOURCE_BINDER, TM_RENDERER_RESOURCE_CREATE_RAY_TRACING_PIPELINE, TM_RENDERER_RESOURCE_CREATE_SHADER_BINDING_TABLE, TM_RENDERER_RESOURCE_CREATE_TOP_LEVEL_ACCELERATION_STRUCTURE, TM_RENDERER_RESOURCE_CREATE_BOTTOM_LEVEL_ACCELERATION_STRUCTURE, TM_RENDERER_RESOURCE_SET_RESOURCE, TM_RENDERER_RESOURCE_SET_ARRAY_RESOURCES, TM_RENDERER_RESOURCE_DESTROY, TM_RENDERER_RESOURCE_NUM_COMMAND_TYPES }; ~~~
### `struct tm_renderer_resource_commands_t`
Render resource command header. ~~~c typedef struct tm_renderer_resource_commands_t { // Command type, one of [[enum tm_renderer_resource]]. uint32_t *types; // Handle to resource affected by command. tm_renderer_handle_t *handles; // Pointer to optional command data. void **data; } tm_renderer_resource_commands_t; ~~~
### `struct tm_renderer_resource_command_buffer_api`
Interface for allocating and deallocating render resources, free-threaded. #### `create_buffer()` ~~~c tm_renderer_handle_t (*create_buffer)(struct tm_renderer_resource_command_buffer_o *inst, const struct tm_renderer_buffer_desc_t *buffer, uint32_t device_affinity_mask); ~~~ Creates a buffer described by `tm_renderer_buffer_desc_t` and returns a handle to it. #### `map_create_buffer()` ~~~c tm_renderer_handle_t (*map_create_buffer)(struct tm_renderer_resource_command_buffer_o *inst, const struct tm_renderer_buffer_desc_t *buffer, uint32_t device_affinity_mask, uint32_t map_flags, void **data); ~~~ Creates a buffer described by `tm_renderer_buffer_desc_t` and returns a handle to it, the buffer is also mapped into CPU visible memory and a pointer to that memory is returned in data. #### `resize_buffer()` ~~~c void (*resize_buffer)(struct tm_renderer_resource_command_buffer_o *inst, tm_renderer_handle_t *handle, uint64_t size); ~~~ Resizes an existing `tm_renderer_buffer_desc_t`. The user is responsible for refilling the buffer with new contents using `update_buffer` after resizing. The buffer must have been created with `usage_flag` `TM_RENDERER_BUFFER_USAGE_UPDATABLE` specified. !!! note: Note: `handle` is passed as a pointer since the bindless handles in `tm_renderer_handle_t` will mutate when resizing, the `resource` handle in `tm_renderer_handle_t` remains consistent. The render backend guarantees that the old buffer and bindless handles will be readable for at least the current frame + 1. This is important in situations where multiple jobs writes into the same shared buffer and one job detects that the shared buffer needs to grow. #### `update_buffer()` ~~~c void (*update_buffer)(struct tm_renderer_resource_command_buffer_o *inst, tm_renderer_handle_t handle, uint64_t offset, uint64_t size, uint32_t device_affinity_mask, uint32_t map_flags, void **data); ~~~ Updates an existing `tm_renderer_buffer_desc_t` with new `data`. The user is responsible for staying within the buffer size. The buffer must have been created with `usage_flag` `TM_RENDERER_BUFFER_USAGE_UPDATABLE` specified. #### `create_image()` ~~~c tm_renderer_handle_t (*create_image)(struct tm_renderer_resource_command_buffer_o *inst, const struct tm_renderer_image_desc_t *image, uint32_t device_affinity_mask); ~~~ Creates an imaged described by `tm_renderer_image_desc_t` and returns a handle to it. #### `map_create_image()` ~~~c tm_renderer_handle_t (*map_create_image)(struct tm_renderer_resource_command_buffer_o *inst, const struct tm_renderer_image_desc_t *image, uint32_t device_affinity_mask, uint32_t map_flags, void **data); ~~~ Creates an image described by `tm_renderer_image_desc_t` and returns a handle to it, the buffer is also mapped into CPU visible memory and a pointer to that memory is returned in data. #### `update_image()` ~~~c void (*update_image)(struct tm_renderer_resource_command_buffer_o *inst, tm_renderer_handle_t handle, uint16_t resource_state, uint32_t format, const struct tm_renderer_image_subresource_layers_t *subresource, const struct tm_renderer_image_offset_t *offset, const struct tm_renderer_image_extent_t *extent, uint32_t device_affinity_mask, uint32_t map_flags, void **data); ~~~ Update image with new content, the buffer is mapped into CPU visible memory and a pointer to the memory is returned in `data`. #### `create_image_views()` ~~~c tm_renderer_handle_t (*create_image_views)(struct tm_renderer_resource_command_buffer_o *inst, tm_renderer_handle_t image, const struct tm_renderer_image_desc_t *desc, uint32_t device_affinity_mask, const struct tm_renderer_image_view_t *views, uint32_t num_views); ~~~ Creates on or many image views for `image` with image description `desc`. #### `create_shader()` ~~~c tm_renderer_handle_t (*create_shader)(struct tm_renderer_resource_command_buffer_o *inst, const struct tm_renderer_shader_t *shader, uint32_t device_affinity_mask); ~~~ Creates a shader described by `tm_renderer_shader_t` and returns a handle to it. #### `create_sampler()` ~~~c tm_renderer_handle_t (*create_sampler)(struct tm_renderer_resource_command_buffer_o *inst, const struct tm_renderer_sampler_t *sampler, uint32_t device_affinity_mask); ~~~ Creates a sampler described by `tm_renderer_sampler_t` and returns a handle to it. #### `create_shader_state_override()` ~~~c tm_renderer_handle_t (*create_shader_state_override)(struct tm_renderer_resource_command_buffer_o *inst, const struct tm_renderer_shader_state_override_t *state_override, uint32_t device_affinity_mask); ~~~ Creates a shader state override resource for the specified `shader`. #### `create_queue_fence()` ~~~c tm_renderer_handle_t (*create_queue_fence)(struct tm_renderer_resource_command_buffer_o *inst, uint32_t device_affinity_mask); ~~~ Creates a queue fence using for synchronizing between command queues. #### `create_resource_binder()` ~~~c tm_renderer_handle_t (*create_resource_binder)(struct tm_renderer_resource_command_buffer_o *inst, const struct tm_renderer_resource_bind_point_t *bind_points, uint32_t num_bind_points, uint32_t device_affinity_mask); ~~~ Creates a resource binder object (describing how resources are bound to a shader) described by n-number of `tm_renderer_resource_bind_point_t` and returns a handle to it. #### `create_ray_tracing_pipeline()` ~~~c tm_renderer_handle_t (*create_ray_tracing_pipeline)(struct tm_renderer_resource_command_buffer_o *inst, const struct tm_renderer_ray_tracing_pipeline_desc_t *pipeline, uint32_t device_affinity_mask); ~~~ Creates a ray tracing pipeline described by `tm_renderer_ray_tracing_pipeline_desc_t` and returns a handle to it. #### `create_shader_binding_table()` ~~~c tm_renderer_handle_t (*create_shader_binding_table)(struct tm_renderer_resource_command_buffer_o *inst, const struct tm_renderer_shader_binding_table_desc_t *shader_binding_table, uint32_t device_affinity_mask); ~~~ Creates a shader binding table from the specified shader groups in the order that they were supplied for the specified ray tracing pipeline. All shaders passed to this function must have been passed at the creation of the ray tracing pipeline. A shader binding table is a buffer and its handle can be used just like any other buffer. #### `create_top_level_acceleration_structure()` ~~~c tm_renderer_handle_t (*create_top_level_acceleration_structure)(struct tm_renderer_resource_command_buffer_o *inst, const struct tm_renderer_top_level_acceleration_structure_desc_t *acceleration_structure, uint32_t device_affinity_mask); ~~~ Creates a top-level acceleration structure described by `tm_renderer_top_level_acceleration_structure_desc_t` and returns a handle to it. #### `create_bottom_level_acceleration_structure()` ~~~c tm_renderer_handle_t (*create_bottom_level_acceleration_structure)(struct tm_renderer_resource_command_buffer_o *inst, const struct tm_renderer_bottom_level_acceleration_structure_desc_t *acceleration_structure, uint32_t device_affinity_mask); ~~~ Creates a bottom-level acceleration structure described by `tm_renderer_bottom_level_acceleration_structure_desc_t` and returns a handle to it. #### `set_resource()` ~~~c void (*set_resource)(struct tm_renderer_resource_command_buffer_o *inst, tm_renderer_handle_t resource_binder, uint32_t bind_point, tm_renderer_handle_t resource_handles, uint32_t reosource_aspect_flags); ~~~ Changes the resource pointed to by `bind_point` in the `resource_binder` to point to `resource_handle`. #### `set_array_resources()` ~~~c void (*set_array_resources)(struct tm_renderer_resource_command_buffer_o *inst, tm_renderer_handle_t resource_binder, uint32_t bind_point, uint32_t first_element, const tm_renderer_handle_t *resource_handles, const uint32_t *resource_aspect_flags, const uint32_t n_handles); ~~~ Changes a range of resources in an array pointed to by `bind_point` in the `resource_binder` to `resource_handles` (with the optional resource_aspect_flags). `first_element` is offset into destination array and `n_handles` is the number of handles to write. #### `destroy_resource()` ~~~c void (*destroy_resource)(struct tm_renderer_resource_command_buffer_o *inst, tm_renderer_handle_t handle); ~~~ Destroys a resource. !!! note: Note: This only queues a destroy package on the command stream, backing memory and resource handles won't be freed until the `tm_renderer_resource_command_buffer_o` has been fully consumed by the backend. #### `num_commands()` ~~~c uint32_t (*num_commands)(struct tm_renderer_resource_command_buffer_o *inst, uint32_t count_per_command_type[TM_RENDERER_RESOURCE_NUM_COMMAND_TYPES]); ~~~ Returns total number of commands in buffer, if `count_per_command_type` isn't 0 it will contain statistics with number of commands per command type (`enum tm_renderer_resource`). #### `commands()` ~~~c tm_renderer_resource_commands_t (*commands)(struct tm_renderer_resource_command_buffer_o *inst); ~~~ Returns structure-of-arrays header to first command in buffer. Use 'num_commands()' to query number of commands in arrays. #### `user_data()` ~~~c void *(*user_data)(struct tm_renderer_resource_command_buffer_o *inst); ~~~ Returns a `void*` to a user data memory block that can be used for backends to associate various data with the command buffer. Size of the `user_data` blob is specified when creating the command buffer pool. #### `set_backend_allocators()` ~~~c void (*set_backend_allocators)(struct tm_renderer_resource_command_buffer_o *inst, struct tm_renderer_backend_resource_allocator_i *resource_allocator, struct tm_renderer_device_memory_allocator_i *memory_allocator); ~~~ Associate backend allocators with this buffer. #### `append_buffers()` ~~~c void (*append_buffers)(struct tm_renderer_resource_command_buffer_o *inst, struct tm_renderer_resource_command_buffer_o **buffers, uint32_t num_buffers); ~~~ Append the contents of `buffers` to `inst`. Ownership of the block allocated contents of `buffers` will be moved to `inst`. `buffers` will be marked as empty when the function returns.
### `struct tm_renderer_resource_command_buffer_pool_api`
Interface for efficient management of `tm_renderer_resource_command_buffer_o`. #### `create()` ~~~c struct tm_renderer_resource_command_buffer_o *(*create)(struct tm_renderer_resource_command_buffer_pool_o *inst); ~~~ #### `destroy()` ~~~c void (*destroy)(struct tm_renderer_resource_command_buffer_pool_o *inst, struct tm_renderer_resource_command_buffer_o *buffer); ~~~ #### `user_data_size()` ~~~c uint64_t (*user_data_size)(struct tm_renderer_resource_command_buffer_pool_o *inst); ~~~