1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-09-19 03:56:10 +08:00

* Added support for building shaders in your mod

* Added nav mesh support
* fixed many warnings and misc bugs
* Fixed the create*projects scripts in mp
* Added a bunch of stuff to .gitignore
This commit is contained in:
Joe Ludwig
2013-07-17 18:26:59 -07:00
parent 64f3b0abed
commit 0e42951d44
210 changed files with 27490 additions and 1351 deletions

View File

@ -10,7 +10,7 @@
#pragma once
#endif
#if defined( USE_SDL ) || defined( OSX )
#if defined( USE_SDL )
#include "tier0/threadtools.h"
#include "appframework/IAppSystem.h"
@ -29,18 +29,12 @@ class CShowPixelsParams;
#endif
// if you rev this version also update materialsystem/cmaterialsystem.cpp CMaterialSystem::Connect as it defines the string directly
#if defined( USE_SDL )
#define SDLMGR_INTERFACE_VERSION "SDLMgrInterface001"
#elif defined( OSX )
#define COCOAMGR_INTERFACE_VERSION "CocoaMgrInterface006"
#endif
#define SDLMGR_INTERFACE_VERSION "SDLMgrInterface001"
class CCocoaEvent;
class CStackCrawlParams;
#if defined( USE_SDL )
typedef struct SDL_Cursor SDL_Cursor;
#endif
class ILauncherMgr : public IAppSystem
{
@ -103,11 +97,9 @@ public:
virtual void *GetWindowRef() = 0;
virtual void SetMouseVisible( bool bState ) = 0;
#ifdef USE_SDL
virtual void SetMouseCursor( SDL_Cursor *hCursor ) = 0;
virtual void SetForbidMouseGrab( bool bForbidMouseGrab ) = 0;
virtual void OnFrameRendered() = 0;
#endif
virtual void SetGammaRamp( const uint16 *pRed, const uint16 *pGreen, const uint16 *pBlue ) = 0;
@ -163,6 +155,6 @@ public:
int m_MouseButton; // which of the CocoaMouseButton_t buttons this is for from above
};
#endif // USE_SDL || OSX
#endif // defined( USE_SDL )
#endif // ILAUNCHERMGR_H

View File

@ -525,7 +525,7 @@ public:
virtual void SetGamestatsData( CGamestatsData *pGamestatsData ) = 0;
virtual CGamestatsData *GetGamestatsData() = 0;
#if defined( USE_SDL ) || defined( OSX )
#if defined( USE_SDL )
// we need to pull delta's from the cocoa mgr, the engine vectors this for us
virtual void GetMouseDelta( int &x, int &y, bool bIgnoreNextMouseDelta = false ) = 0;
#endif

View File

@ -407,6 +407,9 @@ public:
// Server version from the steam.inf, this will be compared to the GC version
virtual int GetServerVersion() const = 0;
// Get sv.GetTime()
virtual float GetServerTime() const = 0;
};

View File

@ -25,7 +25,7 @@ class Vector;
// When used as a duration by a server-side NDebugOverlay:: call,
// causes the overlay to persist until the next server update.
#define NDEBUG_PERSIST_TILL_NEXT_SERVER (0.01023f)
#define NDEBUG_PERSIST_TILL_NEXT_SERVER (0.0f)
class OverlayText_t;

View File

@ -1,84 +0,0 @@
//===== Copyright (c), Valve Corporation, All rights reserved. ======//
//
// Purpose: Contains the IHeadTrack interface, which is implemented in headtrack.dll
//
// $NoKeywords: $
//
//===========================================================================//
#ifndef IHEADTRACK_H
#define IHEADTRACK_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/interface.h"
#include "tier1/refcount.h"
#include "appframework/IAppSystem.h"
#include "mathlib/vmatrix.h"
#include "view_shared.h"
//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// important enumeration
//-----------------------------------------------------------------------------
// NOTE NOTE NOTE!!!! If you up this, grep for "NEW_INTERFACE" to see if there is anything
// waiting to be enabled during an interface revision.
#define HEAD_TRACK_INTERFACE_VERSION "VHeadTrack001"
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
abstract_class IHeadTrack : public IAppSystem
{
public:
virtual ~IHeadTrack() {}
// Placeholder for API revision
virtual bool Connect( CreateInterfaceFn factory ) = 0;
virtual void Disconnect() = 0;
virtual void *QueryInterface( const char *pInterfaceName ) = 0;
virtual InitReturnVal_t Init() = 0;
virtual void Shutdown() = 0;
//-----------------------------------------------------------------------------
// Tracking section
//-----------------------------------------------------------------------------
// All methods return true on success, false on failure.
// Also sets the zero pose
virtual bool ResetTracking() = 0;
// Set the current pose as the "zero"
virtual bool SetCurrentCameraAsZero() = 0;
// Raw interfaces - one one or other of these, not both (GetCameraPoseZeroFromCurrent calls GetCameraFromWorldPose );
virtual bool GetCameraFromWorldPose ( VMatrix *pResultCameraFromWorldPose, VMatrix *pResultCameraFromWorldPoseUnpredicted = NULL, double *pflAcquireTime = NULL ) = 0;
virtual bool GetCameraPoseZeroFromCurrent ( VMatrix *pResultMatrix ) = 0;
// All-in-one interfaces (they call GetCameraPoseZeroFromCurrent)
// Grabs the current tracking data and sets up state for the Override* calls.
virtual bool ProcessCurrentTrackingState ( float PlayerGameFov ) = 0;
// Performs the distortion post-processing.
virtual bool DoDistortionProcessing ( const vrect_t *SrcRect ) = 0;
};
//-----------------------------------------------------------------------------
extern IHeadTrack *g_pHeadTrack;
inline bool UseHeadTracking()
{
return g_pHeadTrack != NULL;
}
#endif // IHEADTRACK_H

View File

@ -32,6 +32,7 @@ enum MaterialSystem_Config_Flags_t
MATSYS_VIDCFG_FLAGS_LIMIT_WINDOWED_SIZE = ( 1 << 13 ),
MATSYS_VIDCFG_FLAGS_SCALE_TO_OUTPUT_RESOLUTION = ( 1 << 14 ),
MATSYS_VIDCFG_FLAGS_USING_MULTIPLE_WINDOWS = ( 1 << 15 ),
MATSYS_VIDCFG_FLAGS_DISABLE_PHONG = ( 1 << 16 ),
};
struct MaterialSystemHardwareIdentifier_t
@ -62,6 +63,7 @@ struct MaterialSystem_Config_t
bool LimitWindowedSize() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_LIMIT_WINDOWED_SIZE ) != 0; }
bool ScaleToOutputResolution() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_SCALE_TO_OUTPUT_RESOLUTION ) != 0; }
bool UsingMultipleWindows() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_USING_MULTIPLE_WINDOWS ) != 0; }
bool UsePhong() const { return ( m_Flags & MATSYS_VIDCFG_FLAGS_DISABLE_PHONG ) == 0; }
bool ShadowDepthTexture() const { return m_bShadowDepthTexture; }
bool MotionBlur() const { return m_bMotionBlur; }
bool SupportFlashlight() const { return m_bSupportFlashlight; }
@ -157,6 +159,7 @@ struct MaterialSystem_Config_t
SetFlag( MATSYS_VIDCFG_FLAGS_LIMIT_WINDOWED_SIZE, false );
SetFlag( MATSYS_VIDCFG_FLAGS_SCALE_TO_OUTPUT_RESOLUTION, false );
SetFlag( MATSYS_VIDCFG_FLAGS_USING_MULTIPLE_WINDOWS, false );
SetFlag( MATSYS_VIDCFG_FLAGS_DISABLE_PHONG, false );
m_VideoMode.m_Width = 640;
m_VideoMode.m_Height = 480;

View File

@ -97,7 +97,9 @@ private:
#ifdef DEBUG // stop crashing edit-and-continue
FORCEINLINE float clamp( float val, float minVal, float maxVal )
{
if( val < minVal )
if ( maxVal < minVal )
return maxVal;
else if( val < minVal )
return minVal;
else if( val > maxVal )
return maxVal;
@ -115,8 +117,8 @@ FORCEINLINE float clamp( float val, float minVal, float maxVal )
_mm_load_ss(&minVal) ),
_mm_load_ss(&maxVal) ) );
#else
val = fpmin(maxVal, val);
val = fpmax(minVal, val);
val = fpmin(maxVal, val);
#endif
return val;
}
@ -128,7 +130,9 @@ FORCEINLINE float clamp( float val, float minVal, float maxVal )
template< class T >
inline T clamp( T const &val, T const &minVal, T const &maxVal )
{
if( val < minVal )
if ( maxVal < minVal )
return maxVal;
else if( val < minVal )
return minVal;
else if( val > maxVal )
return maxVal;
@ -2172,9 +2176,9 @@ bool AlmostEqual(float a, float b, int maxUlps = 10);
inline bool AlmostEqual( const Vector &a, const Vector &b, int maxUlps = 10)
{
return AlmostEqual( a.x, a.x, maxUlps ) &&
AlmostEqual( a.y, a.y, maxUlps ) &&
AlmostEqual( a.z, a.z, maxUlps );
return AlmostEqual( a.x, b.x, maxUlps ) &&
AlmostEqual( a.y, b.y, maxUlps ) &&
AlmostEqual( a.z, b.z, maxUlps );
}

View File

@ -226,7 +226,7 @@ struct FileHeader_t
int maxBonesPerVert;
// must match checkSum in the .mdl
long checkSum;
int checkSum;
int numLODs; // garymcthack - this is also specified in ModelHeader_t and should match

View File

@ -26,6 +26,7 @@ enum RenderParamVector_t
VECTOR_RENDERPARM_HMDWARP_GROW_OUTIN,
VECTOR_RENDERPARM_HMDWARP_GROW_ABOVEBELOW,
VECTOR_RENDERPARM_HMDWARP_ASPECT,
INT_RENDERPARM_DISTORTION_TYPE,
MAX_VECTOR_RENDER_PARMS = 20
};

View File

@ -512,8 +512,8 @@ inline bool CSteamAPIContext::Init()
#if defined(USE_BREAKPAD_HANDLER) || defined(STEAM_API_EXPORTS)
// this should be called before the game initialized the steam APIs
// pchDate should be of the format "Mmm dd yyyy" (such as from the __DATE__ macro )
// pchTime should be of the format "hh:mm:ss" (such as from the __TIME__ macro )
// pchDate should be of the format "Mmm dd yyyy" (such as from the __DATE __ macro )
// pchTime should be of the format "hh:mm:ss" (such as from the __TIME __ macro )
// bFullMemoryDumps (Win32 only) -- writes out a uuid-full.dmp in the client/dumps folder
// pvContext-- can be NULL, will be the void * context passed into m_pfnPreMinidumpCallback
// PFNPreMinidumpCallback m_pfnPreMinidumpCallback -- optional callback which occurs just before a .dmp file is written during a crash. Applications can hook this to allow adding additional information into the .dmp comment stream.

View File

@ -1816,7 +1816,7 @@ struct vertexFileHeader_t
DECLARE_BYTESWAP_DATADESC();
int id; // MODEL_VERTEX_FILE_ID
int version; // MODEL_VERTEX_FILE_VERSION
long checksum; // same as studiohdr_t, ensures sync
int checksum; // same as studiohdr_t, ensures sync
int numLODs; // num of valid lods
int numLODVertexes[MAX_NUM_LODS]; // num verts for desired root lod
int numFixups; // num of vertexFileFixup_t
@ -1991,7 +1991,7 @@ struct studiohdr_t
int id;
int version;
long checksum; // this has to be the same in the phy and vtx files to load!
int checksum; // this has to be the same in the phy and vtx files to load!
inline const char * pszName( void ) const { if (studiohdr2index && pStudioHdr2()->pszName()) return pStudioHdr2()->pszName(); else return name; }
char name[64];

View File

@ -572,4 +572,23 @@ void virtualmodel_t::AppendIKLocks( int group, const studiohdr_t *pStudioHdr )
}
m_iklock = iklock;
// copy knee directions for uninitialized knees
if ( group != 0 )
{
studiohdr_t *pBaseHdr = (studiohdr_t *)m_group[ 0 ].GetStudioHdr();
if ( pStudioHdr->numikchains == pBaseHdr->numikchains )
{
for (j = 0; j < pStudioHdr->numikchains; j++)
{
if ( pBaseHdr->pIKChain( j )->pLink(0)->kneeDir.LengthSqr() == 0.0f )
{
if ( pStudioHdr->pIKChain( j )->pLink(0)->kneeDir.LengthSqr() > 0.0f )
{
pBaseHdr->pIKChain( j )->pLink(0)->kneeDir = pStudioHdr->pIKChain( j )->pLink(0)->kneeDir;
}
}
}
}
}
}

View File

@ -535,7 +535,7 @@ inline void MemAlloc_GlobalMemoryStatus( size_t *pusedMemory, size_t *pfreeMemor
*pusedMemory = 0;
*pfreeMemory = 0;
}
#define MemAlloc_MemoryAllocFailed() 1
#define MemAlloc_MemoryAllocFailed() 0
#define MemAlloc_GetDebugInfoSize() 0
#define MemAlloc_SaveDebugInfo( pvDebugInfo ) ((void)0)

View File

@ -1085,7 +1085,7 @@ PLATFORM_INTERFACE bool Plat_IsInBenchmarkMode();
PLATFORM_INTERFACE double Plat_FloatTime(); // Returns time in seconds since the module was loaded.
PLATFORM_INTERFACE unsigned long Plat_MSTime(); // Time in milliseconds.
PLATFORM_INTERFACE unsigned int Plat_MSTime(); // Time in milliseconds.
PLATFORM_INTERFACE char * Plat_asctime( const struct tm *tm, char *buf );
PLATFORM_INTERFACE char * Plat_ctime( const time_t *timep, char *buf, size_t bufsize );
PLATFORM_INTERFACE struct tm * Plat_gmtime( const time_t *timep, struct tm *result );

View File

@ -10,7 +10,7 @@
#pragma once
#endif
typedef unsigned long CRC32_t;
typedef unsigned int CRC32_t;
void CRC32_Init( CRC32_t *pulCRC );
void CRC32_ProcessBuffer( CRC32_t *pulCRC, const void *p, int len );

View File

@ -135,7 +135,7 @@ private:
typedef char locchar_t;
#define loc_snprintf Q_snprintf
#define loc_sprintf_safe V_snprintf_safe
#define loc_sprintf_safe V_sprintf_safe
#define loc_sncat Q_strncat
#define loc_scat_safe V_strcat_safe
#define loc_sncpy Q_strncpy
@ -148,7 +148,7 @@ private:
typedef wchar_t locchar_t;
#define loc_snprintf V_snwprintf
#define loc_sprintf_safe V_snwprintf_safe
#define loc_sprintf_safe V_swprintf_safe
#define loc_sncat V_wcsncat
#define loc_scat_safe V_wcscat_safe
#define loc_sncpy Q_wcsncpy

View File

@ -1,4 +1,3 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// LZMA Decoder. Designed for run time decoding.
//

View File

