silence gl enging output unless you set EVAS_GL_INFO in env. move some

fixed numbers into env vars for tuning purposes and debugging ... and
importantly - fix a smooth vs non-smooth texture mode thing.



SVN revision: 51651
This commit is contained in:
Carsten Haitzler 2010-08-26 01:41:48 +00:00
parent d8002ff386
commit 9d7a3a2bfc
5 changed files with 164 additions and 87 deletions

View File

@ -98,9 +98,6 @@
#define SHAD_TEXUV2 3
#define SHAD_TEXUV3 4
#define MAX_CUTOUT 512
#define MAX_PIPES 128
typedef struct _Evas_GL_Program Evas_GL_Program;
typedef struct _Evas_GL_Program_Source Evas_GL_Program_Source;
typedef struct _Evas_GL_Shared Evas_GL_Shared;
@ -138,8 +135,47 @@ struct _Evas_GL_Shared
Eina_Bool tex_rect : 1;
Eina_Bool sec_image_map : 1;
// tuning params - per gpu/cpu combo?
int cutout_max;
int pipes_max;
#define MAX_CUTOUT 512
#define DEF_CUTOUT 512
#define MAX_PIPES 128
#define DEF_PIPES 32
#define DEF_PIPES_SGX_540 32
#define DEF_PIPES_TEGRA_2 1
#define MIN_ATLAS_ALLOC 16
#define MAX_ATLAS_ALLOC 1024
#define DEF_ATLAS_ALLOC 1024
#define MIN_ATLAS_ALLOC_ALPHA 16
#define MAX_ATLAS_ALLOC_ALPHA 4096
#define DEF_ATLAS_ALLOC_ALPHA 4096
#define MAX_ATLAS_W 512
#define DEF_ATLAS_W 512
#define MAX_ATLAS_H 512
#define DEF_ATLAS_H 512
#define MIN_ATLAS_SLOT 16
#define MAX_ATLAS_SLOT 512
#define DEF_ATLAS_SLOT 16
struct {
struct {
int max;
} cutout;
struct {
int max;
} pipes;
struct {
int max_alloc_size;
int max_alloc_alpha_size;
int max_w;
int max_h;
int slot_size;
} atlas;
} tune;
} info;
struct {

View File

@ -437,7 +437,8 @@ evas_gl_common_context_new(void)
ext = glGetString(GL_EXTENSIONS);
if (ext)
{
fprintf(stderr, "EXT:\n%s\n", ext);
if (getenv("EVAS_GL_INFO"))
fprintf(stderr, "EXT:\n%s\n", ext);
if ((strstr((char *)ext, "GL_ARB_texture_non_power_of_two")) ||
(strstr((char *)ext, "OES_texture_npot")) ||
(strstr((char *)ext, "GL_IMG_texture_npot")))
@ -483,53 +484,76 @@ evas_gl_common_context_new(void)
// magic numbers that are a result of imperical testing and getting
// "best case" performance across a range of systems
shared->info.cutout_max = 512;
shared->info.pipes_max = 32;
shared->info.tune.cutout.max = DEF_CUTOUT;
shared->info.tune.pipes.max = DEF_PIPES;
shared->info.tune.atlas.max_alloc_size = DEF_ATLAS_ALLOC;
shared->info.tune.atlas.max_alloc_alpha_size = DEF_ATLAS_ALLOC_ALPHA;
shared->info.tune.atlas.max_w = DEF_ATLAS_W;
shared->info.tune.atlas.max_h = DEF_ATLAS_H;
shared->info.tune.atlas.slot_size = DEF_ATLAS_SLOT;
// per gpu hacks. based on impirical measurement of some known gpu's
s = (const char *)glGetString(GL_RENDERER);
if (s)
{
if (strstr(s, "PowerVR SGX 540"))
shared->info.pipes_max = 32;
shared->info.tune.pipes.max = DEF_PIPES_SGX_540;
else if (strstr(s, "NVIDIA Tegra"))
shared->info.pipes_max = 1;
shared->info.tune.pipes.max = DEF_PIPES_TEGRA_2;
}
if (getenv("EVAS_GL_CUTOUT_MAX"))
shared->info.cutout_max = atoi(getenv("EVAS_GL_CUTOUT_MAX"));
if (getenv("EVAS_GL_PIPES_MAX"))
{
shared->info.pipes_max = atoi(getenv("EVAS_GL_PIPES_MAX"));
if (shared->info.pipes_max > MAX_PIPES)
shared->info.pipes_max = MAX_PIPES;
else if (shared->info.pipes_max < 1)
shared->info.pipes_max = 1;
}
fprintf(stderr,
"max tex size %ix%i\n"
"max units %i\n"
"non-power-2 tex %i\n"
"rect tex %i\n"
"bgra : %i\n"
"max ansiotropic filtering: %3.3f\n"
"egl sec map image: %i\n"
"\n"
"cutout max: %i\n"
"pipes max: %i\n"
,
(int)shared->info.max_texture_size, (int)shared->info.max_texture_size,
(int)shared->info.max_texture_units,
(int)shared->info.tex_npo2,
(int)shared->info.tex_rect,
(int)shared->info.bgra,
(double)shared->info.anisotropic,
(int)shared->info.sec_image_map,
(int)shared->info.cutout_max,
(int)shared->info.pipes_max
);
#define GETENVOPT(name, tune_param, min, max) \
do { \
const char *__v = getenv(name); \
if (__v) { \
shared->info.tune.tune_param = atoi(__v); \
if (shared->info.tune.tune_param > max) \
shared->info.tune.tune_param = max; \
else if (shared->info.tune.tune_param < min) \
shared->info.tune.tune_param = min; \
} \
} while (0)
GETENVOPT("EVAS_GL_CUTOUT_MAX", cutout.max, -1, 0x7fffffff);
GETENVOPT("EVAS_GL_PIPES_MAX", pipes.max, 1, MAX_PIPES);
GETENVOPT("EVAS_GL_ATLAS_ALLOC_SIZE", atlas.max_alloc_size, MIN_ATLAS_ALLOC, MAX_ATLAS_ALLOC);
GETENVOPT("EVAS_GL_ATLAS_ALLOC_ALPHA_SIZE", atlas.max_alloc_alpha_size, MIN_ATLAS_ALLOC_ALPHA, MAX_ATLAS_ALLOC_ALPHA);
GETENVOPT("EVAS_GL_ATLAS_MAX_W", atlas.max_w, 0, MAX_ATLAS_W);
GETENVOPT("EVAS_GL_ATLAS_MAX_H", atlas.max_h, 0, MAX_ATLAS_H);
GETENVOPT("EVAS_GL_ATLAS_SLOT_SIZE", atlas.slot_size, MIN_ATLAS_SLOT, MAX_ATLAS_SLOT);
if (getenv("EVAS_GL_INFO"))
fprintf(stderr,
"max tex size %ix%i\n"
"max units %i\n"
"non-power-2 tex %i\n"
"rect tex %i\n"
"bgra : %i\n"
"max ansiotropic filtering: %3.3f\n"
"egl sec map image: %i\n"
"\n"
"EVAS_GL_CUTOUT_MAX: %i\n"
"EVAS_GL_PIPES_MAX: %i\n"
"EVAS_GL_ATLAS_ALLOC_SIZE: %i\n"
"EVAS_GL_ATLAS_ALLOC_ALPHA_SIZE: %i\n"
"EVAS_GL_ATLAS_MAX_W x EVAS_GL_ATLAS_MAX_H: %i x %i\n"
"EVAS_GL_ATLAS_SLOT_SIZE: %i\n"
,
(int)shared->info.max_texture_size, (int)shared->info.max_texture_size,
(int)shared->info.max_texture_units,
(int)shared->info.tex_npo2,
(int)shared->info.tex_rect,
(int)shared->info.bgra,
(double)shared->info.anisotropic,
(int)shared->info.sec_image_map,
(int)shared->info.tune.cutout.max,
(int)shared->info.tune.pipes.max,
(int)shared->info.tune.atlas.max_alloc_size,
(int)shared->info.tune.atlas.max_alloc_alpha_size,
(int)shared->info.tune.atlas.max_w, (int)shared->info.tune.atlas.max_h,
(int)shared->info.tune.atlas.slot_size
);
glDisable(GL_DEPTH_TEST);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
@ -662,7 +686,7 @@ evas_gl_common_context_free(Evas_GL_Context *gc)
if (gc->shared)
{
for (i = 0; i < gc->shared->info.pipes_max; i++)
for (i = 0; i < gc->shared->info.tune.pipes.max; i++)
{
if (gc->pipe[i].array.vertex) free(gc->pipe[i].array.vertex);
if (gc->pipe[i].array.color) free(gc->pipe[i].array.color);
@ -752,7 +776,7 @@ evas_gl_common_context_newframe(Evas_GL_Context *gc)
gc->state.current.cw = 0;
gc->state.current.ch = 0;
for (i = 0; i < gc->shared->info.pipes_max; i++)
for (i = 0; i < gc->shared->info.tune.pipes.max; i++)
{
gc->pipe[i].region.x = 0;
gc->pipe[i].region.y = 0;
@ -1094,7 +1118,7 @@ again:
if (!found)
{
pn = gc->state.top_pipe + 1;
if (pn >= gc->shared->info.pipes_max)
if (pn >= gc->shared->info.tune.pipes.max)
{
shader_array_flush(gc);
goto again;
@ -1269,7 +1293,7 @@ again:
if (!found)
{
pn = gc->state.top_pipe + 1;
if (pn >= gc->shared->info.pipes_max)
if (pn >= gc->shared->info.tune.pipes.max)
{
shader_array_flush(gc);
goto again;
@ -1467,7 +1491,7 @@ again:
if (!found)
{
pn = gc->state.top_pipe + 1;
if (pn >= gc->shared->info.pipes_max)
if (pn >= gc->shared->info.tune.pipes.max)
{
shader_array_flush(gc);
goto again;
@ -1637,7 +1661,7 @@ again:
if (!found)
{
pn = gc->state.top_pipe + 1;
if (pn >= gc->shared->info.pipes_max)
if (pn >= gc->shared->info.tune.pipes.max)
{
shader_array_flush(gc);
goto again;
@ -1889,7 +1913,7 @@ again:
if (!found)
{
pn = gc->state.top_pipe + 1;
if (pn >= gc->shared->info.pipes_max)
if (pn >= gc->shared->info.tune.pipes.max)
{
shader_array_flush(gc);
goto again;
@ -2048,7 +2072,7 @@ shader_array_flush(Evas_GL_Context *gc)
{
int i;
for (i = 0; i < gc->shared->info.pipes_max; i++)
for (i = 0; i < gc->shared->info.tune.pipes.max; i++)
{
if (gc->pipe[i].array.num <= 0) break;
@ -2141,7 +2165,8 @@ shader_array_flush(Evas_GL_Context *gc)
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
}
}
if (gc->pipe[i].shader.smooth != gc->state.current.smooth)
if ((gc->pipe[i].shader.smooth != gc->state.current.smooth) ||
(gc->pipe[i].shader.cur_tex != gc->state.current.cur_tex))
{
if (gc->pipe[i].shader.smooth)
{

View File

@ -527,8 +527,8 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy
im->tex->im = im;
if ((!gc->dc->cutout.rects) ||
((gc->shared->info.cutout_max > 0) &&
(gc->dc->cutout.active > gc->shared->info.cutout_max)))
((gc->shared->info.tune.cutout.max > 0) &&
(gc->dc->cutout.active > gc->shared->info.tune.cutout.max)))
{
if (gc->dc->clip.use)
{

View File

@ -53,7 +53,8 @@ _tex_round_slot(Evas_GL_Context *gc, int h)
{
if (!gc->shared->info.tex_npo2)
h = _nearest_pow2(h);
return (h + 15) >> 4;
return (h + gc->shared->info.tune.atlas.slot_size - 1) /
gc->shared->info.tune.atlas.slot_size;
}
static int
@ -99,7 +100,7 @@ _pool_tex_new(Evas_GL_Context *gc, int w, int h, int intformat, int format)
pt = calloc(1, sizeof(Evas_GL_Texture_Pool));
if (!pt) return NULL;
h = _tex_round_slot(gc, h) << 4;
h = _tex_round_slot(gc, h) * gc->shared->info.tune.atlas.slot_size;
_tex_adjust(gc, &w, &h);
pt->gc = gc;
pt->w = w;
@ -180,7 +181,10 @@ _pool_tex_find(Evas_GL_Context *gc, int w, int h,
Eina_List *l;
int th, th2;
if ((w > 512) || (h > 512))
if (atlas_w > gc->shared->info.max_texture_size)
atlas_w = gc->shared->info.max_texture_size;
if ((w > gc->shared->info.tune.atlas.max_w) ||
(h > gc->shared->info.tune.atlas.max_h))
{
pt = _pool_tex_new(gc, w, h, intformat, format);
gc->shared->tex.whole = eina_list_prepend(gc->shared->tex.whole, pt);
@ -233,30 +237,35 @@ evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im)
if (im->cache_entry.flags.alpha)
{
if (gc->shared->info.bgra)
tex->pt = _pool_tex_find(gc, im->cache_entry.w + 2,
im->cache_entry.h + 1, bgra_ifmt, bgra_fmt,
&u, &v, &l_after, 1024);
tex->pt = _pool_tex_find(gc, im->cache_entry.w + 2,
im->cache_entry.h + 1, bgra_ifmt, bgra_fmt,
&u, &v, &l_after,
gc->shared->info.tune.atlas.max_alloc_alpha_size);
else
tex->pt = _pool_tex_find(gc, im->cache_entry.w + 2,
im->cache_entry.h + 1, rgba_ifmt, rgba_fmt,
&u, &v, &l_after, 1024);
tex->pt = _pool_tex_find(gc, im->cache_entry.w + 2,
im->cache_entry.h + 1, rgba_ifmt, rgba_fmt,
&u, &v, &l_after,
gc->shared->info.tune.atlas.max_alloc_alpha_size);
tex->alpha = 1;
}
else
{
if (gc->shared->info.bgra)
tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3,
im->cache_entry.h + 1, bgr_ifmt, bgr_fmt,
&u, &v, &l_after, 1024);
tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3,
im->cache_entry.h + 1, bgr_ifmt, bgr_fmt,
&u, &v, &l_after,
gc->shared->info.tune.atlas.max_alloc_size);
else
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3,
im->cache_entry.h + 1, rgba_ifmt, rgba_fmt,
&u, &v, &l_after, 1024);
tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3,
im->cache_entry.h + 1, rgba_ifmt, rgba_fmt,
&u, &v, &l_after,
gc->shared->info.tune.atlas.max_alloc_size);
#else
tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3,
im->cache_entry.h + 1, rgb_ifmt, rgb_fmt,
&u, &v, &l_after, 1024);
tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3,
im->cache_entry.h + 1, rgb_ifmt, rgb_fmt,
&u, &v, &l_after,
gc->shared->info.tune.atlas.max_alloc_size);
#endif
}
if (!tex->pt)
@ -287,7 +296,7 @@ _pool_tex_render_new(Evas_GL_Context *gc, int w, int h, int intformat, int forma
pt = calloc(1, sizeof(Evas_GL_Texture_Pool));
if (!pt) return NULL;
h = _tex_round_slot(gc, h) << 4;
h = _tex_round_slot(gc, h) * gc->shared->info.tune.atlas.slot_size;
_tex_adjust(gc, &w, &h);
pt->gc = gc;
pt->w = w;
@ -414,7 +423,8 @@ _pool_tex_dynamic_new(Evas_GL_Context *gc, int w, int h, int intformat, int form
pt = calloc(1, sizeof(Evas_GL_Texture_Pool));
if (!pt) return NULL;
h = _tex_round_slot(gc, h) << 4;
// no atlas pools/sharing here
// h = _tex_round_slot(gc, h) * gc->shared->info.tune.atlas.slot_size;
_tex_adjust(gc, &w, &h);
pt->gc = gc;
pt->w = w;
@ -801,20 +811,21 @@ evas_gl_common_texture_alpha_new(Evas_GL_Context *gc, DATA8 *pixels,
Evas_GL_Texture *tex;
Eina_List *l_after = NULL;
int u = 0, v = 0;
int tw = 4096;
tex = calloc(1, sizeof(Evas_GL_Texture));
if (!tex) return NULL;
tex->gc = gc;
tex->references = 1;
if (tw > gc->shared->info.max_texture_size)
tw = gc->shared->info.max_texture_size;
tex->pt = _pool_tex_find(gc, w + 3, fh, alpha_ifmt, alpha_fmt, &u, &v,
&l_after, tw);
&l_after,
gc->shared->info.tune.atlas.max_alloc_alpha_size);
if (!tex->pt)
{
memset(tex, 0x66, sizeof(Evas_GL_Texture)); // mark as freed
// FIXME: mark as freed for now with 0x66, but this is me TRYING to
// find some mysterious bug i simply have been unable to catch or
// reproduce - so leave a trail and see how it goes.
memset(tex, 0x66, sizeof(Evas_GL_Texture));
free(tex);
return NULL;
}

View File

@ -210,9 +210,12 @@ eng_window_new(Display *disp,
if (!vendor) vendor = "-UNKNOWN-";
if (!renderer) renderer = "-UNKNOWN-";
if (!version) version = "-UNKNOWN-";
fprintf(stderr, "vendor: %s\n", vendor);
fprintf(stderr, "renderer: %s\n", renderer);
fprintf(stderr, "version: %s\n", version);
if (getenv("EVAS_GL_INFO"))
{
fprintf(stderr, "vendor: %s\n", vendor);
fprintf(stderr, "renderer: %s\n", renderer);
fprintf(stderr, "version: %s\n", version);
}
// GLX
#else
@ -284,10 +287,12 @@ eng_window_new(Display *disp,
renderer = glGetString(GL_RENDERER);
version = glGetString(GL_VERSION);
fprintf(stderr, "vendor: %s\n", vendor);
fprintf(stderr, "renderer: %s\n", renderer);
fprintf(stderr, "version: %s\n", version);
if (getenv("EVAS_GL_INFO"))
{
fprintf(stderr, "vendor: %s\n", vendor);
fprintf(stderr, "renderer: %s\n", renderer);
fprintf(stderr, "version: %s\n", version);
}
if (strstr(vendor, "NVIDIA"))
// FIXME: also same as tegra2 - maybe check renderer too
//