PS2: Optimise transform again

This commit is contained in:
UnknownShadow200 2024-06-22 23:45:20 +10:00
parent 3bfec7b607
commit 2ddedc3390
3 changed files with 42 additions and 20 deletions

View File

@ -13,7 +13,7 @@ DEPFILES := $(OBJS:%.o=%.d)
GLDC_LIB = third_party/gldc/libGLdc.a GLDC_LIB = third_party/gldc/libGLdc.a
LDFLAGS = -g LDFLAGS = -g
LIBS = -lm $(GLDC_LIB) -lppp -lkosfat LIBS = -lm $(GLDC_LIB) -lppp -lkosfat_dbg
ifeq ($(strip $(KOS_BASE)),) ifeq ($(strip $(KOS_BASE)),)
$(warning Please set KOS variables in your environment. For example:) $(warning Please set KOS variables in your environment. For example:)

View File

@ -502,6 +502,14 @@ void Gfx_CalcPerspectiveMatrix(struct Matrix* matrix, float fov, float aspect, f
/*########################################################################################################################* /*########################################################################################################################*
*---------------------------------------------------------Rendering-------------------------------------------------------* *---------------------------------------------------------Rendering-------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
typedef struct {
u32 rgba;
float q;
float u;
float v;
xyz_t xyz;
} __attribute__((packed,aligned(8))) TexturedVertex;
void Gfx_SetVertexFormat(VertexFormat fmt) { void Gfx_SetVertexFormat(VertexFormat fmt) {
gfx_format = fmt; gfx_format = fmt;
gfx_stride = strideSizes[fmt]; gfx_stride = strideSizes[fmt];
@ -593,27 +601,33 @@ static u64* DrawColouredTriangle(u64* dw, VU0_VECTOR* coords,
static u64* DrawTexturedTriangle(u64* dw, VU0_VECTOR* coords, static u64* DrawTexturedTriangle(u64* dw, VU0_VECTOR* coords,
struct VertexTextured* V0, struct VertexTextured* V1, struct VertexTextured* V2) { struct VertexTextured* V0, struct VertexTextured* V1, struct VertexTextured* V2) {
struct VertexTextured* v[] = { V0, V1, V2 }; TexturedVertex* dst = (TexturedVertex*)dw;
float Q;
// TODO optimise // TODO optimise
// Add the "primitives" to the GIF packet // Add the "primitives" to the GIF packet
for (int i = 0; i < 3; i++) Q = 1.0f / coords[0].w;
{ dst[0].rgba = V0->Col;
float Q = 1.0f / coords[i].w; dst[0].q = Q;
xyz_t xyz = FinishVertex(coords[i], Q); dst[0].u = V0->U * Q;
color_t color; dst[0].v = V0->V * Q;
texel_t texel; dst[0].xyz = FinishVertex(coords[0], Q);
color.rgbaq = v[i]->Col; Q = 1.0f / coords[1].w;
color.q = Q; dst[1].rgba = V1->Col;
texel.u = v[i]->U * Q; dst[1].q = Q;
texel.v = v[i]->V * Q; dst[1].u = V1->U * Q;
dst[1].v = V1->V * Q;
*dw++ = color.rgbaq; dst[1].xyz = FinishVertex(coords[1], Q);
*dw++ = texel.uv;
*dw++ = xyz.xyz; Q = 1.0f / coords[2].w;
} dst[2].rgba = V2->Col;
return dw; dst[2].q = Q;
dst[2].u = V2->U * Q;
dst[2].v = V2->V * Q;
dst[2].xyz = FinishVertex(coords[2], Q);
return dw + 9;
} }
extern void TransformTexturedQuad(void* src, VU0_VECTOR* dst, VU0_VECTOR* tmp, int* clip_flags); extern void TransformTexturedQuad(void* src, VU0_VECTOR* dst, VU0_VECTOR* tmp, int* clip_flags);

View File

@ -201,6 +201,10 @@ cc_result Directory_Create(const cc_filepath* path) {
// Filesystem returns EINVAL when operation unsupported (e.g. CD system) // Filesystem returns EINVAL when operation unsupported (e.g. CD system)
// so rather than logging an error, just pretend it already exists // so rather than logging an error, just pretend it already exists
if (err == EINVAL) err = EEXIST; if (err == EINVAL) err = EEXIST;
// Changes are cached in memory, sync to SD card
// TODO maybe use fs_shutdown/fs_unmount and only sync once??
if (!err) fs_fat_sync("/sd");
return err; return err;
} }
@ -294,6 +298,10 @@ cc_result File_Close(cc_file file) {
if (file == vmu_write_FD) if (file == vmu_write_FD)
return VMUFile_Close(file); return VMUFile_Close(file);
// Changes are cached in memory, sync to SD card
// TODO maybe use fs_shutdown/fs_unmount and only sync once??
if (!Platform_ReadonlyFilesystem) fs_fat_sync("/sd");
int res = fs_close(file); int res = fs_close(file);
return res == -1 ? errno : 0; return res == -1 ? errno : 0;
} }
@ -547,7 +555,7 @@ static void InitSDCard(void) {
cc_filepath* root = FILEPATH_RAW("/sd/ClassiCube"); cc_filepath* root = FILEPATH_RAW("/sd/ClassiCube");
int res = Directory_Create(root); int res = Directory_Create(root);
Platform_Log1("ROOT DIRECTORY CREATE %i", &res); Platform_Log1("ROOT DIRECTORY CREATE: %i", &res);
} }
static void InitModem(void) { static void InitModem(void) {