@ -290,7 +290,7 @@ template <size_t maxLenInCharacters> int V_vsprintf_safe( OUT_Z_ARRAY char (&pDe
int V_snprintf( OUT_Z_CAP(maxLenInChars) char *pDest, int maxLenInChars, PRINTF_FORMAT_STRING const char *pFormat, ... ) FMTFUNCTION( 3, 4 );
// gcc insists on only having format annotations on declarations, not definitions, which is why I have both.
template <size_t maxLenInChars> int V_sprintf_safe( OUT_Z_ARRAY char (&pDest)[maxLenInChars], PRINTF_FORMAT_STRING const char *pFormat, ... ) FMTFUNCTION( 2, 3 );
template <size_t maxLenInChars> int V_sprintf_safe( OUT_Z_ARRAY char (&pDest)[maxLenInChars], const char *pFormat, ... )
template <size_t maxLenInChars> int V_sprintf_safe( OUT_Z_ARRAY char (&pDest)[maxLenInChars], PRINTF_FORMAT_STRING const char *pFormat, ... )
{
va_list params;
va_start( params, pFormat );

View File

@ -1350,7 +1350,7 @@ int CUtlRBTree<T, I, L, M>::Depth( I node ) const
int depthright = Depth( RightChild(node) );
int depthleft = Depth( LeftChild(node) );
return max(depthright, depthleft) + 1;
return Max(depthright, depthleft) + 1;
}

7
public/togl/glfuncs.inl Normal file
View File

@ -0,0 +1,7 @@
#if defined(LINUX) || defined(_WIN32)
#include "togl/linuxwin/glfuncs.h"
#endif
#if defined(OSX)
#include "togl/osx/glfuncs.h"
#endif

View File

@ -0,0 +1,190 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// cglmprogram.h
// GLMgr buffers (index / vertex)
// ... maybe add PBO later as well
//===============================================================================
#ifndef CGLMBUFFER_H
#define CGLMBUFFER_H
#pragma once
//===============================================================================
extern bool g_bUsePseudoBufs;
// forward declarations
class GLMContext;
enum EGLMBufferType
{
kGLMVertexBuffer,
kGLMIndexBuffer,
kGLMUniformBuffer, // for bindable uniform
kGLMPixelBuffer, // for PBO
kGLMNumBufferTypes
};
// pass this in "options" to constructor to make a dynamic buffer
#define GLMBufferOptionDynamic 0x00000001
struct GLMBuffLockParams
{
uint m_nOffset;
uint m_nSize;
bool m_bNoOverwrite;
bool m_bDiscard;
};
#define GL_STATIC_BUFFER_SIZE ( 2048 * 1024 )
#define GL_MAX_STATIC_BUFFERS 2
extern void glBufferSubDataMaxSize( GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data, uint nMaxSizePerCall = 128 * 1024 );
//===============================================================================
#if GL_ENABLE_INDEX_VERIFICATION
struct GLDynamicBuf_t
{
GLenum m_nGLType;
uint m_nHandle;
uint m_nActualBufSize;
uint m_nSize;
uint m_nLockOffset;
uint m_nLockSize;
};
class CGLMBufferSpanManager
{
CGLMBufferSpanManager( const CGLMBufferSpanManager& );
CGLMBufferSpanManager& operator= ( const CGLMBufferSpanManager& );
public:
CGLMBufferSpanManager();
~CGLMBufferSpanManager();
void Init( GLMContext *pContext, EGLMBufferType nBufType, uint nInitialCapacity, uint nBufSize, bool bDynamic );
void Deinit();
inline GLMContext *GetContext() const { return m_pCtx; }
inline GLenum GetGLBufType() const { return ( m_nBufType == kGLMVertexBuffer ) ? GL_ARRAY_BUFFER_ARB : GL_ELEMENT_ARRAY_BUFFER_ARB; }
struct ActiveSpan_t
{
uint m_nStart;
uint m_nEnd;
GLDynamicBuf_t m_buf;
bool m_bOriginalAlloc;
inline ActiveSpan_t() { }
inline ActiveSpan_t( uint nStart, uint nEnd, GLDynamicBuf_t &buf, bool bOriginalAlloc ) : m_nStart( nStart ), m_nEnd( nEnd ), m_buf( buf ), m_bOriginalAlloc( bOriginalAlloc ) { Assert( nStart <= nEnd ); }
};
ActiveSpan_t *AddSpan( uint nOffset, uint nMaxSize, uint nActualSize, bool bDiscard, bool bNoOverwrite );
void DiscardAllSpans();
bool IsValid( uint nOffset, uint nSize ) const;
private:
bool AllocDynamicBuf( uint nSize, GLDynamicBuf_t &buf );
void ReleaseDynamicBuf( GLDynamicBuf_t &buf );
GLMContext *m_pCtx;
EGLMBufferType m_nBufType;
uint m_nBufSize;
bool m_bDynamic;
CUtlVector<ActiveSpan_t> m_ActiveSpans;
CUtlVector<ActiveSpan_t> m_DeletedSpans;
int m_nSpanEndMax;
int m_nNumAllocatedBufs;
int m_nTotalBytesAllocated;
};
#endif // GL_ENABLE_INDEX_VERIFICATION
class CGLMBuffer
{
public:
void Lock( GLMBuffLockParams *pParams, char **pAddressOut );
void Unlock( int nActualSize = -1, const void *pActualData = NULL );
friend class GLMContext; // only GLMContext can make CGLMBuffer objects
friend class GLMTester;
friend struct IDirect3D9;
friend struct IDirect3DDevice9;
CGLMBuffer( GLMContext *pCtx, EGLMBufferType type, uint size, uint options );
~CGLMBuffer();
void SetModes( bool bAsyncMap, bool bExplicitFlush, bool bForce = false );
void FlushRange( uint offset, uint size );
#if GL_ENABLE_INDEX_VERIFICATION
bool IsSpanValid( uint nOffset, uint nSize ) const;
#endif
GLMContext *m_pCtx; // link back to parent context
EGLMBufferType m_type;
uint m_nSize;
uint m_nActualSize;
bool m_bDynamic;
GLenum m_buffGLTarget; // GL_ARRAY_BUFFER_ARB / GL_ELEMENT_BUFFER_ARB
GLuint m_nHandle; // name of this program in the context
uint m_nRevision; // bump anytime the size changes or buffer is orphaned
bool m_bEnableAsyncMap; // mirror of the buffer state
bool m_bEnableExplicitFlush; // mirror of the buffer state
bool m_bMapped; // is it currently mapped
uint m_dirtyMinOffset; // when equal, range is empty
uint m_dirtyMaxOffset;
float *m_pLastMappedAddress;
int m_nPinnedMemoryOfs;
bool m_bPseudo; // true if the m_name is 0, and the backing is plain RAM
// in pseudo mode, there is just one RAM buffer that acts as the backing.
// expectation is that this mode would only be used for dynamic indices.
// since indices have to be consumed (copied to command stream) prior to return from a drawing call,
// there's no need to do any fencing or multibuffering. orphaning in particular becomes a no-op.
char *m_pActualPseudoBuf; // storage for pseudo buffer
char *m_pPseudoBuf; // storage for pseudo buffer
char *m_pStaticBuffer;
GLMBuffLockParams m_LockParams;
static char ALIGN16 m_StaticBuffers[ GL_MAX_STATIC_BUFFERS ][ GL_STATIC_BUFFER_SIZE ] ALIGN16_POST;
static bool m_bStaticBufferUsed[ GL_MAX_STATIC_BUFFERS ];
#if GL_ENABLE_INDEX_VERIFICATION
CGLMBufferSpanManager m_BufferSpanManager;
#endif
#if GL_ENABLE_UNLOCK_BUFFER_OVERWRITE_DETECTION
uint m_nDirtyRangeStart;
uint m_nDirtyRangeEnd;
#endif
};
#endif // CGLMBUFFER_H

View File

@ -0,0 +1,82 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// cglmfbo.h
// GLMgr FBO's (render targets)
//
//===============================================================================
#ifndef CGLMFBO_H
#define CGLMFBO_H
#pragma once
// good FBO references / recaps
// http://www.songho.ca/opengl/gl_fbo.html
// http://www.gamedev.net/reference/articles/article2331.asp
// ext links
// http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt
// http://www.opengl.org/registry/specs/EXT/framebuffer_multisample.txt
//===============================================================================
// tokens not in the SDK headers
#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT
#define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9
#endif
//===============================================================================
// forward declarations
class GLMContext;
enum EGLMFBOAttachment
{
kAttColor0, kAttColor1, kAttColor2, kAttColor3,
kAttDepth, kAttStencil, kAttDepthStencil,
kAttCount
};
struct GLMFBOTexAttachParams
{
CGLMTex *m_tex;
int m_face; // keep zero if not cube map
int m_mip; // keep zero if notmip mapped
int m_zslice; // keep zero if not a 3D tex
};
class CGLMFBO
{
friend class GLMContext;
friend class GLMTester;
friend class CGLMTex;
friend struct IDirect3D9;
friend struct IDirect3DDevice9;
public:
CGLMFBO( GLMContext *ctx );
~CGLMFBO( );
protected:
void TexAttach( GLMFBOTexAttachParams *params, EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT );
void TexDetach( EGLMFBOAttachment attachIndex, GLenum fboBindPoint = GL_FRAMEBUFFER_EXT );
// you can also pass GL_READ_FRAMEBUFFER_EXT or GL_DRAW_FRAMEBUFFER_EXT to selectively bind the receiving FBO to one or the other.
void TexScrub( CGLMTex *tex );
// search and destroy any attachment for the named texture
bool IsReady( void ); // aka FBO completeness check - ready to draw
GLMContext *m_ctx; // link back to parent context
GLuint m_name; // name of this FBO in the context
GLMFBOTexAttachParams m_attach[ kAttCount ]; // indexed by EGLMFBOAttachment
};
#endif

View File

@ -0,0 +1,420 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// cglmprogram.h
// GLMgr programs (ARBVP/ARBfp)
//
//===============================================================================
#ifndef CGLMPROGRAM_H
#define CGLMPROGRAM_H
#include <sys/stat.h>
#pragma once
// good ARB program references
// http://petewarden.com/notes/archives/2005/05/fragment_progra_2.html
// http://petewarden.com/notes/archives/2005/06/fragment_progra_3.html
// ext links
// http://www.opengl.org/registry/specs/ARB/vertex_program.txt
// http://www.opengl.org/registry/specs/ARB/fragment_program.txt
// http://www.opengl.org/registry/specs/EXT/gpu_program_parameters.txt
//===============================================================================
// tokens not in the SDK headers
//#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT
// #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9
//#endif
//===============================================================================
// forward declarations
class GLMContext;
class CGLMShaderPair;
class CGLMShaderPairCache;
// CGLMProgram can contain two flavors of the same program, one in assembler, one in GLSL.
// these flavors are pretty different in terms of the API's that are used to activate them -
// for example, assembler programs can just get bound to the context, whereas GLSL programs
// have to be linked. To some extent we try to hide that detail inside GLM.
// for now, make CGLMProgram a container, it does not set policy or hold a preference as to which
// flavor you want to use. GLMContext has to handle that.
enum EGLMProgramType
{
kGLMVertexProgram,
kGLMFragmentProgram,
kGLMNumProgramTypes
};
enum EGLMProgramLang
{
kGLMARB,
kGLMGLSL,
kGLMNumProgramLangs
};
struct GLMShaderDesc
{
union
{
GLuint arb; // ARB program object name
GLhandleARB glsl; // GLSL shader object handle (void*)
} m_object;
// these can change if shader text is edited
bool m_textPresent; // is this flavor(lang) of text present in the buffer?
int m_textOffset; // where is it
int m_textLength; // how big
bool m_compiled; // has this text been through a compile attempt
bool m_valid; // and if so, was the compile successful
int m_slowMark; // has it been flagged during a non native draw batch before. increment every time it's slow.
int m_highWater; // count of vec4's in the major uniform array ("vc" on vs, "pc" on ps)
// written by dxabstract.... gross!
int m_VSHighWaterBone; // count of vec4's in the bone-specific uniform array (only valid for vertex shaders)
};
GLenum GLMProgTypeToARBEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target
GLenum GLMProgTypeToGLSLEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target
#define GL_SHADER_PAIR_CACHE_STATS 0
class CGLMProgram
{
public:
friend class CGLMShaderPairCache;
friend class CGLMShaderPair;
friend class GLMContext; // only GLMContext can make CGLMProgram objects
friend class GLMTester;
friend struct IDirect3D9;
friend struct IDirect3DDevice9;
//===============================
// constructor is very light, it just makes one empty program object per flavor.
CGLMProgram( GLMContext *ctx, EGLMProgramType type );
~CGLMProgram( );
void SetProgramText ( char *text ); // import text to GLM object - invalidate any prev compiled program
void SetShaderName ( const char *name ); // only used for debugging/telemetry markup
bool CompileActiveSources ( void ); // compile only the flavors that were provided.
bool Compile ( EGLMProgramLang lang );
bool CheckValidity ( EGLMProgramLang lang );
void LogSlow ( EGLMProgramLang lang ); // detailed spew when called for first time; one liner or perhaps silence after that
void GetLabelIndexCombo ( char *labelOut, int labelOutMaxChars, int *indexOut, int *comboOut );
void GetComboIndexNameString ( char *stringOut, int stringOutMaxChars ); // mmmmmmmm-nnnnnnnn-filename
#if GLMDEBUG
bool PollForChanges( void ); // check mirror for changes.
void ReloadStringFromEditable( void ); // populate m_string from editable item (react to change)
bool SyncWithEditable( void );
#endif
//===============================
// common stuff
GLMContext *m_ctx; // link back to parent context
EGLMProgramType m_type; // vertex or pixel
uint m_nHashTag; // serial number for hashing
char *m_text; // copy of text passed into constructor. Can change if editable shaders is enabled.
// note - it can contain multiple flavors, so use CGLMTextSectioner to scan it and locate them
#if GLMDEBUG
CGLMEditableTextItem *m_editable; // editable text item for debugging
#endif
GLMShaderDesc m_descs[ kGLMNumProgramLangs ];
uint m_samplerMask; // (1<<n) mask of sampler active locs, if this is a fragment shader (dxabstract sets this field)
uint m_samplerTypes; // SAMPLER_2D, etc.
uint m_nNumUsedSamplers;
uint m_maxSamplers;
uint m_maxVertexAttrs;
uint m_nCentroidMask;
uint m_nShadowDepthSamplerMask;
bool m_bTranslatedProgram;
char m_shaderName[64];
};
//===============================================================================
struct GLMShaderPairInfo
{
int m_status; // -1 means req'd index was out of bounds (loop stop..) 0 means not present. 1 means present/active.
char m_vsName[ 128 ];
int m_vsStaticIndex;
int m_vsDynamicIndex;
char m_psName[ 128 ];
int m_psStaticIndex;
int m_psDynamicIndex;
};
class CGLMShaderPair // a container for a linked GLSL shader pair, and metadata obtained post-link
{
public:
friend class CGLMProgram;
friend class GLMContext;
friend class CGLMShaderPairCache;
//===============================
// constructor just sets up a GLSL program object and leaves it empty.
CGLMShaderPair( GLMContext *ctx );
~CGLMShaderPair( );
bool SetProgramPair ( CGLMProgram *vp, CGLMProgram *fp );
// true result means successful link and query
bool RefreshProgramPair ( void );
// re-link and re-query the uniforms
FORCEINLINE void UpdateScreenUniform( uint nWidthHeight )
{
if ( m_nScreenWidthHeight == nWidthHeight )
return;
m_nScreenWidthHeight = nWidthHeight;
uint nWidth = nWidthHeight & 0xFFFF, nHeight = nWidthHeight >> 16;
// Apply half pixel offset to output vertices to account for the pixel center difference between D3D9 and OpenGL.
// We output vertices in clip space, which ranges from [-1,1], so 1.0/width in clip space transforms into .5/width in screenspace, see: "Viewports and Clipping (Direct3D 9)" in the DXSDK
float v[4] = { 1.0f / nWidth, 1.0f / nHeight, nWidth, nHeight };
if ( m_locVertexScreenParams >= 0 )
gGL->glUniform4fv( m_locVertexScreenParams, 1, v );
}
//===============================
// common stuff
GLMContext *m_ctx; // link back to parent context
CGLMProgram *m_vertexProg;
CGLMProgram *m_fragmentProg;
GLhandleARB m_program; // linked program object
// need meta data for attribs / samplers / params
// actually we only need it for samplers and params.
// attributes are hardwired.
// vertex stage uniforms
GLint m_locVertexParams; // "vc" per dx9asmtogl2 convention
GLint m_locVertexBoneParams; // "vcbones"
GLint m_locVertexInteger0; // "i0"
GLint m_locVertexBool0; // "b0"
GLint m_locVertexBool1; // "b1"
GLint m_locVertexBool2; // "b2"
GLint m_locVertexBool3; // "b3"
bool m_bHasBoolOrIntUniforms;
// fragment stage uniforms
GLint m_locFragmentParams; // "pc" per dx9asmtogl2 convention
int m_NumUniformBufferParams[kGLMNumProgramTypes];
GLint m_UniformBufferParams[kGLMNumProgramTypes][256];
GLint m_locFragmentFakeSRGBEnable; // "flSRGBWrite" - set to 1.0 to effect sRGB encoding on output
float m_fakeSRGBEnableValue; // shadow to avoid redundant sets of the m_locFragmentFakeSRGBEnable uniform
// init it to -1.0 at link or relink, so it will trip on any legit incoming value (0.0 or 1.0)
GLint m_locSamplers[ 16 ]; // "sampler0 ... sampler1..."
// other stuff
bool m_valid; // true on successful link
uint m_revision; // if this pair is relinked, bump this number.
GLint m_locVertexScreenParams; // vcscreen
uint m_nScreenWidthHeight;
};
//===============================================================================
// N-row, M-way associative cache with LRU per row.
// still needs some metric dump ability and some parameter tuning.
// extra credit would be to make an auto-tuner.
struct CGLMPairCacheEntry
{
long long m_lastMark; // a mark of zero means an empty entry
CGLMProgram *m_vertexProg;
CGLMProgram *m_fragmentProg;
uint m_extraKeyBits;
CGLMShaderPair *m_pair;
};
class CGLMShaderPairCache // cache for linked GLSL shader pairs
{
public:
protected:
friend class CGLMShaderPair;
friend class CGLMProgram;
friend class GLMContext;
//===============================
CGLMShaderPairCache( GLMContext *ctx );
~CGLMShaderPairCache( );
FORCEINLINE CGLMShaderPair *SelectShaderPair ( CGLMProgram *vp, CGLMProgram *fp, uint extraKeyBits );
void QueryShaderPair ( int index, GLMShaderPairInfo *infoOut );
// shoot down linked pairs that use the program in the arg
// return true if any had to be skipped due to conflict with currently bound pair
bool PurgePairsWithShader( CGLMProgram *prog );
// purge everything (when would GLM know how to do this ? at context destroy time, but any other times?)
// return true if any had to be skipped due to conflict with currently bound pair
bool Purge ( void );
// stats
void DumpStats ( void );
//===============================
FORCEINLINE uint HashRowIndex( CGLMProgram *vp, CGLMProgram *fp, uint extraKeyBits ) const;
FORCEINLINE CGLMPairCacheEntry* HashRowPtr( uint hashRowIndex ) const;
FORCEINLINE void HashRowProbe( CGLMPairCacheEntry *row, CGLMProgram *vp, CGLMProgram *fp, uint extraKeyBits, int &hitway, int &emptyway, int &oldestway );
CGLMShaderPair *SelectShaderPairInternal( CGLMProgram *vp, CGLMProgram *fp, uint extraKeyBits, int rowIndex );
//===============================
// common stuff
GLMContext *m_ctx; // link back to parent context
long long m_mark;
uint m_rowsLg2;
uint m_rows;
uint m_rowsMask;
uint m_waysLg2;
uint m_ways;
uint m_entryCount;
CGLMPairCacheEntry *m_entries; // array[ m_rows ][ m_ways ]
uint *m_evictions; // array[ m_rows ];
#if GL_SHADER_PAIR_CACHE_STATS
uint *m_hits; // array[ m_rows ];
#endif
};
FORCEINLINE uint CGLMShaderPairCache::HashRowIndex( CGLMProgram *vp, CGLMProgram *fp, uint extraKeyBits ) const
{
return ( vp->m_nHashTag + fp->m_nHashTag + extraKeyBits * 7 ) & m_rowsMask;
}
FORCEINLINE CGLMPairCacheEntry* CGLMShaderPairCache::HashRowPtr( uint hashRowIndex ) const
{
return &m_entries[ hashRowIndex * m_ways ];
}
FORCEINLINE void CGLMShaderPairCache::HashRowProbe( CGLMPairCacheEntry *row, CGLMProgram *vp, CGLMProgram *fp, uint extraKeyBits, int& hitway, int& emptyway, int& oldestway )
{
hitway = -1;
emptyway = -1;
oldestway = -1;
// scan this row to see if the desired pair is present
CGLMPairCacheEntry *cursor = row;
long long oldestmark = 0xFFFFFFFFFFFFFFFFLL;
for( uint way = 0; way < m_ways; ++way )
{
if ( cursor->m_lastMark != 0 ) // occupied slot
{
// check if this is the oldest one on the row - only occupied slots are checked
if ( cursor->m_lastMark < oldestmark )
{
oldestway = way;
oldestmark = cursor->m_lastMark;
}
if ( ( cursor->m_vertexProg == vp ) && ( cursor->m_fragmentProg == fp ) && ( cursor->m_extraKeyBits == extraKeyBits ) ) // match?
{
// found it
hitway = way;
break;
}
}
else
{
// empty way, log it if first one seen
if (emptyway<0)
{
emptyway = way;
}
}
cursor++;
}
}
FORCEINLINE CGLMShaderPair *CGLMShaderPairCache::SelectShaderPair( CGLMProgram *vp, CGLMProgram *fp, uint extraKeyBits )
{
// select row where pair would be found if it exists
uint rowIndex = HashRowIndex( vp, fp, extraKeyBits );
CGLMPairCacheEntry *pCursor = HashRowPtr( rowIndex );
if ( ( pCursor->m_fragmentProg != fp ) || ( pCursor->m_vertexProg != vp ) || ( pCursor->m_extraKeyBits != extraKeyBits ) )
{
CGLMPairCacheEntry *pLastCursor = pCursor + m_ways;
++pCursor;
while ( pCursor != pLastCursor )
{
if ( ( pCursor->m_fragmentProg == fp ) && ( pCursor->m_vertexProg == vp ) && ( pCursor->m_extraKeyBits == extraKeyBits ) ) // match?
break;
++pCursor;
};
if ( pCursor == pLastCursor )
return SelectShaderPairInternal( vp, fp, extraKeyBits, rowIndex );
}
// found it. mark it and return
pCursor->m_lastMark = m_mark++;
#if GL_SHADER_PAIR_CACHE_STATS
// count the hit
m_hits[ rowIndex ] ++;
#endif
return pCursor->m_pair;
}
#endif

View File

@ -0,0 +1,90 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// cglmquery.h
// GLMgr queries
//
//===============================================================================
#ifndef CGLMQUERY_H
#define CGLMQUERY_H
#pragma once
#ifdef OSX
#include "glmgr/glmgrbasics.h"
#endif
//===============================================================================
// forward declarations
class GLMContext;
class CGLMQuery;
//===============================================================================
enum EGLMQueryType
{
EOcclusion,
EFence,
EGLMQueryCount
};
struct GLMQueryParams
{
EGLMQueryType m_type;
};
class CGLMQuery
{
// leave everything public til it's running
public:
friend class GLMContext; // only GLMContext can make CGLMTex objects
friend struct IDirect3DDevice9;
friend struct IDirect3DQuery9;
GLMContext *m_ctx; // link back to parent context
GLMQueryParams m_params; // params created with
GLuint m_name; // name of the query object per se - could be fence, could be query object ... NOT USED WITH GL_ARB_sync!
#ifdef HAVE_GL_ARB_SYNC
GLsync m_syncobj; // GL_ARB_sync object. NOT USED WITH GL_NV_fence or GL_APPLE_fence!
#else
GLuint m_syncobj;
#endif
bool m_started;
bool m_stopped;
bool m_done;
bool m_nullQuery; // was gl_nullqueries true at Start time - if so, continue to act like a null query through Stop/IsDone/Complete time
// restated - only Start should examine the convar.
static uint s_nTotalOcclusionQueryCreatesOrDeletes;
CGLMQuery( GLMContext *ctx, GLMQueryParams *params );
~CGLMQuery( );
// for an occlusion query:
// Start = BeginQuery query-start goes into stream
// Stop = EndQuery query-end goes into stream - a fence is also set so we can probe for completion
// IsDone = TestFence use the added fence to ask if query-end has passed (i.e. will Complete block?)
// Complete = GetQueryObjectuivARB(uint id, enum pname, uint *params) - extract the sample count
// for a fence query:
// Start = SetFence fence goes into command stream
// Stop = NOP fences are self finishing - no need to call Stop on a fence
// IsDone = TestFence ask if fence passed
// Complete = FinishFence
void Start ( void );
void Stop ( void );
bool IsDone ( void );
void Complete ( uint *result );
// accessors for the started/stopped state
bool IsStarted ( void );
bool IsStopped ( void );
};
#endif

View File

@ -0,0 +1,502 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// cglmtex.h
// GLMgr textures
//
//===============================================================================
#ifndef CGLMTEX_H
#define CGLMTEX_H
#pragma once
#ifdef OSX
#include "glmgr/glmgrbasics.h"
#endif
#include "tier1/utlhash.h"
#include "tier1/utlmap.h"
//===============================================================================
// forward declarations
class GLMContext;
class GLMTester;
class CGLMTexLayoutTable;
class CGLMTex;
class CGLMFBO;
struct IDirect3DSurface9;
#if GLMDEBUG
extern CGLMTex *g_pFirstCGMLTex;
#endif
// For GL_EXT_texture_sRGB_decode
#ifndef GL_TEXTURE_SRGB_DECODE_EXT
#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48
#endif
#ifndef GL_DECODE_EXT
#define GL_DECODE_EXT 0x8A49
#endif
#ifndef GL_SKIP_DECODE_EXT
#define GL_SKIP_DECODE_EXT 0x8A4A
#endif
//===============================================================================
struct GLMTexFormatDesc
{
const char *m_formatSummary; // for debug visibility
D3DFORMAT m_d3dFormat; // what D3D knows it as; see public/bitmap/imageformat.h
GLenum m_glIntFormat; // GL internal format
GLenum m_glIntFormatSRGB; // internal format if SRGB flavor
GLenum m_glDataFormat; // GL data format
GLenum m_glDataType; // GL data type
int m_chunkSize; // 1 or 4 - 4 is used for compressed textures
int m_bytesPerSquareChunk; // how many bytes for the smallest quantum (m_chunkSize x m_chunkSize)
// this description lets us calculate size cleanly without conditional logic for compression
};
const GLMTexFormatDesc *GetFormatDesc( D3DFORMAT format );
//===============================================================================
// utility function for generating slabs of texels. mostly for test.
typedef struct
{
// in
D3DFORMAT m_format;
void *m_dest; // dest address
int m_chunkCount; // square chunk count (single texels or compressed blocks)
int m_byteCountLimit; // caller expectation of max number of bytes to write out
float r,g,b,a; // color desired
// out
int m_bytesWritten;
} GLMGenTexelParams;
// return true if successful
bool GLMGenTexels( GLMGenTexelParams *params );
//===============================================================================
struct GLMTexLayoutSlice
{
int m_xSize,m_ySize,m_zSize; //texel dimensions of this slice
int m_storageOffset; //where in the storage slab does this slice live
int m_storageSize; //how much storage does this slice occupy
};
enum EGLMTexFlags
{
kGLMTexMipped = 0x01,
kGLMTexMippedAuto = 0x02,
kGLMTexRenderable = 0x04,
kGLMTexIsStencil = 0x08,
kGLMTexIsDepth = 0x10,
kGLMTexSRGB = 0x20,
kGLMTexMultisampled = 0x40, // has an RBO backing it. Cannot combine with Mipped, MippedAuto. One slice maximum, only targeting GL_TEXTURE_2D.
// actually not 100% positive on the mipmapping, the RBO itself can't be mipped, but the resulting texture could
// have mipmaps generated.
};
//===============================================================================
struct GLMTexLayoutKey
{
// input values: held const, these are the hash key for the form map
GLenum m_texGLTarget; // flavor of texture: GL_TEXTURE_2D, GL_TEXTURE_3D, GLTEXTURE_CUBE_MAP
D3DFORMAT m_texFormat; // D3D texel format
unsigned long m_texFlags; // mipped, autogen mips, render target, ... ?
unsigned long m_texSamples; // zero for a plain tex, 2/4/6/8 for "MSAA tex" (RBO backed)
int m_xSize,m_ySize,m_zSize; // size of base mip
};
bool LessFunc_GLMTexLayoutKey( const GLMTexLayoutKey &a, const GLMTexLayoutKey &b );
#define GLM_TEX_MAX_MIPS 14
#define GLM_TEX_MAX_FACES 6
#define GLM_TEX_MAX_SLICES (GLM_TEX_MAX_MIPS * GLM_TEX_MAX_FACES)
#pragma warning( push )
#pragma warning( disable : 4200 )
struct GLMTexLayout
{
char *m_layoutSummary; // for debug visibility
// const inputs used for hashing
GLMTexLayoutKey m_key;
// refcount
int m_refCount;
// derived values:
GLMTexFormatDesc *m_format; // format specific info
int m_mipCount; // derived by starying at base size and working down towards 1x1
int m_faceCount; // 1 for 2d/3d, 6 for cubemap
int m_sliceCount; // product of faces and mips
int m_storageTotalSize; // size of storage slab required
// slice array
GLMTexLayoutSlice m_slices[0]; // dynamically allocated 2-d array [faces][mips]
};
#pragma warning( pop )
class CGLMTexLayoutTable
{
public:
CGLMTexLayoutTable();
GLMTexLayout *NewLayoutRef( GLMTexLayoutKey *pDesiredKey ); // pass in a pointer to layout key - receive ptr to completed layout
void DelLayoutRef( GLMTexLayout *layout ); // pass in pointer to completed layout. refcount is dropped.
void DumpStats( void );
protected:
CUtlMap< GLMTexLayoutKey, GLMTexLayout* > m_layoutMap;
};
//===============================================================================
// a sampler specifies desired state for drawing on a given sampler index
// this is the combination of a texture choice and a set of sampler parameters
// see http://msdn.microsoft.com/en-us/library/bb172602(VS.85).aspx
struct GLMTexLockParams
{
// input params which identify the slice of interest
CGLMTex *m_tex;
int m_face;
int m_mip;
// identifies the region of the slice
GLMRegion m_region;
// tells GLM to force re-read of the texels back from GL
// i.e. "I know I stepped on those texels with a draw or blit - the GLM copy is stale"
bool m_readback;
};
struct GLMTexLockDesc
{
GLMTexLockParams m_req; // form of the lock request
bool m_active; // set true at lock time. cleared at unlock time.
int m_sliceIndex; // which slice in the layout
int m_sliceBaseOffset; // where is that in the texture data
int m_sliceRegionOffset; // offset to the start (lowest address corner) of the region requested
};
//===============================================================================
#define GLM_SAMPLER_COUNT 16
typedef CBitVec<GLM_SAMPLER_COUNT> CTexBindMask;
enum EGLMTexSliceFlag
{
kSliceValid = 0x01, // slice has been teximage'd in whole at least once - set to 0 initially
kSliceStorageValid = 0x02, // if backing store is available, this slice's data is a valid copy - set to 0 initially
kSliceLocked = 0x04, // are one or more locks outstanding on this slice
kSliceFullyDirty = 0x08, // does the slice need to be fully downloaded at unlock time (disregard dirty rects)
};
//===============================================================================
#define GLM_PACKED_SAMPLER_PARAMS_ADDRESS_BITS (2)
#define GLM_PACKED_SAMPLER_PARAMS_MIN_FILTER_BITS (2)
#define GLM_PACKED_SAMPLER_PARAMS_MAG_FILTER_BITS (2)
#define GLM_PACKED_SAMPLER_PARAMS_MIP_FILTER_BITS (2)
#define GLM_PACKED_SAMPLER_PARAMS_MIN_LOD_BITS (4)
#define GLM_PACKED_SAMPLER_PARAMS_MAX_ANISO_BITS (5)
#define GLM_PACKED_SAMPLER_PARAMS_COMPARE_MODE_BITS (1)
#define GLM_PACKED_SAMPLER_PARAMS_SRGB_BITS (1)
struct GLMTexPackedSamplingParams
{
uint32 m_addressU : GLM_PACKED_SAMPLER_PARAMS_ADDRESS_BITS;
uint32 m_addressV : GLM_PACKED_SAMPLER_PARAMS_ADDRESS_BITS;
uint32 m_addressW : GLM_PACKED_SAMPLER_PARAMS_ADDRESS_BITS;
uint32 m_minFilter : GLM_PACKED_SAMPLER_PARAMS_MIN_FILTER_BITS;
uint32 m_magFilter : GLM_PACKED_SAMPLER_PARAMS_MAG_FILTER_BITS;
uint32 m_mipFilter : GLM_PACKED_SAMPLER_PARAMS_MIP_FILTER_BITS;
uint32 m_minLOD : GLM_PACKED_SAMPLER_PARAMS_MIN_LOD_BITS;
uint32 m_maxAniso : GLM_PACKED_SAMPLER_PARAMS_MAX_ANISO_BITS;
uint32 m_compareMode : GLM_PACKED_SAMPLER_PARAMS_COMPARE_MODE_BITS;
uint32 m_srgb : GLM_PACKED_SAMPLER_PARAMS_SRGB_BITS;
uint32 m_isValid : 1;
};
struct GLMTexSamplingParams
{
union
{
GLMTexPackedSamplingParams m_packed;
uint32 m_bits;
};
uint32 m_borderColor;
FORCEINLINE bool operator== (const GLMTexSamplingParams& rhs ) const
{
return ( m_bits == rhs.m_bits ) && ( m_borderColor == rhs.m_borderColor );
}
FORCEINLINE void SetToDefaults()
{
m_bits = 0;
m_borderColor = 0;
m_packed.m_addressU = D3DTADDRESS_WRAP;
m_packed.m_addressV = D3DTADDRESS_WRAP;
m_packed.m_addressW = D3DTADDRESS_WRAP;
m_packed.m_minFilter = D3DTEXF_POINT;
m_packed.m_magFilter = D3DTEXF_POINT;
m_packed.m_mipFilter = D3DTEXF_NONE;
m_packed.m_maxAniso = 1;
m_packed.m_isValid = true;
}
FORCEINLINE void SetToSamplerObject( GLuint nSamplerObject ) const
{
static const GLenum dxtogl_addressMode[] = { GL_REPEAT, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER, (GLenum)-1 };
static const GLenum dxtogl_magFilter[4] = { GL_NEAREST, GL_NEAREST, GL_LINEAR, GL_LINEAR };
static const GLenum dxtogl_minFilter[4][4] = // indexed by _D3DTEXTUREFILTERTYPE on both axes: [row is min filter][col is mip filter].
{
/* min = D3DTEXF_NONE */ { GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, (GLenum)-1 }, // D3DTEXF_NONE we just treat like POINT
/* min = D3DTEXF_POINT */ { GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, (GLenum)-1 },
/* min = D3DTEXF_LINEAR */ { GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR, (GLenum)-1 },
/* min = D3DTEXF_ANISOTROPIC */ { GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR, (GLenum)-1 }, // no diff from prior row, set maxAniso to effect the sampling
};
gGL->glSamplerParameteri( nSamplerObject, GL_TEXTURE_WRAP_S, dxtogl_addressMode[m_packed.m_addressU] );
gGL->glSamplerParameteri( nSamplerObject, GL_TEXTURE_WRAP_T, dxtogl_addressMode[m_packed.m_addressV] );
gGL->glSamplerParameteri( nSamplerObject, GL_TEXTURE_WRAP_R, dxtogl_addressMode[m_packed.m_addressW] );
gGL->glSamplerParameteri( nSamplerObject, GL_TEXTURE_MIN_FILTER, dxtogl_minFilter[m_packed.m_minFilter][m_packed.m_mipFilter] );
gGL->glSamplerParameteri( nSamplerObject, GL_TEXTURE_MAG_FILTER, dxtogl_magFilter[m_packed.m_magFilter] );
gGL->glSamplerParameteri( nSamplerObject, GL_TEXTURE_MAX_ANISOTROPY_EXT, m_packed.m_maxAniso );
float flBorderColor[4] = { 0, 0, 0, 0 };
if ( m_borderColor )
{
flBorderColor[0] = ((m_borderColor >> 16) & 0xFF) * (1.0f/255.0f); //R
flBorderColor[1] = ((m_borderColor >> 8) & 0xFF) * (1.0f/255.0f); //G
flBorderColor[2] = ((m_borderColor ) & 0xFF) * (1.0f/255.0f); //B
flBorderColor[3] = ((m_borderColor >> 24) & 0xFF) * (1.0f/255.0f); //A
}
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->glSamplerParameteri( nSamplerObject, GL_TEXTURE_COMPARE_MODE_ARB, m_packed.m_compareMode ? GL_COMPARE_R_TO_TEXTURE_ARB : GL_NONE );
if ( m_packed.m_compareMode )
{
gGL->glSamplerParameteri( nSamplerObject, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL );
}
if ( gGL->m_bHave_GL_EXT_texture_sRGB_decode )
{
gGL->glSamplerParameteri( nSamplerObject, GL_TEXTURE_SRGB_DECODE_EXT, m_packed.m_srgb ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT );
}
}
inline void DeltaSetToTarget( GLenum target, const GLMTexSamplingParams &curState )
{
static const GLenum dxtogl_addressMode[] = { GL_REPEAT, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER, (GLenum)-1 };
static const GLenum dxtogl_magFilter[4] = { GL_NEAREST, GL_NEAREST, GL_LINEAR, GL_LINEAR };
static const GLenum dxtogl_minFilter[4][4] = // indexed by _D3DTEXTUREFILTERTYPE on both axes: [row is min filter][col is mip filter].
{
/* min = D3DTEXF_NONE */ { GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, (GLenum)-1 }, // D3DTEXF_NONE we just treat like POINT
/* min = D3DTEXF_POINT */ { GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, (GLenum)-1 },
/* min = D3DTEXF_LINEAR */ { GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR, (GLenum)-1 },
/* min = D3DTEXF_ANISOTROPIC */ { GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR, (GLenum)-1 }, // no diff from prior row, set maxAniso to effect the sampling
};
if ( m_packed.m_addressU != curState.m_packed.m_addressU )
{
gGL->glTexParameteri( target, GL_TEXTURE_WRAP_S, dxtogl_addressMode[m_packed.m_addressU] );
}
if ( m_packed.m_addressV != curState.m_packed.m_addressV )
{
gGL->glTexParameteri( target, GL_TEXTURE_WRAP_T, dxtogl_addressMode[m_packed.m_addressV] );
}
if ( m_packed.m_addressW != curState.m_packed.m_addressW )
{
gGL->glTexParameteri( target, GL_TEXTURE_WRAP_R, dxtogl_addressMode[m_packed.m_addressW] );
}
if ( ( m_packed.m_minFilter != curState.m_packed.m_minFilter ) ||
( m_packed.m_magFilter != curState.m_packed.m_magFilter ) ||
( m_packed.m_mipFilter != curState.m_packed.m_mipFilter ) ||
( m_packed.m_maxAniso != curState.m_packed.m_maxAniso ) )
{
gGL->glTexParameteri( target, GL_TEXTURE_MIN_FILTER, dxtogl_minFilter[m_packed.m_minFilter][m_packed.m_mipFilter] );
gGL->glTexParameteri( target, GL_TEXTURE_MAG_FILTER, dxtogl_magFilter[m_packed.m_magFilter] );
gGL->glTexParameteri( target, GL_TEXTURE_MAX_ANISOTROPY_EXT, m_packed.m_maxAniso );
}
if ( m_borderColor != curState.m_borderColor )
{
float flBorderColor[4] = { 0, 0, 0, 0 };
if ( m_borderColor )
{
flBorderColor[0] = ((m_borderColor >> 16) & 0xFF) * (1.0f/255.0f); //R
flBorderColor[1] = ((m_borderColor >> 8) & 0xFF) * (1.0f/255.0f); //G
flBorderColor[2] = ((m_borderColor ) & 0xFF) * (1.0f/255.0f); //B
flBorderColor[3] = ((m_borderColor >> 24) & 0xFF) * (1.0f/255.0f); //A
}
gGL->glTexParameterfv( target, GL_TEXTURE_BORDER_COLOR, flBorderColor ); // <-- this crashes ATI's driver, remark it out
}
if ( m_packed.m_minLOD != curState.m_packed.m_minLOD )
{
gGL->glTexParameteri( target, GL_TEXTURE_MIN_LOD, m_packed.m_minLOD );
}
if ( m_packed.m_compareMode != curState.m_packed.m_compareMode )
{
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 )
{
gGL->glTexParameteri( target, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL );
}
}
if ( ( gGL->m_bHave_GL_EXT_texture_sRGB_decode ) && ( m_packed.m_srgb != curState.m_packed.m_srgb ) )
{
gGL->glTexParameteri( target, GL_TEXTURE_SRGB_DECODE_EXT, m_packed.m_srgb ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT );
}
}
inline void SetToTargetTexture( GLenum target )
{
static const GLenum dxtogl_addressMode[] = { GL_REPEAT, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER, (GLenum)-1 };
static const GLenum dxtogl_magFilter[4] = { GL_NEAREST, GL_NEAREST, GL_LINEAR, GL_LINEAR };
static const GLenum dxtogl_minFilter[4][4] = // indexed by _D3DTEXTUREFILTERTYPE on both axes: [row is min filter][col is mip filter].
{
/* min = D3DTEXF_NONE */ { GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, (GLenum)-1 }, // D3DTEXF_NONE we just treat like POINT
/* min = D3DTEXF_POINT */ { GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, (GLenum)-1 },
/* min = D3DTEXF_LINEAR */ { GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR, (GLenum)-1 },
/* min = D3DTEXF_ANISOTROPIC */ { GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_LINEAR, (GLenum)-1 }, // no diff from prior row, set maxAniso to effect the sampling
};
gGL->glTexParameteri( target, GL_TEXTURE_WRAP_S, dxtogl_addressMode[m_packed.m_addressU] );
gGL->glTexParameteri( target, GL_TEXTURE_WRAP_T, dxtogl_addressMode[m_packed.m_addressV] );
gGL->glTexParameteri( target, GL_TEXTURE_WRAP_R, dxtogl_addressMode[m_packed.m_addressW] );
gGL->glTexParameteri( target, GL_TEXTURE_MIN_FILTER, dxtogl_minFilter[m_packed.m_minFilter][m_packed.m_mipFilter] );
gGL->glTexParameteri( target, GL_TEXTURE_MAG_FILTER, dxtogl_magFilter[m_packed.m_magFilter] );
gGL->glTexParameteri( target, GL_TEXTURE_MAX_ANISOTROPY_EXT, m_packed.m_maxAniso );
float flBorderColor[4] = { 0, 0, 0, 0 };
if ( m_borderColor )
{
flBorderColor[0] = ((m_borderColor >> 16) & 0xFF) * (1.0f/255.0f); //R
flBorderColor[1] = ((m_borderColor >> 8) & 0xFF) * (1.0f/255.0f); //G
flBorderColor[2] = ((m_borderColor ) & 0xFF) * (1.0f/255.0f); //B
flBorderColor[3] = ((m_borderColor >> 24) & 0xFF) * (1.0f/255.0f); //A
}
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->glTexParameteri( target, GL_TEXTURE_COMPARE_MODE_ARB, m_packed.m_compareMode ? GL_COMPARE_R_TO_TEXTURE_ARB : GL_NONE );
if ( m_packed.m_compareMode )
{
gGL->glTexParameteri( target, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL );
}
if ( gGL->m_bHave_GL_EXT_texture_sRGB_decode )
{
gGL->glTexParameteri( target, GL_TEXTURE_SRGB_DECODE_EXT, m_packed.m_srgb ? GL_DECODE_EXT : GL_SKIP_DECODE_EXT );
}
}
};
//===============================================================================
class CGLMTex
{
public:
void Lock( GLMTexLockParams *params, char** addressOut, int* yStrideOut, int *zStrideOut );
void Unlock( GLMTexLockParams *params );
protected:
friend class GLMContext; // only GLMContext can make CGLMTex objects
friend class GLMTester;
friend class CGLMFBO;
friend struct IDirect3DDevice9;
friend struct IDirect3DBaseTexture9;
friend struct IDirect3DTexture9;
friend struct IDirect3DSurface9;
friend struct IDirect3DCubeTexture9;
friend struct IDirect3DVolumeTexture9;
CGLMTex( GLMContext *ctx, GLMTexLayout *layout, const char *debugLabel = NULL );
~CGLMTex( );
int CalcSliceIndex( int face, int mip );
void CalcTexelDataOffsetAndStrides( int sliceIndex, int x, int y, int z, int *offsetOut, int *yStrideOut, int *zStrideOut );
void ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice=true );
void WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice=true, bool noDataWrite=false );
// last param lets us send NULL data ptr (only legal with uncompressed formats, beware)
// this helps out ResetSRGB.
bool IsRBODirty() const;
void ForceRBONonDirty();
void ForceRBODirty();
void AllocBacking();
void ReleaseBacking();
// re-specify texture format to match desired sRGB form
// noWrite means send NULL for texel source addresses instead of actual data - ideal for RT's
GLuint m_texName; // name of this texture in the context
GLenum m_texGLTarget;
uint m_nSamplerType; // SAMPLER_2D, etc.
GLMTexSamplingParams m_SamplingParams;
GLMTexLayout *m_layout; // layout of texture (shared across all tex with same layout)
uint m_nLastResolvedBatchCounter;
int m_minActiveMip;//index of lowest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL.
int m_maxActiveMip;//index of highest mip that has been written. used to drive setting of GL_TEXTURE_MAX_LEVEL.
int m_mipCount;
GLMContext *m_ctx; // link back to parent context
CGLMFBO *m_pBlitSrcFBO;
CGLMFBO *m_pBlitDstFBO;
GLuint m_rboName; // name of MSAA RBO backing the tex if MSAA enabled (or zero)
int m_rtAttachCount; // how many RT's have this texture attached somewhere
char *m_pBacking; // backing storage if available
int m_lockCount; // lock reqs are stored in the GLMContext for tracking
CUtlVector<unsigned char> m_sliceFlags;
char *m_debugLabel; // strdup() of debugLabel passed in, or NULL
bool m_texClientStorage; // was CS selected for texture
bool m_texPreloaded; // has it been kicked into VRAM with GLMContext::PreloadTex yet
#if GLMDEBUG
CGLMTex *m_pPrevTex;
CGLMTex *m_pNextTex;
#endif
};
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,104 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// glbase.h
//
//===============================================================================
#ifndef GLBASE_H
#define GLBASE_H
#ifdef DX_TO_GL_ABSTRACTION
#undef HAVE_GL_ARB_SYNC
#ifndef OSX
#define HAVE_GL_ARB_SYNC 1
#endif
#ifdef OSX
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#include <OpenGL/CGLTypes.h>
#include <OpenGL/CGLRenderers.h>
#include <OpenGL/CGLCurrent.h>
#include <OpenGL/CGLProfiler.h>
#include <ApplicationServices/ApplicationServices.h>
#elif defined(DX_TO_GL_ABSTRACTION)
#include <GL/gl.h>
#include <GL/glext.h>
#else
#error
#endif
#ifdef DX_TO_GL_ABSTRACTION
#ifndef WIN32
#define Debugger DebuggerBreak
#endif
#undef CurrentTime
// prevent some conflicts in SDL headers...
#undef M_PI
#include <stdint.h>
#ifndef _STDINT_H_
#define _STDINT_H_ 1
#endif
#endif
//===============================================================================
// glue to call out to Obj-C land (these are in glmgrcocoa.mm)
#ifdef OSX
bool NewNSGLContext( unsigned long *attribs, PseudoNSGLContextPtr nsglShareCtx, PseudoNSGLContextPtr *nsglCtxOut, CGLContextObj *cglCtxOut );
CGLContextObj GetCGLContextFromNSGL( PseudoNSGLContextPtr nsglCtx );
void DelNSGLContext( PseudoNSGLContextPtr nsglCtx );
#endif
// Set TOGL_SUPPORT_NULL_DEVICE to 1 to support the NULL ref device
#define TOGL_SUPPORT_NULL_DEVICE 0
#if TOGL_SUPPORT_NULL_DEVICE
#define TOGL_NULL_DEVICE_CHECK if( m_params.m_deviceType == D3DDEVTYPE_NULLREF ) return S_OK;
#define TOGL_NULL_DEVICE_CHECK_RET_VOID if( m_params.m_deviceType == D3DDEVTYPE_NULLREF ) return;
#else
#define TOGL_NULL_DEVICE_CHECK
#define TOGL_NULL_DEVICE_CHECK_RET_VOID
#endif
// GL_ENABLE_INDEX_VERIFICATION enables index range verification on all dynamic IB/VB's (obviously slow)
#define GL_ENABLE_INDEX_VERIFICATION 0
// GL_ENABLE_UNLOCK_BUFFER_OVERWRITE_DETECTION (currently win32 only) - If 1, VirtualAlloc/VirtualProtect is used to detect cases where the app locks a buffer, copies the ptr away, unlocks, then tries to later write to the buffer.
#define GL_ENABLE_UNLOCK_BUFFER_OVERWRITE_DETECTION 0
#define GL_BATCH_TELEMETRY_ZONES 0
// GL_BATCH_PERF_ANALYSIS - Enables gl_batch_vis, and various per-batch telemetry statistics messages.
#define GL_BATCH_PERF_ANALYSIS 0
#define GL_BATCH_PERF_ANALYSIS_WRITE_PNGS 0
// GL_TELEMETRY_ZONES - Causes every single OpenGL call to generate a telemetry event
#define GL_TELEMETRY_ZONES 0
// GL_DUMP_ALL_API_CALLS - Causes a debug message to be printed for every API call if s_bDumpCalls bool is set to 1
#define GL_DUMP_ALL_API_CALLS 0
// Must also enable PIX_ENABLE to use GL_TELEMETRY_GPU_ZONES.
#define GL_TELEMETRY_GPU_ZONES 0
// Records global # of OpenGL calls/total cycles spent inside GL
#define GL_TRACK_API_TIME GL_BATCH_PERF_ANALYSIS
#define GL_USE_EXECUTE_HELPER_FOR_ALL_API_CALLS ( GL_TELEMETRY_ZONES || GL_TRACK_API_TIME || GL_DUMP_ALL_API_CALLS )
#if GL_BATCH_PERF_ANALYSIS
#define GL_BATCH_PERF(...) __VA_ARGS__
#else
#define GL_BATCH_PERF(...)
#endif
#define kGLMUserClipPlanes 2
#define kGLMScratchFBOCount 4
#endif // DX_TO_GL_ABSTRACTION
#endif // GLBASE_H

