Browse Source

osx : fix syscalls

pull/71/head
hymei 2 years ago committed by nillerusr
parent
commit
3291cdf978
  1. 14
      appframework/glmrendererinfo_osx.mm
  2. 2
      appframework/sdlmgr.cpp
  3. 2
      datamodel/clipboardmanager.cpp
  4. 1
      engine/filesystem_engine.cpp
  5. 2
      engine/sys_mainwind.cpp
  6. 13
      public/tier0/protected_things.h
  7. 2
      public/tier1/rangecheckedvar.h
  8. 2
      public/togl/linuxwin/glfuncs.h
  9. 4
      public/togl/rendermechanism.h
  10. 9
      togl/linuxwin/cglmprogram.cpp
  11. 25
      togl/linuxwin/glmgr.cpp
  12. 5
      togl/linuxwin/glmgr_flush.inl
  13. 4
      togl/linuxwin/glmgrbasics.cpp
  14. 29
      togl/linuxwin/intelglmallocworkaround.cpp
  15. 8
      vgui2/src/system_posix.cpp
  16. 2
      vguimatsurface/MatSystemSurface.h

14
appframework/glmrendererinfo_osx.mm

@ -206,7 +206,7 @@ GLMRendererInfo::GLMRendererInfo( GLMRendererInfoFields *info ) @@ -206,7 +206,7 @@ GLMRendererInfo::GLMRendererInfo( GLMRendererInfoFields *info )
kCGLPFADoubleBuffer, kCGLPFANoRecovery, kCGLPFAAccelerated,
kCGLPFADepthSize, 0,
kCGLPFAColorSize, 32,
kCGLPFARendererID, info->m_rendererID,
kCGLPFARendererID, (unsigned int)info->m_rendererID,
0
};
@ -859,7 +859,7 @@ void GLMDisplayDB::PopulateRenderers( void ) @@ -859,7 +859,7 @@ void GLMDisplayDB::PopulateRenderers( void )
{
// grab the OS version
long vMajor = 0; long vMinor = 0; long vMinorMinor = 0;
SInt32 vMajor = 0; SInt32 vMinor = 0; SInt32 vMinorMinor = 0;
OSStatus gestalt_err = 0;
gestalt_err = Gestalt(gestaltSystemVersionMajor, &vMajor);
@ -1374,7 +1374,7 @@ bool GLMDisplayDB::GetModeInfo( int rendererIndex, int displayIndex, int modeInd @@ -1374,7 +1374,7 @@ bool GLMDisplayDB::GetModeInfo( int rendererIndex, int displayIndex, int modeInd
{
int modeIndex=0;
number = (CFNumberRef)CFDictionaryGetValue(curModeDict, kCGDisplayMode);
CFNumberGetValue(number, kCFNumberLongType, &modeIndex);
CFNumberGetValue(number, kCFNumberIntType, &modeIndex);
// grab the width and height, I am unclear on whether this is the displayed FB width or the display device width.
int screenWidth=0;
@ -1382,11 +1382,11 @@ bool GLMDisplayDB::GetModeInfo( int rendererIndex, int displayIndex, int modeInd @@ -1382,11 +1382,11 @@ bool GLMDisplayDB::GetModeInfo( int rendererIndex, int displayIndex, int modeInd
int refreshHz=0;
number = (CFNumberRef)CFDictionaryGetValue(curModeDict, kCGDisplayWidth);
CFNumberGetValue(number, kCFNumberLongType, &screenWidth);
CFNumberGetValue(number, kCFNumberIntType, &screenWidth);
number = (CFNumberRef)CFDictionaryGetValue(curModeDict, kCGDisplayHeight);
CFNumberGetValue(number, kCFNumberLongType, &screenHeight);
CFNumberGetValue(number, kCFNumberIntType, &screenHeight);
number = (CFNumberRef)CFDictionaryGetValue(curModeDict, kCGDisplayRefreshRate);
CFNumberGetValue(number, kCFNumberLongType, &refreshHz);
CFNumberGetValue(number, kCFNumberIntType, &refreshHz);
GLMPRINTF(( "-D- GLMDisplayDB::GetModeInfo sees mode-index=%d, width=%d, height=%d on CGID %08x (display index %d on rendererindex %d)",
modeIndex,
@ -1574,7 +1574,7 @@ void GLMDisplayInfo::PopulateModes( void ) @@ -1574,7 +1574,7 @@ void GLMDisplayInfo::PopulateModes( void )
void GLMDisplayInfo::Dump( int which )
{
GLMPRINTF(("\n #%d: GLMDisplayInfo @ %08x, cg-id=%08x display-mask=%08x pixwidth=%d pixheight=%d", which, (int)this, m_info.m_cgDisplayID, m_info.m_glDisplayMask, m_info.m_displayPixelWidth, m_info.m_displayPixelHeight ));
GLMPRINTF(("\n #%d: GLMDisplayInfo @ %08x, cg-id=%08x display-mask=%08x pixwidth=%d pixheight=%d", which, (int)(intp)this, m_info.m_cgDisplayID, m_info.m_glDisplayMask, m_info.m_displayPixelWidth, m_info.m_displayPixelHeight ));
FOR_EACH_VEC( *m_modes, i )
{

2
appframework/sdlmgr.cpp

@ -19,7 +19,9 @@ @@ -19,7 +19,9 @@
#include "tier1/utllinkedlist.h"
#include "tier1/convar.h"
#ifdef TOGLES
#include <EGL/egl.h>
#endif
// NOTE: This has to be the last file included! (turned off below, since this is included like a header)
#include "tier0/memdbgon.h"

2
datamodel/clipboardmanager.cpp

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
#include "datamodel.h"
#include "tier1/KeyValues.h"
#ifndef _LINUX
#ifdef _WIN32
#define USE_WINDOWS_CLIPBOARD
#endif

1
engine/filesystem_engine.cpp

@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
#include "quakedef.h" // for MAX_OSPATH
#include <stdlib.h>
#include <assert.h>
#include <malloc.h>
#include "filesystem.h"
#include "bitmap/tgawriter.h"
#include <tier2/tier2.h>

2
engine/sys_mainwind.cpp

@ -1566,7 +1566,7 @@ void *CGame::GetMainWindowPlatformSpecificHandle( void ) @@ -1566,7 +1566,7 @@ void *CGame::GetMainWindowPlatformSpecificHandle( void )
#ifdef OSX
id nsWindow = (id)pInfo.info.cocoa.window;
SEL selector = sel_registerName("windowRef");
id windowRef = objc_msgSend( nsWindow, selector );
id windowRef = ((id(*)(id, SEL))objc_msgSend)( nsWindow, selector );
return windowRef;
#else
// Not used on Linux.

13
public/tier0/protected_things.h

@ -144,14 +144,15 @@ @@ -144,14 +144,15 @@
#define timeGetTime timeGetTime__USE_VCR_MODE
#if defined( clock )
#undef clock
#endif
#define time time__USE_VCR_MODE
#endif
// MoeMod : breaks system header
//#define time time__USE_VCR_MODE
#if defined( recvfrom )
#undef recvfrom
#endif
#define recvfrom recvfrom__USE_VCR_MODE
//#if defined( recvfrom )
// #undef recvfrom
//#endif
//#define recvfrom recvfrom__USE_VCR_MODE
#if defined( GetCursorPos )

2
public/tier1/rangecheckedvar.h

@ -34,7 +34,7 @@ inline void RangeCheck( const T &value, int minValue, int maxValue ) @@ -34,7 +34,7 @@ inline void RangeCheck( const T &value, int minValue, int maxValue )
if ( ThreadInMainThread() && g_bDoRangeChecks )
{
// Ignore the min/max stuff for now.. just make sure it's not a NAN.
Assert( _finite( value ) );
Assert( IsFinite( value ) );
}
#endif
}

2
public/togl/linuxwin/glfuncs.h

@ -116,6 +116,8 @@ GL_FUNC_VOID(OpenGL,true,glUniform1iARB,(GLint a,GLint b),(a,b)) @@ -116,6 +116,8 @@ 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,glUseProgramObjectARB,(GLhandleARB a),(a))
GL_FUNC_VOID(OpenGL,true,glValidateProgramARB,(GLhandleARB 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))

4
public/togl/rendermechanism.h

@ -34,8 +34,12 @@ @@ -34,8 +34,12 @@
#undef PROTECTED_THINGS_ENABLE
#ifdef OSX
#include <OpenGL/OpenGL.h>
#else
#include <GL/gl.h>
#include <GL/glext.h>
#endif
#include "tier0/basetypes.h"
#include "tier0/platform.h"

9
togl/linuxwin/cglmprogram.cpp

@ -157,7 +157,8 @@ CGLMProgram::~CGLMProgram( ) @@ -157,7 +157,8 @@ CGLMProgram::~CGLMProgram( )
GLMShaderDesc *glslDesc = &m_descs[kGLMGLSL];
if (glslDesc->m_object.glsl)
{
gGL->glDeleteShader( (uint)glslDesc->m_object.glsl ); // why do I need a cast here again ?
//gGL->glDeleteShader( (uint)glslDesc->m_object.glsl ); // why do I need a cast here again ?
gGL->glDeleteObjectARB( glslDesc->m_object.glsl ); // because you call the wrong api
glslDesc->m_object.glsl = 0;
}
@ -814,7 +815,7 @@ void CGLMProgram::LogSlow( EGLMProgramLang lang ) @@ -814,7 +815,7 @@ void CGLMProgram::LogSlow( EGLMProgramLang lang )
m_type==kGLMVertexProgram ? "VS" : "FS",
this,
lang==kGLMGLSL ? "GLSL" : "ARB",
(int)(lang==kGLMGLSL ? (int)desc->m_object.glsl : (int)desc->m_object.arb),
(int)(lang==kGLMGLSL ? (intp)desc->m_object.glsl : (int)desc->m_object.arb),
m_text
);
#endif
@ -828,7 +829,7 @@ void CGLMProgram::LogSlow( EGLMProgramLang lang ) @@ -828,7 +829,7 @@ void CGLMProgram::LogSlow( EGLMProgramLang lang )
m_type==kGLMVertexProgram ? "VS" : "FS",
this,
lang==kGLMGLSL ? "GLSL" : "ARB",
(int)(lang==kGLMGLSL ? (int)desc->m_object.glsl : (int)desc->m_object.arb),
(int)(lang==kGLMGLSL ? (intp)desc->m_object.glsl : (int)desc->m_object.arb),
desc->m_slowMark+1
);
}
@ -984,7 +985,7 @@ bool CGLMShaderPair::ValidateProgramPair() @@ -984,7 +985,7 @@ bool CGLMShaderPair::ValidateProgramPair()
if (m_valid)
{
gGL->glUseProgram( m_program );
gGL->glUseProgramObjectARB( m_program );
m_ctx->NewLinkedProgram();

25
togl/linuxwin/glmgr.cpp

@ -670,7 +670,7 @@ void GLMContext::DumpCaps( void ) @@ -670,7 +670,7 @@ void GLMContext::DumpCaps( void )
#define dumpfield_hex( fff ) printf( "\n %-30s : 0x%08x", #fff, (int) m_caps.fff )
#define dumpfield_str( fff ) printf( "\n %-30s : %s", #fff, m_caps.fff )
printf("\n-------------------------------- context caps for context %08x", (uint)this);
printf("\n-------------------------------- context caps for context %p", this);
dumpfield( m_fullscreen );
dumpfield( m_accelerated );
@ -1745,8 +1745,9 @@ void GLMContext::PreloadTex( CGLMTex *tex, bool force ) @@ -1745,8 +1745,9 @@ void GLMContext::PreloadTex( CGLMTex *tex, bool force )
}
}
gGL->glUseProgram( (GLuint)preloadPair->m_program );
gGL->glUseProgramObjectARB( preloadPair->m_program );
//gGL->glUseProgram( (GLuint)preloadPair->m_program );
m_pBoundPair = preloadPair;
m_bDirtyPrograms = true;
@ -1793,7 +1794,7 @@ void GLMContext::PreloadTex( CGLMTex *tex, bool force ) @@ -1793,7 +1794,7 @@ void GLMContext::PreloadTex( CGLMTex *tex, bool force )
gGL->glEnableVertexAttribArray( 0 );
gGL->glVertexAttribPointer( 0, 3, GL_FLOAT, 0, 0, posns );
gGL->glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), posns );
gGL->glDrawRangeElements( GL_TRIANGLES, 0, 2, 3, GL_UNSIGNED_SHORT, indices);
@ -2701,6 +2702,10 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params ) @@ -2701,6 +2702,10 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params )
// debug state
m_debugFrameIndex = -1;
#if defined( OSX ) && defined( GLMDEBUG )
memset( m_boundProgram , 0, sizeof( m_boundProgram ) );
#endif
#if GLMDEBUG
// #######################################################################################
@ -5202,11 +5207,11 @@ void GLMContext::DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsize @@ -5202,11 +5207,11 @@ void GLMContext::DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsize
if ( pIndexBuf->m_bPseudo )
{
// you have to pass actual address, not offset
indicesActual = (void*)( (int)indicesActual + (int)pIndexBuf->m_pPseudoBuf );
indicesActual = (void*)( (intp)indicesActual + (intp)pIndexBuf->m_pPseudoBuf );
}
if (pIndexBuf->m_bUsingPersistentBuffer)
{
indicesActual = (void*)( (int)indicesActual + (int)pIndexBuf->m_nPersistentBufferStartOffset );
indicesActual = (void*)( (intp)indicesActual + (intp)pIndexBuf->m_nPersistentBufferStartOffset );
}
#if GLMDEBUG
@ -5244,7 +5249,11 @@ void GLMContext::DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsize @@ -5244,7 +5249,11 @@ void GLMContext::DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsize
}
else
{
#if defined( OSX )
// MoeMod: TOGL IS NOT USING m_boundProgram THIS AT ALL
#else
AssertOnce(!"drawing with no vertex program bound");
#endif
}
if (m_boundProgram[kGLMFragmentProgram])
@ -5253,7 +5262,11 @@ void GLMContext::DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsize @@ -5253,7 +5262,11 @@ void GLMContext::DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsize
}
else
{
#if defined( OSX )
// MoeMod: TOGL IS NOT USING m_boundProgram THIS AT ALL
#else
AssertOnce(!"drawing with no fragment program bound");
#endif
}
#endif

