From 1a81f0a8c205b89fd8d21e0e9033e6a04ae7cf4f Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Fri, 3 May 2013 19:31:28 +0900 Subject: [PATCH] force scissor to always be on indicating partial gl update region so gpu can.. do more sensible things. --- .../evas/engines/gl_common/evas_gl_common.h | 5 + .../evas/engines/gl_common/evas_gl_context.c | 104 ++++++++++++------ src/modules/evas/engines/gl_x11/evas_engine.c | 6 + 3 files changed, 84 insertions(+), 31 deletions(-) diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h index 1bffda531c..b3b8b24796 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_common.h +++ b/src/modules/evas/engines/gl_common/evas_gl_common.h @@ -350,6 +350,11 @@ struct _Evas_Engine_GL_Context int clip; } current; } state; + + struct { + int x, y, w, h; + Eina_Bool enabled : 1; + } master_clip; struct { struct { diff --git a/src/modules/evas/engines/gl_common/evas_gl_context.c b/src/modules/evas/engines/gl_common/evas_gl_context.c index f936bc349a..2f7302771c 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_context.c +++ b/src/modules/evas/engines/gl_common/evas_gl_context.c @@ -2571,7 +2571,7 @@ scissor_rot(Evas_Engine_GL_Context *gc EINA_UNUSED, static void shader_array_flush(Evas_Engine_GL_Context *gc) { - int i, gw, gh, setclip, cy, fbo = 0, done = 0; + int i, gw, gh, setclip, fbo = 0, done = 0; if (!gc->havestuff) return; gw = gc->w; @@ -2719,47 +2719,89 @@ shader_array_flush(Evas_Engine_GL_Context *gc) } if (gc->pipe[i].shader.clip != gc->state.current.clip) { - - if (gc->pipe[i].shader.clip) + int cx, cy, cw, ch; + + cx = gc->pipe[i].shader.cx; + cy = gc->pipe[i].shader.cy; + cw = gc->pipe[i].shader.cw; + ch = gc->pipe[i].shader.ch; + if ((gc->master_clip.enabled) && (!fbo)) + { + if (gc->pipe[i].shader.clip) + { + RECTS_CLIP_TO_RECT(cx, cy, cw, ch, + gc->master_clip.x, gc->master_clip.y, + gc->master_clip.w, gc->master_clip.h); + } + else + { + cx = gc->master_clip.x; + cy = gc->master_clip.y; + cw = gc->master_clip.w; + ch = gc->master_clip.h; + } + } + if ((gc->pipe[i].shader.clip) || (gc->master_clip.enabled)) { - cy = gh - gc->pipe[i].shader.cy - gc->pipe[i].shader.ch; - if (fbo) cy = gc->pipe[i].shader.cy; glEnable(GL_SCISSOR_TEST); if (!fbo) - scissor_rot(gc, gc->rot, gw, gh, - gc->pipe[i].shader.cx, - cy, - gc->pipe[i].shader.cw, - gc->pipe[i].shader.ch); + scissor_rot(gc, gc->rot, gw, gh, cx, gh - cy - ch, cw, ch); else - glScissor(gc->pipe[i].shader.cx, cy, - gc->pipe[i].shader.cw, gc->pipe[i].shader.ch); + glScissor(cx, cy, cw, ch); setclip = 1; + gc->state.current.cx = cx; + gc->state.current.cy = cy; + gc->state.current.cw = cw; + gc->state.current.ch = ch; } else { glDisable(GL_SCISSOR_TEST); glScissor(0, 0, 0, 0); + gc->state.current.cx = 0; + gc->state.current.cy = 0; + gc->state.current.cw = 0; + gc->state.current.ch = 0; } } - if ((gc->pipe[i].shader.clip) && (!setclip)) + if (((gc->pipe[i].shader.clip) && (!setclip)) || + (gc->master_clip.enabled)) { - if ((gc->pipe[i].shader.cx != gc->state.current.cx) || - (gc->pipe[i].shader.cy != gc->state.current.cy) || - (gc->pipe[i].shader.cw != gc->state.current.cw) || - (gc->pipe[i].shader.ch != gc->state.current.ch)) + int cx, cy, cw, ch; + + cx = gc->pipe[i].shader.cx; + cy = gc->pipe[i].shader.cy; + cw = gc->pipe[i].shader.cw; + ch = gc->pipe[i].shader.ch; + if ((gc->master_clip.enabled) && (!fbo)) { - cy = gh - gc->pipe[i].shader.cy - gc->pipe[i].shader.ch; - if (fbo) cy = gc->pipe[i].shader.cy; - if (!fbo) - scissor_rot(gc, gc->rot, gw, gh, - gc->pipe[i].shader.cx, - cy, - gc->pipe[i].shader.cw, - gc->pipe[i].shader.ch); + if (gc->pipe[i].shader.clip) + { + RECTS_CLIP_TO_RECT(cx, cy, cw, ch, + gc->master_clip.x, gc->master_clip.y, + gc->master_clip.w, gc->master_clip.h); + } else - glScissor(gc->pipe[i].shader.cx, cy, - gc->pipe[i].shader.cw, gc->pipe[i].shader.ch); + { + cx = gc->master_clip.x; + cy = gc->master_clip.y; + cw = gc->master_clip.w; + ch = gc->master_clip.h; + } + } + if ((cx != gc->state.current.cx) || + (cy != gc->state.current.cy) || + (cw != gc->state.current.cw) || + (ch != gc->state.current.ch)) + { + if (!fbo) + scissor_rot(gc, gc->rot, gw, gh, cx, gh - cy - ch, cw, ch); + else + glScissor(cx, cy, cw, ch); + gc->state.current.cx = cx; + gc->state.current.cy = cy; + gc->state.current.cw = cw; + gc->state.current.ch = ch; } } @@ -2976,10 +3018,10 @@ shader_array_flush(Evas_Engine_GL_Context *gc) gc->state.current.cur_prog = gc->pipe[i].shader.cur_prog; gc->state.current.cur_tex = gc->pipe[i].shader.cur_tex; gc->state.current.render_op = gc->pipe[i].shader.render_op; - gc->state.current.cx = gc->pipe[i].shader.cx; - gc->state.current.cy = gc->pipe[i].shader.cy; - gc->state.current.cw = gc->pipe[i].shader.cw; - gc->state.current.ch = gc->pipe[i].shader.ch; +// gc->state.current.cx = gc->pipe[i].shader.cx; +// gc->state.current.cy = gc->pipe[i].shader.cy; +// gc->state.current.cw = gc->pipe[i].shader.cw; +// gc->state.current.ch = gc->pipe[i].shader.ch; gc->state.current.smooth = gc->pipe[i].shader.smooth; gc->state.current.blend = gc->pipe[i].shader.blend; gc->state.current.clip = gc->pipe[i].shader.clip; diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c index 1785fa57b2..75da4b93f3 100644 --- a/src/modules/evas/engines/gl_x11/evas_engine.c +++ b/src/modules/evas/engines/gl_x11/evas_engine.c @@ -1314,6 +1314,11 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i *cw = rect->w; *ch = rect->h; re->cur_rect = re->cur_rect->next; + re->win->gl_context->master_clip.enabled = EINA_TRUE; + re->win->gl_context->master_clip.x = rect->x; + re->win->gl_context->master_clip.y = rect->y; + re->win->gl_context->master_clip.w = rect->w; + re->win->gl_context->master_clip.h = rect->h; break; case MODE_FULL: re->cur_rect = NULL; @@ -1325,6 +1330,7 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i if (cy) *cy = 0; if (cw) *cw = re->win->w; if (ch) *ch = re->win->h; + re->win->gl_context->master_clip.enabled = EINA_FALSE; break; default: break;