Merge branch 'master' into win64

This commit is contained in:
HappyDOGE 2023-01-23 19:16:19 +03:00
commit c69afba381
24 changed files with 193 additions and 183 deletions

View File

@ -1,23 +1,49 @@
# source-engine
Welcome to source engine:)
# Source Engine
[![GitHub Actions Status](https://github.com/nillerusr/source-engine/actions/workflows/build.yml/badge.svg)](https://github.com/nillerusr/source-engine/actions/workflows/build.yml) [![GitHub Actions Status](https://github.com/nillerusr/source-engine/actions/workflows/tests.yml/badge.svg)](https://github.com/nillerusr/source-engine/actions/workflows/tests.yml)
Discord: [![Discord Server](https://img.shields.io/discord/672055862608658432.svg)](https://discord.gg/hZRB7WMgGw)
Discord: https://discord.gg/hZRB7WMgGw
Information from [wikipedia](https://wikipedia.org/wiki/Source_(game_engine)):
Source is a 3D game engine developed by Valve.
It debuted as the successor to GoldSrc with Half-Life: Source in June 2004,
followed by Counter-Strike: Source and Half-Life 2 later that year.
Source does not have a concise version numbering scheme; instead, it was released in incremental versions
Source code is based on TF2 2018 leak. Don't use it for commercial purposes.
This project is using waf buildsystem. If you have waf-related questions look https://waf.io/book
# Features:
- Android, OSX, FreeBSD, Windows support
- Arm support( except windows )
- 64bit support
- Modern toolchains support
- Fixed many undefined behaviours
- Touch support( even on windows/linux/osx )
- VTF 7.5 support
- PBR support
- bsp v19-v21 support( bsp v21 support is partial, portal 2 and csgo maps works fine )
- mdl v46-49 support
- Removed useless/unnecessary dependencies
- Achivement system working without steam
- Fixed many bugs
# Current tasks
- [x] Windows build support for waf
- [x] NEON support
- [x] remove unnecessary dependencies
- [x] Arm(android) port
- [x] replace current buildsystem with waf
- [x] rewrite achivement system( to work without steam )
- [x] 64-bit support
- [x] VTF 7.5 support
- [x] PBR support
- [ ] improve performance
- [ ] fixing bugs
- [ ] dxvk-native support
- [ ] Elbrus port
- [ ] rewrite serverbrowser to work without steam
- Rewrite materialsystem for OpenGL render
- dxvk-native support
- Elbrus port
- Bink audio support( for video_bink )
- Rewrite serverbrowser to work without steam
# How to Build?
- [Windows](https://github.com/nillerusr/source-engine/wiki/How-to-build#on-windows)
- [Linux](https://github.com/nillerusr/source-engine/wiki/How-to-build#on-linux)
- [For Android under Linux](https://github.com/nillerusr/source-engine/wiki/How-to-build#on-linux-for-android)
# [How to Build?](https://github.com/nillerusr/source-engine/wiki/How-to-build)
# Support me
BTC: `bc1qnjq92jj9uqjtafcx2zvnwd48q89hgtd6w8a6na`
ETH: `0x5d0D561146Ed758D266E59B56e85Af0b03ABAF46`
XMR: `48iXvX61MU24m5VGc77rXQYKmoww3dZh6hn7mEwDaLVTfGhyBKq2teoPpeBq6xvqj4itsGh6EzNTzBty6ZDDevApCFNpsJ`

View File

@ -420,7 +420,7 @@ FORCE_INLINE uint32_t _mm_crc32_u8(uint32_t, uint8_t);
// Older gcc does not define vld1q_u8_x4 type
#if defined(__GNUC__) && !defined(__clang__) && \
((__GNUC__ <= 10 && defined(__arm__)) || \
(defined(__arm__) || \
(__GNUC__ == 10 && __GNUC_MINOR__ < 3 && defined(__aarch64__)) || \
(__GNUC__ <= 9 && defined(__aarch64__)))
FORCE_INLINE uint8x16x4_t _sse2neon_vld1q_u8_x4(const uint8_t *p)

View File

@ -81,7 +81,7 @@ namespace {
#if defined( _X360 )
#define AsyncMdlCache() 0 // Explicitly OFF for 360 (incompatible)
#else
#define AsyncMdlCache() 0
#define AsyncMdlCache() 1
#endif
#define ERROR_MODEL "models/error.mdl"

View File

@ -819,10 +819,13 @@ void CVideoMode_Common::SetupStartupGraphic()
// loading.vtf
buf.Clear(); // added this Clear() because we saw cases where LoadVTF was not emptying the buf fully in the above section
m_pLoadingTexture = LoadVTF( buf, "materials/console/startup_loading.vtf" );
const char* loading = "materials/console/startup_loading.vtf";
if ( IsSteamDeck() )
loading = "materials/gamepadui/game_logo.vtf";
m_pLoadingTexture = LoadVTF( buf, loading );
if ( !m_pLoadingTexture )
{
Error( "Can't find background image materials/console/startup_loading.vtf\n" );
Error( "Can't find background image '%s'\n", loading );
return;
}
}
@ -883,8 +886,12 @@ void CVideoMode_Common::DrawStartupGraphic()
pVMTKeyValues->SetInt( "$nocull", 1 );
IMaterial *pMaterial = g_pMaterialSystem->CreateMaterial( "__background", pVMTKeyValues );
const char* loading = "console/startup_loading.vtf";
if ( IsSteamDeck() )
loading = "gamepadui/game_logo.vtf";
pVMTKeyValues = new KeyValues( "UnlitGeneric" );
pVMTKeyValues->SetString( "$basetexture", "Console/startup_loading.vtf" );
pVMTKeyValues->SetString( "$basetexture", loading );
pVMTKeyValues->SetInt( "$translucent", 1 );
pVMTKeyValues->SetInt( "$ignorez", 1 );
pVMTKeyValues->SetInt( "$nofog", 1 );
@ -922,7 +929,11 @@ void CVideoMode_Common::DrawStartupGraphic()
slide = 0;
DrawScreenSpaceRectangle( pMaterial, 0, 0+slide, w, h-50, 0, 0, tw-1, th-1, tw, th, NULL,1,1,depth );
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh+slide/2, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth-0.1 );
if ( !IsSteamDeck() )
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh+slide/2, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth-0.1 );
else
// TODO: Steam Deck
DrawScreenSpaceRectangle( pLoadingMaterial, w-lw, h-lh+slide/2, lw, lh, 0, 0, lw-1, lh-1, lw, lh, NULL,1,1,depth-0.1 );
}
if(0)

View File

@ -613,7 +613,7 @@ void CEngineVGui::Init()
return;
}
if ( IsX360() )
if ( IsX360() || IsSteamDeck() )
{
CCommand ccommand;
if ( CL_ShouldLoadBackgroundLevel( ccommand ) )
@ -1273,7 +1273,7 @@ void CEngineVGui::OnLevelLoadingStarted()
}
}
if ( IsX360() )
if ( IsX360() || IsSteamDeck() )
{
// TCR requirement, always!!!
m_bShowProgressDialog = true;

View File

@ -32,7 +32,7 @@ extern INetworkStringTable *g_pStringTableInfoPanel;
#define TEMP_HTML_FILE "textwindow_temp.html"
ConVar cl_disablehtmlmotd( "cl_disablehtmlmotd", "0", FCVAR_ARCHIVE, "Disable HTML motds." );
ConVar cl_disablehtmlmotd( "cl_disablehtmlmotd", "1", FCVAR_ARCHIVE, "Disable HTML motds." );
//=============================================================================
// HPE_BEGIN:
@ -129,7 +129,8 @@ void CTextWindow::ApplySchemeSettings( IScheme *pScheme )
CTextWindow::~CTextWindow()
{
// remove temp file again
g_pFullFileSystem->RemoveFile( TEMP_HTML_FILE, "DEFAULT_WRITE_PATH" );
if (g_pFullFileSystem->FileExists(TEMP_HTML_FILE))
g_pFullFileSystem->RemoveFile( TEMP_HTML_FILE, "DEFAULT_WRITE_PATH" );
}
void CTextWindow::Reset( void )

View File

@ -258,7 +258,15 @@ void CHudCrosshair::Paint( void )
pWeapon->GetWeaponCrosshairScale( flWeaponScale );
}
float flPlayerScale = 1.0f;
int iScreenDiv = 1600;
if ( IsSteamDeck() )
iScreenDiv = 1440;
float flPlayerScale;
if ( !m_pCrosshair->bRenderUsingFont )
flPlayerScale = (ScreenHeight() / iScreenDiv) + 1;
else
flPlayerScale = 1.0f;
#ifdef TF_CLIENT_DLL
Color clr( cl_crosshair_red.GetInt(), cl_crosshair_green.GetInt(), cl_crosshair_blue.GetInt(), 255 );
flPlayerScale = cl_crosshair_scale.GetFloat() / 32.0f; // the player can change the scale in the options/multiplayer tab

View File

@ -1801,8 +1801,11 @@ void CBasePanel::ApplySchemeSettings(IScheme *pScheme)
// load the loading icon
if ( m_iLoadingImageID == -1 )
{
const char* loading = "console/startup_loading";
if ( IsSteamDeck() )
loading = "gamepadui/game_logo";
m_iLoadingImageID = surface()->CreateNewTextureID();
surface()->DrawSetTextureFile( m_iLoadingImageID, "Console/startup_loading", false, false );
surface()->DrawSetTextureFile( m_iLoadingImageID, loading, false, false );
}
}
}

View File

@ -27,6 +27,7 @@ char *LauncherArgv[512];
char java_args[4096];
int iLastArgs = 0;
extern void InitCrashHandler();
DLL_EXPORT int LauncherMain( int argc, char **argv ); // from launcher.cpp
DLL_EXPORT int Java_com_valvesoftware_ValveActivity2_setenv(JNIEnv *jenv, jclass *jclass, jstring env, jstring value, jint over)
@ -118,6 +119,8 @@ void android_property_print(const char *name)
DLL_EXPORT int LauncherMainAndroid( int argc, char **argv )
{
InitCrashHandler();
Msg("GetTotalMemory() = %.2f \n", GetTotalMemory());
android_property_print("ro.build.version.sdk");

View File

@ -1029,7 +1029,7 @@ bool CMaterialSystem::AllowThreading( bool bAllow, int nServiceThread )
bool bOldAllow = m_bAllowQueuedRendering;
if ( GetCPUInformation()->m_nPhysicalProcessors >= 2 )
if ( GetCPUInformation()->m_nLogicalProcessors >= 2 )
{
m_bAllowQueuedRendering = bAllow;
bool bQueued = m_IdealThreadMode != MATERIAL_SINGLE_THREADED;
@ -1806,11 +1806,7 @@ static ConVar mat_normalmaps( "mat_normalmaps", "0", FCVAR_CHEAT );
static ConVar mat_measurefillrate( "mat_measurefillrate", "0", FCVAR_CHEAT );
static ConVar mat_fillrate( "mat_fillrate", "0", FCVAR_CHEAT );
static ConVar mat_reversedepth( "mat_reversedepth", "0", FCVAR_CHEAT );
#ifdef DX_TO_GL_ABSTRACTION
static ConVar mat_bufferprimitives( "mat_bufferprimitives", "0" ); // I'm not seeing any benefit speed wise for buffered primitives on GLM/POSIX (checked via TF2 timedemo) - default to zero
#else
static ConVar mat_bufferprimitives( "mat_bufferprimitives", "1" );
#endif
static ConVar mat_drawflat( "mat_drawflat","0", FCVAR_CHEAT );
static ConVar mat_softwarelighting( "mat_softwarelighting", "0", FCVAR_ALLOWED_IN_COMPETITIVE );
static ConVar mat_proxy( "mat_proxy", "0", FCVAR_CHEAT, "", MatProxyCallback );
@ -2780,8 +2776,8 @@ IMaterial* CMaterialSystem::FindMaterialEx( char const* pMaterialName, const cha
{
// We need lower-case symbols for this to work
int nLen = Q_strlen( pMaterialName ) + 1;
char *pFixedNameTemp = (char*)malloc( nLen );
char *pTemp = (char*)malloc( nLen );
char *pFixedNameTemp = (char*)stackalloc( nLen );
char *pTemp = (char*)stackalloc( nLen );
Q_strncpy( pFixedNameTemp, pMaterialName, nLen );
Q_strlower( pFixedNameTemp );
#ifdef POSIX
@ -2883,9 +2879,6 @@ IMaterial* CMaterialSystem::FindMaterialEx( char const* pMaterialName, const cha
}
}
free(pTemp);
free(pFixedNameTemp);
return g_pErrorMaterial->GetRealTimeVersion();
}
@ -3103,20 +3096,12 @@ void CMaterialSystem::ResetTempHWMemory( bool bExitingLevel )
//-----------------------------------------------------------------------------
void CMaterialSystem::CacheUsedMaterials( )
{
printf("Cache materials\n");
g_pShaderAPI->EvictManagedResources();
size_t count = 0;
for (MaterialHandle_t i = FirstMaterial(); i != InvalidMaterial(); i = NextMaterial(i) )
{
// Some (mac) drivers (amd) seem to keep extra resources around on uploads until the next frame swap. This
// injects pointless synthetic swaps (between already-static load frames)
if ( mat_texture_reload_frame_swap_workaround.GetBool() )
{
if ( count++ % 20 == 0 )
{
Flush(true);
SwapBuffers(); // Not the right thing to call
}
}
IMaterialInternal* pMat = GetMaterialInternal(i);
Assert( pMat->GetReferenceCount() >= 0 );
if( pMat->GetReferenceCount() > 0 )
@ -3703,9 +3688,13 @@ void CMaterialSystem::EndFrame( void )
ThreadAcquire( true );
}
IThreadPool* pThreadPool = CreateMatQueueThreadPool();
if ( m_pActiveAsyncJob && !m_pActiveAsyncJob->IsFinished() )
{
m_pActiveAsyncJob->WaitForFinish();
m_pActiveAsyncJob->WaitForFinish(TT_INFINITE, pThreadPool);
// Sync with GPU if we had a job for it, even if it finished early on CPU!
if ( !IsPC() && g_config.ForceHWSync() )
{
g_pShaderAPI->ForceHardwareSync();
@ -3730,7 +3719,6 @@ void CMaterialSystem::EndFrame( void )
}
}
IThreadPool *pThreadPool = CreateMatQueueThreadPool();
pThreadPool->AddJob( m_pActiveAsyncJob );
break;
}
@ -4664,20 +4652,9 @@ void CMaterialSystem::BeginRenderTargetAllocation( void )
void CMaterialSystem::EndRenderTargetAllocation( void )
{
// Any GPU newer than 2005 doesn't need to do this, and it eats up ~40% of our level load time!
const bool cbRequiresRenderTargetAllocationFirst = mat_requires_rt_alloc_first.GetBool();
g_pShaderAPI->FlushBufferedPrimitives();
m_bAllocatingRenderTargets = false;
if ( IsPC() && cbRequiresRenderTargetAllocationFirst && g_pShaderAPI->CanDownloadTextures() )
{
// Simulate an Alt-Tab...will cause RTs to be allocated first
g_pShaderDevice->ReleaseResources();
g_pShaderDevice->ReacquireResources();
}
TextureManager()->CacheExternalStandardRenderTargets();
}

View File

@ -455,14 +455,11 @@ public:
}
else
{
ALIGN16 uint16 tempIndices[16];
static ALIGN16 uint16 tempIndices[256];
// original method
int i = 0;
if ( (size_t)desc.m_pIndices % 4 == 2 )
{
desc.m_pIndices[i] = pIndexData[i] + desc.m_nFirstVertex;
i++;
}
while ( i < nIndices )
{
int nToCopy = min( (int)ARRAYSIZE(tempIndices), nIndices - i );

View File

@ -2458,15 +2458,8 @@ bool CTexture::AsyncReadTextureFromFile( IVTFTexture* pVTFTexture, unsigned int
return false;
}
if ( V_strstr( GetName(), "c_sniperrifle_scope" ) )
{
int i = 0;
i = 3;
}
tmZone( TELEMETRY_LEVEL0, TMZF_NONE, "%s - %s", __FUNCTION__, tmDynamicString( TELEMETRY_LEVEL0, pCacheFileName ) );
// OSX hackery
int nPreserveFlags = nAdditionalCreationFlags;
if ( m_nFlags & TEXTUREFLAGS_SRGB )
@ -4189,12 +4182,6 @@ bool SLoadTextureBitsFromFile( IVTFTexture **ppOutVtfTexture, FileHandle_t hFile
// NOTE! NOTE! NOTE! or by the streaming texture code!
Assert( ppOutVtfTexture != NULL && *ppOutVtfTexture != NULL );
if ( V_strstr( pName, "c_rocketlauncher/c_rocketlauncher" ) )
{
int i = 0;
i = 3;
}
CUtlBuffer buf;
{

View File

@ -79,14 +79,14 @@ Studio models are position independent, so the cache manager can move them.
#define MAXSTUDIOFLEXVERTS 5000
#endif
#define MAXSTUDIOSKINS 32 // total textures
#define MAXSTUDIOBONES 256 // total bones actually used
#define MAXSTUDIOBONES 128 // total bones actually used
#define MAXSTUDIOFLEXDESC 1024 // maximum number of low level flexes (actual morph targets)
#define MAXSTUDIOFLEXCTRL 96 // maximum number of flexcontrollers (input sliders)
#define MAXSTUDIOPOSEPARAM 24
#define MAXSTUDIOBONECTRLS 5
#define MAXSTUDIOANIMBLOCKS 256
#define MAXSTUDIOBONEBITS 8 // NOTE: MUST MATCH MAXSTUDIOBONES
#define MAXSTUDIOBONEBITS 7 // NOTE: MUST MATCH MAXSTUDIOBONES
// NOTE!!! : Changing this number also changes the vtx file format!!!!!
#define MAX_NUM_BONES_PER_VERT 3

View File

@ -52,6 +52,12 @@
#pragma once
#pragma warning(push)
#pragma warning(disable:4251)
extern "C"
{
void __declspec(dllimport) __stdcall Sleep( unsigned long );
}
#endif
#ifdef COMPILER_MSVC64
@ -194,8 +200,6 @@ PLATFORM_INTERFACE bool ReleaseThreadHandle( ThreadHandle_t );
//-----------------------------------------------------------------------------
PLATFORM_INTERFACE void ThreadSleep(unsigned duration = 0);
PLATFORM_INTERFACE void ThreadNanoSleep(unsigned ns);
PLATFORM_INTERFACE ThreadId_t ThreadGetCurrentId();
PLATFORM_INTERFACE ThreadHandle_t ThreadGetCurrentHandle();
PLATFORM_INTERFACE int ThreadGetPriority( ThreadHandle_t hThread = NULL );
@ -229,10 +233,10 @@ inline void ThreadPause()
{
#if defined( COMPILER_PS3 )
__db16cyc();
#elif defined(__arm__) || defined(__aarch64__)
sched_yield();
#elif defined( COMPILER_GCC )
#elif defined( COMPILER_GCC ) && (defined( __i386__ ) || defined( __x86_64__ ))
__asm __volatile( "pause" );
#elif defined( POSIX )
sched_yield();
#elif defined ( COMPILER_MSVC64 )
_mm_pause();
#elif defined( COMPILER_MSVC32 )
@ -247,6 +251,36 @@ inline void ThreadPause()
#endif
}
inline void ThreadSleep(unsigned nMilliseconds = 0)
{
if( nMilliseconds == 0 )
{
ThreadPause();
return;
}
#ifdef _WIN32
#ifdef _WIN32_PC
static bool bInitialized = false;
if ( !bInitialized )
{
bInitialized = true;
// Set the timer resolution to 1 ms (default is 10.0, 15.6, 2.5, 1.0 or
// some other value depending on hardware and software) so that we can
// use Sleep( 1 ) to avoid wasting CPU time without missing our frame
// rate.
timeBeginPeriod( 1 );
}
#endif
Sleep( nMilliseconds );
#elif PS3
sys_timer_usleep( nMilliseconds * 1000 );
#elif defined(POSIX)
usleep( nMilliseconds * 1000 );
#endif
}
PLATFORM_INTERFACE bool ThreadJoin( ThreadHandle_t, unsigned timeout = TT_INFINITE );
PLATFORM_INTERFACE void ThreadSetDebugName( ThreadHandle_t hThread, const char *pszName );

View File

@ -428,6 +428,8 @@ inline bool KeyValues::IsEmpty( int keySymbol )
return dat ? dat->IsEmpty( ) : true;
}
bool IsSteamDeck();
bool EvaluateConditional( const char *str );
class CUtlSortVectorKeyValuesByName

View File

@ -11,21 +11,15 @@ namespace memutils
template<typename T>
inline void copy( T *dest, const T *src, size_t n )
{
do
{
--n;
*(dest+n) = *(src+n);
} while( n );
for(; n; n--)
*(dest++) = *(src++);
}
template<typename T>
inline void set( T *dest, const T &value, size_t n )
inline void set( T *dest, const T& value, size_t n )
{
do
{
--n;
*(dest+n) = value;
} while( n );
for(; n; n--)
*(dest++) = value;
}
}

View File

@ -69,6 +69,8 @@
#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1
#define GL_ALPHA_TEST_REF_QCOM 0x0BC2
#define GLSL_VERSION "#version 300 es\n"
extern void GLMDebugPrintf( const char *pMsg, ... );
extern uint g_nTotalDrawsOrClears, g_nTotalVBLockBytes, g_nTotalIBLockBytes;

View File

@ -492,8 +492,8 @@ public:
//-----------------------------------------------------
// Thread event support (safe for NULL this to simplify code )
//-----------------------------------------------------
bool WaitForFinish( uint32 dwTimeout = TT_INFINITE ) { if (!this) return true; return ( !IsFinished() ) ? g_pThreadPool->YieldWait( this, dwTimeout ) : true; }
bool WaitForFinishAndRelease( uint32 dwTimeout = TT_INFINITE ) { if (!this) return true; bool bResult = WaitForFinish( dwTimeout); Release(); return bResult; }
inline bool WaitForFinish( uint32 dwTimeout = TT_INFINITE, IThreadPool *pool = g_pThreadPool ) { if (!this) return true; return ( !IsFinished() ) ? pool->YieldWait( this, dwTimeout ) : true; }
inline bool WaitForFinishAndRelease( uint32 dwTimeout = TT_INFINITE ) { if (!this) return true; bool bResult = WaitForFinish( dwTimeout); Release(); return bResult; }
CThreadEvent *AccessEvent() { return &m_CompleteEvent; }
//-----------------------------------------------------

View File

@ -485,59 +485,6 @@ bool ReleaseThreadHandle( ThreadHandle_t hThread )
//
//-----------------------------------------------------------------------------
void ThreadSleep(unsigned nMilliseconds)
{
#ifdef _WIN32
#ifdef _WIN32_PC
static bool bInitialized = false;
if ( !bInitialized )
{
bInitialized = true;
// Set the timer resolution to 1 ms (default is 10.0, 15.6, 2.5, 1.0 or
// some other value depending on hardware and software) so that we can
// use Sleep( 1 ) to avoid wasting CPU time without missing our frame
// rate.
timeBeginPeriod( 1 );
}
#endif
Sleep( nMilliseconds );
#elif PS3
if( nMilliseconds == 0 )
{
// sys_ppu_thread_yield doesn't seem to function properly, so sleep instead.
// sys_timer_usleep( 60 );
sys_ppu_thread_yield();
}
else
{
sys_timer_usleep( nMilliseconds * 1000 );
}
#elif defined(POSIX)
usleep( nMilliseconds * 1000 );
#endif
}
//-----------------------------------------------------------------------------
void ThreadNanoSleep(unsigned ns)
{
#ifdef _WIN32
// ceil
Sleep( ( ns + 999 ) / 1000 );
#elif PS3
sys_timer_usleep( ns );
#elif defined(POSIX)
struct timespec tm;
tm.tv_sec = 0;
tm.tv_nsec = ns;
nanosleep( &tm, NULL );
#endif
}
//-----------------------------------------------------------------------------
#ifndef ThreadGetCurrentId
ThreadId_t ThreadGetCurrentId()
{

View File

@ -2179,6 +2179,34 @@ void KeyValues::RecursiveMergeKeyValues( KeyValues *baseKV )
}
}
static int s_nSteamDeckCached = -1;
bool IsSteamDeck()
{
if (s_nSteamDeckCached == -1) {
if ( CommandLine()->CheckParm( "-nogamepadui" ) != 0 )
{
s_nSteamDeckCached = 0;
}
else
{
if ( CommandLine()->CheckParm( "-gamepadui" ) != 0 )
{
s_nSteamDeckCached = 1;
}
else
{
char *deck = getenv("SteamDeck");
if ( deck == 0 || *deck == 0 )
s_nSteamDeckCached = 0;
else
s_nSteamDeckCached = atoi(deck) != 0;
}
}
}
return s_nSteamDeckCached;
}
//-----------------------------------------------------------------------------
// Returns whether a keyvalues conditional evaluates to true or false
// Needs more flexibility with conditionals, checking convars would be nice.
@ -2195,8 +2223,8 @@ bool EvaluateConditional( const char *str )
if ( *str == '!' )
bNot = true;
if( Q_stristr( str, "$DECK" ) )
return false ^ bNot; // Steam deck unsupported
if ( Q_stristr( str, "$DECK" ) )
return IsSteamDeck() ^ bNot;
if ( Q_stristr( str, "$X360" ) )
return IsX360() ^ bNot;

View File

@ -427,7 +427,7 @@ bool GLMGenTexels( GLMGenTexelParams *params )
DebuggerBreak();
return FALSE;
}
// verify that the amount you want to write will not exceed the limit byte count
unsigned long destByteCount = chunksize * params->m_chunkCount;
@ -3828,7 +3828,7 @@ void CGLMTex::Lock( GLMTexLockParams *params, char** addressOut, int* yStrideOut
// d - the params of the lock request have been saved in the lock table (in the context)
// so step 1 is unambiguous. If there's no backing storage, make some.
if (!m_backing)
if (!m_backing && !(m_layout->m_key.m_texFlags & kGLMTexDynamic))
{
if ( gl_pow2_tempmem.GetBool() )
{
@ -3940,7 +3940,7 @@ 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 ) )
if ( (m_layout->m_key.m_texFlags & kGLMTexDynamic) || (params->m_readonly && copyout) )
{
// read the whole slice
// (odds are we'll never request anything but a whole slice to be read..)
@ -4080,7 +4080,7 @@ void CGLMTex::Unlock( GLMTexLockParams *params )
// because it reuploads the whole thing each slice; we only use 3D textures
// for the 32x32x32 colorpsace conversion lookups and debugging the problem
// would not save any more memory.
if ( !m_texClientStorage && ( m_texGLTarget == GL_TEXTURE_2D ) )
if ( !m_texClientStorage && ( m_texGLTarget == GL_TEXTURE_2D ) && m_backing )
{
free(m_backing);
m_backing = NULL;

View File

@ -3287,13 +3287,13 @@ int D3DToGL::TranslateShader( uint32* code, CUtlBuffer *pBufDisassembledCode, bo
if ( ( dwToken & 0xFFFF0000 ) == 0xFFFF0000 )
{
// must explicitly enable extensions if emitting GLSL
V_snprintf( (char *)m_pBufHeaderCode->Base(), m_pBufHeaderCode->Size(), "#version 300 es\nprecision highp float;\n#define varying in\n\n%s", glslExtText );
V_snprintf( (char *)m_pBufHeaderCode->Base(), m_pBufHeaderCode->Size(), GLSL_VERSION "precision highp float;\n#define varying in\n\n%s", glslExtText );
m_bVertexShader = false;
}
else // vertex shader
{
m_bGenerateSRGBWriteSuffix = false;
V_snprintf( (char *)m_pBufHeaderCode->Base(), m_pBufHeaderCode->Size(), "#version 300 es\nprecision highp float;\n#define attribute in\n#define varying out\n%s//ATTRIBMAP-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx\n", glslExtText );
V_snprintf( (char *)m_pBufHeaderCode->Base(), m_pBufHeaderCode->Size(), GLSL_VERSION "precision highp float;\n#define attribute in\n#define varying out\n%s//ATTRIBMAP-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx\n", glslExtText );
// find that first '-xx' which is where the attrib map will be written later.
pAttribMapStart = strstr( (char *)m_pBufHeaderCode->Base(), "-xx" ) + 1;

View File

@ -214,7 +214,11 @@ public:
//-----------------------------------------------------
virtual int YieldWait( CThreadEvent **pEvents, int nEvents, bool bWaitAll = true, unsigned timeout = TT_INFINITE );
virtual int YieldWait( CJob **, int nJobs, bool bWaitAll = true, unsigned timeout = TT_INFINITE );
void Yield( unsigned timeout );
inline void Yield( unsigned timeout )
{
Assert( ThreadInMainThread() );
ThreadSleep( timeout );
}
//-----------------------------------------------------
// Add a native job to the queue (master thread)
@ -656,20 +660,6 @@ int CThreadPool::YieldWait( CJob **ppJobs, int nJobs, bool bWaitAll, unsigned ti
return YieldWait( handles.Base(), handles.Count(), bWaitAll, timeout);
}
//---------------------------------------------------------
void CThreadPool::Yield( unsigned timeout )
{
// @MULTICORE (toml 10/24/2006): not implemented
Assert( ThreadInMainThread() );
if ( !ThreadInMainThread() )
{
ThreadSleep( timeout );
return;
}
ThreadSleep( timeout );
}
//---------------------------------------------------------
// Add a job to the queue
//---------------------------------------------------------

View File

@ -432,7 +432,7 @@ bool CVTFTexture::Init( int nWidth, int nHeight, int nDepth, ImageFormat fmt, in
m_nFrameCount = iFrameCount;
m_nFaceCount = (iFlags & TEXTUREFLAGS_ENVMAP) ? (CUBEMAP_FACE_COUNT-1) : 1;
m_nFaceCount = (iFlags & TEXTUREFLAGS_ENVMAP) ? CUBEMAP_FACE_COUNT : 1;
#if defined( _X360 )
m_nMipSkipCount = 0;
@ -601,7 +601,7 @@ void CVTFTexture::ImageFileInfo( int nFrame, int nFace, int nMipLevel, int *pSta
int nFacesToRead = m_nFaceCount;
if ( IsCubeMap() )
{
if ((m_nVersion[0] == 7) && (m_nVersion[1] < 1))
if ((m_nVersion[0] == 7) && (m_nVersion[1] < 1 || m_nVersion[1] > 4))
{
nFacesToRead = 6;
if (nFace == CUBEMAP_FACE_SPHEREMAP)
@ -1068,7 +1068,7 @@ bool CVTFTexture::UnserializeEx( CUtlBuffer &buf, bool bHeaderOnly, int nForceFl
m_nFrameCount = header.numFrames;
m_nFaceCount = (m_nFlags & TEXTUREFLAGS_ENVMAP) ? (CUBEMAP_FACE_COUNT-1) : 1;
m_nFaceCount = (m_nFlags & TEXTUREFLAGS_ENVMAP) ? CUBEMAP_FACE_COUNT : 1;
// NOTE: We're going to store space for all mip levels, even if we don't
// have data on disk for them. This is for backward compatibility