DS: Try to avoid loading unnecessary textures into VRAM, slightly optimise matrix loading

This commit is contained in:
UnknownShadow200 2024-08-30 08:14:24 +10:00
parent 8c4e42a43b
commit 3e2b0ea9d4
7 changed files with 26 additions and 22 deletions

View File

@ -12,7 +12,7 @@
#include "Options.h" #include "Options.h"
#include "Logger.h" #include "Logger.h"
#ifdef CC_BUILD_ANIMATIONS #ifndef CC_DISABLE_ANIMATIONS
static void Animations_Update(int loc, struct Bitmap* bmp, int stride); static void Animations_Update(int loc, struct Bitmap* bmp, int stride);
#ifdef CC_BUILD_LOWMEM #ifdef CC_BUILD_LOWMEM

View File

@ -158,8 +158,6 @@ typedef cc_uint8 cc_bool;
#define CC_BUILD_FREETYPE #define CC_BUILD_FREETYPE
#define CC_BUILD_RESOURCES #define CC_BUILD_RESOURCES
#define CC_BUILD_PLUGINS #define CC_BUILD_PLUGINS
#define CC_BUILD_ANIMATIONS
#define CC_BUILD_HELDBLOCK
#define CC_BUILD_FILESYSTEM #define CC_BUILD_FILESYSTEM
#define CC_BUILD_ADVLIGHTING #define CC_BUILD_ADVLIGHTING
/*#define CC_BUILD_GL11*/ /*#define CC_BUILD_GL11*/
@ -402,7 +400,8 @@ typedef cc_uint8 cc_bool;
#define CC_BUILD_TOUCH #define CC_BUILD_TOUCH
#define CC_BUILD_SMALLSTACK #define CC_BUILD_SMALLSTACK
#define DEFAULT_NET_BACKEND CC_NET_BACKEND_BUILTIN #define DEFAULT_NET_BACKEND CC_NET_BACKEND_BUILTIN
#undef CC_BUILD_ANIMATIONS /* Very costly in FPU less system */ #define CC_DISABLE_ANIMATIONS /* Very costly in FPU less system */
#define CC_BUILD_LOW_VRAM /* Only ~640 kb of VRAM */
#undef CC_BUILD_ADVLIGHTING #undef CC_BUILD_ADVLIGHTING
#elif defined __WIIU__ #elif defined __WIIU__
#define CC_BUILD_WIIU #define CC_BUILD_WIIU
@ -432,8 +431,8 @@ typedef cc_uint8 cc_bool;
#define CC_BUILD_NOSOUNDS #define CC_BUILD_NOSOUNDS
#undef CC_BUILD_RESOURCES #undef CC_BUILD_RESOURCES
#undef CC_BUILD_NETWORKING #undef CC_BUILD_NETWORKING
#undef CC_BUILD_ANIMATIONS /* Very costly in FPU less system */ #define CC_DISABLE_ANIMATIONS /* Very costly in FPU less system */
#undef CC_BUILD_HELDBLOCK /* Very costly in FPU less system */ #define CC_DISABLE_HELDBLOCK /* Very costly in FPU less system */
#undef CC_BUILD_ADVLIGHTING #undef CC_BUILD_ADVLIGHTING
#undef CC_BUILD_FILESYSTEM #undef CC_BUILD_FILESYSTEM
#elif defined OS2 #elif defined OS2
@ -455,8 +454,8 @@ typedef cc_uint8 cc_bool;
#define CC_BUILD_TINYSTACK #define CC_BUILD_TINYSTACK
#undef CC_BUILD_RESOURCES #undef CC_BUILD_RESOURCES
#undef CC_BUILD_NETWORKING #undef CC_BUILD_NETWORKING
#undef CC_BUILD_ANIMATIONS /* Very costly in FPU less system */ #define CC_DISABLE_ANIMATIONS /* Very costly in FPU less system */
#undef CC_BUILD_HELDBLOCK /* Very costly in FPU less system */ #define CC_DISABLE_HELDBLOCK /* Very costly in FPU less system */
#undef CC_BUILD_ADVLIGHTING #undef CC_BUILD_ADVLIGHTING
#undef CC_BUILD_FILESYSTEM #undef CC_BUILD_FILESYSTEM
#endif #endif