5
togl/linuxwin/glmgr_flush.inl

@ -196,7 +196,8 @@ FORCEINLINE void GLMContext::FlushDrawStates( uint nStartIndex, uint nEndIndex, @@ -196,7 +196,8 @@ FORCEINLINE void GLMContext::FlushDrawStates( uint nStartIndex, uint nEndIndex,
}
}
gGL->glUseProgram( (GLuint)pNewPair->m_program );
gGL->glUseProgramObjectARB(pNewPair->m_program);
//gGL->glUseProgram( (GLuint)pNewPair->m_program );
GL_BATCH_PERF( m_FlushStats.m_nTotalProgramPairChanges++; )
@ -563,7 +564,7 @@ FORCEINLINE void GLMContext::FlushDrawStates( uint nStartIndex, uint nEndIndex, @@ -563,7 +564,7 @@ FORCEINLINE void GLMContext::FlushDrawStates( uint nStartIndex, uint nEndIndex,
SetBufAndVertexAttribPointer( nIndex, pBuf->GetHandle(),
pStream->m_stride, pDeclElem->m_gldecl.m_datatype, pDeclElem->m_gldecl.m_normalized, pDeclElem->m_gldecl.m_nCompCount,
reinterpret_cast< const GLvoid * >( reinterpret_cast< int >( pBuf->m_pPseudoBuf ) + nBufOffset ),
reinterpret_cast< const GLvoid * >( reinterpret_cast< intp >( pBuf->m_pPseudoBuf ) + nBufOffset ),
pBuf->m_nRevision );
if ( !( m_lastKnownVertexAttribMask & nMask ) )

4
togl/linuxwin/glmgrbasics.cpp

@ -4243,7 +4243,9 @@ CGLMEditableTextItem::~CGLMEditableTextItem( ) @@ -4243,7 +4243,9 @@ CGLMEditableTextItem::~CGLMEditableTextItem( )
if (m_mirror)
{
free( m_mirror );
//free( m_mirror );
// MoeMod : should be delete here
delete m_mirror;
}
}

29
togl/linuxwin/intelglmallocworkaround.cpp

@ -27,6 +27,9 @@ @@ -27,6 +27,9 @@
// memdbgon -must- be the last include file in a .cpp file.
#include "tier0/memdbgon.h"
// MoeMod : ARM Mac doesnt need this workround
#if (defined(__i386__) || defined(__x86_64__))
IntelGLMallocWorkaround* IntelGLMallocWorkaround::s_pWorkaround = NULL;
void *IntelGLMallocWorkaround::ZeroingAlloc(size_t size)
@ -68,4 +71,28 @@ bool IntelGLMallocWorkaround::Enable() @@ -68,4 +71,28 @@ bool IntelGLMallocWorkaround::Enable()
}
return true;
}
}
#else
IntelGLMallocWorkaround* IntelGLMallocWorkaround::s_pWorkaround = NULL;
void *IntelGLMallocWorkaround::ZeroingAlloc(size_t size)
{
return nullptr;
}
IntelGLMallocWorkaround* IntelGLMallocWorkaround::Get()
{
if (!s_pWorkaround)
{
s_pWorkaround = new IntelGLMallocWorkaround();
}
return s_pWorkaround;
}
bool IntelGLMallocWorkaround::Enable()
{
return true;
}
#endif

