Kohi Game Engine
|
#include "defines.h"
Go to the source code of this file.
Data Structures | |
struct | job_info |
Describes a job to be run. More... | |
struct | job_system_config |
Typedefs | |
typedef b8(* | pfn_job_start) (void *, void *) |
A function pointer definition for jobs. More... | |
typedef void(* | pfn_job_on_complete) (void *) |
A function pointer definition for completion of a job. More... | |
typedef enum job_type | job_type |
Describes a type of job. More... | |
typedef enum job_priority | job_priority |
Determines which job queue a job uses. The high-priority queue is always exhausted first before processing the normal-priority queue, which must also be exhausted before processing the low-priority queue. More... | |
typedef struct job_info | job_info |
Describes a job to be run. More... | |
typedef struct job_system_config | job_system_config |
Enumerations | |
enum | job_type { JOB_TYPE_GENERAL = 0x02 , JOB_TYPE_RESOURCE_LOAD = 0x04 , JOB_TYPE_GPU_RESOURCE = 0x08 } |
Describes a type of job. More... | |
enum | job_priority { JOB_PRIORITY_LOW , JOB_PRIORITY_NORMAL , JOB_PRIORITY_HIGH } |
Determines which job queue a job uses. The high-priority queue is always exhausted first before processing the normal-priority queue, which must also be exhausted before processing the low-priority queue. More... | |
Functions | |
b8 | job_system_initialize (u64 *job_system_memory_requirement, void *state, void *config) |
Initializes the job system. Call once to retrieve job_system_memory_requirement, passing 0 to state. Then call a second time with allocated state memory block. More... | |
void | job_system_shutdown (void *state) |
Shuts the job system down. More... | |
b8 | job_system_update (void *state, struct frame_data *p_frame_data) |
Updates the job system. Should happen once an update cycle. More... | |
KAPI void | job_system_submit (job_info info) |
Submits the provided job to be queued for execution. More... | |
KAPI job_info | job_create (pfn_job_start entry_point, pfn_job_on_complete on_success, pfn_job_on_complete on_fail, void *param_data, u32 param_data_size, u32 result_data_size) |
Creates a new job with default type (Generic) and priority (Normal). More... | |
KAPI job_info | job_create_type (pfn_job_start entry_point, pfn_job_on_complete on_success, pfn_job_on_complete on_fail, void *param_data, u32 param_data_size, u32 result_data_size, job_type type) |
Creates a new job with default priority (Normal). More... | |
KAPI job_info | job_create_priority (pfn_job_start entry_point, pfn_job_on_complete on_success, pfn_job_on_complete on_fail, void *param_data, u32 param_data_size, u32 result_data_size, job_type type, job_priority priority) |
Creates a new job with the provided priority. More... | |
KAPI job_info | job_create_with_dependencies (pfn_job_start entry_point, pfn_job_on_complete on_success, pfn_job_on_complete on_fail, void *param_data, u32 param_data_size, u32 result_data_size, job_type type, job_priority priority, u8 dependency_count, u16 *dependencies) |
Creates a new job with the provided type, priority, and dependencies. More... | |
KAPI b8 | job_system_query_job_complete (u16 job_id) |
Returns whether or not the job with the given identifier has completed. More... | |
typedef enum job_priority job_priority |
Determines which job queue a job uses. The high-priority queue is always exhausted first before processing the normal-priority queue, which must also be exhausted before processing the low-priority queue.
typedef struct job_system_config job_system_config |
typedef void(* pfn_job_on_complete) (void *) |
A function pointer definition for completion of a job.
typedef b8(* pfn_job_start) (void *, void *) |
A function pointer definition for jobs.
enum job_priority |
Determines which job queue a job uses. The high-priority queue is always exhausted first before processing the normal-priority queue, which must also be exhausted before processing the low-priority queue.
enum job_type |
Describes a type of job.
KAPI job_info job_create | ( | pfn_job_start | entry_point, |
pfn_job_on_complete | on_success, | ||
pfn_job_on_complete | on_fail, | ||
void * | param_data, | ||
u32 | param_data_size, | ||
u32 | result_data_size | ||
) |
Creates a new job with default type (Generic) and priority (Normal).
entry_point | A pointer to a function to be invoked when the job starts. Required. |
on_success | A pointer to a function to be invoked when the job completes successfully. Optional. |
on_fail | A pointer to a function to be invoked when the job fails. Optional. |
param_data | Data to be passed to the entry point upon execution. |
param_data_size | The data to be passed on to entry_point callback. Pass 0 if not used. |
result_data_size | The size of result data to be passed on to success callback. Pass 0 if not used. |
KAPI job_info job_create_priority | ( | pfn_job_start | entry_point, |
pfn_job_on_complete | on_success, | ||
pfn_job_on_complete | on_fail, | ||
void * | param_data, | ||
u32 | param_data_size, | ||
u32 | result_data_size, | ||
job_type | type, | ||
job_priority | priority | ||
) |
Creates a new job with the provided priority.
entry_point | A pointer to a function to be invoked when the job starts. Required. |
on_success | A pointer to a function to be invoked when the job completes successfully. Optional. |
on_fail | A pointer to a function to be invoked when the job fails. Optional. |
param_data | Data to be passed to the entry point upon execution. |
param_data_size | The data to be passed on to entry_point callback. Pass 0 if not used. |
result_data_size | The size of result data to be passed on to success callback. Pass 0 if not used. |
type | The type of job. Used to determine which thread the job executes on. |
priority | The priority of this job. Higher priority jobs obviously run sooner. |
KAPI job_info job_create_type | ( | pfn_job_start | entry_point, |
pfn_job_on_complete | on_success, | ||
pfn_job_on_complete | on_fail, | ||
void * | param_data, | ||
u32 | param_data_size, | ||
u32 | result_data_size, | ||
job_type | type | ||
) |
Creates a new job with default priority (Normal).
entry_point | A pointer to a function to be invoked when the job starts. Required. |
on_success | A pointer to a function to be invoked when the job completes successfully. Optional. |
on_fail | A pointer to a function to be invoked when the job fails. Optional. |
param_data | Data to be passed to the entry point upon execution. |
param_data_size | The data to be passed on to entry_point callback. Pass 0 if not used. |
result_data_size | The size of result data to be passed on to success callback. Pass 0 if not used. |
type | The type of job. Used to determine which thread the job executes on. |
KAPI job_info job_create_with_dependencies | ( | pfn_job_start | entry_point, |
pfn_job_on_complete | on_success, | ||
pfn_job_on_complete | on_fail, | ||
void * | param_data, | ||
u32 | param_data_size, | ||
u32 | result_data_size, | ||
job_type | type, | ||
job_priority | priority, | ||
u8 | dependency_count, | ||
u16 * | dependencies | ||
) |
Creates a new job with the provided type, priority, and dependencies.
entry_point | A pointer to a function to be invoked when the job starts. Required. |
on_success | A pointer to a function to be invoked when the job completes successfully. Optional. |
on_fail | A pointer to a function to be invoked when the job fails. Optional. |
param_data | Data to be passed to the entry point upon execution. |
param_data_size | The data to be passed on to entry_point callback. Pass 0 if not used. |
result_data_size | The size of result data to be passed on to success callback. Pass 0 if not used. |
type | The type of job. Used to determine which thread the job executes on. |
priority | The priority of this job. Higher priority jobs obviously run sooner. |
dependency_count | The number of job identifiers which must be complete before this job runs. |
dependencies | An array of job identifiers which must be complete before this job runs. |
Initializes the job system. Call once to retrieve job_system_memory_requirement, passing 0 to state. Then call a second time with allocated state memory block.
job_system_memory_requirement | A pointer to hold the memory required for the job system state in bytes. |
state | A block of memory to hold the state of the job system. |
config | A pointer to the configuration (job_system_config) of this system. |
Returns whether or not the job with the given identifier has completed.
void job_system_shutdown | ( | void * | state | ) |
Shuts the job system down.
Submits the provided job to be queued for execution.
info | The description of the job to be executed. |
b8 job_system_update | ( | void * | state, |
struct frame_data * | p_frame_data | ||
) |
Updates the job system. Should happen once an update cycle.