From 723c1de520c585795f5ea458c0beb4b255e9ceb3 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 28 Apr 2016 21:15:46 +0200 Subject: [PATCH] Fix various emscripten compile issues --- panda/src/gles2gsg/panda_esgl2ext.h | 80 ++----------------- .../glstuff/glGraphicsStateGuardian_src.cxx | 2 + .../src/glstuff/glGraphicsStateGuardian_src.h | 2 - panda/src/glstuff/glShaderContext_src.h | 2 + panda/src/glstuff/glTextureContext_src.I | 3 + panda/src/glstuff/glTextureContext_src.cxx | 11 +-- panda/src/glstuff/glTextureContext_src.h | 4 + panda/src/movies/dr_flac.h | 32 ++++---- 8 files changed, 39 insertions(+), 97 deletions(-) diff --git a/panda/src/gles2gsg/panda_esgl2ext.h b/panda/src/gles2gsg/panda_esgl2ext.h index 46812c63a4..6d5258fff0 100644 --- a/panda/src/gles2gsg/panda_esgl2ext.h +++ b/panda/src/gles2gsg/panda_esgl2ext.h @@ -934,42 +934,6 @@ GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); #define GL_RGB_RAW_422_APPLE 0x8A51 #endif /* GL_APPLE_rgb_422 */ -#ifndef GL_APPLE_sync -#define GL_APPLE_sync 1 -#define GL_SYNC_OBJECT_APPLE 0x8A53 -#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 -#define GL_OBJECT_TYPE_APPLE 0x9112 -#define GL_SYNC_CONDITION_APPLE 0x9113 -#define GL_SYNC_STATUS_APPLE 0x9114 -#define GL_SYNC_FLAGS_APPLE 0x9115 -#define GL_SYNC_FENCE_APPLE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 -#define GL_UNSIGNALED_APPLE 0x9118 -#define GL_SIGNALED_APPLE 0x9119 -#define GL_ALREADY_SIGNALED_APPLE 0x911A -#define GL_TIMEOUT_EXPIRED_APPLE 0x911B -#define GL_CONDITION_SATISFIED_APPLE 0x911C -#define GL_WAIT_FAILED_APPLE 0x911D -#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 -#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull -typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); -typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); -typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); -typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); -typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); -GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); -GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); -GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); -GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); -GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); -GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif -#endif /* GL_APPLE_sync */ - #ifndef GL_APPLE_texture_format_BGRA8888 #define GL_APPLE_texture_format_BGRA8888 1 #define GL_BGRA_EXT 0x80E1 @@ -1166,8 +1130,8 @@ typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target); typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params); typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +//typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +//typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids); GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids); @@ -1178,8 +1142,8 @@ GL_APICALL void GL_APIENTRY glQueryCounterEXT (GLuint id, GLenum target); GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT (GLuint id, GLenum pname, GLint *params); GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params); -GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); -GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +//GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +//GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); #endif #endif /* GL_EXT_disjoint_timer_query */ @@ -2022,7 +1986,7 @@ typedef void (GL_APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (GL_APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); typedef void (GL_APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); typedef void (GL_APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); -typedef void (GL_APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +//typedef void (GL_APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); typedef void (GL_APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); typedef void (GL_APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); typedef void (GL_APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); @@ -2033,45 +1997,13 @@ GL_APICALL void GL_APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); GL_APICALL void GL_APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); GL_APICALL void GL_APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); GL_APICALL void GL_APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); -GL_APICALL void GL_APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +//GL_APICALL void GL_APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); GL_APICALL void GL_APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); GL_APICALL void GL_APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); GL_APICALL void GL_APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); #endif #endif /* GL_INTEL_performance_query */ -#ifndef GL_NV_bindless_texture -#define GL_NV_bindless_texture 1 -typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); -typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); -typedef void (GL_APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef void (GL_APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef GLuint64 (GL_APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -typedef void (GL_APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); -typedef void (GL_APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); -typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); -typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef GLboolean (GL_APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL GLuint64 GL_APIENTRY glGetTextureHandleNV (GLuint texture); -GL_APICALL GLuint64 GL_APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); -GL_APICALL void GL_APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); -GL_APICALL void GL_APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); -GL_APICALL GLuint64 GL_APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -GL_APICALL void GL_APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); -GL_APICALL void GL_APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); -GL_APICALL void GL_APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); -GL_APICALL void GL_APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); -GL_APICALL void GL_APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); -GL_APICALL void GL_APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -GL_APICALL GLboolean GL_APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); -GL_APICALL GLboolean GL_APIENTRY glIsImageHandleResidentNV (GLuint64 handle); -#endif -#endif /* GL_NV_bindless_texture */ - #ifndef GL_NV_blend_equation_advanced #define GL_NV_blend_equation_advanced 1 #define GL_BLEND_OVERLAP_NV 0x9281 diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 3bfe742beb..9a590bd746 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -11066,7 +11066,9 @@ do_issue_tex_gen() { */ bool CLP(GraphicsStateGuardian):: specify_texture(CLP(TextureContext) *gtc, const SamplerState &sampler) { +#ifndef OPENGLES nassertr(gtc->_handle == 0 /* can't modify tex with active handle */, false); +#endif Texture *tex = gtc->get_texture(); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.h b/panda/src/glstuff/glGraphicsStateGuardian_src.h index d06cf2de3f..3c93fcd174 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.h +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.h @@ -68,8 +68,6 @@ typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); -typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); // There is some trivial disagreement between different gl.h headers about diff --git a/panda/src/glstuff/glShaderContext_src.h b/panda/src/glstuff/glShaderContext_src.h index 13f90fcecc..183f068277 100644 --- a/panda/src/glstuff/glShaderContext_src.h +++ b/panda/src/glstuff/glShaderContext_src.h @@ -83,7 +83,9 @@ private: GLsizei _slider_table_size; GLint _frame_number_loc; GLint _frame_number; +#ifndef OPENGLES pmap _glsl_uniform_handles; +#endif struct ImageInput { CPT(InternalName) _name; diff --git a/panda/src/glstuff/glTextureContext_src.I b/panda/src/glstuff/glTextureContext_src.I index d4b4232513..33bda9a58f 100644 --- a/panda/src/glstuff/glTextureContext_src.I +++ b/panda/src/glstuff/glTextureContext_src.I @@ -24,7 +24,10 @@ CLP(TextureContext)(CLP(GraphicsStateGuardian) *glgsg, glGenTextures(1, &_index); _buffer = 0; +#ifndef OPENGLES _handle = 0; + _handle_resident = false; +#endif _has_storage = false; _immutable = false; _uses_mipmaps = false; diff --git a/panda/src/glstuff/glTextureContext_src.cxx b/panda/src/glstuff/glTextureContext_src.cxx index a5b97dd2f7..a56d6a20a4 100644 --- a/panda/src/glstuff/glTextureContext_src.cxx +++ b/panda/src/glstuff/glTextureContext_src.cxx @@ -77,8 +77,10 @@ reset_data() { // the texture later. glGenTextures(1, &_index); +#ifndef OPENGLES _handle = 0; _handle_resident = false; +#endif _has_storage = false; _immutable = false; @@ -96,9 +98,9 @@ reset_data() { /** * */ +#ifndef OPENGLES void CLP(TextureContext):: make_handle_resident() { -#ifndef OPENGLES if (_handle != 0) { if (!_handle_resident) { _glgsg->_glMakeTextureHandleResident(_handle); @@ -106,18 +108,17 @@ make_handle_resident() { } set_resident(true); } -#endif } +#endif /** * Returns a handle for this texture. Once this has been created, the texture * data may still be updated, but its properties may not. */ +#ifndef OPENGLES INLINE GLuint64 CLP(TextureContext):: get_handle() { -#ifdef OPENGLES return 0; -#else if (!_glgsg->_supports_bindless_texture) { return false; } @@ -128,8 +129,8 @@ get_handle() { _immutable = true; return _handle; -#endif } +#endif #ifndef OPENGLES_1 /** diff --git a/panda/src/glstuff/glTextureContext_src.h b/panda/src/glstuff/glTextureContext_src.h index 123f2d207d..309550eced 100644 --- a/panda/src/glstuff/glTextureContext_src.h +++ b/panda/src/glstuff/glTextureContext_src.h @@ -33,8 +33,10 @@ public: virtual void evict_lru(); void reset_data(); +#ifndef OPENGLES void make_handle_resident(); GLuint64 get_handle(); +#endif #ifdef OPENGLES_1 static CONSTEXPR bool needs_barrier(GLbitfield barrier) { return false; }; @@ -49,9 +51,11 @@ public: // This is only used for buffer textures. GLuint _buffer; +#ifndef OPENGLES // This is the bindless "handle" to the texture object. GLuint64 _handle; bool _handle_resident; +#endif // These are the parameters that we specified with the last glTexImage2D() // or glTexStorage2D() call. If none of these have changed, we can reload diff --git a/panda/src/movies/dr_flac.h b/panda/src/movies/dr_flac.h index 7043ec66f1..ff9960df5b 100644 --- a/panda/src/movies/dr_flac.h +++ b/panda/src/movies/dr_flac.h @@ -387,12 +387,12 @@ drflac* drflac_open_file(const char* filename) FILE* pFile; #ifdef _MSC_VER if (fopen_s(&pFile, filename, "rb") != 0) { - return false; + return NULL; } #else pFile = fopen(filename, "rb"); if (pFile == NULL) { - return false; + return NULL; } #endif @@ -420,7 +420,7 @@ static drflac* drflac_open_file(const char* filename) { HANDLE hFile = CreateFileA(filename, FILE_GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { - return false; + return NULL; } return drflac_open(drflac__on_read_stdio, drflac__on_seek_stdio, (void*)hFile); @@ -486,7 +486,7 @@ static drflac* drflac_open_memory(const void* data, size_t dataSize) { drflac_memory* pUserData = (drflac_memory*)malloc(sizeof(*pUserData)); if (pUserData == NULL) { - return false; + return NULL; } pUserData->data = (const unsigned char*)data; @@ -2438,12 +2438,12 @@ static bool drflac__seek_to_sample__seek_table(drflac* pFlac, uint64_t sampleInd static drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, void* pUserData) { if (onRead == NULL || onSeek == NULL) { - return false; + return NULL; } unsigned char id[4]; if (onRead(pUserData, id, 4) != 4 || id[0] != 'f' || id[1] != 'L' || id[2] != 'a' || id[3] != 'C') { - return false; // Not a FLAC stream. + return NULL; // Not a FLAC stream. } drflac tempFlac; @@ -2460,32 +2460,32 @@ static drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, voi bool isLastBlock; int blockType = drflac__read_block_header(&tempFlac, &blockSize, &isLastBlock); if (blockType != DRFLAC_BLOCK_TYPE_STREAMINFO && blockSize != 34) { - return false; + return NULL; } if (!drflac__seek_bits(&tempFlac, 16)) { // minBlockSize - return false; + return NULL; } if (!drflac__read_uint16(&tempFlac, 16, &tempFlac.maxBlockSize)) { - return false; + return NULL; } if (!drflac__seek_bits(&tempFlac, 48)) { // minFrameSize + maxFrameSize - return false; + return NULL; } if (!drflac__read_uint32(&tempFlac, 20, &tempFlac.sampleRate)) { - return false; + return NULL; } if (!drflac__read_uint8(&tempFlac, 3, &tempFlac.channels)) { - return false; + return NULL; } if (!drflac__read_uint8(&tempFlac, 5, &tempFlac.bitsPerSample)) { - return false; + return NULL; } if (!drflac__read_uint64(&tempFlac, 36, &tempFlac.totalSampleCount)) { - return false; + return NULL; } if (!drflac__seek_bits(&tempFlac, 128)) { // MD5 - return false; + return NULL; } tempFlac.channels += 1; @@ -2536,7 +2536,7 @@ static drflac* drflac_open(drflac_read_proc onRead, drflac_seek_proc onSeek, voi } if (!drflac__seek_bits(&tempFlac, blockSize*8)) { - return false; + return NULL; } }