-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathr_phase4.c
More file actions
96 lines (79 loc) · 2.12 KB
/
r_phase4.c
File metadata and controls
96 lines (79 loc) · 2.12 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
CALICO
Renderer phase 4 - Late prep
*/
#include "doomdef.h"
#include "r_local.h"
#include "mars.h"
boolean R_LatePrep(void) ATTR_DATA_CACHE_ALIGN;
//
// Check if texture is loaded; return if so, flag for cache if not
//
#ifndef MARS
static void R_FinishWall(viswall_t* wc) ATTR_DATA_CACHE_ALIGN;
static boolean cacheneeded;
static void *R_CheckPixels(int lumpnum)
{
void *lumpdata = lumpcache[lumpnum];
if(lumpdata)
{
// touch this graphic resource with the current frame number so that it
// will not be immediately purged again during the same frame
memblock_t *memblock = (memblock_t *)((byte *)lumpdata - sizeof(memblock_t));
memblock->lockframe = framecount;
}
else
cacheneeded = true; // phase 5 will need to be executed to cache graphics
return lumpdata;
}
//
// Late prep for viswalls
//
static void R_FinishWall(viswall_t* wc)
{
unsigned int fw_actionbits = wc->actionbits;
texture_t* fw_texture;
// has top or middle texture?
if (fw_actionbits & AC_TOPTEXTURE)
{
fw_texture = &textures[wc->t_texturenum];
if (fw_texture->data == NULL)
fw_texture->data = R_CheckPixels(fw_texture->lumpnum);
}
// has bottom texture?
if (fw_actionbits & AC_BOTTOMTEXTURE)
{
fw_texture = &textures[wc->b_texturenum];
if (fw_texture->data == NULL)
fw_texture->data = R_CheckPixels(fw_texture->lumpnum);
}
int floorpicnum = wc->floorpicnum;
int ceilingpicnum = wc->ceilingpicnum;
if (flatpixels[floorpicnum] == NULL)
flatpixels[floorpicnum] = R_CheckPixels(firstflat + floorpicnum);
// is there sky at this wall?
if (ceilingpicnum == -1)
{
// cache skytexture if needed
skytexturep->data = R_CheckPixels(skytexturep->lumpnum);
}
else
{
// normal ceilingpic
if (flatpixels[ceilingpicnum] == NULL)
flatpixels[ceilingpicnum] = R_CheckPixels(firstflat + ceilingpicnum);
}
}
#endif
//
// Start late prep rendering stage
//
boolean R_LatePrep(void)
{
#ifdef MARS
return true;
#else
return cacheneeded;
#endif
}
// EOF