static const GLenum lum_fmt = GL_LUMINANCE;
static const GLenum lum_ifmt = GL_LUMINANCE;
+static struct {
+ struct {
+ int num, pix;
+ } c, a, v, r, n, d;
+} texinfo = {0};
+
+static int
+_print_tex_count(void)
+{
+ if (getenv("EVAS_GL_MEMINFO"))
+ {
+ fprintf(stderr,
+ "T: c:%i/%ik | a:%i/%ik | v:%i/%ik | r:%i/%ik | n:%i/%ik | d:%i/%ik\n",
+ texinfo.c.num, (texinfo.c.pix * 4) / 1024,
+ texinfo.a.num, (texinfo.a.pix ) / 1024,
+ texinfo.v.num, (texinfo.v.pix ) / 1024,
+ texinfo.r.num, (texinfo.r.pix * 4) / 1024,
+ texinfo.n.num, (texinfo.n.pix * 4) / 1024,
+ texinfo.d.num, (texinfo.d.pix * 4) / 1024
+ );
+ }
+}
+
static int
_nearest_pow2(int num)
{
pt->format = format;
pt->dataformat = GL_UNSIGNED_BYTE;
pt->references = 0;
+
+ if (format == alpha_fmt)
+ {
+ texinfo.a.num++;
+ texinfo.a.pix += pt->w * pt->h;
+ }
+ else if (format == lum_fmt)
+ {
+ texinfo.v.num++;
+ texinfo.v.pix += pt->w * pt->h;
+ }
+ else
+ {
+ texinfo.c.num++;
+ texinfo.c.pix += pt->w * pt->h;
+ }
+
+ _print_tex_count();
+
glGenTextures(1, &(pt->texture));
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glBindTexture(GL_TEXTURE_2D, pt->texture);
# define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
# endif
#endif
+ texinfo.r.num++;
+ texinfo.r.pix += pt->w * pt->h;
+
+ _print_tex_count();
+
glGenTextures(1, &(pt->texture));
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glBindTexture(GL_TEXTURE_2D, pt->texture);
if (im->native.target == GL_TEXTURE_RECTANGLE_ARB)
{
printf("REEEEEEEEECT\n");
+ pt->w = w;
+ pt->h = h;
}
else
#endif
pt->dataformat = GL_UNSIGNED_BYTE;
pt->references = 0;
pt->native = 1;
+ texinfo.n.num++;
+ texinfo.n.pix += pt->w * pt->h;
+
+ _print_tex_count();
+
glGenTextures(1, &(pt->texture));
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glBindTexture(im->native.target, pt->texture);
pt->dataformat = GL_UNSIGNED_BYTE;
pt->render = 1;
pt->references = 0;
+ texinfo.d.num++;
+ texinfo.d.pix += pt->w * pt->h;
+
+ _print_tex_count();
+
glGenTextures(1, &(pt->texture));
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glBindTexture(GL_TEXTURE_2D, pt->texture);
{
pt->references--;
if (pt->references != 0) return;
+
+ if (pt->format == alpha_fmt)
+ {
+ texinfo.a.num--;
+ texinfo.a.pix -= pt->w * pt->h;
+ }
+ else if (pt->format == lum_fmt)
+ {
+ texinfo.v.num--;
+ texinfo.v.pix -= pt->w * pt->h;
+ }
+ else if (pt->dyn.img)
+ {
+ texinfo.d.num--;
+ texinfo.d.pix -= pt->w * pt->h;
+ }
+ else if (pt->render)
+ {
+ texinfo.r.num--;
+ texinfo.r.pix -= pt->w * pt->h;
+ }
+ else if (pt->native)
+ {
+ texinfo.n.num--;
+ texinfo.n.pix -= pt->w * pt->h;
+ }
+ else
+ {
+ texinfo.c.num--;
+ texinfo.c.pix -= pt->w * pt->h;
+ }
+
+ _print_tex_count();
+
if (!((pt->render) || (pt->native)))
{
if (pt->whole)