Browse Source

Merge pull request #142 from exstrim401/macos

macOS build support
pull/143/head
nillerusr 2 years ago committed by GitHub
parent
commit
c2cdd880bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      appframework/wscript
  2. 15
      engine/wscript
  3. 2
      launcher/wscript
  4. 2
      mathlib/3dnow.cpp
  5. 2
      public/tier0/platform.h
  6. 6
      public/togl/linuxwin/cglmtex.h
  7. 2
      public/togl/linuxwin/glfuncs.h
  8. 4
      public/togl/linuxwin/glmgr.h
  9. 2
      public/togles/linuxwin/glfuncs.h
  10. 4
      public/togles/linuxwin/glmgr.h
  11. 3
      scripts/waifulib/compiler_optimizations.py
  12. 5
      scripts/waifulib/mm_hook.py
  13. 2
      tier0/dbg.cpp
  14. 4
      tier1/mempool.cpp
  15. 2
      tier1/wscript
  16. 168
      togl/linuxwin/cglmtex.cpp
  17. 10
      togl/linuxwin/dxabstract.cpp
  18. 4
      togl/linuxwin/glmgr.cpp
  19. 10
      togl/wscript
  20. 2
      togles/linuxwin/dxabstract.cpp
  21. 4
      togles/linuxwin/glmgr.cpp
  22. 7
      togles/wscript
  23. 4
      utils/vtex/vtex.cpp
  24. 2
      vgui2/src/wscript
  25. 2
      video/wscript
  26. 5
      vstdlib/wscript
  27. 35
      wscript

6
appframework/wscript

@ -18,7 +18,6 @@ def build(bld): @@ -18,7 +18,6 @@ def build(bld):
source = [
'AppSystemGroup.cpp',
'../public/filesystem_init.cpp',
# 'glmrendererinfo_osx.mm' [$OSXALL]
]
if bld.env.SDL:
@ -26,6 +25,11 @@ def build(bld): @@ -26,6 +25,11 @@ def build(bld):
'sdlmgr.cpp'
]
if bld.env.DEST_OS == 'darwin':
source += [
'glmrendererinfo_osx.mm'
]
if bld.env.DEST_OS == 'win32':
source += [
'vguimatsysapp.cpp',

15
engine/wscript

@ -15,6 +15,9 @@ def configure(conf): @@ -15,6 +15,9 @@ def configure(conf):
if conf.options.DEDICATED:
conf.define('SWDS', 1)
conf.define('NO_STEAM', 1)
else:
if conf.env.DEST_OS == 'darwin':
conf.define('HAVE_OPENAL', 1)
conf.env.append_unique('DEFINES',[
'__USEA3D',
@ -204,9 +207,17 @@ def build(bld): @@ -204,9 +207,17 @@ def build(bld):
if bld.env.SDL:
source += [
'audio/snd_dev_sdl.cpp', #[$SDL && !$OSXALL]
'audio/voice_record_sdl.cpp' #[$OSXALL||$LINUXALL]
]
if bld.env.DEST_OS != "darwin":
source += ['audio/snd_dev_sdl.cpp']
if bld.env.DEST_OS == 'darwin':
source += [
'audio/snd_dev_openal.cpp', # [$OSXALL]
'audio/snd_dev_mac_audioqueue.cpp',# [$OSXALL]
'audio/voice_record_mac_audioqueue.cpp', #[$OSXALL]
]
if bld.env.DEST_OS == 'win32':
source += [
@ -352,6 +363,8 @@ def build(bld): @@ -352,6 +363,8 @@ def build(bld):
libs += ['SSL', 'CRYPTO'] # android curl was built with openssl
elif bld.env.DEST_OS == 'win32':
libs += ['USER32', 'WINMM', 'WININET', 'DSOUND', 'DXGUID', 'GDI32', 'bzip2']
elif bld.env.DEST_OS == 'darwin':
libs += ['APPKIT', 'COREAUDIO', 'AUDIOTOOLBOX', 'SYSTEMCONFIGURATION']
install_path = bld.env.LIBDIR

2
launcher/wscript

@ -45,6 +45,8 @@ def build(bld): @@ -45,6 +45,8 @@ def build(bld):
if bld.env.DEST_OS == 'win32':
libs += ['USER32', 'OLE32', 'SHELL32']
elif bld.env.DEST_OS == 'darwin':
libs += ['FOUNDATION', 'APPKIT', 'IOKIT']
install_path = bld.env.LIBDIR

2
mathlib/3dnow.cpp

@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
#if !defined(COMPILER_MSVC64) && !defined(LINUX)
#if !defined(COMPILER_MSVC64) && !defined(LINUX) && !defined(OSX)
// Implement for 64-bit Windows if needed.
// Clang hits "fatal error: error in backend:" and other errors when trying
// to compile the inline assembly below. 3DNow support is highly unlikely to

2
public/tier0/platform.h

@ -1038,7 +1038,7 @@ inline T QWordSwapC( T dw ) @@ -1038,7 +1038,7 @@ inline T QWordSwapC( T dw )
// The typically used methods.
//-------------------------------------
#if (defined(__i386__) || defined(__amd64__) || (defined(__arm__) && defined(ANDROID))) && !defined(VALVE_LITTLE_ENDIAN)
#if (defined(__i386__) || defined(__amd64__) || defined(__arm__) || defined(__aarch64__)) && !defined(VALVE_LITTLE_ENDIAN)
#define VALVE_LITTLE_ENDIAN 1
#endif

6
public/togl/linuxwin/cglmtex.h

@ -126,7 +126,6 @@ enum EGLMTexFlags @@ -126,7 +126,6 @@ enum EGLMTexFlags
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.
kGLMTexDynamic = 0x80
};
//===============================================================================
@ -205,7 +204,6 @@ struct GLMTexLockParams @@ -205,7 +204,6 @@ struct GLMTexLockParams
// 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;
bool m_readonly;
};
struct GLMTexLockDesc
@ -487,7 +485,7 @@ protected: @@ -487,7 +485,7 @@ protected:
int CalcSliceIndex( int face, int mip );
void CalcTexelDataOffsetAndStrides( int sliceIndex, int x, int y, int z, int *offsetOut, int *yStrideOut, int *zStrideOut );
GLubyte *ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice=true, bool readOnly=false );
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.
@ -507,8 +505,6 @@ protected: @@ -507,8 +505,6 @@ protected:
// 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
GLuint m_pbo;
GLubyte *m_mapped;
GLenum m_texGLTarget;
uint m_nSamplerType; // SAMPLER_2D, etc.

2
public/togl/linuxwin/glfuncs.h

@ -63,7 +63,7 @@ GL_FUNC_VOID(OpenGL,true,glDrawArrays,(GLenum a,GLint b,GLsizei c),(a,b,c)) @@ -63,7 +63,7 @@ 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,glDrawBuffers,(GLsizei a,const GLenum *b),(a,b))
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))
#ifndef OSX // 10.6/GL 2.1 compatability
#if 1 //ifndef OSX // 10.6/GL 2.1 compatability
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))
#endif
GL_FUNC_VOID(OpenGL,true,glEnable,(GLenum a),(a))

