#ifndef PSX_GPU_H
#define PSX_GPU_H
+#define MAX_SPANS 512
+#define MAX_BLOCKS 64
+#define MAX_BLOCKS_PER_ROW 128
+
+#define SPAN_DATA_BLOCKS_SIZE 32
+
+#ifndef __ASSEMBLER__
+
+#include "vector_types.h"
+
typedef enum
{
PRIMITIVE_TYPE_TRIANGLE = 0,
u16 y;
} edge_data_struct;
-// 64 bytes total
+// 64 (72) bytes total
typedef struct
{
// 16 bytes
vec_8x16u pixels;
};
- // 8 bytes
+ // 8 (16) bytes
u32 draw_mask_bits;
u16 *fb_ptr;
vec_8x16u dither_offsets;
} block_struct;
-#define MAX_SPANS 512
-#define MAX_BLOCKS 64
-#define MAX_BLOCKS_PER_ROW 128
-
-#define SPAN_DATA_BLOCKS_SIZE 32
-
typedef struct render_block_handler_struct render_block_handler_struct;
typedef struct
u32 triangle_color;
u32 dither_table[4];
- u32 uvrgb_phase;
-
struct render_block_handler_struct *render_block_handler;
void *texture_page_ptr;
void *texture_page_base;
u16 *vram_ptr;
u16 *vram_out_ptr;
+ u32 uvrgb_phase;
+
u16 render_state_base;
u16 render_state;
u32 *reciprocal_table_ptr;
// enhancement stuff
- u16 *enhancement_buf_ptr;
- u16 *enhancement_current_buf_ptr;
- u32 enhancement_x_threshold;
+ u16 *enhancement_buf_ptr; // main alloc
+ u16 *enhancement_current_buf_ptr; // offset into above, 4 bufs
+ u32 saved_hres;
s16 saved_viewport_start_x;
s16 saved_viewport_start_y;
s16 saved_viewport_end_x;
s16 saved_viewport_end_y;
- u8 enhancement_buf_by_x16[64];
+ struct psx_gpu_scanout {
+ u16 x, y, w, h;
+ } enhancement_scanouts[4]; // 0-3 specifying which buf to use
+ u16 enhancement_scanout_eselect; // eviction selector
+ u16 enhancement_current_buf;
// Align up to 64 byte boundary to keep the upcoming buffers cache line
// aligned, also make reachable with single immediate addition
- u8 reserved_a[160];
+ u8 reserved_a[188 + 9*4 - 9*sizeof(void *)];
// 8KB
block_struct blocks[MAX_BLOCKS_PER_ROW];
s16 x;
s16 y;
+
+ u32 padding;
} vertex_struct;
void render_block_fill(psx_gpu_struct *psx_gpu, u32 color, u32 x, u32 y,
u32 texture_region_mask(s32 x1, s32 y1, s32 x2, s32 y2);
+void update_texture_8bpp_cache(psx_gpu_struct *psx_gpu);
void flush_render_block_buffer(psx_gpu_struct *psx_gpu);
void initialize_psx_gpu(psx_gpu_struct *psx_gpu, u16 *vram);
-u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_command);
+u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size,
+ s32 *cpu_cycles, u32 *last_command);
void triangle_benchmark(psx_gpu_struct *psx_gpu);
-#endif
+void compute_all_gradients(psx_gpu_struct * __restrict__ psx_gpu,
+ const vertex_struct * __restrict__ a, const vertex_struct * __restrict__ b,
+ const vertex_struct * __restrict__ c);
+#endif // __ASSEMBLER__
+#endif // PSX_GPU_H