mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 17:47:12 -04:00
PS2: Optimise transform again
This commit is contained in:
parent
3bfec7b607
commit
2ddedc3390
@ -13,7 +13,7 @@ DEPFILES := $(OBJS:%.o=%.d)
|
||||
|
||||
GLDC_LIB = third_party/gldc/libGLdc.a
|
||||
LDFLAGS = -g
|
||||
LIBS = -lm $(GLDC_LIB) -lppp -lkosfat
|
||||
LIBS = -lm $(GLDC_LIB) -lppp -lkosfat_dbg
|
||||
|
||||
ifeq ($(strip $(KOS_BASE)),)
|
||||
$(warning Please set KOS variables in your environment. For example:)
|
||||
|
@ -502,6 +502,14 @@ void Gfx_CalcPerspectiveMatrix(struct Matrix* matrix, float fov, float aspect, f
|
||||
/*########################################################################################################################*
|
||||
*---------------------------------------------------------Rendering-------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
typedef struct {
|
||||
u32 rgba;
|
||||
float q;
|
||||
float u;
|
||||
float v;
|
||||
xyz_t xyz;
|
||||
} __attribute__((packed,aligned(8))) TexturedVertex;
|
||||
|
||||
void Gfx_SetVertexFormat(VertexFormat fmt) {
|
||||
gfx_format = 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,
|
||||
struct VertexTextured* V0, struct VertexTextured* V1, struct VertexTextured* V2) {
|
||||
struct VertexTextured* v[] = { V0, V1, V2 };
|
||||
TexturedVertex* dst = (TexturedVertex*)dw;
|
||||
float Q;
|
||||
|
||||
// TODO optimise
|
||||
// Add the "primitives" to the GIF packet
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
float Q = 1.0f / coords[i].w;
|
||||
xyz_t xyz = FinishVertex(coords[i], Q);
|
||||
color_t color;
|
||||
texel_t texel;
|
||||
|
||||
color.rgbaq = v[i]->Col;
|
||||
color.q = Q;
|
||||
texel.u = v[i]->U * Q;
|
||||
texel.v = v[i]->V * Q;
|
||||
|
||||
*dw++ = color.rgbaq;
|
||||
*dw++ = texel.uv;
|
||||
*dw++ = xyz.xyz;
|
||||
}
|
||||
return dw;
|
||||
Q = 1.0f / coords[0].w;
|
||||
dst[0].rgba = V0->Col;
|
||||
dst[0].q = Q;
|
||||
dst[0].u = V0->U * Q;
|
||||
dst[0].v = V0->V * Q;
|
||||
dst[0].xyz = FinishVertex(coords[0], Q);
|
||||
|
||||
Q = 1.0f / coords[1].w;
|
||||
dst[1].rgba = V1->Col;
|
||||
dst[1].q = Q;
|
||||
dst[1].u = V1->U * Q;
|
||||
dst[1].v = V1->V * Q;
|
||||
dst[1].xyz = FinishVertex(coords[1], Q);
|
||||
|
||||
Q = 1.0f / coords[2].w;
|
||||
dst[2].rgba = V2->Col;
|
||||
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);
|
||||
|
@ -201,6 +201,10 @@ cc_result Directory_Create(const cc_filepath* path) {
|
||||
// Filesystem returns EINVAL when operation unsupported (e.g. CD system)
|
||||
// so rather than logging an error, just pretend it already exists
|
||||
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;
|
||||
}
|
||||
|
||||
@ -294,6 +298,10 @@ cc_result File_Close(cc_file file) {
|
||||
if (file == vmu_write_FD)
|
||||
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);
|
||||
return res == -1 ? errno : 0;
|
||||
}
|
||||
@ -547,7 +555,7 @@ static void InitSDCard(void) {
|
||||
|
||||
cc_filepath* root = FILEPATH_RAW("/sd/ClassiCube");
|
||||
int res = Directory_Create(root);
|
||||
Platform_Log1("ROOT DIRECTORY CREATE %i", &res);
|
||||
Platform_Log1("ROOT DIRECTORY CREATE: %i", &res);
|
||||
}
|
||||
|
||||
static void InitModem(void) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user