ogl_beamforming

Ultrasound Beamforming Implemented with OpenGL
git clone anongit@rnpnr.xyz:ogl_beamforming.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

base_types.h (3502B)


      1 #ifndef BASE_TYPES_H
      2 #define BASE_TYPES_H
      3 #include "base_compiler.h"
      4 
      5 #if COMPILER_MSVC
      6   typedef unsigned __int64  u64;
      7   typedef signed   __int64  i64;
      8   typedef unsigned __int32  u32;
      9   typedef signed   __int32  i32;
     10   typedef unsigned __int16  u16;
     11   typedef signed   __int16  i16;
     12   typedef unsigned __int8   u8;
     13   typedef signed   __int8   i8;
     14 #else
     15   typedef __UINT64_TYPE__   u64;
     16   typedef __INT64_TYPE__    i64;
     17   typedef __UINT32_TYPE__   u32;
     18   typedef __INT32_TYPE__    i32;
     19   typedef __UINT16_TYPE__   u16;
     20   typedef __INT16_TYPE__    i16;
     21   typedef __UINT8_TYPE__    u8;
     22   typedef __INT8_TYPE__     i8;
     23 #endif
     24 
     25 #define I8_MAX           (0x0000007FL)
     26 #define I32_MAX          (0x7FFFFFFFL)
     27 #define S32_MAX          (0x7FFFFFFFL)
     28 #define U8_MAX           (0x000000FFUL)
     29 #define U16_MAX          (0x0000FFFFUL)
     30 #define U32_MAX          (0xFFFFFFFFUL)
     31 #define U64_MAX          (0xFFFFFFFFFFFFFFFFULL)
     32 #define F32_EPSILON      (1e-6f)
     33 #ifndef PI
     34   #define PI             (3.14159265358979323846f)
     35 #endif
     36 
     37 typedef char     c8;
     38 typedef u8       b8;
     39 typedef u16      b16;
     40 typedef u32      b32;
     41 typedef u64      b64;
     42 typedef _Float16 f16;
     43 typedef float    f32;
     44 typedef double   f64;
     45 typedef i64      iptr;
     46 typedef u64      uptr;
     47 
     48 typedef struct { u64 start, stop; } RangeU64;
     49 
     50 typedef union {
     51 	struct { i32 x, y; };
     52 	struct { i32 w, h; };
     53 	i32 E[2];
     54 } iv2;
     55 
     56 typedef union {
     57 	struct { i32 x, y, z; };
     58 	struct { i32 w, h, d; };
     59 	iv2 xy;
     60 	i32 E[3];
     61 } iv3;
     62 
     63 typedef union {
     64 	struct { i32 x, y, z, w; };
     65 	struct { iv3 xyz; i32 _w; };
     66 	i32 E[4];
     67 } iv4;
     68 
     69 typedef union {
     70 	struct { u32 x, y; };
     71 	struct { u32 w, h; };
     72 	u32 E[2];
     73 } uv2;
     74 
     75 typedef union {
     76 	struct { u32 x, y, z; };
     77 	struct { u32 w, h, d; };
     78 	uv2 xy;
     79 	u32 E[3];
     80 } uv3;
     81 
     82 typedef union {
     83 	struct { u32 x, y, z, w; };
     84 	struct { uv3 xyz; u32 _w; };
     85 	u32 E[4];
     86 } uv4;
     87 
     88 typedef union {
     89 	struct { b32 x, y, z; };
     90 	b32 E[3];
     91 } bv3;
     92 
     93 typedef union {
     94 	struct { f32 x, y; };
     95 	struct { f32 w, h; };
     96 	f32 E[2];
     97 } v2;
     98 #define V2_INFINITY (v2){{-inf32(), inf32()}}
     99 
    100 typedef union {
    101 	struct { f32 x,  y, z;   };
    102 	struct { f32 w,  h, d;   };
    103 	struct { v2  xy; f32 _1; };
    104 	struct { f32 _2; v2 yz;  };
    105 	f32 E[3];
    106 } v3;
    107 
    108 typedef union {
    109 	struct { f32 x, y, z, w; };
    110 	struct { f32 r, g, b, a; };
    111 	struct { v3 xyz; f32 _1; };
    112 	struct { f32 _2; v3 yzw; };
    113 	struct { v2 xy, zw; };
    114 	f32 E[4];
    115 } v4;
    116 
    117 typedef union {
    118 	struct { v4 x, y, z, w; };
    119 	v4  c[4];
    120 	f32 E[16];
    121 } m4;
    122 
    123 typedef enum {
    124 	ArenaFlag_NoChain = 1 << 0,
    125 
    126 	ArenaFlag_CreationMask = ArenaFlag_NoChain,
    127 
    128 	ArenaFlag_Sealed  = 1 << 31,
    129 } ArenaFlags;
    130 
    131 typedef struct {
    132 	u64        reserve_size;
    133 	u64        commit_size;
    134 	ArenaFlags flags;
    135 
    136 	void *optional_backing_store;
    137 
    138 	char *name;
    139 	char *allocation_site_file;
    140 	i32   allocation_site_line;
    141 } ArenaParameters;
    142 
    143 typedef struct Arena Arena;
    144 struct Arena {
    145 	u64    position;
    146 	u64    committed;
    147 	u64    reserved;
    148 
    149 	// NOTE(rnp): arena chain
    150 	u64    base_position; // position relative to first arena in chain
    151 	Arena *prev;
    152 	Arena *current;
    153 
    154 	u64        reserve_size;
    155 	u64        commit_size;
    156 	ArenaFlags flags;
    157 
    158 	char *name;
    159 	char *allocation_site_file;
    160 	i32   allocation_site_line;
    161 };
    162 typedef struct { Arena *arena; u64 position; } Temp;
    163 
    164 typedef struct { i64 length; u8 *data; } str8;
    165 #define str8(s)        (str8){.length = countof(s) - 1, .data = (u8 *)s}
    166 #define str8_comp(s)         {sizeof(s) - 1, (u8 *)s}
    167 #define str8_struct(v) (str8){.length = sizeof(*v), .data = (u8 *)v}
    168 
    169 typedef struct { i64 length; u16 *data; } str16;
    170 
    171 #endif /* BASE_TYPES_H */