View File

@ -0,0 +1,378 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// glentrypoints.h
//
//===============================================================================
#ifndef GLENTRYPOINTS_H
#define GLENTRYPOINTS_H
#pragma once
#ifdef DX_TO_GL_ABSTRACTION
#include "tier0/platform.h"
#include "tier0/dynfunction.h"
#include "tier0/vprof_telemetry.h"
#include "interface.h"
#include "togl/rendermechanism.h"
void *VoidFnPtrLookup_GlMgr(const char *fn, bool &okay, const bool bRequired, void *fallback=NULL);
#if GL_USE_EXECUTE_HELPER_FOR_ALL_API_CALLS
class CGLExecuteHelperBase
{
public:
inline void StartCall(const char *pName);
inline void StopCall(const char *pName);
#if GL_TRACK_API_TIME
TmU64 m_nStartTime;
#endif
};
template < class FunctionType, typename Result >
class CGLExecuteHelper : public CGLExecuteHelperBase
{
public:
inline CGLExecuteHelper(FunctionType pFn, const char *pName ) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(); StopCall(pName); }
template<typename A> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a); StopCall(pName); }
template<typename A, typename B> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b); StopCall(pName); }
template<typename A, typename B, typename C> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c); StopCall(pName); }
template<typename A, typename B, typename C, typename D> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d, e); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d, e, f); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d, e, f, g); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g, H h) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d, e, f, g, h); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g, H h, I i) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d, e, f, g, h, i); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d, e, f, g, h, i, j); StopCall(pName); }
inline operator Result() const { return m_Result; }
inline operator char*() const { return (char*)m_Result; }
FunctionType m_pFn;
Result m_Result;
};
template < class FunctionType>
class CGLExecuteHelper<FunctionType, void> : public CGLExecuteHelperBase
{
public:
inline CGLExecuteHelper(FunctionType pFn, const char *pName ) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(); StopCall(pName); }
template<typename A> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a); StopCall(pName); }
template<typename A, typename B> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b); StopCall(pName); }
template<typename A, typename B, typename C> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c); StopCall(pName); }
template<typename A, typename B, typename C, typename D> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d, e); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d, e, f); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d, e, f, g); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g, H h) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d, e, f, g, h); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g, H h, I i) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d, e, f, g, h, i); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d, e, f, g, h, i, j); StopCall(pName); }
FunctionType m_pFn;
};
#endif
template < class FunctionType, typename Result >
class CDynamicFunctionOpenGLBase
{
public:
// Construct with a NULL function pointer. You must manually call
// Lookup() before you can call a dynamic function through this interface.
CDynamicFunctionOpenGLBase() : m_pFn(NULL) {}
// Construct and do a lookup right away. You will need to make sure that
// the lookup actually succeeded, as the gl library might have failed to load
// or (fn) might not exist in it.
CDynamicFunctionOpenGLBase(const char *fn, FunctionType fallback=NULL) : m_pFn(NULL)
{
Lookup(fn, fallback);
}
// Construct and do a lookup right away. See comments in Lookup() about what (okay) does.
CDynamicFunctionOpenGLBase(const char *fn, bool &okay, FunctionType fallback=NULL) : m_pFn(NULL)
{
Lookup(fn, okay, fallback);
}
// Load library if necessary, look up symbol. Returns true and sets
// m_pFn on successful lookup, returns false otherwise. If the
// function pointer is already looked up, this return true immediately.
// Use Reset() first if you want to look up the symbol again.
// This function will return false immediately unless (okay) is true.
// This allows you to chain lookups like this:
// bool okay = true;
// x.Lookup(lib, "x", okay);
// y.Lookup(lib, "y", okay);
// z.Lookup(lib, "z", okay);
// if (okay) { printf("All functions were loaded successfully!\n"); }
// If you supply a fallback, it'll be used if the lookup fails (and if
// non-NULL, means this will always return (okay)).
bool Lookup(const char *fn, bool &okay, FunctionType fallback=NULL)
{
if (!okay)
return false;
else if (this->m_pFn == NULL)
{
this->m_pFn = (FunctionType) VoidFnPtrLookup_GlMgr(fn, okay, false, (void *) fallback);
this->SetFuncName( fn );
}
okay = m_pFn != NULL;
return okay;
}
// Load library if necessary, look up symbol. Returns true and sets
// m_pFn on successful lookup, returns false otherwise. If the
// function pointer is already looked up, this return true immediately.
// Use Reset() first if you want to look up the symbol again.
// This function will return false immediately unless (okay) is true.
// If you supply a fallback, it'll be used if the lookup fails (and if
// non-NULL, means this will always return true).
bool Lookup(const char *fn, FunctionType fallback=NULL)
{
bool okay = true;
return Lookup(fn, okay, fallback);
}
// Invalidates the current lookup. Makes the function pointer NULL. You
// will need to call Lookup() before you can call a dynamic function
// through this interface again.
void Reset() { m_pFn = NULL; }
// Force this to be a specific function pointer.
void Force(FunctionType ptr) { m_pFn = ptr; }
// Retrieve the actual function pointer.
FunctionType Pointer() const { return m_pFn; }
#if GL_USE_EXECUTE_HELPER_FOR_ALL_API_CALLS
#if GL_TELEMETRY_ZONES || GL_DUMP_ALL_API_CALLS
#define GL_FUNC_NAME m_szName
#else
#define GL_FUNC_NAME ""
#endif
inline CGLExecuteHelper<FunctionType, Result> operator() () const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME ); }
template<typename T>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a); }
template<typename T, typename U>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b); }
template<typename T, typename U, typename V>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c ) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c); }
template<typename T, typename U, typename V, typename W>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d); }
template<typename T, typename U, typename V, typename W, typename X>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d, X e) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d, e); }
template<typename T, typename U, typename V, typename W, typename X, typename Y>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d, X e, Y f) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d, e, f); }
template<typename T, typename U, typename V, typename W, typename X, typename Y, typename Z>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d, X e, Y f, Z g) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d, e, f, g); }
template<typename T, typename U, typename V, typename W, typename X, typename Y, typename Z, typename A>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d, X e, Y f, Z g, A h) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d, e, f, g, h); }
template<typename T, typename U, typename V, typename W, typename X, typename Y, typename Z, typename A, typename B>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d, X e, Y f, Z g, A h, B i) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d, e, f, g, h, i); }
template<typename T, typename U, typename V, typename W, typename X, typename Y, typename Z, typename A, typename B, typename C>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d, X e, Y f, Z g, A h, B i, C j) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d, e, f, g, h, i, j); }
#else
operator FunctionType() const { return m_pFn; }
#endif
// Can be used to verify that we have an actual function looked up and
// ready to call: if (!MyDynFunc) { printf("Function not found!\n"); }
operator bool () const { return m_pFn != NULL; }
bool operator !() const { return m_pFn == NULL; }
protected:
FunctionType m_pFn;
#if GL_TELEMETRY_ZONES || GL_DUMP_ALL_API_CALLS
char m_szName[32];
inline void SetFuncName(const char *pFn) { V_strncpy( m_szName, pFn, sizeof( m_szName ) ); }
#else
inline void SetFuncName(const char *pFn) { (void)pFn; }
#endif
};
// This works a lot like CDynamicFunctionMustInit, but we use SDL_GL_GetProcAddress().
template < const bool bRequired, class FunctionType, typename Result >
class CDynamicFunctionOpenGL : public CDynamicFunctionOpenGLBase< FunctionType, Result >
{
private: // forbid default constructor.
CDynamicFunctionOpenGL() {}
public:
CDynamicFunctionOpenGL(const char *fn, FunctionType fallback=NULL)
{
bool okay = true;
Lookup(fn, okay, fallback);
this->SetFuncName( fn );
}
CDynamicFunctionOpenGL(const char *fn, bool &okay, FunctionType fallback=NULL)
{
Lookup(fn, okay, fallback);
this->SetFuncName( fn );
}
// Please note this is not virtual.
// !!! FIXME: we might want to fall back and try "EXT" or "ARB" versions in some case.
bool Lookup(const char *fn, bool &okay, FunctionType fallback=NULL)
{
if (this->m_pFn == NULL)
{
this->m_pFn = (FunctionType) VoidFnPtrLookup_GlMgr(fn, okay, bRequired, (void *) fallback);
this->SetFuncName( fn );
}
return okay;
}
};
enum GLDriverStrings_t
{
cGLVendorString,
cGLRendererString,
cGLVersionString,
cGLExtensionsString,
cGLTotalDriverStrings
};
enum GLDriverProvider_t
{
cGLDriverProviderUnknown,
cGLDriverProviderNVIDIA,
cGLDriverProviderAMD,
cGLDriverProviderIntel,
cGLDriverProviderIntelOpenSource,
cGLDriverProviderApple,
cGLTotalDriverProviders
};
// This provides all the entry points for a given OpenGL context.
// ENTRY POINTS ARE ONLY VALID FOR THE CONTEXT THAT WAS CURRENT WHEN
// YOU LOOKED THEM UP. 99% of the time, this is not a problem, but
// that 1% is really hard to track down. Always access the GL
// through this class!
class COpenGLEntryPoints
{
COpenGLEntryPoints( const COpenGLEntryPoints & );
COpenGLEntryPoints &operator= ( const COpenGLEntryPoints & );
public:
// The GL context you are looking up entry points for must be current when you construct this object!
COpenGLEntryPoints();
~COpenGLEntryPoints();
void ClearEntryPoints();
uint64 m_nTotalGLCycles, m_nTotalGLCalls;
int m_nOpenGLVersionMajor; // if GL_VERSION is 2.1.0, this will be set to 2.
int m_nOpenGLVersionMinor; // if GL_VERSION is 2.1.0, this will be set to 1.
int m_nOpenGLVersionPatch; // if GL_VERSION is 2.1.0, this will be set to 0.
bool m_bHave_OpenGL;
char *m_pGLDriverStrings[cGLTotalDriverStrings];
GLDriverProvider_t m_nDriverProvider;
#define GL_EXT(x,glmajor,glminor) bool m_bHave_##x;
#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;
#include "togl/glfuncs.inl"
#undef GL_FUNC_VOID
#undef GL_FUNC
#undef GL_EXT
bool HasSwapTearExtension() const
{
#ifdef _WIN32
return m_bHave_WGL_EXT_swap_control_tear;
#else
return m_bHave_GLX_EXT_swap_control_tear;
#endif
}
};
// This will be set to the current OpenGL context's entry points.
extern COpenGLEntryPoints *gGL;
typedef void * (*GL_GetProcAddressCallbackFunc_t)(const char *, bool &, const bool, void *);
#ifdef TOGL_DLL_EXPORT
DLL_EXPORT COpenGLEntryPoints *ToGLConnectLibraries( CreateInterfaceFn factory );
DLL_EXPORT void ToGLDisconnectLibraries();
DLL_EXPORT COpenGLEntryPoints *GetOpenGLEntryPoints(GL_GetProcAddressCallbackFunc_t callback);
DLL_EXPORT void ClearOpenGLEntryPoints();
#else
DLL_IMPORT COpenGLEntryPoints *ToGLConnectLibraries( CreateInterfaceFn factory );
DLL_IMPORT void ToGLDisconnectLibraries();
DLL_IMPORT COpenGLEntryPoints *GetOpenGLEntryPoints(GL_GetProcAddressCallbackFunc_t callback);
DLL_IMPORT void ClearOpenGLEntryPoints();
#endif
#if GL_USE_EXECUTE_HELPER_FOR_ALL_API_CALLS
inline void CGLExecuteHelperBase::StartCall(const char *pName)
{
(void)pName;
#if GL_TELEMETRY_ZONES
tmEnter( TELEMETRY_LEVEL3, TMZF_NONE, pName );
#endif
#if GL_TRACK_API_TIME
m_nStartTime = tmFastTime();
#endif
#if GL_DUMP_ALL_API_CALLS
static bool s_bDumpCalls;
if ( s_bDumpCalls )
{
char buf[128];
buf[0] = 'G';
buf[1] = 'L';
buf[2] = ':';
size_t l = strlen( pName );
memcpy( buf + 3, pName, l );
buf[3 + l] = '\n';
buf[4 + l] = '\0';
Plat_DebugString( buf );
}
#endif
}
inline void CGLExecuteHelperBase::StopCall(const char *pName)
{
#if GL_TRACK_API_TIME
uint64 nTotalCycles = tmFastTime() - m_nStartTime;
#endif
#if GL_TELEMETRY_ZONES
tmLeave( TELEMETRY_LEVEL3 );
#endif
#if GL_TRACK_API_TIME
//double flMilliseconds = g_Telemetry.flRDTSCToMilliSeconds * nTotalCycles;
if (gGL)
{
gGL->m_nTotalGLCycles += nTotalCycles;
gGL->m_nTotalGLCalls++;
}
#endif
}
#endif
#endif // DX_TO_GL_ABSTRACTION
#endif // GLENTRYPOINTS_H

