vxKernel/include/vhex/display/stack.h

98 lines
2.3 KiB
C

#ifndef __VHEX_DISPLAY_STACK__
# define __VHEX_DISPLAY_STACK__
#include <vhex/display/shader.h>
#include <vhex/display/types.h>
/* dstack_call - dstack indirect call (same as dshader) */
struct dstack_call {
void (*routine)(
struct dshader_surface *surface,
uint32_t *draw_args
);
uint32_t args[12];
};
typedef struct dstack_call dstack_call_t;
/* dstack_action - dstack drawing action information */
struct dstack_action {
struct dstack_call call;
struct {
dshader_call_t *table;
int number;
int idx;
} shader;
void (*quit)(uint32_t *arg);
};
/* DSTACK_CALL - display indirect call */
#define DSTACK_CALL(fct, ...) (dstack_call_t){ \
.routine = fct, \
.args = { __VA_ARGS__ } \
}
/* dstack_config - dstack configuration structure */
struct dstack_config {
int default_icall_pool_slot;
int default_icall_args_nb;
int default_shader_per_action;
};
#ifndef DSTACK_DEFAULT_ICALL_SLOT
# define DSTACK_DEFAULT_ICALL_SLOT 32
#endif
#ifndef DSTACK_DEFAULT_ICALL_ARGS
# define DSTACK_DEFAULT_ICALL_ARGS 12
#endif
#ifndef DSTACK_DEFAULT_SHADER_PER_ACTION
# define DSTACK_DEFAULT_SHADER_PER_ACTION 4
#endif
/* dstack_drv_interface - driver interface */
struct dstack_drv_interface {
int (*frame_start)(struct dshader_surface *);
int (*frame_frag_next)(struct dshader_surface *);
int (*frame_frag_send)(struct dshader_surface *);
int (*frame_end)(struct dshader_surface *);
size_t display_width;
size_t display_height;
};
//---
// Display stack API
//---
/* dstack_init() : Initialise the draw stack (should not be involved) */
extern int dstack_init(struct dstack_config *config);
/* dstack_add_action() : add a new action in the draw stack */
extern did_t dstack_add_action(
dstack_call_t *call,
dshader_call_t *shaders,
void (*quit)(uint32_t *args)
);
/* dstack_get_action() : get display stack action using its ID */
extern struct dstack_action *dstack_get_action(did_t did);
/* dstack_render(): render a frame */
extern void dstack_render(void);
/* dstack_invalidate() : Invalidate the draw stack (reset) */
extern int dstack_invalidate(void);
/* dstack_display_width() : return the display width */
extern size_t dstack_display_width(void);
/* dstack_display_height() : return the display height */
extern size_t dstack_display_height(void);
/* dstack_quit() : Uninit the draw stack */
extern int dstack_quit(void);
#endif /* __VHEX_DISPLAY_STACK__ */