# render_context.h ## Index
`tm_render_context_o`
`enum tm_render_context_buffer_phase`

`struct tm_render_context_api`
`create()`
`destroy()`
`append_resource_buffers()`
`append_command_buffers()`
`resource_buffers()`
`command_buffers()`

`tm_render_context_api_version`
`struct tm_render_args_t`
## API
### `tm_render_context_o`
~~~c typedef struct tm_render_context_o tm_render_context_o; ~~~
### `enum tm_render_context_buffer_phase`
~~~c typedef enum tm_render_context_buffer_phase { // Default buffer phase, use this for all resource and command buffers scheduled to run under the main render graph TM_RENDER_CONTEXT_BUFFER_PHASE_VIEWER = 0, // Buffer phase to support destruction of temporary resources that should be destroyed after any work scheduled in [[TM_RENDER_CONTEXT_BUFFER_PHASE_VIEWER]] // is done. TM_RENDER_CONTEXT_BUFFER_PHASE_VIEWER_DESTROY, // The utility buffer phase is scheduled to run before the viewer category and can be used to schedule work affecting // shared resources used in more than one viewport. TM_RENDER_CONTEXT_BUFFER_PHASE_UTILITY, // Buffer phase to support destruction of temporary resources that should be destroyed after any work scheduled in [[TM_RENDER_CONTEXT_BUFFER_PHASE_UTILITY]] // is done. TM_RENDER_CONTEXT_BUFFER_PHASE_UTILITY_DESTROY, // Maximum number of categories. TM_RENDER_CONTEXT_BUFFER_PHASE_MAX_PHASES } tm_render_context_buffer_phase; ~~~
### `struct tm_render_context_api`
#### `create()` ~~~c struct tm_render_context_o *(*create)(struct tm_allocator_i *allocator); ~~~ Creates new render context object #### `destroy()` ~~~c void (*destroy)(struct tm_render_context_o *context); ~~~ Destroys render context object #### `append_resource_buffers()` ~~~c void (*append_resource_buffers)(tm_render_context_o *context, tm_render_context_buffer_phase phase, struct tm_renderer_resource_command_buffer_o **res_buffers, uint32_t num_buffers); ~~~ Appends `num_buffers` number of resource buffers to the context. Threading: Internally synchornized #### `append_command_buffers()` ~~~c void (*append_command_buffers)(tm_render_context_o *context, tm_render_context_buffer_phase phase, struct tm_renderer_command_buffer_o **cmd_buffers, uint32_t num_buffers); ~~~ Appends 'num_buffers' number of command buffers to the context. Threading: Internally synchronized #### `resource_buffers()` ~~~c uint32_t (*resource_buffers)(tm_render_context_o *context, tm_render_context_buffer_phase phase, struct tm_renderer_resource_command_buffer_o **res_buffers); ~~~ Retrieves all resource buffers in context and returns them in 'res_buffers'. Set `res_buffers` to null to figure out the lenght of this array. Returns number of resource buffers in context. Threading: Internally synchronized #### `command_buffers()` ~~~c uint32_t (*command_buffers)(tm_render_context_o *context, tm_render_context_buffer_phase phase, struct tm_renderer_command_buffer_o **cmd_buffers); ~~~ Retrieves all command buffers in context and returns them in 'cmd_buffers'. Set `cmd_buffers` to null to figure out the lenght of this array. Returns number of command buffers in context. Threading: Internally synchronized
### `tm_render_context_api_version`
~~~c #define tm_render_context_api_version TM_VERSION(1, 0, 0) ~~~
### `struct tm_render_args_t`
~~~c typedef struct tm_render_args_t { // Main viewer camera transform. tm_transform_t camera_tm; // Main viewer camera. const struct tm_camera_t *camera; // Container object for collecting resource buffers and command buffers created by subsystems during the frame. // Use [[tm_render_context_api]] to append new buffers. tm_render_context_o *context; // Pointer to active render backend. struct tm_renderer_backend_i *render_backend; // Pointer to active shader repository. struct tm_shader_repository_o *shader_repository; // Application requested device affinity mask to use when rendering uint32_t device_affinity_mask; TM_PAD(4); // Default resource command buffer. struct tm_renderer_resource_command_buffer_o *default_resource_buffer; // Default command buffer. struct tm_renderer_command_buffer_o *default_command_buffer; // Active render graph. struct tm_render_graph_o *render_graph; // Active render pipeline interface. struct tm_render_pipeline_i *render_pipeline; // Active shader context. const struct tm_shader_system_context_o *shader_context; } tm_render_args_t ~~~