View File

@ -0,0 +1,236 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
// !!! 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,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,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,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,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,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_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,glDepthRange,(GLclampd a,GLclampd b),(a,b))
GL_FUNC_VOID(OpenGL,true,glDetachObjectARB,(GLhandleARB a,GLhandleARB 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))
GL_FUNC_VOID(OpenGL,true,glDrawBuffer,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glDrawRangeElements,(GLenum a,GLuint b,GLuint c,GLsizei d,GLenum e,const GLvoid *f),(a,b,c,d,e,f))
GL_FUNC_VOID(OpenGL,true,glDrawRangeElementsBaseVertex,(GLenum a,GLuint b,GLuint c,GLsizei d,GLenum e,const GLvoid *f, GLenum g),(a,b,c,d,e,f,g))
GL_FUNC_VOID(OpenGL,true,glEnable,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glEnableVertexAttribArray,(GLuint a),(a))
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,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,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(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,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,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,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,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))
GL_FUNC_VOID(OpenGL,true,glTexCoord2f,(GLfloat a,GLfloat b),(a,b))
GL_FUNC_VOID(OpenGL,true,glTexImage2D,(GLenum a,GLint b,GLint c,GLsizei d,GLsizei e,GLint f,GLenum g,GLenum h,const GLvoid *i),(a,b,c,d,e,f,g,h,i))
GL_FUNC_VOID(OpenGL,true,glTexImage3D,(GLenum a,GLint b,GLint c,GLsizei d,GLsizei e,GLsizei f,GLint g,GLenum h,GLenum i,const GLvoid *j),(a,b,c,d,e,f,g,h,i,j))
GL_FUNC_VOID(OpenGL,true,glTexParameterfv,(GLenum a,GLenum b,const GLfloat *c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glTexParameteri,(GLenum a,GLenum b,GLint c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glTexSubImage2D,(GLenum a,GLint b,GLint c,GLint d,GLsizei e,GLsizei f,GLenum g,GLenum h,const GLvoid *i),(a,b,c,d,e,f,g,h,i))
GL_FUNC_VOID(OpenGL,true,glUniform1f,(GLint a,GLfloat b),(a,b))
GL_FUNC_VOID(OpenGL,true,glUniform1i,(GLint a,GLint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glUniform1iARB,(GLint a,GLint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glUniform4fv,(GLint a,GLsizei b,const GLfloat *c),(a,b,c))
GL_FUNC(OpenGL,true,GLboolean,glUnmapBuffer,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glUseProgram,(GLuint a),(a))
GL_FUNC_VOID(OpenGL,true,glVertex3f,(GLfloat a,GLfloat b,GLfloat c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glVertexAttribPointer,(GLuint a,GLint b,GLenum c,GLboolean d,GLsizei e,const GLvoid *f),(a,b,c,d,e,f))
GL_FUNC_VOID(OpenGL,true,glViewport,(GLint a,GLint b,GLsizei c,GLsizei d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glEnableClientState,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glDisableClientState,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glClientActiveTexture,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glVertexPointer,(GLint a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glTexCoordPointer,(GLint a,GLenum b,GLsizei c,const GLvoid *d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glProgramEnvParameters4fvEXT,(GLenum a,GLuint b,GLsizei c,const GLfloat *d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glColor4sv,(const GLshort *a),(a))
GL_FUNC_VOID(OpenGL,true,glStencilOpSeparate,(GLenum a,GLenum b,GLenum c,GLenum d),(a,b,c,d))
GL_FUNC_VOID(OpenGL,true,glStencilFuncSeparate,(GLenum a,GLenum b,GLint c,GLuint d),(a,b,c,d))
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_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))
GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferRenderbufferEXT,(GLenum a,GLenum b,GLenum c,GLuint d),(a,b,c,d))
GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferTexture2DEXT,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e),(a,b,c,d,e))
GL_FUNC_VOID(GL_EXT_framebuffer_object,false,glFramebufferTexture3DEXT,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e,GLint f),(a,b,c,d,e,f))
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_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))
GL_FUNC_VOID(GL_APPLE_fence,false,glFinishFenceAPPLE,(GLuint a),(a))
GL_FUNC_VOID(GL_APPLE_fence,false,glDeleteFencesAPPLE,(GLsizei a,const GLuint *b),(a,b))
GL_FUNC_VOID(GL_APPLE_fence,false,glGenFencesAPPLE,(GLsizei a,GLuint *b),(a,b))
GL_EXT(GL_NV_fence,-1,-1)
GL_FUNC(GL_NV_fence,false,GLboolean,glTestFenceNV,(GLuint a),(a))
GL_FUNC_VOID(GL_NV_fence,false,glSetFenceNV,(GLuint a,GLenum b),(a,b))
GL_FUNC_VOID(GL_NV_fence,false,glFinishFenceNV,(GLuint a),(a))
GL_FUNC_VOID(GL_NV_fence,false,glDeleteFencesNV,(GLsizei a,const GLuint *b),(a,b))
GL_FUNC_VOID(GL_NV_fence,false,glGenFencesNV,(GLsizei a,GLuint *b),(a,b))
GL_EXT(GL_ARB_sync,3,2)
#ifdef HAVE_GL_ARB_SYNC
GL_FUNC_VOID(GL_ARB_sync,false,glGetSynciv,(GLsync a, GLenum b, GLsizei c, GLsizei *d, GLint *e),(a,b,c,d,e))
GL_FUNC(GL_ARB_sync,false,GLenum,glClientWaitSync,(GLsync a, GLbitfield b, GLuint64 c),(a,b,c))
GL_FUNC_VOID(GL_ARB_sync,false,glWaitSync,(GLsync a, GLbitfield b, GLuint64 c),(a,b,c))
GL_FUNC_VOID(GL_ARB_sync,false,glDeleteSync,(GLsync a),(a))
GL_FUNC(GL_ARB_sync,false,GLsync,glFenceSync,(GLenum a, GLbitfield b),(a,b))
#endif
GL_EXT(GL_EXT_draw_buffers2,-1,-1)
GL_FUNC_VOID(GL_EXT_draw_buffers2,true,glColorMaskIndexedEXT,(GLuint a,GLboolean b,GLboolean c,GLboolean d,GLboolean e),(a,b,c,d,e))
GL_FUNC_VOID(GL_EXT_draw_buffers2,true,glEnableIndexedEXT,(GLenum a,GLuint b),(a,b))
GL_FUNC_VOID(GL_EXT_draw_buffers2,true,glDisableIndexedEXT,(GLenum a,GLuint b),(a,b))
GL_FUNC_VOID(GL_EXT_draw_buffers2,true,glGetBooleanIndexedvEXT,(GLenum a,GLuint b,GLboolean *c),(a,b,c))
GL_EXT(GL_EXT_bindable_uniform,-1,-1)
GL_FUNC_VOID(GL_EXT_bindable_uniform,false,glUniformBufferEXT,(GLuint a,GLint b,GLuint c),(a,b,c))
GL_FUNC(GL_EXT_bindable_uniform,false,int,glGetUniformBufferSizeEXT,(GLenum a, GLenum b),(a,b))
GL_FUNC(GL_EXT_bindable_uniform,false,GLintptr,glGetUniformOffsetEXT,(GLenum a, GLenum b),(a,b))
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_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_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_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))
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,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))
GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferRenderbuffer,(GLenum a,GLenum b,GLenum c,GLuint d),(a,b,c,d))
GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferTexture2D,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e),(a,b,c,d,e))
GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glFramebufferTexture3D,(GLenum a,GLenum b,GLenum c,GLuint d,GLint e,GLint f),(a,b,c,d,e,f))
GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glGenFramebuffers,(GLsizei a,GLuint *b),(a,b))
GL_FUNC_VOID(GL_ARB_framebuffer_object,false,glGenRenderbuffers,(GLsizei a,GLuint *b),(a,b))
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_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)
GL_FUNC_VOID(GL_ARB_debug_output,false,glDebugMessageCallbackARB,(void (APIENTRY *a)(GLenum, GLenum , GLuint , GLenum , GLsizei , const GLchar* , GLvoid*) ,void* b),(a,b))
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_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))
GL_FUNC_VOID(OpenGL,true,glGenSamplers,(GLuint a,GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glDeleteSamplers,(GLsizei a,const GLuint *b),(a,b))
GL_FUNC_VOID(OpenGL,true,glBindSampler,(GLuint a, GLuint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glSamplerParameteri,(GLuint a, GLenum b, GLint c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glSamplerParameterf,(GLuint a, GLenum b, GLfloat c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glSamplerParameterfv,(GLuint a, GLenum b, const GLfloat *c),(a,b,c))
GL_EXT(GL_NV_bindless_texture,-1,-1)
GL_FUNC(GL_NV_bindless_texture, false, GLuint64, glGetTextureHandleNV, (GLuint texture), (texture))
GL_FUNC(GL_NV_bindless_texture, false, GLuint64, glGetTextureSamplerHandleNV, (GLuint texture, GLuint sampler), (texture, sampler))
GL_FUNC_VOID(GL_NV_bindless_texture, false, glMakeTextureHandleResidentNV, (GLuint64 handle), (handle))
GL_FUNC_VOID(GL_NV_bindless_texture, false, glMakeTextureHandleNonResidentNV, (GLuint64 handle), (handle))
GL_FUNC_VOID(GL_NV_bindless_texture, false, glUniformHandleui64NV, (GLint location, GLuint64 value), (location, value))
GL_FUNC_VOID(GL_NV_bindless_texture, false, glUniformHandleui64vNV, (int location, GLsizei count, const GLuint64 *value), (location count, value))
GL_FUNC_VOID(GL_NV_bindless_texture, false, glProgramUniformHandleui64NV, (GLuint program, GLint location, GLuint64 value), (program, location, value))
GL_FUNC_VOID(GL_NV_bindless_texture, false, glProgramUniformHandleui64vNV, (GLuint program, GLint location, GLsizei count, const GLuint64 *values), (program, location, count, values))
GL_FUNC(GL_NV_bindless_texture, false, GLboolean, glIsTextureHandleResidentNV, (GLuint64 handle), (handle))
GL_FUNC_VOID(OpenGL,true,glGenQueries,(GLsizei n, GLuint *ids), (n, ids))
GL_FUNC_VOID(OpenGL,true,glDeleteQueries,(GLsizei n, const GLuint *ids),(n, ids))
GL_FUNC_VOID(OpenGL,true,glBeginQuery,(GLenum target, GLuint id), (target, id))
GL_FUNC_VOID(OpenGL,true,glEndQuery,(GLenum target), (target))
GL_FUNC_VOID(OpenGL,true,glQueryCounter,(GLuint id, GLenum target), (id, target))
GL_FUNC_VOID(OpenGL,true,glGetQueryObjectiv,(GLuint id, GLenum pname, GLint *params), (id, pname, params))
GL_FUNC_VOID(OpenGL,true,glGetQueryObjectui64v,(GLuint id, GLenum pname, GLuint64 *params), (id, pname, params))
GL_FUNC_VOID(OpenGL,true,glCopyBufferSubData,(GLenum readtarget, GLenum writetarget, GLintptr readoffset, GLintptr writeoffset, GLsizeiptr size),(readtarget, writetarget, readoffset, writeoffset, size))
GL_EXT(GL_AMD_pinned_memory,-1,-1)
GL_EXT(GL_EXT_framebuffer_multisample_blit_scaled,-1,-1)
GL_FUNC_VOID(OpenGL,true,glGenVertexArrays,(GLsizei n, GLuint *arrays),(n, arrays))
GL_FUNC_VOID(OpenGL,true,glDeleteVertexArrays,(GLsizei n, GLuint *arrays),(n, arrays))
GL_FUNC_VOID(OpenGL,true,glBindVertexArray,(GLuint a),(a))
GL_EXT(GL_EXT_texture_sRGB_decode,-1,-1)
GL_FUNC_VOID(OpenGL,true,glPushClientAttrib,(GLbitfield a),(a))
GL_FUNC_VOID(OpenGL,true,glPopClientAttrib,(void),())
GL_EXT(GL_NVX_gpu_memory_info,-1,-1)
GL_EXT(GL_ATI_meminfo,-1,-1)
GL_EXT(GL_EXT_texture_compression_s3tc,-1,-1)
GL_EXT(GL_EXT_texture_compression_dxt1,-1,-1)
GL_EXT(GL_ANGLE_texture_compression_dxt3,-1,-1)
GL_EXT(GL_ANGLE_texture_compression_dxt5,-1,-1)
// This one is an OS extension. We'll add a little helper function to look for it.
#ifdef _WIN32
GL_EXT(WGL_EXT_swap_control_tear,-1,-1)
#else
GL_EXT(GLX_EXT_swap_control_tear,-1,-1)
#endif

View File

@ -0,0 +1,160 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
#ifndef GLMDEBUG_H
#define GLMDEBUG_H
#include "tier0/platform.h"
// include this anywhere you need to be able to compile-out code related specifically to GLM debugging.
// we expect DEBUG to be driven by the build system so you can include this header anywhere.
// when we come out, GLMDEBUG will be defined to a value - 0, 1, or 2
// 0 means no GLM debugging is possible
// 1 means it's possible and resulted from being a debug build
// 2 means it's possible and resulted from being manually forced on for a release build
#ifdef POSIX
#ifndef GLMDEBUG
#ifdef DEBUG
#define GLMDEBUG 1 // normally 1 here, testing
#else
// #define GLMDEBUG 2 // don't check this in enabled..
#endif
#ifndef GLMDEBUG
#define GLMDEBUG 0
#endif
#endif
#else
#ifndef GLMDEBUG
#define GLMDEBUG 0
#endif
#endif
//===============================================================================
// debug channels
enum EGLMDebugChannel
{
ePrintf,
eDebugger,
eGLProfiler
};
#if GLMDEBUG
// make all these prototypes disappear in non GLMDEBUG
void GLMDebugInitialize( bool forceReinit=false );
bool GLMDetectOGLP( void );
bool GLMDetectGDB( void );
uint GLMDetectAvailableChannels( void );
uint GLMDebugChannelMask( uint *newValue = NULL );
// note that GDB and OGLP can both come and go during run - forceCheck will allow that to be detected.
// mask returned is in form of 1<<n, n from EGLMDebugChannel
#endif
//===============================================================================
// debug message flavors
enum EGLMDebugFlavor
{
eAllFlavors, // 0
eDebugDump, // 1 debug dump flavor -D-
eTenure, // 2 code tenures > <
eComment, // 3 one off messages ---
eMatrixData, // 4 matrix data -M-
eShaderData, // 5 shader data (params) -S-
eFrameBufData, // 6 FBO data (attachments) -F-
eDXStuff, // 7 dxabstract spew -X-
eAllocations, // 8 tracking allocs and frees -A-
eSlowness, // 9 slow things happening (srgb flips..) -Z-
eDefaultFlavor, // not specified (no marker)
eFlavorCount
};
uint GLMDebugFlavorMask( uint *newValue = NULL );
// make all these prototypes disappear in non GLMDEBUG
#if GLMDEBUG
// these are unconditional outputs, they don't interrogate the string
void GLMStringOut( const char *string );
void GLMStringOutIndented( const char *string, int indentColumns );
#ifdef TOGL_DLL_EXPORT
// these will look at the string to guess its flavor: <, >, ---, -M-, -S-
DLL_EXPORT void GLMPrintfVA( const char *fmt, va_list vargs );
DLL_EXPORT void GLMPrintf( const char *fmt, ... );
#else
DLL_IMPORT void GLMPrintfVA( const char *fmt, va_list vargs );
DLL_IMPORT void GLMPrintf( const char *fmt, ... );
#endif
// these take an explicit flavor with a default value
void GLMPrintStr( const char *str, EGLMDebugFlavor flavor = eDefaultFlavor );
#define GLMPRINTTEXT_NUMBEREDLINES 0x80000000
void GLMPrintText( const char *str, EGLMDebugFlavor flavor = eDefaultFlavor, uint options=0 ); // indent each newline
int GLMIncIndent( int indentDelta );
int GLMGetIndent( void );
void GLMSetIndent( int indent );
#endif
// helpful macro if you are in a position to call GLM functions directly (i.e. you live in materialsystem / shaderapidx9)
#if GLMDEBUG
#define GLMPRINTF(args) GLMPrintf args
#define GLMPRINTSTR(args) GLMPrintStr args
#define GLMPRINTTEXT(args) GLMPrintText args
#else
#define GLMPRINTF(args)
#define GLMPRINTSTR(args)
#define GLMPRINTTEXT(args)
#endif
//===============================================================================
// knob twiddling
#ifdef TOGL_DLL_EXPORT
DLL_EXPORT float GLMKnob( char *knobname, float *setvalue ); // Pass NULL to not-set the knob value
DLL_EXPORT float GLMKnobToggle( char *knobname );
#else
DLL_IMPORT float GLMKnob( char *knobname, float *setvalue ); // Pass NULL to not-set the knob value
DLL_IMPORT float GLMKnobToggle( char *knobname );
#endif
//===============================================================================
// other stuff
#if GLMDEBUG
void GLMTriggerDebuggerBreak();
inline void GLMDebugger( void )
{
if (GLMDebugChannelMask() & (1<<eDebugger))
{
#ifdef OSX
asm {int 3 };
#else
DebuggerBreak();
#endif
}
if (GLMDebugChannelMask() & (1<<eGLProfiler))
{
GLMTriggerDebuggerBreak();
}
}
#else
#define GLMDebugger() do { } while(0)
#endif
// helpers for CGLSetOption - no op if no profiler
void GLMProfilerClearTrace( void );
void GLMProfilerEnableTrace( bool enable );
// helpers for CGLSetParameter - no op if no profiler
void GLMProfilerDumpState( void );
void CheckGLError( int line );
#endif // GLMDEBUG_H

View File

@ -0,0 +1,176 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// glmdisplay.h
// display related stuff - used by both GLMgr and the CocoaMgr
//
//===============================================================================
#ifndef GLMDISPLAY_H
#define GLMDISPLAY_H
#pragma once
#ifdef OSX
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#include <OpenGL/CGLTypes.h>
#include <OpenGL/CGLRenderers.h>
#include <OpenGL/CGLCurrent.h>
#include <ApplicationServices/ApplicationServices.h>
#elif defined(DX_TO_GL_ABSTRACTION)
#include <GL/gl.h>
#include <GL/glext.h>
#include "tier0/platform.h"
#else
#error
#endif
typedef void _PseudoNSGLContext; // aka NSOpenGLContext
typedef _PseudoNSGLContext *PseudoNSGLContextPtr;
struct GLMDisplayModeInfoFields
{
uint m_modePixelWidth;
uint m_modePixelHeight;
uint m_modeRefreshHz;
// are we even going to talk about bit depth... not yet
};
struct GLMDisplayInfoFields
{
#ifdef OSX
CGDirectDisplayID m_cgDisplayID;
CGOpenGLDisplayMask m_glDisplayMask; // result of CGDisplayIDToOpenGLDisplayMask on the cg_displayID.
#endif
uint m_displayPixelWidth;
uint m_displayPixelHeight;
};
struct GLMRendererInfoFields
{
/*properties of interest and their desired values.
kCGLRPFullScreen = 54, true
kCGLRPAccelerated = 73, true
kCGLRPWindow = 80, true
kCGLRPRendererID = 70, informational
kCGLRPDisplayMask = 84, informational
kCGLRPBufferModes = 100, informational
kCGLRPColorModes = 103, informational
kCGLRPAccumModes = 104, informational
kCGLRPDepthModes = 105, informational
kCGLRPStencilModes = 106, informational
kCGLRPMaxAuxBuffers = 107, informational
kCGLRPMaxSampleBuffers = 108, informational
kCGLRPMaxSamples = 109, informational
kCGLRPSampleModes = 110, informational
kCGLRPSampleAlpha = 111, informational
kCGLRPVideoMemory = 120, informational
kCGLRPTextureMemory = 121, informational
kCGLRPRendererCount = 128 number of renderers in the CGLRendererInfoObj under examination
kCGLRPOffScreen = 53, D/C
kCGLRPRobust = 75, FALSE or D/C - aka we're asking for no-fallback
kCGLRPBackingStore = 76, D/C
kCGLRPMPSafe = 78, D/C
kCGLRPMultiScreen = 81, D/C
kCGLRPCompliant = 83, D/C
*/
//--------------------------- info we have from CGL renderer queries, IOKit, Gestalt
//--------------------------- these are set up in the displayDB by CocoaMgr
GLint m_fullscreen;
GLint m_accelerated;
GLint m_windowed;
GLint m_rendererID;
GLint m_displayMask;
GLint m_bufferModes;
GLint m_colorModes;
GLint m_accumModes;
GLint m_depthModes;
GLint m_stencilModes;
GLint m_maxAuxBuffers;
GLint m_maxSampleBuffers;
GLint m_maxSamples;
GLint m_sampleModes;
GLint m_sampleAlpha;
GLint m_vidMemory;
GLint m_texMemory;
uint m_pciVendorID;
uint m_pciDeviceID;
char m_pciModelString[64];
char m_driverInfoString[64];
//--------------------------- OS version related - set up by CocoaMgr
// OS version found
uint m_osComboVersion; // 0x00XXYYZZ : XX major, YY minor, ZZ minor minor : 10.6.3 --> 0x000A0603. 10.5.8 --> 0x000A0508.
//--------------------------- shorthands - also set up by CocoaMgr - driven by vendorid / deviceid
bool m_ati;
bool m_atiR5xx;
bool m_atiR6xx;
bool m_atiR7xx;
bool m_atiR8xx;
bool m_atiNewer;
bool m_intel;
bool m_intel95x;
bool m_intel3100;
bool m_intelNewer;
bool m_nv;
bool m_nvG7x;
bool m_nvG8x;
bool m_nvNewer;
//--------------------------- context query results - left blank in the display DB - but valid in a GLMContext (call ctx->Caps() to get a const ref)
// booleans
bool m_hasGammaWrites; // aka glGetBooleanv(GL_FRAMEBUFFER_SRGB_CAPABLE_EXT) / glEnable(GL_FRAMEBUFFER_SRGB_EXT)
bool m_hasMixedAttachmentSizes; // aka ARB_fbo in 10.6.3 - test for min OS vers, then exported ext string
bool m_hasBGRA; // aka GL_BGRA vertex attribs in 10.6.3 - - test for min OS vers, then exported ext string
bool m_hasNewFullscreenMode; // aka 10.6.x "big window" fullscreen mode
bool m_hasNativeClipVertexMode; // aka GLSL gl_ClipVertex does not fall back to SW- OS version and folklore-based
bool m_hasOcclusionQuery; // occlusion query: do you speak it ?!
bool m_hasFramebufferBlit; // framebuffer blit: know what I'm sayin?!
bool m_hasPerfPackage1; // means new MTGL, fast OQ, fast uniform upload, NV can resolve flipped (late summer 2010 post 10.6.4 update)
// counts
int m_maxAniso; // aniso limit - context query
// other exts
bool m_hasBindableUniforms;
int m_maxVertexBindableUniforms;
int m_maxFragmentBindableUniforms;
int m_maxBindableUniformSize;
bool m_hasUniformBuffers;
// runtime options that aren't negotiable once set
bool m_hasDualShaders; // must supply CLI arg "-glmdualshaders" or we go GLSL only
//--------------------------- " can'ts " - specific problems that need to be worked around
bool m_cantBlitReliably; // Intel chipsets have problems blitting sRGB sometimes
bool m_cantAttachSRGB; // NV G8x on 10.5.8 can't have srgb tex on FBO color - separate issue from hasGammaWrites
bool m_cantResolveFlipped; // happens on NV in 10.6.4 and prior - console variable "gl_can_resolve_flipped" can overrule
bool m_cantResolveScaled; // happens everywhere per GL spec but may be relaxed some day - console variable "gl_can_resolve_scaled" can overrule
bool m_costlyGammaFlips; // this means that sRGB sampling state affects shader code gen, resulting in state-dependent code regen
//--------------------------- " bads " - known bad drivers
bool m_badDriver1064NV; // this is the bad NVIDIA driver on 10.6.4 - stutter, tex corruption, black screen issues
};
#endif

View File

@ -0,0 +1,92 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
#ifndef GLMDISPLAYDB_H
#define GLMDISPLAYDB_H
#include "tier1/utlvector.h"
//===============================================================================
// modes, displays, and renderers
//===============================================================================
// GLMDisplayModeInfoFields is in glmdisplay.h
class GLMDisplayMode
{
public:
GLMDisplayModeInfoFields m_info;
GLMDisplayMode( uint width, uint height, uint refreshHz );
GLMDisplayMode() { };
~GLMDisplayMode( void );
void Init( uint width, uint height, uint refreshHz );
void Dump( int which );
};
//===============================================================================
// GLMDisplayInfoFields is in glmdisplay.h
class GLMDisplayInfo
{
public:
GLMDisplayInfoFields m_info;
CUtlVector< GLMDisplayMode* > *m_modes; // starts out NULL, set by PopulateModes
GLMDisplayInfo( void );
~GLMDisplayInfo( void );
void PopulateModes( void );
void Dump( int which );
};
//===============================================================================
// GLMRendererInfoFields is in glmdisplay.h
class GLMRendererInfo
{
public:
GLMRendererInfoFields m_info;
GLMDisplayInfo *m_display;
GLMRendererInfo ();
~GLMRendererInfo ( void );
void Init( GLMRendererInfoFields *info );
void PopulateDisplays();
void Dump( int which );
};
//===============================================================================
class GLMDisplayDB
{
public:
GLMRendererInfo m_renderer;
GLMDisplayDB ( void );
~GLMDisplayDB ( void );
virtual void PopulateRenderers( void );
virtual void PopulateFakeAdapters( uint realRendererIndex ); // fake adapters = one real adapter times however many displays are on it
virtual void Populate( void );
// The info-get functions return false on success.
virtual int GetFakeAdapterCount( void );
virtual bool GetFakeAdapterInfo( int fakeAdapterIndex, int *rendererOut, int *displayOut, GLMRendererInfoFields *rendererInfoOut, GLMDisplayInfoFields *displayInfoOut );
virtual int GetRendererCount( void );
virtual bool GetRendererInfo( int rendererIndex, GLMRendererInfoFields *infoOut );
virtual int GetDisplayCount( int rendererIndex );
virtual bool GetDisplayInfo( int rendererIndex, int displayIndex, GLMDisplayInfoFields *infoOut );
virtual int GetModeCount( int rendererIndex, int displayIndex );
virtual bool GetModeInfo( int rendererIndex, int displayIndex, int modeIndex, GLMDisplayModeInfoFields *infoOut );
virtual void Dump( void );
};
#endif // GLMDISPLAYDB_H

2259
public/togl/linuxwin/glmgr.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,308 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// glmgrbasics.h
// types, common headers, forward declarations, utilities
//
//===============================================================================
#ifndef GLMBASICS_H
#define GLMBASICS_H
#pragma once
#ifdef OSX
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#include <OpenGL/CGLTypes.h>
#include <OpenGL/CGLRenderers.h>
#include <OpenGL/CGLCurrent.h>
#include <OpenGL/CGLProfiler.h>
#include <ApplicationServices/ApplicationServices.h>
#elif defined(DX_TO_GL_ABSTRACTION)
#include <GL/gl.h>
#include <GL/glext.h>
#else
#error
#endif
#include "tier0/platform.h"
#include "bitmap/imageformat.h"
#include "bitvec.h"
#include "tier1/checksum_md5.h"
#include "tier1/utlvector.h"
#include "tier1/convar.h"
#include <sys/stat.h>
#include "dxabstract_types.h"
struct GLMRect;
typedef void *PseudoGLContextPtr;
// types
// 3-d integer box (used for texture lock/unlock etc)
struct GLMRegion
{
int xmin,xmax;
int ymin,ymax;
int zmin,zmax;
};
struct GLMRect // follows GL convention - if coming from the D3D rect you will need to fiddle the Y's
{
int xmin; // left
int ymin; // bottom
int xmax; // right
int ymax; // top
};
// macros
//#define GLMassert(x) assert(x)
// forward decls
class GLMgr; // singleton
class GLMContext; // GL context
class CGLMContextTester; // testing class
class CGLMTex;
class CGLMFBO;
class CGLMProgram;
class CGLMBuffer;
// utilities
typedef enum
{
// D3D codes
eD3D_DEVTYPE,
eD3D_FORMAT,
eD3D_RTYPE,
eD3D_USAGE,
eD3D_RSTATE, // render state
eD3D_SIO, // D3D shader bytecode
eD3D_VTXDECLUSAGE,
// CGL codes
eCGL_RENDID,
// OpenGL error codes
eGL_ERROR,
// OpenGL enums
eGL_ENUM,
eGL_RENDERER
} GLMThing_t;
// these will look at the string to guess its flavor: <, >, ---, -M-, -S-
#ifdef TOGL_DLL_EXPORT
DLL_EXPORT const char* GLMDecode( GLMThing_t type, unsigned long value ); // decode a numeric const
#else
DLL_IMPORT const char* GLMDecode( GLMThing_t type, unsigned long value ); // decode a numeric const
#endif
const char* GLMDecodeMask( GLMThing_t type, unsigned long value ); // decode a bitmask
FORCEINLINE void GLMStop( void ) { DXABSTRACT_BREAK_ON_ERROR(); }
void GLMEnableTrace( bool on );
//===============================================================================
// output functions
// expose these in release now
// Mimic PIX events so we can decorate debug spew
DLL_EXPORT void GLMBeginPIXEvent( const char *str );
DLL_EXPORT void GLMEndPIXEvent( void );
class CScopedGLMPIXEvent
{
CScopedGLMPIXEvent( const CScopedGLMPIXEvent & );
CScopedGLMPIXEvent& operator= ( const CScopedGLMPIXEvent & );
public:
inline CScopedGLMPIXEvent( const char *pName ) { GLMBeginPIXEvent( pName ); }
inline ~CScopedGLMPIXEvent() { GLMEndPIXEvent( ); }
};
#if GLMDEBUG
//===============================================================================
// classes
// helper class making function tracking easier to wire up
class GLMFuncLogger
{
public:
// simple function log
GLMFuncLogger( const char *funcName )
{
m_funcName = funcName;
m_earlyOut = false;
GLMPrintf( ">%s", m_funcName );
};
// more advanced version lets you pass args (i.e. called parameters or anything else of interest)
// no macro for this one, since no easy way to pass through the args as well as the funcname
GLMFuncLogger( const char *funcName, char *fmt, ... )
{
m_funcName = funcName;
m_earlyOut = false;
// this acts like GLMPrintf here
// all the indent policy is down in GLMPrintfVA
// which means we need to inject a ">" at the front of the format string to make this work... sigh.
char modifiedFmt[2000];
modifiedFmt[0] = '>';
strcpy( modifiedFmt+1, fmt );
va_list vargs;
va_start(vargs, fmt);
GLMPrintfVA( modifiedFmt, vargs );
va_end( vargs );
}
~GLMFuncLogger( )
{
if (m_earlyOut)
{
GLMPrintf( "<%s (early out)", m_funcName );
}
else
{
GLMPrintf( "<%s", m_funcName );
}
};
void EarlyOut( void )
{
m_earlyOut = true;
};
const char *m_funcName; // set at construction time
bool m_earlyOut;
};
// handy macro to go with the function tracking class
#define GLM_FUNC GLMFuncLogger _logger_ ( __FUNCTION__ )
#else
#define GLM_FUNC tmZone( TELEMETRY_LEVEL1, TMZF_NONE, "%s", __FUNCTION__ )
#endif
// class to keep an in-memory mirror of a file which may be getting edited during run
class CGLMFileMirror
{
public:
CGLMFileMirror( char *fullpath ); // just associates mirror with file. if file exists it will be read.
//if non existent it will be created with size zero
~CGLMFileMirror( );
bool HasData( void ); // see if data avail
void GetData( char **dataPtr, uint *dataSizePtr ); // read it out
void SetData( char *data, uint dataSize ); // put data in (and write it to disk)
bool PollForChanges( void ); // check disk copy. If different, read it back in and return true.
void UpdateStatInfo( void ); // make sure stat info is current for our file
void ReadFile( void );
void WriteFile( void );
void OpenInEditor( bool foreground=false ); // pass TRUE if you would like the editor to pop to foreground
/// how about a "wait for change" method..
char *m_path; // fullpath to file
bool m_exists;
struct stat m_stat; // stat results for the file (last time checked)
char *m_data; // content of file
uint m_size; // length of content
};
// class based on the file mirror, that makes it easy to edit them outside the app.
// it receives an initial block of text from the engine, and hashes it. ("orig")
// it munges it by duplicating all the text after the "!!" line, and appending it in commented form. ("munged")
// a mirror file is activated, using a filename based on the hash from the orig text.
// if there is already content on disk matching that filename, use that content *unless* the 'blitz' parameter is set.
// (i.e. engine is instructing this subsystem to wipe out any old/modified variants of the text)
class CGLMEditableTextItem
{
public:
CGLMEditableTextItem( char *text, uint size, bool forceOverwrite, char *prefix, char *suffix = NULL ); // create a text blob from text source, optional filename suffix
~CGLMEditableTextItem( );
bool HasData( void );
bool PollForChanges( void ); // return true if stale i.e. you need to get a new edition
void GetCurrentText( char **textOut, uint *sizeOut ); // query for read access to the active blob (could be the original, could be external edited copy)
void OpenInEditor( bool foreground=false ); // call user attention to this text
// internal methods
void GenHashOfOrigText( void );
void GenBaseNameAndFullPath( char *prefix, char *suffix );
void GenMungedText( bool fromMirror );
// members
// orig
uint m_origSize;
char *m_origText; // what was submitted
unsigned char m_origDigest[MD5_DIGEST_LENGTH]; // digest of what was submitted
// munged
uint m_mungedSize;
char *m_mungedText; // re-processed edition, initial content submission to the file mirror
// mirror
char *m_mirrorBaseName; // generated from the hash of the orig text, plus the label / prefix
char *m_mirrorFullPath; // base name
CGLMFileMirror *m_mirror; // file mirror itself. holds "official" copy for GetCurrentText to return.
};
// debug font
extern unsigned char g_glmDebugFontMap[16384];
// class for cracking multi-part text blobs
// sections are demarcated by beginning-of-line markers submitted in a table by the caller
struct GLMTextSection
{
int m_markerIndex; // based on table of markers passed in to constructor
uint m_textOffset; // where is the text - offset
int m_textLength; // how big is the section
};
class CGLMTextSectioner
{
public:
CGLMTextSectioner( char *text, int textSize, const char **markers ); // constructor finds all the sections
~CGLMTextSectioner( );
int Count( void ); // how many sections found
void GetSection( int index, uint *offsetOut, uint *lengthOut, int *markerIndexOut );
// find section, size, what marker
// note that more than one section can be marked similarly.
// so policy isn't made here, you walk the sections and decide what to do if there are dupes.
//members
//section table
CUtlVector< GLMTextSection > m_sectionTable;
};
void GLMGPUTimestampManagerInit();
void GLMGPUTimestampManagerDeinit();
void GLMGPUTimestampManagerTick();
#endif // GLMBASICS_H

View File

@ -0,0 +1,93 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// glmgrext.h
// helper file for extension testing and runtime importing of entry points
//
//===============================================================================
#pragma once
#ifdef OSX
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#elif defined(DX_TO_GL_ABSTRACTION)
#include <GL/gl.h>
#include <GL/glext.h>
#else
#error
#endif
#ifndef GL_EXT_framebuffer_sRGB
#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA
#endif
#ifndef ARB_texture_rg
#define GL_COMPRESSED_RED 0x8225
#define GL_COMPRESSED_RG 0x8226
#define GL_RG 0x8227
#define GL_RG_INTEGER 0x8228
#define GL_R8 0x8229
#define GL_R16 0x822A
#define GL_RG8 0x822B
#define GL_RG16 0x822C
#define GL_R16F 0x822D
#define GL_R32F 0x822E
#define GL_RG16F 0x822F
#define GL_RG32F 0x8230
#define GL_R8I 0x8231
#define GL_R8UI 0x8232
#define GL_R16I 0x8233
#define GL_R16UI 0x8234
#define GL_R32I 0x8235
#define GL_R32UI 0x8236
#define GL_RG8I 0x8237
#define GL_RG8UI 0x8238
#define GL_RG16I 0x8239
#define GL_RG16UI 0x823A
#define GL_RG32I 0x823B
#define GL_RG32UI 0x823C
#endif
#ifndef GL_EXT_bindable_uniform
#define GL_UNIFORM_BUFFER_EXT 0x8DEE
#endif
// unpublished extension enums (thus the "X")
// from EXT_framebuffer_multisample_blit_scaled..
#define XGL_SCALED_RESOLVE_FASTEST_EXT 0x90BA
#define XGL_SCALED_RESOLVE_NICEST_EXT 0x90BB
#ifndef GL_TEXTURE_MINIMIZE_STORAGE_APPLE
#define GL_TEXTURE_MINIMIZE_STORAGE_APPLE 0x85B6
#endif
#ifndef GL_ALL_COMPLETED_NV
#define GL_ALL_COMPLETED_NV 0x84F2
#endif
#ifndef GL_MAP_READ_BIT
#define GL_MAP_READ_BIT 0x0001
#endif
#ifndef GL_MAP_WRITE_BIT
#define GL_MAP_WRITE_BIT 0x0002
#endif
#ifndef GL_MAP_INVALIDATE_RANGE_BIT
#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
#endif
#ifndef GL_MAP_INVALIDATE_BUFFER_BIT
#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
#endif
#ifndef GL_MAP_FLUSH_EXPLICIT_BIT
#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
#endif
#ifndef GL_MAP_UNSYNCHRONIZED_BIT
#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
#endif

View File

@ -0,0 +1,99 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// cglmprogram.h
// GLMgr buffers (index / vertex)
// ... maybe add PBO later as well
//===============================================================================
#ifndef CGLMBUFFER_H
#define CGLMBUFFER_H
#pragma once
// ext links
// http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt
//===============================================================================
// tokens not in the SDK headers
//#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT
// #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9
//#endif
//===============================================================================
// forward declarations
class GLMContext;
enum EGLMBufferType
{
kGLMVertexBuffer,
kGLMIndexBuffer,
kGLMUniformBuffer, // for bindable uniform
kGLMPixelBuffer, // for PBO
kGLMNumBufferTypes
};
// pass this in "options" to constructor to make a dynamic buffer
#define GLMBufferOptionDynamic 0x00000001
struct GLMBuffLockParams
{
uint m_offset;
uint m_size;
bool m_nonblocking;
bool m_discard;
};

91
public/togl/osx/cglmfbo.h Normal file
View File

@ -0,0 +1,91 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// cglmfbo.h
// GLMgr FBO's (render targets)
//
//===============================================================================
#ifndef CGLMFBO_H
#define CGLMFBO_H
#pragma once
#include "togl/rendermechanism.h"
// good FBO references / recaps
// http://www.songho.ca/opengl/gl_fbo.html
// http://www.gamedev.net/reference/articles/article2331.asp
// ext links
// http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt
// http://www.opengl.org/registry/specs/EXT/framebuffer_multisample.txt
//===============================================================================
// tokens not in the SDK headers
#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT
#define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9
#endif
//===============================================================================
// forward declarations
class GLMContext;
// implicitly 16 maximum color attachments possible
enum EGLMFBOAttachment {
kAttColor0, kAttColor1, kAttColor2, kAttColor3,
kAttColor4, kAttColor5, kAttColor6, kAttColor7,
kAttColor8, kAttColor9, kAttColor10, kAttColor11,
kAttColor12, kAttColor13, kAttColor14, kAttColor15,
kAttDepth, kAttStencil, kAttDepthStencil,
kAttCount
};

View File

@ -0,0 +1,291 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// cglmprogram.h
// GLMgr programs (ARBVP/ARBfp)
//
//===============================================================================
#ifndef CGLMPROGRAM_H
#define CGLMPROGRAM_H
#include <sys/stat.h>
#pragma once
// good ARB program references
// http://petewarden.com/notes/archives/2005/05/fragment_progra_2.html
// http://petewarden.com/notes/archives/2005/06/fragment_progra_3.html
// ext links
// http://www.opengl.org/registry/specs/ARB/vertex_program.txt
// http://www.opengl.org/registry/specs/ARB/fragment_program.txt
// http://www.opengl.org/registry/specs/EXT/gpu_program_parameters.txt
//===============================================================================
// tokens not in the SDK headers
//#ifndef GL_DEPTH_STENCIL_ATTACHMENT_EXT
// #define GL_DEPTH_STENCIL_ATTACHMENT_EXT 0x84F9
//#endif
//===============================================================================
// forward declarations
class GLMContext;
class CGLMShaderPair;
class CGLMShaderPairCache;
// CGLMProgram can contain two flavors of the same program, one in assembler, one in GLSL.
// these flavors are pretty different in terms of the API's that are used to activate them -
// for example, assembler programs can just get bound to the context, whereas GLSL programs
// have to be linked. To some extent we try to hide that detail inside GLM.
// for now, make CGLMProgram a container, it does not set policy or hold a preference as to which
// flavor you want to use. GLMContext has to handle that.
enum EGLMProgramType
{
kGLMVertexProgram,
kGLMFragmentProgram,
kGLMNumProgramTypes
};
enum EGLMProgramLang
{
kGLMARB,
kGLMGLSL,
kGLMNumProgramLangs
};
struct GLMShaderDesc
{
union
{
GLuint arb; // ARB program object name
GLhandleARB glsl; // GLSL shader object handle (void*)
} m_object;
// these can change if shader text is edited
bool m_textPresent; // is this flavor(lang) of text present in the buffer?
int m_textOffset; // where is it
int m_textLength; // how big
bool m_compiled; // has this text been through a compile attempt
bool m_valid; // and if so, was the compile successful
int m_slowMark; // has it been flagged during a non native draw batch before. increment every time it's slow.
int m_highWater; // vount of vec4's in the major uniform array ("vc" on vs, "pc" on ps)
// written by dxabstract.... gross!
};
GLenum GLMProgTypeToARBEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target
GLenum GLMProgTypeToGLSLEnum( EGLMProgramType type ); // map vert/frag to ARB asm bind target
class CGLMProgram
{
public:
friend class CGLMShaderPairCache;
friend class CGLMShaderPair;
friend class GLMContext; // only GLMContext can make CGLMProgram objects
friend class GLMTester;
friend class IDirect3D9;
friend class IDirect3DDevice9;
//===============================
// constructor is very light, it just makes one empty program object per flavor.
CGLMProgram( GLMContext *ctx, EGLMProgramType type );
~CGLMProgram( );
void SetProgramText ( char *text ); // import text to GLM object - invalidate any prev compiled program
bool CompileActiveSources ( void ); // compile only the flavors that were provided.
bool Compile ( EGLMProgramLang lang );
bool CheckValidity ( EGLMProgramLang lang );
void LogSlow ( EGLMProgramLang lang ); // detailed spew when called for first time; one liner or perhaps silence after that
void GetLabelIndexCombo ( char *labelOut, int labelOutMaxChars, int *indexOut, int *comboOut );
void GetComboIndexNameString ( char *stringOut, int stringOutMaxChars ); // mmmmmmmm-nnnnnnnn-filename
#if GLMDEBUG
bool PollForChanges( void ); // check mirror for changes.
void ReloadStringFromEditable( void ); // populate m_string from editable item (react to change)
bool SyncWithEditable( void );
#endif
//===============================
// common stuff
GLMContext *m_ctx; // link back to parent context
EGLMProgramType m_type; // vertex or pixel
uint m_serial; // serial number for hashing
char *m_text; // copy of text passed into constructor. Can change if editable shaders is enabled.
// note - it can contain multiple flavors, so use CGLMTextSectioner to scan it and locate them
#if GLMDEBUG
CGLMEditableTextItem *m_editable; // editable text item for debugging
#endif
GLMShaderDesc m_descs[ kGLMNumProgramLangs ];
uint m_samplerMask; // (1<<n) mask of sampler active locs, if this is a fragment shader (dxabstract sets this field)
};
//===============================================================================

View File

@ -0,0 +1,85 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// cglmquery.h
// GLMgr queries
//
//===============================================================================
#ifndef CGLMQUERY_H
#define CGLMQUERY_H
#pragma once
//===============================================================================
// forward declarations
class GLMContext;
class CGLMQuery;
//===============================================================================
enum EGLMQueryType
{
EOcclusion,
EFence,
EGLMQueryCount
};
struct GLMQueryParams
{
EGLMQueryType m_type;
};
class CGLMQuery
{
// leave everything public til it's running
public:
friend class GLMContext; // only GLMContext can make CGLMTex objects
friend class IDirect3DDevice9;
friend class IDirect3DQuery9;
GLMContext *m_ctx; // link back to parent context
GLMQueryParams m_params; // params created with

273
public/togl/osx/cglmtex.h Normal file
View File

@ -0,0 +1,273 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// cglmtex.h
// GLMgr textures
//
//===============================================================================
#ifndef CGLMTEX_H
#define CGLMTEX_H
#pragma once
#include "tier1/utlhash.h"
#include "tier1/utlmap.h"
//===============================================================================
// forward declarations
class GLMContext;
class GLMTester;
class CGLMTexLayoutTable;
class CGLMTex;
class CGLMFBO;
class IDirect3DSurface9;
//===============================================================================
struct GLMTexFormatDesc
{
char *m_formatSummary; // for debug visibility
D3DFORMAT m_d3dFormat; // what D3D knows it as; see public/bitmap/imageformat.h
GLenum m_glIntFormat; // GL internal format
GLenum m_glIntFormatSRGB; // internal format if SRGB flavor
GLenum m_glDataFormat; // GL data format
GLenum m_glDataType; // GL data type
int m_chunkSize; // 1 or 4 - 4 is used for compressed textures
int m_bytesPerSquareChunk; // how many bytes for the smallest quantum (m_chunkSize x m_chunkSize)
// this description lets us calculate size cleanly without conditional logic for compression
};
const GLMTexFormatDesc *GetFormatDesc( D3DFORMAT format );
//===============================================================================
// utility function for generating slabs of texels. mostly for test.
typedef struct
{
// in
D3DFORMAT m_format;
void *m_dest; // dest address
int m_chunkCount; // square chunk count (single texels or compressed blocks)
int m_byteCountLimit; // caller expectation of max number of bytes to write out
float r,g,b,a; // color desired
// out
int m_bytesWritten;
} GLMGenTexelParams;
// return true if successful
bool GLMGenTexels( GLMGenTexelParams *params );
//===============================================================================
struct GLMTexLayoutSlice
{
int m_xSize,m_ySize,m_zSize; //texel dimensions of this slice
int m_storageOffset; //where in the storage slab does this slice live
int m_storageSize; //how much storage does this slice occupy
};
enum EGLMTexFlags
{
kGLMTexMipped = 0x01,
kGLMTexMippedAuto = 0x02,
kGLMTexRenderable = 0x04,
kGLMTexIsStencil = 0x08,
kGLMTexIsDepth = 0x10,
kGLMTexSRGB = 0x20,
kGLMTexMultisampled = 0x40, // has an RBO backing it. Cannot combine with Mipped, MippedAuto. One slice maximum, only targeting GL_TEXTURE_2D.
// actually not 100% positive on the mipmapping, the RBO itself can't be mipped, but the resulting texture could
// have mipmaps generated.
};
//===============================================================================
struct GLMTexLayoutKey
{
// input values: held const, these are the hash key for the form map
GLenum m_texGLTarget; // flavor of texture: GL_TEXTURE_2D, GL_TEXTURE_3D, GLTEXTURE_CUBE_MAP
D3DFORMAT m_texFormat; // D3D texel format
unsigned long m_texFlags; // mipped, autogen mips, render target, ... ?
unsigned long m_texSamples; // zero for a plain tex, 2/4/6/8 for "MSAA tex" (RBO backed)
int m_xSize,m_ySize,m_zSize; // size of base mip
};
bool LessFunc_GLMTexLayoutKey( const GLMTexLayoutKey &a, const GLMTexLayoutKey &b );
#define GLM_TEX_MAX_MIPS 14
#define GLM_TEX_MAX_FACES 6
#define GLM_TEX_MAX_SLICES (GLM_TEX_MAX_MIPS * GLM_TEX_MAX_FACES)
struct GLMTexLayout
{
char *m_layoutSummary; // for debug visibility
// const inputs used for hashing
GLMTexLayoutKey m_key;
// refcount
int m_refCount;
// derived values:
GLMTexFormatDesc *m_format; // format specific info
int m_mipCount; // derived by starying at base size and working down towards 1x1
int m_faceCount; // 1 for 2d/3d, 6 for cubemap
int m_sliceCount; // product of faces and mips
int m_storageTotalSize; // size of storage slab required
// slice array
GLMTexLayoutSlice m_slices[0]; // dynamically allocated 2-d array [faces][mips]
};
class CGLMTexLayoutTable
{
public:
CGLMTexLayoutTable();
GLMTexLayout *NewLayoutRef( GLMTexLayoutKey *key ); // pass in a pointer to layout key - receive ptr to completed layout
void DelLayoutRef( GLMTexLayout *layout ); // pass in pointer to completed layout. refcount is dropped.
void DumpStats( void );

View File

@ -0,0 +1,804 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//
//
//==================================================================================================
#ifndef DXABSTRACT_H
#define DXABSTRACT_H
#ifdef _WIN32
#pragma once
#endif
#include "togl/rendermechanism.h"
#include "materialsystem/ishader.h"
// Uncomment this on Windows if you want to compile the Windows GL version.
// #undef USE_ACTUAL_DX
#ifdef USE_ACTUAL_DX
#ifndef WIN32
#error sorry man
#endif
#ifdef _X360
#include "d3d9.h"
#include "d3dx9.h"
#else
#include <windows.h>
#include "../../dx9sdk/include/d3d9.h"
#include "../../dx9sdk/include/d3dx9.h"
#endif
typedef HWND VD3DHWND;
#else
#ifdef WIN32
#error Gl on win32?
#endif
#include "tier0/platform.h"
#ifndef DX_TO_GL_ABSTRACTION
#define DX_TO_GL_ABSTRACTION
#endif
#include "bitmap/imageformat.h"
#include "togl/rendermechanism.h"
#ifdef OSX
extern "C" void Debugger(void);
#endif
// turn this on to get refcount logging from IUnknown
#define IUNKNOWN_ALLOC_SPEW 0
#define IUNKNOWN_ALLOC_SPEW_MARK_ALL 0
// ------------------------------------------------------------------------------------------------------------------------------ //
// DEFINES
// ------------------------------------------------------------------------------------------------------------------------------ //
typedef void* VD3DHWND;
typedef void* VD3DHANDLE;
TOGL_INTERFACE void toglGetClientRect( VD3DHWND hWnd, RECT *destRect );
struct TOGL_CLASS IUnknown
{
int m_refcount[2];
bool m_mark;
IUnknown( void )
{
m_refcount[0] = 1;
m_refcount[1] = 0;
m_mark = (IUNKNOWN_ALLOC_SPEW_MARK_ALL != 0); // either all are marked, or only the ones that have SetMark(true) called on them
#if IUNKNOWN_ALLOC_SPEW
if (m_mark)
{
GLMPRINTF(("-A- IUnew (%08x) refc -> (%d,%d) ",this,m_refcount[0],m_refcount[1]));
}
#endif
};
virtual ~IUnknown( void )
{
#if IUNKNOWN_ALLOC_SPEW
if (m_mark)
{
GLMPRINTF(("-A- IUdel (%08x) ",this ));
}
#endif
};
void AddRef( int which=0, char *comment = NULL )
{
Assert( which >= 0 );
Assert( which < 2 );
m_refcount[which]++;
#if IUNKNOWN_ALLOC_SPEW
if (m_mark)
{
GLMPRINTF(("-A- IUAddRef (%08x,%d) refc -> (%d,%d) [%s]",this,which,m_refcount[0],m_refcount[1],comment?comment:"...")) ;
if (!comment)
{
GLMPRINTF(("")) ; // place to hang a breakpoint
}
}
#endif
};
ULONG __stdcall Release( int which=0, char *comment = NULL )
{
Assert( which >= 0 );
Assert( which < 2 );
//int oldrefcs[2] = { m_refcount[0], m_refcount[1] };
bool deleting = false;
m_refcount[which]--;
if ( (!m_refcount[0]) && (!m_refcount[1]) )
{
deleting = true;
}
#if IUNKNOWN_ALLOC_SPEW
if (m_mark)
{
GLMPRINTF(("-A- IURelease (%08x,%d) refc -> (%d,%d) [%s] %s",this,which,m_refcount[0],m_refcount[1],comment?comment:"...",deleting?"->DELETING":""));
if (!comment)
{
GLMPRINTF(("")) ; // place to hang a breakpoint
}
}
#endif
if (deleting)
{
if (m_mark)
{
GLMPRINTF(("")) ; // place to hang a breakpoint
}
delete this;
return 0;
}
else
{
return m_refcount[0];
}
};
void SetMark( bool markValue, char *comment=NULL )
{
#if IUNKNOWN_ALLOC_SPEW
if (!m_mark && markValue) // leading edge detect
{
// print the same thing that the constructor would have printed if it had been marked from the beginning
// i.e. it's anticipated that callers asking for marking will do so right at create time
GLMPRINTF(("-A- IUSetMark (%08x) refc -> (%d,%d) (%s) ",this,m_refcount[0],m_refcount[1],comment?comment:"..."));
}
#endif
m_mark = markValue;
}
};
// ------------------------------------------------------------------------------------------------------------------------------ //
// INTERFACES
// ------------------------------------------------------------------------------------------------------------------------------ //
struct TOGL_CLASS IDirect3DResource9 : public IUnknown
{
IDirect3DDevice9 *m_device; // parent device
D3DRESOURCETYPE m_restype;
DWORD SetPriority(DWORD PriorityNew);
};
struct TOGL_CLASS IDirect3DBaseTexture9 : public IDirect3DResource9 // "A Texture.."
{
D3DSURFACE_DESC m_descZero; // desc of top level.
CGLMTex *m_tex; // a CGLMTex can represent all forms of tex
int m_srgbFlipCount;
virtual ~IDirect3DBaseTexture9();
D3DRESOURCETYPE GetType();
DWORD GetLevelCount();
HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc);
};
struct TOGL_CLASS IDirect3DTexture9 : public IDirect3DBaseTexture9 // "Texture 2D"
{
IDirect3DSurface9 *m_surfZero; // surf of top level.
virtual ~IDirect3DTexture9();
HRESULT LockRect(UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags);
HRESULT UnlockRect(UINT Level);
HRESULT GetSurfaceLevel(UINT Level,IDirect3DSurface9** ppSurfaceLevel);
};
struct TOGL_CLASS IDirect3DCubeTexture9 : public IDirect3DBaseTexture9 // "Texture Cube Map"
{
IDirect3DSurface9 *m_surfZero[6]; // surfs of top level.
virtual ~IDirect3DCubeTexture9();
HRESULT GetCubeMapSurface(D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface9** ppCubeMapSurface);
HRESULT GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc);
};
struct TOGL_CLASS IDirect3DVolumeTexture9 : public IDirect3DBaseTexture9 // "Texture 3D"
{
IDirect3DSurface9 *m_surfZero; // surf of top level.
D3DVOLUME_DESC m_volDescZero; // volume desc top level
virtual ~IDirect3DVolumeTexture9();
HRESULT LockBox(UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags);
HRESULT UnlockBox(UINT Level);
HRESULT GetLevelDesc( UINT level, D3DVOLUME_DESC *pDesc );
};
// for the moment, a "D3D surface" is modeled as a GLM tex, a face, and a mip.
// no Create method, these are filled in by the various create surface methods.
struct TOGL_CLASS IDirect3DSurface9 : public IDirect3DResource9
{
virtual ~IDirect3DSurface9();
HRESULT LockRect(D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags);
HRESULT UnlockRect();
HRESULT GetDesc(D3DSURFACE_DESC *pDesc);
D3DSURFACE_DESC m_desc;
CGLMTex *m_tex;
int m_face;
int m_mip;
};
struct TOGL_CLASS IDirect3D9 : public IUnknown
{
public:
virtual ~IDirect3D9();
UINT GetAdapterCount(); //cheese: returns 1
HRESULT GetDeviceCaps (UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS9* pCaps);
HRESULT GetAdapterIdentifier (UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER9* pIdentifier);
HRESULT CheckDeviceFormat (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat);
UINT GetAdapterModeCount (UINT Adapter,D3DFORMAT Format);
HRESULT EnumAdapterModes (UINT Adapter,D3DFORMAT Format,UINT Mode,D3DDISPLAYMODE* pMode);
HRESULT CheckDeviceType (UINT Adapter,D3DDEVTYPE DevType,D3DFORMAT AdapterFormat,D3DFORMAT BackBufferFormat,BOOL bWindowed);
HRESULT GetAdapterDisplayMode (UINT Adapter,D3DDISPLAYMODE* pMode);
HRESULT CheckDepthStencilMatch (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat);
HRESULT CheckDeviceMultiSampleType (UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType,DWORD* pQualityLevels);
HRESULT CreateDevice (UINT Adapter,D3DDEVTYPE DeviceType,VD3DHWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice9** ppReturnedDeviceInterface);
};
struct TOGL_CLASS IDirect3DSwapChain9 : public IUnknown
{
};
// typedef enum D3DDECLUSAGE
// {
// D3DDECLUSAGE_POSITION = 0,
// D3DDECLUSAGE_BLENDWEIGHT = 1,
// D3DDECLUSAGE_BLENDINDICES = 2,
// D3DDECLUSAGE_NORMAL = 3,
// D3DDECLUSAGE_PSIZE = 4,
// D3DDECLUSAGE_TEXCOORD = 5,
// D3DDECLUSAGE_TANGENT = 6,
// D3DDECLUSAGE_BINORMAL = 7,
// D3DDECLUSAGE_TESSFACTOR = 8,
// D3DDECLUSAGE_POSITIONT = 9,
// D3DDECLUSAGE_COLOR = 10,
// D3DDECLUSAGE_FOG = 11,
// D3DDECLUSAGE_DEPTH = 12,
// D3DDECLUSAGE_SAMPLE = 13,
// } D3DDECLUSAGE, *LPD3DDECLUSAGE;
// Constants
//
// D3DDECLUSAGE_POSITION
// Position data ranging from (-1,-1) to (1,1). Use D3DDECLUSAGE_POSITION with
// a usage index of 0 to specify untransformed position for fixed function
// vertex processing and the n-patch tessellator. Use D3DDECLUSAGE_POSITION
// with a usage index of 1 to specify untransformed position in the fixed
// function vertex shader for vertex tweening.
//
// D3DDECLUSAGE_BLENDWEIGHT
// Blending weight data. Use D3DDECLUSAGE_BLENDWEIGHT with a usage index of 0
// to specify the blend weights used in indexed and nonindexed vertex
// blending.
//
// D3DDECLUSAGE_BLENDINDICES
// Blending indices data. Use D3DDECLUSAGE_BLENDINDICES with a usage index of
// 0 to specify matrix indices for indexed paletted skinning.
//
// D3DDECLUSAGE_NORMAL
// Vertex normal data. Use D3DDECLUSAGE_NORMAL with a usage index of 0 to
// specify vertex normals for fixed function vertex processing and the n-patch
// tessellator. Use D3DDECLUSAGE_NORMAL with a usage index of 1 to specify
// vertex normals for fixed function vertex processing for vertex tweening.
//
// D3DDECLUSAGE_PSIZE
// Point size data. Use D3DDECLUSAGE_PSIZE with a usage index of 0 to specify
// the point-size attribute used by the setup engine of the rasterizer to
// expand a point into a quad for the point-sprite functionality.
//
// D3DDECLUSAGE_TEXCOORD
// Texture coordinate data. Use D3DDECLUSAGE_TEXCOORD, n to specify texture
// coordinates in fixed function vertex processing and in pixel shaders prior
// to ps_3_0. These can be used to pass user defined data.
//
// D3DDECLUSAGE_TANGENT
// Vertex tangent data.
//
// D3DDECLUSAGE_BINORMAL
// Vertex binormal data.
//
// D3DDECLUSAGE_TESSFACTOR
// Single positive floating point value. Use D3DDECLUSAGE_TESSFACTOR with a
// usage index of 0 to specify a tessellation factor used in the tessellation
// unit to control the rate of tessellation. For more information about the
// data type, see D3DDECLTYPE_FLOAT1.
//
// D3DDECLUSAGE_POSITIONT
// Vertex data contains transformed position data ranging from (0,0) to
// (viewport width, viewport height). Use D3DDECLUSAGE_POSITIONT with a usage
// index of 0 to specify transformed position. When a declaration containing
// this is set, the pipeline does not perform vertex processing.
//
// D3DDECLUSAGE_COLOR
// Vertex data contains diffuse or specular color. Use D3DDECLUSAGE_COLOR with
// a usage index of 0 to specify the diffuse color in the fixed function
// vertex shader and pixel shaders prior to ps_3_0. Use D3DDECLUSAGE_COLOR
// with a usage index of 1 to specify the specular color in the fixed function
// vertex shader and pixel shaders prior to ps_3_0.
//
// D3DDECLUSAGE_FOG
// Vertex data contains fog data. Use D3DDECLUSAGE_FOG with a usage index of 0
// to specify a fog blend value used after pixel shading finishes. This
// applies to pixel shaders prior to version ps_3_0.
//
// D3DDECLUSAGE_DEPTH
// Vertex data contains depth data.
//
// D3DDECLUSAGE_SAMPLE
// Vertex data contains sampler data. Use D3DDECLUSAGE_SAMPLE with a usage
// index of 0 to specify the displacement value to look up. It can be used
// only with D3DDECLUSAGE_LOOKUPPRESAMPLED or D3DDECLUSAGE_LOOKUP.
//note the form of the list terminator..
// #define D3DDECL_END() {0xFF,0,D3DDECLTYPE_UNUSED,0,0,0}
// typedef struct _D3DVERTEXELEMENT9
// {
// WORD Stream; // Stream index
// WORD Offset; // Offset in the stream in bytes
// BYTE Type; // Data type
// BYTE Method; // Processing method
// BYTE Usage; // Semantics
// BYTE UsageIndex; // Semantic index
// } D3DVERTEXELEMENT9, *LPD3DVERTEXELEMENT9;
#define MAX_D3DVERTEXELEMENTS 16
struct TOGL_CLASS IDirect3DVertexDeclaration9 : public IUnknown
{
//public:
uint m_elemCount;
D3DVERTEXELEMENT9_GL m_elements[ MAX_D3DVERTEXELEMENTS ];
virtual ~IDirect3DVertexDeclaration9();
};
struct TOGL_CLASS IDirect3DQuery9 : public IDirect3DResource9 //was IUnknown
{
//public:
D3DQUERYTYPE m_type; // D3DQUERYTYPE_OCCLUSION or D3DQUERYTYPE_EVENT
GLMContext *m_ctx;
CGLMQuery *m_query;
virtual ~IDirect3DQuery9();
HRESULT Issue(DWORD dwIssueFlags);
HRESULT GetData(void* pData,DWORD dwSize,DWORD dwGetDataFlags);
};
struct TOGL_CLASS IDirect3DVertexBuffer9 : public IDirect3DResource9 //was IUnknown
{
//public:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,329 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// glentrypoints.h
//
//===============================================================================
#ifndef GLENTRYPOINTS_H
#define GLENTRYPOINTS_H
#pragma once
#ifdef DX_TO_GL_ABSTRACTION
#include "tier0/platform.h"
#include "tier0/dynfunction.h"
#include "tier0/vprof_telemetry.h"
#include "interface.h"
#include "togl/rendermechanism.h"
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef CALLBACK
#define CALLBACK
#endif
void *VoidFnPtrLookup_GlMgr(const char *fn, bool &okay, const bool bRequired, void *fallback=NULL);
#if GL_TELEMETRY_ZONES || GL_TRACK_API_TIME
class CGLExecuteHelperBase
{
public:
inline void StartCall(const char *pName);
inline void StopCall(const char *pName);
#if GL_TRACK_API_TIME
TmU64 m_nStartTime;
#endif
};
template < class FunctionType, typename Result >
class CGLExecuteHelper : public CGLExecuteHelperBase
{
public:
inline CGLExecuteHelper(FunctionType pFn, const char *pName ) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(); StopCall(pName); }
template<typename A> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a); StopCall(pName); }
template<typename A, typename B> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b); StopCall(pName); }
template<typename A, typename B, typename C> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c); StopCall(pName); }
template<typename A, typename B, typename C, typename D> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d, e); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d, e, f); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d, e, f, g); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g, H h) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d, e, f, g, h); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g, H h, I i) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d, e, f, g, h, i); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j) : m_pFn( pFn ) { StartCall(pName); m_Result = (*m_pFn)(a, b, c, d, e, f, g, h, i, j); StopCall(pName); }
inline operator Result() const { return m_Result; }
inline operator char*() const { return (char*)m_Result; }
FunctionType m_pFn;
Result m_Result;
};
template < class FunctionType>
class CGLExecuteHelper<FunctionType, void> : public CGLExecuteHelperBase
{
public:
inline CGLExecuteHelper(FunctionType pFn, const char *pName ) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(); StopCall(pName); }
template<typename A> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a); StopCall(pName); }
template<typename A, typename B> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b); StopCall(pName); }
template<typename A, typename B, typename C> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c); StopCall(pName); }
template<typename A, typename B, typename C, typename D> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d, e); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d, e, f); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d, e, f, g); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g, H h) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d, e, f, g, h); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g, H h, I i) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d, e, f, g, h, i); StopCall(pName); }
template<typename A, typename B, typename C, typename D, typename E, typename F, typename G, typename H, typename I, typename J> inline CGLExecuteHelper(FunctionType pFn, const char *pName, A a, B b, C c, D d, E e, F f, G g, H h, I i, J j) : m_pFn( pFn ) { StartCall(pName); (*m_pFn)(a, b, c, d, e, f, g, h, i, j); StopCall(pName); }
FunctionType m_pFn;
};
#endif
template < class FunctionType, typename Result >
class CDynamicFunctionOpenGLBase
{
public:
// Construct with a NULL function pointer. You must manually call
// Lookup() before you can call a dynamic function through this interface.
CDynamicFunctionOpenGLBase() : m_pFn(NULL) {}
// Construct and do a lookup right away. You will need to make sure that
// the lookup actually succeeded, as the gl library might have failed to load
// or (fn) might not exist in it.
CDynamicFunctionOpenGLBase(const char *fn, FunctionType fallback=NULL) : m_pFn(NULL)
{
Lookup(fn, fallback);
}
// Construct and do a lookup right away. See comments in Lookup() about what (okay) does.
CDynamicFunctionOpenGLBase(const char *fn, bool &okay, FunctionType fallback=NULL) : m_pFn(NULL)
{
Lookup(fn, okay, fallback);
}
// Load library if necessary, look up symbol. Returns true and sets
// m_pFn on successful lookup, returns false otherwise. If the
// function pointer is already looked up, this return true immediately.
// Use Reset() first if you want to look up the symbol again.
// This function will return false immediately unless (okay) is true.
// This allows you to chain lookups like this:
// bool okay = true;
// x.Lookup(lib, "x", okay);
// y.Lookup(lib, "y", okay);
// z.Lookup(lib, "z", okay);
// if (okay) { printf("All functions were loaded successfully!\n"); }
// If you supply a fallback, it'll be used if the lookup fails (and if
// non-NULL, means this will always return (okay)).
bool Lookup(const char *fn, bool &okay, FunctionType fallback=NULL)
{
if (!okay)
return false;
else if (this->m_pFn == NULL)
{
this->m_pFn = (FunctionType) VoidFnPtrLookup_GlMgr(fn, okay, false, (void *) fallback);
this->SetFuncName( fn );
}
return okay;
}
// Load library if necessary, look up symbol. Returns true and sets
// m_pFn on successful lookup, returns false otherwise. If the
// function pointer is already looked up, this return true immediately.
// Use Reset() first if you want to look up the symbol again.
// This function will return false immediately unless (okay) is true.
// If you supply a fallback, it'll be used if the lookup fails (and if
// non-NULL, means this will always return true).
bool Lookup(const char *fn, FunctionType fallback=NULL)
{
bool okay = true;
return Lookup(fn, okay, fallback);
}
// Invalidates the current lookup. Makes the function pointer NULL. You
// will need to call Lookup() before you can call a dynamic function
// through this interface again.
void Reset() { m_pFn = NULL; }
// Force this to be a specific function pointer.
void Force(FunctionType ptr) { m_pFn = ptr; }
// Retrieve the actual function pointer.
FunctionType Pointer() const { return m_pFn; }
#if GL_TELEMETRY_ZONES || GL_TRACK_API_TIME
#if GL_TELEMETRY_ZONES
#define GL_FUNC_NAME m_szName
#else
#define GL_FUNC_NAME ""
#endif
inline CGLExecuteHelper<FunctionType, Result> operator() () const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME ); }
template<typename T>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a); }
template<typename T, typename U>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b); }
template<typename T, typename U, typename V>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c ) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c); }
template<typename T, typename U, typename V, typename W>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d); }
template<typename T, typename U, typename V, typename W, typename X>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d, X e) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d, e); }
template<typename T, typename U, typename V, typename W, typename X, typename Y>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d, X e, Y f) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d, e, f); }
template<typename T, typename U, typename V, typename W, typename X, typename Y, typename Z>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d, X e, Y f, Z g) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d, e, f, g); }
template<typename T, typename U, typename V, typename W, typename X, typename Y, typename Z, typename A>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d, X e, Y f, Z g, A h) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d, e, f, g, h); }
template<typename T, typename U, typename V, typename W, typename X, typename Y, typename Z, typename A, typename B>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d, X e, Y f, Z g, A h, B i) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d, e, f, g, h, i); }
template<typename T, typename U, typename V, typename W, typename X, typename Y, typename Z, typename A, typename B, typename C>
inline CGLExecuteHelper<FunctionType, Result> operator() (T a, U b, V c, W d, X e, Y f, Z g, A h, B i, C j) const { return CGLExecuteHelper<FunctionType, Result>(m_pFn, GL_FUNC_NAME, a, b, c, d, e, f, g, h, i, j); }
#else
operator FunctionType() const { return m_pFn; }
#endif
// Can be used to verify that we have an actual function looked up and
// ready to call: if (!MyDynFunc) { printf("Function not found!\n"); }
operator bool () const { return m_pFn != NULL; }
bool operator !() const { return m_pFn == NULL; }
protected:
FunctionType m_pFn;
#if GL_TELEMETRY_ZONES
char m_szName[32];
inline void SetFuncName(const char *pFn) { V_strncpy( m_szName, pFn, sizeof( m_szName ) ); }
#else
inline void SetFuncName(const char *pFn) { (void)pFn; }
#endif
};
// This works a lot like CDynamicFunctionMustInit, but we use SDL_GL_GetProcAddress().
template < const bool bRequired, class FunctionType, typename Result >
class CDynamicFunctionOpenGL : public CDynamicFunctionOpenGLBase< FunctionType, Result >
{
private: // forbid default constructor.
CDynamicFunctionOpenGL() {}
public:
CDynamicFunctionOpenGL(const char *fn, FunctionType fallback=NULL)
{
bool okay = true;
Lookup(fn, okay, fallback);
this->SetFuncName( fn );
}
CDynamicFunctionOpenGL(const char *fn, bool &okay, FunctionType fallback=NULL)
{
Lookup(fn, okay, fallback);
this->SetFuncName( fn );
}
// Please note this is not virtual.
// !!! FIXME: we might want to fall back and try "EXT" or "ARB" versions in some case.
bool Lookup(const char *fn, bool &okay, FunctionType fallback=NULL)
{
if (this->m_pFn == NULL)
{
this->m_pFn = (FunctionType) VoidFnPtrLookup_GlMgr(fn, okay, bRequired, (void *) fallback);
this->SetFuncName( fn );
}
return okay;
}
};
// This provides all the entry points for a given OpenGL context.
// ENTRY POINTS ARE ONLY VALID FOR THE CONTEXT THAT WAS CURRENT WHEN
// YOU LOOKED THEM UP. 99% of the time, this is not a problem, but
// that 1% is really hard to track down. Always access the GL
// through this class!
class COpenGLEntryPoints
{
public:
// The GL context you are looking up entry points for must be current when you construct this object!
COpenGLEntryPoints();
uint64 m_nTotalGLCycles, m_nTotalGLCalls;
int m_nOpenGLVersionMajor; // if GL_VERSION is 2.1.0, this will be set to 2.
int m_nOpenGLVersionMinor; // if GL_VERSION is 2.1.0, this will be set to 1.
int m_nOpenGLVersionPatch; // if GL_VERSION is 2.1.0, this will be set to 0.
bool m_bHave_OpenGL;
#define GL_EXT(x,glmajor,glminor) bool m_bHave_##x;
#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;
#include "togl/glfuncs.inl"
#undef GL_FUNC_VOID
#undef GL_FUNC
#undef GL_EXT
};
// This will be set to the current OpenGL context's entry points.
extern COpenGLEntryPoints *gGL;
typedef void * (*GL_GetProcAddressCallbackFunc_t)(const char *, bool &, const bool, void *);
#ifdef TOGL_DLL_EXPORT
DLL_EXPORT COpenGLEntryPoints *ToGLConnectLibraries( CreateInterfaceFn factory );
DLL_EXPORT void ToGLDisconnectLibraries();
DLL_EXPORT COpenGLEntryPoints *GetOpenGLEntryPoints(GL_GetProcAddressCallbackFunc_t callback);
#else
DLL_IMPORT COpenGLEntryPoints *ToGLConnectLibraries( CreateInterfaceFn factory );
DLL_IMPORT void ToGLDisconnectLibraries();
DLL_IMPORT COpenGLEntryPoints *GetOpenGLEntryPoints(GL_GetProcAddressCallbackFunc_t callback);
#endif
#if GL_TELEMETRY_ZONES || GL_TRACK_API_TIME
inline void CGLExecuteHelperBase::StartCall(const char *pName)
{
(void)pName;
#if GL_TELEMETRY_ZONES
tmEnter( TELEMETRY_LEVEL3, TMZF_NONE, pName );
#endif
#if GL_TRACK_API_TIME
m_nStartTime = tmFastTime();
#endif
}
inline void CGLExecuteHelperBase::StopCall(const char *pName)
{
#if GL_TRACK_API_TIME
uint64 nTotalCycles = tmFastTime() - m_nStartTime;
#endif
#if GL_TELEMETRY_ZONES
tmLeave( TELEMETRY_LEVEL3 );
#endif
#if GL_TRACK_API_TIME
//double flMilliseconds = g_Telemetry.flRDTSCToMilliSeconds * nTotalCycles;
if (gGL)
{
gGL->m_nTotalGLCycles += nTotalCycles;
gGL->m_nTotalGLCalls++;
}
#endif
}
#endif
#endif // DX_TO_GL_ABSTRACTION
#endif // GLENTRYPOINTS_H

