diff --git a/NOTES.md b/NOTES.md index 731061e..29ad779 100644 --- a/NOTES.md +++ b/NOTES.md @@ -1,9 +1,18 @@ +# Things that are interesting about IpuDoom + + - Fixed precision int math + - 64-bit int division + - wasn't supported in the supervisor context, drop into a worker thread for each individual division, do double division +- Avoid recursive algorithms, e.g. make a non-recursive BSP +- Split column rendering over 32 tiles +- Memory + - Save 50-60k of lookup tabes for transcendentals by using float functions + - Store textures on other tiles, JIT-fetch as needed (by live patching exchange programs to select a tile) + - Can call exchanges from deep in the call stack, don't need to exit the vertex + -Things I don't support, to make my life easier: +#### Things I don't support, to make my life easier: - gamemodes other than shareware - multiplayer - cheating - -What about: - -precomputed trancendental takes like 32kb on its own, recompute live? \ No newline at end of file diff --git a/demo.lmp b/demo.lmp new file mode 100644 index 0000000..000a901 Binary files /dev/null and b/demo.lmp differ diff --git a/src/ipu/ipu_texturetiles.cpp b/src/ipu/ipu_texturetiles.cpp index 4f292d3..3d88d08 100644 --- a/src/ipu/ipu_texturetiles.cpp +++ b/src/ipu/ipu_texturetiles.cpp @@ -78,6 +78,8 @@ void IPU_R_FulfilColumnRequest(unsigned* progBuf, unsigned char* textureBuf, uns auto sendProgram = &progBuf[progBuf[1]]; auto aggrProgram = &progBuf[progBuf[2]]; + int noise = 0; + while (1) { XCOM_Execute(recvProgram, NULL, textureBuf); @@ -91,20 +93,37 @@ void IPU_R_FulfilColumnRequest(unsigned* progBuf, unsigned char* textureBuf, uns textureNum >= tileLocalTextureRange[0] && textureNum < tileLocalTextureRange[1]) { col = &textureBuf[tileLocalTextureOffsets[textureNum] + columnOffset]; - // if (firstPrint && tileID >= 32 && tileID < 36) printf("Accepted texture %d\n", (int)textureNum); - } else { - // if (firstPrint && tileID >= 32 && tileID < 36) printf("Rejected texture %d\n", (int)textureNum); } - byte c1 = (17 * 9) % 256; - byte c2 = (c1 + 1) % 256; - byte c3 = (c1 + 2) % 256; - byte c4 = (c1 + 1) % 256; - unsigned colour = c1 | (c2 << 8) | (c3 << 16) | (c4 << 24); - for (int i = 0; i < IPUTEXTURECACHELINESIZE; i++) { - ((unsigned*)textureBuf)[i] = colour; - } + + // noise = (noise + 1) % 4; + // unsigned renderStripe = (tileID - IPUFIRSTTEXTURETILE) / IPUTEXTURETILESPERRENDERTILE; + // { + // // unsigned colour = (renderStripe * 9) % 256; + // colour = colour | (colour << 8) | (colour << 16) | (colour << 24); + // for (int i = 0; i < IPUTEXTURECACHELINESIZE; i++) { + // if (noise == 0) { + // ((unsigned*)col)[i] += 0x01010101; + // } + // // ((unsigned*)col)[i] = colour; + // } + // } + + // { + // // Render Tile Stripes + // unsigned colour = renderStripe * 16; + // for (int i = 0; i < IPUTEXTURECACHELINESIZE * sizeof(int); i++) { + // if (renderStripe % 2) { + // textureBuf[i] = (col[i] % 4); //(col[i] % 30) + 20; + // } else { + // textureBuf[i] = (col[i] % 30) + 80; //(col[i] % 4); + // } + // } + // col = textureBuf; + // } + XCOM_Execute(sendProgram, col, NULL); + // XCOM_Execute(sendProgram, col, NULL); XCOM_Execute(aggrProgram, NULL, commsBuf); if (commsBuf[0]) diff --git a/src/ipu/m_fixed.cpp b/src/ipu/m_fixed.cpp index 4ee799d..d8f2237 100644 --- a/src/ipu/m_fixed.cpp +++ b/src/ipu/m_fixed.cpp @@ -55,25 +55,17 @@ fixed_t FixedMul(fixed_t a, fixed_t b) struct DivWorker : public poplar::Vertex { fixed_t a, b; void compute() { - // Using int64_ caused some weird errors. So use double instead...? + // Using int64_t caused some weird errors. So use double instead...? // a = (((int64_t) a) << FRACBITS) / b; a = ((double) a * FRACUNIT) / (double) b; } }; -// -// FixedDiv, C version. -// -extern "C" -__SUPER__ fixed_t FixedDiv(fixed_t a, fixed_t b) { if ((abs(a) >> 14) >= abs(b)) { return (a^b) < 0 ? INT_MIN : INT_MAX; } else { - // int64_t result; // JOSEF - // result = ((int64_t) a << FRACBITS) / b; - // return (fixed_t) result; DivWorker workerArgs; unsigned workerArgsPtr = (unsigned)&workerArgs - TMEM_BASE_ADDR; @@ -91,4 +83,3 @@ fixed_t FixedDiv(fixed_t a, fixed_t b) return workerArgs.a; } } - diff --git a/src/ipu/r_codelets.cpp b/src/ipu/r_codelets.cpp index 3509171..802d38a 100644 --- a/src/ipu/r_codelets.cpp +++ b/src/ipu/r_codelets.cpp @@ -88,6 +88,9 @@ R_RenderPlayerView_Vertex : public poplar::SupervisorVertex { (R_RenderPlayerView_MiscValues_t*) &miscValues[0] ); + // For visualisation of progress + // memset(I_VideoBuffer, 0, IPUCOLSPERRENDERTILE * SCREENHEIGHT); + R_RenderPlayerView(&players[displayplayer]); IPU_R_RenderTileDone(); return; diff --git a/src/r_data.c b/src/r_data.c index 43d2dbb..4c076c9 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -333,7 +333,7 @@ void R_GenerateLookup(int texnum) { // // R_GetColumn // -byte *R_GetColumn_Original(int tex, int col) { // JOSEF: Renamed to `_Original` +byte *R_GetColumn(int tex, int col) { // JOSEF: Renamed to `_Original` int lump; int ofs; @@ -382,7 +382,7 @@ void GenerateIPUTextureBlob(void) { ipuTextureBlobOffsets[t] = pos; byte* dst = &ipuTextureBlob[tile * IPUTEXTURETILEBUFSIZE + pos]; for (int x = 0; x < tex_width; x += 1, dst += tex_height) { - byte* col = R_GetColumn_Original(t, x); + byte* col = R_GetColumn(t, x); memcpy(dst, col, tex_height); } pos += tex_size; @@ -393,8 +393,7 @@ void GenerateIPUTextureBlob(void) { // // R_GetColumn : JOSEF: The version that uses the IPU texture dump // -byte *R_GetColumn(int tex, int col) { - // return R_GetColumn_Original(tex, col); // For checking old behaviour +byte *R_GetColumn_LikeIPU(int tex, int col) { int tile; col &= texturewidthmask[tex]; for (tile = 0; tile < IPUTEXTURETILESPERRENDERTILE; ++tile) {