Downsize big char arrays in shader structs - a lot of these get

allocated on the stack so this would cost a lot of memory
This commit is contained in:
libretroadmin 2024-09-10 07:03:10 +02:00
parent cfbfd01f38
commit 046c2375e7
2 changed files with 13 additions and 4 deletions

View File

@ -178,7 +178,7 @@ struct video_shader_pass
char *vertex; /* Dynamically allocated. Must be free'd. */ char *vertex; /* Dynamically allocated. Must be free'd. */
char *fragment; /* Dynamically allocated. Must be free'd. */ char *fragment; /* Dynamically allocated. Must be free'd. */
} string; } string;
char path[PATH_MAX_LENGTH]; char path[NAME_MAX_LENGTH*2];
} source; } source;
char alias[64]; char alias[64];
uint8_t flags; uint8_t flags;
@ -189,7 +189,7 @@ struct video_shader_lut
unsigned filter; unsigned filter;
enum gfx_wrap_type wrap; enum gfx_wrap_type wrap;
char id[64]; char id[64];
char path[PATH_MAX_LENGTH]; char path[NAME_MAX_LENGTH*2];
bool mipmap; bool mipmap;
}; };

View File

@ -139,6 +139,14 @@ static INLINE bool bits_any_different(uint32_t *a, uint32_t *b, uint32_t count)
#define DIR_MAX_LENGTH 256 #define DIR_MAX_LENGTH 256
#endif #endif
/**
* An upper limit for the length of a file or directory (excluding parent directories).
* If a path has a component longer than this, it may not work properly.
*/
#ifndef NAME_MAX_LENGTH
#define NAME_MAX_LENGTH 128
#endif
#else #else
#ifndef PATH_MAX_LENGTH #ifndef PATH_MAX_LENGTH
@ -149,8 +157,6 @@ static INLINE bool bits_any_different(uint32_t *a, uint32_t *b, uint32_t count)
#define DIR_MAX_LENGTH 1024 #define DIR_MAX_LENGTH 1024
#endif #endif
#endif
/** /**
* An upper limit for the length of a file or directory (excluding parent directories). * An upper limit for the length of a file or directory (excluding parent directories).
* If a path has a component longer than this, it may not work properly. * If a path has a component longer than this, it may not work properly.
@ -159,6 +165,9 @@ static INLINE bool bits_any_different(uint32_t *a, uint32_t *b, uint32_t count)
#define NAME_MAX_LENGTH 256 #define NAME_MAX_LENGTH 256
#endif #endif
#endif
#ifndef MAX #ifndef MAX
/** /**
* @return \c a or \c b, whichever is larger. * @return \c a or \c b, whichever is larger.