184
public/togl/osx/glfuncs.h Normal file
View File

@ -0,0 +1,184 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
// !!! 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,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,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,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,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,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_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,glDepthRange,(GLclampd a,GLclampd b),(a,b))
GL_FUNC_VOID(OpenGL,true,glDetachObjectARB,(GLhandleARB a,GLhandleARB 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))
GL_FUNC_VOID(OpenGL,true,glDrawBuffer,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glDrawRangeElements,(GLenum a,GLuint b,GLuint c,GLsizei d,GLenum e,const GLvoid *f),(a,b,c,d,e,f))
GL_FUNC_VOID(OpenGL,true,glEnable,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glEnableVertexAttribArray,(GLuint a),(a))
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,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,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(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,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,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,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,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))
GL_FUNC_VOID(OpenGL,true,glTexCoord2f,(GLfloat a,GLfloat b),(a,b))
GL_FUNC_VOID(OpenGL,true,glTexImage2D,(GLenum a,GLint b,GLint c,GLsizei d,GLsizei e,GLint f,GLenum g,GLenum h,const GLvoid *i),(a,b,c,d,e,f,g,h,i))
GL_FUNC_VOID(OpenGL,true,glTexImage3D,(GLenum a,GLint b,GLint c,GLsizei d,GLsizei e,GLsizei f,GLint g,GLenum h,GLenum i,const GLvoid *j),(a,b,c,d,e,f,g,h,i,j))
GL_FUNC_VOID(OpenGL,true,glTexParameterfv,(GLenum a,GLenum b,const GLfloat *c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glTexParameteri,(GLenum a,GLenum b,GLint c),(a,b,c))
GL_FUNC_VOID(OpenGL,true,glTexSubImage2D,(GLenum a,GLint b,GLint c,GLint d,GLsizei e,GLsizei f,GLenum g,GLenum h,const GLvoid *i),(a,b,c,d,e,f,g,h,i))
GL_FUNC_VOID(OpenGL,true,glUniform1f,(GLint a,GLfloat b),(a,b))
GL_FUNC_VOID(OpenGL,true,glUniform1i,(GLint a,GLint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glUniform1iARB,(GLint a,GLint b),(a,b))
GL_FUNC_VOID(OpenGL,true,glUniform4fv,(GLint a,GLsizei b,const GLfloat *c),(a,b,c))
GL_FUNC(OpenGL,true,GLboolean,glUnmapBuffer,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glUseProgram,(GLuint a),(a))
GL_FUNC_VOID(OpenGL,true,glVertex3f,(GLfloat a,GLfloat b,GLfloat c),(a,b,c))

157
public/togl/osx/glmdebug.h Normal file
View File

@ -0,0 +1,157 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
#ifndef GLMDEBUG_H
#define GLMDEBUG_H
#include "tier0/platform.h"
#include <stdarg.h>
// include this anywhere you need to be able to compile-out code related specifically to GLM debugging.
// we expect DEBUG to be driven by the build system so you can include this header anywhere.
// when we come out, GLMDEBUG will be defined to a value - 0, 1, or 2
// 0 means no GLM debugging is possible
// 1 means it's possible and resulted from being a debug build
// 2 means it's possible and resulted from being manually forced on for a release build
#ifdef POSIX
#ifndef GLMDEBUG
#ifdef DEBUG
#define GLMDEBUG 1 // normally 1 here, testing
#else
// #define GLMDEBUG 2 // don't check this in enabled..
#endif
#ifndef GLMDEBUG
#define GLMDEBUG 0
#endif
#endif
#else
#ifndef GLMDEBUG
#define GLMDEBUG 0
#endif
#endif
//===============================================================================
// debug channels
enum EGLMDebugChannel
{
ePrintf,
eDebugger,
eGLProfiler
};
#if GLMDEBUG
// make all these prototypes disappear in non GLMDEBUG
void GLMDebugInitialize( bool forceReinit=false );
bool GLMDetectOGLP( void );
bool GLMDetectGDB( void );
uint GLMDetectAvailableChannels( void );
uint GLMDebugChannelMask( uint *newValue = NULL );
// note that GDB and OGLP can both come and go during run - forceCheck will allow that to be detected.
// mask returned is in form of 1<<n, n from EGLMDebugChannel
#endif
//===============================================================================
// debug message flavors
enum EGLMDebugFlavor
{
eAllFlavors, // 0
eDebugDump, // 1 debug dump flavor -D-
eTenure, // 2 code tenures > <
eComment, // 3 one off messages ---
eMatrixData, // 4 matrix data -M-
eShaderData, // 5 shader data (params) -S-
eFrameBufData, // 6 FBO data (attachments) -F-
eDXStuff, // 7 dxabstract spew -X-
eAllocations, // 8 tracking allocs and frees -A-
eSlowness, // 9 slow things happening (srgb flips..) -Z-
eDefaultFlavor, // not specified (no marker)
eFlavorCount
};
uint GLMDebugFlavorMask( uint *newValue = NULL );
// make all these prototypes disappear in non GLMDEBUG
#if GLMDEBUG
// these are unconditional outputs, they don't interrogate the string
void GLMStringOut( const char *string );
void GLMStringOutIndented( const char *string, int indentColumns );
#ifdef TOGL_DLL_EXPORT
// these will look at the string to guess its flavor: <, >, ---, -M-, -S-
DLL_EXPORT void GLMPrintfVA( const char *fmt, va_list vargs );
DLL_EXPORT void GLMPrintf( const char *fmt, ... );
#else
DLL_IMPORT void GLMPrintfVA( const char *fmt, va_list vargs );
DLL_IMPORT void GLMPrintf( const char *fmt, ... );
#endif
// these take an explicit flavor with a default value
void GLMPrintStr( const char *str, EGLMDebugFlavor flavor = eDefaultFlavor );
#define GLMPRINTTEXT_NUMBEREDLINES 0x80000000
void GLMPrintText( const char *str, EGLMDebugFlavor flavor = eDefaultFlavor, uint options=0 ); // indent each newline
int GLMIncIndent( int indentDelta );
int GLMGetIndent( void );
void GLMSetIndent( int indent );
#endif
// helpful macro if you are in a position to call GLM functions directly (i.e. you live in materialsystem / shaderapidx9)
#if GLMDEBUG
#define GLMPRINTF(args) GLMPrintf args
#define GLMPRINTSTR(args) GLMPrintStr args
#define GLMPRINTTEXT(args) GLMPrintText args
#else
#define GLMPRINTF(args)
#define GLMPRINTSTR(args)
#define GLMPRINTTEXT(args)
#endif
//===============================================================================
// knob twiddling
#ifdef TOGL_DLL_EXPORT
DLL_EXPORT float GLMKnob( char *knobname, float *setvalue ); // Pass NULL to not-set the knob value
DLL_EXPORT float GLMKnobToggle( char *knobname );
#else
DLL_IMPORT float GLMKnob( char *knobname, float *setvalue ); // Pass NULL to not-set the knob value
DLL_IMPORT float GLMKnobToggle( char *knobname );
#endif
//===============================================================================
// other stuff
#if GLMDEBUG
void GLMTriggerDebuggerBreak();
inline void GLMDebugger( void )
{
if (GLMDebugChannelMask() & (1<<eDebugger))
{
DebuggerBreak();
}
if (GLMDebugChannelMask() & (1<<eGLProfiler))
{
GLMTriggerDebuggerBreak();
}
}
#else
#define GLMDebugger() do { } while(0)
#endif
// helpers for CGLSetOption - no op if no profiler
void GLMProfilerClearTrace( void );
void GLMProfilerEnableTrace( bool enable );
// helpers for CGLSetParameter - no op if no profiler
void GLMProfilerDumpState( void );
void CheckGLError( int line );
#endif // GLMDEBUG_H

View File

@ -0,0 +1,177 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// glmdisplay.h
// display related stuff - used by both GLMgr and the CocoaMgr
//
//===============================================================================
#ifndef GLMDISPLAY_H
#define GLMDISPLAY_H
#pragma once
#ifdef OSX
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#include <OpenGL/CGLTypes.h>
#include <OpenGL/CGLRenderers.h>
#include <OpenGL/CGLCurrent.h>
typedef uint32_t CGDirectDisplayID;
typedef uint32_t CGOpenGLDisplayMask;
typedef double CGRefreshRate;
//#include <ApplicationServices/ApplicationServices.h>
#elif defined(LINUX)
#include "tier0/platform.h"
#include <GL/gl.h>
#include <GL/glext.h>
#else
#error
#endif
typedef void _PseudoNSGLContext; // aka NSOpenGLContext
typedef _PseudoNSGLContext *PseudoNSGLContextPtr;
struct GLMDisplayModeInfoFields
{
uint m_modePixelWidth;
uint m_modePixelHeight;
uint m_modeRefreshHz;
// are we even going to talk about bit depth... not yet
};
struct GLMDisplayInfoFields
{
#ifdef OSX
CGDirectDisplayID m_cgDisplayID;
CGOpenGLDisplayMask m_glDisplayMask; // result of CGDisplayIDToOpenGLDisplayMask on the cg_displayID.
#endif
uint m_displayPixelWidth;
uint m_displayPixelHeight;
};
struct GLMRendererInfoFields
{
/*properties of interest and their desired values.
kCGLRPFullScreen = 54, true
kCGLRPAccelerated = 73, true
kCGLRPWindow = 80, true
kCGLRPRendererID = 70, informational
kCGLRPDisplayMask = 84, informational
kCGLRPBufferModes = 100, informational
kCGLRPColorModes = 103, informational
kCGLRPAccumModes = 104, informational
kCGLRPDepthModes = 105, informational
kCGLRPStencilModes = 106, informational
kCGLRPMaxAuxBuffers = 107, informational
kCGLRPMaxSampleBuffers = 108, informational
kCGLRPMaxSamples = 109, informational
kCGLRPSampleModes = 110, informational
kCGLRPSampleAlpha = 111, informational
kCGLRPVideoMemory = 120, informational
kCGLRPTextureMemory = 121, informational
kCGLRPRendererCount = 128 number of renderers in the CGLRendererInfoObj under examination
kCGLRPOffScreen = 53, D/C
kCGLRPRobust = 75, FALSE or D/C - aka we're asking for no-fallback
kCGLRPBackingStore = 76, D/C
kCGLRPMPSafe = 78, D/C
kCGLRPMultiScreen = 81, D/C
kCGLRPCompliant = 83, D/C
*/
//--------------------------- info we have from CGL renderer queries, IOKit, Gestalt
//--------------------------- these are set up in the displayDB by CocoaMgr

View File

@ -0,0 +1,115 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
#ifndef GLMDISPLAYDB_H
#define GLMDISPLAYDB_H
#include "tier1/utlvector.h"
//===============================================================================
// modes, displays, and renderers
// think of renderers as being at the top of a tree.
// each renderer has displays hanging off of it.
// each display has modes hanging off of it.
// the tree is populated on demand and then queried as needed.
//===============================================================================
// GLMDisplayModeInfoFields is in glmdisplay.h
class GLMDisplayMode
{
public:
GLMDisplayModeInfoFields m_info;
GLMDisplayMode( uint width, uint height, uint refreshHz );
GLMDisplayMode() { };
~GLMDisplayMode( void );
void Init( uint width, uint height, uint refreshHz );
void Dump( int which );
};
//===============================================================================
// GLMDisplayInfoFields is in glmdisplay.h
class GLMDisplayInfo
{
public:
GLMDisplayInfoFields m_info;
CUtlVector< GLMDisplayMode* > *m_modes; // starts out NULL, set by PopulateModes
GLMDisplayInfo( void );
~GLMDisplayInfo( void );
void PopulateModes( void );
void Dump( int which );
};
//===============================================================================
// GLMRendererInfoFields is in glmdisplay.h
class GLMRendererInfo
{
public:
GLMRendererInfoFields m_info;
GLMDisplayInfo *m_display; // starts out NULL, set by PopulateDisplays
GLMRendererInfo ( GLMRendererInfoFields *info );
~GLMRendererInfo ( void );
void PopulateDisplays();
void Dump( int which );
};
//===============================================================================
// this is just a tuple describing fake adapters which are really renderer/display pairings.
// dxabstract bridges the gap between the d3d adapter-centric world and the GL renderer+display world.
// this makes it straightforward to handle cases like two video cards with two displays on one, and one on the other -
// you get three fake adapters which represent each useful screen.
// the constraint that dxa will have to follow though, is that if the user wants to change their
// display selection for full screen, they would only be able to pick on that has the same underlying renderer.
// can't change fakeAdapter from one to another with different GL renderer under it. Screen hop but no card hop.
struct GLMFakeAdapter
{
int m_rendererIndex;
int m_displayIndex;
};
class GLMDisplayDB
{
public:
CUtlVector< GLMRendererInfo* > *m_renderers; // starts out NULL, set by PopulateRenderers
CUtlVector< GLMFakeAdapter > m_fakeAdapters;
GLMDisplayDB ( void );
~GLMDisplayDB ( void );
virtual void PopulateRenderers( void );
virtual void PopulateFakeAdapters( uint realRendererIndex ); // fake adapters = one real adapter times however many displays are on it
virtual void Populate( void );
// The info-get functions return false on success.
virtual int GetFakeAdapterCount( void );
virtual bool GetFakeAdapterInfo( int fakeAdapterIndex, int *rendererOut, int *displayOut, GLMRendererInfoFields *rendererInfoOut, GLMDisplayInfoFields *displayInfoOut );
virtual int GetRendererCount( void );
virtual bool GetRendererInfo( int rendererIndex, GLMRendererInfoFields *infoOut );
virtual int GetDisplayCount( int rendererIndex );
virtual bool GetDisplayInfo( int rendererIndex, int displayIndex, GLMDisplayInfoFields *infoOut );
virtual int GetModeCount( int rendererIndex, int displayIndex );
virtual bool GetModeInfo( int rendererIndex, int displayIndex, int modeIndex, GLMDisplayModeInfoFields *infoOut );
virtual void Dump( void );
};
#endif // GLMDISPLAYDB_H

1088
public/togl/osx/glmgr.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,299 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// glmgrbasics.h
// types, common headers, forward declarations, utilities
//
//===============================================================================
#ifndef GLMBASICS_H
#define GLMBASICS_H
#pragma once
#ifdef OSX
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#include <OpenGL/CGLTypes.h>
#include <OpenGL/CGLRenderers.h>
#include <OpenGL/CGLCurrent.h>
#include <OpenGL/CGLProfiler.h>
//#include <ApplicationServices/ApplicationServices.h>
#elif defined(LINUX)
#include <GL/gl.h>
#include <GL/glext.h>
#else
#error
#endif
#include "tier0/platform.h"
#include "bitmap/imageformat.h"
#include "bitvec.h"
#include "tier1/checksum_md5.h"
#include "tier1/utlvector.h"
#include "tier1/convar.h"
#include <sys/stat.h>
#include "dxabstract_types.h"
// types
struct GLMRect;
typedef void *PseudoGLContextPtr;
// 3-d integer box (used for texture lock/unlock etc)
struct GLMRegion
{
int xmin,xmax;
int ymin,ymax;
int zmin,zmax;
};
struct GLMRect // follows GL convention - if coming from the D3D rect you will need to fiddle the Y's
{
int xmin; // left
int ymin; // bottom
int xmax; // right
int ymax; // top
};
// macros
//#define GLMassert(x) assert(x)
// forward decls
class GLMgr; // singleton
class GLMContext; // GL context
class CGLMContextTester; // testing class
class CGLMTex;
class CGLMFBO;
class CGLMProgram;
class CGLMBuffer;
// utilities
typedef enum
{
// D3D codes
eD3D_DEVTYPE,
eD3D_FORMAT,
eD3D_RTYPE,
eD3D_USAGE,
eD3D_RSTATE, // render state
eD3D_SIO, // D3D shader bytecode
eD3D_VTXDECLUSAGE,
// CGL codes
eCGL_RENDID,
// OpenGL error codes
eGL_ERROR,
// OpenGL enums
eGL_ENUM,
eGL_RENDERER
} GLMThing_t;
const char* GLMDecode( GLMThing_t type, unsigned long value ); // decode a numeric const
const char* GLMDecodeMask( GLMThing_t type, unsigned long value ); // decode a bitmask
void GLMStop( void ); // aka Debugger()
void GLMCheckError( bool noStop = false, bool noLog= false );
void GLMEnableTrace( bool on );
// expose these in release now
// Mimic PIX events so we can decorate debug spew
void GLMBeginPIXEvent( const char *str );
void GLMEndPIXEvent( void );
//===============================================================================
// knob twiddling
float GLMKnob( char *knobname, float *setvalue ); // Pass NULL to not-set the knob value
float GLMKnobToggle( char *knobname );
//===============================================================================
// other stuff
// helpers for CGLSetOption - no op if no profiler
void GLMProfilerClearTrace( void );
void GLMProfilerEnableTrace( bool enable );
// helpers for CGLSetParameter - no op if no profiler
void GLMProfilerDumpState( void );
//===============================================================================
// classes
// helper class making function tracking easier to wire up
#if GLMDEBUG
class GLMFuncLogger
{
public:
// simple function log
GLMFuncLogger( const char *funcName )
{
m_funcName = funcName;
m_earlyOut = false;
GLMPrintf( ">%s", m_funcName );
};
// more advanced version lets you pass args (i.e. called parameters or anything else of interest)
// no macro for this one, since no easy way to pass through the args as well as the funcname
GLMFuncLogger( const char *funcName, char *fmt, ... )
{

View File

@ -0,0 +1,93 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// glmgrext.h
// helper file for extension testing and runtime importing of entry points
//
//===============================================================================
#pragma once
#ifdef OSX
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#elif defined(LINUX)
#include <GL/gl.h>
#include <GL/glext.h>
#else
#error
#endif
#ifndef GL_EXT_framebuffer_sRGB
#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA
#endif
#ifndef ARB_texture_rg
#define GL_COMPRESSED_RED 0x8225
#define GL_COMPRESSED_RG 0x8226
#define GL_RG 0x8227
#define GL_RG_INTEGER 0x8228
#define GL_R8 0x8229
#define GL_R16 0x822A
#define GL_RG8 0x822B
#define GL_RG16 0x822C
#define GL_R16F 0x822D
#define GL_R32F 0x822E
#define GL_RG16F 0x822F
#define GL_RG32F 0x8230
#define GL_R8I 0x8231
#define GL_R8UI 0x8232
#define GL_R16I 0x8233
#define GL_R16UI 0x8234
#define GL_R32I 0x8235
#define GL_R32UI 0x8236
#define GL_RG8I 0x8237
#define GL_RG8UI 0x8238
#define GL_RG16I 0x8239
#define GL_RG16UI 0x823A

View File

@ -0,0 +1,70 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
#ifndef RENDERMECHANISM_H
#define RENDERMECHANISM_H
#if defined(DX_TO_GL_ABSTRACTION)
#undef PROTECTED_THINGS_ENABLE
#include <GL/gl.h>
#include <GL/glext.h>
#include "tier0/basetypes.h"
#include "tier0/platform.h"
#if defined(LINUX) || defined(_WIN32)
#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"
#elif defined(OSX)
#include "togl/osx/glmdebug.h"
//#include "togl/osx/glbase.h"
#include "togl/osx/glentrypoints.h"
#include "togl/osx/glmdisplay.h"
#include "togl/osx/glmdisplaydb.h"
#include "togl/osx/glmgrbasics.h"
#include "togl/osx/glmgrext.h"
#include "togl/osx/cglmbuffer.h"
#include "togl/osx/cglmtex.h"
#include "togl/osx/cglmfbo.h"
#include "togl/osx/cglmprogram.h"
#include "togl/osx/cglmquery.h"
#include "togl/osx/glmgr.h"
#include "togl/osx/dxabstract_types.h"
#include "togl/osx/dxabstract.h"
#endif
#else
//USE_ACTUAL_DX
#ifdef WIN32
#ifdef _X360
#include "d3d9.h"
#include "d3dx9.h"
#else
#include <windows.h>
#include "../../dx9sdk/include/d3d9.h"
#include "../../dx9sdk/include/d3dx9.h"
#endif
typedef HWND VD3DHWND;
#endif
#define GLMPRINTF(args)
#define GLMPRINTSTR(args)
#define GLMPRINTTEXT(args)
#endif // defined(DX_TO_GL_ABSTRACTION)
#endif // RENDERMECHANISM_H

View File

@ -95,6 +95,10 @@ public:
// data accessor for above
virtual bool GetShouldVGuiControlSleep() = 0;
// enables VR mode
virtual void SetVRMode( bool bVRMode ) = 0;
virtual bool GetVRMode() = 0;
};
#define VGUI_IVGUI_INTERFACE_VERSION "VGUI_ivgui008"