Rewrite ToGL in OpenGLES(Uncomplete)

This commit is contained in:
nillerusr 2021-11-21 01:38:59 +03:00
parent 76bfcf40ca
commit 4508c9c863
24 changed files with 829 additions and 1057 deletions

View File

@ -57,7 +57,7 @@ COpenGLEntryPoints *gGL = NULL;
const int kBogusSwapInterval = INT_MAX;
#ifdef ANDROID
#if defined ANDROID || defined TOGLES
static void *l_gl4es = NULL;
static void *l_egl = NULL;
@ -182,13 +182,16 @@ void CheckGLError( int line )
void *VoidFnPtrLookup_GlMgr(const char *fn, bool &okay, const bool bRequired, void *fallback)
{
void *retval = NULL;
#ifndef TOGLES // TODO(nillerusr): remove this hack
if ((!okay) && (!bRequired)) // always look up if required (so we get a complete list of crucial missing symbols).
return NULL;
#endif
// The SDL path would work on all these platforms, if we were using SDL there, too...
#ifdef ANDROID
#if defined ANDROID || defined TOGLES
// SDL does the right thing, so we never need to use tier0 in this case.
if( _glGetProcAddress )
retval = _glGetProcAddress(fn);
@ -214,7 +217,12 @@ void *VoidFnPtrLookup_GlMgr(const char *fn, bool &okay, const bool bRequired, vo
// Note that a non-NULL response doesn't mean it's safe to call the function!
// You always have to check that the extension is supported;
// an implementation MAY return NULL in this case, but it doesn't have to (and doesn't, with the DRI drivers).
#ifdef TOGLES // TODO(nillerusr): remove this hack
okay = retval != NULL;
#else
okay = (okay && (retval != NULL));
#endif
if (bRequired && !okay)
{
// We can't continue execution, because one or more GL function pointers will be NULL.
@ -499,7 +507,11 @@ InitReturnVal_t CSDLMgr::Init()
SDL_GL_SetAttribute( SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG );
}
#ifdef TOGLES
if (SDL_GL_LoadLibrary("libGLESv2.so") == -1)
#else
if (SDL_GL_LoadLibrary(NULL) == -1)
#endif
Error( "SDL_GL_LoadLibrary(NULL) failed: %s", SDL_GetError() );
#endif
}
@ -568,7 +580,18 @@ InitReturnVal_t CSDLMgr::Init()
*(attCursor++) = (int) (key); \
*(attCursor++) = (int) (value);
#ifdef ANDROID
#ifdef TOGLES
l_egl = dlopen("libEGL.so", RTLD_LAZY);
if( l_egl )
_glGetProcAddress = (t_glGetProcAddress)dlsym(l_egl, "eglGetProcAddress");
SET_GL_ATTR(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SET_GL_ATTR(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SET_GL_ATTR(SDL_GL_CONTEXT_MINOR_VERSION, 0);
#elif ANDROID
bool m_bOGL = false;
l_egl = dlopen("libEGL.so", RTLD_LAZY);
@ -619,7 +642,7 @@ InitReturnVal_t CSDLMgr::Init()
// GL entry points, but the game hasn't made a window yet. So it's time
// to make a window! We make a 640x480 one here, and later, when asked
// to really actually make a window, we just resize the one we built here.
if ( !CreateHiddenGameWindow( "", 640, 480 ) )
if ( !CreateHiddenGameWindow( "", 1280, 720 ) )
Error( "CreateGameWindow failed" );
SDL_HideWindow( m_Window );
@ -653,7 +676,11 @@ void CSDLMgr::Shutdown()
SDLAPP_FUNC;
if (gGL && m_readFBO)
#ifdef TOGLES
gGL->glDeleteFramebuffers(1, &m_readFBO);
#else
gGL->glDeleteFramebuffersEXT(1, &m_readFBO);
#endif
m_readFBO = 0;
if ( m_Window )
@ -794,7 +821,7 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
SDL_GL_MakeCurrent(m_Window, m_GLContext);
#ifdef ANDROID
#if defined ANDROID && !defined TOGLES
if( l_gl4es )
{
_glGetProcAddress = (t_glGetProcAddress)dlsym(l_gl4es, "gl4es_GetProcAddress" );
@ -819,7 +846,9 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
// If we specified -gl_debug, make sure the extension string is present now.
if ( CommandLine()->FindParm( "-gl_debug" ) )
{
#ifndef TOGLES
Assert( V_strstr(pszString, "GL_ARB_debug_output") );
#endif
}
#endif // DBGFLAG_ASSERT
@ -844,7 +873,11 @@ bool CSDLMgr::CreateHiddenGameWindow( const char *pTitle, int width, int height
DebugPrintf("\n");
}
#ifdef TOGLES
gGL->glGenFramebuffers(1, &m_readFBO);
#else
gGL->glGenFramebuffersEXT(1, &m_readFBO);
#endif
gGL->glViewport(0, 0, width, height); /* Reset The Current Viewport And Perspective Transformation */
gGL->glScissor(0, 0, width, height); /* Reset The Current Viewport And Perspective Transformation */
@ -1191,6 +1224,17 @@ void CSDLMgr::ShowPixels( CShowPixelsParams *params )
// bind a quickie FBO to enclose the source texture
GLint myreadfb = 1000;
#ifdef TOGLES
glBindFramebuffer( GL_READ_FRAMEBUFFER, myreadfb);
CheckGLError( __LINE__ );
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0); // to the default FB/backbuffer
CheckGLError( __LINE__ );
// attach source tex to source FB
glFramebufferTexture2D( GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, params->m_srcTexName, 0);
CheckGLError( __LINE__ );
#else
glBindFramebufferEXT( GL_READ_FRAMEBUFFER_EXT, myreadfb);
CheckGLError( __LINE__ );
@ -1200,6 +1244,7 @@ void CSDLMgr::ShowPixels( CShowPixelsParams *params )
// attach source tex to source FB
glFramebufferTexture2DEXT( GL_READ_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, params->m_srcTexName, 0);
CheckGLError( __LINE__ );
#endif
// blit
@ -1234,6 +1279,23 @@ void CSDLMgr::ShowPixels( CShowPixelsParams *params )
// go NEAREST if sizes match
GLenum filter = ( ((srcxmax-srcxmin)==(dstxmax-dstxmin)) && ((srcymax-srcymin)==(dstymax-dstymin)) ) ? GL_NEAREST : GL_LINEAR;
#ifdef TOGLES
glBlitFramebuffer(
/* src min and maxes xy xy */ srcxmin, srcymin, srcxmax,srcymax,
/* dst min and maxes xy xy */ dstxmin, dstymax, dstxmax,dstymin, // note yflip here
GL_COLOR_BUFFER_BIT, filter );
CheckGLError( __LINE__ );
// detach source tex
glFramebufferTexture2D( GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
CheckGLError( __LINE__ );
glBindFramebuffer( GL_READ_FRAMEBUFFER, 0);
CheckGLError( __LINE__ );
glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0); // to the default FB/backbuffer
CheckGLError( __LINE__ );
#else
glBlitFramebufferEXT(
/* src min and maxes xy xy */ srcxmin, srcymin, srcxmax,srcymax,
/* dst min and maxes xy xy */ dstxmin, dstymax, dstxmax,dstymin, // note yflip here
@ -1249,6 +1311,7 @@ void CSDLMgr::ShowPixels( CShowPixelsParams *params )
glBindFramebufferEXT( GL_DRAW_FRAMEBUFFER_EXT, 0); // to the default FB/backbuffer
CheckGLError( __LINE__ );
#endif
}
else
@ -1911,7 +1974,11 @@ void CSDLMgr::DecWindowRefCount()
if ( gGL && m_readFBO )
{
#ifdef TOGLES
gGL->glDeleteFramebuffers( 1, &m_readFBO );
#else
gGL->glDeleteFramebuffersEXT( 1, &m_readFBO );
#endif
}
m_readFBO = 0;

View File

@ -1176,6 +1176,8 @@ static const char *BuildCommand()
return (const char *)build.Base();
}
extern void InitGL4ES();
//-----------------------------------------------------------------------------
// Purpose: The real entry point for the application
// Input : hInstance -
@ -1208,8 +1210,13 @@ DLL_EXPORT int LauncherMain( int argc, char **argv )
{
Warning( "WARNING: setlocale('%s') failed, using locale:'%s'. International characters may not work.\n", en_US, CurrentLocale );
}
#endif // LINUX
#if defined LINUX && defined USE_SDL && defined TOGLES
SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1");
#endif
#ifdef WIN32
SetAppInstance( hInstance );
#elif defined( POSIX )

View File

@ -1,2 +1,2 @@
#include "togl/linuxwin/glfuncs.h"
#include "togles/linuxwin/glfuncs.h"

View File

@ -90,7 +90,7 @@ struct GLMShaderDesc
union
{
GLuint arb; // ARB program object name
GLhandleARB glsl; // GLSL shader object handle (void*)
GLuint glsl; // GLSL shader object handle (void*)
} m_object;
// these can change if shader text is edited
@ -253,7 +253,7 @@ public:
CGLMProgram *m_vertexProg;
CGLMProgram *m_fragmentProg;
GLhandleARB m_program; // linked program object
GLuint m_program; // linked program object
// need meta data for attribs / samplers / params
// actually we only need it for samplers and params.

View File

@ -323,9 +323,9 @@ struct GLMTexSamplingParams
}
gGL->glSamplerParameterfv( nSamplerObject, GL_TEXTURE_BORDER_COLOR, flBorderColor ); // <-- this crashes ATI's driver, remark it out
gGL->glSamplerParameteri( nSamplerObject, GL_TEXTURE_MIN_LOD, m_packed.m_minLOD );
gGL->glSamplerParameterfv( nSamplerObject, GL_TEXTURE_LOD_BIAS, &m_lodBias );
// gGL->glSamplerParameterfv( nSamplerObject, GL_TEXTURE_LOD_BIAS, &m_lodBias );
gGL->glSamplerParameteri( nSamplerObject, GL_TEXTURE_COMPARE_MODE_ARB, m_packed.m_compareMode ? GL_COMPARE_R_TO_TEXTURE_ARB : GL_NONE );
gGL->glSamplerParameterf( nSamplerObject, GL_TEXTURE_LOD_BIAS, m_lodBias );
// gGL->glSamplerParameterf( nSamplerObject, GL_TEXTURE_LOD_BIAS, m_lodBias );
if ( m_packed.m_compareMode )
{
gGL->glSamplerParameteri( nSamplerObject, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL );
@ -443,7 +443,7 @@ struct GLMTexSamplingParams
}
gGL->glTexParameterfv( target, GL_TEXTURE_BORDER_COLOR, flBorderColor ); // <-- this crashes ATI's driver, remark it out
gGL->glTexParameteri( target, GL_TEXTURE_MIN_LOD, m_packed.m_minLOD );
gGL->glTexParameterfv( target, GL_TEXTURE_LOD_BIAS, &m_lodBias );
// gGL->glTexParameterfv( target, GL_TEXTURE_LOD_BIAS, &m_lodBias );
gGL->glTexParameteri( target, GL_TEXTURE_COMPARE_MODE_ARB, m_packed.m_compareMode ? GL_COMPARE_R_TO_TEXTURE_ARB : GL_NONE );
if ( m_packed.m_compareMode )
{

View File

@ -30,7 +30,7 @@
#ifdef DX_TO_GL_ABSTRACTION
#include "togl/rendermechanism.h"
#include "togles/rendermechanism.h"
#include "tier0/platform.h"
#include "tier0/dbg.h"

View File

@ -36,7 +36,7 @@
#include "tier0/platform.h"
#include "tier0/vprof_telemetry.h"
#include "interface.h"
#include "togl/rendermechanism.h"
#include "togles/rendermechanism.h"
void *VoidFnPtrLookup_GlMgr(const char *fn, bool &okay, const bool bRequired, void *fallback=NULL);
@ -316,7 +316,7 @@ public:
#define GL_FUNC(ext,req,ret,fn,arg,call) CDynamicFunctionOpenGL< req, ret (APIENTRY *) arg, ret > fn;
#define GL_FUNC_VOID(ext,req,fn,arg,call) CDynamicFunctionOpenGL< req, void (APIENTRY *) arg, void > fn;
#endif
#include "togl/glfuncs.inl"
#include "togles/glfuncs.inl"
#undef GL_FUNC_VOID
#undef GL_FUNC
#undef GL_EXT

View File

@ -23,40 +23,45 @@
// THE SOFTWARE.
// !!! FIXME: Some of these aren't base OpenGL...pick out the extensions.
// !!! FIXME: Also, look up these -1, -1 versions numbers.
GL_FUNC(OpenGL,true,GLenum,glGetError,(void),())
GL_FUNC_VOID(OpenGL,true,glActiveTexture,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glAlphaFunc,(GLenum a,GLclampf b),(a,b))
GL_FUNC_VOID(OpenGL,true,glAttachObjectARB,(GLhandleARB a,GLhandleARB b),(a,b))
GL_FUNC_VOID(OpenGL,true,glAttachShader,(GLuint a, GLuint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glBegin,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glBindAttribLocationARB,(GLhandleARB a,GLuint b,const GLcharARB *c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glBindBufferARB,(GLenum a,GLuint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glBindProgramARB,(GLenum a,GLuint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glBindAttribLocation,(GLuint a,GLuint b,const GLchar *c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glBindBuffer,(GLenum a,GLuint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glBindProgram,(GLenum a,GLuint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glBindTexture,(GLenum a,GLuint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glBlendColor,(GLclampf a,GLclampf b,GLclampf c,GLclampf d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glBlendEquation,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glBlendFunc,(GLenum a,GLenum b),(a,b))
GL_FUNC_VOID(OpenGL,true,glBufferDataARB,(GLenum a,GLsizeiptrARB b,const GLvoid *c,GLenum d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glBufferData,(GLenum a, GLsizeiptr b, const GLvoid *c,GLenum d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glClear,(GLbitfield a),(a))
GL_FUNC_VOID(OpenGL,true,glClearColor,(GLclampf a,GLclampf b,GLclampf c,GLclampf d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glClearDepth,(GLclampd a),(a))
GL_FUNC_VOID(OpenGL,true,glReadPixels, (GLint a, GLint b, GLsizei c, GLsizei d, GLenum e, GLenum f, void * g), (a,b,c,d,e,f,g))
GL_FUNC_VOID(OpenGL,true,glClearStencil,(GLint a),(a))
GL_FUNC_VOID(OpenGL,true,glClipPlane,(GLenum a,const GLdouble *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glColorMask,(GLboolean a,GLboolean b,GLboolean c,GLboolean d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glCompileShaderARB,(GLhandleARB a),(a))
GL_FUNC_VOID(OpenGL,true,glCompileShader,(GLuint a),(a))
GL_FUNC_VOID(OpenGL,true,glGetShaderiv,(GLuint a, GLenum b, GLint *c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glGetShaderInfoLog,(GLuint a, GLsizei b, GLsizei *c, GLchar *d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glGetProgramInfoLog,(GLuint a, GLsizei b, GLsizei *c, GLchar *d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glCompressedTexImage2D,(GLenum a,GLint b,GLenum c,GLsizei d,GLsizei e,GLint f,GLsizei g,const GLvoid *h),(a,b,c,d,e,f,g,h))
GL_FUNC_VOID(OpenGL,true,glCompressedTexImage3D,(GLenum a,GLint b,GLenum c,GLsizei d,GLsizei e,GLsizei f,GLint g,GLsizei h,const GLvoid *i),(a,b,c,d,e,f,g,h,i))
GL_FUNC(OpenGL,true,GLhandleARB,glCreateProgramObjectARB,(void),())
GL_FUNC(OpenGL,true,GLhandleARB,glCreateShaderObjectARB,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glDeleteBuffersARB,(GLsizei a,const GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glDeleteObjectARB,(GLhandleARB a),(a))
GL_FUNC_VOID(OpenGL,true,glDeleteProgramsARB,(GLsizei a,const GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glDeleteQueriesARB,(GLsizei a,const GLuint *b),(a,b))
GL_FUNC(OpenGL,true,GLuint,glCreateProgram,(void),())
GL_FUNC(OpenGL,true,GLuint,glCreateShader,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glDeleteBuffers,(GLsizei a,const GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glDeleteObject,(GLuint a),(a))
GL_FUNC_VOID(OpenGL,true,glDeletePrograms,(GLsizei a,const GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glDeleteShader,(GLuint a),(a))
GL_FUNC_VOID(OpenGL,true,glDeleteTextures,(GLsizei a,const GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glDepthFunc,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glDepthMask,(GLboolean a),(a))
GL_FUNC_VOID(OpenGL,true,glDepthRangef,(GLfloat a,GLfloat b),(a,b))
GL_FUNC_VOID(OpenGL,true,glDepthRange,(GLclampd a,GLclampd b),(a,b))
GL_FUNC_VOID(OpenGL,true,glDetachObjectARB,(GLhandleARB a,GLhandleARB b),(a,b))
GL_FUNC_VOID(OpenGL,true,glDetachObject,(GLuint a,GLuint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glDisable,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glDisableVertexAttribArray,(GLuint a),(a))
GL_FUNC_VOID(OpenGL,true,glDrawArrays,(GLenum a,GLint b,GLsizei c),(a,b,c))
@ -72,35 +77,34 @@ GL_FUNC_VOID(OpenGL,true,glEnd,(void),())
GL_FUNC_VOID(OpenGL,true,glFinish,(void),())
GL_FUNC_VOID(OpenGL,true,glFlush,(void),())
GL_FUNC_VOID(OpenGL,true,glFrontFace,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glGenBuffersARB,(GLsizei a,GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glGenProgramsARB,(GLsizei a,GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glGenQueriesARB,(GLsizei a,GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glGenBuffers,(GLsizei a,GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glGenPrograms,(GLsizei a,GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glGenTextures,(GLsizei a,GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glGetBooleanv,(GLenum a,GLboolean *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glGetCompressedTexImage,(GLenum a,GLint b,GLvoid *c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glGetDoublev,(GLenum a,GLdouble *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glGetFloatv,(GLenum a,GLfloat *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glGetInfoLogARB,(GLhandleARB a,GLsizei b,GLsizei *c,GLcharARB *d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glGetInfoLog,(GLuint a,GLsizei b,GLsizei *c,GLchar *d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glGetIntegerv,(GLenum a,GLint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glGetObjectParameterivARB,(GLhandleARB a,GLenum b,GLint *c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glGetProgramivARB,(GLenum a,GLenum b,GLint *c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glGetObjectParameteriv,(GLuint a,GLenum b,GLint *c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glGetProgramiv,(GLenum a,GLenum b,GLint *c),(a,b,c))
GL_FUNC(OpenGL,true,const GLubyte *,glGetString,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glGetTexImage,(GLenum a,GLint b,GLenum c,GLenum d,GLvoid *e),(a,b,c,d,e))
GL_FUNC(OpenGL,true,GLint,glGetUniformLocationARB,(GLhandleARB a,const GLcharARB *b),(a,b))
GL_FUNC(OpenGL,true,GLint,glGetUniformLocation,(GLuint a,const GLchar *b),(a,b))
GL_FUNC(OpenGL,true,GLboolean,glIsEnabled,(GLenum a),(a))
GL_FUNC(OpenGL,true,GLboolean,glIsTexture,(GLuint a),(a))
GL_FUNC_VOID(OpenGL,true,glLinkProgramARB,(GLhandleARB a),(a))
GL_FUNC(OpenGL,true,GLvoid*,glMapBufferARB,(GLenum a,GLenum b),(a,b))
GL_FUNC_VOID(OpenGL,true,glLinkProgram,(GLuint a),(a))
//GL_FUNC(OpenGL,true,GLvoid*,glMapBufferARB,(GLenum a,GLenum b),(a,b))
GL_FUNC_VOID(OpenGL,true,glOrtho,(GLdouble a,GLdouble b,GLdouble c,GLdouble d,GLdouble e,GLdouble f),(a,b,c,d,e,f))
GL_FUNC_VOID(OpenGL,true,glPixelStorei,(GLenum a,GLint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glPolygonMode,(GLenum a,GLenum b),(a,b))
GL_FUNC_VOID(OpenGL,true,glPolygonOffset,(GLfloat a,GLfloat b),(a,b))
GL_FUNC_VOID(OpenGL,true,glPopAttrib,(void),())
GL_FUNC_VOID(OpenGL,true,glProgramStringARB,(GLenum a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d))
//GL_FUNC_VOID(OpenGL,true,glProgramStringARB,(GLenum a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glPushAttrib,(GLbitfield a),(a))
GL_FUNC_VOID(OpenGL,true,glReadBuffer,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glScissor,(GLint a,GLint b,GLsizei c,GLsizei d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glShaderSourceARB,(GLhandleARB a,GLsizei b,const GLcharARB **c,const GLint *d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glShaderSource,(GLuint a,GLsizei b,const GLchar **c,const GLint *d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glStencilFunc,(GLenum a,GLint b,GLuint c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glStencilMask,(GLuint a),(a))
GL_FUNC_VOID(OpenGL,true,glStencilOp,(GLenum a,GLenum b,GLenum c),(a,b,c))
@ -131,7 +135,9 @@ GL_FUNC_VOID(OpenGL,true,glStencilFuncSeparate,(GLenum a,GLenum b,GLint c,GLuint
GL_FUNC_VOID(OpenGL,true,glGetTexLevelParameteriv,(GLenum a,GLint b,GLenum c,GLint *d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glColor4f,(GLfloat a,GLfloat b,GLfloat c,GLfloat d),(a,b,c,d))
GL_EXT(GL_EXT_framebuffer_object,-1,-1)
GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glBindFramebufferEXT,(GLenum a,GLuint b),(a,b))
GL_EXT(GL_EXT_framebuffer_blit,-1,-1)
GL_EXT(GL_EXT_framebuffer_multisample,-1,-1)
/*GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glBindFramebufferEXT,(GLenum a,GLuint b),(a,b))
GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glBindRenderbufferEXT,(GLenum a,GLuint b),(a,b))
GL_FUNC(GL_EXT_framebuffer_object,false,GLenum,glCheckFramebufferStatusEXT,(GLenum a),(a))
GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glDeleteRenderbuffersEXT,(GLsizei a,const GLuint *b),(a,b))
@ -141,10 +147,8 @@ GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferTexture3DEXT,(GLenum a
GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glGenFramebuffersEXT,(GLsizei a,GLuint *b),(a,b))
GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glGenRenderbuffersEXT,(GLsizei a,GLuint *b),(a,b))
GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glDeleteFramebuffersEXT,(GLsizei a,const GLuint *b),(a,b))
GL_EXT(GL_EXT_framebuffer_blit,-1,-1)
GL_FUNC_VOID(GL_EXT_framebuffer_blit,false,glBlitFramebufferEXT,(GLint a,GLint b,GLint c,GLint d,GLint e,GLint f,GLint g,GLint h,GLbitfield i,GLenum j),(a,b,c,d,e,f,g,h,i,j))
GL_EXT(GL_EXT_framebuffer_multisample,-1,-1)
GL_FUNC_VOID(GL_EXT_framebuffer_multisample,false,glRenderbufferStorageMultisampleEXT,(GLenum a,GLsizei b,GLenum c,GLsizei d,GLsizei e),(a,b,c,d,e))
GL_FUNC_VOID(GL_EXT_framebuffer_multisample,false,glRenderbufferStorageMultisampleEXT,(GLenum a,GLsizei b,GLenum c,GLsizei d,GLsizei e),(a,b,c,d,e))*/
GL_EXT(GL_APPLE_fence,-1,-1)
GL_FUNC(GL_APPLE_fence,false,GLboolean,glTestFenceAPPLE,(GLuint a),(a))
GL_FUNC_VOID(GL_APPLE_fence,false,glSetFenceAPPLE,(GLuint a),(a))
@ -178,15 +182,15 @@ GL_EXT(GL_APPLE_flush_buffer_range,-1,-1)
GL_FUNC_VOID(GL_APPLE_flush_buffer_range,false,glBufferParameteriAPPLE,(GLenum a,GLenum b,GLint c),(a,b,c))
GL_FUNC_VOID(GL_APPLE_flush_buffer_range,false,glFlushMappedBufferRangeAPPLE,(GLenum a,GLintptr b,GLsizeiptr c),(a,b,c))
GL_EXT(GL_ARB_map_buffer_range,-1,-1)
GL_FUNC(GL_ARB_map_buffer_range,false,void*,glMapBufferRange,(GLenum a,GLintptr b,GLsizeiptr c,GLbitfield d),(a,b,c,d))
GL_FUNC_VOID(GL_ARB_map_buffer_range,false,glFlushMappedBufferRange,(GLenum a,GLintptr b,GLsizeiptr c),(a,b,c))
GL_FUNC(OpenGL,false,void*,glMapBufferRange,(GLenum a,GLintptr b,GLsizeiptr c,GLbitfield d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,false,glFlushMappedBufferRange,(GLenum a,GLintptr b,GLsizeiptr c),(a,b,c))
GL_EXT(GL_ARB_vertex_buffer_object,-1,-1)
GL_FUNC_VOID(GL_ARB_vertex_buffer_object,true,glBufferSubData,(GLenum a,GLintptr b,GLsizeiptr c,const GLvoid *d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glBufferSubData,(GLenum a,GLintptr b,GLsizeiptr c,const GLvoid *d),(a,b,c,d))
GL_EXT(GL_ARB_occlusion_query,-1,-1)
GL_FUNC_VOID(GL_ARB_occlusion_query,false,glBeginQueryARB,(GLenum a,GLuint b),(a,b))
GL_FUNC_VOID(GL_ARB_occlusion_query,false,glEndQueryARB,(GLenum a),(a))
GL_FUNC_VOID(GL_ARB_occlusion_query,false,glGetQueryObjectivARB,(GLuint a,GLenum b,GLint *c),(a,b,c))
GL_FUNC_VOID(GL_ARB_occlusion_query,false,glGetQueryObjectuivARB,(GLuint a,GLenum b,GLuint *c),(a,b,c))
GL_FUNC_VOID(OpenGL,false,glGetQueryObjectuiv,(GLuint a,GLenum b,GLuint *c),(a,b,c))
GL_EXT(GL_APPLE_texture_range,-1,-1)
GL_FUNC_VOID(GL_APPLE_texture_range,false,glTextureRangeAPPLE,(GLenum a,GLsizei b,void *c),(a,b,c))
GL_FUNC_VOID(GL_APPLE_texture_range,false,glGetTexParameterPointervAPPLE,(GLenum a,GLenum b,void* *c),(a,b,c))
@ -194,8 +198,9 @@ GL_EXT(GL_APPLE_client_storage,-1,-1)
GL_EXT(GL_ARB_uniform_buffer,-1,-1)
GL_EXT(GL_ARB_vertex_array_bgra,-1,-1)
GL_EXT(GL_EXT_vertex_array_bgra,-1,-1)
GL_EXT(GL_ARB_framebuffer_object,3,0)
GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBindFramebuffer,(GLenum a,GLuint b),(a,b))
/*GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBindFramebuffer,(GLenum a,GLuint b),(a,b))
GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBindRenderbuffer,(GLenum a,GLuint b),(a,b))
GL_FUNC(GL_ARB_framebuffer_object,false,GLenum,glCheckFramebufferStatus,(GLenum a),(a))
GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glDeleteRenderbuffers,(GLsizei a,const GLuint *b),(a,b))
@ -207,15 +212,25 @@ GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glGenRenderbuffers,(GLsizei a,GLuin
GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glDeleteFramebuffers,(GLsizei a,const GLuint *b),(a,b))
GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glBlitFramebuffer,(GLint a,GLint b,GLint c,GLint d,GLint e,GLint f,GLint g,GLint h,GLbitfield i,GLenum j),(a,b,c,d,e,f,g,h,i,j))
GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glRenderbufferStorageMultisample,(GLenum a,GLsizei b,GLenum c,GLsizei d,GLsizei e),(a,b,c,d,e))
*/
GL_FUNC_VOID(OpenGL,false,glBindFramebuffer,(GLenum a,GLuint b),(a,b))
GL_FUNC_VOID(OpenGL,false,glBindRenderbuffer,(GLenum a,GLuint b),(a,b))
GL_FUNC(OpenGL,false,GLenum,glCheckFramebufferStatus,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,false,glDeleteRenderbuffers,(GLsizei a,const GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,false,glFramebufferRenderbuffer,(GLenum a,GLenum b,GLenum c,GLuint d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,false,glFramebufferTexture2D,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e),(a,b,c,d,e))
GL_FUNC_VOID(OpenGL,false,glFramebufferTexture3D,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e,GLint f),(a,b,c,d,e,f))
GL_FUNC_VOID(OpenGL,false,glGenFramebuffers,(GLsizei a,GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,false,glGenRenderbuffers,(GLsizei a,GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,false,glDeleteFramebuffers,(GLsizei a,const GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,false,glBlitFramebuffer,(GLint a,GLint b,GLint c,GLint d,GLint e,GLint f,GLint g,GLint h,GLbitfield i,GLenum j),(a,b,c,d,e,f,g,h,i,j))
GL_FUNC_VOID(OpenGL,false,glRenderbufferStorageMultisample,(GLenum a,GLsizei b,GLenum c,GLsizei d,GLsizei e),(a,b,c,d,e))
GL_EXT(GL_GREMEDY_string_marker,-1,-1)
GL_FUNC_VOID(GL_GREMEDY_string_marker,false,glStringMarkerGREMEDY,(GLsizei a,const void *b),(a,b))
GL_EXT(GL_ARB_debug_output,-1,-1)
#ifdef OSX
GL_FUNC_VOID(GL_ARB_debug_output,false,glDebugMessageCallbackARB,(void ( *a)(GLenum, GLenum , GLuint , GLenum , GLsizei , const GLchar* , GLvoid*) ,void* b),(a,b))
#else
GL_FUNC_VOID(GL_ARB_debug_output,false,glDebugMessageCallbackARB,(void (APIENTRY *a)(GLenum, GLenum , GLuint , GLenum , GLsizei , const GLchar* , GLvoid*) ,void* b),(a,b))
#endif
GL_FUNC_VOID(GL_ARB_debug_output,false,glDebugMessageControlARB,(GLenum a, GLenum b, GLenum c, GLsizei d, const GLuint* e, GLboolean f),(a,b,c,d,e,f))
GL_FUNC_VOID(OpenGL,false,glDebugMessageCallback,(void (APIENTRY *a)(GLenum, GLenum , GLuint , GLenum , GLsizei , const GLchar* , GLvoid*) ,void* b),(a,b))
GL_FUNC_VOID(OpenGL,false,glDebugMessageControl,(GLenum a, GLenum b, GLenum c, GLsizei d, const GLuint* e, GLboolean f),(a,b,c,d,e,f))
GL_EXT(GL_EXT_direct_state_access,-1,-1)
GL_FUNC_VOID(GL_EXT_direct_state_access,false,glBindMultiTextureEXT,(GLenum a,GLuint b, GLuint c),(a,b,c))

View File

@ -325,7 +325,7 @@ FORCEINLINE void GLContextGetDefault( GLAlphaTestEnable_t *dst )
// --- GLAlphaTestFunc ---
FORCEINLINE void GLContextSet( GLAlphaTestFunc_t *src )
{
gGL->glAlphaFunc( src->func, src->ref );
// gGL->glAlphaFunc( src->func, src->ref );
}
FORCEINLINE void GLContextGet( GLAlphaTestFunc_t *dst )
@ -343,12 +343,12 @@ FORCEINLINE void GLContextGetDefault( GLAlphaTestFunc_t *dst )
// --- GLAlphaToCoverageEnable ---
FORCEINLINE void GLContextSet( GLAlphaToCoverageEnable_t *src )
{
glSetEnable( GL_SAMPLE_ALPHA_TO_COVERAGE_ARB, src->enable != 0 );
glSetEnable( GL_SAMPLE_ALPHA_TO_COVERAGE, src->enable != 0 );
}
FORCEINLINE void GLContextGet( GLAlphaToCoverageEnable_t *dst )
{
dst->enable = gGL->glIsEnabled( GL_SAMPLE_ALPHA_TO_COVERAGE_ARB );
dst->enable = gGL->glIsEnabled( GL_SAMPLE_ALPHA_TO_COVERAGE );
}
FORCEINLINE void GLContextGetDefault( GLAlphaToCoverageEnable_t *dst )
@ -393,8 +393,8 @@ FORCEINLINE void GLContextGetDefault( GLCullFrontFace_t *dst )
// --- GLPolygonMode ---
FORCEINLINE void GLContextSet( GLPolygonMode_t *src )
{
gGL->glPolygonMode( GL_FRONT, src->values[0] );
gGL->glPolygonMode( GL_BACK, src->values[1] );
// gGL->glPolygonMode( GL_FRONT, src->values[0] );
// gGL->glPolygonMode( GL_BACK, src->values[1] );
}
FORCEINLINE void GLContextGet( GLPolygonMode_t *dst )
@ -497,7 +497,7 @@ FORCEINLINE void GLContextGetDefault( GLViewportBox_t *dst )
// --- GLViewportDepthRange ---
FORCEINLINE void GLContextSet( GLViewportDepthRange_t *src )
{
gGL->glDepthRange ( src->flNear, src->flFar );
gGL->glDepthRangef ( src->flNear, src->flFar );
}
FORCEINLINE void GLContextGet( GLViewportDepthRange_t *dst )
@ -543,9 +543,9 @@ FORCEINLINE void GLContextGetDefaultIndexed( GLClipPlaneEnable_t *dst, int index
FORCEINLINE void GLContextSetIndexed( GLClipPlaneEquation_t *src, int index )
{
// shove into glGlipPlane
GLdouble coeffs[4] = { src->x, src->y, src->z, src->w };
gGL->glClipPlane( GL_CLIP_PLANE0 + index, coeffs );
// GLdouble coeffs[4] = { src->x, src->y, src->z, src->w };
// gGL->glClipPlane( GL_CLIP_PLANE0 + index, coeffs );
}
FORCEINLINE void GLContextGetIndexed( GLClipPlaneEquation_t *dst, int index )
@ -864,7 +864,8 @@ FORCEINLINE void GLContextGetDefault( GLClearColor_t *dst )
// --- GLClearDepth ---
FORCEINLINE void GLContextSet( GLClearDepth_t *src )
{
gGL->glClearDepth ( src->d );
// TOFUCK: wut
// gGL->glClearDepth ( src->d );
}
FORCEINLINE void GLContextGet( GLClearDepth_t *dst )
@ -1204,133 +1205,6 @@ public:
uint m_nNewVS;
};
//===========================================================================//
#ifndef OSX
#ifndef GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD
#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160
#endif
#define GLMGR_PINNED_MEMORY_BUFFER_SIZE ( 6 * 1024 * 1024 )
class CPinnedMemoryBuffer
{
CPinnedMemoryBuffer( const CPinnedMemoryBuffer & );
CPinnedMemoryBuffer & operator= ( const CPinnedMemoryBuffer & );
public:
CPinnedMemoryBuffer()
:
m_pRawBuf( NULL )
, m_pBuf( NULL )
, m_nSize( 0 )
, m_nOfs( 0 )
, m_nBufferObj( 0 )
#ifdef HAVE_GL_ARB_SYNC
, m_nSyncObj( 0 )
#endif
{
}
~CPinnedMemoryBuffer()
{
Deinit();
}
bool Init( uint nSize )
{
Deinit();
// Guarantee 64KB alignment
m_pRawBuf = malloc( nSize + 65535 );
m_pBuf = reinterpret_cast<void *>((reinterpret_cast<uint64>(m_pRawBuf) + 65535) & (~65535));
m_nSize = nSize;
m_nOfs = 0;
gGL->glGenBuffersARB( 1, &m_nBufferObj );
gGL->glBindBufferARB( GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, m_nBufferObj );
gGL->glBufferDataARB( GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, m_nSize, m_pBuf, GL_STREAM_COPY );
return true;
}
void Deinit()
{
if ( !m_pRawBuf )
return;
BlockUntilNotBusy();
gGL->glBindBufferARB(GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, m_nBufferObj );
gGL->glBufferDataARB( GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0, (void*)NULL, GL_STREAM_COPY );
gGL->glBindBufferARB( GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, 0 );
gGL->glDeleteBuffersARB( 1, &m_nBufferObj );
m_nBufferObj = 0;
free( m_pRawBuf );
m_pRawBuf = NULL;
m_pBuf = NULL;
m_nSize = 0;
m_nOfs = 0;
}
inline uint GetSize() const { return m_nSize; }
inline uint GetOfs() const { return m_nOfs; }
inline uint GetBytesRemaining() const { return m_nSize - m_nOfs; }
inline void *GetPtr() const { return m_pBuf; }
inline GLuint GetHandle() const { return m_nBufferObj; }
void InsertFence()
{
#ifdef HAVE_GL_ARB_SYNC
if ( m_nSyncObj )
{
gGL->glDeleteSync( m_nSyncObj );
}
m_nSyncObj = gGL->glFenceSync( GL_SYNC_GPU_COMMANDS_COMPLETE, 0 );
#endif
}
void BlockUntilNotBusy()
{
#ifdef HAVE_GL_ARB_SYNC
if ( m_nSyncObj )
{
gGL->glClientWaitSync( m_nSyncObj, GL_SYNC_FLUSH_COMMANDS_BIT, 3000000000000ULL );
gGL->glDeleteSync( m_nSyncObj );
m_nSyncObj = 0;
}
#endif
m_nOfs = 0;
}
void Append( uint nSize )
{
m_nOfs += nSize;
Assert( m_nOfs <= m_nSize );
}
private:
void *m_pRawBuf;
void *m_pBuf;
uint m_nSize;
uint m_nOfs;
GLuint m_nBufferObj;
#ifdef HAVE_GL_ARB_SYNC
GLsync m_nSyncObj;
#endif
};
#endif // !OSX
//===========================================================================//
class GLMContext
@ -1568,7 +1442,7 @@ class GLMContext
if ( nGLName != m_nBoundGLBuffer[kGLMVertexBuffer] )
{
m_nBoundGLBuffer[kGLMVertexBuffer] = nGLName;
gGL->glBindBufferARB( GL_ARRAY_BUFFER_ARB, nGLName );
gGL->glBindBuffer( GL_ARRAY_BUFFER, nGLName );
}
else if ( ( curAttribs.m_pPtr == pBuf ) &&
( curAttribs.m_revision == nRevision ) &&
@ -1624,18 +1498,18 @@ class GLMContext
void BindTexToTMU( CGLMTex *tex, int tmu );
// render targets / FBO's
void BindFBOToCtx( CGLMFBO *fbo, GLenum bindPoint = GL_FRAMEBUFFER_EXT ); // you can also choose GL_READ_FRAMEBUFFER_EXT / GL_DRAW_FRAMEBUFFER_EXT
void BindFBOToCtx( CGLMFBO *fbo, GLenum bindPoint = GL_FRAMEBUFFER ); // you can also choose GL_READ_FRAMEBUFFER_EXT / GL_DRAW_FRAMEBUFFER_EXT
// buffers
FORCEINLINE void BindGLBufferToCtx( GLenum nGLBufType, GLuint nGLName, bool bForce = false )
{
Assert( ( nGLBufType == GL_ARRAY_BUFFER_ARB ) || ( nGLBufType == GL_ELEMENT_ARRAY_BUFFER_ARB ) );
const uint nIndex = ( nGLBufType == GL_ARRAY_BUFFER_ARB ) ? kGLMVertexBuffer : kGLMIndexBuffer;
Assert( ( nGLBufType == GL_ARRAY_BUFFER ) || ( nGLBufType == GL_ELEMENT_ARRAY_BUFFER ) );
const uint nIndex = ( nGLBufType == GL_ARRAY_BUFFER ) ? kGLMVertexBuffer : kGLMIndexBuffer;
if ( ( bForce ) || ( m_nBoundGLBuffer[nIndex] != nGLName ) )
{
m_nBoundGLBuffer[nIndex] = nGLName;
gGL->glBindBufferARB( nGLBufType, nGLName );
gGL->glBindBuffer( nGLBufType, nGLName );
}
}
@ -1654,10 +1528,6 @@ class GLMContext
void GenDebugFontTex( void );
void DrawDebugText( float x, float y, float z, float drawCharWidth, float drawCharHeight, char *string );
#ifndef OSX
CPinnedMemoryBuffer *GetCurPinnedMemoryBuffer( ) { return &m_PinnedMemoryBuffers[m_nCurPinnedMemoryBuffer]; }
#endif
CPersistentBuffer* GetCurPersistentBuffer( EGLMBufferType type ) { return &( m_persistentBuffer[m_nCurPersistentBuffer][type] ); }
// members------------------------------------------
@ -1859,12 +1729,6 @@ class GLMContext
GLuint m_destroyPBO;
CUtlVector< TextureEntry_t > m_availableTextures;
#ifndef OSX
enum { cNumPinnedMemoryBuffers = 4 };
CPinnedMemoryBuffer m_PinnedMemoryBuffers[cNumPinnedMemoryBuffers];
uint m_nCurPinnedMemoryBuffer;
#endif
enum { cNumPersistentBuffers = 3 };
CPersistentBuffer m_persistentBuffer[cNumPersistentBuffers][kGLMNumBufferTypes];
uint m_nCurPersistentBuffer;
@ -2320,7 +2184,7 @@ FORCEINLINE void GLMContext::BindIndexBufferToCtx( CGLMBuffer *buff )
{
GLMPRINTF(( "--- GLMContext::BindIndexBufferToCtx buff %p, GL name %d", buff, (buff) ? buff->m_nHandle : -1 ));
Assert( !buff || ( buff->m_buffGLTarget == GL_ELEMENT_ARRAY_BUFFER_ARB ) );
Assert( !buff || ( buff->m_buffGLTarget == GL_ELEMENT_ARRAY_BUFFER ) );
GLuint nGLName = buff ? buff->GetHandle() : 0;
@ -2328,14 +2192,14 @@ FORCEINLINE void GLMContext::BindIndexBufferToCtx( CGLMBuffer *buff )
return;
m_nBoundGLBuffer[ kGLMIndexBuffer] = nGLName;
gGL->glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, nGLName );
gGL->glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, nGLName );
}
FORCEINLINE void GLMContext::BindVertexBufferToCtx( CGLMBuffer *buff )
{
GLMPRINTF(( "--- GLMContext::BindVertexBufferToCtx buff %p, GL name %d", buff, (buff) ? buff->m_nHandle : -1 ));
Assert( !buff || ( buff->m_buffGLTarget == GL_ARRAY_BUFFER_ARB ) );
Assert( !buff || ( buff->m_buffGLTarget == GL_ARRAY_BUFFER ) );
GLuint nGLName = buff ? buff->GetHandle() : 0;
@ -2343,7 +2207,7 @@ FORCEINLINE void GLMContext::BindVertexBufferToCtx( CGLMBuffer *buff )
return;
m_nBoundGLBuffer[ kGLMVertexBuffer] = nGLName;
gGL->glBindBufferARB( GL_ARRAY_BUFFER_ARB, nGLName );
gGL->glBindBuffer( GL_ARRAY_BUFFER, nGLName );
}
FORCEINLINE void GLMContext::SetMaxUsedVertexShaderConstantsHint( uint nMaxConstants )

View File

@ -35,21 +35,21 @@
#include "tier0/basetypes.h"
#include "tier0/platform.h"
#include "togl/linuxwin/glmdebug.h"
#include "togl/linuxwin/glbase.h"
#include "togl/linuxwin/glentrypoints.h"
#include "togl/linuxwin/glmdisplay.h"
#include "togl/linuxwin/glmdisplaydb.h"
#include "togl/linuxwin/glmgrbasics.h"
#include "togl/linuxwin/glmgrext.h"
#include "togl/linuxwin/cglmbuffer.h"
#include "togl/linuxwin/cglmtex.h"
#include "togl/linuxwin/cglmfbo.h"
#include "togl/linuxwin/cglmprogram.h"
#include "togl/linuxwin/cglmquery.h"
#include "togl/linuxwin/glmgr.h"
#include "togl/linuxwin/dxabstract_types.h"
#include "togl/linuxwin/dxabstract.h"
#include "togles/linuxwin/glmdebug.h"
#include "togles/linuxwin/glbase.h"
#include "togles/linuxwin/glentrypoints.h"
#include "togles/linuxwin/glmdisplay.h"
#include "togles/linuxwin/glmdisplaydb.h"
#include "togles/linuxwin/glmgrbasics.h"
#include "togles/linuxwin/glmgrext.h"
#include "togles/linuxwin/cglmbuffer.h"
#include "togles/linuxwin/cglmtex.h"
#include "togles/linuxwin/cglmfbo.h"
#include "togles/linuxwin/cglmprogram.h"
#include "togles/linuxwin/cglmquery.h"
#include "togles/linuxwin/glmgr.h"
#include "togles/linuxwin/dxabstract_types.h"
#include "togles/linuxwin/dxabstract.h"
#else
//USE_ACTUAL_DX

View File

@ -1,7 +1,7 @@
typedef unsigned int uint;
#include "../public/togl/linuxwin/glmdisplay.h"
#include "../public/togl/linuxwin/glmdisplaydb.h"
#include "../public/togles/linuxwin/glmdisplay.h"
#include "../public/togles/linuxwin/glmdisplaydb.h"
void GLMDisplayDB::PopulateRenderers( void ) { }
void GLMDisplayDB::PopulateFakeAdapters( uint realRendererIndex ) { } // fake adapters = one real adapter times however many displays are on

View File

@ -26,7 +26,7 @@
//
//===============================================================================
#include "togl/rendermechanism.h"
#include "togles/rendermechanism.h"
// memdbgon -must- be the last include file in a .cpp file.
#include "tier0/memdbgon.h"
@ -102,16 +102,16 @@ void CPersistentBuffer::Init( EGLMBufferType type,uint nSize )
switch ( type )
{
case kGLMVertexBuffer: m_buffGLTarget = GL_ARRAY_BUFFER_ARB; break;
case kGLMIndexBuffer: m_buffGLTarget = GL_ELEMENT_ARRAY_BUFFER_ARB; break;
case kGLMVertexBuffer: m_buffGLTarget = GL_ARRAY_BUFFER; break;
case kGLMIndexBuffer: m_buffGLTarget = GL_ELEMENT_ARRAY_BUFFER; break;
default: Assert( nSize == 0 );
}
if ( m_nSize > 0 )
{
gGL->glGenBuffersARB( 1, &m_nHandle );
gGL->glBindBufferARB( m_buffGLTarget, m_nHandle );
gGL->glGenBuffers( 1, &m_nHandle );
gGL->glBindBuffer( m_buffGLTarget, m_nHandle );
// Create persistent immutable buffer that we will permanently map. This buffer can be written from any thread (not just
// the renderthread)
@ -132,11 +132,11 @@ void CPersistentBuffer::Deinit()
BlockUntilNotBusy();
gGL->glBindBufferARB( m_buffGLTarget, m_nHandle );
gGL->glBindBuffer( m_buffGLTarget, m_nHandle );
gGL->glUnmapBuffer( m_buffGLTarget );
gGL->glBindBufferARB( m_buffGLTarget, 0 );
gGL->glBindBuffer( m_buffGLTarget, 0 );
gGL->glDeleteBuffersARB( 1, &m_nHandle );
gGL->glDeleteBuffers( 1, &m_nHandle );
m_nSize = 0;
m_nHandle = 0;
@ -438,10 +438,10 @@ CGLMBuffer::CGLMBuffer( GLMContext *pCtx, EGLMBufferType type, uint size, uint o
switch ( m_type )
{
case kGLMVertexBuffer: m_buffGLTarget = GL_ARRAY_BUFFER_ARB; break;
case kGLMIndexBuffer: m_buffGLTarget = GL_ELEMENT_ARRAY_BUFFER_ARB; break;
case kGLMUniformBuffer: m_buffGLTarget = GL_UNIFORM_BUFFER_EXT; break;
case kGLMPixelBuffer: m_buffGLTarget = GL_PIXEL_UNPACK_BUFFER_ARB; break;
case kGLMVertexBuffer: m_buffGLTarget = GL_ARRAY_BUFFER; break;
case kGLMIndexBuffer: m_buffGLTarget = GL_ELEMENT_ARRAY_BUFFER; break;
case kGLMUniformBuffer: m_buffGLTarget = GL_UNIFORM_BUFFER; break;
case kGLMPixelBuffer: m_buffGLTarget = GL_PIXEL_UNPACK_BUFFER; break;
default: Assert(!"Unknown buffer type" ); DXABSTRACT_BREAK_ON_ERROR();
}
@ -520,25 +520,25 @@ CGLMBuffer::CGLMBuffer( GLMContext *pCtx, EGLMBufferType type, uint size, uint o
}
else
{
gGL->glGenBuffersARB( 1, &m_nHandle );
gGL->glGenBuffers( 1, &m_nHandle );
m_pCtx->BindBufferToCtx( m_type, this ); // causes glBindBufferARB
// buffers start out static, but if they get orphaned and gl_bufmode is non zero,
// then they will get flipped to dynamic.
GLenum hint = GL_STATIC_DRAW_ARB;
GLenum hint = GL_STATIC_DRAW;
switch (m_type)
{
case kGLMVertexBuffer: hint = m_bDynamic ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB; break;
case kGLMIndexBuffer: hint = m_bDynamic ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB; break;
case kGLMUniformBuffer: hint = GL_DYNAMIC_DRAW_ARB; break;
case kGLMPixelBuffer: hint = m_bDynamic ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB; break;
case kGLMVertexBuffer: hint = m_bDynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW; break;
case kGLMIndexBuffer: hint = m_bDynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW; break;
case kGLMUniformBuffer: hint = GL_DYNAMIC_DRAW; break;
case kGLMPixelBuffer: hint = m_bDynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW; break;
default: Assert(!"Unknown buffer type" ); DXABSTRACT_BREAK_ON_ERROR();
}
gGL->glBufferDataARB( m_buffGLTarget, m_nSize, (const GLvoid*)NULL, hint ); // may ultimately need more hints to set the usage correctly (esp for streaming)
gGL->glBufferData( m_buffGLTarget, m_nSize, (const GLvoid*)NULL, hint ); // may ultimately need more hints to set the usage correctly (esp for streaming)
SetModes( false, true, true );
@ -566,7 +566,7 @@ CGLMBuffer::~CGLMBuffer( )
}
else
{
gGL->glDeleteBuffersARB( 1, &m_nHandle );
gGL->glDeleteBuffers( 1, &m_nHandle );
}
m_pCtx = NULL;
@ -591,11 +591,6 @@ void CGLMBuffer::SetModes( bool bAsyncMap, bool bExplicitFlush, bool bForce )
{
if ( bForce || ( m_bEnableAsyncMap != bAsyncMap ) )
{
// note the sense of the parameter, it's TRUE if you *want* serialization, so for async you turn it to false.
if ( ( gGL->m_bHave_GL_APPLE_flush_buffer_range ) && ( !gGL->m_bHave_GL_ARB_map_buffer_range ) )
{
gGL->glBufferParameteriAPPLE( m_buffGLTarget, GL_BUFFER_SERIALIZED_MODIFY_APPLE, bAsyncMap == false );
}
m_bEnableAsyncMap = bAsyncMap;
}
@ -603,10 +598,6 @@ void CGLMBuffer::SetModes( bool bAsyncMap, bool bExplicitFlush, bool bForce )
{
// Note that the GL_ARB_map_buffer_range path handles this in the glMapBufferRange() call in Lock().
// note the sense of the parameter, it's TRUE if you *want* auto-flush-on-unmap, so for explicit-flush, you turn it to false.
if ( ( gGL->m_bHave_GL_APPLE_flush_buffer_range ) && ( !gGL->m_bHave_GL_ARB_map_buffer_range ) )
{
gGL->glBufferParameteriAPPLE( m_buffGLTarget, GL_BUFFER_FLUSHING_UNMAP_APPLE, bExplicitFlush == false );
}
m_bEnableExplicitFlush = bExplicitFlush;
}
}
@ -634,16 +625,7 @@ void CGLMBuffer::FlushRange( uint offset, uint size )
double flStart = Plat_FloatTime();
#endif
// assumes buffer is bound.
if ( gGL->m_bHave_GL_ARB_map_buffer_range )
{
gGL->glFlushMappedBufferRange( m_buffGLTarget, (GLintptr)( offset - m_dirtyMinOffset ), (GLsizeiptr)size );
}
else if ( gGL->m_bHave_GL_APPLE_flush_buffer_range )
{
gGL->glFlushMappedBufferRangeAPPLE( m_buffGLTarget, (GLintptr)offset, (GLsizeiptr)size );
}
gGL->glFlushMappedBufferRange( m_buffGLTarget, (GLintptr)( offset - m_dirtyMinOffset ), (GLsizeiptr)size );
#ifdef REPORT_LOCK_TIME
double flEnd = Plat_FloatTime();
if ( flEnd - flStart > 5.0 / 1000.0 )
@ -792,26 +774,6 @@ void CGLMBuffer::Lock( GLMBuffLockParams *pParams, char **pAddressOut )
//DevMsg( " --> buff=%x, startOffset=%d, paramsOffset=%d, persistOffset = %d\n", this, m_nPersistentBufferStartOffset, pParams->m_nOffset, persistentBufferOffset );
}
#ifndef OSX
else if ( m_bDynamic && gGL->m_bHave_GL_AMD_pinned_memory && ( m_pCtx->GetCurPinnedMemoryBuffer()->GetBytesRemaining() >= pParams->m_nSize ) )
{
if ( pParams->m_bDiscard )
{
m_nRevision++;
}
m_dirtyMinOffset = pParams->m_nOffset;
m_dirtyMaxOffset = pParams->m_nOffset + pParams->m_nSize;
CPinnedMemoryBuffer *pTempBuffer = m_pCtx->GetCurPinnedMemoryBuffer();
m_nPinnedMemoryOfs = pTempBuffer->GetOfs();
resultPtr = static_cast<char*>( pTempBuffer->GetPtr() ) + m_nPinnedMemoryOfs;
pTempBuffer->Append( pParams->m_nSize );
}
#endif // OSX
else if ( !g_bDisableStaticBuffer && ( pParams->m_bDiscard || pParams->m_bNoOverwrite ) && ( pParams->m_nSize <= GL_STATIC_BUFFER_SIZE ) )
{
#if TOGL_SUPPORT_NULL_DEVICE
@ -824,8 +786,8 @@ void CGLMBuffer::Lock( GLMBuffLockParams *pParams, char **pAddressOut )
// observe gl_bufmode on any orphan event.
// if orphaned and bufmode is nonzero, flip it to dynamic.
GLenum hint = gl_bufmode.GetInt() ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB;
gGL->glBufferDataARB( m_buffGLTarget, m_nSize, (const GLvoid*)NULL, hint );
GLenum hint = gl_bufmode.GetInt() ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW;
gGL->glBufferData( m_buffGLTarget, m_nSize, (const GLvoid*)NULL, hint );
m_nRevision++; // revision grows on orphan event
}
@ -867,8 +829,8 @@ void CGLMBuffer::Lock( GLMBuffLockParams *pParams, char **pAddressOut )
// if orphaned and bufmode is nonzero, flip it to dynamic.
// We always want to call glBufferData( ..., NULL ) on discards, even though we're using the GL_MAP_INVALIDATE_BUFFER_BIT flag, because this flag is actually only a hint according to AMD.
GLenum hint = gl_bufmode.GetInt() ? GL_DYNAMIC_DRAW_ARB : GL_STATIC_DRAW_ARB;
gGL->glBufferDataARB( m_buffGLTarget, m_nSize, (const GLvoid*)NULL, hint );
GLenum hint = gl_bufmode.GetInt() ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW;
gGL->glBufferData( m_buffGLTarget, m_nSize, (const GLvoid*)NULL, hint );
m_nRevision++; // revision grows on orphan event
}
@ -878,64 +840,51 @@ void CGLMBuffer::Lock( GLMBuffLockParams *pParams, char **pAddressOut )
// map
char *mapPtr;
if ( gGL->m_bHave_GL_ARB_map_buffer_range )
{
// m_bEnableAsyncMap is actually pParams->m_bNoOverwrite
GLbitfield parms = GL_MAP_WRITE_BIT | ( m_bEnableAsyncMap ? GL_MAP_UNSYNCHRONIZED_BIT : 0 ) | ( pParams->m_bDiscard ? GL_MAP_INVALIDATE_BUFFER_BIT : 0 ) | ( m_bEnableExplicitFlush ? GL_MAP_FLUSH_EXPLICIT_BIT : 0 );
// m_bEnableAsyncMap is actually pParams->m_bNoOverwrite
GLbitfield parms = GL_MAP_WRITE_BIT | ( m_bEnableAsyncMap ? GL_MAP_UNSYNCHRONIZED_BIT : 0 ) | ( pParams->m_bDiscard ? GL_MAP_INVALIDATE_BUFFER_BIT : 0 ) | ( m_bEnableExplicitFlush ? GL_MAP_FLUSH_EXPLICIT_BIT : 0 );
#ifdef REPORT_LOCK_TIME
double flStart = Plat_FloatTime();
double flStart = Plat_FloatTime();
#endif
mapPtr = (char*)gGL->glMapBufferRange( m_buffGLTarget, pParams->m_nOffset, pParams->m_nSize, parms);
mapPtr = (char*)gGL->glMapBufferRange( m_buffGLTarget, pParams->m_nOffset, pParams->m_nSize, parms);
#ifdef REPORT_LOCK_TIME
double flEnd = Plat_FloatTime();
if ( flEnd - flStart > 5.0 / 1000.0 )
double flEnd = Plat_FloatTime();
if ( flEnd - flStart > 5.0 / 1000.0 )
{
int nDelta = ( int )( ( flEnd - flStart ) * 1000 );
if ( nDelta > 2 )
{
int nDelta = ( int )( ( flEnd - flStart ) * 1000 );
if ( nDelta > 2 )
{
Msg( "**** " );
}
Msg( "glMapBufferRange Time=%d: ( Name=%d BufSize=%d ) Target=%p Offset=%d LockSize=%d ", nDelta, m_nHandle, m_nSize, m_buffGLTarget, pParams->m_nOffset, pParams->m_nSize );
if ( parms & GL_MAP_WRITE_BIT )
{
Msg( "GL_MAP_WRITE_BIT ");
}
if ( parms & GL_MAP_UNSYNCHRONIZED_BIT )
{
Msg( "GL_MAP_UNSYNCHRONIZED_BIT ");
}
if ( parms & GL_MAP_INVALIDATE_BUFFER_BIT )
{
Msg( "GL_MAP_INVALIDATE_BUFFER_BIT ");
}
if ( parms & GL_MAP_INVALIDATE_RANGE_BIT )
{
Msg( "GL_MAP_INVALIDATE_RANGE_BIT ");
}
if ( parms & GL_MAP_FLUSH_EXPLICIT_BIT )
{
Msg( "GL_MAP_FLUSH_EXPLICIT_BIT ");
}
Msg( "\n" );
Msg( "**** " );
}
Msg( "glMapBufferRange Time=%d: ( Name=%d BufSize=%d ) Target=%p Offset=%d LockSize=%d ", nDelta, m_nHandle, m_nSize, m_buffGLTarget, pParams->m_nOffset, pParams->m_nSize );
if ( parms & GL_MAP_WRITE_BIT )
{
Msg( "GL_MAP_WRITE_BIT ");
}
if ( parms & GL_MAP_UNSYNCHRONIZED_BIT )
{
Msg( "GL_MAP_UNSYNCHRONIZED_BIT ");
}
if ( parms & GL_MAP_INVALIDATE_BUFFER_BIT )
{
Msg( "GL_MAP_INVALIDATE_BUFFER_BIT ");
}
if ( parms & GL_MAP_INVALIDATE_RANGE_BIT )
{
Msg( "GL_MAP_INVALIDATE_RANGE_BIT ");
}
if ( parms & GL_MAP_FLUSH_EXPLICIT_BIT )
{
Msg( "GL_MAP_FLUSH_EXPLICIT_BIT ");
}
Msg( "\n" );
}
#endif
}
else
{
mapPtr = (char*)gGL->glMapBufferARB( m_buffGLTarget, GL_WRITE_ONLY_ARB );
}
Assert( mapPtr );
// calculate offset location
resultPtr = mapPtr;
if ( !gGL->m_bHave_GL_ARB_map_buffer_range )
{
resultPtr += pParams->m_nOffset;
}
// set range
m_dirtyMinOffset = pParams->m_nOffset;
@ -1070,34 +1019,6 @@ void CGLMBuffer::Unlock( int nActualSize, const void *pActualData )
else if ( m_type == kGLMVertexBuffer )
g_nTotalVBLockBytes += nActualSize;
#endif
#ifndef OSX
if ( m_nPinnedMemoryOfs >= 0 )
{
#if TOGL_SUPPORT_NULL_DEVICE
if ( !g_bNullD3DDevice )
{
#endif
if ( nActualSize )
{
m_pCtx->BindBufferToCtx( m_type, this );
gGL->glCopyBufferSubData(
GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD,
m_buffGLTarget,
m_nPinnedMemoryOfs,
m_dirtyMinOffset,
nActualSize );
}
#if TOGL_SUPPORT_NULL_DEVICE
}
#endif
m_nPinnedMemoryOfs = -1;
}
else
#endif // !OSX
if ( m_bUsingPersistentBuffer )
{
if ( nActualSize )

View File

@ -26,7 +26,7 @@
//
//===============================================================================
#include "togl/rendermechanism.h"
#include "togles/rendermechanism.h"
// memdbgon -must- be the last include file in a .cpp file.
#include "tier0/memdbgon.h"
@ -36,7 +36,7 @@ CGLMFBO::CGLMFBO( GLMContext *ctx )
m_ctx = ctx;
m_ctx->CheckCurrent();
gGL->glGenFramebuffersEXT( 1, &m_name );
gGL->glGenFramebuffers( 1, &m_name );
memset( m_attach, 0, sizeof( m_attach ) );
}
@ -55,7 +55,7 @@ CGLMFBO::~CGLMFBO( )
}
}
gGL->glDeleteFramebuffersEXT( 1, &m_name );
gGL->glDeleteFramebuffers( 1, &m_name );
m_name = 0;
m_ctx = NULL;
@ -68,22 +68,22 @@ static GLenum EncodeAttachmentFBO( EGLMFBOAttachment index )
{
if (index < kAttDepth)
{
return GL_COLOR_ATTACHMENT0_EXT + (int) index;
return GL_COLOR_ATTACHMENT0 + (int) index;
}
else
{
switch( index )
{
case kAttDepth:
return GL_DEPTH_ATTACHMENT_EXT;
return GL_DEPTH_ATTACHMENT;
break;
case kAttStencil:
return GL_STENCIL_ATTACHMENT_EXT;
return GL_STENCIL_ATTACHMENT;
break;
case kAttDepthStencil:
return GL_DEPTH_STENCIL_ATTACHMENT_EXT;
return GL_DEPTH_STENCIL_ATTACHMENT;
break;
default:
@ -94,7 +94,7 @@ static GLenum EncodeAttachmentFBO( EGLMFBOAttachment index )
GLMStop(); // bad news
// shouldn't get here
return GL_COLOR_ATTACHMENT0_EXT;
return GL_COLOR_ATTACHMENT0;
}
void CGLMFBO::TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attachIndex, GLenum fboBindPoint )
@ -136,7 +136,7 @@ void CGLMFBO::TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attach
if (layout->m_key.m_texFlags & kGLMTexMultisampled)
{
// it is an MSAA tex
if (fboBindPoint == GL_READ_FRAMEBUFFER_EXT)
if (fboBindPoint == GL_READ_FRAMEBUFFER)
{
// I think you just want to read a resolved tex.
// But I will check that it is resolved first..
@ -148,34 +148,31 @@ void CGLMFBO::TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attach
useRBO = true;
}
}
if (useRBO)
{
// MSAA path - attach the RBO, not the texture, and mark the RBO dirty
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT)
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT)
{
// you have to attach it both places...
// http://www.opengl.org/wiki/GL_EXT_framebuffer_object
// bind the RBO to the GL_RENDERBUFFER_EXT target
gGL->glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, tex->m_rboName );
// attach the GL_RENDERBUFFER_EXT target to the depth and stencil attach points
gGL->glFramebufferRenderbufferEXT( fboBindPoint, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, tex->m_rboName);
gGL->glFramebufferRenderbufferEXT( fboBindPoint, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, tex->m_rboName);
// bind the RBO to the GL_RENDERBUFFER target
gGL->glBindRenderbuffer( GL_RENDERBUFFER, tex->m_rboName );
// attach the GL_RENDERBUFFER target to the depth and stencil attach points
gGL->glFramebufferRenderbuffer( fboBindPoint, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, tex->m_rboName);
gGL->glFramebufferRenderbuffer( fboBindPoint, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, tex->m_rboName);
// no need to leave the RBO hanging on
gGL->glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 );
gGL->glBindRenderbuffer( GL_RENDERBUFFER, 0 );
}
else
{
// color attachment (likely 0)
gGL->glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, tex->m_rboName );
gGL->glFramebufferRenderbufferEXT( fboBindPoint, attachIndexGL, GL_RENDERBUFFER_EXT, tex->m_rboName);
gGL->glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 );
gGL->glBindRenderbuffer( GL_RENDERBUFFER, tex->m_rboName );
gGL->glFramebufferRenderbuffer( fboBindPoint, attachIndexGL, GL_RENDERBUFFER, tex->m_rboName);
gGL->glBindRenderbuffer( GL_RENDERBUFFER, 0 );
}
tex->ForceRBODirty();
}
@ -183,26 +180,25 @@ void CGLMFBO::TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attach
{
// regular path - attaching a texture2d
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT)
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT)
{
// you have to attach it both places...
// http://www.opengl.org/wiki/GL_EXT_framebuffer_object
gGL->glFramebufferTexture2DEXT( fboBindPoint, GL_DEPTH_ATTACHMENT_EXT, target, tex->m_texName, params->m_mip );
gGL->glFramebufferTexture2DEXT( fboBindPoint, GL_STENCIL_ATTACHMENT_EXT, target, tex->m_texName, params->m_mip );
gGL->glFramebufferTexture2D( fboBindPoint, GL_DEPTH_ATTACHMENT, target, tex->m_texName, params->m_mip );
gGL->glFramebufferTexture2D( fboBindPoint, GL_STENCIL_ATTACHMENT, target, tex->m_texName, params->m_mip );
}
else
{
gGL->glFramebufferTexture2DEXT( fboBindPoint, attachIndexGL, target, tex->m_texName, params->m_mip );
gGL->glFramebufferTexture2D( fboBindPoint, attachIndexGL, target, tex->m_texName, params->m_mip );
}
}
}
break;
case GL_TEXTURE_3D:
{
gGL->glFramebufferTexture3DEXT( fboBindPoint, attachIndexGL, target, tex->m_texName, params->m_mip, params->m_zslice );
{
// gGL->glFramebufferTexture3DEXT( fboBindPoint, attachIndexGL, target, tex->m_texName, params->m_mip, params->m_zslice );
}
break;
@ -210,8 +206,8 @@ void CGLMFBO::TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attach
{
// adjust target to steer to the proper face of the cube map
target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + params->m_face;
gGL->glFramebufferTexture2DEXT( fboBindPoint, attachIndexGL, target, tex->m_texName, params->m_mip );
gGL->glFramebufferTexture2D( fboBindPoint, attachIndexGL, target, tex->m_texName, params->m_mip );
}
break;
}
@ -248,35 +244,35 @@ void CGLMFBO::TexDetach( EGLMFBOAttachment attachIndex, GLenum fboBindPoint )
// MSAA path - detach the RBO, not the texture
// (is this the right time to resolve? probably better to wait until someone tries to sample the texture)
gGL->glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 );
gGL->glBindRenderbuffer( GL_RENDERBUFFER, 0 );
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT)
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT)
{
// detach the GL_RENDERBUFFER_EXT target at depth and stencil attach points
gGL->glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
// detach the GL_RENDERBUFFER target at depth and stencil attach points
gGL->glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
gGL->glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
gGL->glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
}
else
{
// color attachment (likely 0)
gGL->glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, attachIndexGL, GL_RENDERBUFFER_EXT, 0);
gGL->glFramebufferRenderbuffer( GL_FRAMEBUFFER, attachIndexGL, GL_RENDERBUFFER, 0);
}
}
else
{
// plain tex detach
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT)
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT)
{
// you have to detach it both places...
// http://www.opengl.org/wiki/GL_EXT_framebuffer_object
gGL->glFramebufferTexture2DEXT( fboBindPoint, GL_DEPTH_ATTACHMENT_EXT, target, 0, 0 );
gGL->glFramebufferTexture2DEXT( fboBindPoint, GL_STENCIL_ATTACHMENT_EXT, target, 0, 0 );
gGL->glFramebufferTexture2D( fboBindPoint, GL_DEPTH_ATTACHMENT, target, 0, 0 );
gGL->glFramebufferTexture2D( fboBindPoint, GL_STENCIL_ATTACHMENT, target, 0, 0 );
}
else
{
gGL->glFramebufferTexture2DEXT( fboBindPoint, attachIndexGL, target, 0, 0 );
gGL->glFramebufferTexture2D( fboBindPoint, attachIndexGL, target, 0, 0 );
}
}
}
@ -284,13 +280,13 @@ void CGLMFBO::TexDetach( EGLMFBOAttachment attachIndex, GLenum fboBindPoint )
case GL_TEXTURE_3D:
{
gGL->glFramebufferTexture3DEXT( fboBindPoint, attachIndexGL, target, 0, 0, 0 );
// gGL->glFramebufferTexture3DEXT( fboBindPoint, attachIndexGL, target, 0, 0, 0 );
}
break;
case GL_TEXTURE_CUBE_MAP:
{
gGL->glFramebufferTexture2DEXT( fboBindPoint, attachIndexGL, target, 0, 0 );
gGL->glFramebufferTexture2D( fboBindPoint, attachIndexGL, target, 0, 0 );
}
break;
}
@ -315,7 +311,7 @@ void CGLMFBO::TexScrub( CGLMTex *tex )
if (m_attach[ attachIndex ].m_tex == tex)
{
// blammo
TexDetach( (EGLMFBOAttachment)attachIndex, GL_DRAW_FRAMEBUFFER_EXT );
TexDetach( (EGLMFBOAttachment)attachIndex, GL_DRAW_FRAMEBUFFER );
}
}
}
@ -332,7 +328,9 @@ bool CGLMFBO::IsReady( void )
m_ctx->BindFBOToCtx( this );
GLenum status;
status = gGL->glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
status = gGL->glCheckFramebufferStatus(GL_FRAMEBUFFER);
#if 0
switch(status)
{
case GL_FRAMEBUFFER_COMPLETE_EXT:
@ -351,5 +349,6 @@ bool CGLMFBO::IsReady( void )
/* programming error; will fail on all hardware */
break;
}
return result;
#endif
return true;
}

View File

@ -26,7 +26,7 @@
//
//===============================================================================
#include "togl/rendermechanism.h"
#include "togles/rendermechanism.h"
#include "filesystem.h"
#include "tier1/fmtstr.h"
@ -84,8 +84,8 @@ GLenum GLMProgTypeToGLSLEnum( EGLMProgramType type )
GLenum result = 0;
switch(type)
{
case kGLMVertexProgram: result = GL_VERTEX_SHADER_ARB; break;
case kGLMFragmentProgram: result = GL_FRAGMENT_SHADER_ARB; break;
case kGLMVertexProgram: result = GL_VERTEX_SHADER; break;
case kGLMFragmentProgram: result = GL_FRAGMENT_SHADER; break;
default: Assert( !"bad program type"); result = 0; break;
}
return result;
@ -116,16 +116,11 @@ CGLMProgram::CGLMProgram( GLMContext *ctx, EGLMProgramType type )
m_nNumUsedSamplers = GLM_SAMPLER_COUNT;
m_maxVertexAttrs = kGLMVertexAttributeIndexMax;
// create an ARB vp/fp program object name. No need to bind it yet.
GLMShaderDesc *arbDesc = &m_descs[ kGLMARB ];
Assert(gGL);
gGL->glGenProgramsARB( 1, &arbDesc->m_object.arb );
// create a GLSL shader object.
GLMShaderDesc *glslDesc = &m_descs[ kGLMGLSL ];
GLenum glslStage = GLMProgTypeToGLSLEnum( m_type );
glslDesc->m_object.glsl = gGL->glCreateShaderObjectARB( glslStage );;
glslDesc->m_object.glsl = gGL->glCreateShader( glslStage );;
m_shaderName[0] = '\0';
@ -144,15 +139,7 @@ CGLMProgram::CGLMProgram( GLMContext *ctx, EGLMProgramType type )
CGLMProgram::~CGLMProgram( )
{
m_ctx->CheckCurrent();
// if there is an arb program, delete it
GLMShaderDesc *arbDesc = &m_descs[ kGLMARB ];
if (arbDesc->m_object.arb)
{
gGL->glDeleteProgramsARB( 1, &arbDesc->m_object.arb );
arbDesc->m_object.arb = 0;
}
// if there is a GLSL shader, delete it
GLMShaderDesc *glslDesc = &m_descs[kGLMGLSL];
if (glslDesc->m_object.glsl)
@ -183,16 +170,6 @@ enum EShaderSection
kGLMARBFragment, kGLMARBFragmentDisabled,
kGLMGLSLVertex, kGLMGLSLVertexDisabled,
kGLMGLSLFragment, kGLMGLSLFragmentDisabled,
};
const char *g_shaderSectionMarkers[] = // match ordering of enum
{
"!!ARBvp", "-!!ARBvp", // enabled and disabled markers. so you can have multiple flavors in a blob and activate the one you want.
"!!ARBfp", "-!!ARBfp",
"//GLSLvp", "-//GLSLvp",
"//GLSLfp", "-//GLSLfp",
NULL
};
void CGLMProgram::SetShaderName( const char *name )
@ -255,7 +232,7 @@ void CGLMProgram::SetProgramText( char *text )
}
#endif
#if 0
// scan the text and find sections
CGLMTextSectioner sections( m_text, strlen( m_text ), g_shaderSectionMarkers );
@ -267,61 +244,23 @@ void CGLMProgram::SetProgramText( char *text )
int markerIndex = 0;
sections.GetSection( i, &subtextOffset, &subtextLength, &markerIndex );
#endif
uint subtextOffset = 0;
uint subtextLength = strlen( m_text );
int markerIndex = 0;
// act on the section
GLMShaderDesc *desc = NULL;
switch( m_type )
{
case kGLMVertexProgram:
switch( markerIndex )
{
case kGLMARBVertex:
case kGLMGLSLVertex:
desc = &m_descs[ (markerIndex==kGLMARBVertex) ? kGLMARB : kGLMGLSL];
// these steps are generic across both langs
desc->m_textPresent = true;
desc->m_textOffset = subtextOffset;
desc->m_textLength = subtextLength;
desc->m_compiled = false;
desc->m_valid = false;
break;
case kGLMARBVertexDisabled:
case kGLMGLSLVertexDisabled:
// ignore quietly
break;
default: Assert(!"Mismatched section marker seen in SetProgramText (VP)"); break;
}
break;
case kGLMFragmentProgram:
switch( markerIndex )
{
case kGLMARBFragment:
case kGLMGLSLFragment:
desc = &m_descs[ (markerIndex==kGLMARBFragment) ? kGLMARB : kGLMGLSL];
// these steps are generic across both langs
desc->m_textPresent = true;
desc->m_textOffset = subtextOffset;
desc->m_textLength = subtextLength;
desc->m_compiled = false;
desc->m_valid = false;
break;
case kGLMARBFragmentDisabled:
case kGLMGLSLFragmentDisabled:
// ignore quietly
break;
default: Assert(!"Mismatched section marker seen in SetProgramText (VP)"); break;
}
break;
}
}
// act on the section
GLMShaderDesc *desc = NULL;
desc = &m_descs[kGLMGLSL];
// these steps are generic across both langs
desc->m_textPresent = true;
desc->m_textOffset = subtextOffset;
desc->m_textLength = subtextLength;
desc->m_compiled = false;
desc->m_valid = false;
// find the label string
// example:
// trans#2871 label:vs-file vertexlit_and_unlit_generic_vs20 vs-index 294912 vs-combo 1234
@ -369,53 +308,6 @@ void CGLMProgram::Compile( EGLMProgramLang lang )
switch( lang )
{
case kGLMARB:
{
GLMShaderDesc *arbDesc;
arbDesc = &m_descs[ kGLMARB ];
// make sure no GLSL program is set up
gGL->glUseProgram(0);
// bind our program container to context
GLenum arbTarget = GLMProgTypeToARBEnum( m_type );
glSetEnable( arbTarget, true ); // unclear if I need this to compile or just to draw...
gGL->glBindProgramARB( arbTarget, arbDesc->m_object.arb ); // object created or just re-bound
char *section = m_text + arbDesc->m_textOffset;
char *lastCharOfSection = section + arbDesc->m_textLength; // actually it's one past the last textual character
lastCharOfSection;
#if GLMDEBUG
if(noisy)
{
GLMPRINTF((">-D- CGLMProgram::Compile submitting following text for ARB %s program (name %d) ---------------------",
arbTarget == GL_FRAGMENT_PROGRAM_ARB ? "fragment" : "vertex",
arbDesc->m_object.arb ));
// we don't have a "print this many chars" call yet
// just temporarily null terminate the text we want to print
char saveChar = *lastCharOfSection;
*lastCharOfSection= 0;
GLMPRINTTEXT(( section, eDebugDump ));
*lastCharOfSection= saveChar;
GLMPRINTF(("<-D- CGLMProgram::Compile ARB EOT--" ));
}
#endif
gGL->glProgramStringARB( arbTarget, GL_PROGRAM_FORMAT_ASCII_ARB, arbDesc->m_textLength, section );
arbDesc->m_compiled = true; // compiled but not necessarily valid
CheckValidity( lang );
// leave it bound n enabled, don't care (draw will sort it all out)
}
break;
case kGLMGLSL:
{
GLMShaderDesc *glslDesc;
@ -425,13 +317,6 @@ void CGLMProgram::Compile( EGLMProgramLang lang )
GLenum glslStage = GLMProgTypeToGLSLEnum( m_type );
glslStage;
// there's no binding to do for GLSL. but make sure no ARB stuff is bound for tidiness.
glSetEnable( GL_VERTEX_PROGRAM_ARB, false );
glSetEnable( GL_FRAGMENT_PROGRAM_ARB, false ); // add check errors on these
gGL->glBindProgramARB( GL_VERTEX_PROGRAM_ARB, 0 );
gGL->glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, 0 );
// no GLSL program either
gGL->glUseProgram(0);
@ -445,7 +330,7 @@ void CGLMProgram::Compile( EGLMProgramLang lang )
if(noisy)
{
GLMPRINTF((">-D- CGLMProgram::Compile submitting following text for GLSL %s program (name %d) ---------------------",
glslStage == GL_FRAGMENT_SHADER_ARB ? "fragment" : "vertex",
glslStage == GL_FRAGMENT_SHADER ? "fragment" : "vertex",
glslDesc->m_object.glsl ));
// we don't have a "print this many chars" call yet
@ -461,9 +346,27 @@ void CGLMProgram::Compile( EGLMProgramLang lang )
}
#endif
gGL->glShaderSourceARB( glslDesc->m_object.glsl, 1, (const GLchar **)&section, &glslDesc->m_textLength);
gGL->glShaderSource( glslDesc->m_object.glsl, 1, (const GLchar **)&section, &glslDesc->m_textLength);
#if GLM_FREE_SHADER_TEXT
// compile
gGL->glCompileShader( glslDesc->m_object.glsl );
GLint isCompiled = 0;
gGL->glGetShaderiv(glslDesc->m_object.glsl, GL_COMPILE_STATUS, &isCompiled);
if(isCompiled == GL_FALSE)
{
GLint maxLength = 0;
gGL->glGetShaderiv(glslDesc->m_object.glsl , GL_INFO_LOG_LENGTH, &maxLength);
GLchar log[4096];
gGL->glGetShaderInfoLog( glslDesc->m_object.glsl, sizeof(log), &maxLength, log );
printf("shader compile log: %s\n", log);
printf("Shader %d source is:\n===============\n%s\nn===============\n", glslDesc->m_object.glsl, section);
}
#if 0 //GLM_FREE_SHADER_TEXT
// Free the shader program text - not needed anymore (GL has its own copy)
if ( m_text && !m_descs[kGLMARB].m_textPresent )
{
@ -472,8 +375,6 @@ void CGLMProgram::Compile( EGLMProgramLang lang )
}
#endif
// compile
gGL->glCompileShaderARB( glslDesc->m_object.glsl );
glslDesc->m_compiled = true; // compiled but not necessarily valid
// Check shader validity at creation time. This will cause the driver to not be able to
@ -621,7 +522,7 @@ struct GLMShaderLimitDesc
// macro to help make the table of what to check
#ifndef LMD
#define LMD( val, flags ) { GL_PROGRAM_##val##_ARB, GL_MAX_PROGRAM_##val##_ARB, #val, flags }
#define LMD( val, flags ) { GL_PROGRAM_##val, GL_MAX_PROGRAM_##val, #val, flags }
#else
#error you need to use a different name for this macro.
#endif
@ -629,25 +530,25 @@ struct GLMShaderLimitDesc
GLMShaderLimitDesc g_glmShaderLimitDescs[] =
{
// VP and FP..
LMD( INSTRUCTIONS, 3 ),
LMD( NATIVE_INSTRUCTIONS, 3 ),
LMD( NATIVE_TEMPORARIES, 3 ),
LMD( PARAMETERS, 3 ),
LMD( NATIVE_PARAMETERS, 3 ),
LMD( ATTRIBS, 3 ),
LMD( NATIVE_ATTRIBS, 3 ),
// LMD( INSTRUCTIONS, 3 ),
// LMD( NATIVE_INSTRUCTIONS, 3 ),
// LMD( NATIVE_TEMPORARIES, 3 ),
// LMD( PARAMETERS, 3 ),
// LMD( NATIVE_PARAMETERS, 3 ),
// LMD( ATTRIBS, 3 ),
// LMD( NATIVE_ATTRIBS, 3 ),
// VP only..
LMD( ADDRESS_REGISTERS, 1 ),
LMD( NATIVE_ADDRESS_REGISTERS, 1 ),
// LMD( ADDRESS_REGISTERS, 1 ),
// LMD( NATIVE_ADDRESS_REGISTERS, 1 ),
// FP only..
LMD( ALU_INSTRUCTIONS, 2 ),
LMD( NATIVE_ALU_INSTRUCTIONS, 2 ),
LMD( TEX_INSTRUCTIONS, 2 ),
LMD( NATIVE_TEX_INSTRUCTIONS, 2 ),
LMD( TEX_INDIRECTIONS, 2 ),
LMD( NATIVE_TEX_INDIRECTIONS, 2 ),
// LMD( ALU_INSTRUCTIONS, 2 ),
// LMD( NATIVE_ALU_INSTRUCTIONS, 2 ),
// LMD( TEX_INSTRUCTIONS, 2 ),
// LMD( NATIVE_TEX_INSTRUCTIONS, 2 ),
// LMD( TEX_INDIRECTIONS, 2 ),
// LMD( NATIVE_TEX_INDIRECTIONS, 2 ),
{ 0, 0, NULL, 0 }
};
@ -668,128 +569,34 @@ bool CGLMProgram::CheckValidity( EGLMProgramLang lang )
bool bValid = false;
//#error "What the fuck?"
switch(lang)
{
case kGLMARB:
{
GLMShaderDesc *arbDesc;
arbDesc = &m_descs[ kGLMARB ];
GLenum arbTarget = GLMProgTypeToARBEnum( m_type );
Assert( arbDesc->m_compiled );
arbDesc->m_valid = true; // assume success til we see otherwise
// assume program is bound. is there anything wrong with it ?
GLint isNative=0;
gGL->glGetProgramivARB( arbTarget, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &isNative );
// If the program is over the hardware's limits, print out some information
if (isNative!=1)
{
arbDesc->m_valid = false;
// check everything we can check
char checkmask = (1<<m_type); // 1 for VP, 2 for FP
for( GLMShaderLimitDesc *desc = g_glmShaderLimitDescs; desc->m_valueEnum !=0; desc++ )
{
if ( desc->m_flags & checkmask )
{
// test it
GLint value = 0;
GLint limit = 0;
gGL->glGetProgramivARB(arbTarget, desc->m_valueEnum, &value);
gGL->glGetProgramivARB(arbTarget, desc->m_limitEnum, &limit);
if (value > limit)
{
GLMPRINTF(("-D- Invalid %s program: program has %d %s; limit is %d", targnames[ m_type ], value, desc->m_debugName, limit ));
}
}
}
}
// syntax error check
GLint errorLine;
gGL->glGetIntegerv( GL_PROGRAM_ERROR_POSITION_ARB, &errorLine );
if ( errorLine!=-1 )
{
const GLubyte* errorString = gGL->glGetString(GL_PROGRAM_ERROR_STRING_ARB); errorString;
GLMPRINTF(( "-D- Syntax error in ARB %s program: %s",targnames[ m_type ], errorString ));
arbDesc->m_valid = false;
}
if (!arbDesc->m_valid)
{
char *temp = strdup(m_text);
temp[ arbDesc->m_textOffset + arbDesc->m_textLength ] = 0;
GLMPRINTF(("-D- ----- ARB compile failed; bad source follows -----" ));
GLMPRINTTEXT(( temp + arbDesc->m_textOffset, eDebugDump, GLMPRINTTEXT_NUMBEREDLINES ));
GLMPRINTF(("-D- -----end-----" ));
free( temp );
}
bValid = arbDesc->m_valid;
}
break;
case kGLMGLSL:
{
GLMShaderDesc *glslDesc;
GLcharARB *logString = NULL;
glslDesc = &m_descs[ kGLMGLSL ];
GLenum glslStage = GLMProgTypeToGLSLEnum( m_type ); glslStage;
Assert( glslDesc->m_compiled );
glslDesc->m_valid = true; // assume success til we see otherwise
// GLSL error check
int compiled = 0, length = 0, laux = 0;
int compiled = 0;
gGL->glGetObjectParameterivARB( (GLhandleARB)glslDesc->m_object.glsl, GL_OBJECT_COMPILE_STATUS_ARB, &compiled);
gGL->glGetObjectParameterivARB( (GLhandleARB)glslDesc->m_object.glsl, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
if ( length > 0 )
{
logString = (GLcharARB *)malloc(length * sizeof(GLcharARB));
gGL->glGetInfoLogARB((GLhandleARB)glslDesc->m_object.glsl, length, &laux, logString);
}
// we may not be able to check "native limits" stuff until link time. meh
gGL->glGetShaderiv(glslDesc->m_object.glsl, GL_COMPILE_STATUS, &compiled);
if (!compiled)
{
glslDesc->m_valid = false;
}
if (!glslDesc->m_valid)
{
GLMPRINTF(("-D- ----- GLSL compile failed: \n %s \n",logString ));
#if !GLM_FREE_SHADER_TEXT
char *temp = strdup(m_text);
temp[ glslDesc->m_textOffset + glslDesc->m_textLength ] = 0;
GLMPRINTTEXT(( temp + glslDesc->m_textOffset, eDebugDump, GLMPRINTTEXT_NUMBEREDLINES ));
free( temp );
#endif
GLMPRINTF(("-D- -----end-----" ));
}
if ( logString )
free( logString );
bValid = glslDesc->m_valid;
}
break;
}
if ( !bValid )
{
GLMDebugPrintf( "Compile of \"%s\" Failed:\n%s\n", m_shaderName, m_text ? m_text : "" );
}
AssertOnce( bValid );
if (bTimeShaderCompiles)
@ -884,7 +691,7 @@ CGLMShaderPair::CGLMShaderPair( GLMContext *ctx )
m_ctx = ctx;
m_vertexProg = m_fragmentProg = NULL;
m_program = gGL->glCreateProgramObjectARB();
m_program = gGL->glCreateProgram();
m_locVertexParams = -1;
m_locVertexBoneParams = -1;
@ -911,7 +718,7 @@ CGLMShaderPair::~CGLMShaderPair( )
{
if (m_program)
{
gGL->glDeleteObjectARB( (GLhandleARB)m_program );
gGL->glDeleteObject( m_program );
m_program = 0;
}
}
@ -938,8 +745,8 @@ bool CGLMShaderPair::ValidateProgramPair()
}
// check for success
GLint result = 0;
gGL->glGetObjectParameterivARB( m_program, GL_OBJECT_LINK_STATUS_ARB, &result ); // want GL_TRUE
GLint result = GL_TRUE;
gGL->glGetObjectParameteriv( m_program, GL_OBJECT_LINK_STATUS_ARB, &result ); // want GL_TRUE
m_bCheckLinkStatus = false;
if (result == GL_TRUE)
@ -955,10 +762,10 @@ bool CGLMShaderPair::ValidateProgramPair()
GLint laux = 0;
// do some digging
gGL->glGetObjectParameterivARB( m_program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length );
gGL->glGetObjectParameteriv( m_program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length );
GLcharARB *logString = (GLcharARB *)malloc( length * sizeof(GLcharARB) );
gGL->glGetInfoLogARB( m_program, length, &laux, logString );
GLchar *logString = (GLchar *)malloc( length * sizeof(GLchar) );
gGL->glGetInfoLog( m_program, length, &laux, logString );
GLMPRINTF( ("-D- ----- GLSL link failed: \n %s ", logString) );
#if !GLM_FREE_SHADER_TEXT
@ -988,12 +795,12 @@ bool CGLMShaderPair::ValidateProgramPair()
m_ctx->NewLinkedProgram();
m_locVertexParams = gGL->glGetUniformLocationARB( m_program, "vc" );
m_locVertexBoneParams = gGL->glGetUniformLocationARB( m_program, "vcbones" );
m_locVertexScreenParams = gGL->glGetUniformLocationARB( m_program, "vcscreen" );
m_locVertexParams = gGL->glGetUniformLocation( m_program, "vc" );
m_locVertexBoneParams = gGL->glGetUniformLocation( m_program, "vcbones" );
m_locVertexScreenParams = gGL->glGetUniformLocation( m_program, "vcscreen" );
m_nScreenWidthHeight = 0xFFFFFFFF;
m_locVertexInteger0 = gGL->glGetUniformLocationARB( m_program, "i0" );
m_locVertexInteger0 = gGL->glGetUniformLocation( m_program, "i0" );
m_bHasBoolOrIntUniforms = false;
if (m_locVertexInteger0 >= 0)
@ -1003,7 +810,7 @@ bool CGLMShaderPair::ValidateProgramPair()
{
char buf[256];
V_snprintf( buf, sizeof(buf), "b%d", i );
m_locVertexBool[i] = gGL->glGetUniformLocationARB( m_program, buf );
m_locVertexBool[i] = gGL->glGetUniformLocation( m_program, buf );
if (m_locVertexBool[i] != -1)
m_bHasBoolOrIntUniforms = true;
}
@ -1012,12 +819,12 @@ bool CGLMShaderPair::ValidateProgramPair()
{
char buf[256];
V_snprintf( buf, sizeof(buf), "fb%d", i );
m_locFragmentBool[i] = gGL->glGetUniformLocationARB( m_program, buf );
m_locFragmentBool[i] = gGL->glGetUniformLocation( m_program, buf );
if (m_locFragmentBool[i] != -1)
m_bHasBoolOrIntUniforms = true;
}
m_locFragmentParams = gGL->glGetUniformLocationARB( m_program, "pc" );
m_locFragmentParams = gGL->glGetUniformLocation( m_program, "pc" );
for (uint i = 0; i < kGLMNumProgramTypes; i++)
{
@ -1039,7 +846,7 @@ bool CGLMShaderPair::ValidateProgramPair()
char buf[256];
V_snprintf( buf, sizeof(buf), "%cc[%i]", "vp"[i], j );
// Grab the handle of each array element, so we can more efficiently update array elements in the middle.
int l = m_UniformBufferParams[i][j] = gGL->glGetUniformLocationARB( m_program, buf );
int l = m_UniformBufferParams[i][j] = gGL->glGetUniformLocation( m_program, buf );
if (l < 0)
break;
}
@ -1047,7 +854,7 @@ bool CGLMShaderPair::ValidateProgramPair()
m_NumUniformBufferParams[i] = j;
}
m_locFragmentFakeSRGBEnable = gGL->glGetUniformLocationARB( m_program, "flSRGBWrite" );
m_locFragmentFakeSRGBEnable = gGL->glGetUniformLocation( m_program, "flSRGBWrite" );
m_fakeSRGBEnableValue = -1.0f;
for (int sampler = 0; sampler < 16; sampler++)
@ -1055,11 +862,11 @@ bool CGLMShaderPair::ValidateProgramPair()
char tmp[16];
sprintf( tmp, "sampler%d", sampler ); // sampler0 .. sampler1.. etc
GLint nLoc = gGL->glGetUniformLocationARB( m_program, tmp );
GLint nLoc = gGL->glGetUniformLocation( m_program, tmp );
m_locSamplers[sampler] = nLoc;
if (nLoc >= 0)
{
gGL->glUniform1iARB( nLoc, sampler );
gGL->glUniform1i( nLoc, sampler );
}
}
}
@ -1133,22 +940,22 @@ bool CGLMShaderPair::SetProgramPair( CGLMProgram *vp, CGLMProgram *fp )
// attempt link. but first, detach any previously attached programs
if (m_vertexProg)
{
gGL->glDetachObjectARB(m_program, m_vertexProg->m_descs[kGLMGLSL].m_object.glsl);
gGL->glDetachObject(m_program, m_vertexProg->m_descs[kGLMGLSL].m_object.glsl);
m_vertexProg = NULL;
}
if (m_fragmentProg)
{
gGL->glDetachObjectARB(m_program, m_fragmentProg->m_descs[kGLMGLSL].m_object.glsl);
gGL->glDetachObject(m_program, m_fragmentProg->m_descs[kGLMGLSL].m_object.glsl);
m_fragmentProg = NULL;
}
// now attach
gGL->glAttachObjectARB( m_program, vp->m_descs[kGLMGLSL].m_object.glsl );
gGL->glAttachShader( m_program, vp->m_descs[kGLMGLSL].m_object.glsl );
m_vertexProg = vp;
gGL->glAttachObjectARB( m_program, fp->m_descs[kGLMGLSL].m_object.glsl );
gGL->glAttachShader( m_program, fp->m_descs[kGLMGLSL].m_object.glsl );
m_fragmentProg = fp;
// force the locations for input attributes v0-vN to be at locations 0-N
@ -1160,7 +967,7 @@ bool CGLMShaderPair::SetProgramPair( CGLMProgram *vp, CGLMProgram *fp )
char tmp[16];
sprintf(tmp, "v%d", i); // v0 v1 v2 ... et al
gGL->glBindAttribLocationARB( m_program, i, tmp );
gGL->glBindAttribLocation( m_program, i, tmp );
}
#if !GLM_FREE_SHADER_TEXT
if (CommandLine()->CheckParm("-dumpallshaders"))
@ -1175,9 +982,26 @@ bool CGLMShaderPair::SetProgramPair( CGLMProgram *vp, CGLMProgram *fp )
}
}
#endif
// now link
gGL->glLinkProgramARB( m_program );
gGL->glLinkProgram( m_program );
GLint isLinked = 0;
gGL->glGetShaderiv(m_program, GL_LINK_STATUS, &isLinked);
if(isLinked == GL_FALSE)
{
GLint maxLength = 0;
gGL->glGetShaderiv(m_program, GL_INFO_LOG_LENGTH, &maxLength);
GLchar log[4096];
gGL->glGetProgramInfoLog( m_program, sizeof(log), &maxLength, log );
if( maxLength )
{
printf("vp: \n%s\nfp: \n%s\n", vp->m_text, fp->m_text );
printf("shader %d link log: %s\n", m_program, log);
}
}
m_bCheckLinkStatus = true;
}
else

View File

@ -26,7 +26,7 @@
//
//===============================================================================
#include "togl/rendermechanism.h"
#include "togles/rendermechanism.h"
#ifndef _WIN32
#include <unistd.h>
@ -77,7 +77,7 @@ CGLMQuery::CGLMQuery( GLMContext *ctx, GLMQueryParams *params )
case EOcclusion:
{
//make an occlusion query (and a fence to go with it)
gGL->glGenQueriesARB( 1, &m_name );
gGL->glGenQueries( 1, &m_name );
s_nTotalOcclusionQueryCreatesOrDeletes++;
GLMPRINTF(("-A- CGLMQuery(OQ) created name %d", m_name));
}
@ -114,7 +114,7 @@ CGLMQuery::~CGLMQuery()
{
// do a finish occlusion query ?
GLMPRINTF(("-A- ~CGLMQuery(OQ) deleting name %d", m_name));
gGL->glDeleteQueriesARB(1, &m_name );
gGL->glDeleteQueries(1, &m_name );
s_nTotalOcclusionQueryCreatesOrDeletes++;
}
break;
@ -163,7 +163,7 @@ void CGLMQuery::Start( void ) // "start counting"
}
else
{
gGL->glBeginQueryARB( GL_SAMPLES_PASSED_ARB, m_name );
gGL->glBeginQuery( GL_SAMPLES_PASSED, m_name );
}
}
break;
@ -204,7 +204,7 @@ void CGLMQuery::Stop( void ) // "stop counting"
}
else
{
gGL->glEndQueryARB( GL_SAMPLES_PASSED_ARB ); // we are only putting the request-to-stop-counting into the cmd stream.
gGL->glEndQuery( GL_SAMPLES_PASSED ); // we are only putting the request-to-stop-counting into the cmd stream.
}
}
break;
@ -240,7 +240,7 @@ bool CGLMQuery::IsDone( void )
// prepare to pay a big price on drivers prior to 10.6.4+SLGU
GLint available = 0;
gGL->glGetQueryObjectivARB(m_name, GL_QUERY_RESULT_AVAILABLE_ARB, &available );
gGL->glGetQueryObjectiv(m_name, GL_QUERY_RESULT_AVAILABLE, &available );
m_done = (available != 0);
}
@ -301,7 +301,7 @@ void CGLMQuery::Complete( uint *result )
}
else
{
gGL->glGetQueryObjectuivARB( m_name, GL_QUERY_RESULT_ARB, &resultval);
gGL->glGetQueryObjectuiv( m_name, GL_QUERY_RESULT, &resultval);
m_done = true;
}
}

View File

@ -26,7 +26,7 @@
//
//===============================================================================
#include "togl/rendermechanism.h"
#include "togles/rendermechanism.h"
#include "tier0/icommandline.h"
#include "glmtexinlines.h"
@ -777,11 +777,11 @@ CGLMTex::CGLMTex( GLMContext *ctx, GLMTexLayout *layout, uint levels, const char
// if tex is MSAA renderable, make an RBO, else zero the RBO name and dirty bit
if (layout->m_key.m_texFlags & kGLMTexMultisampled)
{
gGL->glGenRenderbuffersEXT( 1, &m_rboName );
gGL->glGenRenderbuffers( 1, &m_rboName );
// so we have enough info to go ahead and bind the RBO and put storage on it?
// try it.
gGL->glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_rboName );
gGL->glBindRenderbuffer( GL_RENDERBUFFER, m_rboName );
// quietly clamp if sample count exceeds known limit for the device
int sampleCount = layout->m_key.m_texSamples;
@ -792,7 +792,7 @@ CGLMTex::CGLMTex( GLMContext *ctx, GLMTexLayout *layout, uint levels, const char
}
GLenum msaaFormat = (layout->m_key.m_texFlags & kGLMTexSRGB) ? layout->m_format->m_glIntFormatSRGB : layout->m_format->m_glIntFormat;
gGL->glRenderbufferStorageMultisampleEXT( GL_RENDERBUFFER_EXT,
gGL->glRenderbufferStorageMultisample( GL_RENDERBUFFER,
sampleCount, // not "layout->m_key.m_texSamples"
msaaFormat,
layout->m_key.m_xSize,
@ -803,7 +803,7 @@ CGLMTex::CGLMTex( GLMContext *ctx, GLMTexLayout *layout, uint levels, const char
printf( "\n == MSAA Tex %p %s : MSAA RBO is intformat %s (%x)", this, m_debugLabel?m_debugLabel:"", GLMDecode( eGL_ENUM, msaaFormat ), msaaFormat );
}
gGL->glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 );
gGL->glBindRenderbuffer( GL_RENDERBUFFER, 0 );
}
else
{
@ -1013,7 +1013,7 @@ CGLMTex::~CGLMTex( )
if ( m_rboName )
{
gGL->glDeleteRenderbuffersEXT( 1, &m_rboName );
gGL->glDeleteRenderbuffers( 1, &m_rboName );
m_rboName = 0;
}
@ -1120,7 +1120,7 @@ void CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice )
{
readBox = desc->m_req.m_region;
}
CGLMTex *pPrevTex = m_ctx->m_samplers[0].m_pBoundTex;
m_ctx->BindTexToTMU( this, 0 ); // SelectTMU(n) is a side effect
@ -1135,9 +1135,10 @@ void CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice )
void *sliceAddress = m_backing + m_layout->m_slices[ desc->m_sliceIndex ].m_storageOffset; // this would change for PBO
//int sliceSize = m_layout->m_slices[ desc->m_sliceIndex ].m_storageSize;
// interestingly enough, we can use the same path for both 2D and 3D fetch
switch( target )
{
case GL_TEXTURE_CUBE_MAP:
@ -1153,7 +1154,7 @@ void CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice )
{
// compressed path
// http://www.opengl.org/sdk/docs/man/xhtml/glGetCompressedTexImage.xml
gGL->glGetCompressedTexImage( target, // target
desc->m_req.m_mip, // level
sliceAddress ); // destination
@ -1162,15 +1163,50 @@ void CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice )
{
// uncompressed path
// http://www.opengl.org/sdk/docs/man/xhtml/glGetTexImage.xml
GLuint fbo;
GLint Rfbo = 0, Dfbo = 0;
gGL->glGetIntegerv( GL_DRAW_FRAMEBUFFER_BINDING, &Dfbo );
gGL->glGetIntegerv( GL_READ_FRAMEBUFFER_BINDING, &Rfbo );
/*
gl4es_glGenFramebuffers(1, &fbo);
gl4es_glBindFramebuffer(GL_FRAMEBUFFER_OES, fbo);
gl4es_glFramebufferTexture2D(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_TEXTURE_2D, oldBind, 0);
// Read the pixels!
gl4es_glReadPixels(0, nheight-height, width, height, format, type, img); // using "full" version with conversion of format/type
gl4es_glBindFramebuffer(GL_FRAMEBUFFER_OES, old_fbo);
gl4es_glDeleteFramebuffers(1, &fbo);
*/
gGL->glGenFramebuffers(1, &fbo);
gGL->glBindFramebuffer(GL_FRAMEBUFFER, fbo);
gGL->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_ctx->m_samplers[0].m_pBoundTex->m_texName, 0);
uint fmt = format->m_glDataFormat;
if( fmt == GL_BGR )
fmt = GL_RGB;
else if( fmt == GL_BGRA )
fmt = GL_RGBA;
gGL->glReadPixels(0, 0, m_layout->m_slices[ desc->m_sliceIndex ].m_xSize, m_layout->m_slices[ desc->m_sliceIndex ].m_ySize, fmt , format->m_glDataType == GL_UNSIGNED_INT_8_8_8_8_REV ? GL_UNSIGNED_BYTE : format->m_glDataType, sliceAddress);
gGL->glBindFramebuffer(GL_READ_FRAMEBUFFER, Rfbo);
gGL->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, Dfbo);
gGL->glDeleteFramebuffers(1, &fbo);
#if 0
gGL->glGetTexImage( target, // target
desc->m_req.m_mip, // level
format->m_glDataFormat, // dataformat
format->m_glDataType, // datatype
sliceAddress ); // destination
#endif
}
}
break;
break;
}
}
else
@ -1238,10 +1274,10 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
// allow use of subimage if the target is texture2D and it has already been teximage'd
bool mayUseSubImage = false;
if ( (target==GL_TEXTURE_2D) && (m_sliceFlags[ desc->m_sliceIndex ] & kSliceValid) )
{
mayUseSubImage = gl_enabletexsubimage.GetInt() != 0;
}
//if ( (target==GL_TEXTURE_2D) && (m_sliceFlags[ desc->m_sliceIndex ] & kSliceValid) )
//{
// mayUseSubImage = gl_enabletexsubimage.GetInt() != 0;
//}
// check flavor, 2D, 3D, or cube map
// we also have the choice to use subimage if this is a tex already created. (open question as to benefit)
@ -1262,7 +1298,7 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
if (m_layout->m_key.m_texFlags & kGLMTexSRGB)
{
Assert( m_layout->m_format->m_glDataFormat != GL_DEPTH_COMPONENT );
Assert( m_layout->m_format->m_glDataFormat != GL_DEPTH_STENCIL_EXT );
Assert( m_layout->m_format->m_glDataFormat != GL_DEPTH_STENCIL );
Assert( m_layout->m_format->m_glDataFormat != GL_ALPHA );
}
@ -1366,14 +1402,14 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
gGL->glPixelStorei( GL_UNPACK_SKIP_PIXELS, writeBox.xmin ); // in pixels
gGL->glPixelStorei( GL_UNPACK_SKIP_ROWS, writeBox.ymin ); // in pixels
gGL->glTexSubImage2D( target,
gGL->glTexSubImage2D( glDataFormat,
desc->m_req.m_mip, // level
writeBox.xmin, // xoffset into dest
writeBox.ymin, // yoffset into dest
writeBox.xmax - writeBox.xmin, // width (was slice->m_xSize)
writeBox.ymax - writeBox.ymin, // height (was slice->m_ySize)
glDataFormat, // format
glDataType, // type
glDataType == GL_UNSIGNED_INT_8_8_8_8_REV ? GL_UNSIGNED_BYTE : glDataType, // type
sliceAddress // data (will be offsetted by the SKIP_PIXELS and SKIP_ROWS - let GL do the math to find the first source texel)
);
@ -1413,12 +1449,12 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
// http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/teximage2d.html
gGL->glTexImage2D( target, // target
desc->m_req.m_mip, // level
intformat, // internalformat - don't use format->m_glIntFormat because we have the SRGB select going on above
glDataFormat, // internalformat - don't use format->m_glIntFormat because we have the SRGB select going on above
slice->m_xSize, // width
slice->m_ySize, // height
0, // border
glDataFormat, // dataformat
glDataType, // datatype
glDataType == GL_UNSIGNED_INT_8_8_8_8_REV ? GL_UNSIGNED_BYTE : glDataType, // datatype
noDataWrite ? NULL : sliceAddress ); // data (optionally suppressed in case ResetSRGB desires)
if (m_layout->m_key.m_texFlags & kGLMTexMultisampled)

View File

@ -28,7 +28,7 @@
#include <GL/gl.h>
#include <GL/glext.h>
#include "togl/rendermechanism.h"
#include "togles/rendermechanism.h"
#include "tier0/dbg.h"
#include "tier1/strtools.h"
#include "tier1/utlbuffer.h"
@ -59,6 +59,42 @@
//#define Assert(n) if( !(n) ){ TranslationError(); }
static char g_szShadow2D[] =
"uniform sampler2D u_ShadowMap;\n"
"#define invSize 0.001953125\n"
"#define size 512.0\n"
"vec4 _shadow2D( sampler2D u_depthTex, vec3 suv)\n"
"{\n"
"vec2 p1 = suv.xy;\n"
"vec2 p2 = suv.xy+vec2(0.0,invSize);\n"
"vec2 p3 = suv.xy+vec2(invSize,0.0);\n"
"vec2 p4 = suv.xy+vec2(invSize);\n"
"float d = texture2D(u_depthTex,p1).r;\n"
"float r = float(d>suv.z);\n"
"d = texture2D(u_depthTex,p2).r;\n"
"float r2 = float(d>suv.z);\n"
"d = texture2D(u_depthTex,p3).r;\n"
"float r3 = float(d>suv.z);\n"
"d = texture2D(u_depthTex,p4).r;\n"
"float r4 = float(d>suv.z);\n"
"p1*=size;\n"
"float a = p1.y-floor(p1.y);\n"
"float b = p1.x-floor(p1.x);\n"
"float gg = mix(mix(r,r2,a),mix(r3,r4,a),b);\n"
"return vec4(gg, gg, gg, gg);"
"}\n"
"#define shadow2D _shadow2D\n";
static char g_szShadow2DProj[] =
"float _shadow2DProj( vec4 projection, vec2 texel, float NdotL )\n"
"{\n"
"vec3 coord = vec3( projection.xyz / ( projection.w + 0.0005 )); // z-bias\n"
"coord.s = float( clamp( float( coord.s ), texel.x, 1.0 - texel.x ));\n"
"coord.t = float( clamp( float( coord.t ), texel.y, 1.0 - texel.y ));\n"
"coord.r = float( clamp( float( coord.r ), 0.0, 1.0 ));\n"
"return _shadow2D( u_ShadowMap, coord );\n"
"}\n"
"#define shadow2DProj _shadow2DProj\n";
static char *g_szVecZeros[] = { NULL, "0.0", "vec2( 0.0, 0.0 )", "vec3( 0.0, 0.0, 0.0 )", "vec4( 0.0, 0.0, 0.0, 0.0 )" };
static char *g_szVecOnes[] = { NULL, "1.0", "vec2( 1.0, 1.0 )", "vec3( 1.0, 1.0, 1.0 )", "vec4( 1.0, 1.0, 1.0, 1.0 )" };
@ -894,7 +930,7 @@ void D3DToGL::PrintUsageAndIndexToString( uint32 dwToken, char* strUsageUsageInd
V_snprintf( strUsageUsageIndexName, nBufLen, "_psize" ); // no analog
break;
case D3DDECLUSAGE_TEXCOORD:
V_snprintf( strUsageUsageIndexName, nBufLen, "oT%d", dwUsageIndex );
V_snprintf( strUsageUsageIndexName, nBufLen, "oT%d", dwUsageIndex );
break;
case D3DDECLUSAGE_TANGENT:
@ -919,8 +955,7 @@ void D3DToGL::PrintUsageAndIndexToString( uint32 dwToken, char* strUsageUsageInd
// if ( fSemanticFlags & SEMANTIC_OUTPUT )
// V_snprintf( strUsageUsageIndexName, nBufLen, dwUsageIndex != 0 ? "gl_BackColor" : "gl_FrontColor" );
// else
V_snprintf( strUsageUsageIndexName, nBufLen, dwUsageIndex != 0 ? "gl_SecondaryColor" : "gl_Color" );
V_snprintf( strUsageUsageIndexName, nBufLen, dwUsageIndex != 0 ? "_gl_SecondaryColor" : "_gl_Color" );
break;
case D3DDECLUSAGE_FOG:
TranslationError();
@ -1185,9 +1220,9 @@ void D3DToGL::PrintParameterToString ( uint32 dwToken, uint32 dwSourceOrDest, ch
}
else
{
V_snprintf( buff, sizeof( buff ), dwRegNum == 0 ? "gl_Color" : "gl_SecondaryColor" );
V_snprintf( buff, sizeof( buff ), dwRegNum == 0 ? "_gl_Color" : "_gl_SecondaryColor" );
}
strcat_s( pRegisterName, nBufLen, buff );
strcat_s( pRegisterName, nBufLen, buff );
}
else
{
@ -1318,13 +1353,12 @@ void D3DToGL::PrintParameterToString ( uint32 dwToken, uint32 dwSourceOrDest, ch
// Is this iterator centroid?
if ( m_nCentroidMask & ( 0x00000001 << dwRegNum ) )
{
V_snprintf( buff, sizeof( buff ), "centroid varying vec4 oT%d", dwRegNum ); // centroid varying
V_snprintf( buff, sizeof( buff ), "centroid in vec4 oT%d", dwRegNum ); // centroid varying
}
else
{
V_snprintf( buff, sizeof( buff ), "varying vec4 oT%d", dwRegNum );
}
V_snprintf( buff, sizeof( buff ), "in vec4 oT%d", dwRegNum );
}
bAllowWriteMask = false;
}
else // source register
@ -1345,7 +1379,13 @@ void D3DToGL::PrintParameterToString ( uint32 dwToken, uint32 dwSourceOrDest, ch
break;
case D3DSRO_FOG:
strcat_s( pRegisterName, nBufLen, "gl_FogFragCoord" );
if( !m_bFogFragCoord )
{
StrcatToHeaderCode("varying mediump vec4 _gl_FogFragCoord;\n");
m_bFogFragCoord = true;
}
strcat_s( pRegisterName, nBufLen, "_gl_FogFragCoord" );
m_bDeclareVSOFog = true;
break;
@ -1361,11 +1401,23 @@ void D3DToGL::PrintParameterToString ( uint32 dwToken, uint32 dwSourceOrDest, ch
if ( dwRegNum == 0 )
{
V_snprintf( buff, sizeof( buff ), "gl_FrontColor" );
if( !m_bFrontColor )
{
StrcatToHeaderCode("varying lowp vec4 _gl_FrontColor;\n");
m_bFrontColor = true;
}
V_snprintf( buff, sizeof( buff ), "_gl_FrontColor" );
}
else if ( dwRegNum == 1 )
{
V_snprintf( buff, sizeof( buff ), "gl_FrontSecondaryColor" );
if( !m_bFrontSecondaryColor )
{
StrcatToHeaderCode("varying lowp vec4 _gl_FrontSecondaryColor;\n");
m_bFrontSecondaryColor = true;
}
V_snprintf( buff, sizeof( buff ), "_gl_FrontSecondaryColor" );
}
else
{
@ -1404,6 +1456,10 @@ void D3DToGL::PrintParameterToString ( uint32 dwToken, uint32 dwSourceOrDest, ch
m_dwConstIntUsageMask |= 0x00000001 << dwRegNum; // Keep track of the use of this integer constant
break;
case D3DSPR_COLOROUT:
// TODO(nillerusr): go fck urself
if( dwRegNum+1 > m_iFragDataCount )
m_iFragDataCount = dwRegNum+1;
V_snprintf( buff, sizeof( buff ), "gl_FragData[%d]", dwRegNum );
strcat_s( pRegisterName, nBufLen, buff );
m_bOutputColorRegister[dwRegNum] = true;
@ -1816,7 +1872,7 @@ void D3DToGL::Handle_DCL()
CUtlString sParam2 = GetUsageAndIndexString( dwToken, SEMANTIC_INPUT );
sParam2 = FixGLSLSwizzle( sParam1, sParam2 );
PrintToBuf( *m_pBufHeaderCode, "attribute vec4 %s; // ", sParam1.String() );
PrintToBuf( *m_pBufHeaderCode, "in vec4 %s; // ", sParam1.String() );
MaintainAttributeMap( dwToken, dwRegToken );
@ -1869,12 +1925,13 @@ void D3DToGL::Handle_DCL()
char buf[256];
if ( m_nCentroidMask & ( 0x00000001 << dwUsageIndex ) )
{
V_snprintf( buf, sizeof( buf ), "centroid varying vec4 oT%d;\n", dwUsageIndex ); // centroid varying
V_snprintf( buf, sizeof( buf ), "centroid in vec4 oT%d;\n", dwUsageIndex ); // centroid varying
}
else
{
V_snprintf( buf, sizeof( buf ), "varying vec4 oT%d;\n", dwUsageIndex );
V_snprintf( buf, sizeof( buf ), "in vec4 oT%d;\n", dwUsageIndex );
}
StrcatToHeaderCode( buf );
}
}
@ -2877,13 +2934,14 @@ void D3DToGL::Handle_UnaryOp( uint32 nInstruction )
void D3DToGL::WriteGLSLSamplerDefinitions()
{
int nSamplersWritten = 0;
bool m_bSampler3d = false;
for ( int i=0; i < ARRAYSIZE( m_dwSamplerTypes ); i++ )
{
if ( m_dwSamplerTypes[i] == SAMPLER_TYPE_2D )
{
if ( ( ( 1 << i ) & m_nShadowDepthSamplerMask ) != 0 )
{
PrintToBuf( *m_pBufHeaderCode, "uniform sampler2DShadow sampler%d;\n", i );
PrintToBuf( *m_pBufHeaderCode, "uniform sampler2D sampler%d;\n", i );
}
else
{
@ -2893,6 +2951,12 @@ void D3DToGL::WriteGLSLSamplerDefinitions()
}
else if ( m_dwSamplerTypes[i] == SAMPLER_TYPE_3D )
{
if( !m_bSampler3d )
{
StrcatToHeaderCode( "precision mediump sampler3D;\n" );
m_bSampler3d = true;
}
PrintToBuf( *m_pBufHeaderCode, "uniform sampler3D sampler%d;\n", i );
++nSamplersWritten;
}
@ -2941,21 +3005,27 @@ void D3DToGL::WriteGLSLOutputVariableAssignments()
if ( dwUsage == D3DDECLUSAGE_COLOR )
{
PrintToBufWithIndents( *m_pBufALUCode, "%s = oTempT%d;\n", dwUsageIndex ? "gl_FrontSecondaryColor" : "gl_FrontColor", i );
if( !m_bFrontColor )
{
StrcatToHeaderCode("varying lowp vec4 _gl_FrontColor;\n");
m_bFrontColor = true;
}
PrintToBufWithIndents( *m_pBufALUCode, "%s = oTempT%d;\n", dwUsageIndex ? "gl_FrontSecondaryColor" : "_gl_FrontColor", i );
}
else if ( dwUsage == D3DDECLUSAGE_TEXCOORD )
{
char buf[256];
if ( m_nCentroidMask & ( 0x00000001 << dwUsageIndex ) )
{
V_snprintf( buf, sizeof( buf ), "centroid varying vec4 oT%d;\n", dwUsageIndex ); // centroid varying
V_snprintf( buf, sizeof( buf ), "centroid out vec4 oT%d;\n", dwUsageIndex ); // centroid varying
}
else
{
V_snprintf( buf, sizeof( buf ), "varying vec4 oT%d;\n", dwUsageIndex );
V_snprintf( buf, sizeof( buf ), "out vec4 oT%d;\n", dwUsageIndex );
}
StrcatToHeaderCode( buf );
PrintToBufWithIndents( *m_pBufALUCode, "oT%d = oTempT%d;\n", dwUsageIndex, i );
}
}
@ -2979,12 +3049,12 @@ void D3DToGL::WriteGLSLInputVariableAssignments()
if ( dwUsage == D3DDECLUSAGE_COLOR )
{
PrintToBufWithIndents( *m_pBufAttribCode, "vec4 oTempT%d = %s;\n", i, dwUsageIndex ? "gl_SecondaryColor" : "gl_Color" );
PrintToBufWithIndents( *m_pBufAttribCode, "vec4 oTempT%d = %s;\n", i, dwUsageIndex ? "_gl_SecondaryColor" : "_gl_Color" );
}
else if ( dwUsage == D3DDECLUSAGE_TEXCOORD )
{
PrintToBufWithIndents( *m_pBufAttribCode, "vec4 oTempT%d = oT%d;\n", i, dwUsageIndex );
}
}
}
}
@ -3100,6 +3170,13 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
m_bDoFixupZ = (options & D3DToGL_OptionDoFixupZ) != 0;
m_bDoFixupY = (options & D3DToGL_OptionDoFixupY) != 0;
m_bDoUserClipPlanes = (options & D3DToGL_OptionDoUserClipPlanes) != 0;
m_bFrontSecondaryColor = false;
m_bFogFragCoord = false;
m_bColor = false;
m_bFrontColor = false;
m_bSecondaryColor = false;
m_iFragDataCount = 0;
m_bAddHexCodeComments = (options & D3DToGL_AddHexComments) != 0;
m_bPutHexCodesAfterLines = (options & D3DToGL_PutHexCommentsAfterLines) != 0;
@ -3190,25 +3267,24 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
m_dwMinorVersion = D3DSHADER_VERSION_MINOR( dwToken );
// If pixel shader
const char *glslExtText = "#extension GL_ARB_shader_texture_lod : require\n";//m_bUseBindlessTexturing ? "#extension GL_NV_bindless_texture : require\n" : "";
const char *glslExtText = "\n";//#extension GL_ARB_shader_texture_lod : require\n";//m_bUseBindlessTexturing ? "#extension GL_NV_bindless_texture : require\n" : "";
// 7ls
const char *glslVersionText = m_bUseBindlessTexturing ? "330 compatibility" : "120";
// const char *glslVersionText = m_bUseBindlessTexturing ? "330 compatibility" : "120";
if ( ( dwToken & 0xFFFF0000 ) == 0xFFFF0000 )
{
// must explicitly enable extensions if emitting GLSL
V_snprintf( (char *)m_pBufHeaderCode->Base(), m_pBufHeaderCode->Size(), "#version %s\n%s", glslVersionText, glslExtText );
V_snprintf( (char *)m_pBufHeaderCode->Base(), m_pBufHeaderCode->Size(), "#version 300 es\nprecision mediump float;\n#define varying in\n\n%s", glslExtText );
m_bVertexShader = false;
}
else // vertex shader
{
m_bGenerateSRGBWriteSuffix = false;
V_snprintf( (char *)m_pBufHeaderCode->Base(), m_pBufHeaderCode->Size(), "#version 300 es\nprecision mediump float;\n#define attribute in\n#define varying out\n%s//ATTRIBMAP-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx\n", glslExtText );
V_snprintf( (char *)m_pBufHeaderCode->Base(), m_pBufHeaderCode->Size(), "#version %s\n%s//ATTRIBMAP-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx\n", glslVersionText, glslExtText );
// find that first '-xx' which is where the attrib map will be written later.
pAttribMapStart = strstr( (char *)m_pBufHeaderCode->Base(), "-xx" ) + 1;
m_bVertexShader = true;
}
@ -3521,7 +3597,7 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
// Note that this constant packing expects .wzyx swizzles in case we ever use the SINCOS code in a ps_2_x shader
//
// The Microsoft documentation on this is all kinds of broken and, strangely, these numbers don't even
// The Microsoft do cumentation on this is all kinds of broken and, strangely, these numbers don't even
// match the D3DSINCOSCONST1 and D3DSINCOSCONST2 constants used by the D3D assembly sincos instruction...
if ( m_bNeedsSinCosDeclarations )
{
@ -3688,7 +3764,7 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
{
if ( m_bDoUserClipPlanes )
{
StrcatToALUCode( "gl_ClipVertex = vTempPos;\n" ); // if user clip is enabled, jam clip space position into gl_ClipVertex
// StrcatToALUCode( "gl_ClipVertex = vTempPos;\n" ); // if user clip is enabled, jam clip space position into gl_ClipVertex
}
if ( m_bDoFixupZ || m_bDoFixupY )
@ -3746,12 +3822,12 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
{
if ( m_nCentroidMask & ( 0x00000001 << i ) )
{
V_snprintf( outTexCoordBuff, sizeof( outTexCoordBuff ), "centroid varying vec4 oT%d;\n", i ); // centroid varying
V_snprintf( outTexCoordBuff, sizeof( outTexCoordBuff ), "centroid out vec4 oT%d;\n", i ); // centroid varying
StrcatToHeaderCode( outTexCoordBuff );
}
else
{
V_snprintf( outTexCoordBuff, sizeof( outTexCoordBuff ), "varying vec4 oT%d;\n", i );
V_snprintf( outTexCoordBuff, sizeof( outTexCoordBuff ), "out vec4 oT%d;\n", i );
StrcatToHeaderCode( outTexCoordBuff );
}
}
@ -3769,7 +3845,7 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
// do some annotation at the end of the attrib block
{
char temp[1000];
char temp[5000];
if ( m_bVertexShader )
{
@ -3800,6 +3876,30 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
StrcatToHeaderCode( "OPTION ARB_fragment_program_shadow;\n" );
}
if( m_iFragDataCount || m_bGenerateSRGBWriteSuffix )
{
char buf[256];
snprintf(buf, sizeof buf, "out vec4 _gl_FragData[%d];\n#define gl_FragData _gl_FragData\n", m_iFragDataCount);
StrcatToHeaderCode( buf );
}
#define FindSubcode(a) (V_strstr((char*)m_pBufALUCode->Base(), a) != 0 || V_strstr((char*)m_pBufHeaderCode->Base(), a) != 0 || V_strstr((char*)m_pBufParamCode->Base(), a) != 0 || V_strstr((char*)m_pBufAttribCode->Base(), a) != 0 )
if( FindSubcode("shadow2DProj") )
{
StrcatToHeaderCode( g_szShadow2D );
StrcatToHeaderCode( g_szShadow2DProj );
}
else if( FindSubcode("shadow2D") )
StrcatToHeaderCode( g_szShadow2D );
if( FindSubcode("_gl_Color") )
StrcatToHeaderCode( "vec4 _gl_Color;\n" );
if( FindSubcode("_gl_SecondaryColor") )
StrcatToHeaderCode( "vec4 _gl_SecondaryColor;\n" );
StrcatToHeaderCode( "\nvoid main()\n{\n" );
if ( m_bUsedAtomicTempVar )
{
@ -3815,9 +3915,9 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
StrcatToALUCode( "sRGBFragData.xyz = exp( sRGBFragData.xyz );\n" );
StrcatToALUCode( "gl_FragData[0].xyz = mix( gl_FragData[0].xyz, sRGBFragData, flSRGBWrite );\n" );
}
strcat_s( (char*)m_pBufALUCode->Base(), m_pBufALUCode->Size(), "}\n" );
strcat_s( (char*)m_pBufALUCode->Base(), m_pBufALUCode->Size(), "}\n" );
// Put all of the strings together for final program ( pHeaderCode + pAttribCode + pParamCode + pALUCode )
StrcatToHeaderCode( (char*)m_pBufAttribCode->Base() );
StrcatToHeaderCode( (char*)m_pBufParamCode->Base() );

View File

@ -82,7 +82,13 @@ private:
bool m_bGenerateSRGBWriteSuffix; // set D3DToGL_OptionSRGBWriteSuffix
bool m_bGenerateBoneUniformBuffer;
bool m_bUseBindlessTexturing;
bool m_bFogFragCoord;
bool m_bFrontSecondaryColor;
bool m_bColor;
bool m_bSecondaryColor;
bool m_bFrontColor;
// Counter for dealing with nested loops
int m_nLoopDepth;
@ -181,6 +187,7 @@ private:
// Have they used the tangent input semantic (i.e. is g_pTangentAttributeName declared)?
bool m_bTangentInputUsed;
uint m_iFragDataCount;
bool m_bUsesDSTInstruction;

View File

@ -25,7 +25,7 @@
// dxabstract.cpp
//
//==================================================================================================
#include "togl/rendermechanism.h"
#include "togles/rendermechanism.h"
#include "tier0/vprof_telemetry.h"
#include "tier0/dbg.h"
#include "tier0/threadtools.h"
@ -2384,7 +2384,7 @@ HRESULT IDirect3DDevice9::Create( IDirect3DDevice9Params *params )
m_ctx->m_drawingFBO = m_ctx->NewFBO();
// bind it to context. will receive attachments shortly.
m_ctx->BindFBOToCtx( m_ctx->m_drawingFBO, GL_FRAMEBUFFER_EXT );
m_ctx->BindFBOToCtx( m_ctx->m_drawingFBO, GL_FRAMEBUFFER );
m_bFBODirty = false;
@ -3235,7 +3235,7 @@ void IDirect3DDevice9::UpdateBoundFBO()
m_ctx->m_drawingFBO = newFBO;
}
m_ctx->BindFBOToCtx( m_ctx->m_drawingFBO, GL_FRAMEBUFFER_EXT );
m_ctx->BindFBOToCtx( m_ctx->m_drawingFBO, GL_FRAMEBUFFER );
m_bFBODirty = false;
}
@ -3873,10 +3873,8 @@ HRESULT IDirect3DDevice9::CreatePixelShader(CONST DWORD* pFunction,IDirect3DPixe
int maxTranslationSize = 50000; // size of any one translation
CUtlBuffer transbuf( 3000, numTranslations * maxTranslationSize, CUtlBuffer::TEXT_BUFFER );
CUtlBuffer tempbuf( 3000, maxTranslationSize, CUtlBuffer::TEXT_BUFFER );
transbuf.PutString( "//GLSLfp\n" ); // this is required so GLM can crack the text apart
CUtlBuffer transbuf( 9000, numTranslations * maxTranslationSize, CUtlBuffer::TEXT_BUFFER );
CUtlBuffer tempbuf( 9000, maxTranslationSize, CUtlBuffer::TEXT_BUFFER );
// note the GLSL translator wants its own buffer
tempbuf.EnsureCapacity( maxTranslationSize );
@ -4009,7 +4007,7 @@ HRESULT IDirect3DDevice9::CreatePixelShader(CONST DWORD* pFunction,IDirect3DPixe
{
// find the fb outputs used by this shader/combo
const GLenum buffers[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_COLOR_ATTACHMENT3_EXT };
const GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
char *fragDataMaskPrefix = "//FRAGDATAMASK-";
@ -4153,10 +4151,8 @@ HRESULT IDirect3DDevice9::CreateVertexShader(CONST DWORD* pFunction, IDirect3DVe
int maxTranslationSize = 500000; // size of any one translation
CUtlBuffer transbuf( 1000, numTranslations * maxTranslationSize, CUtlBuffer::TEXT_BUFFER );
CUtlBuffer tempbuf( 1000, maxTranslationSize, CUtlBuffer::TEXT_BUFFER );
transbuf.PutString( "//GLSLvp\n" ); // this is required so GLM can crack the text apart
CUtlBuffer transbuf( 5000, numTranslations * maxTranslationSize, CUtlBuffer::TEXT_BUFFER );
CUtlBuffer tempbuf( 5000, maxTranslationSize, CUtlBuffer::TEXT_BUFFER );
// note the GLSL translator wants its own buffer
tempbuf.EnsureCapacity( maxTranslationSize );

View File

@ -27,7 +27,7 @@
//=============================================================================//
// Immediately include gl.h, etc. here to avoid compilation warnings.
#include "togl/rendermechanism.h"
#include "togles/rendermechanism.h"
#include "appframework/AppFramework.h"
#include "appframework/IAppSystemGroup.h"
@ -80,9 +80,9 @@ bool g_bPrintOpenGLCalls = false;
fflush(stdout); \
} \
const GLenum err = glGetError_gldebugptr(); \
if ( err == GL_INVALID_FRAMEBUFFER_OPERATION_EXT ) { \
const GLenum fberr = gGL->glCheckFramebufferStatus( GL_FRAMEBUFFER_EXT ); \
printf("%s triggered error GL_INVALID_FRAMEBUFFER_OPERATION_EXT! (0x%X)\n\n\n", #fn, (int) fberr); \
if ( err == GL_INVALID_FRAMEBUFFER_OPERATION ) { \
const GLenum fberr = gGL->glCheckFramebufferStatus( GL_FRAMEBUFFER ); \
printf("%s triggered error GL_INVALID_FRAMEBUFFER_OPERATION! (0x%X)\n\n\n", #fn, (int) fberr); \
fflush(stdout); \
__asm__ __volatile__ ( "int $3\n\t" ); \
} else if (err != GL_NO_ERROR) { \
@ -107,9 +107,9 @@ bool g_bPrintOpenGLCalls = false;
fflush(stdout); \
} \
const GLenum err = glGetError_gldebugptr(); \
if ( err == GL_INVALID_FRAMEBUFFER_OPERATION_EXT ) { \
const GLenum fberr = gGL->glCheckFramebufferStatus( GL_FRAMEBUFFER_EXT ); \
printf("%s triggered error GL_INVALID_FRAMEBUFFER_OPERATION_EXT! (0x%X)\n\n\n", #fn, (int) fberr); \
if ( err == GL_INVALID_FRAMEBUFFER_OPERATION ) { \
const GLenum fberr = gGL->glCheckFramebufferStatus( GL_FRAMEBUFFER ); \
printf("%s triggered error GL_INVALID_FRAMEBUFFER_OPERATION! (0x%X)\n\n\n", #fn, (int) fberr); \
fflush(stdout); \
__asm__ __volatile__ ( "int $3\n\t" ); \
} else if (err != GL_NO_ERROR) { \
@ -119,7 +119,7 @@ bool g_bPrintOpenGLCalls = false;
} \
}
#include "togl/glfuncs.inl"
#include "togles/glfuncs.inl"
#undef GL_FUNC_VOID
#undef GL_FUNC
#undef GL_EXT
@ -296,7 +296,9 @@ static bool CheckOpenGLExtension_internal(const char *ext, const int coremajor,
return false;
}
}
#elif !defined ( OSX ) && !defined( __ANDROID__ )
/*
if (!ptr)
{
static CDynamicFunctionOpenGL< true, Display *( APIENTRY *)( ), Display* > glXGetCurrentDisplay("glXGetCurrentDisplay");
@ -306,7 +308,7 @@ static bool CheckOpenGLExtension_internal(const char *ext, const int coremajor,
extensions = glXQueryExtensionsString(glXGetCurrentDisplay(), 0);
ptr = strstr(extensions, ext);
}
}
}*/
#endif
if (!ptr)
@ -342,7 +344,7 @@ COpenGLEntryPoints::COpenGLEntryPoints()
#define GL_EXT(x,glmajor,glminor) , m_bHave_##x(CheckOpenGLExtension(#x, glmajor, glminor))
#define GL_FUNC(ext,req,ret,fn,arg,call) , fn(#fn, m_bHave_##ext)
#define GL_FUNC_VOID(ext,req,fn,arg,call) , fn(#fn, m_bHave_##ext)
#include "togl/glfuncs.inl"
#include "togles/glfuncs.inl"
#undef GL_FUNC_VOID
#undef GL_FUNC
#undef GL_EXT
@ -380,7 +382,7 @@ COpenGLEntryPoints::COpenGLEntryPoints()
#ifndef ANDROID // HACK
if ((m_bHave_OpenGL) && ((!m_bHave_GL_NV_fence) && (!m_bHave_GL_ARB_sync) && (!m_bHave_GL_APPLE_fence)))
{
Error( "Required OpenGL extension \"GL_NV_fence\", \"GL_ARB_sync\", or \"GL_APPLE_fence\" is not supported. Please upgrade your OpenGL driver." );
// Error( "Required OpenGL extension \"GL_NV_fence\", \"GL_ARB_sync\", or \"GL_APPLE_fence\" is not supported. Please upgrade your OpenGL driver." );
}
#endif
@ -393,25 +395,26 @@ COpenGLEntryPoints::COpenGLEntryPoints()
// GL_ARB_framebuffer_object is a superset of GL_EXT_framebuffer_object,
// (etc) but if you don't call in through the ARB entry points, you won't
// get the relaxed restrictions on mismatched attachment dimensions.
if (m_bHave_GL_ARB_framebuffer_object)
// if (m_bHave_GL_ARB_framebuffer_object)
{
m_bHave_GL_EXT_framebuffer_object = true;
m_bHave_GL_EXT_framebuffer_blit = true;
m_bHave_GL_EXT_framebuffer_multisample = true;
glBindFramebufferEXT.Force(glBindFramebuffer.Pointer());
glBindRenderbufferEXT.Force(glBindRenderbuffer.Pointer());
glCheckFramebufferStatusEXT.Force(glCheckFramebufferStatus.Pointer());
glDeleteRenderbuffersEXT.Force(glDeleteRenderbuffers.Pointer());
glFramebufferRenderbufferEXT.Force(glFramebufferRenderbuffer.Pointer());
glFramebufferTexture2DEXT.Force(glFramebufferTexture2D.Pointer());
glFramebufferTexture3DEXT.Force(glFramebufferTexture3D.Pointer());
glGenFramebuffersEXT.Force(glGenFramebuffers.Pointer());
glGenRenderbuffersEXT.Force(glGenRenderbuffers.Pointer());
glDeleteFramebuffersEXT.Force(glDeleteFramebuffers.Pointer());
glBlitFramebufferEXT.Force(glBlitFramebuffer.Pointer());
glRenderbufferStorageMultisampleEXT.Force(glRenderbufferStorageMultisample.Pointer());
glBindFramebuffer.Force(glBindFramebuffer.Pointer());
glBindRenderbuffer.Force(glBindRenderbuffer.Pointer());
glCheckFramebufferStatus.Force(glCheckFramebufferStatus.Pointer());
glDeleteRenderbuffers.Force(glDeleteRenderbuffers.Pointer());
glFramebufferRenderbuffer.Force(glFramebufferRenderbuffer.Pointer());
glFramebufferTexture2D.Force(glFramebufferTexture2D.Pointer());
glFramebufferTexture3D.Force(glFramebufferTexture3D.Pointer());
glGenFramebuffers.Force(glGenFramebuffers.Pointer());
glGenRenderbuffers.Force(glGenRenderbuffers.Pointer());
glDeleteFramebuffers.Force(glDeleteFramebuffers.Pointer());
glBlitFramebuffer.Force(glBlitFramebuffer.Pointer());
glRenderbufferStorageMultisample.Force(glRenderbufferStorageMultisample.Pointer());
}
#if DEBUG_ALL_GLCALLS
// push all GL calls through the debug wrappers.
#define GL_EXT(x,glmajor,glminor)
@ -421,7 +424,7 @@ COpenGLEntryPoints::COpenGLEntryPoints()
#define GL_FUNC_VOID(ext,req,fn,arg,call) \
fn##_gldebugptr = this->fn; \
this->fn.Force(fn##_gldebug);
#include "togl/glfuncs.inl"
#include "togles/glfuncs.inl"
#undef GL_FUNC_VOID
#undef GL_FUNC
#undef GL_EXT
@ -500,7 +503,7 @@ void COpenGLEntryPoints::ClearEntryPoints()
#define GL_EXT(x,glmajor,glminor)
#define GL_FUNC(ext,req,ret,fn,arg,call) fn.Force( NULL );
#define GL_FUNC_VOID(ext,req,fn,arg,call) fn.Force( NULL );
#include "togl/glfuncs.inl"
#include "togles/glfuncs.inl"
#undef GL_FUNC_VOID
#undef GL_FUNC
#undef GL_EXT

View File

@ -25,7 +25,7 @@
// glmgr.cpp
//
//===============================================================================
#include "togl/rendermechanism.h"
#include "togles/rendermechanism.h"
#include "tier0/icommandline.h"
@ -76,28 +76,25 @@ const uint32 g_garbageTextureBits[ 4 * kDeletedTextureDim * kDeletedTextureDim ]
char g_nullFragmentProgramText [] =
{
"!!ARBfp1.0 \n"
"PARAM black = { 0.0, 0.0, 0.0, 1.0 }; \n" // opaque black
"MOV result.color, black; \n"
"END \n\n\n"
"//GLSLfp\n"
"#version 300 es\n"
"precision mediump float;\n"
"out vec4 _gl_FragColor;\n"
"void main()\n"
"{\n"
"gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n"
"_gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n"
"}\n"
};
// make dummy programs for doing texture preload via dummy draw
char g_preloadTexVertexProgramText[] =
char g_preloadTexVertexProgramText[] = // Гроб гроб кладбище пидор
{
"//GLSLvp \n"
"#version 120 \n"
"varying vec4 otex; \n"
"#version 300 es\n"
"precision mediump float;\n"
"out vec4 otex;\n"
"void main() \n"
"{ \n"
"vec4 pos = ftransform(); // vec4( 0.1, 0.1, 0.1, 0.1 ); \n"
"vec4 tex = vec4( 0.0, 0.0, 0.0, 0.0 ); \n"
"vec4 pos = vec4( 0.1, 0.1, 0.1, 0.1 );\n"
"vec4 tex = vec4( 0.0, 0.0, 0.0, 0.0 );\n"
" \n"
"gl_Position = pos; \n"
"otex = tex; \n"
@ -106,9 +103,10 @@ char g_preloadTexVertexProgramText[] =
char g_preload2DTexFragmentProgramText[] =
{
"//GLSLfp \n"
"#version 120 \n"
"varying vec4 otex; \n"
"#version 300 es\n"
"precision mediump float;\n"
"out vec4 _gl_FragColor;\n"
"in vec4 otex;\n"
"//SAMPLERMASK-8000 // may not be needed \n"
"//HIGHWATER-30 // may not be needed \n"
" \n"
@ -119,18 +117,20 @@ char g_preload2DTexFragmentProgramText[] =
"{ \n"
"vec4 r0; \n"
"r0 = texture2D( sampler15, otex.xy ); \n"
"gl_FragColor = r0; //discard; \n"
"_gl_FragColor = r0; //discard; \n"
"} \n"
};
char g_preload3DTexFragmentProgramText[] =
{
"//GLSLfp \n"
"#version 120 \n"
"varying vec4 otex; \n"
"#version 300 es\n"
"precision mediump float;\n"
"out vec4 _gl_FragColor;\n"
"in vec4 otex;\n"
"//SAMPLERMASK-8000 // may not be needed \n"
"//HIGHWATER-30 // may not be needed \n"
" \n"
"precision mediump sampler3D;\n"
"uniform vec4 pc[31]; \n"
"uniform sampler3D sampler15; \n"
" \n"
@ -138,17 +138,18 @@ char g_preload3DTexFragmentProgramText[] =
"{ \n"
"vec4 r0; \n"
"r0 = texture3D( sampler15, otex.xyz ); \n"
"gl_FragColor = r0; //discard; \n"
"_gl_FragColor = vec4(0,0,0,0); //discard; \n"
"} \n"
};
char g_preloadCubeTexFragmentProgramText[] =
{
"//GLSLfp \n"
"#version 120 \n"
"varying vec4 otex; \n"
"//SAMPLERMASK-8000 // may not be needed \n"
"//HIGHWATER-30 // may not be needed \n"
"#version 300 es\n"
"precision mediump float;\n"
"in vec4 otex;\n"
"out vec4 _gl_FragColor;\n"
"//SAMPLERMASK-8000 // may not be needed \n"
"//HIGHWATER-30 // may not be needed \n"
" \n"
"uniform vec4 pc[31]; \n"
"uniform samplerCube sampler15; \n"
@ -157,7 +158,7 @@ char g_preloadCubeTexFragmentProgramText[] =
"{ \n"
"vec4 r0; \n"
"r0 = textureCube( sampler15, otex.xyz ); \n"
"gl_FragColor = r0; //discard; \n"
"_gl_FragColor = r0; //discard; \n"
"} \n"
};
@ -638,19 +639,12 @@ void GLMContext::ForceFlushStates()
NullProgram();
// FBO
BindFBOToCtx( m_boundReadFBO, GL_READ_FRAMEBUFFER_EXT );
BindFBOToCtx( m_boundDrawFBO, GL_DRAW_FRAMEBUFFER_EXT );
BindFBOToCtx( m_boundReadFBO, GL_READ_FRAMEBUFFER );
BindFBOToCtx( m_boundDrawFBO, GL_DRAW_FRAMEBUFFER );
// Current VB/IB/pinned memory buffers
gGL->glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nBoundGLBuffer[ kGLMIndexBuffer] );
gGL->glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nBoundGLBuffer[ kGLMVertexBuffer] );
#ifndef OSX
if ( gGL->m_bHave_GL_AMD_pinned_memory )
{
gGL->glBindBufferARB( GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, m_PinnedMemoryBuffers[m_nCurPinnedMemoryBuffer].GetHandle() );
}
#endif
gGL->glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, m_nBoundGLBuffer[ kGLMIndexBuffer] );
gGL->glBindBuffer( GL_ARRAY_BUFFER, m_nBoundGLBuffer[ kGLMVertexBuffer] );
}
const GLMRendererInfoFields& GLMContext::Caps( void )
@ -827,17 +821,17 @@ enum eBlitFormatClass
eDepthStencil
};
uint glAttachFromClass[ 3 ] = { GL_COLOR_ATTACHMENT0_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_DEPTH_STENCIL_ATTACHMENT_EXT };
uint glAttachFromClass[ 3 ] = { GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, GL_DEPTH_STENCIL_ATTACHMENT };
void glScrubFBO ( GLenum target )
{
gGL->glFramebufferRenderbufferEXT ( target, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, 0);
gGL->glFramebufferRenderbufferEXT ( target, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
gGL->glFramebufferRenderbufferEXT ( target, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
gGL->glFramebufferRenderbuffer ( target, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
gGL->glFramebufferRenderbuffer ( target, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
gGL->glFramebufferRenderbuffer ( target, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
gGL->glFramebufferTexture2DEXT ( target, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, 0, 0 );
gGL->glFramebufferTexture2DEXT ( target, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0 );
gGL->glFramebufferTexture2DEXT ( target, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0 );
gGL->glFramebufferTexture2D ( target, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0 );
gGL->glFramebufferTexture2D ( target, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0 );
gGL->glFramebufferTexture2D ( target, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0 );
}
void glAttachRBOtoFBO ( GLenum target, eBlitFormatClass formatClass, uint rboName )
@ -845,16 +839,16 @@ void glAttachRBOtoFBO ( GLenum target, eBlitFormatClass formatClass, uint rboNam
switch( formatClass )
{
case eColor:
gGL->glFramebufferRenderbufferEXT ( target, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, rboName);
gGL->glFramebufferRenderbuffer ( target, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rboName);
break;
case eDepth:
gGL->glFramebufferRenderbufferEXT ( target, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboName);
gGL->glFramebufferRenderbuffer ( target, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboName);
break;
case eDepthStencil:
gGL->glFramebufferRenderbufferEXT ( target, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboName);
gGL->glFramebufferRenderbufferEXT ( target, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboName);
gGL->glFramebufferRenderbuffer ( target, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboName);
gGL->glFramebufferRenderbuffer ( target, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rboName);
break;
}
}
@ -864,15 +858,15 @@ void glAttachTex2DtoFBO ( GLenum target, eBlitFormatClass formatClass, uint texN
switch( formatClass )
{
case eColor:
gGL->glFramebufferTexture2DEXT ( target, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texName, texMip );
gGL->glFramebufferTexture2D ( target, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texName, texMip );
break;
case eDepth:
gGL->glFramebufferTexture2DEXT ( target, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texName, texMip );
gGL->glFramebufferTexture2D ( target, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texName, texMip );
break;
case eDepthStencil:
gGL->glFramebufferTexture2DEXT ( target, GL_DEPTH_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, texName, texMip );
gGL->glFramebufferTexture2D ( target, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, texName, texMip );
break;
}
}
@ -934,7 +928,7 @@ void GLMContext::Blit2( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int srcM
blitMask = GL_DEPTH_BUFFER_BIT;
break;
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH_STENCIL:
formatClass = eDepthStencil;
blitMask = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
break;
@ -1048,14 +1042,14 @@ void GLMContext::Blit2( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int srcM
// a resolve that can't be done directly due to constraints on scaling or flipping.
// bind scratch FBO0 to read, scrub it, attach RBO
BindFBOToCtx ( m_scratchFBO[0], GL_READ_FRAMEBUFFER_EXT );
glScrubFBO ( GL_READ_FRAMEBUFFER_EXT );
glAttachRBOtoFBO ( GL_READ_FRAMEBUFFER_EXT, formatClass, srcTex->m_rboName );
BindFBOToCtx ( m_scratchFBO[0], GL_READ_FRAMEBUFFER );
glScrubFBO ( GL_READ_FRAMEBUFFER );
glAttachRBOtoFBO ( GL_READ_FRAMEBUFFER, formatClass, srcTex->m_rboName );
// bind scratch FBO1 to write, scrub it, attach scratch tex
BindFBOToCtx ( m_scratchFBO[1], GL_DRAW_FRAMEBUFFER_EXT );
glScrubFBO ( GL_DRAW_FRAMEBUFFER_EXT );
glAttachTex2DtoFBO ( GL_DRAW_FRAMEBUFFER_EXT, formatClass, srcTex->m_texName, 0 );
BindFBOToCtx ( m_scratchFBO[1], GL_DRAW_FRAMEBUFFER );
glScrubFBO ( GL_DRAW_FRAMEBUFFER );
glAttachTex2DtoFBO ( GL_DRAW_FRAMEBUFFER, formatClass, srcTex->m_texName, 0 );
// set read and draw buffers appropriately
gGL->glReadBuffer ( glAttachFromClass[formatClass] );
@ -1066,15 +1060,15 @@ void GLMContext::Blit2( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int srcM
GLenum resolveFilter = GL_NEAREST;
gGL->glBlitFramebufferEXT( 0, 0, srcTex->m_layout->m_key.m_xSize, srcTex->m_layout->m_key.m_ySize,
gGL->glBlitFramebuffer( 0, 0, srcTex->m_layout->m_key.m_xSize, srcTex->m_layout->m_key.m_ySize,
0, 0, srcTex->m_layout->m_key.m_xSize, srcTex->m_layout->m_key.m_ySize, // same source and dest rect, whole surface
blitMask, resolveFilter );
// FBO1 now holds the interesting content.
// scrub FBO0, bind FBO1 to READ, fall through to next stage of blit where 1 goes onto 0 (or BACK)
glScrubFBO ( GL_READ_FRAMEBUFFER_EXT ); // zap FBO0
BindFBOToCtx ( m_scratchFBO[1], GL_READ_FRAMEBUFFER_EXT );
glScrubFBO ( GL_READ_FRAMEBUFFER ); // zap FBO0
BindFBOToCtx ( m_scratchFBO[1], GL_READ_FRAMEBUFFER );
srcTex->ForceRBONonDirty();
}
@ -1084,33 +1078,33 @@ void GLMContext::Blit2( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int srcM
if (srcTex->m_pBlitSrcFBO == NULL)
{
srcTex->m_pBlitSrcFBO = NewFBO();
BindFBOToCtx( srcTex->m_pBlitSrcFBO, GL_READ_FRAMEBUFFER_EXT );
BindFBOToCtx( srcTex->m_pBlitSrcFBO, GL_READ_FRAMEBUFFER );
if (blitResolves)
{
glAttachRBOtoFBO( GL_READ_FRAMEBUFFER_EXT, formatClass, srcTex->m_rboName );
glAttachRBOtoFBO( GL_READ_FRAMEBUFFER, formatClass, srcTex->m_rboName );
}
else
{
glAttachTex2DtoFBO( GL_READ_FRAMEBUFFER_EXT, formatClass, srcTex->m_texName, srcMip );
glAttachTex2DtoFBO( GL_READ_FRAMEBUFFER, formatClass, srcTex->m_texName, srcMip );
}
}
else
{
BindFBOToCtx ( srcTex->m_pBlitSrcFBO, GL_READ_FRAMEBUFFER_EXT );
BindFBOToCtx ( srcTex->m_pBlitSrcFBO, GL_READ_FRAMEBUFFER );
// GLMCheckError();
}
#else
// arrange source surface on FBO1 for blit directly to dest (which could be FBO0 or BACK)
BindFBOToCtx( m_scratchFBO[1], GL_READ_FRAMEBUFFER_EXT );
glScrubFBO( GL_READ_FRAMEBUFFER_EXT );
BindFBOToCtx( m_scratchFBO[1], GL_READ_FRAMEBUFFER );
glScrubFBO( GL_READ_FRAMEBUFFER );
GLMCheckError();
if (blitResolves)
{
glAttachRBOtoFBO( GL_READ_FRAMEBUFFER_EXT, formatClass, srcTex->m_rboName );
glAttachRBOtoFBO( GL_READ_FRAMEBUFFER, formatClass, srcTex->m_rboName );
}
else
{
glAttachTex2DtoFBO( GL_READ_FRAMEBUFFER_EXT, formatClass, srcTex->m_texName, srcMip );
glAttachTex2DtoFBO( GL_READ_FRAMEBUFFER, formatClass, srcTex->m_texName, srcMip );
}
#endif
@ -1124,7 +1118,7 @@ void GLMContext::Blit2( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int srcM
{
// backbuffer is special - FBO0 is left out (either scrubbed already, or not used)
BindFBOToCtx ( NULL, GL_DRAW_FRAMEBUFFER_EXT );
BindFBOToCtx ( NULL, GL_DRAW_FRAMEBUFFER );
gGL->glDrawBuffer ( GL_BACK );
yflip = true;
@ -1137,31 +1131,31 @@ void GLMContext::Blit2( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int srcM
if (dstTex->m_pBlitDstFBO == NULL)
{
dstTex->m_pBlitDstFBO = NewFBO();
BindFBOToCtx( dstTex->m_pBlitDstFBO, GL_DRAW_FRAMEBUFFER_EXT );
BindFBOToCtx( dstTex->m_pBlitDstFBO, GL_DRAW_FRAMEBUFFER );
if (dstTex->m_rboName)
{
glAttachRBOtoFBO( GL_DRAW_FRAMEBUFFER_EXT, formatClass, dstTex->m_rboName );
glAttachRBOtoFBO( GL_DRAW_FRAMEBUFFER, formatClass, dstTex->m_rboName );
}
else
{
glAttachTex2DtoFBO( GL_DRAW_FRAMEBUFFER_EXT, formatClass, dstTex->m_texName, dstMip );
glAttachTex2DtoFBO( GL_DRAW_FRAMEBUFFER, formatClass, dstTex->m_texName, dstMip );
}
}
else
{
BindFBOToCtx( dstTex->m_pBlitDstFBO, GL_DRAW_FRAMEBUFFER_EXT );
BindFBOToCtx( dstTex->m_pBlitDstFBO, GL_DRAW_FRAMEBUFFER );
}
#else
BindFBOToCtx( m_scratchFBO[0], GL_DRAW_FRAMEBUFFER_EXT ); GLMCheckError();
glScrubFBO( GL_DRAW_FRAMEBUFFER_EXT );
BindFBOToCtx( m_scratchFBO[0], GL_DRAW_FRAMEBUFFER ); GLMCheckError();
glScrubFBO( GL_DRAW_FRAMEBUFFER );
if (dstTex->m_rboName)
{
glAttachRBOtoFBO( GL_DRAW_FRAMEBUFFER_EXT, formatClass, dstTex->m_rboName );
glAttachRBOtoFBO( GL_DRAW_FRAMEBUFFER, formatClass, dstTex->m_rboName );
}
else
{
glAttachTex2DtoFBO( GL_DRAW_FRAMEBUFFER_EXT, formatClass, dstTex->m_texName, dstMip );
glAttachTex2DtoFBO( GL_DRAW_FRAMEBUFFER, formatClass, dstTex->m_texName, dstMip );
}
gGL->glDrawBuffer ( glAttachFromClass[formatClass] ); GLMCheckError();
@ -1181,31 +1175,31 @@ void GLMContext::Blit2( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int srcM
// this is blit #1 or #2 depending on what took place above.
if (yflip)
{
gGL->glBlitFramebufferEXT( srcRect->xmin, srcRect->ymin, srcRect->xmax, srcRect->ymax,
gGL->glBlitFramebuffer( srcRect->xmin, srcRect->ymin, srcRect->xmax, srcRect->ymax,
dstRect->xmin, dstRect->ymax, dstRect->xmax, dstRect->ymin, // note dest Y's are flipped
blitMask, filter );
}
else
{
gGL->glBlitFramebufferEXT( srcRect->xmin, srcRect->ymin, srcRect->xmax, srcRect->ymax,
gGL->glBlitFramebuffer( srcRect->xmin, srcRect->ymin, srcRect->xmax, srcRect->ymax,
dstRect->xmin, dstRect->ymin, dstRect->xmax, dstRect->ymax,
blitMask, filter );
}
//----------------------------------------------------------------- scrub READ and maybe DRAW FBO, and unbind
// glScrubFBO ( GL_READ_FRAMEBUFFER_EXT );
BindFBOToCtx ( NULL, GL_READ_FRAMEBUFFER_EXT );
// glScrubFBO ( GL_READ_FRAMEBUFFER );
BindFBOToCtx ( NULL, GL_READ_FRAMEBUFFER );
if (!blitToBack)
{
// glScrubFBO ( GL_DRAW_FRAMEBUFFER_EXT );
BindFBOToCtx ( NULL, GL_DRAW_FRAMEBUFFER_EXT );
// glScrubFBO ( GL_DRAW_FRAMEBUFFER );
BindFBOToCtx ( NULL, GL_DRAW_FRAMEBUFFER );
}
//----------------------------------------------------------------- restore GLM's drawing FBO
// restore GLM drawing FBO
BindFBOToCtx( m_drawingFBO, GL_FRAMEBUFFER_EXT );
BindFBOToCtx( m_drawingFBO, GL_FRAMEBUFFER );
if (doPushPop)
{
@ -1329,19 +1323,19 @@ void GLMContext::BlitTex( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int sr
case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
attachIndex = kAttColor0;
attachIndexGL = GL_COLOR_ATTACHMENT0_EXT;
attachIndexGL = GL_COLOR_ATTACHMENT0;
blitMask = GL_COLOR_BUFFER_BIT;
break;
case GL_DEPTH_COMPONENT:
attachIndex = kAttDepth;
attachIndexGL = GL_DEPTH_ATTACHMENT_EXT;
attachIndexGL = GL_DEPTH_ATTACHMENT;
blitMask = GL_DEPTH_BUFFER_BIT;
break;
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH_STENCIL:
attachIndex = kAttDepthStencil;
attachIndexGL = GL_DEPTH_STENCIL_ATTACHMENT_EXT;
attachIndexGL = GL_DEPTH_STENCIL_ATTACHMENT;
blitMask = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
break;
@ -1351,31 +1345,31 @@ void GLMContext::BlitTex( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int sr
}
// set the read fb, attach read tex at appropriate attach point, set read buffer
BindFBOToCtx( m_blitReadFBO, GL_READ_FRAMEBUFFER_EXT );
BindFBOToCtx( m_blitReadFBO, GL_READ_FRAMEBUFFER );
GLMFBOTexAttachParams attparams;
attparams.m_tex = srcTex;
attparams.m_face = srcFace;
attparams.m_mip = srcMip;
attparams.m_zslice = 0;
m_blitReadFBO->TexAttach( &attparams, attachIndex, GL_READ_FRAMEBUFFER_EXT );
m_blitReadFBO->TexAttach( &attparams, attachIndex, GL_READ_FRAMEBUFFER );
gGL->glReadBuffer( attachIndexGL );
// set the write fb and buffer, and attach write tex
BindFBOToCtx( m_blitDrawFBO, GL_DRAW_FRAMEBUFFER_EXT );
BindFBOToCtx( m_blitDrawFBO, GL_DRAW_FRAMEBUFFER );
attparams.m_tex = dstTex;
attparams.m_face = dstFace;
attparams.m_mip = dstMip;
attparams.m_zslice = 0;
m_blitDrawFBO->TexAttach( &attparams, attachIndex, GL_DRAW_FRAMEBUFFER_EXT );
m_blitDrawFBO->TexAttach( &attparams, attachIndex, GL_DRAW_FRAMEBUFFER );
gGL->glDrawBuffer( attachIndexGL );
// do the blit
gGL->glBlitFramebufferEXT( srcRect->xmin, srcRect->ymin, srcRect->xmax, srcRect->ymax,
gGL->glBlitFramebuffer( srcRect->xmin, srcRect->ymin, srcRect->xmax, srcRect->ymax,
dstRect->xmin, dstRect->ymin, dstRect->xmax, dstRect->ymax,
blitMask, filter );
@ -1383,13 +1377,13 @@ void GLMContext::BlitTex( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int sr
// unset the read fb and buffer, detach read tex
// unset the write fb and buffer, detach write tex
m_blitReadFBO->TexDetach( attachIndex, GL_READ_FRAMEBUFFER_EXT );
m_blitReadFBO->TexDetach( attachIndex, GL_READ_FRAMEBUFFER );
m_blitDrawFBO->TexDetach( attachIndex, GL_DRAW_FRAMEBUFFER_EXT );
m_blitDrawFBO->TexDetach( attachIndex, GL_DRAW_FRAMEBUFFER );
// put the original FB back in place (both read and draw)
// this bind will hit both read and draw bindings
BindFBOToCtx( m_drawingFBO, GL_FRAMEBUFFER_EXT );
BindFBOToCtx( m_drawingFBO, GL_FRAMEBUFFER );
// set the read and write buffers back to... what ? does it matter for anything but copies ? don't worry about it
@ -1414,7 +1408,7 @@ void GLMContext::BlitTex( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int sr
case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
attachIndex = kAttColor0;
attachIndexGL = GL_COLOR_ATTACHMENT0_EXT;
attachIndexGL = GL_COLOR_ATTACHMENT0;
break;
default:
@ -1422,14 +1416,14 @@ void GLMContext::BlitTex( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int sr
break;
}
BindFBOToCtx( m_blitDrawFBO, GL_DRAW_FRAMEBUFFER_EXT );
BindFBOToCtx( m_blitDrawFBO, GL_DRAW_FRAMEBUFFER );
GLMFBOTexAttachParams attparams;
attparams.m_tex = dstTex;
attparams.m_face = dstFace;
attparams.m_mip = dstMip;
attparams.m_zslice = 0;
m_blitDrawFBO->TexAttach( &attparams, attachIndex, GL_DRAW_FRAMEBUFFER_EXT );
m_blitDrawFBO->TexAttach( &attparams, attachIndex, GL_DRAW_FRAMEBUFFER );
gGL->glDrawBuffer( attachIndexGL );
@ -1509,10 +1503,10 @@ void GLMContext::BlitTex( CGLMTex *srcTex, GLMRect *srcRect, int srcFace, int sr
// unset the write fb and buffer, detach write tex
m_blitDrawFBO->TexDetach( attachIndex, GL_DRAW_FRAMEBUFFER_EXT );
m_blitDrawFBO->TexDetach( attachIndex, GL_DRAW_FRAMEBUFFER );
// put the original FB back in place (both read and draw)
BindFBOToCtx( m_drawingFBO, GL_FRAMEBUFFER_EXT );
BindFBOToCtx( m_drawingFBO, GL_FRAMEBUFFER );
}
while(pushed)
@ -1563,19 +1557,19 @@ void GLMContext::ResolveTex( CGLMTex *tex, bool forceDirty )
// case GL_LUMINANCE:
// case GL_LUMINANCE_ALPHA:
attachIndex = kAttColor0;
attachIndexGL = GL_COLOR_ATTACHMENT0_EXT;
attachIndexGL = GL_COLOR_ATTACHMENT0;
blitMask = GL_COLOR_BUFFER_BIT;
break;
// case GL_DEPTH_COMPONENT:
// attachIndex = kAttDepth;
// attachIndexGL = GL_DEPTH_ATTACHMENT_EXT;
// attachIndexGL = GL_DEPTH_ATTACHMENT;
// blitMask = GL_DEPTH_BUFFER_BIT;
// break;
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH_STENCIL:
attachIndex = kAttDepthStencil;
attachIndexGL = GL_DEPTH_STENCIL_ATTACHMENT_EXT;
attachIndexGL = GL_DEPTH_STENCIL_ATTACHMENT;
blitMask = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
break;
@ -1586,35 +1580,35 @@ void GLMContext::ResolveTex( CGLMTex *tex, bool forceDirty )
// set the read fb, attach read RBO at appropriate attach point, set read buffer
BindFBOToCtx( m_blitReadFBO, GL_READ_FRAMEBUFFER_EXT );
BindFBOToCtx( m_blitReadFBO, GL_READ_FRAMEBUFFER );
// going to avoid the TexAttach / TexDetach calls due to potential confusion, implement it directly here
//-----------------------------------------------------------------------------------
// put tex->m_rboName on the read FB's attachment
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT)
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT)
{
// you have to attach it both places...
// http://www.opengl.org/wiki/GL_EXT_framebuffer_object
// bind the RBO to the GL_RENDERBUFFER_EXT target - is this extraneous ?
//glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, tex->m_rboName );
// bind the RBO to the GL_RENDERBUFFER target - is this extraneous ?
//glBindRenderbufferEXT( GL_RENDERBUFFER, tex->m_rboName );
// attach the GL_RENDERBUFFER_EXT target to the depth and stencil attach points
gGL->glFramebufferRenderbufferEXT( GL_READ_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, tex->m_rboName);
// attach the GL_RENDERBUFFER target to the depth and stencil attach points
gGL->glFramebufferRenderbuffer( GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, tex->m_rboName);
gGL->glFramebufferRenderbufferEXT( GL_READ_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, tex->m_rboName);
gGL->glFramebufferRenderbuffer( GL_READ_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, tex->m_rboName);
// no need to leave the RBO hanging on
//glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 );
//glBindRenderbufferEXT( GL_RENDERBUFFER, 0 );
}
else
{
//glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, tex->m_rboName );
//glBindRenderbufferEXT( GL_RENDERBUFFER, tex->m_rboName );
gGL->glFramebufferRenderbufferEXT( GL_READ_FRAMEBUFFER_EXT, attachIndexGL, GL_RENDERBUFFER_EXT, tex->m_rboName);
gGL->glFramebufferRenderbuffer( GL_READ_FRAMEBUFFER, attachIndexGL, GL_RENDERBUFFER, tex->m_rboName);
//glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 );
//glBindRenderbufferEXT( GL_RENDERBUFFER, 0 );
}
gGL->glReadBuffer( attachIndexGL );
@ -1623,19 +1617,19 @@ void GLMContext::ResolveTex( CGLMTex *tex, bool forceDirty )
// put tex->m_texName on the draw FBO attachment
// set the write fb and buffer, and attach write tex
BindFBOToCtx( m_blitDrawFBO, GL_DRAW_FRAMEBUFFER_EXT );
BindFBOToCtx( m_blitDrawFBO, GL_DRAW_FRAMEBUFFER );
// regular path - attaching a texture2d
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT)
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT)
{
gGL->glFramebufferTexture2DEXT( GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, tex->m_texName, 0 );
gGL->glFramebufferTexture2D( GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex->m_texName, 0 );
gGL->glFramebufferTexture2DEXT( GL_DRAW_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, tex->m_texName, 0 );
gGL->glFramebufferTexture2D( GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, tex->m_texName, 0 );
}
else
{
gGL->glFramebufferTexture2DEXT( GL_DRAW_FRAMEBUFFER_EXT, attachIndexGL, GL_TEXTURE_2D, tex->m_texName, 0 );
gGL->glFramebufferTexture2D( GL_DRAW_FRAMEBUFFER, attachIndexGL, GL_TEXTURE_2D, tex->m_texName, 0 );
}
gGL->glDrawBuffer( attachIndexGL );
@ -1643,7 +1637,7 @@ void GLMContext::ResolveTex( CGLMTex *tex, bool forceDirty )
//-----------------------------------------------------------------------------------
// blit
gGL->glBlitFramebufferEXT( 0, 0, tex->m_layout->m_key.m_xSize, tex->m_layout->m_key.m_ySize,
gGL->glBlitFramebuffer( 0, 0, tex->m_layout->m_key.m_xSize, tex->m_layout->m_key.m_ySize,
0, 0, tex->m_layout->m_key.m_xSize, tex->m_layout->m_key.m_ySize,
blitMask, GL_NEAREST );
// or should it be GL_LINEAR? does it matter ?
@ -1654,38 +1648,37 @@ void GLMContext::ResolveTex( CGLMTex *tex, bool forceDirty )
// unset the read fb and buffer, detach read RBO
//glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, 0 );
//glBindRenderbufferEXT( GL_RENDERBUFFER, 0 );
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT)
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT)
{
// detach the GL_RENDERBUFFER_EXT target from the depth and stencil attach points
gGL->glFramebufferRenderbufferEXT( GL_READ_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
gGL->glFramebufferRenderbufferEXT( GL_READ_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
// detach the GL_RENDERBUFFER target from the depth and stencil attach points
gGL->glFramebufferRenderbuffer( GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
gGL->glFramebufferRenderbuffer( GL_READ_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
}
else
{
gGL->glFramebufferRenderbufferEXT( GL_READ_FRAMEBUFFER_EXT, attachIndexGL, GL_RENDERBUFFER_EXT, 0);
gGL->glFramebufferRenderbuffer( GL_READ_FRAMEBUFFER, attachIndexGL, GL_RENDERBUFFER, 0);
}
//-----------------------------------------------------------------------------------
// unset the write fb and buffer, detach write tex
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT_EXT)
if (attachIndexGL==GL_DEPTH_STENCIL_ATTACHMENT)
{
gGL->glFramebufferTexture2DEXT( GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0 );
gGL->glFramebufferTexture2D( GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0 );
gGL->glFramebufferTexture2DEXT( GL_DRAW_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0 );
gGL->glFramebufferTexture2D( GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0 );
}
else
{
gGL->glFramebufferTexture2DEXT( GL_DRAW_FRAMEBUFFER_EXT, attachIndexGL, GL_TEXTURE_2D, 0, 0 );
gGL->glFramebufferTexture2D( GL_DRAW_FRAMEBUFFER, attachIndexGL, GL_TEXTURE_2D, 0, 0 );
}
// put the original FB back in place (both read and draw)
// this bind will hit both read and draw bindings
BindFBOToCtx( m_drawingFBO, GL_FRAMEBUFFER_EXT );
BindFBOToCtx( m_drawingFBO, GL_FRAMEBUFFER );
// set the read and write buffers back to... what ? does it matter for anything but copies ? don't worry about it
@ -1740,9 +1733,7 @@ void GLMContext::PreloadTex( CGLMTex *tex, bool force )
if ( !preloadPair->m_valid )
{
if ( !preloadPair->ValidateProgramPair() )
{
return;
}
}
gGL->glUseProgram( (GLuint)preloadPair->m_program );
@ -1795,7 +1786,7 @@ void GLMContext::PreloadTex( CGLMTex *tex, bool force )
gGL->glVertexAttribPointer( 0, 3, GL_FLOAT, 0, 0, posns );
gGL->glDrawRangeElements( GL_TRIANGLES, 0, 3, 3, GL_UNSIGNED_INT, indices);
gGL->glDrawRangeElements( GL_TRIANGLES, 0, 2, 3, GL_UNSIGNED_INT, indices);
gGL->glDisableVertexAttribArray( 0 );
@ -1830,13 +1821,13 @@ void GLMContext::DelFBO( CGLMFBO *fbo )
if (m_boundReadFBO == fbo )
{
BindFBOToCtx( NULL, GL_READ_FRAMEBUFFER_EXT );
BindFBOToCtx( NULL, GL_READ_FRAMEBUFFER );
m_boundReadFBO = NULL;
}
if (m_boundDrawFBO == fbo )
{
BindFBOToCtx( NULL, GL_DRAW_FRAMEBUFFER_EXT );
BindFBOToCtx( NULL, GL_DRAW_FRAMEBUFFER );
m_boundDrawFBO = NULL;
}
@ -2272,47 +2263,17 @@ void GLMContext::Present( CGLMTex *tex )
ProcessTextureDeletes();
#ifdef HAVE_GL_ARB_SYNC
if ( gGL->m_bHave_GL_AMD_pinned_memory )
{
m_PinnedMemoryBuffers[m_nCurPinnedMemoryBuffer].InsertFence();
m_nCurPinnedMemoryBuffer = ( m_nCurPinnedMemoryBuffer + 1 ) % cNumPinnedMemoryBuffers;
m_PinnedMemoryBuffers[m_nCurPinnedMemoryBuffer].BlockUntilNotBusy();
gGL->glBindBufferARB( GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, m_PinnedMemoryBuffers[m_nCurPinnedMemoryBuffer].GetHandle() );
}
if ( gGL->m_bHave_GL_ARB_buffer_storage )
{
for (uint lpType = 0; lpType < kGLMNumBufferTypes; ++lpType)
{
m_persistentBuffer[m_nCurPersistentBuffer][lpType].InsertFence();
}
m_nCurPersistentBuffer = ( m_nCurPersistentBuffer + 1 ) % cNumPersistentBuffers;
for (uint lpType = 0; lpType < kGLMNumBufferTypes; ++lpType)
{
m_persistentBuffer[m_nCurPersistentBuffer][lpType].BlockUntilNotBusy();
}
}
#endif // HAVE_GL_ARB_SYNC
bool newRefreshMode = false;
// two ways to go:
// old school, do the resolve, had the tex down to cocoamgr to actually blit.
// that way is required if you are not in one-context mode (10.5.8)
if ( (gl_blitmode.GetInt() != 0) )
{
newRefreshMode = true;
}
// this is the path whether full screen or windowed... we always blit.
CShowPixelsParams showparams;
memset( &showparams, 0, sizeof(showparams) );
@ -2378,13 +2339,13 @@ void GLMContext::Present( CGLMTex *tex )
// we set showparams.m_noBlit, and just let CocoaMgr handle the swap (flushbuffer / page flip)
showparams.m_noBlit = true;
BindFBOToCtx( NULL, GL_FRAMEBUFFER_EXT );
BindFBOToCtx( NULL, GL_FRAMEBUFFER );
}
else
{
ResolveTex( tex, true ); // dxabstract used to do this unconditionally.we still do if new refresh mode doesn't engage.
BindFBOToCtx( NULL, GL_FRAMEBUFFER_EXT );
BindFBOToCtx( NULL, GL_FRAMEBUFFER );
// showparams.m_noBlit is left set to 0. CocoaMgr does the blit.
}
@ -2394,7 +2355,7 @@ void GLMContext::Present( CGLMTex *tex )
// put the original FB back in place (both read and draw)
// this bind will hit both read and draw bindings
BindFBOToCtx( m_drawingFBO, GL_FRAMEBUFFER_EXT );
BindFBOToCtx( m_drawingFBO, GL_FRAMEBUFFER );
// put em back !!
m_ScissorEnable.Flush();
@ -2490,19 +2451,6 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params )
ClearCurAttribs();
#ifndef OSX
m_nCurPinnedMemoryBuffer = 0;
if ( gGL->m_bHave_GL_AMD_pinned_memory )
{
for ( uint t = 0; t < cNumPinnedMemoryBuffers; t++ )
{
m_PinnedMemoryBuffers[t].Init( GLMGR_PINNED_MEMORY_BUFFER_SIZE );
}
gGL->glBindBufferARB( GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, m_PinnedMemoryBuffers[m_nCurPinnedMemoryBuffer].GetHandle() );
}
#endif // OSX
m_nCurPersistentBuffer = 0;
if ( gGL->m_bHave_GL_ARB_buffer_storage )
{
@ -2569,9 +2517,9 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params )
IncrementWindowRefCount();
// If we're using GL_ARB_debug_output, go ahead and setup the callback here.
if ( gGL->m_bHave_GL_ARB_debug_output && CommandLine()->FindParm( "-gl_debug" ) )
if ( CommandLine()->FindParm( "-gl_debug" ) )
{
#if GLMDEBUG
//#if GLMDEBUG
// Turning this on is a perf loss, but it ensures that you can (at least) swap to the other
// threads to see what call is currently being made.
// Note that if the driver is in multithreaded mode, you can put it back into singlethreaded mode
@ -2585,16 +2533,16 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params )
printf( "GLMContext::GLMContext: GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB enabled!\n" );
#endif
#endif
// TODO(nillerusr): rewrite me!!!
// This should be there if we get in here--make sure.
Assert(gGL->glDebugMessageControlARB);
gGL->glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, (const GLuint *)NULL, GL_TRUE);
gGL->glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, (const GLuint *)NULL, GL_TRUE);
// Gonna filter these out, they're "chatty".
gGL->glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB, GL_DEBUG_TYPE_OTHER_ARB, GL_DEBUG_SEVERITY_LOW_ARB, 0, (const GLuint *)NULL, GL_FALSE);
gGL->glDebugMessageCallbackARB(GL_Debug_Output_Callback, (void*)NULL);
gGL->glDebugMessageControl(GL_DEBUG_SOURCE_API_ARB, GL_DEBUG_TYPE_OTHER_ARB, GL_DEBUG_SEVERITY_LOW_ARB, 0, (const GLuint *)NULL, GL_FALSE);
gGL->glDebugMessageCallback(GL_Debug_Output_Callback, (void*)NULL);
GLMDebugPrintf( "GLMContext::GLMContext: Debug output (gl_arb_debug_output) enabled!\n" );
//#endif
}
@ -2741,10 +2689,10 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params )
// Create a PBO that we can use to fill textures with bogus data asyncronously.
m_nBoundGLBuffer[ kGLMPixelBuffer ] = 0;
gGL->glGenBuffersARB( 1, &m_destroyPBO );
gGL->glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, m_destroyPBO );
gGL->glBufferDataARB( GL_PIXEL_UNPACK_BUFFER_ARB, sizeof( g_garbageTextureBits ), g_garbageTextureBits, GL_STATIC_DRAW );
gGL->glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, m_nBoundGLBuffer[ kGLMPixelBuffer ] );
gGL->glGenBuffers( 1, &m_destroyPBO );
gGL->glBindBuffer( GL_PIXEL_UNPACK_BUFFER, m_destroyPBO );
gGL->glBufferData( GL_PIXEL_UNPACK_BUFFER, sizeof( g_garbageTextureBits ), g_garbageTextureBits, GL_STATIC_DRAW );
gGL->glBindBuffer( GL_PIXEL_UNPACK_BUFFER, m_nBoundGLBuffer[ kGLMPixelBuffer ] );
// Create a bunch of texture names for us to use forever and ever ramen.
FillTexCache( false, kGLMInitialTexCount );
@ -2842,40 +2790,6 @@ void GLMContext::Reset()
GLMContext::~GLMContext ()
{
#ifndef OSX
GLMGPUTimestampManagerDeinit();
for ( uint t = 0; t < cNumPinnedMemoryBuffers; t++ )
{
m_PinnedMemoryBuffers[t].Deinit();
}
if (gGL->m_bHave_GL_ARB_buffer_storage)
{
for (uint lpType = 0; lpType < kGLMNumBufferTypes; ++lpType)
{
for (uint lpNum = 0; lpNum < cNumPersistentBuffers; ++lpNum)
{
m_persistentBuffer[lpNum][lpType].Deinit();
}
}
}
if ( m_bUseSamplerObjects )
{
for( int i=0; i< GLM_SAMPLER_COUNT; i++)
{
gGL->glBindSampler( i, 0 );
}
for( int i=0; i< cSamplerObjectHashSize; i++)
{
gGL->glDeleteSamplers( 1, &m_samplerObjectHash[i].m_samplerObject );
m_samplerObjectHash[i].m_samplerObject = 0;
}
}
#endif // !OSX
if (m_debugFontTex)
{
DelTex( m_debugFontTex );
@ -2908,7 +2822,7 @@ GLMContext::~GLMContext ()
// m_texLayoutTable can be scrubbed once we know that all the tex are freed
gGL->glDeleteBuffersARB( 1, &m_destroyPBO );
gGL->glDeleteBuffers( 1, &m_destroyPBO );
PurgeTexCache();
@ -2958,29 +2872,29 @@ void GLMContext::BindFBOToCtx( CGLMFBO *fbo, GLenum bindPoint )
CheckCurrent();
if ( bindPoint == GL_FRAMEBUFFER_EXT )
if ( bindPoint == GL_FRAMEBUFFER )
{
gGL->glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fbo ? fbo->m_name : 0 );
gGL->glBindFramebuffer( GL_FRAMEBUFFER, fbo ? fbo->m_name : 0 );
m_boundReadFBO = fbo;
m_boundDrawFBO = fbo;
return;
}
bool targetRead = (bindPoint==GL_READ_FRAMEBUFFER_EXT);
bool targetDraw = (bindPoint==GL_DRAW_FRAMEBUFFER_EXT);
bool targetRead = (bindPoint==GL_READ_FRAMEBUFFER);
bool targetDraw = (bindPoint==GL_DRAW_FRAMEBUFFER);
if (targetRead)
{
if (fbo) // you can pass NULL to go back to no-FBO
{
gGL->glBindFramebufferEXT( GL_READ_FRAMEBUFFER_EXT, fbo->m_name );
gGL->glBindFramebuffer( GL_READ_FRAMEBUFFER, fbo->m_name );
m_boundReadFBO = fbo;
//dontcare fbo->m_bound = true;
}
else
{
gGL->glBindFramebufferEXT( GL_READ_FRAMEBUFFER_EXT, 0 );
gGL->glBindFramebuffer( GL_READ_FRAMEBUFFER, 0 );
m_boundReadFBO = NULL;
}
@ -2990,14 +2904,14 @@ void GLMContext::BindFBOToCtx( CGLMFBO *fbo, GLenum bindPoint )
{
if (fbo) // you can pass NULL to go back to no-FBO
{
gGL->glBindFramebufferEXT( GL_DRAW_FRAMEBUFFER_EXT, fbo->m_name );
gGL->glBindFramebuffer( GL_DRAW_FRAMEBUFFER, fbo->m_name );
m_boundDrawFBO = fbo;
//dontcare fbo->m_bound = true;
}
else
{
gGL->glBindFramebufferEXT( GL_DRAW_FRAMEBUFFER_EXT, 0 );
gGL->glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 );
m_boundDrawFBO = NULL;
}
@ -3023,17 +2937,17 @@ void GLMContext::BindBufferToCtx( EGLMBufferType type, CGLMBuffer *pBuff, bool b
GLenum target = 0;
switch( type )
{
case kGLMVertexBuffer: target = GL_ARRAY_BUFFER_ARB; break;
case kGLMIndexBuffer: target = GL_ELEMENT_ARRAY_BUFFER_ARB; break;
case kGLMUniformBuffer: target = GL_UNIFORM_BUFFER_EXT; break;
case kGLMPixelBuffer: target = GL_PIXEL_UNPACK_BUFFER_ARB; break;
case kGLMVertexBuffer: target = GL_ARRAY_BUFFER; break;
case kGLMIndexBuffer: target = GL_ELEMENT_ARRAY_BUFFER; break;
case kGLMUniformBuffer: target = GL_UNIFORM_BUFFER; break;
case kGLMPixelBuffer: target = GL_PIXEL_UNPACK_BUFFER; break;
default: Assert(!"Unknown buffer type" );
}
Assert( !pBuff || ( pBuff->m_buffGLTarget == target ) );
m_nBoundGLBuffer[type] = nGLName;
gGL->glBindBufferARB( target, nGLName );
gGL->glBindBuffer( target, nGLName );
}
@ -3079,7 +2993,7 @@ void GLMContext::CleanupTex( GLenum texBind, GLMTexLayout* pLayout, GLuint tex )
const GLuint oldPBO = m_nBoundGLBuffer[ kGLMPixelBuffer ];
const GLuint oldTex = ( m_samplers[ m_activeTexture ].m_pBoundTex != NULL ) ? m_samplers[ m_activeTexture ].m_pBoundTex->GetTexName() : 0;
gGL->glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, m_destroyPBO );
gGL->glBindBuffer( GL_PIXEL_UNPACK_BUFFER, m_destroyPBO );
gGL->glBindTexture( texBind, tex );
// Clear out old data.
@ -3101,7 +3015,7 @@ void GLMContext::CleanupTex( GLenum texBind, GLMTexLayout* pLayout, GLuint tex )
}
gGL->glBindTexture( texBind, oldTex );
gGL->glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, oldPBO );
gGL->glBindBuffer( GL_PIXEL_UNPACK_BUFFER, oldPBO );
}
void GLMContext::DestroyTex( GLenum texBind, GLMTexLayout* pLayout, GLuint tex )
@ -5366,7 +5280,7 @@ void GLMTester::StdSetup( void )
InternalError( !ready, "drawing FBO no go");
// bind it
ctx->BindFBOToCtx( m_drawFBO, GL_FRAMEBUFFER_EXT );
ctx->BindFBOToCtx( m_drawFBO, GL_FRAMEBUFFER );
gGL->glViewport(0, 0, (GLsizei) m_drawWidth, (GLsizei) m_drawHeight );
CheckGLError("stdsetup viewport");
@ -5386,7 +5300,7 @@ void GLMTester::StdCleanup( void )
GLMContext *ctx = m_params.m_ctx;
// unbind
ctx->BindFBOToCtx( NULL, GL_FRAMEBUFFER_EXT );
ctx->BindFBOToCtx( NULL, GL_FRAMEBUFFER );
// del FBO
if (m_drawFBO)
@ -5456,10 +5370,10 @@ return;
const char *decodedStr = GLMDecode( eGL_ERROR, errorcode );
const char *decodedStr2 = "";
if ( errorcode == GL_INVALID_FRAMEBUFFER_OPERATION_EXT )
if ( errorcode == GL_INVALID_FRAMEBUFFER_OPERATION )
{
// dig up the more detailed FBO status
errorcode2 = gGL->glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
errorcode2 = gGL->glCheckFramebufferStatus( GL_FRAMEBUFFER );
decodedStr2 = GLMDecode( eGL_ERROR, errorcode2 );
@ -5904,7 +5818,7 @@ void GLMTester::Test1( void )
printf("\n -> %s\n", ready ? "pass" : "fail" );
// unbind
ctx->BindFBOToCtx( NULL, GL_FRAMEBUFFER_EXT );
ctx->BindFBOToCtx( NULL, GL_FRAMEBUFFER );
// del FBO
ctx->DelFBO(fbo);

View File

@ -26,7 +26,7 @@
//
//===============================================================================
#include "togl/rendermechanism.h"
#include "togles/rendermechanism.h"
#include "tier0/icommandline.h"
#include "tier1/utlhash.h"

View File

@ -19,7 +19,7 @@
#include "tier1/interface.h"
#include "tier1/strtools.h"
#include "tier1/utllinkedlist.h"
#include "togl/rendermechanism.h"
#include "togles/rendermechanism.h"

21
wscript
View File

@ -65,7 +65,6 @@ projects={
'tier1',
'tier2',
'tier3',
'togl',
'vgui2/matsys_controls',
'vgui2/src',
'vgui2/vgui_controls',
@ -136,6 +135,8 @@ def get_taskgen_count(self):
def define_platform(conf):
conf.env.DEDICATED = conf.options.DEDICATED
conf.env.TOGLES = conf.options.TOGLES
conf.env.GL = conf.options.GL
if conf.options.DEDICATED:
conf.options.SDL = False
@ -149,6 +150,10 @@ def define_platform(conf):
'BINK_VIDEO'
])
if conf.options.TOGLES:
conf.env.append_unique('DEFINES', ['TOGLES'])
if conf.options.SDL:
conf.define('USE_SDL', 1)
@ -205,6 +210,9 @@ def options(opt):
grp.add_option('--use-ccache', action = 'store_true', dest = 'CCACHE', default = False,
help = 'build using ccache [default: %default]')
grp.add_option('--togles', action = 'store_true', dest = 'TOGLES', default = False,
help = 'build engine with ToGLES [default: %default]')
opt.load('compiler_optimizations subproject')
# opt.add_subproject(projects['game'])
@ -228,6 +236,12 @@ def configure(conf):
define_platform(conf)
if conf.env.TOGLES:
projects['game'] += ['togles']
elif conf.env.GL:
projects['game'] += ['togl']
if conf.env.DEST_OS in ['win32', 'linux', 'darwin'] and conf.env.DEST_CPU == 'x86_64':
conf.env.BIT32_MANDATORY = not conf.options.ALLOW64
if conf.env.BIT32_MANDATORY:
@ -396,4 +410,9 @@ def build(bld):
if bld.env.DEDICATED:
bld.add_subproject(projects['dedicated'])
else:
if bld.env.TOGLES:
projects['game'] += ['togles']
elif bld.env.GL:
projects['game'] += ['togl']
bld.add_subproject(projects['game'])