PageRenderTime 55ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/GT-I5700/gles20/src/glCore.cpp

https://github.com/DE-NISkA/cm_android_vendor_spica
C++ | 3905 lines | 3103 code | 552 blank | 250 comment | 519 complexity | 1bb512e6cd9dc82d173d9e917e59523a MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. /*
  2. *******************************************************************************
  3. *
  4. * SAMSUNG INDIA SOFTWARE OPERATIONS
  5. * Copyright(C) 2006
  6. * ALL RIGHTS RESERVED
  7. *
  8. * This program is proprietary to Samsung India Software Operations Pvt. Ltd.,
  9. * and is protected under International Copyright Act as an unpublished work.Its
  10. * use and disclosure is limited by the terms and conditions of a license agree-
  11. * -ment. It may not be copied or otherwise reproduced or disclosed to persons
  12. * outside the licensee's organization except in accordance with the terms and
  13. * conditions of such an agreement. All copies and reproductions shall be the
  14. * property of Samsung India Software Operations Pvt. Ltd. and must bear this
  15. * notice in its entirety.
  16. *
  17. *******************************************************************************
  18. */
  19. /*
  20. ***************************************************************************//*!
  21. *
  22. * \file glCore.cpp
  23. * \author Sandeep Kakarlapudi (s.kakarla@samsung.com)
  24. * Anurag Ved (anuragv@samsung.com)
  25. * \brief Implementation of Core functionality of GL
  26. *
  27. *//*---------------------------------------------------------------------------
  28. * NOTES:
  29. *
  30. *//*---------------------------------------------------------------------------
  31. * HISTORY:
  32. *
  33. * 07.08.2006 Sandeep Kakarlapudi Initial version from OGL2_glfimg.c
  34. *
  35. *******************************************************************************
  36. */
  37. #include <stdio.h>
  38. #include <stdlib.h>
  39. #include <string.h>
  40. //TODO: modify the includes
  41. #include "glState.h"
  42. #include "glFimg.h"
  43. //#include "egl.h"
  44. #include "buffers.h"
  45. #include "pixel.h"
  46. #include "platform.h"
  47. #include "glprof.h"
  48. #include <cutils/log.h>
  49. #include <time.h>
  50. /*
  51. *******************************************************************************
  52. * Global Variable Definitions
  53. *******************************************************************************
  54. */
  55. #ifndef MULTI_CONTEXT
  56. OGLState *pgles2State;
  57. #endif
  58. static GLuint gContextIDCounter = 2000;
  59. #ifdef CACHE_MEM
  60. extern void invalidate_cached_buffer(void);
  61. extern void clean_cached_buffer(void);
  62. extern void clean_invalidate_cached_buffer(void);
  63. #endif
  64. extern int fimgPowerInit(void);
  65. extern int fimgPowerStatus(void);
  66. extern int lock3DCriticalSection(void);
  67. extern int unlock3DCriticalSection(void);
  68. bool stateFlush( OGLState * ctx);
  69. //TODO: Need a cleanup function
  70. static void gfSetFrameBuffer(OGLState* ctx, GLint Width, GLint Height)
  71. {
  72. // GET_GL_STATE(ctx);
  73. ctx->viewport_data.x = 0;
  74. ctx->viewport_data.y = 0;
  75. ctx->viewport_data.w = Width;
  76. ctx->viewport_data.h = Height;
  77. ctx->scissor_test_data.w = Width;
  78. ctx->scissor_test_data.h = Height;
  79. ctx->scissor_test_data.x = 0;
  80. ctx->scissor_test_data.y = 0;
  81. }
  82. static void set_default_values(OGLState* ctx)
  83. {
  84. ctx->version = 20;
  85. ctx->id = gContextIDCounter++;
  86. ctx->init_dimensions = GL_TRUE;
  87. // GLint W_WIDTH = ctx->defFBData.width;
  88. // GLint W_HEIGHT = ctx->defFBData.height;
  89. ctx->sharedState = NULL;
  90. for(int i=0; i<MAX_VERTEX_ATTRIBS; i++)
  91. {
  92. ctx->vertex_attribs[i][0] = ctx->vertex_attribs[i][1] = ctx->vertex_attribs[i][2] = 0.0f;
  93. ctx->vertex_attribs[i][3] = 1.0f;
  94. }
  95. for(int i=0; i<MAX_VERTEX_ATTRIBS; i++)
  96. {
  97. ctx->vertex_attrib_array_data[i].size = 4;
  98. ctx->vertex_attrib_array_data[i].type = GL_FLOAT;
  99. ctx->vertex_attrib_array_data[i].normalized = GL_FALSE;
  100. ctx->vertex_attrib_array_data[i].stride = 0;
  101. ctx->vertex_attrib_array_data[i].ptr = NULL;
  102. ctx->vertex_attrib_array_data[i].enabled = GL_FALSE;
  103. ctx->vertex_attrib_array_data[i].vboID = 0;
  104. ctx->vertex_attrib_array_data[i].vertex_attrib_ptr_binding = NULL;
  105. }
  106. Plat::memset(&(ctx->buffer_object_data),0,sizeof(BufferObjectData));
  107. ctx->depth_range_data.near_depth =0.0f;
  108. ctx->depth_range_data.far_depth =1.0f;
  109. /*
  110. ctx->viewport_data.x = 0;
  111. ctx->viewport_data.y = 0;
  112. ctx->viewport_data.w = W_WIDTH;
  113. ctx->viewport_data.h = W_HEIGHT;
  114. */
  115. ctx->front_face_mode = GL_CCW;
  116. ctx->point_size = 1.0f;
  117. ctx->line_width = 1.0f;
  118. ctx->cull_face_data.is_enabled = GL_FALSE;
  119. ctx->cull_face_data.mode = GL_BACK;
  120. ctx->polygon_offset_data.factor = 0.0;
  121. ctx->polygon_offset_data.units = 0.0;
  122. ctx->polygon_offset_data.is_enabled_fill = GL_FALSE;
  123. ctx->pixel_store_data.pack_alignment = 4;
  124. ctx->pixel_store_data.unpack_alignment = 4;
  125. ctx->sample_coverage_data.is_enabled_alpha_to_coverage = GL_FALSE;
  126. ctx->sample_coverage_data.is_enabled_coverage = GL_FALSE;
  127. ctx->sample_coverage_data.value = 1.0f;
  128. ctx->sample_coverage_data.invert = GL_FALSE;
  129. ctx->stencil_test_data.is_enabled = GL_FALSE;
  130. ctx->stencil_test_data.front_face_func = GL_ALWAYS;
  131. ctx->stencil_test_data.front_face_mask = ~0;
  132. ctx->stencil_test_data.front_face_ref = 0;
  133. ctx->stencil_test_data.front_face_fail = GL_KEEP;
  134. ctx->stencil_test_data.front_face_zfail = GL_KEEP;
  135. ctx->stencil_test_data.front_face_zpass = GL_KEEP;
  136. ctx->stencil_test_data.back_face_func = GL_ALWAYS;
  137. ctx->stencil_test_data.back_face_mask = ~0;
  138. ctx->stencil_test_data.back_face_ref = 0;
  139. ctx->stencil_test_data.back_face_fail = GL_KEEP;
  140. ctx->stencil_test_data.back_face_zfail = GL_KEEP;
  141. ctx->stencil_test_data.back_face_zpass = GL_KEEP;
  142. ctx->blend_data.is_enabled = GL_FALSE;
  143. ctx->blend_data.fn_srcRGB = GL_ONE;
  144. ctx->blend_data.fn_srcAlpha = GL_ONE;
  145. ctx->blend_data.fn_dstRGB = GL_ZERO;
  146. ctx->blend_data.fn_dstAlpha = GL_ZERO;
  147. ctx->blend_data.eqn_modeRGB = GL_FUNC_ADD;
  148. ctx->blend_data.eqn_modeAlpha = GL_FUNC_ADD;
  149. ctx->blend_data.blnd_clr_alpha = 0;
  150. ctx->blend_data.blnd_clr_blue = 0;
  151. ctx->blend_data.blnd_clr_green = 0;
  152. ctx->blend_data.blnd_clr_red = 0;
  153. ctx->scissor_test_data.is_enabled = GL_FALSE;
  154. /* ctx->scissor_test_data.w = W_WIDTH;
  155. ctx->scissor_test_data.h = W_HEIGHT;
  156. ctx->scissor_test_data.x = 0;
  157. ctx->scissor_test_data.y = 0;
  158. */
  159. ctx->depth_test_func = GL_LESS;
  160. ctx->is_enabled_depth = GL_FALSE;
  161. ctx->depth_write_mask = GL_TRUE;
  162. ctx->front_stencil_writemask = ~0;
  163. ctx->back_stencil_writemask = ~0;
  164. ctx->color_mask_data.r = GL_TRUE;
  165. ctx->color_mask_data.g = GL_TRUE;
  166. ctx->color_mask_data.b = GL_TRUE;
  167. ctx->color_mask_data.a = GL_TRUE;
  168. ctx->clear_color_data.r = 0;
  169. ctx->clear_color_data.g = 0;
  170. ctx->clear_color_data.b = 0;
  171. ctx->clear_color_data.a = 0;
  172. ctx->clear_depth = 1.0f;
  173. ctx->clear_stencil = 0;
  174. ctx->is_enabled_dither = GL_TRUE;
  175. ctx->is_enabled_vertex_program_point_size = GL_FALSE;
  176. ctx->hint_data.generate_mipmap_hint = GL_DONT_CARE;
  177. ctx->hint_data.fragment_shader_derivative_hint = GL_DONT_CARE;
  178. // ctx->shader_and_program_data; //TODO: verify this is to be set to zero
  179. ctx->current_program = 0;
  180. ctx->error = GL_NO_ERROR;
  181. ctx->str_data.version = "2.0"; //not used, instead GLES2_VERSION_STRING is used
  182. ctx->str_data.vendor = "Samsung Electronics";
  183. ctx->str_data.renderer = "FIMG";
  184. ctx->str_data.extensions = "OES_read_format OES_compressed_paletted_texture OES_framebuffer_object OES_stencil8 OES_texture_compression_S3TC OES_mapbuffer OES_texture_npot " ;
  185. ctx->str_data.shadingLangVersion = "1.00";
  186. #ifdef EN_EXT_ALPHA_TEST_EXP
  187. ctx->alpha_test_data.func = GL_ALWAYS;
  188. ctx->alpha_test_data.refValue = 0.0f;
  189. ctx->alpha_test_data.is_enabled = false;
  190. #endif
  191. #ifdef EN_EXT_LOGIC_OP_EXP
  192. ctx->logicOp = GL_COPY_EXP;
  193. ctx->is_logicOp_enabled = GL_FALSE;
  194. #endif
  195. #ifdef EN_EXT_POINT_SPRITE_EXP
  196. ctx->is_point_sprite_enable = GL_TRUE; //for default case this should be always true
  197. #endif
  198. //clear out temporary data;
  199. Plat::memset(ctx->tempStrBuff,0,GLF_TEMP_STRING_BUFFER_LENGTH);
  200. ctx->tempInt4[0] = ctx->tempInt4[1] = ctx->tempInt4[2] = ctx->tempInt4[3] = 0;
  201. ctx->tempFloat4[0] = ctx->tempFloat4[1] = ctx->tempFloat4[2] = ctx->tempFloat4[3] = 0.0f;
  202. Plat::memset(&(ctx->prevFBData), 0, sizeof(FramebufferData));
  203. Plat::memset(&(ctx->curFBData), 0, sizeof(FramebufferData));
  204. ctx->VPPSEnable = false;
  205. gfSetFrameBuffer(ctx,0, 0);
  206. }
  207. #ifdef USE_3D_PM
  208. GLboolean PM_GLES2SetSurfaceData(GLES2SurfaceData * surfdata);
  209. extern "C" GLboolean GLES2SetSurfaceData(GLES2SurfaceData * surfdata)
  210. {
  211. GLboolean retVal = GL_FALSE;
  212. lock3DCriticalSection();
  213. retVal = PM_GLES2SetSurfaceData(surfdata);
  214. unlock3DCriticalSection();
  215. return retVal;
  216. }
  217. GLboolean PM_GLES2SetSurfaceData(GLES2SurfaceData * surfdata)
  218. #else
  219. extern "C" GLboolean GLES2SetSurfaceData(GLES2SurfaceData * surfdata)
  220. #endif
  221. {
  222. if(surfdata)
  223. {
  224. GET_GL_STATE(ctx);
  225. if(!ctx)
  226. {
  227. //LOGMSG("ERROR: ctx is 0 while trying to set SurfaceData");
  228. }
  229. //FimgFinish(ctx);
  230. #if 0
  231. FramebufferData* fbData;
  232. fbData = (FramebufferData*)Plat::malloc(sizeof(FramebufferData));
  233. fbData->colorAddr.vaddr = surfdata->colorAddr2.vaddr;
  234. fbData->colorAddr.paddr = surfdata->colorAddr2.paddr;
  235. fbData->depthStencilAddr.vaddr = surfdata->depthStencilAddr.vaddr;
  236. fbData->depthStencilAddr.paddr = surfdata->depthStencilAddr.paddr;
  237. fbData->width = surfdata->width;
  238. fbData->height = surfdata->height;
  239. fbData->nativeColorFormat = surfdata->nativeColorFormat;
  240. fbData->nativeDepthStencilFormat = surfdata->nativeDepthStencilFormat;
  241. fbData->flipped = surfdata->flipped;
  242. #endif
  243. //Plat::printf("id %d egl make current = %p \n" ,pthread_self(), surfdata->colorAddr.paddr);
  244. Plat::memcpy(&(ctx->defFBData), surfdata, sizeof(FramebufferData));
  245. #if 0
  246. ctx->colorBuff1.vaddr = surfdata->colorAddr1.vaddr;
  247. ctx->colorBuff1.paddr = surfdata->colorAddr1.paddr;
  248. ctx->colorBuff2.vaddr = surfdata->colorAddr2.vaddr;
  249. ctx->colorBuff2.paddr = surfdata->colorAddr2.paddr;
  250. ctx->colorBuff3.vaddr = surfdata->colorAddr3.vaddr;
  251. ctx->colorBuff3.paddr = surfdata->colorAddr3.paddr;
  252. #endif
  253. if(ctx->init_dimensions)
  254. {
  255. gfSetFrameBuffer(ctx,ctx->defFBData.width,ctx->defFBData.height);
  256. ctx->init_dimensions = GL_FALSE;
  257. }
  258. }
  259. return GL_TRUE;
  260. }
  261. extern "C" GLboolean GLES2SetDrawSurface(GLES2SurfaceData *surface)
  262. {
  263. if(surface)
  264. {
  265. GET_GL_STATE(ctx);
  266. if(!ctx)
  267. {
  268. //LOGMSG("ERROR: ctx is 0 while trying to set DrawSurfaceData");
  269. }
  270. //FimgFinish(ctx); // 090827 : "color touch lite" app bug patch
  271. Plat::memcpy(&(ctx->defFBData), surface, sizeof(FramebufferData));
  272. if(ctx->init_dimensions)
  273. {
  274. gfSetFrameBuffer(ctx,ctx->defFBData.width, ctx->defFBData.height);
  275. ctx->init_dimensions = GL_FALSE;
  276. }
  277. }
  278. return GL_TRUE;
  279. }
  280. #ifdef USE_3D_PM
  281. GLboolean PM_GLES2SetReadSurface(GLES2SurfaceData *surface);
  282. extern "C" GLboolean GLES2SetReadSurface(GLES2SurfaceData *surface)
  283. {
  284. GLboolean retVal = GL_FALSE;
  285. lock3DCriticalSection();
  286. retVal = PM_GLES2SetReadSurface(surface);
  287. unlock3DCriticalSection();
  288. return retVal;
  289. }
  290. GLboolean PM_GLES2SetReadSurface(GLES2SurfaceData *surface)
  291. #else
  292. extern "C" GLboolean GLES2SetReadSurface(GLES2SurfaceData *surface)
  293. #endif
  294. {
  295. if(surface)
  296. {
  297. GET_GL_STATE(ctx);
  298. if(!ctx)
  299. {
  300. //LOGMSG("ERROR: ctx is 0 while trying to set DrawSurfaceData");
  301. }
  302. //FimgFinish(ctx); // 090827 : "color touch lite" app bug patch
  303. Plat::memcpy(&(ctx->readFBData), surface, sizeof(FramebufferData));
  304. }
  305. return GL_TRUE;
  306. }
  307. #ifdef USE_3D_PM
  308. GLES2Context PM_GLES2CreateContext(GLES2Context sharedctx);
  309. extern "C" GLES2Context GLES2CreateContext(GLES2Context sharedctx)
  310. {
  311. GLES2Context retVal = NULL;
  312. lock3DCriticalSection();
  313. retVal = PM_GLES2CreateContext(sharedctx);
  314. unlock3DCriticalSection();
  315. return retVal;
  316. }
  317. GLES2Context PM_GLES2CreateContext(GLES2Context sharedctx)
  318. #else
  319. extern "C" GLES2Context GLES2CreateContext(GLES2Context sharedctx)
  320. #endif
  321. {
  322. #ifndef MULTI_CONTEXT
  323. if(sharedctx != GLES_NO_CONTEXT){
  324. //LOGMSG("ERROR: Sharing texture object withour using multi-context");
  325. sharedctx = GLES_NO_CONTEXT;
  326. }
  327. #endif
  328. #ifdef FIMG_GLES_11
  329. OGLState *ctx = new OGLState();
  330. #else
  331. #ifdef MULTI_CONTEXT
  332. OGLState *ctx = new OGLState();
  333. SET_GL_STATE(ctx)
  334. #else
  335. pgles2State = new OGLState(); //ctx = new OGLState();
  336. GET_GL_STATE(ctx);
  337. #endif
  338. #endif
  339. //part of context not being shared so need to be initialized everytime
  340. set_default_values(ctx);
  341. InitShaderState(ctx);
  342. glfInit(ctx);
  343. //Init FBO state
  344. ctx->renderbuffState.setDefaults();
  345. ctx->framebuffState.setDefaults();
  346. //Init local texture state
  347. InitLocalTextureState(ctx);
  348. SharedState* sharedState = NULL;
  349. if(sharedctx == GLES_NO_CONTEXT){
  350. sharedState = new SharedState();
  351. #ifdef SHARED_CONTEXT_DEBUG
  352. //LOGMSG("\n \"shared context\" being created \n");
  353. #endif
  354. }
  355. else
  356. {
  357. //as to share the state need to make it equal to the ctx being passed as argument
  358. sharedState = ((OGLState *)sharedctx)->sharedState;
  359. #ifdef SHARED_CONTEXT_DEBUG
  360. //LOGMSG("\n \"shared context\" being initailized from another context \n");
  361. #endif
  362. }
  363. ctx->sharedState = sharedState;
  364. lockGLSharedState(ctx); //lock the shared state before any opeartion
  365. ctx->sharedState->sharedStateRefCount++;
  366. unlockGLSharedState(ctx); //unlock the shared state before any opeartion
  367. #ifdef SHARED_CONTEXT_DEBUG
  368. //LOGMSG("\n shared state ref count = %d : gles2createContext \n" , ctx->sharedState->sharedStateRefCount);
  369. #endif
  370. #ifdef FSO_JITO
  371. ctx->cgd = constructCodegenData();
  372. #endif
  373. return ctx;
  374. }
  375. extern "C" GLES2Context GLES2SetContext(GLES2Context glctx)
  376. {
  377. GET_GL_STATE_NOCHECK(prev_ctx);
  378. if(glctx != NULL)
  379. {
  380. #ifndef FIMG_GLES_11
  381. #ifdef MULTI_CONTEXT
  382. SET_GL_STATE(glctx)
  383. #else
  384. pgles2State = (OGLState *)glctx;
  385. #endif
  386. #endif
  387. }
  388. return prev_ctx;
  389. }
  390. extern "C" GLboolean GLES2DestroyContext(GLES2Context _ctx)
  391. {
  392. OGLState* ctx = (OGLState*)_ctx;
  393. //GET_GL_STATE(ctx);
  394. if(!ctx)
  395. {
  396. return GL_FALSE;
  397. }
  398. ((OGLState*) ctx)->framebuffState.setDefaults();
  399. ((OGLState*) ctx)->renderbuffState.setDefaults();
  400. for(int i = 0; i < ((OGLState*) ctx)->buffer_object_data.buffer_objects_last_index; i++){
  401. if( ((OGLState*) ctx)->buffer_object_data.buffer_objects[i].data){
  402. free(ctx->buffer_object_data.buffer_objects[i].data);
  403. ctx->buffer_object_data.buffer_objects[i].data=NULL;
  404. }
  405. }
  406. DeInitShaderState((OGLState*)ctx);
  407. lockGLSharedTextureState(ctx);
  408. DeInitLocalTextureState(ctx);
  409. unlockGLSharedTextureState(ctx);
  410. lockGLSharedState(ctx); //lock the shared state before any opeartion
  411. ctx->sharedState->sharedStateRefCount--;
  412. #ifdef SHARED_CONTEXT_DEBUG
  413. //LOGMSG("\n shared state ref count = %d : GLES2DestroyContext \n" , ctx->sharedState->sharedStateRefCount);
  414. #endif
  415. unlockGLSharedState(ctx); //unlock the shared state before any opeartion
  416. if(ctx->sharedState->sharedStateRefCount == 0){
  417. delete(ctx->sharedState);
  418. ctx->sharedState = NULL;
  419. }else{
  420. ctx->sharedState = NULL;
  421. }
  422. #ifdef FSO_JITO
  423. destroyCodegenData(((OGLState*) ctx)->cgd);
  424. ((OGLState*) ctx)->cgd = 0;
  425. #endif
  426. #ifndef MULTI_CONTEXT
  427. delete pgles2State;
  428. pgles2State = 0;
  429. #else
  430. delete ctx;
  431. ctx = NULL;
  432. #endif
  433. return GL_TRUE;
  434. }
  435. #ifdef USE_3D_PM
  436. GLboolean PM_GLES2Flush(void);
  437. extern "C" GLboolean GLES2Flush(void)
  438. {
  439. GLboolean retVal = GL_FALSE;
  440. lock3DCriticalSection();
  441. retVal = PM_GLES2Flush();
  442. unlock3DCriticalSection();
  443. return retVal;
  444. }
  445. GLboolean PM_GLES2Flush(void)
  446. #else
  447. extern "C" GLboolean GLES2Flush(void)
  448. #endif
  449. {
  450. GET_GL_STATE(ctx);
  451. FimgFinish(ctx);
  452. return GL_TRUE;
  453. }
  454. glfError FimgFinish(OGLState* pState)
  455. {
  456. Plat::lockGPUSFR(__FUNCTION__);
  457. glfFinish(pState);
  458. Plat::unlockGPUSFR(__FUNCTION__);
  459. return GLF_ERR_SUCCESS;
  460. }
  461. void set_err(GLenum err)
  462. {
  463. GET_GL_STATE(ctx);
  464. // //LOGMSG("\nGLERROR: %s from %s\n", getGLErrorString(err), getLastGLFunc());
  465. #ifdef _MSC_VER
  466. // __asm int 3;
  467. #endif
  468. if(ctx->error == GL_NO_ERROR) //Do not overwrite older error
  469. {
  470. ctx->error = err;
  471. }
  472. }
  473. void set_err(OGLState *ctx, GLenum err)
  474. {
  475. // //LOGMSG("\nGLERROR: %s from %s\n", getGLErrorString(err), getLastGLFunc());
  476. #ifdef _MSC_VER
  477. //TODO: remove this? This is useful while testnig the statemanagement with
  478. // visual studio
  479. // __asm int 3;
  480. #endif
  481. if(ctx->error == GL_NO_ERROR) //Do not overwrite older error
  482. {
  483. ctx->error = err;
  484. }
  485. // LOGE("ERROR in 2.0 ::%d",ctx->error);
  486. }
  487. /* determines the number of bytes per pixel based on 'format' and 'type' */
  488. int determine_bpp(GLenum format, GLenum type)
  489. {
  490. int bpp = 0;
  491. if((format == GL_RGBA) && (type == GL_UNSIGNED_BYTE))
  492. {
  493. bpp = 4;
  494. }
  495. else if((format == GL_RGB) && (type == GL_UNSIGNED_BYTE))
  496. {
  497. bpp = 3;
  498. }
  499. else if((format == GL_RGBA) && (type == GL_UNSIGNED_SHORT_4_4_4_4))
  500. {
  501. bpp = 2;
  502. }
  503. else if((format == GL_RGBA) && (type == GL_UNSIGNED_SHORT_5_5_5_1))
  504. {
  505. bpp = 2;
  506. }
  507. else if((format == GL_RGB) && (type == GL_UNSIGNED_SHORT_5_6_5))
  508. {
  509. bpp = 2;
  510. }
  511. else if((format == GL_LUMINANCE_ALPHA) && (type == GL_UNSIGNED_BYTE))
  512. {
  513. bpp = 2;
  514. }
  515. else if((format == GL_LUMINANCE) && (type == GL_UNSIGNED_BYTE))
  516. {
  517. bpp = 1;
  518. }
  519. else if((format == GL_ALPHA) && (type == GL_UNSIGNED_BYTE))
  520. {
  521. bpp = 1;
  522. }
  523. else
  524. {
  525. set_err(GL_INVALID_ENUM);
  526. }
  527. return bpp;
  528. }
  529. GLboolean isValidBlendFunc(GLenum factor)
  530. {
  531. switch(factor)
  532. {
  533. case GL_ZERO:
  534. case GL_ONE:
  535. case GL_SRC_COLOR:
  536. case GL_ONE_MINUS_SRC_COLOR:
  537. case GL_SRC_ALPHA:
  538. case GL_ONE_MINUS_SRC_ALPHA:
  539. case GL_DST_ALPHA:
  540. case GL_ONE_MINUS_DST_ALPHA:
  541. case GL_DST_COLOR:
  542. case GL_ONE_MINUS_DST_COLOR:
  543. case GL_SRC_ALPHA_SATURATE:
  544. case GL_CONSTANT_COLOR:
  545. case GL_ONE_MINUS_CONSTANT_COLOR:
  546. case GL_CONSTANT_ALPHA:
  547. case GL_ONE_MINUS_CONSTANT_ALPHA:
  548. return GL_TRUE; //intended fall through
  549. break;
  550. }
  551. return GL_FALSE;
  552. }
  553. GLboolean isValidDepthFunc(GLenum func)
  554. {
  555. switch(func)
  556. {
  557. case GL_NEVER:
  558. case GL_LESS:
  559. case GL_EQUAL:
  560. case GL_LEQUAL:
  561. case GL_GREATER:
  562. case GL_NOTEQUAL:
  563. case GL_GEQUAL:
  564. case GL_ALWAYS:
  565. return GL_TRUE;
  566. break;
  567. }
  568. return GL_FALSE;
  569. }
  570. GLboolean isValidStencilOp(GLenum op)
  571. {
  572. //should be GL_KEEP, GL_ZERO, GL_REPLACE, GL_INCR, GL_DECR, and GL_INVERT
  573. switch(op)
  574. {
  575. case GL_KEEP:
  576. case GL_ZERO:
  577. case GL_REPLACE:
  578. case GL_INCR:
  579. case GL_DECR:
  580. case GL_INVERT:
  581. return GL_TRUE; //intended fall though
  582. }
  583. return GL_FALSE;
  584. }
  585. GL_API void GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
  586. {
  587. GET_GL_STATE(ctx);
  588. ctx->blend_data.blnd_clr_red = clamp(red);
  589. ctx->blend_data.blnd_clr_green = clamp(green);
  590. ctx->blend_data.blnd_clr_blue = clamp(blue);
  591. ctx->blend_data.blnd_clr_alpha = clamp(alpha);
  592. SetUpDateFlagPerFragment(ctx,GLF_UF_Blend);
  593. }
  594. GL_API void GL_APIENTRY glBlendEquation( GLenum mode )
  595. {
  596. //GET_GL_STATE(ctx);
  597. glBlendEquationSeparate(mode, mode);
  598. }
  599. GL_API void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
  600. {
  601. GET_GL_STATE(ctx);
  602. switch(modeRGB)
  603. {
  604. case GL_FUNC_ADD:
  605. case GL_FUNC_SUBTRACT:
  606. case GL_FUNC_REVERSE_SUBTRACT:
  607. break; //Intended fallthough
  608. default:
  609. set_err(GL_INVALID_ENUM);
  610. return;
  611. }
  612. switch(modeAlpha)
  613. {
  614. case GL_FUNC_ADD:
  615. case GL_FUNC_SUBTRACT:
  616. case GL_FUNC_REVERSE_SUBTRACT:
  617. break; //Intended fallthough
  618. default:
  619. set_err(GL_INVALID_ENUM);
  620. return;
  621. }
  622. ctx->blend_data.eqn_modeRGB = modeRGB;
  623. ctx->blend_data.eqn_modeAlpha = modeAlpha;
  624. SetUpDateFlagPerFragment(ctx,GLF_UF_Blend);
  625. }
  626. GL_API void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor)
  627. {
  628. //GET_GL_STATE(ctx);
  629. glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
  630. }
  631. GL_API void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
  632. {
  633. GET_GL_STATE(ctx);
  634. if(isValidBlendFunc(srcRGB) && isValidBlendFunc(dstRGB) && isValidBlendFunc(srcAlpha) && isValidBlendFunc(dstAlpha))
  635. {
  636. ctx->blend_data.fn_srcRGB = srcRGB;
  637. ctx->blend_data.fn_srcAlpha = srcAlpha;
  638. ctx->blend_data.fn_dstRGB = dstRGB;
  639. ctx->blend_data.fn_dstAlpha = dstAlpha;
  640. SetUpDateFlagPerFragment(ctx,GLF_UF_Blend);
  641. }
  642. else
  643. {
  644. set_err(GL_INVALID_ENUM);
  645. }
  646. }
  647. #ifdef USE_3D_PM
  648. void PM_glClear (GLbitfield mask);
  649. GL_API void GL_APIENTRY glClear (GLbitfield mask)
  650. {
  651. lock3DCriticalSection();
  652. PM_glClear(mask);
  653. unlock3DCriticalSection();
  654. }
  655. void PM_glClear (GLbitfield mask)
  656. #else
  657. GL_API void GL_APIENTRY glClear (GLbitfield mask)
  658. #endif
  659. {
  660. GET_GL_STATE(ctx);
  661. //Check if FB is complete Sandeep K.
  662. if(!isFBrenderable(ctx))
  663. {
  664. set_err(GL_INVALID_FRAMEBUFFER_OPERATION);
  665. return;
  666. }
  667. //glfFinish(ctx); //this is done inside glfClear.
  668. //SPEC: mask can only be a bitwise or of GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, GL_STENCIL_BUFFER_BIT
  669. GLbitfield temp = (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT|GL_COLOR_BUFFER_WITH_IMAGE_BIT);
  670. if( (mask & temp)!= mask)
  671. {
  672. set_err(GL_INVALID_ENUM);
  673. return;
  674. }
  675. Plat::lockGPUSFR(__FUNCTION__);
  676. #if FIMG_PLATFORM == 1
  677. #if GLF_DRAW == ENABLE
  678. glfClear(ctx, mask);
  679. #endif
  680. #ifdef CACHE_MEM
  681. clean_cached_buffer();
  682. #endif
  683. #endif
  684. Plat::unlockGPUSFR(__FUNCTION__);
  685. }
  686. GL_API void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
  687. {
  688. GET_GL_STATE(ctx);
  689. //SPEC: NOTE: clear color's clamping behaviour must change if float textures are supported. The values should not be in that case
  690. // and instead are clamped by the hw dependent code to suit the specific rendertarget's format.
  691. ctx->clear_color_data.r = clamp(red);
  692. ctx->clear_color_data.b = clamp(blue);
  693. ctx->clear_color_data.g = clamp(green);
  694. ctx->clear_color_data.a = clamp(alpha);
  695. }
  696. GL_API void GL_APIENTRY glClearDepthf (GLclampf depth)
  697. {
  698. GET_GL_STATE(ctx);
  699. //SPEC: [value] is clamped to the range [0, 1] and converted to fixed-point according to the rules for a window z value given in section 2.11.1
  700. //TODO: check and code the computation to find the fixedpoint value of depth clear value.
  701. ctx->clear_depth = clamp(depth);
  702. }
  703. GL_API void GL_APIENTRY glClearStencil (GLint s)
  704. {
  705. GET_GL_STATE(ctx);
  706. //SPEC: s is masked to the number of bitplanes available
  707. //TODO: who does the masking?
  708. ctx->clear_stencil = s;
  709. }
  710. GL_API void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
  711. {
  712. GET_GL_STATE(ctx);
  713. ctx->color_mask_data.r = red;
  714. ctx->color_mask_data.g = green;
  715. ctx->color_mask_data.b = blue;
  716. ctx->color_mask_data.a = alpha;
  717. SetUpDateFlagPerFragment(ctx,GLF_UF_ColorBuffer);
  718. }
  719. GL_API void GL_APIENTRY glCullFace (GLenum mode)
  720. {
  721. GET_GL_STATE(ctx);
  722. switch(mode)
  723. {
  724. case GL_FRONT:
  725. case GL_BACK:
  726. case GL_FRONT_AND_BACK:
  727. ctx->cull_face_data.mode = mode; //intended fallthrough
  728. SetUpDateFlagRasterEngine(ctx,GLF_UF_BackfaceCull);
  729. //ctx->updateBits.re = UB_RE_ALL;
  730. break;
  731. default:
  732. set_err(GL_INVALID_ENUM);
  733. return;
  734. }
  735. }
  736. GL_API void GL_APIENTRY glDepthFunc (GLenum func)
  737. {
  738. GET_GL_STATE(ctx);
  739. if(isValidDepthFunc(func))
  740. {
  741. ctx->depth_test_func = func;
  742. SetUpDateFlagPerFragment(ctx,GLF_UF_DepthTest);
  743. }
  744. else
  745. {
  746. set_err(GL_INVALID_ENUM);
  747. }
  748. }
  749. GL_API void GL_APIENTRY glDepthMask (GLboolean flag)
  750. {
  751. GET_GL_STATE(ctx);
  752. ctx->depth_write_mask = flag;
  753. SetUpDateFlagPerFragment(ctx,GLF_UF_DepthTest);
  754. }
  755. GL_API void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar)
  756. {
  757. GET_GL_STATE(ctx);
  758. ctx->depth_range_data.near_depth = clamp(zNear);
  759. ctx->depth_range_data.far_depth = clamp(zFar);
  760. SetUpDateFlagPrimEngine(ctx,GLF_UF_DepthRange);
  761. }
  762. GL_API void GL_APIENTRY glDisable (GLenum cap)
  763. {
  764. GET_GL_STATE(ctx);
  765. switch(cap)
  766. {
  767. // case GL_VERTEX_PROGRAM_POINT_SIZE: ctx->is_enabled_vertex_program_point_size = GL_FALSE; break;
  768. case GL_CULL_FACE:
  769. ctx->cull_face_data.is_enabled = GL_FALSE;
  770. SetUpDateFlagRasterEngine(ctx,GLF_UF_BackfaceCull);
  771. //ctx->updateBits.re = UB_RE_ALL;
  772. break;
  773. case GL_POLYGON_OFFSET_FILL:
  774. ctx->polygon_offset_data.is_enabled_fill = GL_FALSE;
  775. SetUpDateFlagRasterEngine(ctx,GLF_UF_DepthOffset);
  776. //ctx->updateBits.re = UB_RE_ALL;
  777. break;
  778. case GL_SCISSOR_TEST:
  779. ctx->scissor_test_data.is_enabled = GL_FALSE;
  780. #if GLF_SCISSOR_IN_RA == ENABLE
  781. SetUpDateFlagRasterEngine(ctx,GLF_UF_ScissorTest);
  782. #else
  783. SetUpDateFlagPerFragment(ctx, GLF_UF_ScissorTest);
  784. #endif
  785. break;
  786. case GL_SAMPLE_COVERAGE: ctx->sample_coverage_data.is_enabled_coverage = GL_FALSE; break;
  787. case GL_SAMPLE_ALPHA_TO_COVERAGE: ctx->sample_coverage_data.is_enabled_alpha_to_coverage = GL_FALSE; break;
  788. case GL_STENCIL_TEST:
  789. ctx->stencil_test_data.is_enabled = GL_FALSE;
  790. SetUpDateFlagPerFragment(ctx,GLF_UF_StencilTest);
  791. break;
  792. case GL_DEPTH_TEST:
  793. ctx->is_enabled_depth = GL_FALSE;
  794. SetUpDateFlagPerFragment(ctx,GLF_UF_DepthTest);
  795. break;
  796. case GL_BLEND:
  797. ctx->blend_data.is_enabled = GL_FALSE;
  798. SetUpDateFlagPerFragment(ctx,GLF_UF_Blend);
  799. break;
  800. case GL_DITHER: ctx->is_enabled_dither = GL_FALSE; break;
  801. #ifdef EN_EXT_ALPHA_TEST_EXP
  802. case GL_ALPHA_TEST_EXP:
  803. ctx->alpha_test_data.is_enabled = GL_FALSE;
  804. SetUpDateFlagPerFragment(ctx,GLF_UF_AlphaTest);
  805. break;
  806. #endif
  807. #ifdef EN_EXT_LOGIC_OP_EXP
  808. case GL_COLOR_LOGIC_OP_EXP:
  809. ctx->is_logicOp_enabled = GL_FALSE;
  810. SetUpDateFlagPerFragment(ctx,GLF_UF_LogicalOp);
  811. break;
  812. #endif
  813. #ifdef EN_EXT_POINT_SPRITE_EXP
  814. case GL_POINT_SPRITE_OES_EXP:
  815. ctx->is_point_sprite_enable = GL_FALSE;
  816. break;
  817. #endif
  818. default:
  819. set_err(GL_INVALID_ENUM);
  820. }
  821. }
  822. GL_API void GL_APIENTRY glDisableVertexAttribArray (GLuint index)
  823. {
  824. GET_GL_STATE(ctx);
  825. if(index >= MAX_VERTEX_ATTRIBS)
  826. {
  827. set_err(GL_INVALID_VALUE);
  828. return ;
  829. }
  830. ctx->vertex_attrib_array_data[index].enabled = GL_FALSE;
  831. }
  832. bool isDrawVertexCountValid(GLenum mode, GLsizei count)
  833. {
  834. if( count <= 0 )
  835. return false;
  836. switch(mode)
  837. {
  838. case GL_POINTS: return count > 0;
  839. case GL_LINE_STRIP: return count > 1;
  840. case GL_LINE_LOOP: return count > 1;
  841. case GL_LINES: return count > 1 ;
  842. case GL_TRIANGLES: return count > 2 ;
  843. case GL_TRIANGLE_STRIP: return count > 2;
  844. case GL_TRIANGLE_FAN: return count > 2;
  845. }
  846. gAssert(false && "Invalid enum in mode");
  847. return false; //To silence the compiler
  848. }
  849. #ifdef USE_3D_PM
  850. void PM_glDrawArrays (GLenum mode, GLint first, GLsizei count);
  851. GL_API void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count)
  852. {
  853. lock3DCriticalSection();
  854. PM_glDrawArrays( mode, first, count);
  855. unlock3DCriticalSection();
  856. }
  857. void PM_glDrawArrays (GLenum mode, GLint first, GLsizei count)
  858. #else
  859. GL_API void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count)
  860. #endif
  861. {
  862. GET_GL_STATE(ctx);
  863. //Validation---------------
  864. //TODO: validate mode, first and count.
  865. //TODO: validate that this will not access out of the range?
  866. if(mode != GL_POINTS && mode != GL_LINE_STRIP && mode != GL_LINE_LOOP && mode != GL_LINES
  867. && mode != GL_TRIANGLES && mode != GL_TRIANGLE_STRIP && mode != GL_TRIANGLE_FAN){
  868. set_err(GL_INVALID_ENUM);
  869. return;
  870. }
  871. if(first < 0)
  872. {
  873. set_err(GL_INVALID_VALUE);
  874. return;
  875. }
  876. if(!isDrawVertexCountValid(mode, count))
  877. {
  878. //set_err(GL_INVALID_VALUE); //Sliently ignore
  879. return;
  880. }
  881. //Check if FB is complete
  882. if(!isFBrenderable(ctx))
  883. {
  884. set_err(GL_INVALID_FRAMEBUFFER_OPERATION);
  885. return;
  886. }
  887. //Set whether VPPS should be enabled or not. All other VPPS dependent state configurations are set based on this value!
  888. Executable *pExe = ctx->current_executable;
  889. if(pExe->pointSizeIndex == -1 || (mode != GL_POINTS ) ) {
  890. ctx->VPPSEnable = false;
  891. }else {
  892. ctx->VPPSEnable = true;
  893. }
  894. Plat::lockGPUSFR(__FUNCTION__);
  895. //Drawing------------------------------------------
  896. if(!stateFlush(ctx))
  897. {
  898. //LOGMSG("\nWARNING: state has not been flushed to hw, current draw call ignored\n");
  899. Plat::unlockGPUSFR(__FUNCTION__);
  900. return;
  901. }
  902. glfSetDrawMode(ctx,mode);
  903. glfDraw(ctx, mode, first, count);
  904. Plat::unlockGPUSFR(__FUNCTION__);
  905. }
  906. #ifdef USE_3D_PM
  907. void PM_glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices);
  908. GL_API void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices)
  909. {
  910. lock3DCriticalSection();
  911. PM_glDrawElements( mode, count, type, indices);
  912. unlock3DCriticalSection();
  913. }
  914. void PM_glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices)
  915. #else
  916. GL_API void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices)
  917. #endif
  918. {
  919. GET_GL_STATE(ctx);
  920. const void * inds = indices;
  921. //Validation---------------
  922. if(mode != GL_POINTS && mode != GL_LINE_STRIP && mode != GL_LINE_LOOP && mode != GL_LINES
  923. && mode != GL_TRIANGLES && mode != GL_TRIANGLE_STRIP && mode != GL_TRIANGLE_FAN){
  924. set_err(GL_INVALID_ENUM);
  925. return;
  926. }
  927. if(!isDrawVertexCountValid(mode, count)){
  928. //set_err(GL_INVALID_VALUE); //silently ignore
  929. return;
  930. }
  931. /*
  932. if(indices == NULL){
  933. set_err(GL_INVALID_VALUE);
  934. return;
  935. }
  936. */
  937. if(ctx->buffer_object_data.element_array_buffer_binding == NULL) {
  938. if(indices == NULL) {
  939. return;
  940. }
  941. } else {
  942. if(ctx->buffer_object_data.element_array_buffer_binding->data == NULL) {
  943. return;
  944. }
  945. int offset = (char *)indices - (char*)NULL;
  946. inds = (void*) ((char*)ctx->buffer_object_data.element_array_buffer_binding->data + offset);
  947. }
  948. if(type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT && type != GL_UNSIGNED_INT){
  949. set_err(GL_INVALID_ENUM);
  950. return;
  951. }
  952. //Check if FB is complete
  953. if(!isFBrenderable(ctx))
  954. {
  955. set_err(GL_INVALID_FRAMEBUFFER_OPERATION);
  956. return;
  957. }
  958. //Set whether VPPS should be enabled or not. All other VPPS dependent state configurations are set based on this value!
  959. Executable *pExe = ctx->current_executable;
  960. if(pExe->pointSizeIndex == -1 || (mode != GL_POINTS ) ) {
  961. ctx->VPPSEnable = false;
  962. }else {
  963. ctx->VPPSEnable = true;
  964. }
  965. Plat::lockGPUSFR(__FUNCTION__);
  966. //Drawing------------------------------------------
  967. // State flush
  968. if(!stateFlush(ctx))
  969. {
  970. //LOGMSG("\nWARNING: state has not been flushed to hw, current draw call ignored\n");
  971. Plat::unlockGPUSFR(__FUNCTION__);
  972. return;
  973. }
  974. glfSetDrawMode(ctx, mode);
  975. glfDrawElements(ctx, mode, count, type, inds);
  976. Plat::unlockGPUSFR(__FUNCTION__);
  977. }
  978. GL_API void GL_APIENTRY glEnable (GLenum cap)
  979. {
  980. GET_GL_STATE(ctx);
  981. switch(cap)
  982. {
  983. //case GL_VERTEX_PROGRAM_POINT_SIZE: ctx->is_enabled_vertex_program_point_size = GL_TRUE; break;
  984. case GL_CULL_FACE:
  985. ctx->cull_face_data.is_enabled = GL_TRUE;
  986. SetUpDateFlagRasterEngine(ctx,GLF_UF_BackfaceCull);
  987. //ctx->updateBits.re = UB_RE_ALL;
  988. break;
  989. case GL_POLYGON_OFFSET_FILL:
  990. ctx->polygon_offset_data.is_enabled_fill = GL_TRUE;
  991. SetUpDateFlagRasterEngine(ctx,GLF_UF_DepthOffset);
  992. //ctx->updateBits.re = UB_RE_ALL;
  993. break;
  994. case GL_SCISSOR_TEST:
  995. ctx->scissor_test_data.is_enabled = GL_TRUE;
  996. #if GLF_SCISSOR_IN_RA == ENABLE
  997. SetUpDateFlagRasterEngine(ctx,GLF_UF_ScissorTest);
  998. #else
  999. SetUpDateFlagPerFragment(ctx, GLF_UF_ScissorTest);
  1000. #endif
  1001. break;
  1002. case GL_SAMPLE_COVERAGE: ctx->sample_coverage_data.is_enabled_coverage = GL_TRUE; break;
  1003. case GL_SAMPLE_ALPHA_TO_COVERAGE: ctx->sample_coverage_data.is_enabled_alpha_to_coverage = GL_TRUE; break;
  1004. case GL_STENCIL_TEST:
  1005. ctx->stencil_test_data.is_enabled = GL_TRUE;
  1006. SetUpDateFlagPerFragment(ctx,GLF_UF_StencilTest);
  1007. break;
  1008. case GL_DEPTH_TEST:
  1009. ctx->is_enabled_depth = GL_TRUE;
  1010. SetUpDateFlagPerFragment(ctx,GLF_UF_DepthTest);
  1011. break;
  1012. case GL_BLEND:
  1013. ctx->blend_data.is_enabled = GL_TRUE;
  1014. SetUpDateFlagPerFragment(ctx,GLF_UF_Blend);
  1015. break;
  1016. case GL_DITHER: ctx->is_enabled_dither = GL_TRUE; break;
  1017. #ifdef EN_EXT_ALPHA_TEST_EXP
  1018. case GL_ALPHA_TEST_EXP:
  1019. ctx->alpha_test_data.is_enabled = GL_TRUE;
  1020. SetUpDateFlagPerFragment(ctx,GLF_UF_AlphaTest);
  1021. break;
  1022. #endif
  1023. #ifdef EN_EXT_LOGIC_OP_EXP
  1024. case GL_COLOR_LOGIC_OP_EXP:
  1025. ctx->is_logicOp_enabled = GL_TRUE;
  1026. SetUpDateFlagPerFragment(ctx,GLF_UF_LogicalOp);
  1027. break;
  1028. #endif
  1029. #ifdef EN_EXT_POINT_SPRITE_EXP
  1030. case GL_POINT_SPRITE_OES_EXP:
  1031. ctx->is_point_sprite_enable = GL_TRUE;
  1032. break;
  1033. #endif
  1034. default:
  1035. set_err(GL_INVALID_ENUM);
  1036. }
  1037. }
  1038. GL_API void GL_APIENTRY glEnableVertexAttribArray (GLuint index)
  1039. {
  1040. GET_GL_STATE(ctx);
  1041. if(index >= MAX_VERTEX_ATTRIBS)
  1042. {
  1043. set_err(GL_INVALID_VALUE);
  1044. return ;
  1045. }
  1046. ctx->vertex_attrib_array_data[index].enabled = GL_TRUE;
  1047. }
  1048. static inline void updateBuiltinUniforms(ShaderExecutable& se, OGLState* ctx) {
  1049. float* uniforms = se.constFloatMemBlock;
  1050. const GLESBuiltinUniforms& indices = se.builtinUniformIndices;
  1051. if(indices.depthRange_near != -1) {
  1052. uniforms[indices.depthRange_near] = ctx->depth_range_data.near_depth;
  1053. }
  1054. if(indices.depthRange_far != -1) {
  1055. uniforms[indices.depthRange_far] = ctx->depth_range_data.far_depth;
  1056. }
  1057. if(indices.depthRange_diff != -1) {
  1058. uniforms[indices.depthRange_diff] = ctx->depth_range_data.far_depth - ctx->depth_range_data.near_depth;
  1059. }
  1060. }
  1061. bool stateFlush(OGLState * ctx)
  1062. {
  1063. TextureState* pTexState = &(ctx->texState);
  1064. TextureObject* pTexObj;
  1065. bool zz=updateCurrentExecutable();
  1066. if(zz)
  1067. {
  1068. Executable *pExe = ctx->current_executable;
  1069. int texUnitUsage = 0;
  1070. for(int i = 0; i < MAX_TEXTURE_UNITS; i++)
  1071. {
  1072. if(pExe->fsSamplerMappings[i].isUsed == false)
  1073. continue;
  1074. int texUnit = pExe->fsSamplerMappings[i].glTexUnit;
  1075. if(texUnit >= MAX_TEXTURE_UNITS){
  1076. //TO DO
  1077. //LOGMSG(" the value of the texUNit is greater than max. texture unit : %s", __FUNCTION__);
  1078. return false;
  1079. }
  1080. GLenum texType = pExe->fsSamplerMappings[i].type;
  1081. //instead of below mentioned thing need to call GLVALIDATEPROGRAM ??? CHECK IN SPEC TO DO
  1082. //It is not allowed to have variables of different sampler types pointing to the
  1083. //same texture image unit within a program object.
  1084. int bitToSet = 1<<( 3 * texUnit + (texType - GL_SAMPLER_2D));
  1085. int previousSamplerValue = (texUnitUsage >> (3 * texUnit)) & 7 ;
  1086. if(previousSamplerValue == 0){
  1087. texUnitUsage |= bitToSet;
  1088. }
  1089. else if( previousSamplerValue != (1 << (texType - GL_SAMPLER_2D))){
  1090. fprintf(stderr, "error /n");
  1091. SET_ERR(ctx, GL_INVALID_OPERATION, "glTexImage2D");
  1092. return false;
  1093. }
  1094. if(texType == GL_SAMPLER_2D)
  1095. {
  1096. #if STORE_TEX_OBJ_POINTER == ENABLE
  1097. pTexObj = pTexState->ptexUnitBinding[texUnit].texture2D;
  1098. #else
  1099. pTexObj = GetTextureObject(GL_TEXTURE_2D,true,texUnit);
  1100. // fprintf(stderr, " %p %p \n", pTexObj , &(pTexState->defaultTexObjects[TEX_2D_DEFAULT]);
  1101. #endif
  1102. ////LOGMSG(" pTexObj=%d pTestTexObj=%d \n" , pTexObj , pTestTexObj);
  1103. //gAssert((pTexObj == pTestTexObj) && "texture object pointer is wrong");
  1104. }
  1105. else if(texType == GL_SAMPLER_CUBE)
  1106. {
  1107. #if STORE_TEX_OBJ_POINTER == ENABLE
  1108. pTexObj = pTexState->ptexUnitBinding[texUnit].cubeMap;
  1109. #else
  1110. pTexObj = GetTextureObject(GL_TEXTURE_CUBE_MAP,true,texUnit);
  1111. #endif
  1112. ////LOGMSG(" pTexObj=%d pTestTexObj=%d \n" , pTexObj , pTestTexObj);
  1113. //gAssert((pTexObj == pTestTexObj) && "texture object pointer is wrong");
  1114. }
  1115. else if(texType == GL_SAMPLER_3D)
  1116. {
  1117. #if STORE_TEX_OBJ_POINTER == ENABLE
  1118. pTexObj = pTexState->ptexUnitBinding[texUnit].texture3D;
  1119. #else
  1120. pTexObj = GetTextureObject(GL_TEXTURE_3D,true,texUnit);
  1121. #endif
  1122. ////LOGMSG(" pTexObj=%d pTestTexObj=%d \n" , pTexObj , pTestTexObj);
  1123. //gAssert((pTexObj == pTestTexObj) && "texture object pointer is wrong");
  1124. }
  1125. else
  1126. {
  1127. //LOGMSG("Type of Sampler unknown\n");
  1128. return false;
  1129. }
  1130. GLboolean res = pTexObj->Compile();
  1131. if(res)
  1132. {
  1133. //texDim need not be a valid index since these special texDim uniforms
  1134. //are generated only if a varying is used as a tex coord.
  1135. if(pExe->dimensions.tex[i] != -1)
  1136. {
  1137. pExe->fs.constFloatMemBlock[pExe->dimensions.tex[i]] = float(pTexObj->width);
  1138. pExe->fs.constFloatMemBlock[pExe->dimensions.tex[i]+1] = float(pTexObj->height);
  1139. }
  1140. pTexState->pTexObjectToConfigFimg[i].id = pTexObj->id;
  1141. pTexState->pTexObjectToConfigFimg[i].pTexFGLState = &(pTexObj->texFGLState);
  1142. }
  1143. else
  1144. {
  1145. //as compilation fails need to update with fallback texture
  1146. pTexState->pTexObjectToConfigFimg[i].id = 0;
  1147. if(texType == GL_SAMPLER_2D) {
  1148. pTexState->pTexObjectToConfigFimg[i].pTexFGLState = &(ctx->sharedState->sharedTexState.fallBackTexFGLstate[0]);
  1149. }
  1150. else if(texType == GL_SAMPLER_3D) {
  1151. pTexState->pTexObjectToConfigFimg[i].pTexFGLState = &(ctx->sharedState->sharedTexState.fallBackTexFGLstate[1]);
  1152. }
  1153. else if(texType == GL_SAMPLER_CUBE) {
  1154. pTexState->pTexObjectToConfigFimg[i].pTexFGLState = &(ctx->sharedState->sharedTexState.fallBackTexFGLstate[2]);
  1155. }
  1156. // //LOGMSG("Compile failed\n");
  1157. }
  1158. } //End of tex unit for loop
  1159. updateBuiltinUniforms(pExe->vs, ctx);
  1160. updateBuiltinUniforms(pExe->fs, ctx);
  1161. //#if FIMG_PLATFORM == 1
  1162. //No fimg setting on win32 :)
  1163. // glfFinish(ctx); just to see what happens
  1164. glfFlush(ctx);
  1165. //#endif
  1166. return true;
  1167. }
  1168. return false;
  1169. }
  1170. #ifdef USE_3D_PM
  1171. void PM_glFinish (void);
  1172. GL_API void GL_APIENTRY glFinish (void)
  1173. {
  1174. lock3DCriticalSection();
  1175. PM_glFinish();
  1176. unlock3DCriticalSection();
  1177. }
  1178. void PM_glFinish (void)
  1179. #else
  1180. GL_API void GL_APIENTRY glFinish (void)
  1181. #endif
  1182. {
  1183. Plat::lockGPUSFR(__FUNCTION__);
  1184. GET_GL_STATE(ctx);
  1185. #if FIMG_PLATFORM == 1
  1186. glfFinish(ctx);
  1187. #endif
  1188. #ifdef CACHE_MEM
  1189. invalidate_cached_buffer();
  1190. #endif
  1191. Plat::unlockGPUSFR(__FUNCTION__);
  1192. }
  1193. #ifdef USE_3D_PM
  1194. void PM_glFlush (void);
  1195. GL_API void GL_APIENTRY glFlush (void)
  1196. {
  1197. lock3DCriticalSection();
  1198. PM_glFlush();
  1199. unlock3DCriticalSection();
  1200. }
  1201. void PM_glFlush (void)
  1202. #else
  1203. GL_API void GL_APIENTRY glFlush (void)
  1204. #endif
  1205. {
  1206. Plat::lockGPUSFR(__FUNCTION__);
  1207. GET_GL_STATE(ctx);
  1208. if(!stateFlush(ctx))
  1209. {
  1210. //LOGMSG("\nWARNING: state has not been flushed to hw\n");
  1211. }
  1212. Plat::unlockGPUSFR(__FUNCTION__);
  1213. }
  1214. GL_API void GL_APIENTRY glFrontFace (GLenum mode)
  1215. {
  1216. GET_GL_STATE(ctx);
  1217. if((mode == GL_CW )||(mode == GL_CCW))
  1218. {
  1219. ctx->front_face_mode = mode;
  1220. SetUpDateFlagRasterEngine(ctx,GLF_UF_BackfaceCull);
  1221. //ctx->updateBits.re = UB_RE_ALL;
  1222. }
  1223. else
  1224. {
  1225. set_err(GL_INVALID_ENUM);
  1226. }
  1227. }
  1228. GL_API void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *params)
  1229. {
  1230. GET_GL_STATE(ctx);
  1231. FramebufferData fbData = getFBData();
  1232. float tempValue[4] ;
  1233. if(params == NULL)
  1234. SET_ERR(ctx, GL_INVALID_VALUE, "glGetBooleanv*");
  1235. else
  1236. switch(pname)
  1237. {
  1238. //the state variable whose basic type is boolean
  1239. case GL_SAMPLE_COVERAGE_INVERT:
  1240. params[0] = ctx->sample_coverage_data.invert;
  1241. break;
  1242. case GL_COLOR_WRITEMASK:
  1243. params[0] = ctx->color_mask_data.r;
  1244. params[1] = ctx->color_mask_data.g;
  1245. params[2] = ctx->color_mask_data.b;
  1246. params[3] = ctx->color_mask_data.a;
  1247. break;
  1248. case GL_DEPTH_WRITEMASK:
  1249. params[0] = ctx->depth_write_mask;
  1250. break;
  1251. case GL_SHADER_COMPILER :
  1252. params[0] = GL_FALSE;
  1253. break;
  1254. //The state variable supported by glIsEnabled
  1255. case GL_CULL_FACE:
  1256. case GL_POLYGON_OFFSET_FILL:
  1257. case GL_SAMPLE_COVERAGE:
  1258. case GL_SAMPLE_ALPHA_TO_COVERAGE:
  1259. case GL_SCISSOR_TEST:
  1260. case GL_STENCIL_TEST:
  1261. case GL_DEPTH_TEST:
  1262. case GL_BLEND:
  1263. case GL_DITHER:
  1264. #ifdef EN_EXT_ALPHA_TEST_EXP
  1265. case GL_ALPHA_TEST_EXP:
  1266. #endif
  1267. #ifdef EN_EXT_LOGIC_OP_EXP
  1268. case GL_COLOR_LOGIC_OP:
  1269. #endif
  1270. params[0] = glIsEnabled(pname);
  1271. break;
  1272. //The state variable added from glGetInteger* and glGetFloat*
  1273. case GL_ARRAY_BUFFER_BINDING:
  1274. params[0] = 0;
  1275. if(ctx->buffer_object_data.array_buffer_binding != NULL){
  1276. if(ctx->buffer_object_data.array_buffer_binding->id != 0) params[0] = 1;
  1277. }
  1278. break;
  1279. case GL_ELEMENT_ARRAY_BUFFER_BINDING:
  1280. params[0] = 0;
  1281. if(ctx->buffer_object_data.element_array_buffer_binding != NULL){
  1282. if(ctx->buffer_object_data.element_array_buffer_binding->id != 0) params[0] = 1;
  1283. }
  1284. break;
  1285. case GL_VIEWPORT:
  1286. if(ctx->viewport_data.x != 0){
  1287. params[0] = 1;
  1288. }else params[0] = 0;
  1289. if(ctx->viewport_data.y != 0){
  1290. params[1] = 1;
  1291. }else params[0] = 0;
  1292. if(ctx->viewport_data.w != 0){
  1293. params[2] = 1;
  1294. }else params[0] = 0;
  1295. if(ctx->viewport_data.h != 0){
  1296. params[3] = 1;
  1297. }else params[0] = 0;
  1298. break;
  1299. case GL_DEPTH_RANGE:
  1300. if( ctx->depth_range_data.near_depth != 0){
  1301. params[0] = 1;
  1302. }else params[0] = 0;
  1303. if(ctx->depth_range_data.far_depth != 0){
  1304. params[1] = 1;
  1305. }else params[0] = 0;
  1306. break;
  1307. case GL_LINE_WIDTH:
  1308. if(ctx->line_width != 0){
  1309. params[0] = 1;
  1310. }else params[0] = 0;
  1311. break;
  1312. case GL_CULL_FACE_MODE:
  1313. if(ctx->cull_face_data.mode != 0){
  1314. params[0] = 1;
  1315. }else params[0] = 0;
  1316. break;
  1317. case GL_FRONT_FACE:
  1318. if(ctx->front_face_mode != 0){
  1319. params[0] = 1;
  1320. }else params[0] = 0;
  1321. break;
  1322. case GL_POLYGON_OFFSET_FACTOR:
  1323. if(ctx->polygon_offset_data.factor != 0){
  1324. params[0] = 1;
  1325. }else params[0] = 0;
  1326. break;
  1327. case GL_POLYGON_OFFSET_UNITS:
  1328. if(ctx->polygon_offset_data.units != 0){
  1329. params[0] = 1;
  1330. }else params[0] = 0;
  1331. break;
  1332. case GL_SAMPLE_COVERAGE_VALUE:
  1333. if(ctx->sample_coverage_data.value != 0){
  1334. params[0] = 1;
  1335. }else params[0] = 0;
  1336. break;
  1337. case GL_TEXTURE_BINDING_2D: //to check
  1338. if( ctx->texState.texUnitBinding[ctx->texState.activeTexUnit].texture2D != 0){
  1339. params[0] = 1;
  1340. }else params[0] = 0;
  1341. break;
  1342. case GL_TEXTURE_BINDING_3D:
  1343. if(ctx->texState.texUnitBinding[ctx->texState.activeTexUnit].texture3D != 0){
  1344. params[0] = 1;
  1345. }else params[0] = 0;
  1346. break;
  1347. case GL_TEXTURE_BINDING_CUBE_MAP:
  1348. if(ctx->texState.texUnitBinding[ctx->texState.activeTexUnit].cubeMap != 0){
  1349. params[0] = 1;
  1350. }else params[0] = 0;
  1351. //params[0] = GetTexNameArrayIndex(params[0] );
  1352. break;
  1353. case GL_ACTIVE_TEXTURE:
  1354. if(ctx->texState.activeTexUnit != 0){
  1355. params[0] = 1;
  1356. }else params[0] = 0;
  1357. break;
  1358. case GL_STENCIL_WRITEMASK :
  1359. if(ctx->front_stencil_writemask != 0){
  1360. params[0] = 1;
  1361. }else params[0] = 0;
  1362. break;
  1363. case GL_STENCIL_BACK_WRITEMASK :
  1364. if(ctx->back_stencil_writemask != 0){
  1365. params[0] = 1;
  1366. }else params[0] = 0;
  1367. break;
  1368. case GL_COLOR_CLEAR_VALUE :
  1369. if( ctx->clear_color_data.r != 0){
  1370. params[0] = 1;
  1371. }else params[0] = 0;
  1372. if(ctx->clear_color_data.g != 0){
  1373. params[1] = 1;
  1374. }else params[0] = 0;
  1375. if( ctx->clear_color_data.b != 0){
  1376. params[2] = 1;
  1377. }else params[0] = 0;
  1378. if(ctx->clear_color_data.a != 0){
  1379. params[3] = 1;
  1380. }else params[0] = 0;
  1381. break;
  1382. case GL_DEPTH_CLEAR_VALUE :
  1383. if( ctx->clear_depth != 0){
  1384. params[0] = 1;
  1385. }else params[0] = 0;
  1386. break;
  1387. case GL_STENCIL_CLEAR_VALUE:
  1388. if(ctx->clear_stencil != 0){
  1389. params[0] = 1;
  1390. }else params[0] = 0;
  1391. break;
  1392. case GL_SCISSOR_BOX:
  1393. if(ctx->scissor_test_data.x != 0){
  1394. params[0] = 1;
  1395. }else params[0] = 0;
  1396. if(ctx->scissor_test_data.y != 0){
  1397. params[1] = 1;
  1398. }else params[0] = 0;
  1399. if( ctx->scissor_test_data.w != 0){
  1400. params[2] = 1;
  1401. }else params[0] = 0;
  1402. if(ctx->scissor_test_data.h != 0){
  1403. params[3] = 1;
  1404. }else params[0] = 0;
  1405. break;
  1406. case GL_STENCIL_FUNC:
  1407. if(ctx->stencil_test_data.front_face_func != 0){
  1408. params[0] =1;
  1409. }else params[0] = 0;
  1410. break;
  1411. case GL_STENCIL_VALUE_MASK:
  1412. if(ctx->stencil_test_data.front_face_mask != 0){
  1413. params[0] = 1;
  1414. }else params[0] = 0;
  1415. break;
  1416. case GL_STENCIL_REF :
  1417. if(ctx->stencil_test_data.front_face_ref != 0){
  1418. params[0] = 1;
  1419. }else params[0] = 0;
  1420. break;
  1421. case GL_STENCIL_FAIL :
  1422. if(ctx->stencil_test_data.front_face_fail != 0){
  1423. params[0] = 1;
  1424. }else params[0] = 0;
  1425. break;
  1426. case GL_STENCIL_PASS_DEPTH_FAIL :
  1427. if(ctx->stencil_test_data.front_face_zfail != 0){
  1428. params[0] = 1;
  1429. }else params[0] = 0;
  1430. break;
  1431. case GL_STENCIL_PASS_DEPTH_PASS :
  1432. if(ctx->stencil_test_data.front_face_zpass != 0){
  1433. params[0] = 1;
  1434. }else params[0] = 0;
  1435. break;
  1436. case GL_STENCIL_BACK_FUNC :
  1437. if( ctx->stencil_test_data.back_face_func != 0){
  1438. params[0] = 1;
  1439. }else params[0] = 0;
  1440. break;
  1441. case GL_STENCIL_BACK_VALUE_MASK :
  1442. if(ctx->stencil_test_data.back_face_mask != 0){
  1443. params[0] = 1;
  1444. }else params[0] = 0;
  1445. break;
  1446. case GL_STENCIL_BACK_REF :
  1447. if(ctx->stencil_test_data.back_face_ref != 0){
  1448. params[0] = 1;
  1449. }else params[0] = 0;
  1450. break;
  1451. case GL_STENCIL_BACK_FAIL :
  1452. if(ctx->stencil_test_data.back_face_fail != 0){
  1453. params[0] =1;
  1454. }else params[0] = 0;
  1455. break;
  1456. case GL_STENCIL_BACK_PASS_DEPTH_FAIL :
  1457. if(ctx->stencil_test_data.back_face_zfail != 0){
  1458. params[0] = 1;
  1459. }else params[0] = 0;
  1460. break;
  1461. case GL_STENCIL_BACK_PASS_DEPTH_PASS :
  1462. if( ctx->stencil_test_data.back_face_zpass != 0){
  1463. params[0] = 1;
  1464. }else params[0] = 0;
  1465. break;
  1466. case GL_DEPTH_FUNC:
  1467. if(ctx->depth_test_func != 0){
  1468. params[0] = 1;
  1469. }else params[0] = 0;
  1470. break;
  1471. case GL_BLEND_SRC_RGB :
  1472. //if((params[0] = ctx->blend_data.fn_srcRG)!=0){
  1473. // params[0] =1;
  1474. //}
  1475. //break;
  1476. case GL_BLEND_SRC_ALPHA:
  1477. if(ctx->blend_data.fn_srcAlpha != 0){
  1478. params[0] =1;
  1479. }else params[0] = 0;
  1480. break;
  1481. case GL_BLEND_DST_RGB :
  1482. if(ctx->blend_data.fn_dstRGB != 0){
  1483. params[0] = 1;
  1484. }else params[0] = 0;
  1485. break;
  1486. case GL_BLEND_DST_ALPHA:
  1487. if(ctx->blend_data.fn_dstAlpha != 0){
  1488. params[0] =1;
  1489. }else params[0] = 0;
  1490. break;
  1491. case GL_BLEND_EQUATION_RGB :
  1492. if(ctx->blend_data.eqn_modeRGB != 0){
  1493. params[0] = 1;
  1494. }else params[0] = 0;
  1495. break;
  1496. case GL_BLEND_EQUATION_ALPHA:
  1497. if(ctx->blend_data.eqn_modeAlpha != 0){
  1498. params[0] = 1;
  1499. }else params[0] = 0;
  1500. break;
  1501. case GL_BLEND_COLOR :
  1502. if( ctx->blend_data.blnd_clr_red != 0){
  1503. params[0] = 1;
  1504. }else params[0] = 0;
  1505. if(ctx->blend_data.blnd_clr_green != 0){
  1506. params[0] = 1;
  1507. }else params[0] = 0;
  1508. if(ctx->blend_data.blnd_clr_blue != 0){
  1509. params[2] = 1;
  1510. }else params[0] = 0;
  1511. if(ctx->blend_data.blnd_clr_alpha != 0){
  1512. params[3] = 1;
  1513. }else params[0] = 0;
  1514. break;
  1515. case GL_UNPACK_ALIGNMENT:
  1516. if(ctx->pixel_store_data.unpack_alignment != 0){
  1517. params[0] = 1;
  1518. }else params[0] = 0;
  1519. break;
  1520. case GL_PACK_ALIGNMENT:
  1521. if(ctx->pixel_store_data.pack_alignment != 0){
  1522. params[0] = 1;
  1523. }else params[0] = 0;
  1524. break;
  1525. case GL_CURRENT_PROGRAM:
  1526. if(ctx->current_program != 0){
  1527. params[0] = 1;
  1528. }else params[0] = 0;
  1529. break;
  1530. case GL_GENERATE_MIPMAP_HINT:
  1531. if(ctx->hint_data.generate_mipmap_hint != 0){
  1532. params[0] = 1;
  1533. }else params[0] = 0;
  1534. break;
  1535. case GL_MAX_TEXTURE_SIZE:
  1536. if( MAX_TEXTURE_SIZE != 0){
  1537. params[0] = 1;
  1538. }else params[0] = 0;
  1539. break;
  1540. case GL_MAX_CUBE_MAP_TEXTURE_SIZE:
  1541. if( MAX_CUBEMAP_TEXTURE_SIZE != 0){
  1542. params[0] = 1;
  1543. }else params[0] = 0;
  1544. break;
  1545. case GL_MAX_VIEWPORT_DIMS:
  1546. if(MAX_VIEWPORT_DIMS != 0){
  1547. params[0] = 1;
  1548. params[1] = 1;
  1549. }else{ params[0] = 0; params[1] = 0;}
  1550. break;
  1551. case GL_MAX_ELEMENTS_INDICES :
  1552. if(MAX_ELEMENTS_INDICES != 0){
  1553. params[0] = 1;
  1554. }else params[0] = 0;
  1555. break;
  1556. case GL_MAX_ELEMENTS_VERTICES :
  1557. if(MAX_ELEMENTS_VERTICES != 0){
  1558. params[0] = 1;
  1559. }else params[0] = 0;
  1560. break;
  1561. case GL_SAMPLE_BUFFERS :
  1562. if(NO_OF_SAMPLES != 0){
  1563. params[0] = 1;
  1564. }else params[0] = 0;
  1565. break;
  1566. case GL_SAMPLES :
  1567. if(MULTISAMPLING != 0){
  1568. params[0] = 1;
  1569. }else params[0] = 0;
  1570. break;
  1571. case GL_COMPRESSED_TEXTURE_FORMATS :
  1572. if(NUM_COMPRESSED_TEXTURE_FORMATS != 0){
  1573. params[0] = 1;
  1574. }else params[0] = 0;
  1575. break;
  1576. case GL_NUM_COMPRESSED_TEXTURE_FORMATS :
  1577. if(NUM_COMPRESSED_TEXTURE_FORMATS != 0){
  1578. params[0] = 1;
  1579. }else params[0] = 0;
  1580. break;
  1581. case GL_NUM_SHADER_BINARY_FORMATS :
  1582. if((tempValue[0] = NUM_SHADER_BINARY_FORMATS) != 0){
  1583. params[0] = 1;
  1584. }else params[0] = 0;
  1585. break;
  1586. case GL_MAX_VERTEX_ATTRIBS :
  1587. if(MAX_VERTEX_ATTRIB_VARS != 0){
  1588. params[0] = 1;
  1589. }else params[0] = 0;
  1590. break;
  1591. case GL_MAX_VERTEX_UNIFORM_VECTORS :
  1592. if(MAX_UNIFORMS != 0){
  1593. params[0] = 1;
  1594. }else params[0] = 0;
  1595. break;
  1596. case GL_MAX_VARYING_VECTORS :
  1597. if(MAX_VARYING_VECTORS != 0){
  1598. params[0] = 1;
  1599. }else params[0] = 0;
  1600. break;
  1601. case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS :
  1602. if(MAX_VERTEX_TEXTURE_UNITS +

Large files files are truncated, but you can click here to view the full file