This commit is contained in:
Branimir Karadžić 2014-03-09 21:20:34 -07:00
Родитель beb73905d0
Коммит 22bbd166d7
3 изменённых файлов: 76 добавлений и 14 удалений

Просмотреть файл

@ -31,6 +31,8 @@
#define GL_IMPORT_____x(_optional, _proto, _func) GL_EXTENSION(_optional, _proto, _func, _func ## XXXXX)
#if GL_IMPORT_TYPEDEFS
typedef void (GL_APIENTRYP GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
typedef void (GL_APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
typedef void (GL_APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
typedef void (GL_APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id);
@ -64,6 +66,9 @@ typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum t
typedef GLuint (GL_APIENTRYP PFNGLCREATEPROGRAMPROC) (void);
typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);
typedef void (GL_APIENTRYP PFNGLCULLFACEPROC) (GLenum mode);
typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam);
typedef void (GL_APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers);
typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);
@ -98,9 +103,13 @@ typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuin
typedef void (GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
typedef GLint (GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
typedef GLenum (GL_APIENTRYP PFNGLGETERRORPROC) (void);
typedef void (GL_APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data);
typedef void (GL_APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data);
typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
typedef void (GL_APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, void **params);
typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
typedef void (GL_APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
@ -114,10 +123,14 @@ typedef void (GL_APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenu
typedef const GLubyte* (GL_APIENTRYP PFNGLGETSTRINGPROC) (GLenum name);
typedef GLint (GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
typedef void (GL_APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
typedef void (GL_APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label);
typedef void (GL_APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param);
typedef void (GL_APIENTRYP PFNGLPOINTSIZEPROC) (GLfloat size);
typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void);
typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length);
typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value);
typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message);
typedef void (GL_APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target);
typedef void (GL_APIENTRYP PFNGLREADBUFFERPROC) (GLenum mode);
typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
@ -201,6 +214,9 @@ GL_IMPORT______(true , PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC, glCompressedT
GL_IMPORT______(false, PFNGLCREATEPROGRAMPROC, glCreateProgram);
GL_IMPORT______(false, PFNGLCREATESHADERPROC, glCreateShader);
GL_IMPORT______(false, PFNGLCULLFACEPROC, glCullFace);
GL_IMPORT______(true, PFNGLDEBUGMESSAGECONTROLPROC, glDebugMessageControl);
GL_IMPORT______(true, PFNGLDEBUGMESSAGEINSERTPROC, glDebugMessageInsert);
GL_IMPORT______(true, PFNGLDEBUGMESSAGECALLBACKPROC, glDebugMessageCallback);
GL_IMPORT______(false, PFNGLDELETEBUFFERSPROC, glDeleteBuffers);
GL_IMPORT______(true, PFNGLDELETEFRAMEBUFFERSPROC, glDeleteFramebuffers);
GL_IMPORT______(false, PFNGLDELETEPROGRAMPROC, glDeleteProgram);
@ -235,9 +251,13 @@ GL_IMPORT______(true, PFNGLGENVERTEXARRAYSPROC, glGenVertexAr
GL_IMPORT______(false, PFNGLGETACTIVEATTRIBPROC, glGetActiveAttrib);
GL_IMPORT______(false, PFNGLGETATTRIBLOCATIONPROC, glGetAttribLocation);
GL_IMPORT______(false, PFNGLGETACTIVEUNIFORMPROC, glGetActiveUniform);
GL_IMPORT______(true, PFNGLGETDEBUGMESSAGELOGPROC, glGetDebugMessageLog);
GL_IMPORT______(false, PFNGLGETERRORPROC, glGetError);
GL_IMPORT______(false, PFNGLGETFLOATVPROC, glGetFloatv);
GL_IMPORT______(false, PFNGLGETINTEGERVPROC, glGetIntegerv);
GL_IMPORT______(true, PFNGLGETOBJECTLABELPROC, glGetObjectLabel);
GL_IMPORT______(true, PFNGLGETOBJECTPTRLABELPROC, glGetObjectPtrLabel);
GL_IMPORT______(true, PFNGLGETPOINTERVPROC, glGetPointerv);
GL_IMPORT______(true, PFNGLGETPROGRAMBINARYPROC, glGetProgramBinary);
GL_IMPORT______(false, PFNGLGETPROGRAMIVPROC, glGetProgramiv);
GL_IMPORT______(false, PFNGLGETPROGRAMINFOLOGPROC, glGetProgramInfoLog);
@ -251,9 +271,13 @@ GL_IMPORT______(false, PFNGLGETSHADERINFOLOGPROC, glGetShaderIn
GL_IMPORT______(false, PFNGLGETSTRINGPROC, glGetString);
GL_IMPORT______(false, PFNGLGETUNIFORMLOCATIONPROC, glGetUniformLocation);
GL_IMPORT______(false, PFNGLLINKPROGRAMPROC, glLinkProgram);
GL_IMPORT______(true, PFNGLOBJECTLABELPROC, glObjectLabel);
GL_IMPORT______(true, PFNGLOBJECTPTRLABELPROC, glObjectPtrLabel);
GL_IMPORT______(false, PFNGLPIXELSTOREIPROC, glPixelStorei);
GL_IMPORT______(true, PFNGLPOPDEBUGGROUPPROC, glPopDebugGroup);
GL_IMPORT______(true, PFNGLPROGRAMBINARYPROC, glProgramBinary);
GL_IMPORT______(true, PFNGLPROGRAMPARAMETERIPROC, glProgramParameteri);
GL_IMPORT______(true, PFNGLPUSHDEBUGGROUPPROC, glPushDebugGroup);
GL_IMPORT______(true, PFNGLQUERYCOUNTERPROC, glQueryCounter);
GL_IMPORT______(true, PFNGLREADBUFFERPROC, glReadBuffer);
GL_IMPORT______(false, PFNGLREADPIXELSPROC, glReadPixels);
@ -300,10 +324,17 @@ GL_IMPORT______(false, PFNGLVIEWPORTPROC, glViewport);
GL_IMPORT______(false, PFNGLCLEARDEPTHPROC, glClearDepth);
GL_IMPORT______(false, PFNGLPOINTSIZEPROC, glPointSize);
GL_IMPORT (true, PFNGLDEBUGMESSAGECONTROLARBPROC, glDebugMessageControl, glDebugMessageControlARB);
GL_IMPORT (true, PFNGLDEBUGMESSAGEINSERTARBPROC, glDebugMessageInsert, glDebugMessageInsertARB);
GL_IMPORT (true, PFNGLDEBUGMESSAGECALLBACKARBPROC, glDebugMessageCallback, glDebugMessageCallbackARB);
GL_IMPORT (true, PFNGLGETDEBUGMESSAGELOGARBPROC, glGetDebugMessageLog, glGetDebugMessageLogARB);
GL_IMPORT_ARB__(true, PFNGLDEBUGMESSAGECONTROLPROC, glDebugMessageControl);
GL_IMPORT_ARB__(true, PFNGLDEBUGMESSAGEINSERTPROC, glDebugMessageInsert);
GL_IMPORT_ARB__(true, PFNGLDEBUGMESSAGECALLBACKPROC, glDebugMessageCallback);
GL_IMPORT_ARB__(true, PFNGLGETDEBUGMESSAGELOGPROC, glGetDebugMessageLog);
GL_IMPORT_ARB__(true, PFNGLPUSHDEBUGGROUPPROC, glPushDebugGroup);
GL_IMPORT_ARB__(true, PFNGLPOPDEBUGGROUPPROC, glPopDebugGroup);
GL_IMPORT_ARB__(true, PFNGLOBJECTLABELPROC, glObjectLabel);
GL_IMPORT_ARB__(true, PFNGLGETOBJECTLABELPROC, glGetObjectLabel);
GL_IMPORT_ARB__(true, PFNGLOBJECTPTRLABELPROC, glObjectPtrLabel);
GL_IMPORT_ARB__(true, PFNGLGETOBJECTPTRLABELPROC, glGetObjectPtrLabel);
GL_IMPORT_ARB__(true, PFNGLGETPOINTERVPROC, glGetPointerv);
GL_IMPORT_ARB__(true, PFNGLVERTEXATTRIBDIVISORPROC, glVertexAttribDivisor);
GL_IMPORT_ARB__(true, PFNGLDRAWARRAYSINSTANCEDPROC, glDrawArraysInstanced);
@ -350,6 +381,7 @@ GL_IMPORT_EXT__(true, PFNGLTEXSTORAGE3DPROC, glTexStorage3
GL_IMPORT_EXT__(true, PFNGLINSERTEVENTMARKEREXTPROC, glInsertEventMarker);
GL_IMPORT_EXT__(true, PFNGLPUSHGROUPMARKEREXTPROC, glPushGroupMarker);
GL_IMPORT_EXT__(true, PFNGLPOPGROUPMARKEREXTPROC, glPopGroupMarker);
GL_IMPORT_EXT__(true, PFNGLOBJECTLABELPROC, glObjectLabel);
GL_IMPORT_OES__(true, PFNGLGETPROGRAMBINARYPROC, glGetProgramBinary);
GL_IMPORT_OES__(true, PFNGLPROGRAMBINARYPROC, glProgramBinary);

Просмотреть файл

@ -211,6 +211,7 @@ namespace bgfx
ANGLE_translated_shader_source,
APPLE_texture_format_BGRA8888,
APPLE_texture_max_level,
ARB_debug_label,
ARB_debug_output,
@ -329,7 +330,8 @@ namespace bgfx
{ "GL_ANGLE_translated_shader_source", false, true },
{ "GL_APPLE_texture_format_BGRA8888", false, true },
{ "GL_APPLE_texture_max_level", false, true },
{ "GL_ARB_debug_label", false, true },
{ "GL_ARB_debug_output", BGFX_CONFIG_RENDERER_OPENGL >= 43, true },
{ "GL_ARB_depth_clamp", BGFX_CONFIG_RENDERER_OPENGL >= 32, true },
@ -517,6 +519,10 @@ namespace bgfx
GL_CHECK(glStringMarkerGREMEDY(_length, _marker) );
}
static void GL_APIENTRY stubObjectLabel(GLenum /*_identifier*/, GLuint /*_name*/, GLsizei /*_length*/, const char* /*_label*/)
{
}
typedef void (*PostSwapBuffersFn)(uint32_t _width, uint32_t _height);
static const char* getGLString(GLenum _name)
@ -573,9 +579,9 @@ namespace bgfx
}
}
#if BGFX_CONFIG_RENDERER_OPENGL
const char* toString(GLenum _enum)
{
#if defined(GL_DEBUG_SOURCE_API_ARB)
switch (_enum)
{
case GL_DEBUG_SOURCE_API_ARB: return "API";
@ -596,12 +602,17 @@ namespace bgfx
default:
break;
}
#else
BX_UNUSED(_enum);
#endif // defined(GL_DEBUG_SOURCE_API_ARB)
return "<unknown>";
}
static void APIENTRY debugProcCb(GLenum _source, GLenum _type, GLuint _id, GLenum _severity, GLsizei /*_length*/, const GLchar* _message, const void* /*_userParam*/)
static void GL_APIENTRY debugProcCb(GLenum _source, GLenum _type, GLuint _id, GLenum _severity, GLsizei /*_length*/, const GLchar* _message, const void* /*_userParam*/)
{
BX_UNUSED(debugProcCb(_source, _type, _id, _severity, 0, NULL, NULL) );
BX_TRACE("src %s, type %s, id %d, severity %s, '%s'"
, toString(_source)
, toString(_type)
@ -611,7 +622,6 @@ namespace bgfx
);
BX_UNUSED(_source, _type, _id, _severity, _message);
}
#endif // BGFX_CONFIG_RENDERER_OPENGL
GLint glGet(GLenum _pname)
{
@ -1317,7 +1327,8 @@ namespace bgfx
s_textureFormat[TextureFormat::L8].m_fmt = GL_RED;
}
if (s_extension[Extension::ARB_debug_output].m_supported)
if (s_extension[Extension::ARB_debug_output].m_supported
|| s_extension[Extension::KHR_debug].m_supported)
{
GL_CHECK(glDebugMessageCallback(debugProcCb, NULL) );
GL_CHECK(glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM_ARB, 0, NULL, GL_TRUE) );
@ -1347,6 +1358,11 @@ namespace bgfx
;
}
if (NULL == glObjectLabel)
{
glObjectLabel = stubObjectLabel;
}
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL) )
{
m_queries.create();
@ -2272,9 +2288,11 @@ namespace bgfx
GL_CHECK(glTexParameteri(target, GL_TEXTURE_WRAP_S, s_textureAddress[(flags&BGFX_TEXTURE_U_MASK)>>BGFX_TEXTURE_U_SHIFT]) );
GL_CHECK(glTexParameteri(target, GL_TEXTURE_WRAP_T, s_textureAddress[(flags&BGFX_TEXTURE_V_MASK)>>BGFX_TEXTURE_V_SHIFT]) );
#if BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES3
GL_CHECK(glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, numMips-1) );
#endif // BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES3
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL|BGFX_CONFIG_RENDERER_OPENGLES3)
|| s_extension[Extension::APPLE_texture_max_level].m_supported)
{
GL_CHECK(glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, numMips-1) );
}
if (target == GL_TEXTURE_3D)
{
@ -2405,7 +2423,7 @@ namespace bgfx
{
writeString(&writer
, "#extension GL_EXT_frag_depth : enable\n"
"#define gl_FragDepth gl_FragDepthEXT\n"
"#define bgfx_FragDepth gl_FragDepthEXT\n"
);
char str[128];
@ -2483,11 +2501,19 @@ namespace bgfx
const char* end = bx::strmb(brace, '{', '}');
if (NULL != end)
{
strins(brace+1, "\n float gl_FragDepth = 0.0;\n");
strins(brace+1, "\n float bgfx_FragDepth = 0.0;\n");
}
}
}
}
// Replace all instances of gl_FragDepth with bgfx_FragDepth.
for (const char* fragDepth = bx::findIdentifierMatch(temp, "gl_FragDepth"); NULL != fragDepth; fragDepth = bx::findIdentifierMatch(fragDepth, "gl_FragDepth") )
{
char* insert = const_cast<char*>(fragDepth);
strins(insert, "bg");
memcpy(insert + 2, "fx", 2);
}
}
else if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGLES3) )
{

Просмотреть файл

@ -295,6 +295,10 @@ typedef uint64_t GLuint64;
# define GL_SAMPLER_2D_SHADOW 0x8B62
#endif // GL_SAMPLER_2D_SHADOW
#ifndef GL_TEXTURE_MAX_LEVEL
# define GL_TEXTURE_MAX_LEVEL 0x813D
#endif // GL_TEXTURE_MAX_LEVEL
#if BX_PLATFORM_NACL
# include "glcontext_ppapi.h"
#elif BX_PLATFORM_WINDOWS