4
public/togl/linuxwin/glmgr.h

@ -1451,7 +1451,7 @@ class GLMContext @@ -1451,7 +1451,7 @@ class GLMContext
void FlushDrawStatesNoShaders();
// drawing
#ifndef OSX
#if 1 //ifndef OSX
FORCEINLINE void DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, uint baseVertex, CGLMBuffer *pIndexBuf );
void DrawRangeElementsNonInline( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, uint baseVertex, CGLMBuffer *pIndexBuf );
#else
@ -1911,7 +1911,7 @@ class GLMContext @@ -1911,7 +1911,7 @@ class GLMContext
CTSQueue<CGLMTex*> m_DeleteTextureQueue;
};
#ifndef OSX
#if 1 //ifndef OSX
FORCEINLINE void GLMContext::DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, uint baseVertex, CGLMBuffer *pIndexBuf )
{

2
public/togles/linuxwin/glfuncs.h

@ -66,7 +66,7 @@ GL_FUNC_VOID(OpenGL,true,glWaitSync,(GLsync a, GLbitfield b, GLuint64 c),(a,b,c) @@ -66,7 +66,7 @@ GL_FUNC_VOID(OpenGL,true,glWaitSync,(GLsync a, GLbitfield b, GLuint64 c),(a,b,c)
GL_FUNC_VOID(OpenGL,true,glDeleteSync,(GLsync a),(a))
GL_FUNC(OpenGL,true,GLsync,glFenceSync,(GLenum a, GLbitfield b),(a,b))
#ifndef OSX // 10.6/GL 2.1 compatability
#if 1 //ifndef OSX // 10.6/GL 2.1 compatability
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))
#endif
GL_FUNC_VOID(OpenGL,true,glEnable,(GLenum a),(a))

4
public/togles/linuxwin/glmgr.h

@ -1365,7 +1365,7 @@ class GLMContext @@ -1365,7 +1365,7 @@ class GLMContext
void FlushDrawStatesNoShaders();
// drawing
#ifndef OSX
#if 1 //ifndef OSX
FORCEINLINE void DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, uint baseVertex, CGLMBuffer *pIndexBuf );
void DrawRangeElementsNonInline( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, uint baseVertex, CGLMBuffer *pIndexBuf );
#else
@ -1815,7 +1815,7 @@ class GLMContext @@ -1815,7 +1815,7 @@ class GLMContext
CTSQueue<CGLMTex*> m_DeleteTextureQueue;
};
#ifndef OSX
#if 1 //ifndef OSX
FORCEINLINE void GLMContext::DrawRangeElements( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, uint baseVertex, CGLMBuffer *pIndexBuf )
{

3
scripts/waifulib/compiler_optimizations.py

@ -35,6 +35,7 @@ VALID_BUILD_TYPES = ['fastnative', 'fast', 'release', 'debug', 'nooptimize', 'sa @@ -35,6 +35,7 @@ VALID_BUILD_TYPES = ['fastnative', 'fast', 'release', 'debug', 'nooptimize', 'sa
LINKFLAGS = {
'common': {
'msvc': ['/DEBUG'], # always create PDB, doesn't affect result binaries
'clang': ['-fvisibility=hidden'],
'gcc': ['-Wl,--no-undefined'],
'owcc': ['-Wl,option stack=512k', '-fvisibility=hidden']
},
@ -48,7 +49,7 @@ CFLAGS = { @@ -48,7 +49,7 @@ CFLAGS = {
'common': {
# disable thread-safe local static initialization for C++11 code, as it cause crashes on Windows XP
'msvc': ['/D_USING_V110_SDK71_', '/Zi', '/FS', '/Zc:threadSafeInit-'],
'clang': ['-fno-strict-aliasing'],
'clang': ['-fno-strict-aliasing', '-fvisibility=hidden'],
'gcc': ['-g0', '-fno-strict-aliasing', '-fvisibility=hidden'],
'owcc': ['-fno-short-enum', '-ffloat-store', '-g0']
},

5
scripts/waifulib/mm_hook.py

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
from waflib import TaskGen
@TaskGen.extension('.mm')
def mm_hook(self, node):
"""Alias .mm files to be compiled the same as .cpp files, gcc will do the right thing."""
return self.create_compiled_task('cxx', node)

2
tier0/dbg.cpp

@ -439,7 +439,7 @@ static SpewRetval_t _SpewMessage( SpewType_t spewType, const char *pGroupName, i @@ -439,7 +439,7 @@ static SpewRetval_t _SpewMessage( SpewType_t spewType, const char *pGroupName, i
/* direct it to the appropriate target(s) */
SpewRetval_t ret;
assert( g_pSpewInfo == (void*)NULL );
assert( (void*)g_pSpewInfo == (void*)NULL );
SpewInfo_t spewInfo =
{
pColor,

4
tier1/mempool.cpp

@ -12,8 +12,12 @@ @@ -12,8 +12,12 @@
#include "tier1/strtools.h"
#ifndef _PS3
#ifdef _OSX
#include <malloc/malloc.h>
#else
#include <malloc.h>
#endif
#endif
// Should be last include
#include "tier0/memdbgon.h"

2
tier1/wscript

@ -84,6 +84,8 @@ def build(bld): @@ -84,6 +84,8 @@ def build(bld):
libs = []
if bld.env.DEST_OS == 'win32':
libs += ['RPCRT4']
elif bld.env.DEST_OS == "darwin":
libs += ['ICONV']
bld.stlib(
source = source,

168
togl/linuxwin/cglmtex.cpp

@ -763,17 +763,6 @@ CGLMTex::CGLMTex( GLMContext *ctx, GLMTexLayout *layout, uint levels, const char @@ -763,17 +763,6 @@ CGLMTex::CGLMTex( GLMContext *ctx, GLMTexLayout *layout, uint levels, const char
m_pBlitSrcFBO = NULL;
m_pBlitDstFBO = NULL;
m_mapped = NULL;
m_pbo = 0;
if( m_layout->m_key.m_texFlags & kGLMTexDynamic )
{
gGL->glGenBuffersARB(1, &m_pbo);
gGL->glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, m_pbo);
gGL->glBufferDataARB(GL_PIXEL_UNPACK_BUFFER, m_layout->m_storageTotalSize, 0, GL_STATIC_DRAW);
gGL->glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, 0);
}
// Sense whether to try and apply client storage upon teximage/subimage.
// This should only be true if we're running on OSX 10.6 or it was explicitly
// enabled with -gl_texclientstorage on the command line.
@ -837,6 +826,7 @@ CGLMTex::CGLMTex( GLMContext *ctx, GLMTexLayout *layout, uint levels, const char @@ -837,6 +826,7 @@ CGLMTex::CGLMTex( GLMContext *ctx, GLMTexLayout *layout, uint levels, const char
if ( !(layout->m_key.m_texFlags & kGLMTexRenderable) && m_texClientStorage )
{
m_backing = (char *)malloc( m_layout->m_storageTotalSize );
memset( m_backing, 0, m_layout->m_storageTotalSize );
// track bytes allocated for non-RT's
int formindex = sEncodeLayoutAsIndex( &layout->m_key );
@ -1050,9 +1040,6 @@ CGLMTex::~CGLMTex( ) @@ -1050,9 +1040,6 @@ CGLMTex::~CGLMTex( )
m_debugLabel = NULL;
}
if( m_pbo )
gGL->glDeleteBuffersARB( 1, &m_pbo );
m_ctx = NULL;
}
@ -1117,10 +1104,9 @@ void CGLMTex::CalcTexelDataOffsetAndStrides( int sliceIndex, int x, int y, int z @@ -1117,10 +1104,9 @@ void CGLMTex::CalcTexelDataOffsetAndStrides( int sliceIndex, int x, int y, int z
*zStrideOut = zStride;
}
GLubyte *CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice, bool readOnly )
void CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice )
{
GLMRegion readBox;
GLubyte* data = NULL;
if (readWholeSlice)
{
@ -1147,51 +1133,45 @@ GLubyte *CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice, bool re @@ -1147,51 +1133,45 @@ GLubyte *CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice, bool re
GLMTexFormatDesc *format = m_layout->m_format;
GLenum target = m_layout->m_key.m_texGLTarget;
if( readOnly )
void *sliceAddress = m_backing + m_layout->m_slices[ desc->m_sliceIndex ].m_storageOffset; // this would change for PBO
//int sliceSize = m_layout->m_slices[ desc->m_sliceIndex ].m_storageSize;
// interestingly enough, we can use the same path for both 2D and 3D fetch
switch( target )
{
data = (GLubyte*)(m_backing + m_layout->m_slices[ desc->m_sliceIndex ].m_storageOffset); // this would change for PBO
//int sliceSize = m_layout->m_slices[ desc->m_sliceIndex ].m_storageSize;
case GL_TEXTURE_CUBE_MAP:
// interestingly enough, we can use the same path for both 2D and 3D fetch
// adjust target to steer to the proper face, then fall through to the 2D texture path.
target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + desc->m_req.m_face;
switch( target )
case GL_TEXTURE_2D:
case GL_TEXTURE_3D:
{
case GL_TEXTURE_CUBE_MAP:
// adjust target to steer to the proper face, then fall through to the 2D texture path.
target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + desc->m_req.m_face;
case GL_TEXTURE_2D:
case GL_TEXTURE_3D:
// check compressed or not
if (format->m_chunkSize != 1)
{
// check compressed or not
if (format->m_chunkSize != 1)
{
// compressed path
// http://www.opengl.org/sdk/docs/man/xhtml/glGetCompressedTexImage.xml
gGL->glGetCompressedTexImage( target, // target
// compressed path
// http://www.opengl.org/sdk/docs/man/xhtml/glGetCompressedTexImage.xml
gGL->glGetCompressedTexImage( target, // target
desc->m_req.m_mip, // level
data ); // destination
}
else
{
// uncompressed path
// http://www.opengl.org/sdk/docs/man/xhtml/glGetTexImage.xml
gGL->glGetTexImage( target, // target
sliceAddress ); // destination
}
else
{
// uncompressed path
// http://www.opengl.org/sdk/docs/man/xhtml/glGetTexImage.xml
gGL->glGetTexImage( target, // target
desc->m_req.m_mip, // level
format->m_glDataFormat, // dataformat
format->m_glDataType, // datatype
data ); // destination
}
sliceAddress ); // destination
}
break;
}
break;
}
else
{
gGL->glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, m_pbo);
data = (GLubyte*)gGL->glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, m_layout->m_slices[ desc->m_sliceIndex ].m_storageSize, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT);
}
}
else
{
@ -1199,8 +1179,6 @@ GLubyte *CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice, bool re @@ -1199,8 +1179,6 @@ GLubyte *CGLMTex::ReadTexels( GLMTexLockDesc *desc, bool readWholeSlice, bool re
}
m_ctx->BindTexToTMU( pPrevTex, 0 );
return data;
}
// TexSubImage should work properly on every driver stack and GPU--enabling by default.
@ -1256,13 +1234,7 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa @@ -1256,13 +1234,7 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
GLenum glDataType = format->m_glDataType;
GLMTexLayoutSlice *slice = &m_layout->m_slices[ desc->m_sliceIndex ];
void *sliceAddress = NULL;
if( m_mapped )
sliceAddress = m_mapped;
else if( m_backing )
sliceAddress = m_backing + slice->m_storageOffset;
void *sliceAddress = m_backing ? (m_backing + slice->m_storageOffset) : NULL; // this would change for PBO
// allow use of subimage if the target is texture2D and it has already been teximage'd
bool mayUseSubImage = false;
@ -1309,7 +1281,7 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa @@ -1309,7 +1281,7 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
gGL->glTexParameteri( target, GL_TEXTURE_BASE_LEVEL, desc->m_req.m_mip);
}
if (needsExpand && !m_mapped)
if (needsExpand)
{
int expandSize = 0;
@ -1389,13 +1361,12 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa @@ -1389,13 +1361,12 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
{
// go subimage2D if it's a replacement, not a creation
if( !m_mapped )
{
gGL->glPixelStorei( GL_UNPACK_ROW_LENGTH, slice->m_xSize ); // in pixels
gGL->glPixelStorei( GL_UNPACK_SKIP_PIXELS, writeBox.xmin ); // in pixels
gGL->glPixelStorei( GL_UNPACK_SKIP_ROWS, writeBox.ymin ); // in pixels
gGL->glTexSubImage2D( target,
gGL->glPixelStorei( GL_UNPACK_ROW_LENGTH, slice->m_xSize ); // in pixels
gGL->glPixelStorei( GL_UNPACK_SKIP_PIXELS, writeBox.xmin ); // in pixels
gGL->glPixelStorei( GL_UNPACK_SKIP_ROWS, writeBox.ymin ); // in pixels
gGL->glTexSubImage2D( target,
desc->m_req.m_mip, // level
writeBox.xmin, // xoffset into dest
writeBox.ymin, // yoffset into dest
@ -1406,23 +1377,23 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa @@ -1406,23 +1377,23 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
sliceAddress // data (will be offsetted by the SKIP_PIXELS and SKIP_ROWS - let GL do the math to find the first source texel)
);
gGL->glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
gGL->glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
gGL->glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
}
else
{
gGL->glTexSubImage2D( target,
desc->m_req.m_mip, // level
writeBox.xmin, // xoffset into dest
writeBox.ymin, // yoffset into dest
writeBox.xmax - writeBox.xmin, // width (was slice->m_xSize)
writeBox.ymax - writeBox.ymin, // height (was slice->m_ySize)
glDataFormat, // format
glDataType, // type
0
);
}
gGL->glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
gGL->glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
gGL->glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 );
/*
//http://www.opengl.org/sdk/docs/man/xhtml/glTexSubImage2D.xml
glTexSubImage2D( target,
desc->m_req.m_mip, // level
0, // xoffset
0, // yoffset
slice->m_xSize, // width
slice->m_ySize, // height
glDataFormat, // format
glDataType, // type
sliceAddress // data
);
*/
}
else
{
@ -1485,6 +1456,8 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa @@ -1485,6 +1456,8 @@ void CGLMTex::WriteTexels( GLMTexLockDesc *desc, bool writeWholeSlice, bool noDa
}
else
{
// uncompressed path
// http://www.opengl.org/sdk/docs/man/xhtml/glTexImage3D.xml
gGL->glTexImage3D( target, // target
desc->m_req.m_mip, // level
intformat, // internalformat
@ -1567,11 +1540,11 @@ void CGLMTex::Lock( GLMTexLockParams *params, char** addressOut, int* yStrideOut @@ -1567,11 +1540,11 @@ void CGLMTex::Lock( GLMTexLockParams *params, char** addressOut, int* yStrideOut
unStoragePow2 |= unStoragePow2 >> 8;
unStoragePow2 |= unStoragePow2 >> 16;
unStoragePow2++;
m_backing = (char *)malloc( unStoragePow2 );
m_backing = (char *)calloc( unStoragePow2, 1 );
}
else
{
m_backing = (char *)malloc( m_layout->m_storageTotalSize );
m_backing = (char *)calloc( m_layout->m_storageTotalSize, 1 );
}
// clear the kSliceStorageValid bit on all slices
@ -1666,18 +1639,14 @@ void CGLMTex::Lock( GLMTexLockParams *params, char** addressOut, int* yStrideOut @@ -1666,18 +1639,14 @@ void CGLMTex::Lock( GLMTexLockParams *params, char** addressOut, int* yStrideOut
desc->m_sliceRegionOffset = offsetInSlice + desc->m_sliceBaseOffset;
if ( copyout && ( (m_layout->m_key.m_texFlags & kGLMTexDynamic) || params->m_readonly ) )
{
*addressOut = (char*)ReadTexels( desc, true, params->m_readonly );
if( params->m_readonly == false )
m_mapped = (GLubyte*)*addressOut;
}
else
if (copyout)
{
*addressOut = m_backing + desc->m_sliceRegionOffset;
}
// read the whole slice
// (odds are we'll never request anything but a whole slice to be read..)
ReadTexels( desc, true );
} // this would be a good place to fill with scrub value if in debug...
*addressOut = m_backing + desc->m_sliceRegionOffset;
*yStrideOut = yStride;
*zStrideOut = zStride;
@ -1763,16 +1732,7 @@ void CGLMTex::Unlock( GLMTexLockParams *params ) @@ -1763,16 +1732,7 @@ void CGLMTex::Unlock( GLMTexLockParams *params )
// fullyDirty |= (m_sliceFlags[ desc->m_sliceIndex ] & kSliceStorageValid);
if( m_layout->m_key.m_texFlags & kGLMTexDynamic && m_mapped )
{
gGL->glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
WriteTexels( desc, fullyDirty );
m_mapped = NULL;
gGL->glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, 0);
}
else
WriteTexels( desc, fullyDirty );
WriteTexels( desc, fullyDirty );
// logical place to trigger preloading
// only do it for an RT tex, if it is not yet attached to any FBO.

10
togl/linuxwin/dxabstract.cpp

@ -404,7 +404,7 @@ HRESULT IDirect3DDevice9::CreateTexture(UINT Width,UINT Height,UINT Levels,DWORD @@ -404,7 +404,7 @@ HRESULT IDirect3DDevice9::CreateTexture(UINT Width,UINT Height,UINT Levels,DWORD
if (Usage & D3DUSAGE_DYNAMIC)
{
key.m_texFlags |= kGLMTexDynamic;
// GLMPRINTF(("-X- DYNAMIC tex usage ignored..")); //FIXME
}
if (Usage & D3DUSAGE_TEXTURE_SRGB)
@ -617,7 +617,7 @@ HRESULT IDirect3DDevice9::CreateCubeTexture(UINT EdgeLength,UINT Levels,DWORD Us @@ -617,7 +617,7 @@ HRESULT IDirect3DDevice9::CreateCubeTexture(UINT EdgeLength,UINT Levels,DWORD Us
if (Usage & D3DUSAGE_DYNAMIC)
{
key.m_texFlags |= kGLMTexDynamic;
//GLMPRINTF(("-X- DYNAMIC tex usage ignored..")); //FIXME
}
if (Usage & D3DUSAGE_TEXTURE_SRGB)
@ -823,7 +823,7 @@ HRESULT IDirect3DDevice9::CreateVolumeTexture(UINT Width,UINT Height,UINT Depth, @@ -823,7 +823,7 @@ HRESULT IDirect3DDevice9::CreateVolumeTexture(UINT Width,UINT Height,UINT Depth,
if (Usage & D3DUSAGE_DYNAMIC)
{
key.m_texFlags |= kGLMTexDynamic;
GLMPRINTF(("-X- DYNAMIC tex usage ignored..")); //FIXME
}
if (Usage & D3DUSAGE_TEXTURE_SRGB)
@ -1041,8 +1041,6 @@ HRESULT IDirect3DSurface9::LockRect(D3DLOCKED_RECT* pLockedRect,CONST RECT* pRec @@ -1041,8 +1041,6 @@ HRESULT IDirect3DSurface9::LockRect(D3DLOCKED_RECT* pLockedRect,CONST RECT* pRec
lockreq.m_readback = true;
}
lockreq.m_readonly = (Flags & D3DLOCK_READONLY) ? true : false;
char *lockAddress;
int yStride;
int zStride;
@ -5329,7 +5327,7 @@ HRESULT IDirect3DDevice9::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT Pr @@ -5329,7 +5327,7 @@ HRESULT IDirect3DDevice9::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT Pr
// [in] Number of primitives to render. The number of vertices used is a function of the primitive count and the primitive type. The maximum number of primitives allowed is determined by checking the MaxPrimitiveCount member of the D3DCAPS9 structure.
// BE VERY CAREFUL what you do in this function. It's extremely hot, and calling the wrong GL API's in here will crush perf. on NVidia threaded drivers.
#ifndef OSX
#if 1 //ifndef OSX
HRESULT IDirect3DDevice9::DrawIndexedPrimitive( D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount )
{

4
togl/linuxwin/glmgr.cpp

@ -2812,6 +2812,7 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params ) @@ -2812,6 +2812,7 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params )
}
}
/*
if ( m_caps.m_badDriver108Intel )
{
// this way we have something to look for in terminal spew if users report issues related to this in the future.
@ -2821,6 +2822,7 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params ) @@ -2821,6 +2822,7 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params )
Warning( "Unable to enable OSX 10.8 / Intel HD4000 workaround, there might be crashes.\n" );
}
}
*/
#endif
// also, set the remote convar "gl_can_query_fast" to 1 if perf package present, else 0.
@ -5080,7 +5082,7 @@ static inline uint GetDataTypeSizeInBytes( GLenum dataType ) @@ -5080,7 +5082,7 @@ static inline uint GetDataTypeSizeInBytes( GLenum dataType )
return 0;
}
#ifndef OSX
#if 1 //ifndef OS
void GLMContext::DrawRangeElementsNonInline( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, uint baseVertex, CGLMBuffer *pIndexBuf )
{

10
togl/wscript

@ -23,9 +23,6 @@ def build(bld): @@ -23,9 +23,6 @@ def build(bld):
'linuxwin/glentrypoints.cpp',
'linuxwin/glmgr.cpp',
'linuxwin/glmgrbasics.cpp',
#'linuxwin/glmgrcocoa.mm', [$OSXALL]
#'linuxwin/intelglmallocworkaround.cpp', [$OSXALL]
#'linuxwin/mach_override.c', [$OSXALL]
'linuxwin/cglmtex.cpp',
'linuxwin/cglmfbo.cpp',
'linuxwin/cglmprogram.cpp',
@ -33,6 +30,10 @@ def build(bld): @@ -33,6 +30,10 @@ def build(bld):
'linuxwin/cglmquery.cpp',
'linuxwin/asanstubs.cpp'
]
if bld.env.DEST_OS == "darwin":
source += [
'linuxwin/glmgrcocoa.mm',
]
includes = [
'.',
@ -45,6 +46,9 @@ def build(bld): @@ -45,6 +46,9 @@ def build(bld):
libs = ['tier0','tier1','tier2','vstdlib','mathlib']
if bld.env.DEST_OS == "darwin":
libs += ["OPENGL", "CARBON"]
install_path = bld.env.LIBDIR
bld.shlib(

2
togles/linuxwin/dxabstract.cpp

@ -5326,7 +5326,7 @@ HRESULT IDirect3DDevice9::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT Pr @@ -5326,7 +5326,7 @@ HRESULT IDirect3DDevice9::DrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType,UINT Pr
// [in] Number of primitives to render. The number of vertices used is a function of the primitive count and the primitive type. The maximum number of primitives allowed is determined by checking the MaxPrimitiveCount member of the D3DCAPS9 structure.
// BE VERY CAREFUL what you do in this function. It's extremely hot, and calling the wrong GL API's in here will crush perf. on NVidia threaded drivers.
#ifndef OSX
#if 1 //ifndef OSX
HRESULT IDirect3DDevice9::DrawIndexedPrimitive( D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount )
{

4
togles/linuxwin/glmgr.cpp

@ -2692,6 +2692,7 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params ) @@ -2692,6 +2692,7 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params )
}
}
/*
if ( m_caps.m_badDriver108Intel )
{
// this way we have something to look for in terminal spew if users report issues related to this in the future.
@ -2701,6 +2702,7 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params ) @@ -2701,6 +2702,7 @@ GLMContext::GLMContext( IDirect3DDevice9 *pDevice, GLMDisplayParams *params )
Warning( "Unable to enable OSX 10.8 / Intel HD4000 workaround, there might be crashes.\n" );
}
}
*/
#endif
// also, set the remote convar "gl_can_query_fast" to 1 if perf package present, else 0.
@ -4899,7 +4901,7 @@ static inline uint GetDataTypeSizeInBytes( GLenum dataType ) @@ -4899,7 +4901,7 @@ static inline uint GetDataTypeSizeInBytes( GLenum dataType )
return 0;
}
#ifndef OSX
#if 1 //ifndef OSX
void GLMContext::DrawRangeElementsNonInline( GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, uint baseVertex, CGLMBuffer *pIndexBuf )
{

7
togles/wscript

@ -23,7 +23,6 @@ def build(bld): @@ -23,7 +23,6 @@ def build(bld):
'linuxwin/glentrypoints.cpp',
'linuxwin/glmgr.cpp',
'linuxwin/glmgrbasics.cpp',
#'linuxwin/glmgrcocoa.mm', [$OSXALL]
#'linuxwin/intelglmallocworkaround.cpp', [$OSXALL]
#'linuxwin/mach_override.c', [$OSXALL]
'linuxwin/cglmtex.cpp',
@ -35,6 +34,9 @@ def build(bld): @@ -35,6 +34,9 @@ def build(bld):
'linuxwin/decompress.c'
]
if bld.env.DEST_OS == "darwin":
source += ['linuxwin/glmgrcocoa.mm']
includes = [
'.',
'../public',
@ -46,6 +48,9 @@ def build(bld): @@ -46,6 +48,9 @@ def build(bld):
libs = ['tier0','tier1','tier2','vstdlib','mathlib']
if bld.env.DEST_OS == "darwin":
libs += ["OPENGL", "CARBON"]
install_path = bld.env.LIBDIR
bld.shlib(

4
utils/vtex/vtex.cpp

@ -7,7 +7,11 @@ @@ -7,7 +7,11 @@
#include <stdlib.h>
#include <stdio.h>
#ifdef OSX
#include <malloc/malloc.h>
#else
#include <malloc.h>
#endif
#include <string.h>
#include "tier1/strtools.h"
#include <sys/stat.h>

2
vgui2/src/wscript

@ -62,6 +62,8 @@ def build(bld): @@ -62,6 +62,8 @@ def build(bld):
if bld.env.DEST_OS == 'win32':
libs += ['USER32', 'IMM32', 'GDI32', 'SHELL32', 'OLE32', 'SHLWAPI', 'vgui_surfacelib', 'WINMM']
elif bld.env.DEST_OS == 'darwin':
libs += ['APPLICATIONSERVICES']
install_path = bld.env.LIBDIR

2
video/wscript

@ -34,6 +34,8 @@ def build(bld): @@ -34,6 +34,8 @@ def build(bld):
if bld.env.DEST_OS == 'win32':
libs += ['USER32']
elif bld.env.DEST_OS == 'darwin':
libs += ['COREGRAPHICS']
install_path = bld.env.LIBDIR

5
vstdlib/wscript

@ -48,9 +48,13 @@ def build(bld): @@ -48,9 +48,13 @@ def build(bld):
defines = []
libs = ['tier0','tier1']
linkflags = []
if bld.env.DEST_OS == 'android':
libs += ['ANDROID_SUPPORT']
elif bld.env.DEST_OS == 'darwin':
libs += ['ICONV', 'COREFOUNDATION']
linkflags += ['-framework', 'CoreServices']
install_path = bld.env.LIBDIR
@ -62,6 +66,7 @@ def build(bld): @@ -62,6 +66,7 @@ def build(bld):
includes = includes,
defines = defines,
use = libs,
linkflags = linkflags,
install_path = install_path,
subsystem = bld.env.MSVC_SUBSYSTEM,
idx = bld.get_taskgen_count()

35
wscript

@ -212,6 +212,14 @@ def define_platform(conf): @@ -212,6 +212,14 @@ def define_platform(conf):
'_ALLOW_MSC_VER_MISMATCH',
'NO_X360_XDK'
])
elif conf.env.DEST_OS == 'darwin':
conf.env.append_unique('DEFINES', [
'OSX=1', '_OSX=1',
'POSIX=1', '_POSIX=1', 'PLATFORM_POSIX=1',
'GNUC',
'NO_HOOK_MALLOC',
'_DLL_EXT=.dylib'
])
if conf.options.DEBUG_ENGINE:
conf.env.append_unique('DEFINES', [
@ -284,6 +292,8 @@ def configure(conf): @@ -284,6 +292,8 @@ def configure(conf):
conf.load('subproject xcompile compiler_c compiler_cxx gitversion clang_compilation_database strip_on_install waf_unit_test enforce_pic')
if conf.env.DEST_OS == 'win32' and conf.env.DEST_CPU == 'amd64':
conf.load('masm')
elif conf.env.DEST_OS == 'darwin':
conf.load('mm_hook')
define_platform(conf)
conf.define('GIT_COMMIT_HASH', conf.env.GIT_VERSION)
@ -302,8 +312,7 @@ def configure(conf): @@ -302,8 +312,7 @@ def configure(conf):
conf.env.BIT32_MANDATORY = not conf.options.ALLOW64
if conf.env.BIT32_MANDATORY:
Logs.info('WARNING: will build engine for 32-bit target')
conf.load('force_32bit')
conf.load('force_32bit')
if conf.options.DISABLE_WARNS:
compiler_optional_flags = ['-w']
@ -353,7 +362,7 @@ def configure(conf): @@ -353,7 +362,7 @@ def configure(conf):
]
flags += ['-funwind-tables', '-fvisibility=default']
elif conf.env.COMPILER_CC != 'msvc':
elif conf.env.COMPILER_CC not in ['msvc', 'clang']:
flags += ['-march=native']
if conf.env.DEST_CPU in ['x86', 'x86_64']:
@ -444,7 +453,10 @@ def configure(conf): @@ -444,7 +453,10 @@ def configure(conf):
else:
conf.check_pkg('freetype2', 'FT2', FT2_CHECK)
conf.check_pkg('fontconfig', 'FC', FC_CHECK)
conf.check_cfg(package='openal', uselib_store='OPENAL', args=['--cflags', '--libs'])
if conf.env.DEST_OS == "darwin":
conf.env.FRAMEWORK_OPENAL = "OpenAL"
else:
conf.check_cfg(package='openal', uselib_store='OPENAL', args=['--cflags', '--libs'])
conf.check_cfg(package='libjpeg', uselib_store='JPEG', args=['--cflags', '--libs'])
conf.check_cfg(package='libpng', uselib_store='PNG', args=['--cflags', '--libs'])
conf.check_cfg(package='libcurl', uselib_store='CURL', args=['--cflags', '--libs'])
@ -466,6 +478,21 @@ def configure(conf): @@ -466,6 +478,21 @@ def configure(conf):
conf.check(lib='android_support', uselib_store='ANDROID_SUPPORT')
conf.check(lib='opus', uselib_store='OPUS')
if conf.env.DEST_OS == "darwin":
conf.check(lib='iconv', uselib_store='ICONV')
conf.env.FRAMEWORK_APPKIT = "AppKit"
conf.env.FRAMEWORK_IOKIT = "IOKit"
conf.env.FRAMEWORK_FOUNDATION = "Foundation"
conf.env.FRAMEWORK_COREFOUNDATION = "CoreFoundation"
conf.env.FRAMEWORK_COREGRAPHICS = "CoreGraphics"
conf.env.FRAMEWORK_OPENGL = "OpenGL"
conf.env.FRAMEWORK_CARBON = "Carbon"
conf.env.FRAMEWORK_APPLICATIONSERVICES = "ApplicationServices"
conf.env.FRAMEWORK_CORESERVICES = "CoreServices"
conf.env.FRAMEWORK_COREAUDIO = "CoreAudio"
conf.env.FRAMEWORK_AUDIOTOOLBOX = "AudioToolbox"
conf.env.FRAMEWORK_SYSTEMCONFIGURATION = "SystemConfiguration"
if conf.env.DEST_OS != 'win32':
conf.check_cc(lib='dl', mandatory=False)
conf.check_cc(lib='bz2', mandatory=False)

Loading…
Cancel
Save