8
vgui2/src/system_posix.cpp

@ -30,6 +30,8 @@ @@ -30,6 +30,8 @@
#ifdef OSX
#include <Carbon/Carbon.h>
#include <sys/param.h>
#include <sys/mount.h>
#elif defined(LINUX)
#include <sys/vfs.h>
#endif
@ -583,8 +585,14 @@ int CSystem::GetAvailableDrives(char *buf, int bufLen) @@ -583,8 +585,14 @@ int CSystem::GetAvailableDrives(char *buf, int bufLen)
//-----------------------------------------------------------------------------
double CSystem::GetFreeDiskSpace(const char *path)
{
#if __DARWIN_ONLY_64_BIT_INO_T
// MoeMod: newer macOS only support 64bit, so no statfs64 is provided
struct statfs buf;
int ret = statfs( path, &buf );
#else
struct statfs64 buf;
int ret = statfs64( path, &buf );
#endif
if ( ret < 0 )
return 0.0;
return (double) ( buf.f_bsize * buf.f_bfree );

2
vguimatsurface/MatSystemSurface.h

@ -556,7 +556,7 @@ private: @@ -556,7 +556,7 @@ private:
int m_nFullscreenViewportHeight;
ITexture *m_pFullscreenRenderTarget;
#ifdef LINUX
#if defined(LINUX) || defined(OSX)
struct font_entry
{
void *data;

Loading…
Cancel
Save