aboutsummaryrefslogtreecommitdiffstats
path: root/WinQuake/pum_render.h
blob: 0d62c51ad4a41c1c46a84426d83a89503dd7fd03 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
Process-using-Memory (PuM) rendering pipeline for Quake

This file contains the host-side driver that offloads computationally
intensive, bit-parallel work of the software renderer to DRAM using
"Process-using-Memory" (PuM).  The actual DRAM control is performed by
DRAM Bender's SoftMC instruction engine running on an AMD Alveo U200
FPGA card, accessed over PCI Express via the XDMA device files.

The PuM pipeline is only compiled when RENDER_PUM is defined.  When the
switch is absent, all rendering is performed on the CPU exactly as in the
original WinQuake source.
*/

#ifndef PUM_RENDER_H
#define PUM_RENDER_H

#ifdef RENDER_PUM

// 8192 bytes per row
// 64 bit data bus (x8 devices, 8 chips)
// 64 bytes per column, 128 columns per row

#define PUM_ROW_BYTES       8192
#define PUM_TILE_BYTES      64 // one column access = one cache line
#define PUM_TILES_PER_ROW   (PUM_ROW_BYTES / PUM_TILE_BYTES)

// DRAM organisation of HMA81GU6AFR8N-UH
#define PUM_NUM_BANKS       16
#define PUM_NUM_ROWS        32768

typedef enum {
    PUM_OP_AND = 0,
    PUM_OP_OR,
    PUM_OP_XOR,
    PUM_OP_NOT
} pum_op_t;

// Init platform, prepare rows (C0, C1, T0 ... T3)
int  PUM_Init (void);

// Release platform, precharge all banks
void PUM_Shutdown (void);

// bitwise operations
// Transparent fallbacks included
void PUM_BitwiseAnd (const byte *a, const byte *b, byte *dst, int num_bytes);
void PUM_BitwiseOr  (const byte *a, const byte *b, byte *dst, int num_bytes);
void PUM_BitwiseXor (const byte *a, const byte *b, byte *dst, int num_bytes);
void PUM_BitwiseNot (const byte *a, byte *dst, int num_bytes);

// shading on 8.8 fp mask/select
// tiles of packed 32-bit pixels
void PUM_LightMaskAndTexel (byte *dst, const byte *src, const byte *mask,
                            int num_bytes);
void PUM_EdgeSpanInit (byte *dst, const byte *clear, int num_bytes);

// Whether PUM engine is active
int  PUM_Active (void);

#endif /* RENDER_PUM */

// stub functions
#ifndef RENDER_PUM
#define PUM_Init()             (0)
#define PUM_Shutdown()         do {} while (0)
#define PUM_Active()           (0)
#define PUM_BitwiseAnd(a,b,d,n)  do {} while (0)
#define PUM_BitwiseOr(a,b,d,n)   do {} while (0)
#define PUM_BitwiseXor(a,b,d,n)  do {} while (0)
#define PUM_BitwiseNot(a,d,n)    do {} while (0)
#define PUM_LightMaskAndTexel(a,b,c,n) do {} while (0)
#define PUM_EdgeSpanInit(a,b,n)       do {} while (0)
#endif

#endif /* PUM_RENDER_H */