1 #ifndef _EVAS_GL_CORE_PRIVATE_H 2 #define _EVAS_GL_CORE_PRIVATE_H 3 #include "evas_gl_private.h" 4 #include "evas_gl_core.h" 5 #include "evas_gl_api_ext.h" 6 #define EVAS_GL_NO_GL_H_CHECK 1 7 #include "Evas_GL.h" 8 9 //#include "evas_gl_ext.h" 10 11 extern int _evas_gl_log_dom; 12 13 #ifdef ERR 14 # undef ERR 15 #endif 16 #define ERR(...) EINA_LOG_DOM_ERR(_evas_gl_log_dom, __VA_ARGS__) 17 18 #ifdef DBG 19 # undef DBG 20 #endif 21 #define DBG(...) EINA_LOG_DOM_DBG(_evas_gl_log_dom, __VA_ARGS__) 22 #ifdef INF 23 # undef INF 24 #endif 25 #define INF(...) EINA_LOG_DOM_INFO(_evas_gl_log_dom, __VA_ARGS__) 26 27 #ifdef WRN 28 # undef WRN 29 #endif 30 #define WRN(...) EINA_LOG_DOM_WARN(_evas_gl_log_dom, __VA_ARGS__) 31 32 #ifdef CRI 33 # undef CRI 34 #endif 35 #define CRI(...) EINA_LOG_DOM_CRIT(_evas_gl_log_dom, __VA_ARGS__) 36 37 38 struct _EVGL_Interface 39 { 40 // Returns the native display of evas engine. 41 void *(*display_get)(void *data); 42 43 // Returns the Window surface that evas uses for direct rendering opt 44 void *(*evas_surface_get)(void *data); 45 void *(*native_window_create)(void *data); 46 int (*native_window_destroy)(void *data, void *window); 47 48 // Creates/Destroys the native surface from evas engine. 49 void *(*surface_create)(void *data, void *native_window); 50 int (*surface_destroy)(void *data, void *surface); 51 52 // Creates/Destroys the native surface from evas engine. 53 void *(*context_create)(void *data, void *share_ctx, Evas_GL_Context_Version version); 54 int (*context_destroy)(void *data, void *context); 55 56 // Calls the make_current from evas_engine. 57 int (*make_current)(void *data, void *surface, void *context, int flush); 58 59 // Returns the get proc_address function 60 void *(*proc_address_get)(const char *name); 61 62 // Returns the string of supported extensions 63 const char *(*ext_string_get)(void *data); 64 65 // Returns the current rotation angle of evas 66 int (*rotation_angle_get)(void *data); 67 68 // Create a pbuffer surface 69 void *(*pbuffer_surface_create)(void *data, EVGL_Surface *evgl_sfc, const int *attrib_list); 70 int (*pbuffer_surface_destroy)(void *data, void *surface); 71 72 // Create a surface for 1.x & 3.x rendering (could be pbuffer or xpixmap for instance) 73 void *(*indirect_surface_create)(EVGL_Engine *evgl, void *data, EVGL_Surface *evgl_sfc, Evas_GL_Config *cfg, int w, int h); 74 75 // Destroy 1.x & 3.x surface (could be pbuffer or xpixmap for instance) 76 int (*indirect_surface_destroy)(void *data, EVGL_Surface *evgl_sfc); 77 78 // Create an indirect rendering context for GLES 1.x 79 void *(*gles_context_create)(void *data, EVGL_Context *share_ctx, EVGL_Surface *evgl_sfc); 80 81 // Check native window surface config for Evas GL Direct Rendering 82 void (*native_win_surface_config_get)(void *data, int *win_depth, int *win_stencil, int *win_msaa); 83 }; 84 85 struct _EVGL_Surface 86 { 87 int w, h; 88 89 //-------------------------// 90 // Related to FBO Surface 91 92 // MSAA 93 GLint msaa_samples; 94 95 // Color Buffer Target 96 GLuint color_buf; 97 GLint color_ifmt; 98 GLenum color_fmt; 99 100 // Depth Buffer Target 101 GLuint depth_buf; 102 GLenum depth_fmt; 103 104 // Stencil Buffer Target 105 GLuint stencil_buf; 106 GLenum stencil_fmt; 107 108 // Depth_Stencil Target 109 GLuint depth_stencil_buf; 110 GLenum depth_stencil_fmt; 111 112 // Direct Rendering Options 113 unsigned direct_fb_opt : 1; 114 unsigned client_side_rotation : 1; 115 unsigned alpha : 1; 116 117 // Flag indicating this surface is used for indirect rendering 118 unsigned indirect : 1; 119 unsigned yinvert : 1; 120 121 // Moved from evgl_engine 122 unsigned direct_override : 1; 123 unsigned direct_mem_opt : 1; 124 125 // Init Flag 126 unsigned buffers_skip_allocate : 1; 127 unsigned buffers_allocated : 1; 128 129 void *cfg; 130 int cfg_index; 131 132 133 // Rough estimate of buffer in memory per renderbuffer 134 // 0. color 1. depth 2. stencil 3. depth_stencil 135 int buffer_mem[4]; 136 137 //-------------------------// 138 // Used if indirect == 1 139 EVGLNative_Surface indirect_sfc; 140 void *indirect_sfc_native; 141 void *indirect_sfc_visual; 142 void *indirect_sfc_config; 143 void *egl_image; 144 145 //-------------------------// 146 // Related to PBuffer Surface 147 struct { 148 EVGLNative_Surface native_surface; 149 Evas_GL_Color_Format color_fmt; 150 Eina_Bool is_pbuffer : 1; 151 } pbuffer; 152 153 154 //-------------------------// 155 156 EVGL_Context *current_ctx; 157 }; 158 159 160 161 struct _EVGL_Context 162 { 163 EVGLNative_Context context; 164 165 Evas_GL_Context_Version version; 166 int version_minor; 167 168 // Context FBO 169 GLuint surface_fbo; 170 171 // Current FBO 172 GLuint current_fbo; 173 GLuint current_draw_fbo; //for GLES3 174 GLuint current_read_fbo; //for GLES3 175 176 // Direct Rendering Related 177 unsigned scissor_enabled : 1; 178 unsigned scissor_updated : 1; 179 unsigned direct_scissor : 1; 180 unsigned viewport_updated : 1; 181 unsigned extension_checked : 1; 182 unsigned fbo_image_supported : 1; 183 unsigned pixmap_image_supported : 1; 184 185 int scissor_coord[4]; 186 int viewport_coord[4]; 187 int viewport_direct[4]; 188 189 // For GLES1/GLES3 with indirect rendering 190 EVGLNative_Context indirect_context; 191 192 // Partial Rendering 193 int partial_render; 194 195 EVGL_Surface *current_sfc; 196 197 //glGetError 198 GLenum gl_error; 199 }; 200 201 typedef enum _EVGL_Color_Bit 202 { 203 COLOR_NONE = 0, 204 COLOR_RGB_888 = 0x1, 205 COLOR_RGBA_8888 = 0x3, 206 } EVGL_Color_Bit; 207 208 209 typedef enum _EVGL_Depth_Bit 210 { 211 DEPTH_NONE = 0, 212 DEPTH_BIT_8 = 0x1, 213 DEPTH_BIT_16 = 0x3, 214 DEPTH_BIT_24 = 0x7, 215 DEPTH_BIT_32 = 0xF, 216 DEPTH_STENCIL = 0xFF, 217 } EVGL_Depth_Bit; 218 219 typedef enum _EVGL_Stencil_Bit 220 { 221 STENCIL_NONE = 0, 222 STENCIL_BIT_1 = 0x1, 223 STENCIL_BIT_2 = 0x3, 224 STENCIL_BIT_4 = 0x7, 225 STENCIL_BIT_8 = 0xF, 226 STENCIL_BIT_16 = 0x1F, 227 } EVGL_Stencil_Bit; 228 229 230 struct _EVGL_Surface_Format 231 { 232 int index; 233 234 EVGL_Color_Bit color_bit; 235 GLint color_ifmt; 236 GLenum color_fmt; 237 238 EVGL_Depth_Bit depth_bit; 239 GLenum depth_fmt; 240 241 EVGL_Stencil_Bit stencil_bit; 242 GLenum stencil_fmt; 243 244 GLenum depth_stencil_fmt; 245 246 int samples; 247 }; 248 249 struct _EVGL_Cap 250 { 251 EVGL_Surface_Format fbo_fmts[100]; 252 int num_fbo_fmts; 253 254 int max_w; 255 int max_h; 256 257 int msaa_supported; 258 int msaa_samples[3]; // High, Med, Low 259 }; 260 261 struct _EVGL_Resource 262 { 263 Eina_Thread id; 264 265 EVGLNative_Display display; 266 EVGLNative_Context context; 267 EVGLNative_Window window; 268 EVGLNative_Surface surface; 269 270 EVGL_Context *current_ctx; 271 void *current_eng; 272 273 int error_state; 274 275 struct { 276 EVGLNative_Surface surface; 277 int rendered; 278 279 int rot; 280 int win_w; 281 int win_h; 282 283 struct { 284 int x, y, w, h; 285 } img; 286 287 struct { 288 int x, y, w, h; 289 } clip; 290 291 struct { 292 int preserve; 293 Eina_Bool enabled : 1; 294 } partial; 295 296 Eina_Bool enabled : 1; 297 Eina_Bool in_get_pixels : 1; 298 Eina_Bool render_op_copy : 1; 299 } direct; 300 struct { 301 GLclampf r, g, b, a; 302 } clear_color; 303 struct { 304 void *data; 305 void *surface; 306 void *context; 307 } stored; 308 309 }; 310 311 struct _EVGL_Engine 312 { 313 int initted; 314 315 const EVGL_Interface *funcs; 316 317 EVGL_Cap caps; 318 319 const char *gl_ext; 320 const char *evgl_ext; 321 322 // Resource context/surface per Thread in TLS for evasgl use 323 LK(resource_lock); 324 Eina_TLS resource_key; 325 Eina_List *resource_list; 326 Eina_Thread main_tid; 327 328 // Add more debug logs (DBG levels 4 and 6) 329 int api_debug_mode; 330 331 // Force Off for Debug purposes 332 int direct_force_off; 333 334 // Other DR flags for debugging purposes 335 int direct_override; 336 int direct_mem_opt; 337 338 // Force Direct Scissoring off for Debug purposes 339 int direct_scissor_off; 340 341 // Keep track of all the current surfaces/contexts 342 Eina_List *surfaces; 343 Eina_List *contexts; 344 345 //void *engine_data; 346 Eina_Hash *safe_extensions; 347 }; 348 349 350 // Evas GL Engine 351 extern EVGL_Engine *evgl_engine; 352 353 // Internally used functions 354 extern void _evgl_api_gles2_get(Evas_GL_API *api, Eina_Bool debug); 355 extern void _evgl_api_gles1_get(Evas_GL_API *api, Eina_Bool debug); 356 extern void _evgl_api_gles3_get(Evas_GL_API *funcs, void *(*get_proc_address)(const char *), Eina_Bool debug, int minor_version); 357 extern EVGL_Resource *_evgl_tls_resource_get(void); 358 extern EVGL_Resource *_evgl_tls_resource_create(void *data); 359 extern void _evgl_tls_resource_destroy(void *data); 360 extern EVGL_Context *_evgl_current_context_get(void); 361 extern int _evgl_not_in_pixel_get(void); 362 extern int _evgl_direct_enabled(void); 363 extern EVGLNative_Context _evgl_native_context_get(Evas_GL_Context *ctx); 364 extern void *_evgl_engine_data_get(Evas_GL *evasgl); 365 Eina_Bool _evgl_api_gles2_ext_init(void *getproc, const char *glueexts); 366 Eina_Bool _evgl_api_gles1_ext_init(void *getproc, const char *glueexts); 367 Eina_Bool _evgl_api_gles3_ext_init(void *getproc, const char *glueexts); 368 Evas_GL_API* _evgl_api_gles1_internal_get(void); 369 Evas_GL_API* _evgl_api_gles3_internal_get(void); 370 371 #endif //_EVAS_GL_CORE_PRIVATE_H 372