F3DLX2.Rej integration

The master displaylist has been split into two, one for things to render in F3DZEX, and one that renders in F3DLX2.Rej, with the aim to save performance when rendering smaller things.
This commit is contained in:
Fazana committed 2021-09-14 21:43:55 +01:00
1 parent 6e07c3c724
commit 9d1329f245
12 files changed
+118 -57

No files matched your search

+7 -4
View File
@@ -907,7 +907,7 @@ static BhvCommandProc BehaviorCmdTable[] = {
void cur_obj_update(void) {
UNUSED u32 unused;
s16 objFlags = gCurrentObject->oFlags;
u32 objFlags = gCurrentObject->oFlags;
f32 distanceFromMario;
BhvCommandProc bhvCmdProc;
s32 bhvProcResult;
@@ -952,9 +952,6 @@ void cur_obj_update(void) {
gCurrentObject->oPrevAction = gCurrentObject->oAction);
}
// Execute various code based on object flags.
objFlags = (s16) gCurrentObject->oFlags;
if (objFlags & OBJ_FLAG_SET_FACE_ANGLE_TO_MOVE_ANGLE) {
obj_set_face_angle_to_move_angle(gCurrentObject);
}
@@ -983,6 +980,12 @@ void cur_obj_update(void) {
obj_update_gfx_pos_and_angle(gCurrentObject);
}
if (objFlags & OBJ_FLAG_UCODE_LARGE)
gCurrentObject->header.gfx.uCode = UCODE_DEFAULT;
else
gCurrentObject->header.gfx.uCode = UCODE_REJ;
#ifdef PUPPYLIGHTS
puppylights_object_emit(gCurrentObject);
#endif
+5 -2
View File
@@ -7,6 +7,9 @@
#include "types.h"
#include "game/memory.h"
#define UCODE_DEFAULT 0
#define UCODE_REJ 1
#define GRAPH_RENDER_ACTIVE (1 << 0)
#define GRAPH_RENDER_CHILDREN_FIRST (1 << 1)
#define GRAPH_RENDER_BILLBOARD (1 << 2)
@@ -126,8 +129,8 @@ struct DisplayListNode
struct GraphNodeMasterList
{
/*0x00*/ struct GraphNode node;
/*0x14*/ struct DisplayListNode *listHeads[GFX_NUM_MASTER_LISTS];
/*0x34*/ struct DisplayListNode *listTails[GFX_NUM_MASTER_LISTS];
/*0x14*/ struct DisplayListNode *listHeads[2][GFX_NUM_MASTER_LISTS];
/*0x34*/ struct DisplayListNode *listTails[2][GFX_NUM_MASTER_LISTS];
};
/** Simply used as a parent to group multiple children.
+1 -1
View File
@@ -963,7 +963,7 @@ struct LevelCommand *level_script_execute(struct LevelCommand *cmd) {
}
profiler_log_thread5_time(LEVEL_SCRIPT_EXECUTE);
init_rcp();
init_rcp(1);
render_game();
end_master_display_list();
alloc_display_list(0);
+1 -2
View File
@@ -111,9 +111,8 @@ void crash_screen_print(s32 x, s32 y, const char *fmt, ...) {
u32 glyph;
s32 size;
char buf[0x108];
UNUSED s32 i = 0;
memset(buf, 0, sizeof(buf));
bzero(&buf ,sizeof(buf));
va_list args;
va_start(args, fmt);
+8 -7
View File
@@ -125,9 +125,7 @@ void init_rdp(void) {
gDPSetColorDither(gDisplayListHead++, G_CD_MAGICSQ);
gDPSetCycleType(gDisplayListHead++, G_CYC_FILL);
#ifdef VERSION_SH
gDPSetAlphaDither(gDisplayListHead++, G_AD_PATTERN);
#endif
gDPPipeSync(gDisplayListHead++);
}
@@ -135,6 +133,7 @@ void init_rdp(void) {
* Sets the initial RSP (Reality Signal Processor) settings.
*/
void init_rsp(void) {
gSPClearGeometryMode(gDisplayListHead++, G_SHADE | G_SHADING_SMOOTH | G_CULL_BOTH | G_FOG
| G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD);
@@ -153,13 +152,15 @@ void init_rsp(void) {
/**
* Initialize the z buffer for the current frame.
*/
void init_z_buffer(void) {
void init_z_buffer(s32 resetZB) {
gDPPipeSync(gDisplayListHead++);
gDPSetDepthSource(gDisplayListHead++, G_ZS_PIXEL);
gDPSetDepthImage(gDisplayListHead++, gPhysicalZBuffer);
gDPSetColorImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, gPhysicalZBuffer);
if (!resetZB)
return;
gDPSetFillColor(gDisplayListHead++,
GPACK_ZDZ(G_MAXFBZ, 0) << 16 | GPACK_ZDZ(G_MAXFBZ, 0));
@@ -273,7 +274,7 @@ void create_gfx_task_structure(void) {
gGfxSPTask->task.t.type = M_GFXTASK;
gGfxSPTask->task.t.ucode_boot = rspbootTextStart;
gGfxSPTask->task.t.ucode_boot_size = ((u8 *) rspbootTextEnd - (u8 *) rspbootTextStart);
gGfxSPTask->task.t.flags = 0;
gGfxSPTask->task.t.flags = OS_TASK_LOADABLE | OS_TASK_DP_WAIT;
#ifdef L3DEX2_ALONE
gGfxSPTask->task.t.ucode = gspL3DEX2_fifoTextStart;
gGfxSPTask->task.t.ucode_data = gspL3DEX2_fifoDataStart;
@@ -312,11 +313,11 @@ void create_gfx_task_structure(void) {
/**
* Set default RCP (Reality Co-Processor) settings.
*/
void init_rcp(void) {
void init_rcp(s32 resetZB) {
move_segment_table_to_dmem();
init_rdp();
init_rsp();
init_z_buffer();
init_z_buffer(resetZB);
select_frame_buffer();
}
@@ -381,7 +382,7 @@ void render_init(void) {
gGfxSPTask = &gGfxPool->spTask;
gDisplayListHead = gGfxPool->buffer;
gGfxPoolEnd = (u8 *)(gGfxPool->buffer + GFX_POOL_SIZE);
init_rcp();
init_rcp(1);
clear_frame_buffer(0);
end_master_display_list();
exec_display_list(&gGfxPool->spTask);
+1 -1
View File
@@ -79,7 +79,7 @@ void thread5_game_loop(UNUSED void *arg);
void clear_frame_buffer(s32 color);
void clear_viewport(Vp *viewport, s32 color);
void make_viewport_clip_rect(Vp *viewport);
void init_rcp(void);
void init_rcp(s32 resetZB);
void end_master_display_list(void);
void render_init(void);
void select_gfx_pool(void);
+72 -28
View File
@@ -142,7 +142,7 @@ LookAt lookAt;
*/
static void geo_process_master_list_sub(struct GraphNodeMasterList *node) {
struct DisplayListNode *currList;
s32 i;
s32 i, j;
s32 enableZBuffer = (node->node.flags & GRAPH_RENDER_Z_BUFFER) != 0;
struct RenderModeContainer *modeList = &renderModeTable_1Cycle[enableZBuffer];
struct RenderModeContainer *mode2List = &renderModeTable_2Cycle[enableZBuffer];
@@ -155,26 +155,56 @@ static void geo_process_master_list_sub(struct GraphNodeMasterList *node) {
guLookAtReflect(&lMtx, &lookAt, 0, 0, 0, /* eye */ 0, 0, 1, /* at */ 1, 0, 0 /* up */);
#endif
if (enableZBuffer != 0) {
if (enableZBuffer != 0)
{
gDPPipeSync(gDisplayListHead++);
gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER);
}
for (i = 0; i < GFX_NUM_MASTER_LISTS; i++) {
if ((currList = node->listHeads[i]) != NULL) {
gDPSetRenderMode(gDisplayListHead++, modeList->modes[i], mode2List->modes[i]);
while (currList != NULL) {
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(currList->transform),
G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
gSPDisplayList(gDisplayListHead++, currList->displayList);
currList = currList->next;
#ifdef F3DZEX_GBI_2
for (j = 0; j < 2; j++)
{
//Load rejection on pass 2. ZEX is loaded afterwards.
if (j == 1)
{
gSPLoadUcodeL(gDisplayListHead++, gspF3DLX2_Rej_fifo);
init_rcp(0);
gSPClipRatio(gDisplayListHead++, FRUSTRATIO_2);
if (enableZBuffer != 0)
{
gDPPipeSync(gDisplayListHead++);
gSPSetGeometryMode(gDisplayListHead++, G_ZBUFFER);
}
guLookAtReflect(&lMtx, &lookAt, 0, 0, 0, /* eye */ 0, 0, 1, /* at */ 1, 0, 0 /* up */);
}
#else
j = 0;
#endif
for (i = 0; i < GFX_NUM_MASTER_LISTS; i++)
{
if ((currList = node->listHeads[j][i]) != NULL)
{
gDPSetRenderMode(gDisplayListHead++, modeList->modes[i], mode2List->modes[i]);
while (currList != NULL)
{
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(currList->transform), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH);
gSPDisplayList(gDisplayListHead++, currList->displayList);
currList = currList->next;
}
}
}
#ifdef F3DZEX_GBI_2
}
if (enableZBuffer != 0) {
#endif
if (enableZBuffer != 0)
{
gDPPipeSync(gDisplayListHead++);
gSPClearGeometryMode(gDisplayListHead++, G_ZBUFFER);
}
#ifdef F3DZEX_GBI_2
gSPLoadUcodeL(gDisplayListHead++, gspF3DZEX2_PosLight_fifo);
init_rcp(0);
#endif
}
/**
@@ -182,24 +212,35 @@ static void geo_process_master_list_sub(struct GraphNodeMasterList *node) {
* parameter. Look at the RenderModeContainer struct to see the corresponding
* render modes of layers.
*/
static void geo_append_display_list(void *displayList, s16 layer) {
static void geo_append_display_list(void *displayList, s32 layer)
{
s32 index = 0;
#ifdef F3DEX_GBI_2
gSPLookAt(gDisplayListHead++, &lookAt);
#endif
if (gCurGraphNodeMasterList != 0) {
struct DisplayListNode *listNode =
alloc_only_pool_alloc(gDisplayListHeap, sizeof(struct DisplayListNode));
#ifdef F3DZEX_GBI_2
if (gCurGraphNodeObject != NULL)
{
if (gCurGraphNodeObject->uCode == UCODE_REJ)
index = 1;
}
#endif
if (gCurGraphNodeMasterList != 0)
{
struct DisplayListNode *listNode = alloc_only_pool_alloc(gDisplayListHeap, sizeof(struct DisplayListNode));
listNode->transform = gMatStackFixed[gMatStackIndex];
listNode->displayList = displayList;
listNode->next = 0;
if (gCurGraphNodeMasterList->listHeads[layer] == 0) {
gCurGraphNodeMasterList->listHeads[layer] = listNode;
} else {
gCurGraphNodeMasterList->listTails[layer]->next = listNode;
if (gCurGraphNodeMasterList->listHeads[index][layer] == 0)
{
gCurGraphNodeMasterList->listHeads[index][layer] = listNode;
}
gCurGraphNodeMasterList->listTails[layer] = listNode;
else
{
gCurGraphNodeMasterList->listTails[index][layer]->next = listNode;
}
gCurGraphNodeMasterList->listTails[index][layer] = listNode;
}
}
@@ -209,13 +250,16 @@ static void geo_append_display_list(void *displayList, s16 layer) {
static void geo_process_master_list(struct GraphNodeMasterList *node) {
s32 i;
if (gCurGraphNodeMasterList == NULL && node->node.children != NULL) {
if (gCurGraphNodeMasterList == NULL && node->node.children != NULL)
{
gCurGraphNodeMasterList = node;
for (i = 0; i < GFX_NUM_MASTER_LISTS; i++) {
node->listHeads[i] = NULL;
for (i = 0; i < GFX_NUM_MASTER_LISTS; i++)
{
node->listHeads[0][i] = NULL;
node->listHeads[1][i] = NULL;
}
geo_process_node_and_siblings(node->node.children);
geo_process_master_list_sub(node);
geo_process_master_list_sub(gCurGraphNodeMasterList);
gCurGraphNodeMasterList = NULL;
}
}
@@ -768,8 +812,8 @@ static void geo_process_shadow(struct GraphNodeShadow *node) {
* Since (0,0,0) is unaffected by rotation, columns 0, 1 and 2 are ignored.
*/
static s32 obj_is_in_view(struct GraphNodeObject *node, Mat4 matrix) {
s16 cullingRadius;
s16 halfFov; // half of the fov in in-game angle units instead of degrees
s32 cullingRadius;
s32 halfFov; // half of the fov in in-game angle units instead of degrees
struct GraphNode *geo;
f32 hScreenEdge;
+1
View File
@@ -286,6 +286,7 @@ struct Object *allocate_object(struct ObjectNode *objList) {
obj->header.gfx.pos[1] = -10000.0f;
obj->header.gfx.pos[2] = -10000.0f;
obj->header.gfx.throwMatrix = NULL;
obj->header.gfx.uCode = UCODE_REJ;
#ifdef PUPPYLIGHTS
obj->oLightID = 0xFFFF;
#endif