summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaeKwang Ryu <dkdk.ryu@samsung.com>2015-11-11 11:36:42 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-11-11 14:35:50 +0900
commit5ccd7830697b45480bfd4fbef455a07a1f222dca (patch)
tree47ce47b4b9c6255a60ddb022b3a3c93a494b59eb
parent25bcf4c64f0f694c538bf35fa37096387d4ca5a7 (diff)
Evas GL: implement GLES2/GLES3 wrapper functions
Summary: I found some bugs in EvasGL with OpenGL ES conformance test. 6 wrapper functions are added for GLES2, (glDeleteFramebuffers, glFramebufferRenderbuffer glFramebufferTexture2D, glGetError glGetFloatv, glGetFramebufferAttachmentParameteriv) 3 wrapper fucntions are added for GLES3. (glDrawbuffers, glGetStringi, glReadBuffer) Test Plan: GLES3 sample app, EvasGL(OpenGL ES CTS) for 2.0 is passed. For 3.0, 10 TCs are failed (Total : 2994TCs). Reviewers: wonsik, spacegrapher, jpeg Subscribers: cedric, JoogabYun, scholb.kim Maniphest Tasks: T2621 Differential Revision: https://phab.enlightenment.org/D3301
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api.c839
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api_def.h12
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api_ext.c37
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api_ext.h2
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api_gles3_def.h7
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h2
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core.c258
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core_private.h5
8 files changed, 1025 insertions, 137 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api.c b/src/modules/evas/engines/gl_common/evas_gl_api.c
index a97204e..44a87cc 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_api.c
@@ -14,6 +14,13 @@
14#define EVGLD_FUNC_END() GLERRV(__FUNCTION__) 14#define EVGLD_FUNC_END() GLERRV(__FUNCTION__)
15#define _EVGL_INT_INIT_VALUE -3 15#define _EVGL_INT_INIT_VALUE -3
16 16
17#define SET_GL_ERROR(gl_error_type) \
18 if (ctx->gl_error == GL_NO_ERROR) \
19 { \
20 ctx->gl_error = glGetError(); \
21 if (ctx->gl_error == GL_NO_ERROR) ctx->gl_error = gl_error_type; \
22 }
23
17static void *_gles3_handle = NULL; 24static void *_gles3_handle = NULL;
18static Evas_GL_API _gles3_api; 25static Evas_GL_API _gles3_api;
19//---------------------------------------// 26//---------------------------------------//
@@ -80,42 +87,120 @@ _evgl_glBindFramebuffer(GLenum target, GLuint framebuffer)
80 } 87 }
81 88
82 // Take care of BindFramebuffer 0 issue 89 // Take care of BindFramebuffer 0 issue
83 if (framebuffer==0) 90 if (ctx->version == EVAS_GL_GLES_2_X)
84 { 91 {
85 if (_evgl_direct_enabled()) 92 if (framebuffer==0)
86 { 93 {
87 glBindFramebuffer(target, 0); 94 if (_evgl_direct_enabled())
88
89 if (rsc->direct.partial.enabled)
90 { 95 {
91 if (!ctx->partial_render) 96 glBindFramebuffer(target, 0);
97
98 if (rsc->direct.partial.enabled)
92 { 99 {
93 evgl_direct_partial_render_start(); 100 if (!ctx->partial_render)
94 ctx->partial_render = 1; 101 {
102 evgl_direct_partial_render_start();
103 ctx->partial_render = 1;
104 }
95 } 105 }
96 } 106 }
107 else
108 {
109 glBindFramebuffer(target, ctx->surface_fbo);
110 }
111 ctx->current_fbo = 0;
97 } 112 }
98 else 113 else
99 { 114 {
100 glBindFramebuffer(target, ctx->surface_fbo); 115 if (_evgl_direct_enabled())
116 {
117 if (ctx->current_fbo == 0)
118 {
119 if (rsc->direct.partial.enabled)
120 evgl_direct_partial_render_end();
121 }
122 }
123
124 glBindFramebuffer(target, framebuffer);
125
126 // Save this for restore when doing make current
127 ctx->current_fbo = framebuffer;
101 } 128 }
102 ctx->current_fbo = 0;
103 } 129 }
104 else 130 else if (ctx->version == EVAS_GL_GLES_3_X)
105 { 131 {
106 if (_evgl_direct_enabled()) 132 if (target == GL_FRAMEBUFFER || target == GL_DRAW_FRAMEBUFFER)
107 { 133 {
108 if (ctx->current_fbo == 0) 134 if (framebuffer==0)
109 { 135 {
110 if (rsc->direct.partial.enabled) 136 if (_evgl_direct_enabled())
111 evgl_direct_partial_render_end(); 137 {
138 glBindFramebuffer(target, 0);
139
140 if (rsc->direct.partial.enabled)
141 {
142 if (!ctx->partial_render)
143 {
144 evgl_direct_partial_render_start();
145 ctx->partial_render = 1;
146 }
147 }
148 }
149 else
150 {
151 glBindFramebuffer(target, ctx->surface_fbo);
152 }
153 ctx->current_draw_fbo = 0;
154
155 if (target == GL_FRAMEBUFFER)
156 ctx->current_read_fbo = 0;
112 } 157 }
113 } 158 else
159 {
160 if (_evgl_direct_enabled())
161 {
162 if (ctx->current_draw_fbo == 0)
163 {
164 if (rsc->direct.partial.enabled)
165 evgl_direct_partial_render_end();
166 }
167 }
168
169 glBindFramebuffer(target, framebuffer);
114 170
115 glBindFramebuffer(target, framebuffer); 171 // Save this for restore when doing make current
172 ctx->current_draw_fbo = framebuffer;
173
174 if (target == GL_FRAMEBUFFER)
175 ctx->current_read_fbo = framebuffer;
176 }
177 }
178 else if (target == GL_READ_FRAMEBUFFER)
179 {
180 if (framebuffer==0)
181 {
182 if (_evgl_direct_enabled())
183 {
184 glBindFramebuffer(target, 0);
185 }
186 else
187 {
188 glBindFramebuffer(target, ctx->surface_fbo);
189 }
190 ctx->current_read_fbo = 0;
191 }
192 else
193 {
194 glBindFramebuffer(target, framebuffer);
116 195
117 // Save this for restore when doing make current 196 // Save this for restore when doing make current
118 ctx->current_fbo = framebuffer; 197 ctx->current_read_fbo = framebuffer;
198 }
199 }
200 else
201 {
202 glBindFramebuffer(target, framebuffer);
203 }
119 } 204 }
120} 205}
121 206
@@ -130,6 +215,61 @@ _evgl_glClearDepthf(GLclampf depth)
130} 215}
131 216
132void 217void
218_evgl_glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
219{
220 EVGL_Context *ctx;
221 int i;
222
223 ctx = evas_gl_common_current_context_get();
224 if (!ctx)
225 {
226 ERR("Unable to retrive Current Context");
227 return;
228 }
229
230 if (!framebuffers)
231 {
232 glDeleteFramebuffers(n, framebuffers);
233 return;
234 }
235
236 if (!_evgl_direct_enabled())
237 {
238 if (ctx->version == EVAS_GL_GLES_2_X)
239 {
240 for (i = 0; i < n; i++)
241 {
242 if (framebuffers[i] == ctx->current_fbo)
243 {
244 glBindFramebuffer(GL_FRAMEBUFFER, ctx->surface_fbo);
245 ctx->current_fbo = 0;
246 break;
247 }
248 }
249 }
250 else if (ctx->version == EVAS_GL_GLES_3_X)
251 {
252 for (i = 0; i < n; i++)
253 {
254 if (framebuffers[i] == ctx->current_draw_fbo)
255 {
256 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ctx->surface_fbo);
257 ctx->current_draw_fbo = 0;
258 }
259
260 if (framebuffers[i] == ctx->current_read_fbo)
261 {
262 glBindFramebuffer(GL_READ_FRAMEBUFFER, ctx->surface_fbo);
263 ctx->current_read_fbo = 0;
264 }
265 }
266 }
267 }
268
269 glDeleteFramebuffers(n, framebuffers);
270}
271
272void
133_evgl_glDepthRangef(GLclampf zNear, GLclampf zFar) 273_evgl_glDepthRangef(GLclampf zNear, GLclampf zFar)
134{ 274{
135#ifdef GL_GLES 275#ifdef GL_GLES
@@ -139,6 +279,34 @@ _evgl_glDepthRangef(GLclampf zNear, GLclampf zFar)
139#endif 279#endif
140} 280}
141 281
282GLenum
283_evgl_glGetError(void)
284{
285 GLenum ret;
286 EVGL_Context *ctx = evas_gl_common_current_context_get();
287
288 if (!ctx)
289 {
290 ERR("No current context set.");
291 return GL_NO_ERROR;
292 }
293
294 if (ctx->gl_error != GL_NO_ERROR)
295 {
296 ret = ctx->gl_error;
297
298 //reset error state to GL_NO_ERROR. (EvasGL & Native GL)
299 ctx->gl_error = GL_NO_ERROR;
300 glGetError();
301
302 return ret;
303 }
304 else
305 {
306 return glGetError();
307 }
308}
309
142void 310void
143_evgl_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) 311_evgl_glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
144{ 312{
@@ -364,7 +532,8 @@ _evgl_glClear(GLbitfield mask)
364 532
365 if (_evgl_direct_enabled()) 533 if (_evgl_direct_enabled())
366 { 534 {
367 if (!(rsc->current_ctx->current_fbo)) 535 if ((!(rsc->current_ctx->current_fbo) && rsc->current_ctx->version == EVAS_GL_GLES_2_X) ||
536 (!(rsc->current_ctx->current_draw_fbo) && rsc->current_ctx->version == EVAS_GL_GLES_3_X))
368 { 537 {
369 /* Skip glClear() if clearing with transparent color 538 /* Skip glClear() if clearing with transparent color
370 * Note: There will be side effects if the object itself is not 539 * Note: There will be side effects if the object itself is not
@@ -471,7 +640,8 @@ _evgl_glEnable(GLenum cap)
471 640
472 if (rsc) 641 if (rsc)
473 { 642 {
474 if (!ctx->current_fbo) 643 if ((!ctx->current_fbo && ctx->version == EVAS_GL_GLES_2_X) ||
644 (!ctx->current_draw_fbo && ctx->version == EVAS_GL_GLES_3_X))
475 { 645 {
476 // Direct rendering to canvas 646 // Direct rendering to canvas
477 if (!ctx->scissor_updated) 647 if (!ctx->scissor_updated)
@@ -539,7 +709,8 @@ _evgl_glDisable(GLenum cap)
539 709
540 if (_evgl_direct_enabled()) 710 if (_evgl_direct_enabled())
541 { 711 {
542 if (!ctx->current_fbo) 712 if ((!ctx->current_fbo && ctx->version == EVAS_GL_GLES_2_X) ||
713 (!ctx->current_draw_fbo && ctx->version == EVAS_GL_GLES_3_X))
543 { 714 {
544 // Restore default scissors for direct rendering 715 // Restore default scissors for direct rendering
545 int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0}, cc[4] = {0,0,0,0}; 716 int oc[4] = {0,0,0,0}, nc[4] = {0,0,0,0}, cc[4] = {0,0,0,0};
@@ -576,73 +747,468 @@ _evgl_glDisable(GLenum cap)
576 glDisable(cap); 747 glDisable(cap);
577} 748}
578 749
750static void
751_evgl_glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
752{
753 EVGL_Resource *rsc;
754 EVGL_Context *ctx;
755
756 if (!(rsc=_evgl_tls_resource_get()))
757 {
758 ERR("Unable to execute GL command. Error retrieving tls");
759 return;
760 }
761
762 if (!rsc->current_eng)
763 {
764 ERR("Unable to retrive Current Engine");
765 return;
766 }
767
768 ctx = rsc->current_ctx;
769 if (!ctx)
770 {
771 ERR("Unable to retrive Current Context");
772 return;
773 }
774
775 if (!_evgl_direct_enabled())
776 {
777 if (ctx->version == EVAS_GL_GLES_2_X)
778 {
779 if (target == GL_FRAMEBUFFER && ctx->current_fbo == 0)
780 {
781 SET_GL_ERROR(GL_INVALID_OPERATION);
782 return;
783 }
784 }
785 else if (ctx->version == EVAS_GL_GLES_3_X)
786 {
787 if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER)
788 {
789 if (ctx->current_draw_fbo == 0)
790 {
791 SET_GL_ERROR(GL_INVALID_OPERATION);
792 return;
793 }
794 }
795 else if (target == GL_READ_FRAMEBUFFER)
796 {
797 if (ctx->current_read_fbo == 0)
798 {
799 SET_GL_ERROR(GL_INVALID_OPERATION);
800 return;
801 }
802 }
803 }
804 }
805
806 glFramebufferTexture2D(target, attachment, textarget, texture, level);
807}
808
809static void
810_evgl_glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
811{
812 EVGL_Resource *rsc;
813 EVGL_Context *ctx;
814
815 if (!(rsc=_evgl_tls_resource_get()))
816 {
817 ERR("Unable to execute GL command. Error retrieving tls");
818 return;
819 }
820
821 if (!rsc->current_eng)
822 {
823 ERR("Unable to retrive Current Engine");
824 return;
825 }
826
827 ctx = rsc->current_ctx;
828 if (!ctx)
829 {
830 ERR("Unable to retrive Current Context");
831 return;
832 }
833
834 if (!_evgl_direct_enabled())
835 {
836 if(ctx->version == EVAS_GL_GLES_2_X)
837 {
838 if (target == GL_FRAMEBUFFER && ctx->current_fbo == 0)
839 {
840 SET_GL_ERROR(GL_INVALID_OPERATION);
841 return;
842 }
843 }
844 else if(ctx->version == EVAS_GL_GLES_3_X)
845 {
846 if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER)
847 {
848 if (ctx->current_draw_fbo == 0)
849 {
850 SET_GL_ERROR(GL_INVALID_OPERATION);
851 return;
852 }
853 }
854 else if (target == GL_READ_FRAMEBUFFER)
855 {
856 if (ctx->current_read_fbo == 0)
857 {
858 SET_GL_ERROR(GL_INVALID_OPERATION);
859 return;
860 }
861 }
862 }
863 }
864
865 glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
866}
867
579void 868void
580_evgl_glGetIntegerv(GLenum pname, GLint* params) 869_evgl_glGetFloatv(GLenum pname, GLfloat* params)
581{ 870{
582 EVGL_Resource *rsc; 871 EVGL_Resource *rsc;
583 EVGL_Context *ctx; 872 EVGL_Context *ctx;
584 873
874 if (!params)
875 {
876 ERR("Invalid Parameter");
877 return;
878 }
879
880 if (!(rsc=_evgl_tls_resource_get()))
881 {
882 ERR("Unable to execute GL command. Error retrieving tls");
883 return;
884 }
885
886 ctx = rsc->current_ctx;
887 if (!ctx)
888 {
889 ERR("Unable to retrive Current Context");
890 return;
891 }
892
585 if (_evgl_direct_enabled()) 893 if (_evgl_direct_enabled())
586 { 894 {
587 if (!params) 895 if (ctx->version == EVAS_GL_GLES_2_X)
588 { 896 {
589 ERR("Invalid Parameter"); 897 // Only need to handle it if it's directly rendering to the window
590 return; 898 if (!(rsc->current_ctx->current_fbo))
899 {
900 if (pname == GL_SCISSOR_BOX)
901 {
902 if (ctx->scissor_updated)
903 {
904 params[0] = (GLfloat)ctx->scissor_coord[0];
905 params[1] = (GLfloat)ctx->scissor_coord[1];
906 params[2] = (GLfloat)ctx->scissor_coord[2];
907 params[3] = (GLfloat)ctx->scissor_coord[3];
908 return;
909 }
910 }
911 else if (pname == GL_VIEWPORT)
912 {
913 if (ctx->viewport_updated)
914 {
915 memcpy(params, ctx->viewport_coord, sizeof(int)*4);
916 return;
917 }
918 }
919
920 // If it hasn't been initialized yet, return img object size
921 if ((pname == GL_SCISSOR_BOX) || (pname == GL_VIEWPORT))
922 {
923 params[0] = (GLfloat)0.0;
924 params[1] = (GLfloat)0.0;
925 params[2] = (GLfloat)rsc->direct.img.w;
926 params[3] = (GLfloat)rsc->direct.img.h;
927 return;
928 }
929 }
591 } 930 }
931 else if (ctx->version == EVAS_GL_GLES_3_X)
932 {
933 // Only need to handle it if it's directly rendering to the window
934 if (!(rsc->current_ctx->current_draw_fbo))
935 {
936 if (pname == GL_SCISSOR_BOX)
937 {
938 if (ctx->scissor_updated)
939 {
940 params[0] = (GLfloat)ctx->scissor_coord[0];
941 params[1] = (GLfloat)ctx->scissor_coord[1];
942 params[2] = (GLfloat)ctx->scissor_coord[2];
943 params[3] = (GLfloat)ctx->scissor_coord[3];
944 return;
945 }
946 }
947 else if (pname == GL_VIEWPORT)
948 {
949 if (ctx->viewport_updated)
950 {
951 memcpy(params, ctx->viewport_coord, sizeof(int)*4);
952 return;
953 }
954 }
955 // If it hasn't been initialized yet, return img object size
956 if ((pname == GL_SCISSOR_BOX) )//|| (pname == GL_VIEWPORT))
957 {
958 params[0] = (GLfloat)0.0;
959 params[1] = (GLfloat)0.0;
960 params[2] = (GLfloat)rsc->direct.img.w;
961 params[3] = (GLfloat)rsc->direct.img.h;
962 return;
963 }
964 }
592 965
593 if (!(rsc=_evgl_tls_resource_get())) 966 if (pname == GL_NUM_EXTENSIONS)
967 {
968 *params = (GLfloat)evgl_api_ext_num_extensions_get(ctx->version);
969 return;
970 }
971 }
972 }
973 else
974 {
975 if (ctx->version == EVAS_GL_GLES_2_X)
594 { 976 {
595 ERR("Unable to execute GL command. Error retrieving tls"); 977 if (pname == GL_FRAMEBUFFER_BINDING)
596 return; 978 {
979 rsc = _evgl_tls_resource_get();
980 ctx = rsc ? rsc->current_ctx : NULL;
981 if (ctx)
982 {
983 *params = (GLfloat)ctx->current_fbo;
984 return;
985 }
986 }
597 } 987 }
988 else if (ctx->version == EVAS_GL_GLES_3_X)
989 {
990 if (pname == GL_DRAW_FRAMEBUFFER_BINDING || pname == GL_FRAMEBUFFER_BINDING)
991 {
992 *params = (GLfloat)ctx->current_draw_fbo;
993 return;
994 }
995 else if (pname == GL_READ_FRAMEBUFFER_BINDING)
996 {
997 *params = (GLfloat)ctx->current_read_fbo;
998 return;
999 }
1000 else if (pname == GL_READ_BUFFER)
1001 {
1002 if (ctx->current_read_fbo == 0)
1003 {
1004 glGetFloatv(pname, params);
1005 if (*params == GL_COLOR_ATTACHMENT0)
1006 {
1007 *params = (GLfloat)GL_BACK;
1008 return;
1009 }
1010 }
1011 }
1012 else if (pname == GL_NUM_EXTENSIONS)
1013 {
1014 *params = (GLfloat)evgl_api_ext_num_extensions_get(ctx->version);
1015 return;
1016 }
1017 }
1018 }
1019
1020 glGetFloatv(pname, params);
1021}
1022
1023void
1024_evgl_glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
1025{
1026 EVGL_Context *ctx;
1027
1028 ctx = evas_gl_common_current_context_get();
1029
1030 if (!ctx)
1031 {
1032 ERR("Unable to retrive Current Context");
1033 return;
1034 }
598 1035
599 ctx = rsc->current_ctx; 1036 if (!_evgl_direct_enabled())
600 if (!ctx) 1037 {
1038 if (ctx->version == EVAS_GL_GLES_2_X)
601 { 1039 {
602 ERR("Unable to retrive Current Context"); 1040 if (ctx->current_fbo == 0)
603 return; 1041 {
1042 SET_GL_ERROR(GL_INVALID_OPERATION);
1043 return;
1044 }
604 } 1045 }
1046 else if (ctx->version == EVAS_GL_GLES_3_X)
1047 {
1048 if (target == GL_DRAW_FRAMEBUFFER || target == GL_FRAMEBUFFER)
1049 {
1050 if (ctx->current_draw_fbo == 0 && attachment == GL_BACK)
1051 {
1052 glGetFramebufferAttachmentParameteriv(target, GL_COLOR_ATTACHMENT0, pname, params);
1053 return;
1054 }
1055 }
1056 else if (target == GL_READ_FRAMEBUFFER)
1057 {
1058 if (ctx->current_read_fbo == 0 && attachment == GL_BACK)
1059 {
1060 glGetFramebufferAttachmentParameteriv(target, GL_COLOR_ATTACHMENT0, pname, params);
1061 return;
1062 }
1063 }
1064 }
1065 }
1066
1067 glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
1068}
1069
1070void
1071_evgl_glGetIntegerv(GLenum pname, GLint* params)
1072{
1073 EVGL_Resource *rsc;
1074 EVGL_Context *ctx;
1075
1076 if (!params)
1077 {
1078 ERR("Invalid Parameter");
1079 return;
1080 }
605 1081
606 // Only need to handle it if it's directly rendering to the window 1082 if (!(rsc=_evgl_tls_resource_get()))
607 if (!(rsc->current_ctx->current_fbo)) 1083 {
1084 ERR("Unable to execute GL command. Error retrieving tls");
1085 return;
1086 }
1087
1088 ctx = rsc->current_ctx;
1089 if (!ctx)
1090 {
1091 ERR("Unable to retrive Current Context");
1092 return;
1093 }
1094
1095 if (_evgl_direct_enabled())
1096 {
1097 if (ctx->version == EVAS_GL_GLES_2_X)
608 { 1098 {
609 if (pname == GL_SCISSOR_BOX) 1099 // Only need to handle it if it's directly rendering to the window
1100 if (!(rsc->current_ctx->current_fbo))
610 { 1101 {
611 if (ctx->scissor_updated) 1102 if (pname == GL_SCISSOR_BOX)
612 { 1103 {
613 memcpy(params, ctx->scissor_coord, sizeof(int)*4); 1104 if (ctx->scissor_updated)
1105 {
1106 memcpy(params, ctx->scissor_coord, sizeof(int)*4);
1107 return;
1108 }
1109 }
1110 else if (pname == GL_VIEWPORT)
1111 {
1112 if (ctx->viewport_updated)
1113 {
1114 memcpy(params, ctx->viewport_coord, sizeof(int)*4);
1115 return;
1116 }
1117 }
1118
1119 // If it hasn't been initialized yet, return img object size
1120 if ((pname == GL_SCISSOR_BOX) || (pname == GL_VIEWPORT))
1121 {
1122 params[0] = 0;
1123 params[1] = 0;
1124 params[2] = (GLint)rsc->direct.img.w;
1125 params[3] = (GLint)rsc->direct.img.h;
614 return; 1126 return;
615 } 1127 }
616 } 1128 }
617 else if (pname == GL_VIEWPORT) 1129 }
1130 else if (ctx->version == EVAS_GL_GLES_3_X)
1131 {
1132 // Only need to handle it if it's directly rendering to the window
1133 if (!(rsc->current_ctx->current_draw_fbo))
618 { 1134 {
619 if (ctx->viewport_updated) 1135 if (pname == GL_SCISSOR_BOX)
1136 {
1137 if (ctx->scissor_updated)
1138 {
1139 memcpy(params, ctx->scissor_coord, sizeof(int)*4);
1140 return;
1141 }
1142 }
1143 else if (pname == GL_VIEWPORT)
1144 {
1145 if (ctx->viewport_updated)
1146 {
1147 memcpy(params, ctx->viewport_coord, sizeof(int)*4);
1148 return;
1149 }
1150 }
1151 // If it hasn't been initialized yet, return img object size
1152 if ((pname == GL_SCISSOR_BOX) )//|| (pname == GL_VIEWPORT))
620 { 1153 {
621 memcpy(params, ctx->viewport_coord, sizeof(int)*4); 1154 params[0] = 0;
1155 params[1] = 0;
1156 params[2] = (GLint)rsc->direct.img.w;
1157 params[3] = (GLint)rsc->direct.img.h;
622 return; 1158 return;
623 } 1159 }
624 } 1160 }
625 1161
626 // If it hasn't been initialized yet, return img object size 1162 if (pname == GL_NUM_EXTENSIONS)
627 if ((pname == GL_SCISSOR_BOX) || (pname == GL_VIEWPORT))
628 { 1163 {
629 params[0] = 0; 1164 *params = evgl_api_ext_num_extensions_get(ctx->version);
630 params[1] = 0;
631 params[2] = (GLint)rsc->direct.img.w;
632 params[3] = (GLint)rsc->direct.img.h;
633 return; 1165 return;
634 } 1166 }
635 } 1167 }
636 } 1168 }
637 else 1169 else
638 { 1170 {
639 if (pname == GL_FRAMEBUFFER_BINDING) 1171 if (ctx->version == EVAS_GL_GLES_2_X)
1172 {
1173 if (pname == GL_FRAMEBUFFER_BINDING)
1174 {
1175 rsc = _evgl_tls_resource_get();
1176 ctx = rsc ? rsc->current_ctx : NULL;
1177 if (ctx)
1178 {
1179 *params = ctx->current_fbo;
1180 return;
1181 }
1182 }
1183 }
1184 else if (ctx->version == EVAS_GL_GLES_3_X)
640 { 1185 {
641 rsc = _evgl_tls_resource_get(); 1186 if (pname == GL_DRAW_FRAMEBUFFER_BINDING || pname == GL_FRAMEBUFFER_BINDING)
642 ctx = rsc ? rsc->current_ctx : NULL; 1187 {
643 if (ctx) 1188 *params = ctx->current_draw_fbo;
1189 return;
1190 }
1191 else if (pname == GL_READ_FRAMEBUFFER_BINDING)
1192 {
1193 *params = ctx->current_read_fbo;
1194 return;
1195 }
1196 else if (pname == GL_READ_BUFFER)
1197 {
1198 if (ctx->current_read_fbo == 0)
1199 {
1200 glGetIntegerv(pname, params);
1201
1202 if (*params == GL_COLOR_ATTACHMENT0)
1203 {
1204 *params = GL_BACK;
1205 return;
1206 }
1207 }
1208 }
1209 else if (pname == GL_NUM_EXTENSIONS)
644 { 1210 {
645 *params = ctx->current_fbo; 1211 *params = evgl_api_ext_num_extensions_get(ctx->version);
646 return; 1212 return;
647 } 1213 }
648 } 1214 }
@@ -748,6 +1314,37 @@ _evgl_glGetString(GLenum name)
748 return glGetString(name); 1314 return glGetString(name);
749} 1315}
750 1316
1317static const GLubyte *
1318_evgl_glGetStringi(GLenum name, GLuint index)
1319{
1320 EVGL_Context *ctx;
1321
1322 ctx = evas_gl_common_current_context_get();
1323
1324 if (!ctx)
1325 {
1326 ERR("Unable to retrive Current Context");
1327 return NULL;
1328 }
1329
1330 switch (name)
1331 {
1332 case GL_EXTENSIONS:
1333 if (index < evgl_api_ext_num_extensions_get(ctx->version))
1334 {
1335 return (GLubyte *)evgl_api_ext_stringi_get(index, ctx->version);
1336 }
1337 else
1338 SET_GL_ERROR(GL_INVALID_VALUE);
1339 break;
1340 default:
1341 SET_GL_ERROR(GL_INVALID_ENUM);
1342 break;
1343 }
1344
1345 return NULL;
1346}
1347
751static void 1348static void
752_evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) 1349_evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
753{ 1350{
@@ -779,7 +1376,8 @@ _evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum forma
779 if (_evgl_direct_enabled()) 1376 if (_evgl_direct_enabled())
780 { 1377 {
781 1378
782 if (!(rsc->current_ctx->current_fbo)) 1379 if ((!(rsc->current_ctx->current_fbo) && rsc->current_ctx->version == EVAS_GL_GLES_2_X) ||
1380 (!(rsc->current_ctx->current_read_fbo) && rsc->current_ctx->version == EVAS_GL_GLES_3_X))
783 { 1381 {
784 compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h, 1382 compute_gl_coordinates(rsc->direct.win_w, rsc->direct.win_h,
785 rsc->direct.rot, 1, 1383 rsc->direct.rot, 1,
@@ -831,7 +1429,8 @@ _evgl_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
831 1429
832 if (_evgl_direct_enabled()) 1430 if (_evgl_direct_enabled())
833 { 1431 {
834 if (!(rsc->current_ctx->current_fbo)) 1432 if ((!(rsc->current_ctx->current_fbo) && rsc->current_ctx->version == EVAS_GL_GLES_2_X) ||
1433 (!(rsc->current_ctx->current_draw_fbo) && rsc->current_ctx->version == EVAS_GL_GLES_3_X))
835 { 1434 {
836 // Direct rendering to canvas 1435 // Direct rendering to canvas
837 if ((ctx->direct_scissor) && (!ctx->scissor_enabled)) 1436 if ((ctx->direct_scissor) && (!ctx->scissor_enabled))
@@ -918,7 +1517,8 @@ _evgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
918 1517
919 if (_evgl_direct_enabled()) 1518 if (_evgl_direct_enabled())
920 { 1519 {
921 if (!(rsc->current_ctx->current_fbo)) 1520 if ((!(rsc->current_ctx->current_fbo) && rsc->current_ctx->version == EVAS_GL_GLES_2_X) ||
1521 (!(rsc->current_ctx->current_draw_fbo) && rsc->current_ctx->version == EVAS_GL_GLES_3_X))
922 { 1522 {
923 if ((!ctx->direct_scissor)) 1523 if ((!ctx->direct_scissor))
924 { 1524 {
@@ -1002,6 +1602,100 @@ _evgl_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
1002 } 1602 }
1003} 1603}
1004 1604
1605static void
1606_evgl_glDrawBuffers(GLsizei n, const GLenum *bufs)
1607{
1608 EVGL_Context *ctx;
1609 Eina_Bool target_is_fbo = EINA_FALSE;
1610 unsigned int drawbuffer;
1611
1612 ctx = evas_gl_common_current_context_get();
1613 if (!ctx)
1614 {
1615 ERR("Unable to retrive Current Context");
1616 return;
1617 }
1618
1619 if (!bufs)
1620 {
1621 glDrawBuffers(n, bufs);
1622 return;
1623 }
1624
1625 if (!_evgl_direct_enabled())
1626 {
1627 if (ctx->current_draw_fbo == 0)
1628 target_is_fbo = EINA_TRUE;
1629 }
1630
1631 if (target_is_fbo)
1632 {
1633 if (n==1)
1634 {
1635 if (*bufs == GL_BACK)
1636 {
1637 drawbuffer = GL_COLOR_ATTACHMENT0;
1638 glDrawBuffers(n, &drawbuffer);
1639 }
1640 else if ((*bufs & GL_COLOR_ATTACHMENT0) == GL_COLOR_ATTACHMENT0)
1641 {
1642 SET_GL_ERROR(GL_INVALID_OPERATION);
1643 }
1644 else
1645 {
1646 glDrawBuffers(n, bufs);
1647 }
1648 }
1649 else
1650 {
1651 SET_GL_ERROR(GL_INVALID_OPERATION);
1652 }
1653 }
1654 else
1655 {
1656 glDrawBuffers(n, bufs);
1657 }
1658}
1659
1660static void
1661_evgl_glReadBuffer(GLenum src)
1662{
1663 EVGL_Context *ctx;
1664 Eina_Bool target_is_fbo = EINA_FALSE;
1665
1666 ctx = evas_gl_common_current_context_get();
1667 if (!ctx)
1668 {
1669 ERR("Unable to retrive Current Context");
1670 return;
1671 }
1672
1673 if (!_evgl_direct_enabled())
1674 {
1675 if (ctx->current_read_fbo == 0)
1676 target_is_fbo = EINA_TRUE;
1677 }
1678
1679 if (target_is_fbo)
1680 {
1681 if (src == GL_BACK)
1682 {
1683 glReadBuffer(GL_COLOR_ATTACHMENT0);
1684 }
1685 else if((src & GL_COLOR_ATTACHMENT0) == GL_COLOR_ATTACHMENT0)
1686 {
1687 SET_GL_ERROR(GL_INVALID_OPERATION);
1688 }
1689 else
1690 {
1691 glReadBuffer(src);
1692 }
1693 }
1694 else
1695 {
1696 glReadBuffer(src);
1697 }
1698}
1005 1699
1006//-------------------------------------------------------------// 1700//-------------------------------------------------------------//
1007// Open GLES 2.0 APIs 1701// Open GLES 2.0 APIs
@@ -1079,6 +1773,20 @@ static void _evgld_##name param1 { \
1079 1773
1080//-------------------------------------------------------------// 1774//-------------------------------------------------------------//
1081// Open GLES 3.0 APIs 1775// Open GLES 3.0 APIs
1776#define _EVASGL_FUNCTION_PRIVATE_BEGIN(ret, name, param1, param2) \
1777static ret evgl_gles3_##name param1 { \
1778 EVGL_FUNC_BEGIN(); \
1779 if (!_gles3_api.name) return (ret)0; \
1780 return _evgl_##name param2; \
1781}
1782
1783#define _EVASGL_FUNCTION_PRIVATE_BEGIN_VOID(name, param1, param2) \
1784static void evgl_gles3_##name param1 { \
1785 EVGL_FUNC_BEGIN(); \
1786 if (!_gles3_api.name) return; \
1787 _evgl_##name param2; \
1788}
1789
1082#define _EVASGL_FUNCTION_BEGIN(ret, name, param1, param2) \ 1790#define _EVASGL_FUNCTION_BEGIN(ret, name, param1, param2) \
1083static ret evgl_gles3_##name param1 { \ 1791static ret evgl_gles3_##name param1 { \
1084 EVGL_FUNC_BEGIN(); \ 1792 EVGL_FUNC_BEGIN(); \
@@ -1095,12 +1803,31 @@ static void evgl_gles3_##name param1 { \
1095 1803
1096#include "evas_gl_api_gles3_def.h" 1804#include "evas_gl_api_gles3_def.h"
1097 1805
1806#undef _EVASGL_FUNCTION_PRIVATE_BEGIN
1807#undef _EVASGL_FUNCTION_PRIVATE_BEGIN_VOID
1098#undef _EVASGL_FUNCTION_BEGIN 1808#undef _EVASGL_FUNCTION_BEGIN
1099#undef _EVASGL_FUNCTION_BEGIN_VOID 1809#undef _EVASGL_FUNCTION_BEGIN_VOID
1100 1810
1101 1811
1102//-------------------------------------------------------------// 1812//-------------------------------------------------------------//
1103// Open GLES 3.0 APIs DEBUG 1813// Open GLES 3.0 APIs DEBUG
1814#define _EVASGL_FUNCTION_PRIVATE_BEGIN(ret, name, param1, param2) \
1815static ret _evgld_##name param1 { \
1816 EVGLD_FUNC_BEGIN(); \
1817 if (!_gles3_api.name) return (ret)0; \
1818 ret _a = _evgl_##name param2; \
1819 EVGLD_FUNC_END(); \
1820 return _a; \
1821}
1822
1823#define _EVASGL_FUNCTION_PRIVATE_BEGIN_VOID(name, param1, param2) \
1824static void _evgld_##name param1 { \
1825 EVGLD_FUNC_BEGIN(); \
1826 if (!_gles3_api.name) return; \
1827 _evgl_##name param2; \
1828 EVGLD_FUNC_END(); \
1829}
1830
1104#define _EVASGL_FUNCTION_BEGIN(ret, name, param1, param2) \ 1831#define _EVASGL_FUNCTION_BEGIN(ret, name, param1, param2) \
1105static ret _evgld_##name param1 { \ 1832static ret _evgld_##name param1 { \
1106 EVGLD_FUNC_BEGIN(); \ 1833 EVGLD_FUNC_BEGIN(); \
@@ -1120,6 +1847,8 @@ static void _evgld_##name param1 { \
1120 1847
1121#include "evas_gl_api_gles3_def.h" 1848#include "evas_gl_api_gles3_def.h"
1122 1849
1850#undef _EVASGL_FUNCTION_PRIVATE_BEGIN
1851#undef _EVASGL_FUNCTION_PRIVATE_BEGIN_VOID
1123#undef _EVASGL_FUNCTION_BEGIN 1852#undef _EVASGL_FUNCTION_BEGIN
1124#undef _EVASGL_FUNCTION_BEGIN_VOID 1853#undef _EVASGL_FUNCTION_BEGIN_VOID
1125 1854
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_def.h b/src/modules/evas/engines/gl_common/evas_gl_api_def.h
index 40d5600..662fbac 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api_def.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_api_def.h
@@ -13,6 +13,12 @@ _EVASGL_FUNCTION_PRIVATE_BEGIN(const GLubyte *, glGetString, (GLenum name), (nam
13_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels), (x, y, width, height, format, type, pixels)) 13_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glReadPixels, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels), (x, y, width, height, format, type, pixels))
14_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glScissor, (GLint x, GLint y, GLsizei width, GLsizei height), (x, y, width, height)) 14_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glScissor, (GLint x, GLint y, GLsizei width, GLsizei height), (x, y, width, height))
15_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glViewport, (GLint x, GLint y, GLsizei width, GLsizei height), (x, y, width, height)) 15_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glViewport, (GLint x, GLint y, GLsizei width, GLsizei height), (x, y, width, height))
16_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glDeleteFramebuffers, (GLsizei n, const GLuint* framebuffers), (n, framebuffers))
17_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glFramebufferRenderbuffer, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer), (target, attachment, renderbuffertarget, renderbuffer))
18_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glFramebufferTexture2D, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level), (target, attachment, textarget, texture, level))
19_EVASGL_FUNCTION_PRIVATE_BEGIN(GLenum, glGetError, (void), ())
20_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glGetFloatv, (GLenum pname, GLfloat* params), (pname, params))
21_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glGetFramebufferAttachmentParameteriv, (GLenum target, GLenum attachment, GLenum pname, GLint* params), (target, attachment, pname, params))
16 22
17_EVASGL_FUNCTION_BEGIN_VOID( glActiveTexture, (GLenum texture), (texture)) 23_EVASGL_FUNCTION_BEGIN_VOID( glActiveTexture, (GLenum texture), (texture))
18_EVASGL_FUNCTION_BEGIN_VOID( glAttachShader, (GLuint program, GLuint shader), (program, shader)) 24_EVASGL_FUNCTION_BEGIN_VOID( glAttachShader, (GLuint program, GLuint shader), (program, shader))
@@ -39,7 +45,6 @@ _EVASGL_FUNCTION_BEGIN(GLuint, glCreateProgram, (void), ())
39_EVASGL_FUNCTION_BEGIN(GLuint, glCreateShader, (GLenum type), (type)) 45_EVASGL_FUNCTION_BEGIN(GLuint, glCreateShader, (GLenum type), (type))
40_EVASGL_FUNCTION_BEGIN_VOID( glCullFace, (GLenum mode), (mode)) 46_EVASGL_FUNCTION_BEGIN_VOID( glCullFace, (GLenum mode), (mode))
41_EVASGL_FUNCTION_BEGIN_VOID( glDeleteBuffers, (GLsizei n, const GLuint* buffers), (n, buffers)) 47_EVASGL_FUNCTION_BEGIN_VOID( glDeleteBuffers, (GLsizei n, const GLuint* buffers), (n, buffers))
42_EVASGL_FUNCTION_BEGIN_VOID( glDeleteFramebuffers, (GLsizei n, const GLuint* framebuffers), (n, framebuffers))
43_EVASGL_FUNCTION_BEGIN_VOID( glDeleteProgram, (GLuint program), (program)) 48_EVASGL_FUNCTION_BEGIN_VOID( glDeleteProgram, (GLuint program), (program))
44_EVASGL_FUNCTION_BEGIN_VOID( glDeleteRenderbuffers, (GLsizei n, const GLuint* renderbuffers), (n, renderbuffers)) 49_EVASGL_FUNCTION_BEGIN_VOID( glDeleteRenderbuffers, (GLsizei n, const GLuint* renderbuffers), (n, renderbuffers))
45_EVASGL_FUNCTION_BEGIN_VOID( glDeleteShader, (GLuint shader), (shader)) 50_EVASGL_FUNCTION_BEGIN_VOID( glDeleteShader, (GLuint shader), (shader))
@@ -53,8 +58,6 @@ _EVASGL_FUNCTION_BEGIN_VOID( glDrawElements, (GLenum mode, GLsizei count, GLenum
53_EVASGL_FUNCTION_BEGIN_VOID( glEnableVertexAttribArray, (GLuint index), (index)) 58_EVASGL_FUNCTION_BEGIN_VOID( glEnableVertexAttribArray, (GLuint index), (index))
54_EVASGL_FUNCTION_BEGIN_VOID( glFinish, (void), ()) 59_EVASGL_FUNCTION_BEGIN_VOID( glFinish, (void), ())
55_EVASGL_FUNCTION_BEGIN_VOID( glFlush, (void), ()) 60_EVASGL_FUNCTION_BEGIN_VOID( glFlush, (void), ())
56_EVASGL_FUNCTION_BEGIN_VOID( glFramebufferRenderbuffer, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer), (target, attachment, renderbuffertarget, renderbuffer))
57_EVASGL_FUNCTION_BEGIN_VOID( glFramebufferTexture2D, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level), (target, attachment, textarget, texture, level))
58_EVASGL_FUNCTION_BEGIN_VOID( glFrontFace, (GLenum mode), (mode)) 61_EVASGL_FUNCTION_BEGIN_VOID( glFrontFace, (GLenum mode), (mode))
59_EVASGL_FUNCTION_BEGIN_VOID( glGenBuffers, (GLsizei n, GLuint* buffers), (n, buffers)) 62_EVASGL_FUNCTION_BEGIN_VOID( glGenBuffers, (GLsizei n, GLuint* buffers), (n, buffers))
60_EVASGL_FUNCTION_BEGIN_VOID( glGenerateMipmap, (GLenum target), (target)) 63_EVASGL_FUNCTION_BEGIN_VOID( glGenerateMipmap, (GLenum target), (target))
@@ -67,9 +70,6 @@ _EVASGL_FUNCTION_BEGIN_VOID( glGetAttachedShaders, (GLuint program, GLsizei maxc
67_EVASGL_FUNCTION_BEGIN(int, glGetAttribLocation, (GLuint program, const char* name), (program, name)) 70_EVASGL_FUNCTION_BEGIN(int, glGetAttribLocation, (GLuint program, const char* name), (program, name))
68_EVASGL_FUNCTION_BEGIN_VOID( glGetBooleanv, (GLenum pname, GLboolean* params), (pname, params)) 71_EVASGL_FUNCTION_BEGIN_VOID( glGetBooleanv, (GLenum pname, GLboolean* params), (pname, params))
69_EVASGL_FUNCTION_BEGIN_VOID( glGetBufferParameteriv, (GLenum target, GLenum pname, GLint* params), (target, pname, params)) 72_EVASGL_FUNCTION_BEGIN_VOID( glGetBufferParameteriv, (GLenum target, GLenum pname, GLint* params), (target, pname, params))
70_EVASGL_FUNCTION_BEGIN(GLenum, glGetError, (void), ())
71_EVASGL_FUNCTION_BEGIN_VOID( glGetFloatv, (GLenum pname, GLfloat* params), (pname, params))
72_EVASGL_FUNCTION_BEGIN_VOID( glGetFramebufferAttachmentParameteriv, (GLenum target, GLenum attachment, GLenum pname, GLint* params), (target, attachment, pname, params))
73_EVASGL_FUNCTION_BEGIN_VOID( glGetProgramiv, (GLuint program, GLenum pname, GLint* params), (program, pname, params)) 73_EVASGL_FUNCTION_BEGIN_VOID( glGetProgramiv, (GLuint program, GLenum pname, GLint* params), (program, pname, params))
74_EVASGL_FUNCTION_BEGIN_VOID( glGetProgramInfoLog, (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog), (program, bufsize, length, infolog)) 74_EVASGL_FUNCTION_BEGIN_VOID( glGetProgramInfoLog, (GLuint program, GLsizei bufsize, GLsizei* length, char* infolog), (program, bufsize, length, infolog))
75_EVASGL_FUNCTION_BEGIN_VOID( glGetRenderbufferParameteriv, (GLenum target, GLenum pname, GLint* params), (target, pname, params)) 75_EVASGL_FUNCTION_BEGIN_VOID( glGetRenderbufferParameteriv, (GLenum target, GLenum pname, GLint* params), (target, pname, params))
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_ext.c b/src/modules/evas/engines/gl_common/evas_gl_api_ext.c
index eb6f156..fd6cb55 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api_ext.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_api_ext.c
@@ -19,6 +19,8 @@ static char *_gles1_ext_string_official = NULL;
19// list of gles 3.1 exts by official name 19// list of gles 3.1 exts by official name
20static char *_gles3_ext_string = NULL; 20static char *_gles3_ext_string = NULL;
21static char *_gles3_ext_string_official = NULL; 21static char *_gles3_ext_string_official = NULL;
22// indexed pointer list of each extension of gles 3
23Eina_Array *_gles3_ext_plist = NULL;
22 24
23typedef void (*_getproc_fn) (void); 25typedef void (*_getproc_fn) (void);
24typedef _getproc_fn (*fp_getproc)(const char *); 26typedef _getproc_fn (*fp_getproc)(const char *);
@@ -1236,6 +1238,7 @@ _evgl_api_gles3_ext_init(void *getproc, const char *glueexts)
1236 } 1238 }
1237#endif 1239#endif
1238 1240
1241 _gles3_ext_plist = eina_array_new(1);
1239 gles3_funcs = _evgl_api_gles3_internal_get(); 1242 gles3_funcs = _evgl_api_gles3_internal_get();
1240 if (!gles3_funcs || !gles3_funcs->glGetString) 1243 if (!gles3_funcs || !gles3_funcs->glGetString)
1241 { 1244 {
@@ -1352,7 +1355,10 @@ _evgl_api_gles3_ext_init(void *getproc, const char *glueexts)
1352 { \ 1355 { \
1353 eina_strbuf_append(sb, name" "); \ 1356 eina_strbuf_append(sb, name" "); \
1354 if ((strncmp(name, "GL_", 3) == 0) && (strstr(eina_strbuf_string_get(sboff), name) == NULL)) \ 1357 if ((strncmp(name, "GL_", 3) == 0) && (strstr(eina_strbuf_string_get(sboff), name) == NULL)) \
1355 eina_strbuf_append(sboff, name" "); \ 1358 { \
1359 eina_strbuf_append(sboff, name" "); \
1360 eina_array_push(_gles3_ext_plist, name); \
1361 } \
1356 } 1362 }
1357#define _EVASGL_EXT_DRVNAME(name) \ 1363#define _EVASGL_EXT_DRVNAME(name) \
1358 if (_curext_supported) \ 1364 if (_curext_supported) \
@@ -1506,3 +1512,32 @@ evgl_api_ext_string_get(Eina_Bool official, int version)
1506 1512
1507 return (official?_gl_ext_string_official:_gl_ext_string); 1513 return (official?_gl_ext_string_official:_gl_ext_string);
1508} 1514}
1515
1516const char *
1517evgl_api_ext_stringi_get(GLuint index, int version)
1518{
1519 if (_evgl_api_ext_status < 1)
1520 {
1521 ERR("EVGL extension is not yet initialized.");
1522 return NULL;
1523 }
1524
1525 if (version == EVAS_GL_GLES_3_X)
1526 {
1527 if (index < evgl_api_ext_num_extensions_get(version))
1528 {
1529 return eina_array_data_get(_gles3_ext_plist, index);
1530 }
1531 }
1532
1533 return NULL;
1534}
1535
1536GLuint
1537evgl_api_ext_num_extensions_get(int version)
1538{
1539 if (version == EVAS_GL_GLES_3_X)
1540 return eina_array_count_get(_gles3_ext_plist);
1541
1542 return 0;
1543}
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_ext.h b/src/modules/evas/engines/gl_common/evas_gl_api_ext.h
index df128da..118e409 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api_ext.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_api_ext.h
@@ -108,6 +108,8 @@ extern void evgl_api_gles1_ext_get(Evas_GL_API *gl_funcs, void *getproc, const c
108extern void evgl_api_gles3_ext_get(Evas_GL_API *gl_funcs, void *getproc, const char *glueexts); 108extern void evgl_api_gles3_ext_get(Evas_GL_API *gl_funcs, void *getproc, const char *glueexts);
109extern const char *evgl_api_ext_egl_string_get(void); 109extern const char *evgl_api_ext_egl_string_get(void);
110extern const char *evgl_api_ext_string_get(Eina_Bool official, int version); 110extern const char *evgl_api_ext_string_get(Eina_Bool official, int version);
111extern const char *evgl_api_ext_stringi_get(GLuint index, int version);
112extern GLuint evgl_api_ext_num_extensions_get(int version);
111 113
112#endif //_EVAS_GL_API_EXT_H 114#endif //_EVAS_GL_API_EXT_H
113 115
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_gles3_def.h b/src/modules/evas/engines/gl_common/evas_gl_api_gles3_def.h
index c421b8c..f282857 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api_gles3_def.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_api_gles3_def.h
@@ -1,3 +1,7 @@
1_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glDrawBuffers, (GLsizei n, const GLenum *bufs), (n, bufs))
2_EVASGL_FUNCTION_PRIVATE_BEGIN(const GLubyte *, glGetStringi, (GLenum name, GLuint index), (name, index))
3_EVASGL_FUNCTION_PRIVATE_BEGIN_VOID( glReadBuffer, (GLenum src), (src))
4
1_EVASGL_FUNCTION_BEGIN_VOID( glBeginQuery, (GLenum target, GLuint id), (target, id)) 5_EVASGL_FUNCTION_BEGIN_VOID( glBeginQuery, (GLenum target, GLuint id), (target, id))
2_EVASGL_FUNCTION_BEGIN_VOID( glBeginTransformFeedback, (GLenum primitiveMode), (primitiveMode)) 6_EVASGL_FUNCTION_BEGIN_VOID( glBeginTransformFeedback, (GLenum primitiveMode), (primitiveMode))
3_EVASGL_FUNCTION_BEGIN_VOID( glBindBufferBase, (GLenum target, GLuint index, GLuint buffer), (target, index, buffer)) 7_EVASGL_FUNCTION_BEGIN_VOID( glBindBufferBase, (GLenum target, GLuint index, GLuint buffer), (target, index, buffer))
@@ -21,7 +25,6 @@ _EVASGL_FUNCTION_BEGIN_VOID( glDeleteSync, (GLsync sync), (sync))
21_EVASGL_FUNCTION_BEGIN_VOID( glDeleteTransformFeedbacks, (GLsizei n, const GLuint *ids), (n, ids)) 25_EVASGL_FUNCTION_BEGIN_VOID( glDeleteTransformFeedbacks, (GLsizei n, const GLuint *ids), (n, ids))
22_EVASGL_FUNCTION_BEGIN_VOID( glDeleteVertexArrays, (GLsizei n, const GLuint *arrays), (n, arrays)) 26_EVASGL_FUNCTION_BEGIN_VOID( glDeleteVertexArrays, (GLsizei n, const GLuint *arrays), (n, arrays))
23_EVASGL_FUNCTION_BEGIN_VOID( glDrawArraysInstanced, (GLenum mode, GLint first, GLsizei count, GLsizei primcount), (mode, first, count, primcount)) 27_EVASGL_FUNCTION_BEGIN_VOID( glDrawArraysInstanced, (GLenum mode, GLint first, GLsizei count, GLsizei primcount), (mode, first, count, primcount))
24_EVASGL_FUNCTION_BEGIN_VOID( glDrawBuffers, (GLsizei n, const GLenum *bufs), (n, bufs))
25_EVASGL_FUNCTION_BEGIN_VOID( glDrawElementsInstanced, (GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount), (mode, count, type, indices, primcount)) 28_EVASGL_FUNCTION_BEGIN_VOID( glDrawElementsInstanced, (GLenum mode, GLsizei count, GLenum type, const void * indices, GLsizei primcount), (mode, count, type, indices, primcount))
26_EVASGL_FUNCTION_BEGIN_VOID( glDrawRangeElements, (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices), (mode, start, end, count, type, indices)) 29_EVASGL_FUNCTION_BEGIN_VOID( glDrawRangeElements, (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices), (mode, start, end, count, type, indices))
27_EVASGL_FUNCTION_BEGIN_VOID( glEndQuery, (GLenum target), (target)) 30_EVASGL_FUNCTION_BEGIN_VOID( glEndQuery, (GLenum target), (target))
@@ -48,7 +51,6 @@ _EVASGL_FUNCTION_BEGIN_VOID( glGetQueryiv, (GLenum target, GLenum pname, GLint *
48_EVASGL_FUNCTION_BEGIN_VOID( glGetQueryObjectuiv, (GLuint id, GLenum pname, GLuint * params), (id, pname, params)) 51_EVASGL_FUNCTION_BEGIN_VOID( glGetQueryObjectuiv, (GLuint id, GLenum pname, GLuint * params), (id, pname, params))
49_EVASGL_FUNCTION_BEGIN_VOID( glGetSamplerParameterfv, (GLuint sampler, GLenum pname, GLfloat * params), (sampler, pname, params)) 52_EVASGL_FUNCTION_BEGIN_VOID( glGetSamplerParameterfv, (GLuint sampler, GLenum pname, GLfloat * params), (sampler, pname, params))
50_EVASGL_FUNCTION_BEGIN_VOID( glGetSamplerParameteriv, (GLuint sampler, GLenum pname, GLint * params), (sampler, pname, params)) 53_EVASGL_FUNCTION_BEGIN_VOID( glGetSamplerParameteriv, (GLuint sampler, GLenum pname, GLint * params), (sampler, pname, params))
51_EVASGL_FUNCTION_BEGIN(const GLubyte *, glGetStringi, (GLenum name, GLuint index), (name, index))
52_EVASGL_FUNCTION_BEGIN_VOID( glGetSynciv, (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values), (sync, pname, bufSize, length, values)) 54_EVASGL_FUNCTION_BEGIN_VOID( glGetSynciv, (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values), (sync, pname, bufSize, length, values))
53_EVASGL_FUNCTION_BEGIN_VOID( glGetTransformFeedbackVarying, (GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, char * name), (program, index, bufSize, length, size, type, name)) 55_EVASGL_FUNCTION_BEGIN_VOID( glGetTransformFeedbackVarying, (GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, char * name), (program, index, bufSize, length, size, type, name))
54_EVASGL_FUNCTION_BEGIN(GLuint, glGetUniformBlockIndex, (GLuint program, const GLchar *uniformBlockName), (program, uniformBlockName)) 56_EVASGL_FUNCTION_BEGIN(GLuint, glGetUniformBlockIndex, (GLuint program, const GLchar *uniformBlockName), (program, uniformBlockName))
@@ -67,7 +69,6 @@ _EVASGL_FUNCTION_BEGIN(void *, glMapBufferRange, (GLenum target, GLintptr offset
67_EVASGL_FUNCTION_BEGIN_VOID( glPauseTransformFeedback, (void), ()) 69_EVASGL_FUNCTION_BEGIN_VOID( glPauseTransformFeedback, (void), ())
68_EVASGL_FUNCTION_BEGIN_VOID( glProgramBinary, (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length), (program, binaryFormat, binary, length)) 70_EVASGL_FUNCTION_BEGIN_VOID( glProgramBinary, (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length), (program, binaryFormat, binary, length))
69_EVASGL_FUNCTION_BEGIN_VOID( glProgramParameteri, (GLuint program, GLenum pname, GLint value), (program, pname, value)) 71_EVASGL_FUNCTION_BEGIN_VOID( glProgramParameteri, (GLuint program, GLenum pname, GLint value), (program, pname, value))
70_EVASGL_FUNCTION_BEGIN_VOID( glReadBuffer, (GLenum src), (src))
71_EVASGL_FUNCTION_BEGIN_VOID( glRenderbufferStorageMultisample, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height), (target, samples, internalformat, width, height)) 72_EVASGL_FUNCTION_BEGIN_VOID( glRenderbufferStorageMultisample, (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height), (target, samples, internalformat, width, height))
72_EVASGL_FUNCTION_BEGIN_VOID( glResumeTransformFeedback, (void), ()) 73_EVASGL_FUNCTION_BEGIN_VOID( glResumeTransformFeedback, (void), ())
73_EVASGL_FUNCTION_BEGIN_VOID( glSamplerParameterf, (GLuint sampler, GLenum pname, GLfloat param), (sampler, pname, param)) 74_EVASGL_FUNCTION_BEGIN_VOID( glSamplerParameterf, (GLuint sampler, GLenum pname, GLfloat param), (sampler, pname, param))
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 307aa6a..845aa3f 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -32,6 +32,8 @@
32# ifdef GL_GLES 32# ifdef GL_GLES
33# include <GLES2/gl2.h> 33# include <GLES2/gl2.h>
34# include <GLES2/gl2ext.h> 34# include <GLES2/gl2ext.h>
35# include <GLES3/gl3.h>
36# include <GLES3/gl3ext.h>
35# else 37# else
36# include <GL/gl.h> 38# include <GL/gl.h>
37# include <GL/glext.h> 39# include <GL/glext.h>
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.c b/src/modules/evas/engines/gl_common/evas_gl_core.c
index ef012cf..2a0787d 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.c
@@ -204,7 +204,7 @@ _texture_destroy(GLuint *tex)
204// Attach 2D texture with the given format to already bound FBO 204// Attach 2D texture with the given format to already bound FBO
205// *NOTE: attach2 here is used for depth_stencil attachment in GLES env. 205// *NOTE: attach2 here is used for depth_stencil attachment in GLES env.
206static void 206static void
207_texture_attach_2d(GLuint tex, GLenum attach, GLenum attach2, int samples, Eina_Bool use_extension) 207_texture_attach_2d(GLuint tex, GLenum attach, GLenum attach2, int samples, Evas_GL_Context_Version version)
208{ 208{
209 if (samples) 209 if (samples)
210 { 210 {
@@ -224,7 +224,7 @@ _texture_attach_2d(GLuint tex, GLenum attach, GLenum attach2, int samples, Eina_
224 ERR("MSAA not supported. Should not have come in here...!"); 224 ERR("MSAA not supported. Should not have come in here...!");
225#endif 225#endif
226 } 226 }
227 else if (use_extension) 227 else if (version == EVAS_GL_GLES_1_X)
228 { 228 {
229 if (EXT_FUNC_GLES1(glFramebufferTexture2DOES)) 229 if (EXT_FUNC_GLES1(glFramebufferTexture2DOES))
230 EXT_FUNC_GLES1(glFramebufferTexture2DOES)(GL_FRAMEBUFFER, attach, GL_TEXTURE_2D, tex, 0); 230 EXT_FUNC_GLES1(glFramebufferTexture2DOES)(GL_FRAMEBUFFER, attach, GL_TEXTURE_2D, tex, 0);
@@ -302,9 +302,9 @@ _egl_image_destroy(void *image)
302} 302}
303 303
304static void 304static void
305_framebuffer_create(GLuint *buf, Eina_Bool use_extension) 305_framebuffer_create(GLuint *buf, Evas_GL_Context_Version version)
306{ 306{
307 if (use_extension) 307 if (version == EVAS_GL_GLES_1_X)
308 { 308 {
309 if (EXT_FUNC_GLES1(glGenFramebuffersOES)) 309 if (EXT_FUNC_GLES1(glGenFramebuffersOES))
310 EXT_FUNC_GLES1(glGenFramebuffersOES)(1, buf); 310 EXT_FUNC_GLES1(glGenFramebuffersOES)(1, buf);
@@ -316,9 +316,9 @@ _framebuffer_create(GLuint *buf, Eina_Bool use_extension)
316} 316}
317 317
318static void 318static void
319_framebuffer_bind(GLuint buf, Eina_Bool use_extension) 319_framebuffer_bind(GLuint buf, Evas_GL_Context_Version version)
320{ 320{
321 if (use_extension) 321 if (version == EVAS_GL_GLES_1_X)
322 { 322 {
323 if (EXT_FUNC_GLES1(glBindFramebufferOES)) 323 if (EXT_FUNC_GLES1(glBindFramebufferOES))
324 EXT_FUNC_GLES1(glBindFramebufferOES)(GL_FRAMEBUFFER, buf); 324 EXT_FUNC_GLES1(glBindFramebufferOES)(GL_FRAMEBUFFER, buf);
@@ -329,11 +329,27 @@ _framebuffer_bind(GLuint buf, Eina_Bool use_extension)
329 } 329 }
330} 330}
331 331
332static void
333_framebuffer_draw_bind(GLuint buf, Evas_GL_Context_Version version)
334{
335 if (version == EVAS_GL_GLES_3_X)
336 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, buf);
337}
338
339//This function is not needed in EvasGL backend engine with GLES 2.0.
340//But It is useful when EvasGL backend works with GLES 3.X and use read buffers.
341static void
342_framebuffer_read_bind(GLuint buf, Evas_GL_Context_Version version)
343{
344 if (version == EVAS_GL_GLES_3_X)
345 glBindFramebuffer(GL_READ_FRAMEBUFFER, buf);
346}
347
332static GLenum 348static GLenum
333_framebuffer_check(Eina_Bool use_extension) 349_framebuffer_check(Evas_GL_Context_Version version)
334{ 350{
335 GLenum ret = 0; 351 GLenum ret = 0;
336 if (use_extension) 352 if (version == EVAS_GL_GLES_1_X)
337 { 353 {
338 if (EXT_FUNC_GLES1(glCheckFramebufferStatusOES)) 354 if (EXT_FUNC_GLES1(glCheckFramebufferStatusOES))
339 ret = EXT_FUNC_GLES1(glCheckFramebufferStatusOES)(GL_FRAMEBUFFER); 355 ret = EXT_FUNC_GLES1(glCheckFramebufferStatusOES)(GL_FRAMEBUFFER);
@@ -384,9 +400,9 @@ _renderbuffer_destroy(GLuint *buf)
384 400
385// Attach a renderbuffer with the given format to already bound FBO 401// Attach a renderbuffer with the given format to already bound FBO
386static void 402static void
387_renderbuffer_attach(GLuint buf, GLenum attach, Eina_Bool use_extension) 403_renderbuffer_attach(GLuint buf, GLenum attach, Evas_GL_Context_Version version)
388{ 404{
389 if (use_extension) 405 if (version == EVAS_GL_GLES_1_X)
390 { 406 {
391 if (EXT_FUNC_GLES1(glFramebufferRenderbufferOES)) 407 if (EXT_FUNC_GLES1(glFramebufferRenderbufferOES))
392 EXT_FUNC_GLES1(glFramebufferRenderbufferOES)(GL_FRAMEBUFFER, attach, GL_RENDERBUFFER, buf); 408 EXT_FUNC_GLES1(glFramebufferRenderbufferOES)(GL_FRAMEBUFFER, attach, GL_RENDERBUFFER, buf);
@@ -398,6 +414,7 @@ _renderbuffer_attach(GLuint buf, GLenum attach, Eina_Bool use_extension)
398} 414}
399 415
400// Check whether the given FBO surface config is supported by the driver 416// Check whether the given FBO surface config is supported by the driver
417// TODO - we also should test with GLES3's formats.
401static int 418static int
402_fbo_surface_cap_test(GLint color_ifmt, GLenum color_fmt, 419_fbo_surface_cap_test(GLint color_ifmt, GLenum color_fmt,
403 GLenum depth_fmt, GLenum stencil_fmt, int mult_samples) 420 GLenum depth_fmt, GLenum stencil_fmt, int mult_samples)
@@ -420,7 +437,7 @@ _fbo_surface_cap_test(GLint color_ifmt, GLenum color_fmt,
420 { 437 {
421 _texture_create(&color_buf); 438 _texture_create(&color_buf);
422 _texture_allocate_2d(color_buf, color_ifmt, color_fmt, GL_UNSIGNED_BYTE, w, h); 439 _texture_allocate_2d(color_buf, color_ifmt, color_fmt, GL_UNSIGNED_BYTE, w, h);
423 _texture_attach_2d(color_buf, GL_COLOR_ATTACHMENT0, 0, mult_samples, EINA_FALSE); 440 _texture_attach_2d(color_buf, GL_COLOR_ATTACHMENT0, 0, mult_samples, EVAS_GL_GLES_2_X);
424 } 441 }
425 442
426 // Check Depth_Stencil Format First 443 // Check Depth_Stencil Format First
@@ -431,7 +448,7 @@ _fbo_surface_cap_test(GLint color_ifmt, GLenum color_fmt,
431 _texture_allocate_2d(depth_stencil_buf, depth_fmt, 448 _texture_allocate_2d(depth_stencil_buf, depth_fmt,
432 depth_fmt, GL_UNSIGNED_INT_24_8_OES, w, h); 449 depth_fmt, GL_UNSIGNED_INT_24_8_OES, w, h);
433 _texture_attach_2d(depth_stencil_buf, GL_DEPTH_ATTACHMENT, 450 _texture_attach_2d(depth_stencil_buf, GL_DEPTH_ATTACHMENT,
434 GL_STENCIL_ATTACHMENT, mult_samples, EINA_FALSE); 451 GL_STENCIL_ATTACHMENT, mult_samples, EVAS_GL_GLES_2_X);
435 depth_stencil = 1; 452 depth_stencil = 1;
436 } 453 }
437#else 454#else
@@ -449,7 +466,7 @@ _fbo_surface_cap_test(GLint color_ifmt, GLenum color_fmt,
449 { 466 {
450 _renderbuffer_create(&depth_buf); 467 _renderbuffer_create(&depth_buf);
451 _renderbuffer_allocate(depth_buf, depth_fmt, w, h, mult_samples); 468 _renderbuffer_allocate(depth_buf, depth_fmt, w, h, mult_samples);
452 _renderbuffer_attach(depth_buf, GL_DEPTH_ATTACHMENT, EINA_FALSE); 469 _renderbuffer_attach(depth_buf, GL_DEPTH_ATTACHMENT, EVAS_GL_GLES_2_X);
453 } 470 }
454 471
455 // Stencil Attachment 472 // Stencil Attachment
@@ -457,7 +474,7 @@ _fbo_surface_cap_test(GLint color_ifmt, GLenum color_fmt,
457 { 474 {
458 _renderbuffer_create(&stencil_buf); 475 _renderbuffer_create(&stencil_buf);
459 _renderbuffer_allocate(stencil_buf, stencil_fmt, w, h, mult_samples); 476 _renderbuffer_allocate(stencil_buf, stencil_fmt, w, h, mult_samples);
460 _renderbuffer_attach(stencil_buf, GL_STENCIL_ATTACHMENT, EINA_FALSE); 477 _renderbuffer_attach(stencil_buf, GL_STENCIL_ATTACHMENT, EVAS_GL_GLES_2_X);
461 } 478 }
462 479
463 // Check FBO for completeness 480 // Check FBO for completeness
@@ -1087,47 +1104,47 @@ _surface_context_list_print()
1087// Start from here..... 1104// Start from here.....
1088//--------------------------------------------------------// 1105//--------------------------------------------------------//
1089static int 1106static int
1090_surface_buffers_fbo_set(EVGL_Surface *sfc, GLuint fbo, Eina_Bool use_extension) 1107_surface_buffers_fbo_set(EVGL_Surface *sfc, GLuint fbo, Evas_GL_Context_Version version)
1091{ 1108{
1092 int status; 1109 int status;
1093 1110
1094 _framebuffer_bind(fbo, use_extension); 1111 _framebuffer_bind(fbo, version);
1095 1112
1096 // Detach any previously attached buffers 1113 // Detach any previously attached buffers
1097 _texture_attach_2d(0, GL_COLOR_ATTACHMENT0, 0, 0, use_extension); 1114 _texture_attach_2d(0, GL_COLOR_ATTACHMENT0, 0, 0, version);
1098 _renderbuffer_attach(0, GL_DEPTH_ATTACHMENT, use_extension); 1115 _renderbuffer_attach(0, GL_DEPTH_ATTACHMENT, version);
1099 _renderbuffer_attach(0, GL_STENCIL_ATTACHMENT, use_extension); 1116 _renderbuffer_attach(0, GL_STENCIL_ATTACHMENT, version);
1100#ifdef GL_GLES 1117#ifdef GL_GLES
1101 _texture_attach_2d(0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, 0, use_extension); 1118 _texture_attach_2d(0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, 0, version);
1102#else 1119#else
1103 _renderbuffer_attach(0, GL_DEPTH_STENCIL_ATTACHMENT, use_extension); 1120 _renderbuffer_attach(0, GL_DEPTH_STENCIL_ATTACHMENT, version);
1104#endif 1121#endif
1105 1122
1106 // Render Target Texture 1123 // Render Target Texture
1107 if (sfc->color_buf) 1124 if (sfc->color_buf)
1108 _texture_attach_2d(sfc->color_buf, GL_COLOR_ATTACHMENT0, 0, sfc->msaa_samples, use_extension); 1125 _texture_attach_2d(sfc->color_buf, GL_COLOR_ATTACHMENT0, 0, sfc->msaa_samples, version);
1109 1126
1110 // Depth Stencil RenderBuffer - Attach it to FBO 1127 // Depth Stencil RenderBuffer - Attach it to FBO
1111 if (sfc->depth_stencil_buf) 1128 if (sfc->depth_stencil_buf)
1112 { 1129 {
1113#ifdef GL_GLES 1130#ifdef GL_GLES
1114 _texture_attach_2d(sfc->depth_stencil_buf, GL_DEPTH_ATTACHMENT, 1131 _texture_attach_2d(sfc->depth_stencil_buf, GL_DEPTH_ATTACHMENT,
1115 GL_STENCIL_ATTACHMENT, sfc->msaa_samples, use_extension); 1132 GL_STENCIL_ATTACHMENT, sfc->msaa_samples, version);
1116#else 1133#else
1117 _renderbuffer_attach(sfc->depth_stencil_buf, GL_DEPTH_STENCIL_ATTACHMENT, use_extension); 1134 _renderbuffer_attach(sfc->depth_stencil_buf, GL_DEPTH_STENCIL_ATTACHMENT, version);
1118#endif 1135#endif
1119 } 1136 }
1120 1137
1121 // Depth RenderBuffer - Attach it to FBO 1138 // Depth RenderBuffer - Attach it to FBO
1122 if (sfc->depth_buf) 1139 if (sfc->depth_buf)
1123 _renderbuffer_attach(sfc->depth_buf, GL_DEPTH_ATTACHMENT, use_extension); 1140 _renderbuffer_attach(sfc->depth_buf, GL_DEPTH_ATTACHMENT, version);
1124 1141
1125 // Stencil RenderBuffer - Attach it to FBO 1142 // Stencil RenderBuffer - Attach it to FBO
1126 if (sfc->stencil_buf) 1143 if (sfc->stencil_buf)
1127 _renderbuffer_attach(sfc->stencil_buf, GL_STENCIL_ATTACHMENT, use_extension); 1144 _renderbuffer_attach(sfc->stencil_buf, GL_STENCIL_ATTACHMENT, version);
1128 1145
1129 // Check FBO for completeness 1146 // Check FBO for completeness
1130 status = _framebuffer_check(use_extension); 1147 status = _framebuffer_check(version);
1131 if (status != GL_FRAMEBUFFER_COMPLETE) 1148 if (status != GL_FRAMEBUFFER_COMPLETE)
1132 { 1149 {
1133 ERR("FBO not complete. Error Code: %x!", status); 1150 ERR("FBO not complete. Error Code: %x!", status);
@@ -1173,7 +1190,7 @@ _surface_buffers_create(EVGL_Surface *sfc)
1173 1190
1174 1191
1175static int 1192static int
1176_surface_buffers_allocate(void *eng_data, EVGL_Surface *sfc, int w, int h, int mc) 1193_surface_buffers_allocate(void *eng_data, EVGL_Surface *sfc, int w, int h, int mc, Evas_GL_Context_Version version)
1177{ 1194{
1178 // Set the context current with resource context/surface 1195 // Set the context current with resource context/surface
1179 if (mc) 1196 if (mc)
@@ -1203,9 +1220,18 @@ _surface_buffers_allocate(void *eng_data, EVGL_Surface *sfc, int w, int h, int m
1203 if (sfc->depth_stencil_fmt) 1220 if (sfc->depth_stencil_fmt)
1204 { 1221 {
1205#ifdef GL_GLES 1222#ifdef GL_GLES
1206 _texture_allocate_2d(sfc->depth_stencil_buf, sfc->depth_stencil_fmt, 1223 if (version == EVAS_GL_GLES_3_X)
1207 sfc->depth_stencil_fmt, GL_UNSIGNED_INT_24_8_OES, 1224 {
1208 w, h); 1225 _texture_allocate_2d(sfc->depth_stencil_buf, GL_DEPTH24_STENCIL8_OES,
1226 sfc->depth_stencil_fmt, GL_UNSIGNED_INT_24_8_OES,
1227 w, h);
1228 }
1229 else
1230 {
1231 _texture_allocate_2d(sfc->depth_stencil_buf, sfc->depth_stencil_fmt,
1232 sfc->depth_stencil_fmt, GL_UNSIGNED_INT_24_8_OES,
1233 w, h);
1234 }
1209#else 1235#else
1210 _renderbuffer_allocate(sfc->depth_stencil_buf, sfc->depth_stencil_fmt, 1236 _renderbuffer_allocate(sfc->depth_stencil_buf, sfc->depth_stencil_fmt,
1211 w, h, sfc->msaa_samples); 1237 w, h, sfc->msaa_samples);
@@ -2133,6 +2159,7 @@ evgl_context_create(void *eng_data, EVGL_Context *share_ctx,
2133 ctx->scissor_coord[1] = 0; 2159 ctx->scissor_coord[1] = 0;
2134 ctx->scissor_coord[2] = evgl_engine->caps.max_w; 2160 ctx->scissor_coord[2] = evgl_engine->caps.max_w;
2135 ctx->scissor_coord[3] = evgl_engine->caps.max_h; 2161 ctx->scissor_coord[3] = evgl_engine->caps.max_h;
2162 ctx->gl_error = GL_NO_ERROR;
2136 2163
2137 // Call engine create context 2164 // Call engine create context
2138 if (share_ctx) 2165 if (share_ctx)
@@ -2242,7 +2269,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2242{ 2269{
2243 Eina_Bool dbg = EINA_FALSE; 2270 Eina_Bool dbg = EINA_FALSE;
2244 EVGL_Resource *rsc; 2271 EVGL_Resource *rsc;
2245 int curr_fbo = 0; 2272 int curr_fbo = 0, curr_draw_fbo = 0, curr_read_fbo = 0;
2246 2273
2247 // Check the input validity. If either sfc or ctx is NULL, it's also error. 2274 // Check the input validity. If either sfc or ctx is NULL, it's also error.
2248 if ( (!evgl_engine) || 2275 if ( (!evgl_engine) ||
@@ -2276,14 +2303,30 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2276 if (rsc->direct.partial.enabled) 2303 if (rsc->direct.partial.enabled)
2277 evgl_direct_partial_render_end(); 2304 evgl_direct_partial_render_end();
2278 2305
2279 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &curr_fbo); 2306 if (rsc->current_ctx->version == EVAS_GL_GLES_3_X)
2280 if ((rsc->current_ctx->surface_fbo == (GLuint) curr_fbo) ||
2281 (rsc->current_ctx->current_sfc &&
2282 rsc->current_ctx->current_sfc->color_buf == (GLuint) curr_fbo))
2283 { 2307 {
2284 glBindFramebuffer(GL_FRAMEBUFFER, 0); 2308 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &curr_draw_fbo);
2285 rsc->current_ctx->current_fbo = 0; 2309 if ((rsc->current_ctx->surface_fbo == (GLuint) curr_draw_fbo) ||
2310 (rsc->current_ctx->current_sfc &&
2311 rsc->current_ctx->current_sfc->color_buf == (GLuint) curr_draw_fbo))
2312 {
2313 glBindFramebuffer(GL_FRAMEBUFFER, 0);
2314 rsc->current_ctx->current_draw_fbo = 0;
2315 rsc->current_ctx->current_read_fbo = 0;
2316 }
2286 } 2317 }
2318 else
2319 {
2320 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &curr_fbo);
2321 if ((rsc->current_ctx->surface_fbo == (GLuint) curr_fbo) ||
2322 (rsc->current_ctx->current_sfc &&
2323 rsc->current_ctx->current_sfc->color_buf == (GLuint) curr_fbo))
2324 {
2325 glBindFramebuffer(GL_FRAMEBUFFER, 0);
2326 rsc->current_ctx->current_fbo = 0;
2327 }
2328 }
2329
2287 } 2330 }
2288 2331
2289 if (dbg) DBG("Calling make_current(NULL, NULL)"); 2332 if (dbg) DBG("Calling make_current(NULL, NULL)");
@@ -2370,7 +2413,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2370 // Destroy created resources 2413 // Destroy created resources
2371 if (sfc->buffers_allocated) 2414 if (sfc->buffers_allocated)
2372 { 2415 {
2373 if (!_surface_buffers_allocate(eng_data, sfc, 0, 0, 0)) 2416 if (!_surface_buffers_allocate(eng_data, sfc, 0, 0, 0, ctx->version))
2374 { 2417 {
2375 ERR("Unable to destroy surface buffers!"); 2418 ERR("Unable to destroy surface buffers!");
2376 evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC); 2419 evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC);
@@ -2391,7 +2434,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2391 if (!sfc->buffers_allocated) 2434 if (!sfc->buffers_allocated)
2392 { 2435 {
2393 if (dbg) DBG("Allocating buffers for sfc %p", sfc); 2436 if (dbg) DBG("Allocating buffers for sfc %p", sfc);
2394 if (!_surface_buffers_allocate(eng_data, sfc, sfc->w, sfc->h, 0)) 2437 if (!_surface_buffers_allocate(eng_data, sfc, sfc->w, sfc->h, 1, ctx->version))
2395 { 2438 {
2396 ERR("Unable Create Specificed Surfaces. Unsupported format!"); 2439 ERR("Unable Create Specificed Surfaces. Unsupported format!");
2397 evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC); 2440 evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC);
@@ -2406,7 +2449,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2406 { 2449 {
2407 if (!sfc->buffers_allocated) 2450 if (!sfc->buffers_allocated)
2408 { 2451 {
2409 if (!_surface_buffers_allocate(eng_data, sfc, sfc->w, sfc->h, 0)) 2452 if (!_surface_buffers_allocate(eng_data, sfc, sfc->w, sfc->h, 0, ctx->version))
2410 { 2453 {
2411 ERR("Unable Create Allocate Memory for Surface."); 2454 ERR("Unable Create Allocate Memory for Surface.");
2412 evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC); 2455 evas_gl_common_error_set(eng_data, EVAS_GL_BAD_ALLOC);
@@ -2459,53 +2502,100 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2459 glViewport(ctx->viewport_coord[0], ctx->viewport_coord[1], ctx->viewport_coord[2], ctx->viewport_coord[3]); 2502 glViewport(ctx->viewport_coord[0], ctx->viewport_coord[1], ctx->viewport_coord[2], ctx->viewport_coord[3]);
2460 if ((ctx->direct_scissor) && (!ctx->scissor_enabled)) 2503 if ((ctx->direct_scissor) && (!ctx->scissor_enabled))
2461 glDisable(GL_SCISSOR_TEST); 2504 glDisable(GL_SCISSOR_TEST);
2505 }
2506
2507 if (ctx->version == EVAS_GL_GLES_3_X)
2508 {
2509 ctx->current_draw_fbo = 0;
2510 ctx->current_read_fbo = 0;
2511 }
2512 else
2513 {
2514 ctx->current_fbo = 0;
2462 } 2515 }
2463 2516
2464 ctx->current_fbo = 0;
2465 rsc->direct.rendered = 0; 2517 rsc->direct.rendered = 0;
2466 } 2518 }
2467 } 2519 }
2468 else 2520 else
2469 { 2521 {
2470 Eina_Bool use_extension = EINA_FALSE;
2471#ifdef GL_GLES
2472 if ((ctx->version == EVAS_GL_GLES_1_X) && (gles1_funcs))
2473 use_extension = EINA_TRUE;
2474#endif
2475
2476 // Normal FBO Rendering 2522 // Normal FBO Rendering
2477 // Create FBO if it hasn't been created 2523 // Create FBO if it hasn't been created
2478 if (!ctx->surface_fbo) 2524 if (!ctx->surface_fbo)
2479 _framebuffer_create(&ctx->surface_fbo, use_extension); 2525 _framebuffer_create(&ctx->surface_fbo, ctx->version);
2480 2526
2481 // Direct Rendering 2527 // Direct Rendering
2482 if (_evgl_direct_renderable(rsc, sfc)) 2528 if (_evgl_direct_renderable(rsc, sfc))
2483 { 2529 {
2484 if (dbg) DBG("sfc %p is direct renderable.", sfc); 2530 if (dbg) DBG("sfc %p is direct renderable.", sfc);
2485 2531
2486 // This is to transition from FBO rendering to direct rendering 2532 if (ctx->version == EVAS_GL_GLES_3_X)
2487 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &curr_fbo);
2488 if (ctx->surface_fbo == (GLuint)curr_fbo)
2489 { 2533 {
2490 _framebuffer_bind(0, use_extension); 2534 // This is to transition from FBO rendering to direct rendering
2491 ctx->current_fbo = 0; 2535 glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &curr_draw_fbo);
2536 if (ctx->surface_fbo == (GLuint)curr_draw_fbo)
2537 {
2538 _framebuffer_draw_bind(0, ctx->version);
2539 ctx->current_draw_fbo = 0;
2540 }
2541 else if (ctx->current_sfc && (ctx->current_sfc->pbuffer.is_pbuffer))
2542 {
2543 // Using the same context, we were rendering on a pbuffer
2544 _framebuffer_draw_bind(0, ctx->version);
2545 ctx->current_draw_fbo = 0;
2546 }
2547
2548 glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &curr_read_fbo);
2549 if (ctx->surface_fbo == (GLuint)curr_read_fbo)
2550 {
2551 _framebuffer_read_bind(0, ctx->version);
2552 ctx->current_read_fbo = 0;
2553 }
2554 else if (ctx->current_sfc && (ctx->current_sfc->pbuffer.is_pbuffer))
2555 {
2556 _framebuffer_read_bind(0, ctx->version);
2557 ctx->current_read_fbo = 0;
2558 }
2559
2560 if (ctx->current_read_fbo == 0)
2561 {
2562 // If master clip is set and clip is greater than 0, do partial render
2563 if (rsc->direct.partial.enabled)
2564 {
2565 if (!ctx->partial_render)
2566 {
2567 evgl_direct_partial_render_start();
2568 ctx->partial_render = 1;
2569 }
2570 }
2571 }
2492 } 2572 }
2493 else if (ctx->current_sfc && (ctx->current_sfc->pbuffer.is_pbuffer)) 2573 else
2494 { 2574 {
2495 // Using the same context, we were rendering on a pbuffer 2575 // This is to transition from FBO rendering to direct rendering
2496 _framebuffer_bind(0, use_extension); 2576 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &curr_fbo);
2497 ctx->current_fbo = 0; 2577 if (ctx->surface_fbo == (GLuint)curr_fbo)
2498 } 2578 {
2579 _framebuffer_bind(0, ctx->version);
2580 ctx->current_fbo = 0;
2581 }
2582 else if (ctx->current_sfc && (ctx->current_sfc->pbuffer.is_pbuffer))
2583 {
2584 // Using the same context, we were rendering on a pbuffer
2585 _framebuffer_bind(0, ctx->version);
2586 ctx->current_fbo = 0;
2587 }
2499 2588
2500 if (ctx->current_fbo == 0) 2589 if (ctx->current_fbo == 0)
2501 {
2502 // If master clip is set and clip is greater than 0, do partial render
2503 if (rsc->direct.partial.enabled)
2504 { 2590 {
2505 if (!ctx->partial_render) 2591 // If master clip is set and clip is greater than 0, do partial render
2592 if (rsc->direct.partial.enabled)
2506 { 2593 {
2507 evgl_direct_partial_render_start(); 2594 if (!ctx->partial_render)
2508 ctx->partial_render = 1; 2595 {
2596 evgl_direct_partial_render_start();
2597 ctx->partial_render = 1;
2598 }
2509 } 2599 }
2510 } 2600 }
2511 } 2601 }
@@ -2522,7 +2612,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2522 2612
2523 if (sfc->color_buf) 2613 if (sfc->color_buf)
2524 { 2614 {
2525 if (!_surface_buffers_fbo_set(sfc, sfc->color_buf, use_extension)) 2615 if (!_surface_buffers_fbo_set(sfc, sfc->color_buf, ctx->version))
2526 ERR("Could not detach current FBO"); 2616 ERR("Could not detach current FBO");
2527 } 2617 }
2528 2618
@@ -2531,8 +2621,20 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2531 ctx->context, EINA_TRUE); 2621 ctx->context, EINA_TRUE);
2532 2622
2533 // Bind to the previously bound buffer (may be 0) 2623 // Bind to the previously bound buffer (may be 0)
2534 if (ctx->current_fbo) 2624 if (ctx->version == EVAS_GL_GLES_3_X)
2535 _framebuffer_bind(ctx->current_fbo, use_extension); 2625 {
2626 if (ctx->current_draw_fbo)
2627 {
2628 _framebuffer_draw_bind(ctx->current_draw_fbo, ctx->version);
2629 }
2630 }
2631 else
2632 {
2633 if (ctx->current_fbo)
2634 {
2635 _framebuffer_bind(ctx->current_fbo, ctx->version);
2636 }
2637 }
2536 2638
2537 rsc->direct.rendered = 0; 2639 rsc->direct.rendered = 0;
2538 } 2640 }
@@ -2555,7 +2657,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2555 if (rsc->direct.partial.enabled) 2657 if (rsc->direct.partial.enabled)
2556 evgl_direct_partial_render_end(); 2658 evgl_direct_partial_render_end();
2557 2659
2558 if (!_surface_buffers_fbo_set(sfc, ctx->surface_fbo, use_extension)) 2660 if (!_surface_buffers_fbo_set(sfc, ctx->surface_fbo, ctx->version))
2559 { 2661 {
2560 ERR("Attaching buffers to context fbo failed. Engine: %p Surface: %p Context FBO: %u", evgl_engine, sfc, ctx->surface_fbo); 2662 ERR("Attaching buffers to context fbo failed. Engine: %p Surface: %p Context FBO: %u", evgl_engine, sfc, ctx->surface_fbo);
2561 evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONTEXT); 2663 evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONTEXT);
@@ -2564,8 +2666,20 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx)
2564 } 2666 }
2565 2667
2566 // Bind to the previously bound buffer 2668 // Bind to the previously bound buffer
2567 if (ctx->current_fbo) 2669
2568 _framebuffer_bind(ctx->current_fbo, use_extension); 2670 if (ctx->version == EVAS_GL_GLES_3_X)
2671 {
2672 if (ctx->current_draw_fbo)
2673 _framebuffer_draw_bind(ctx->current_draw_fbo, ctx->version);
2674
2675 if (ctx->current_read_fbo)
2676 _framebuffer_read_bind(ctx->current_read_fbo, ctx->version);
2677 }
2678 else
2679 {
2680 if (ctx->current_fbo)
2681 _framebuffer_bind(ctx->current_fbo, ctx->version);
2682 }
2569 } 2683 }
2570 rsc->direct.rendered = 0; 2684 rsc->direct.rendered = 0;
2571 } 2685 }
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core_private.h b/src/modules/evas/engines/gl_common/evas_gl_core_private.h
index 87c74d2..41151d5 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core_private.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_core_private.h
@@ -169,6 +169,8 @@ struct _EVGL_Context
169 169
170 // Current FBO 170 // Current FBO
171 GLuint current_fbo; 171 GLuint current_fbo;
172 GLuint current_draw_fbo; //for GLES3
173 GLuint current_read_fbo; //for GLES3
172 174
173 // Direct Rendering Related 175 // Direct Rendering Related
174 unsigned scissor_enabled : 1; 176 unsigned scissor_enabled : 1;
@@ -190,6 +192,9 @@ struct _EVGL_Context
190 int partial_render; 192 int partial_render;
191 193
192 EVGL_Surface *current_sfc; 194 EVGL_Surface *current_sfc;
195
196 //glGetError
197 GLenum gl_error;
193}; 198};
194 199
195typedef enum _EVGL_Color_Bit 200typedef enum _EVGL_Color_Bit