Implement tile-local component of column texture fetching

This commit is contained in:
jndean
2023-10-09 20:43:35 +00:00
parent 32c5781f8f
commit 5e07e34835
14 changed files with 139 additions and 67 deletions
+1
View File
@@ -7,6 +7,7 @@ IPU_OBJ = $(addprefix build/ipu_obj/, \
ipu_vertices.gp \
ipu_transfer.gp \
ipu_malloc.gp \
ipu_texturetiles.gp \
i_video.gp \
g_game.gp \
g_game_codelets.gp \
+2 -2
View File
@@ -1,8 +1,8 @@
#include <stdlib.h>
#include "ipu_malloc.h"
#include "print.h"
#include "r_main.h"
#include "ipu_malloc.h"
#include "ipu_utils.h"
#define ALIGN32(x) (((x) + 3) & (~3))
+33
View File
@@ -0,0 +1,33 @@
#include "doomtype.h"
#include "ipu_utils.h"
#include "ipu_texturetiles.h"
// #include "../../xcom.hpp"
#define NUMCACHECOLS (20)
#define CACHECOLSIZE (128)
static byte columnCache[NUMCACHECOLS][CACHECOLSIZE];
extern "C"
void IPU_R_InitColumnRequester(void) {
// TMP colours
for (int i = 0; i < NUMCACHECOLS; ++i) {
unsigned* col = (unsigned*) columnCache[i];
byte c1 = (i * 8) % 256;
byte c2 = (c1 + 1) % 256;
byte c3 = (c1 + 2) % 256;
byte c4 = (c1 + 1) % 256;
unsigned packedColour = c1 | (c2 << 8) | (c3 << 16) | (c4 << 24);
for (int j = 0; j < CACHECOLSIZE / 4; j++) {
col[j] = packedColour;
}
}
}
extern "C" byte* IPU_R_RequestColumn(int texture, int column) {
return columnCache[texture % NUMCACHECOLS];
}
+25
View File
@@ -0,0 +1,25 @@
#ifndef __IPU_TEXTURETILES__
#define __IPU_TEXTURETILES__
#ifdef __cplusplus
extern "C" {
#endif
#include "doomtype.h"
#include "ipu_utils.h"
void IPU_R_InitColumnRequester(void);
byte* IPU_R_RequestColumn(int texture, int column);
#ifdef __cplusplus
}
#endif
#endif // __IPU_TEXTURETILES__
+9
View File
@@ -0,0 +1,9 @@
#ifndef __IPU_UTILS__
#define __IPU_UTILS__
// #define __SUPER__ __attribute__((target("supervisor")))
extern int tileID;
#endif // __IPU_UTILS__
+6 -1
View File
@@ -3,9 +3,11 @@
#include <cassert>
#include "doomtype.h"
#include "r_main.h"
#include "i_video.h"
#include "ipu_utils.h"
#include "ipu_texturetiles.h"
typedef uint8_t pixel_t;
@@ -58,6 +60,9 @@ struct IPU_Init_Vertex : public poplar::SupervisorVertex {
logical += 2 * row;
tileID = logical;
// IPU_R_InitColumnRequester(physical);
}
};
+3 -1
View File
@@ -7,6 +7,8 @@
#include "i_video.h"
#include "ipu_transfer.h"
#include "ipu_utils.h"
#include "ipu_texturetiles.h"
extern "C" {
@@ -31,7 +33,7 @@ struct R_Init_Vertex: public poplar::Vertex {
break; case 1:
R_InitTextures((int*)&lumpBuf[0], (R_Init_MiscValues_t*)&miscValues[0]);
IPU_R_InitColumnRequester();
*lumpNum = 0;
step = 0;
+7 -5
View File
@@ -41,6 +41,7 @@
*/
#include <print.h>
#include "ipu_utils.h"
#include "ipu_transfer.h"
#include "ipu_malloc.h"
@@ -372,7 +373,6 @@ byte *R_GetColumn(int tex, int col) {
return texturecomposite[tex] + ofs;
}
*/
static void GenerateTextureHashTable(void) {
IPUpatchlesstexture_t **rover;
int i;
@@ -587,10 +587,12 @@ void R_InitTextures(int* maptex, R_Init_MiscValues_t* miscVals) {
// R_GenerateLookup(i);
// Create translation table for global animation.
// texturetranslation = // JOSEF
// Z_Malloc((numtextures + 1) * sizeof(*texturetranslation), PU_STATIC, 0);
// for (i = 0; i < numtextures; i++)
// texturetranslation[i] = i;
texturetranslation = IPU_static_malloc(
(numtextures + 1) * sizeof(*texturetranslation),
"texturetranslation"
);
for (i = 0; i < numtextures; i++)
texturetranslation[i] = i;
GenerateTextureHashTable();
}
+7 -9
View File
@@ -113,10 +113,6 @@ void R_DrawColumn(void) {
fixed_t frac;
fixed_t fracstep;
// JOSEF: Each tile only renders a portion of the frame
if ((dc_x < tileLeftClip) || (dc_x >= tileRightClip))
return;
count = dc_yh - dc_yl;
// Zero length, column does not exceed a pixel.
@@ -124,7 +120,6 @@ void R_DrawColumn(void) {
return;
if ((unsigned)dc_x >= SCREENWIDTH || dc_yl < 0 || dc_yh >= SCREENHEIGHT) {
// I_Error("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x);
printf("ERROR: R_DrawColumn: %u to %u at %u\n", dc_yl, dc_yh, dc_x);
}
char colour = (bspnum - (lightnum & 1)) % 256; // JOSEF: TMP!
@@ -136,8 +131,8 @@ void R_DrawColumn(void) {
// Determine scaling,
// which is the only mapping to be done.
// fracstep = dc_iscale; // LATER
// frac = dc_texturemid + (dc_yl - centery) * fracstep; // LATER
fracstep = dc_iscale;
frac = dc_texturemid + (dc_yl - centery) * fracstep;
// Inner loop that does the actual texture mapping,
// e.g. a DDA-lile scaling.
@@ -145,10 +140,13 @@ void R_DrawColumn(void) {
do {
// Re-map color indices from wall texture column
// using a lighting/special effects LUT.
*dest = colour; // LATER: dc_colormap[dc_source[(frac >> FRACBITS) & 127]]; // LATER
// LATER: *dest = dc_colormap[dc_source[(frac >> FRACBITS) & 127]]; // LATER
// *dest = colour;
*dest = dc_source[(frac >> FRACBITS) & 127];
dest += IPUCOLSPERRENDERTILE; // JOSEF: SCREENWIDTH;
// frac += fracstep; // LATER
frac += fracstep;
} while (count--);
}
+8 -12
View File
@@ -254,9 +254,7 @@ int R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line) {
// the y (<=x) is scaled and divided by x to get a
// tangent (slope) value which is looked up in the
// tantoangle[] table.
//
angle_t R_PointToAngle(fixed_t x, fixed_t y) {
x -= viewx;
y -= viewy;
@@ -676,6 +674,7 @@ void R_ExecuteSetViewSize(void) {
*/
}
/*
//
// R_Init
//
@@ -683,27 +682,24 @@ void R_ExecuteSetViewSize(void) {
void R_Init(void) {
R_InitData();
/* LATER
// printf(".");
printf(".");
R_InitPointToAngle();
// printf(".");
printf(".");
R_InitTables();
// viewwidth / viewheight / detailLevel are set by the defaults
// printf(".");
printf(".");
R_SetViewSize(screenblocks, detailLevel);
R_InitPlanes();
// printf(".");
printf(".");
R_InitLightTables();
// printf(".");
printf(".");
R_InitSkyMap();
R_InitTranslationTables();
// printf(".");
*/
printf(".");
framecount = 0;
}
/*
//
// R_PointInSubsector
@@ -746,7 +742,7 @@ void R_SetupFrame(player_t *player) {
viewsin = IPU_finesine(viewangle >> ANGLETOFINESHIFT);
viewcos = finecosine[viewangle >> ANGLETOFINESHIFT];
// JOSEF TMP tests!
// JOSEF TMP, some tests to about replacing sin LUTs!
// angle_t sin_input = viewangle >> ANGLETOFINESHIFT;
// float sin_inscaled = (sin_input + 0.5f) * 3.14159265359f * 2 / FINEANGLES;
// float sin_sin = sinf(sin_inscaled);
+1 -2
View File
@@ -82,7 +82,7 @@ extern int detailshift;
// Used to select shadow mode etc.
//
// extern void (*colfunc)(void);
// extern void (*colfunc)(void); // JOSEF
void colfunc(void); // Don't want to call via pointer on IPU
extern void (*transcolfunc)(void);
extern void (*basecolfunc)(void);
@@ -92,7 +92,6 @@ extern void (*spanfunc)(void);
// JOSEF
extern int tileID;
extern int tileLeftClip;
extern int tileRightClip;
+35 -33
View File
@@ -38,6 +38,7 @@
#include "v_patch.h"
#include <print.h>
#include "ipu_texturetiles.h"
// OPTIMIZE: closed two sided lines as single sided
@@ -196,7 +197,7 @@ void R_RenderSegLoop(void) {
int yl;
int yh;
int mid;
// fixed_t texturecolumn; // LATER
fixed_t texturecolumn;
int top;
int bottom;
@@ -240,9 +241,9 @@ void R_RenderSegLoop(void) {
// texturecolumn and lighting are independent of wall tiers
if (segtextured) {
// calculate texture offset
// angle = (rw_centerangle + xtoviewangle[rw_x]) >> ANGLETOFINESHIFT;
// texturecolumn = rw_offset - FixedMul(finetangent[angle], rw_distance); // LATER
// texturecolumn >>= FRACBITS; // LATER
angle = (rw_centerangle + xtoviewangle[rw_x]) >> ANGLETOFINESHIFT;
texturecolumn = rw_offset - FixedMul(finetangent[angle], rw_distance);
texturecolumn >>= FRACBITS;
// calculate lighting
index = rw_scale >> LIGHTSCALESHIFT;
@@ -254,8 +255,7 @@ void R_RenderSegLoop(void) {
dc_iscale = 0xffffffffu / (unsigned)rw_scale;
} else {
// purely to shut up the compiler
// texturecolumn = 0; // LATER
texturecolumn = 0;
}
// draw the wall tiers
@@ -263,8 +263,9 @@ void R_RenderSegLoop(void) {
// single sided line
dc_yl = yl;
dc_yh = yh;
// dc_texturemid = rw_midtexturemid; // LATER
// dc_source = R_GetColumn(midtexture, texturecolumn); // LATER
dc_texturemid = rw_midtexturemid;
// dc_source = R_GetColumn(midtexture, texturecolumn); // JOSEF
dc_source = IPU_R_RequestColumn(midtexture, texturecolumn);
colfunc();
ceilingclip[rw_x] = viewheight;
floorclip[rw_x] = -1;
@@ -281,8 +282,9 @@ void R_RenderSegLoop(void) {
if (mid >= yl) {
dc_yl = yl;
dc_yh = mid;
// dc_texturemid = rw_toptexturemid; // LATER
// dc_source = R_GetColumn(toptexture, texturecolumn); // LATER
dc_texturemid = rw_toptexturemid;
// dc_source = R_GetColumn(toptexture, texturecolumn); // JOSEF
dc_source = IPU_R_RequestColumn(toptexture, texturecolumn);
colfunc();
ceilingclip[rw_x] = mid;
@@ -306,8 +308,9 @@ void R_RenderSegLoop(void) {
if (mid <= yh) {
dc_yl = mid;
dc_yh = yh;
// dc_texturemid = rw_bottomtexturemid; // LATER
// dc_source = R_GetColumn(bottomtexture, texturecolumn); // LATER
dc_texturemid = rw_bottomtexturemid;
// dc_source = R_GetColumn(bottomtexture, texturecolumn); // JOSEF
dc_source = IPU_R_RequestColumn(bottomtexture, texturecolumn);
colfunc();
floorclip[rw_x] = mid;
} else
@@ -397,20 +400,19 @@ void R_StoreWallRange(int start, int stop) {
if (!backsector) {
// single sided line
midtexture = sidedef->midtexture; //LATER: texturetranslation[sidedef->midtexture];
midtexture = texturetranslation[sidedef->midtexture];
// a single sided line is terminal, so it must mark ends
markfloor = markceiling = true;
// ---- JOSEF: LATER ----
// if (linedef->flags & ML_DONTPEGBOTTOM) {
// vtop = frontsector->floorheight + textureheight[sidedef->midtexture];
// // bottom of texture at bottom
// rw_midtexturemid = vtop - viewz;
// } else {
// // top of texture at top
// rw_midtexturemid = worldtop;
// }
// rw_midtexturemid += sidedef->rowoffset;
if (linedef->flags & ML_DONTPEGBOTTOM) {
vtop = frontsector->floorheight + textureheight[sidedef->midtexture];
// bottom of texture at bottom
rw_midtexturemid = vtop - viewz;
} else {
// top of texture at top
rw_midtexturemid = worldtop;
}
rw_midtexturemid += sidedef->rowoffset;
ds_p->silhouette = SIL_BOTH;
@@ -488,20 +490,20 @@ void R_StoreWallRange(int start, int stop) {
if (worldhigh < worldtop) {
// top texture
toptexture = sidedef->toptexture; // LATER: texturetranslation[sidedef->toptexture];
// if (linedef->flags & ML_DONTPEGTOP) {
// // top of texture at top
// rw_toptexturemid = worldtop;
// } else {
// vtop = backsector->ceilingheight + textureheight[sidedef->toptexture];
toptexture = texturetranslation[sidedef->toptexture];
if (linedef->flags & ML_DONTPEGTOP) {
// top of texture at top
rw_toptexturemid = worldtop;
} else {
vtop = backsector->ceilingheight + textureheight[sidedef->toptexture];
// // bottom of texture
// rw_toptexturemid = vtop - viewz;
// }
// bottom of texture
rw_toptexturemid = vtop - viewz;
}
}
if (worldlow > worldbottom) {
// bottom texture
bottomtexture = sidedef->bottomtexture; // LATER: texturetranslation[sidedef->bottomtexture];
bottomtexture = texturetranslation[sidedef->bottomtexture];
if (linedef->flags & ML_DONTPEGBOTTOM) {
// bottom of texture at bottom
+1 -1
View File
@@ -578,7 +578,7 @@ const fixed_t finetangent[4096] =
11392683,13145455,15535599,18988036,24413316,34178904,56965752,170910304
};
// 40K lookup table is a bit dear for IPU, could calc live instead
// 40K lookup table is a bit dear for IPU, eventually calculate live instead
fixed_t IPU_finesine(int i) {
return finesine[i];
+1 -1
View File
@@ -17,7 +17,7 @@
//
#include "ipu_utils.h"
/*
#include <ctype.h
>