[sldev] Re: Reformatting Textures for the cache
Argent Stonecutter
secret.argent at gmail.com
Thu Mar 22 14:51:54 PDT 2007
> There must be the impression that when the word "database" is used
> that
> a "relational database" is the assumption such that "or whatever
> database" does not imply otherwise for such meaning.
Well, I guess if you'd said "Relational (or whatever)" instead of
"SQL (or whatever)", it might have been a bit more obvious.
Anyway, setting that aside... coming up with a database format that's
better than one file per object is not obviously going to be easy.
The old VFS cache *is* such a database, and it wasn't better than
files... and it's not that critical to even try initially. Using the
file *model* gives you a lot of flexibility, even if you decide to
cache many small images in one file you can do that without making
that decision visible very high up the tree...
typedef struct {
FILE *fp;
off_t off;
off_t start;
off_t end;
} MY_FILE;
MY_FILE *my_fopen(char *filename, char *mode)
{
MY_FILE *fp = ckalloc(sizeof *fp);
char *cache_file;
off_t end;
off_t start;
// If it's in the fast cache, it's a small fixed-size read-only
file, use that.
if(mode[0] == 'r' && lookup(filename, &cache_fp, &cache_file,
&start, &end))
{
if(cache_file != NULL) cache_fp = ckfopen(filename, mode);
fp->fp = cache_fp;
fp->off = fp->start = start;
fp->end = end;
return fp;
}
fp->fp = ckfopen(filename, mode);
fp->off = fp-start = -1L;
fp->end = -1L;
return fp;
}
...
More information about the SLDev
mailing list