summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongyeon Kim <dy5.kim@samsung.com>2015-05-27 09:11:23 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-06-03 11:30:22 +0900
commit25822405a4ba2e20d770eea37808fb6a7465836e (patch)
tree00ca8a16f7f67731730eddc46d801e513bd8c00c
parent3e39bf36389fdbc8a3f84521410f6c996a64a22d (diff)
evas/gl_common: Reset mvp matrix only for shaders that are being used
Summary: Evas has quite a number of shaders, and resetting the projection matrix for all shaders takes some time, which is an overhead when target surface is continuously being changed (ie. when using proxy). So here we reset the projection matrix for shaders that are actually used.
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h6
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c29
2 files changed, 24 insertions, 11 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 877842a3f7..3ee8c5b0e1 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -343,6 +343,7 @@ struct _Evas_GL_Program
343 GLuint vert, frag, prog; 343 GLuint vert, frag, prog;
344 344
345 int tex_count; 345 int tex_count;
346 Eina_Bool reset;
346}; 347};
347 348
348struct _Evas_GL_Program_Source 349struct _Evas_GL_Program_Source
@@ -444,6 +445,7 @@ struct _Evas_GL_Shared
444 // persp map 445 // persp map
445 int foc, z0, px, py; 446 int foc, z0, px, py;
446 int ax, ay; 447 int ax, ay;
448 GLfloat proj[16];
447}; 449};
448 450
449typedef enum _Shader_Sampling Shader_Sampling; 451typedef enum _Shader_Sampling Shader_Sampling;
@@ -492,7 +494,7 @@ struct _Evas_Engine_GL_Context
492 struct { 494 struct {
493 int top_pipe; 495 int top_pipe;
494 struct { 496 struct {
495 Evas_GL_Shader id; // debug info 497 Evas_GL_Shader id;
496 GLuint cur_prog; 498 GLuint cur_prog;
497 GLuint cur_tex, cur_texu, cur_texv, cur_texa, cur_texm; 499 GLuint cur_tex, cur_texu, cur_texv, cur_texa, cur_texm;
498 int render_op; 500 int render_op;
@@ -520,7 +522,7 @@ struct _Evas_Engine_GL_Context
520 Eina_Bool active : 1; 522 Eina_Bool active : 1;
521 } clip; 523 } clip;
522 struct { 524 struct {
523 Evas_GL_Shader id; // debug info 525 Evas_GL_Shader id;
524 Evas_GL_Image *surface; 526 Evas_GL_Image *surface;
525 GLuint cur_prog; 527 GLuint cur_prog;
526 GLuint cur_tex, cur_texu, cur_texv, cur_texa, cur_texm; 528 GLuint cur_tex, cur_texu, cur_texv, cur_texa, cur_texm;
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 eed625bd0e..9a1ef99ed7 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -482,7 +482,6 @@ _evas_gl_common_version_check(int *gles_ver)
482static void 482static void
483_evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc) 483_evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc)
484{ 484{
485 GLfloat proj[16];
486 unsigned int i; 485 unsigned int i;
487 int w = 1, h = 1, m = 1, rot = 1, foc = 0; 486 int w = 1, h = 1, m = 1, rot = 1, foc = 0;
488 487
@@ -539,14 +538,14 @@ _evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc)
539 glViewport(0, 0, h, w); 538 glViewport(0, 0, h, w);
540 // std matrix 539 // std matrix
541 if (m == 1) 540 if (m == 1)
542 matrix_ortho(proj, 541 matrix_ortho(gc->shared->proj,
543 0, w, 0, h, 542 0, w, 0, h,
544 -1000000.0, 1000000.0, 543 -1000000.0, 1000000.0,
545 rot, w, h, 544 rot, w, h,
546 1, 1.0); 545 1, 1.0);
547 // v flipped matrix for render-to-texture 546 // v flipped matrix for render-to-texture
548 else 547 else
549 matrix_ortho(proj, 548 matrix_ortho(gc->shared->proj,
550 0, w, h, 0, 549 0, w, h, 0,
551 -1000000.0, 1000000.0, 550 -1000000.0, 1000000.0,
552 rot, w, h, 551 rot, w, h,
@@ -602,12 +601,12 @@ _evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc)
602 else 601 else
603 glViewport(-2 * vy, -2 * vx, vh, vw); 602 glViewport(-2 * vy, -2 * vx, vh, vw);
604 if (m == 1) 603 if (m == 1)
605 matrix_ortho(proj, 0, vw, 0, vh, 604 matrix_ortho(gc->shared->proj, 0, vw, 0, vh,
606 -1000000.0, 1000000.0, 605 -1000000.0, 1000000.0,
607 rot, vw, vh, 606 rot, vw, vh,
608 foc, 0.0); 607 foc, 0.0);
609 else 608 else
610 matrix_ortho(proj, 0, vw, vh, 0, 609 matrix_ortho(gc->shared->proj, 0, vw, vh, 0,
611 -1000000.0, 1000000.0, 610 -1000000.0, 1000000.0,
612 rot, vw, vh, 611 rot, vw, vh,
613 foc, 0.0); 612 foc, 0.0);
@@ -617,13 +616,20 @@ _evas_gl_common_viewport_set(Evas_Engine_GL_Context *gc)
617 616
618 for (i = 0; i < SHADER_LAST; ++i) 617 for (i = 0; i < SHADER_LAST; ++i)
619 { 618 {
620 glUseProgram(gc->shared->shader[i].prog); 619 gc->shared->shader[i].reset = EINA_TRUE;
621 glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader[i].prog, "mvp"), 1, GL_FALSE, proj);
622 } 620 }
623 621
624 if (gc->state.current.cur_prog == PRG_INVALID) 622 if (gc->state.current.cur_prog == PRG_INVALID)
625 glUseProgram(gc->shared->shader[0].prog); 623 {
626 else glUseProgram(gc->state.current.cur_prog); 624 glUseProgram(gc->shared->shader[0].prog);
625 glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader[0].prog, "mvp"), 1, GL_FALSE, gc->shared->proj);
626 gc->shared->shader[0].reset = EINA_FALSE;
627 }
628 else
629 {
630 glUseProgram(gc->state.current.cur_prog);
631 glUniformMatrix4fv(glGetUniformLocation(gc->state.current.cur_prog, "mvp"), 1, GL_FALSE, gc->shared->proj);
632 }
627} 633}
628 634
629EAPI Evas_Engine_GL_Context * 635EAPI Evas_Engine_GL_Context *
@@ -3044,6 +3050,11 @@ shader_array_flush(Evas_Engine_GL_Context *gc)
3044 if (gc->pipe[i].shader.cur_prog != gc->state.current.cur_prog) 3050 if (gc->pipe[i].shader.cur_prog != gc->state.current.cur_prog)
3045 { 3051 {
3046 glUseProgram(gc->pipe[i].shader.cur_prog); 3052 glUseProgram(gc->pipe[i].shader.cur_prog);
3053 if (gc->shared->shader[gc->pipe[i].shader.id].reset)
3054 {
3055 glUniformMatrix4fv(glGetUniformLocation(gc->pipe[i].shader.cur_prog, "mvp"), 1, GL_FALSE, gc->shared->proj);
3056 gc->shared->shader[gc->pipe[i].shader.id].reset = EINA_FALSE;
3057 }
3047 } 3058 }
3048 3059
3049 if (gc->pipe[i].shader.cur_tex != gc->state.current.cur_tex) 3060 if (gc->pipe[i].shader.cur_tex != gc->state.current.cur_tex)