View File

@ -916,10 +916,12 @@ static void OnInit(void) {
EnvRenderer_Legacy = flags & ENV_LEGACY; EnvRenderer_Legacy = flags & ENV_LEGACY;
EnvRenderer_Minimal = flags & ENV_MINIMAL; EnvRenderer_Minimal = flags & ENV_MINIMAL;
#ifndef CC_BUILD_LOW_VRAM
TextureEntry_Register(&clouds_entry); TextureEntry_Register(&clouds_entry);
TextureEntry_Register(&skybox_entry); TextureEntry_Register(&skybox_entry);
TextureEntry_Register(&snow_entry); TextureEntry_Register(&snow_entry);
TextureEntry_Register(&rain_entry); TextureEntry_Register(&rain_entry);
#endif
Event_Register_(&TextureEvents.PackChanged, NULL, OnTexturePackChanged); Event_Register_(&TextureEvents.PackChanged, NULL, OnTexturePackChanged);
Event_Register_(&TextureEvents.AtlasChanged, NULL, OnTerrainAtlasChanged); Event_Register_(&TextureEvents.AtlasChanged, NULL, OnTerrainAtlasChanged);

View File

@ -401,22 +401,24 @@ static int matrix_modes[] = { GL_PROJECTION, GL_MODELVIEW, GL_TEXTURE };
static int lastMatrix; static int lastMatrix;
void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) { void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) {
if (type != lastMatrix) { lastMatrix = type; glMatrixMode(matrix_modes[type]); } if (type != lastMatrix) {
lastMatrix = type;
MATRIX_CONTROL = matrix_modes[type];
}
// loads 4x4 identity matrix
if (matrix == &Matrix_Identity) { if (matrix == &Matrix_Identity) {
glLoadIdentity(); MATRIX_IDENTITY = 0;
return; return;
// TODO still scale? // TODO still scale?
} }
m4x4 m; // loads 4x4 matrix from memory
const float* src = (const float*)matrix; const float* src = (const float*)matrix;
for (int i = 0; i < 4 * 4; i++) for (int i = 0; i < 4 * 4; i++)
{ {
m.m[i] = floattof32(src[i]); MATRIX_LOAD4x4 = floattof32(src[i]);
} }
glLoadMatrix4x4(&m);
// Vertex commands are signed 16 bit values, with 12 bits fractional // Vertex commands are signed 16 bit values, with 12 bits fractional
// aka only from -8.0 to 8.0 // aka only from -8.0 to 8.0

View File

@ -11,7 +11,7 @@
#include "Options.h" #include "Options.h"
cc_bool HeldBlockRenderer_Show; cc_bool HeldBlockRenderer_Show;
#ifdef CC_BUILD_HELDBLOCK #ifndef CC_DISABLE_HELDBLOCK
static BlockID held_block; static BlockID held_block;
static struct Entity held_entity; static struct Entity held_entity;
static struct Matrix held_blockProj; static struct Matrix held_blockProj;

View File

@ -122,8 +122,9 @@ void Platform_EncodePath(cc_filepath* dst, const cc_string* path) {
cc_result Directory_Create(const cc_filepath* path) { cc_result Directory_Create(const cc_filepath* path) {
if (!fat_available) return 0; if (!fat_available) return 0;
Platform_Log1("mkdir %c", path->buffer); int ret = mkdir(path->buffer, 0) == -1 ? errno : 0;
return mkdir(path->buffer, 0) == -1 ? errno : 0; Platform_Log2("mkdir %c = %i", path->buffer, &ret);
return ret;
} }
int File_Exists(const cc_filepath* path) { int File_Exists(const cc_filepath* path) {