From 1b48ce3fe3410ef6862d34c7288a69ab201b532d Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 10 Aug 2024 10:08:06 +1000 Subject: [PATCH] Dreamcast: Slightly optimise clipping by avoiding colour interpolation unless necessary --- misc/dreamcast/VertexClip.S | 10 ++++++++-- misc/dreamcast/VertexClip2.S | 9 ++++++++- src/Platform_3DS.c | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/misc/dreamcast/VertexClip.S b/misc/dreamcast/VertexClip.S index cec3e069c..90df94d9e 100644 --- a/misc/dreamcast/VertexClip.S +++ b/misc/dreamcast/VertexClip.S @@ -123,10 +123,15 @@ _ClipLine: add #-4, OUT ! EX, OUT -= 4 mov.l @IN1,CL1 ! LS, ACOLOR = v1->bgra + mov.l @IN2,CL2 ! LS, BCOLOR = v2->bgra +! Bypass interpolation if unnecessary + cmp/eq CL1,CL2 ! MT, T = ACOLOR == BCOLOR + bt.s 1f ! BR, if (T) goto 1; + mov CL1,CLO ! MT, OUTCOLOR = ACOLOR (branch delay instruction) + extu.b CL1,TM1 ! EX, val = ACOLOR.b lds TM1,fpul ! CO, FPUL = val float fpul,fr2 ! EX, fr2 = float(FPUL) - mov.l @IN2,CL2 ! LS, BCOLOR = v2->bgra extu.b CL2,TM1 ! EX, val = BCOLOR.b lds TM1,fpul ! CO, FPUL = val float fpul,fr3 ! EX, fr3 = float(FPUL) @@ -181,8 +186,9 @@ _ClipLine: shll16 TM2 ! EX, tmp <<= 16 shll8 TM2 ! EX, tmp <<= 8 or TM2,CLO ! EX, OUTCOLOR.a |= tmp - mov.l CLO,@OUT ! LS, OUT->color = OUTCOLOR +1: + mov.l CLO,@OUT ! LS, OUT->color = OUTCOLOR mov.l @r15+,r5 ! LS, pop(r5) rts ! CO, return after executing instruction in delay slot mov.l @r15+,r4 ! LS, pop(r4) diff --git a/misc/dreamcast/VertexClip2.S b/misc/dreamcast/VertexClip2.S index ee04dc6c6..de372e33b 100644 --- a/misc/dreamcast/VertexClip2.S +++ b/misc/dreamcast/VertexClip2.S @@ -121,10 +121,15 @@ _ClipEdge: add #-4, OUT ! EX, OUT -= 4 mov.l @IN1,CL1 ! LS, ACOLOR = v1->bgra + mov.l @IN2,CL2 ! LS, BCOLOR = v2->bgra +! Bypass interpolation if unnecessary + cmp/eq CL1,CL2 ! MT, T = ACOLOR == BCOLOR + bt.s 1f ! BR, if (T) goto 1; + mov CL1,CLO ! MT, OUTCOLOR = ACOLOR (branch delay instruction) + extu.b CL1,TM1 ! EX, val = ACOLOR.b lds TM1,fpul ! CO, FPUL = val float fpul,fr2 ! EX, fr2 = float(FPUL) - mov.l @IN2,CL2 ! LS, BCOLOR = v2->bgra extu.b CL2,TM1 ! EX, val = BCOLOR.b lds TM1,fpul ! CO, FPUL = val float fpul,fr3 ! EX, fr3 = float(FPUL) @@ -179,5 +184,7 @@ _ClipEdge: shll16 TM2 ! EX, tmp <<= 16 shll8 TM2 ! EX, tmp <<= 8 or TM2,CLO ! EX, OUTCOLOR.a |= tmp + +1: rts ! CO, return after executing instruction in delay slot mov.l CLO,@OUT ! LS, OUT->color = OUTCOLOR diff --git a/src/Platform_3DS.c b/src/Platform_3DS.c index c2df0883f..5771b379e 100644 --- a/src/Platform_3DS.c +++ b/src/Platform_3DS.c @@ -34,9 +34,9 @@ const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */ const cc_result ReturnCode_FileNotFound = ENOENT; +const cc_result ReturnCode_DirectoryExists = EEXIST; const cc_result ReturnCode_SocketInProgess = EINPROGRESS; const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK; -const cc_result ReturnCode_DirectoryExists = EEXIST; const char* Platform_AppNameSuffix = " 3DS"; cc_bool Platform_ReadonlyFilesystem;