IPU loads map vertices

This commit is contained in:
jndean
2022-08-26 21:50:47 +01:00
parent 1512b6ccb3
commit aa22391bae
5 changed files with 73 additions and 17 deletions

View File

@@ -13,9 +13,8 @@
// MAP related Lookup tables.
// Store VERTEXES, LINEDEFS, SIDEDEFS, etc.
//
#define MAXVERTEXES (1024)
int numvertexes;
vertex_t vertexes[MAXVERTEXES];
vertex_t *vertexes;
int numsegs;
seg_t *segs;
@@ -74,6 +73,50 @@ mapthing_t playerstarts[MAXPLAYERS];
// P_LoadVertexes
//
void P_LoadVertexes(const unsigned char *buf) {
byte *data;
int i;
mapvertex_t *ml;
vertex_t *li;
// Determine number of lumps:
// total lump length / vertex record length.
int lumplen = ((int*)buf)[0];
numvertexes = lumplen / sizeof(mapvertex_t);
// Allocate zone memory for buffer.
vertexes = IPU_level_malloc(numvertexes * sizeof(vertex_t));
// Load data into cache.
// JOSEF: data = W_CacheLumpNum(lump, PU_STATIC);
ml = (mapvertex_t *)(&buf[sizeof(int)]);
li = vertexes;
// Copy and convert vertex coordinates,
// internal representation as fixed.
for (i = 0; i < numvertexes; i++, li++, ml++) {
li->x = ml->x << FRACBITS;
li->y = ml->y << FRACBITS;
}
ipuprint("numvertexes: ");
ipuprintnum(numvertexes);
ipuprint(", 1x: ");
ipuprintnum(vertexes[0].x);
ipuprint(", -1y: ");
ipuprintnum(vertexes[numvertexes-1].y);
ipuprint("\n");
// Free buffer memory.
// JOSEF: W_ReleaseLumpNum(lump);
requestedlumpnum = gamelumpnum + ML_SECTORS;
}
//
// P_SetupLevel
//
@@ -186,7 +229,7 @@ void P_LoadBlockMap(const unsigned char *buf) {
blockmap = blockmaplump + 4;
// Swap all short integers to native byte ordering.
// JOSEF: assumer endianness of SHORT is fine
// JOSEF: assume endianness of SHORT is fine
// Read the header
@@ -195,20 +238,12 @@ void P_LoadBlockMap(const unsigned char *buf) {
bmapwidth = blockmaplump[2];
bmapheight = blockmaplump[3];
ipuprint("[IPU] bmaporgx ");
ipuprintnum(bmaporgx);
ipuprint(", bmaporgy ");
ipuprintnum(bmaporgy);
ipuprint(", bmapwidth ");
ipuprintnum(bmapwidth);
ipuprint(", bmapheight ");
ipuprintnum(bmapheight);
ipuprint("\n");
// Clear out mobj chains
count = sizeof(*blocklinks) * bmapwidth * bmapheight;
blocklinks = IPU_level_malloc(count);
memset(blocklinks, 0, count);
// JOSEF: next lump to load
requestedlumpnum = gamelumpnum + ML_VERTEXES;
}

View File

@@ -6,6 +6,7 @@
extern "C" {
void P_SetupLevel_pt0(void);
void P_LoadBlockMap(const unsigned char *buf);
void P_LoadVertexes(const unsigned char *buf);
};
@@ -30,3 +31,14 @@ class P_LoadBlockMap_Vertex : public poplar::Vertex {
return true;
}
};
class P_LoadVertexes_Vertex : public poplar::Vertex {
poplar::Input<poplar::Vector<unsigned char>> lumpBuf;
poplar::Output<int> lumpNum;
public:
bool compute() {
P_LoadVertexes(&lumpBuf[0]);
*lumpNum = requestedlumpnum;
return true;
}
};

View File

@@ -142,6 +142,12 @@ void IpuDoom::buildIpuGraph() {
m_ipuGraph.setTileMapping(vtx, 0);
m_ipuGraph.setPerfEstimate(vtx, 100);
poplar::ComputeSet P_LoadVertexes_CS = m_ipuGraph.addComputeSet("P_LoadVertexes_CS");
vtx = m_ipuGraph.addVertex(P_LoadVertexes_CS, "P_LoadVertexes_Vertex", {
{"lumpNum", m_lumpNum}, {"lumpBuf", m_lumpBuf}});
m_ipuGraph.setTileMapping(vtx, 0);
m_ipuGraph.setPerfEstimate(vtx, 100);
poplar::program::Sequence G_DoLoadLevel_prog({
poplar::program::Copy(miscValuesStream, m_miscValuesBuf),
@@ -150,6 +156,9 @@ void IpuDoom::buildIpuGraph() {
poplar::program::Copy(m_lumpNum, lumpNumStream),
poplar::program::Copy(lumpBufStream, m_lumpBuf),
poplar::program::Execute(P_LoadBlockMap_CS),
poplar::program::Copy(m_lumpNum, lumpNumStream),
poplar::program::Copy(lumpBufStream, m_lumpBuf),
poplar::program::Execute(P_LoadVertexes_CS),
GetPrintbuf_prog,
// poplar::program::Copy(lumpStream, m_lumpBuf),
// poplar::program::Execute(IPU_UnpackLineDefs_CS),

View File

@@ -27,15 +27,12 @@ void IPU_G_LoadLevel_PackMiscValues(void* buf) {
lumpname[4] = '\0';
pack.lumpnum = W_GetNumForName(lumpname);
printf("[CPU]: %d\n", pack.lumpnum);
memcpy(buf, &pack, sizeof(pack));
}
void IPU_LoadLumpForTransfer(int lumpnum, byte* buf) {
int size = W_LumpLength(lumpnum);
printf("[CPU] Sending lumlen %d\n", size);
int required = size + sizeof(int); // Space for size field
if (required > IPUMAXLUMPBYTES) {
printf("\nNeed %d bytes to transfer lump %d to IPU, only have %d\n",

View File

@@ -137,6 +137,9 @@ void P_LoadVertexes(int lump) {
li->y = SHORT(ml->y) << FRACBITS;
}
printf("[CPU] numvertexes: %d, 1x: %d, -1y:%d\n",
numvertexes, vertexes[0].x, vertexes[numvertexes-1].y);
// Free buffer memory.
W_ReleaseLumpNum(lump);
}