Skip to content

Commit

Permalink
#407 32X on-chip 2k rasterization code test (slower)
Browse files Browse the repository at this point in the history
  • Loading branch information
XProger committed Apr 23, 2022
1 parent 93058da commit fedd2ed
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/platform/32x/32x.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,8 @@ extern "C"
void CacheClearLine(void* ptr);
}

#define CacheClear()\
CacheControl(0);\
CacheControl(SH2_CCTL_CP | SH2_CCTL_CE);

#endif
6 changes: 0 additions & 6 deletions src/platform/32x/asm/common.i
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@
// int16 e10, e11, e12 // rotation
// int16 e20, e21, e22 // rotation
// int16 e03, e13, e23 // translation
//
// word [ N Z Z ] // rot
// [ Z N Z ] // rot
// [ Z Z N ] // rot
// [ Z Z Z ] // trans
// long [ NZ ZZ NZ ZZ NZ ZZ ]

// row[0] rotation
#define M00 0
Expand Down
6 changes: 6 additions & 0 deletions src/platform/32x/asm/matrixSetIdentity.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ SEG_MATH
#define ZZ r1
#define NZ r2

// word [ N Z Z ] // rot
// [ Z N Z ] // rot
// [ Z Z N ] // rot
// [ Z Z Z ] // trans
// long [ NZ ZZ NZ ZZ NZ ZZ ]

.align 4
.global _matrixSetIdentity_asm
_matrixSetIdentity_asm:
Expand Down
8 changes: 8 additions & 0 deletions src/platform/32x/asm/rasterize.s
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ var_fb:
// write per but allow transparent write for byte & word
.long 0x24020200
var_table:
/* 2k on-chip test
.long 0xC0000000 + 516 + 416 + 256 + 18 //_rasterizeS_asm
.long 0xC0000000 + 516 + 416 + 18 //_rasterizeF_asm
.long 0xC0000000 + 516 + 18 //_rasterizeFT_asm
.long 0xC0000000 + 516 + 18 //_rasterizeFT_asm
.long 0xC0000000 + 20 //_rasterizeGT_asm
.long 0xC0000000 + 20 //_rasterizeGT_asm
*/
.long _rasterizeS_asm
.long _rasterizeF_asm
.long _rasterizeFT_asm
Expand Down
7 changes: 7 additions & 0 deletions src/platform/32x/asm/rasterizeF.s
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ SEG_RASTER
#define LMAP inv

.align 4
.global _rasterizeF_asm_start
_rasterizeF_asm_start:

.exit:
// pop
mov.l @sp+, r14
Expand Down Expand Up @@ -213,3 +216,7 @@ var_LMAP_ADDR:
.long _gLightmap_base
var_divTable:
.long _divTable

.align 2
.global _rasterizeF_asm_end
_rasterizeF_asm_end:
7 changes: 7 additions & 0 deletions src/platform/32x/asm/rasterizeFT.s
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ SP_R = 24
SP_SIZE = 28

.align 4
.global _rasterizeFT_asm_start
_rasterizeFT_asm_start:

.exit:
// pop
add #SP_SIZE, sp
Expand Down Expand Up @@ -317,3 +320,7 @@ var_divTable:
.long _divTable
var_gTile:
.long _gTile

.align 2
.global _rasterizeFT_asm_end
_rasterizeFT_asm_end:
8 changes: 8 additions & 0 deletions src/platform/32x/asm/rasterizeGT.s
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ SP_R = 28
SP_SIZE = 32

.align 4

.global _rasterizeGT_asm_start
_rasterizeGT_asm_start:

.exit:
// pop
add #SP_SIZE, sp
Expand Down Expand Up @@ -400,3 +404,7 @@ var_divTable:
.long _divTable
var_gTile:
.long _gTile

.align 2
.global _rasterizeGT_asm_end
_rasterizeGT_asm_end:
7 changes: 7 additions & 0 deletions src/platform/32x/asm/rasterizeS.s
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ SEG_RASTER
#define ih inv

.align 4
.global _rasterizeS_asm_start
_rasterizeS_asm_start:

.exit:
// pop
mov.l @sp+, r14
Expand Down Expand Up @@ -188,3 +191,7 @@ var_LMAP_ADDR:
.long _gLightmap_base
var_divTable:
.long _divTable

.align 2
.global _rasterizeS_asm_end
_rasterizeS_asm_end:
47 changes: 47 additions & 0 deletions src/platform/32x/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,37 @@ void flush_c()
return;

gFacesBase = gFaces;
/*
CacheControl(0);
CacheControl(SH2_CCTL_CP | SH2_CCTL_CE | SH2_CCTL_TW);
extern int32 rasterizeGT_asm_start;
extern int32 rasterizeGT_asm_end;
int32 size = intptr_t(&rasterizeGT_asm_end) - intptr_t(&rasterizeGT_asm_start);
fast_memcpy((void*)(0xC0000000 + 0), &rasterizeGT_asm_start, size >> 2); // 516
extern int32 rasterizeFT_asm_start;
extern int32 rasterizeFT_asm_end;
size = intptr_t(&rasterizeFT_asm_end) - intptr_t(&rasterizeFT_asm_start);
fast_memcpy((void*)(0xC0000000 + 516), &rasterizeFT_asm_start, size >> 2); // 416
extern int32 rasterizeF_asm_start;
extern int32 rasterizeF_asm_end;
size = intptr_t(&rasterizeF_asm_end) - intptr_t(&rasterizeF_asm_start);
fast_memcpy((void*)(0xC0000000 + 516 + 416), &rasterizeF_asm_start, size >> 2); // 256
extern int32 rasterizeS_asm_start;
extern int32 rasterizeS_asm_end;
size = intptr_t(&rasterizeS_asm_end) - intptr_t(&rasterizeS_asm_start);
fast_memcpy((void*)(0xC0000000 + 516 + 416 + 256), &rasterizeS_asm_start, size >> 2); // 224
//extern int32 fps;
//fps = size;
*/

PROFILE(CNT_FLUSH);

Expand Down Expand Up @@ -753,6 +784,10 @@ void flush_c()

} while (face);
}
/*
CacheControl(0);
CacheControl(SH2_CCTL_CP | SH2_CCTL_CE);
*/
}
#endif

Expand Down Expand Up @@ -843,6 +878,18 @@ void renderInit()
gFacesBase = gFaces;
}

void renderFree()
{
}

void renderLevelInit()
{
}

void renderLevelFree()
{
}

extern "C" X_NOINLINE void drawTriangle(uint32 flags, VertexLink* v)
{
VertexLink* v0 = v + 0;
Expand Down

0 comments on commit fedd2ed

Please sign in to comment.