91 lines
2.2 KiB
C
91 lines
2.2 KiB
C
#ifndef __VHEX_DISPLAY_SHADER__
|
|
# define __VHEX_DISPLAY_SHADER__
|
|
|
|
#include <vhex/defs/attributes.h>
|
|
#include <vhex/defs/types.h>
|
|
|
|
/* dshader_call_arg_t: All types of arguments allowed in an indirect shader call
|
|
|
|
Because a function call cannot be easily pieced together, there are
|
|
restrictions on what arguments can be passed. The following union lists all
|
|
of the available types. Other types can be used if casted, mainly pointers;
|
|
see the description of DSHADER*() for details. */
|
|
typedef union dshader_call_arg {
|
|
int8_t i8;
|
|
uint8_t u8;
|
|
|
|
int16_t i16;
|
|
uint16_t u16;
|
|
|
|
/* 32-bit integers */
|
|
int i;
|
|
unsigned int u;
|
|
int32_t i32;
|
|
uint32_t u32;
|
|
/* 32-bit floating-point */
|
|
float f;
|
|
|
|
/* Pointers to most common types, in all possible const/volatile
|
|
qualifications */
|
|
#define POINTER(type, name) \
|
|
type *name; \
|
|
type const *name ## _c; \
|
|
type volatile *name ## _v; \
|
|
type volatile const *name ## _cv;
|
|
|
|
POINTER(void, pv)
|
|
POINTER(char, pc)
|
|
POINTER(unsigned char, puc)
|
|
POINTER(short, ps)
|
|
POINTER(unsigned short, pus)
|
|
POINTER(int, pi)
|
|
POINTER(unsigned int, pui)
|
|
POINTER(int8_t, pi8)
|
|
POINTER(uint8_t, pu8)
|
|
POINTER(int16_t, pi16)
|
|
POINTER(uint16_t, pu16)
|
|
POINTER(int32_t, pi32)
|
|
POINTER(uint32_t, pu32)
|
|
POINTER(int64_t, pi64)
|
|
POINTER(uint64_t, pu64)
|
|
POINTER(long long int, pll)
|
|
POINTER(unsigned long long int, pull)
|
|
POINTER(float, pf)
|
|
POINTER(double, pd)
|
|
|
|
#undef POINTER
|
|
} dshader_call_arg_t;
|
|
|
|
/* dshader_surface - Describe the surface */
|
|
struct dshader_surface {
|
|
void *draw;
|
|
void *frag;
|
|
size_t width;
|
|
size_t height;
|
|
unsigned int x;
|
|
unsigned int y;
|
|
};
|
|
|
|
/* dshader - display shader definition */
|
|
struct dshader_call {
|
|
int (*routine)(
|
|
struct dshader_surface *surface,
|
|
dshader_call_arg_t *draw_args,
|
|
dshader_call_arg_t *shader_args
|
|
);
|
|
dshader_call_arg_t args[8];
|
|
};
|
|
typedef struct dshader_call dshader_call_t;
|
|
typedef struct dshader_call dshader_t;
|
|
|
|
/* DSHADER_LIST - helper to create a list of shader "on-the-fly" */
|
|
#define DSHADER_LIST(shader_list) (dshader_call_t*)&{ shader_list }
|
|
|
|
/* DSHADER - helper to create a shader object */
|
|
#define DSHADER(fct, ...) (dshader_call_t){ \
|
|
.routine = fct, \
|
|
.args = { __VA_ARGS__ } \
|
|
}
|
|
|
|
#endif /* __VHEX_DISPLAY_SHADER__ */
|