osx : fix syscalls

This commit is contained in:
hymei 2022-02-23 20:04:52 +08:00 committed by nillerusr
parent c7308906d1
commit 3291cdf978
16 changed files with 92 additions and 32 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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_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(OpenGL,true,GLboolean,glUnmapBuffer,(GLenum a),(a))
GL_FUNC_VOID(OpenGL,true,glUseProgram,(GLuint 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,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,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,glViewport,(GLint a,GLint b,GLsizei c,GLsizei d),(a,b,c,d))

View File

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

View File

@ -157,7 +157,8 @@ CGLMProgram::~CGLMProgram( )
GLMShaderDesc *glslDesc = &m_descs[kGLMGLSL]; GLMShaderDesc *glslDesc = &m_descs[kGLMGLSL];
if (glslDesc->m_object.glsl) 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; glslDesc->m_object.glsl = 0;
} }
@ -814,7 +815,7 @@ void CGLMProgram::LogSlow( EGLMProgramLang lang )
m_type==kGLMVertexProgram ? "VS" : "FS", m_type==kGLMVertexProgram ? "VS" : "FS",
this, this,
lang==kGLMGLSL ? "GLSL" : "ARB", 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 m_text
); );
#endif #endif
@ -828,7 +829,7 @@ void CGLMProgram::LogSlow( EGLMProgramLang lang )
m_type==kGLMVertexProgram ? "VS" : "FS", m_type==kGLMVertexProgram ? "VS" : "FS",
this, this,
lang==kGLMGLSL ? "GLSL" : "ARB", 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 desc->m_slowMark+1
); );
} }
@ -984,7 +985,7 @@ bool CGLMShaderPair::ValidateProgramPair()
if (m_valid) if (m_valid)
{ {
gGL->glUseProgram( m_program ); gGL->glUseProgramObjectARB( m_program );
m_ctx->NewLinkedProgram(); m_ctx->NewLinkedProgram();

View File

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

View File

@ -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++; ) GL_BATCH_PERF( m_FlushStats.m_nTotalProgramPairChanges++; )
@ -563,7 +564,7 @@ FORCEINLINE void GLMContext::FlushDrawStates( uint nStartIndex, uint nEndIndex,
SetBufAndVertexAttribPointer( nIndex, pBuf->GetHandle(), SetBufAndVertexAttribPointer( nIndex, pBuf->GetHandle(),
pStream->m_stride, pDeclElem->m_gldecl.m_datatype, pDeclElem->m_gldecl.m_normalized, pDeclElem->m_gldecl.m_nCompCount, 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 ); pBuf->m_nRevision );
if ( !( m_lastKnownVertexAttribMask & nMask ) ) if ( !( m_lastKnownVertexAttribMask & nMask ) )

View File

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

View File

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

View File

@ -30,6 +30,8 @@
#ifdef OSX #ifdef OSX
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
#include <sys/param.h>
#include <sys/mount.h>
#elif defined(LINUX) #elif defined(LINUX)
#include <sys/vfs.h> #include <sys/vfs.h>
#endif #endif
@ -583,8 +585,14 @@ int CSystem::GetAvailableDrives(char *buf, int bufLen)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
double CSystem::GetFreeDiskSpace(const char *path) 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; struct statfs64 buf;
int ret = statfs64( path, &buf ); int ret = statfs64( path, &buf );
#endif
if ( ret < 0 ) if ( ret < 0 )
return 0.0; return 0.0;
return (double) ( buf.f_bsize * buf.f_bfree ); return (double) ( buf.f_bsize * buf.f_bfree );

View File

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