diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b22a8e315..5629187f6 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- os: [windows-latest, ubuntu-latest]
+ os: [windows-latest, ubuntu-latest, macos-15-intel, macos-latest]
configuration: [Debug, Release]
include:
- os: ubuntu-latest
diff --git a/Dependencies/Steamworks/Steamworks.csproj b/Dependencies/Steamworks/Steamworks.csproj
index 7213eb36e..64f15ce25 100644
--- a/Dependencies/Steamworks/Steamworks.csproj
+++ b/Dependencies/Steamworks/Steamworks.csproj
@@ -5,7 +5,6 @@
Steamworks
Steamworks.NET
false
- x64
Debug;Release;Debug (Dedicated);Release (Dedicated)
$(DefineConstants);STEAMWORKS_X64
diff --git a/Directory.Build.props b/Directory.Build.props
index 8082adb95..4ec807c32 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -40,13 +40,24 @@
$(DefineConstants);LINUX
+
+ $(DefineConstants);POSIX
+
+
$(DefineConstants);SWDS;DEDICATED
- x64
- x64
+ $([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)
+ x64;arm64
+ x64
+ arm64
+ x64
+
+
+
+ AnyCPU
diff --git a/Directory.Build.targets b/Directory.Build.targets
index bbf1d9fc0..aca752f7a 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -4,4 +4,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Game.Assets/Game.Assets.csproj b/Game.Assets/Game.Assets.csproj
index 007937c07..1a55104af 100644
--- a/Game.Assets/Game.Assets.csproj
+++ b/Game.Assets/Game.Assets.csproj
@@ -4,7 +4,6 @@
net10.0
enable
enable
- x64
Debug;Release;Debug (Dedicated);Release (Dedicated)
diff --git a/Game.Client/HL2/HudCredits.cs b/Game.Client/HL2/HudCredits.cs
index bfefab031..631963a49 100644
--- a/Game.Client/HL2/HudCredits.cs
+++ b/Game.Client/HL2/HudCredits.cs
@@ -219,7 +219,7 @@ private void DrawOutroCreditsName() {
LastOneInPlace = true;
// 360 certification requires that we not hold a static image too long.
- FadeTime = gpGlobals.CurTime + (IsConsole() ? 2.0f : 10.0f);
+ FadeTime = gpGlobals.CurTime + 10.0f;
}
}
else {
diff --git a/Game.Client/RenderTexture.cs b/Game.Client/RenderTexture.cs
index 7c3f2f0fa..ad36dbaec 100644
--- a/Game.Client/RenderTexture.cs
+++ b/Game.Client/RenderTexture.cs
@@ -26,9 +26,6 @@ static void AddReleaseFunc() {
static readonly TextureReference PowerOfTwoFrameBufferTexture = new();
public static ITexture? GetPowerOfTwoFrameBufferTexture() {
- if (IsX360())
- return GetFullFrameFrameBufferTexture(1);
-
if (!PowerOfTwoFrameBufferTexture.IsValid()) {
PowerOfTwoFrameBufferTexture.Init(materials.FindTexture("_rt_PowerOfTwoFB", MaterialDefines.TEXTURE_GROUP_RENDER_TARGET));
Assert(!ITexture.IsError(PowerOfTwoFrameBufferTexture.Get()));
@@ -169,11 +166,6 @@ static void AddReleaseFunc() {
/// tiny 32x32 texture, always 8888
///
public static ITexture? GetTeenyTexture(int which) {
- if (IsX360()) {
- Assert(false);
- return null;
- }
-
Assert(which < MAX_TEENY_TEXTURES);
if (!TeenyTextures[which].IsValid()) {
diff --git a/Game.Client/ViewScene.cs b/Game.Client/ViewScene.cs
index 02d3ddb0e..c67c8ed46 100644
--- a/Game.Client/ViewScene.cs
+++ b/Game.Client/ViewScene.cs
@@ -26,18 +26,16 @@ public static class ViewScene
public static void UpdateRefractTexture(int x, int y, int w, int h, bool forceUpdate = false) {
Assert(!DrawingShadowDepthView());
- if (!IsRetail() && !r_updaterefracttexture.GetBool())
+ if (!r_updaterefracttexture.GetBool())
return;
using MatRenderContextPtr renderContext = new(materials);
ITexture? texture = RenderTexture.GetPowerOfTwoFrameBufferTexture();
- if (IsPC() || forceUpdate || g_bAllowMultipleRefractUpdatesPerScenePerFrame || (gpGlobals.FrameCount != g_viewscene_refractUpdateFrame)) {
- // forced or only once per frame
- System.Drawing.Rectangle rect = new(x, y, w, h);
- renderContext.CopyRenderTargetToTextureEx(texture!, 0, ref rect, ref Unsafe.NullRef());
+ // forced or only once per frame
+ System.Drawing.Rectangle rect = new(x, y, w, h);
+ renderContext.CopyRenderTargetToTextureEx(texture!, 0, ref rect, ref Unsafe.NullRef());
- g_viewscene_refractUpdateFrame = gpGlobals.FrameCount;
- }
+ g_viewscene_refractUpdateFrame = gpGlobals.FrameCount;
renderContext.SetFrameBufferCopyTexture(texture);
}
diff --git a/Game.Server/BaseEntity.cs b/Game.Server/BaseEntity.cs
index a0cbd7f20..5c0eb1447 100644
--- a/Game.Server/BaseEntity.cs
+++ b/Game.Server/BaseEntity.cs
@@ -3015,25 +3015,23 @@ public static void PrecacheModelComponents(int modelIndex) {
return;
// sounds
- if (IsPC()) {
- ReadOnlySpan name = modelinfo.GetModelName(model);
- if (!g_ModelSoundsCache.TryGetValue(name.Hash(), out _)) {
- ReadOnlySpan extension = Path.GetExtension(name);
+ ReadOnlySpan name = modelinfo.GetModelName(model);
+ if (!g_ModelSoundsCache.TryGetValue(name.Hash(), out _)) {
+ ReadOnlySpan extension = Path.GetExtension(name);
- if (!stristr(extension, "mdl").IsEmpty)
- DevMsg(2, $"Late precache of {name}, need to rebuild modelsounds.cache\n");
- else {
- if (extension[0] == '\0')
- Warning($"Precache of {name} ambigious (no extension specified)\n");
- else
- Warning($"Late precache of {name} (file missing?)\n");
- return;
- }
+ if (!stristr(extension, "mdl").IsEmpty)
+ DevMsg(2, $"Late precache of {name}, need to rebuild modelsounds.cache\n");
+ else {
+ if (extension[0] == '\0')
+ Warning($"Precache of {name} ambigious (no extension specified)\n");
+ else
+ Warning($"Late precache of {name} (file missing?)\n");
+ return;
}
-
- if (g_ModelSoundsCache.TryGetValue(name.Hash(), out ModelSoundsCache? entry))
- entry.PrecacheSoundList();
}
+
+ if (g_ModelSoundsCache.TryGetValue(name.Hash(), out ModelSoundsCache? entry))
+ entry.PrecacheSoundList();
}
static readonly Dictionary g_ModelSoundsCache = [];
diff --git a/Game.Server/World.cs b/Game.Server/World.cs
index 24c256a34..7d2dfa7ac 100644
--- a/Game.Server/World.cs
+++ b/Game.Server/World.cs
@@ -171,8 +171,8 @@ public override void Spawn() {
g_EventQueue.Init();
Precache();
- GlobalEntity.Add("is_console", gpGlobals.MapName, (IsConsole()) ? GlobalEState.On : GlobalEState.Off);
- GlobalEntity.Add("is_pc", gpGlobals.MapName, (!IsConsole()) ? GlobalEState.On : GlobalEState.Off);
+ GlobalEntity.Add("is_console", gpGlobals.MapName, GlobalEState.Off);
+ GlobalEntity.Add("is_pc", gpGlobals.MapName, GlobalEState.On);
}
public static readonly new ServerClass ServerClass = new ServerClass(DT_WORLD);
diff --git a/Game.Shared/AchievementMgr.cs b/Game.Shared/AchievementMgr.cs
index 04659f6bc..edcd893b3 100644
--- a/Game.Shared/AchievementMgr.cs
+++ b/Game.Shared/AchievementMgr.cs
@@ -545,7 +545,7 @@ public void ResetAchievement(int achievementID) {
}
public void PrintAchievementStatus() {
- if (IsPC() && !LoggedIntoSteam()) {
+ if (!LoggedIntoSteam()) {
Msg("Steam not running, achievements disabled. Cannot view or unlock achievements.\n");
return;
}
diff --git a/Game.Shared/HL2/HL_GameMovement.cs b/Game.Shared/HL2/HL_GameMovement.cs
index aaae1d0a8..46e96fb2c 100644
--- a/Game.Shared/HL2/HL_GameMovement.cs
+++ b/Game.Shared/HL2/HL_GameMovement.cs
@@ -587,7 +587,7 @@ protected override void FullLadderMove() {
if (!wouldleaveladder && !neardismountnode) {
// Otherwise, if the move would leave the ladder, disallow it.
if (pressed_use) {
- if (ExitLadderViaDismountNode(ladder, false, IsX360())) {
+ if (ExitLadderViaDismountNode(ladder, false)) {
// See if they +used a dismount point mid-span..
return;
}
diff --git a/Game.UI/GameUI.cs b/Game.UI/GameUI.cs
index bf3470c8d..7dea4a6b6 100644
--- a/Game.UI/GameUI.cs
+++ b/Game.UI/GameUI.cs
@@ -158,24 +158,15 @@ private bool FindPlatformDirectory(out ReadOnlySpan platformDir) {
platformDir = string.Empty;
#if WIN32
- var location = System.Reflection.Assembly.GetExecutingAssembly().Location;
- if (string.IsNullOrEmpty(location))
- return false;
-
- var dir = Path.GetDirectoryName(location);
- if (dir == null)
- return false;
-
- platformDir = Path.Combine(dir, "platform") + Path.DirectorySeparatorChar;
- return true;
+ string? dir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
#else
- string dir = Directory.GetCurrentDirectory();
+ string? dir = Directory.GetCurrentDirectory();
+#endif
if (string.IsNullOrEmpty(dir))
return false;
platformDir = Path.Combine(dir, "platform") + Path.DirectorySeparatorChar;
return true;
-#endif
}
public void Shutdown() {
@@ -186,20 +177,18 @@ public void Start() {
if (!FindPlatformDirectory(out ReadOnlySpan platformDir))
return;
- if (IsPC()) {
- Span configDir = stackalloc char[512];
- strcpy(configDir, platformDir);
- strcat(configDir, "config");
+ Span configDir = stackalloc char[512];
+ strcpy(configDir, platformDir);
+ strcat(configDir, "config");
- Msg($"Steam config directory: {configDir.SliceNullTerminatedString()}\n");
+ Msg($"Steam config directory: {configDir.SliceNullTerminatedString()}\n");
- fileSystem.AddSearchPath(configDir.SliceNullTerminatedString(), "CONFIG");
- fileSystem.CreateDirHierarchy("", "CONFIG");
+ fileSystem.AddSearchPath(configDir.SliceNullTerminatedString(), "CONFIG");
+ fileSystem.CreateDirHierarchy("", "CONFIG");
- // todo SetUserConfigFile
+ // todo SetUserConfigFile
- fileSystem.AddSearchPath("platform", "PLATFORM");
- }
+ fileSystem.AddSearchPath("platform", "PLATFORM");
localize.AddFile("Resource/platform_%language%.txt");
localize.AddFile("Resource/vgui_%language%.txt");
diff --git a/Game.UI/OptionsDialog.cs b/Game.UI/OptionsDialog.cs
index 7b92df74a..41af0365d 100644
--- a/Game.UI/OptionsDialog.cs
+++ b/Game.UI/OptionsDialog.cs
@@ -33,12 +33,12 @@ public OptionsDialog(Panel? parent) : base(parent, "OptionsDialog") {
AddPage(new OptionsSubVoice(this, null), "#GameUI_Voice");
// AddPage(new OptionsSubLegal(this, null), "#GameUI_Legal");
#else
-#if WIN32
- ConVarRef hap_HasDevice = new("hap_HasDevice");
- hap_HasDevice.Init("hap_HasDevice", true);
- // if (hap_HasDevice.GetBool())
- // AddPage(new OptionsSubHaptics(this), "#GameUI_Haptics_TabTitle");
-#endif
+ if (IsWindows) {
+ ConVarRef hap_HasDevice = new("hap_HasDevice");
+ hap_HasDevice.Init("hap_HasDevice", true);
+ // if (hap_HasDevice.GetBool())
+ // AddPage(new OptionsSubHaptics(this), "#GameUI_Haptics_TabTitle");
+ }
// if (ModInfo.IsSinglePlayerOnly() && !ModInfo.NoDifficulty())
// AddPage(new OptionsSubDifficulty(this), "#GameUI_Difficulty");
diff --git a/Game.UI/OptionsSubAudio.cs b/Game.UI/OptionsSubAudio.cs
index 654fdc5e9..7b8aa7134 100644
--- a/Game.UI/OptionsSubAudio.cs
+++ b/Game.UI/OptionsSubAudio.cs
@@ -40,15 +40,14 @@ public OptionsSubAudio(Panel? parent, ReadOnlySpan name) : base(parent, na
SoundQualityCombo.AddItem("#GameUI_Low", null);
SpeakerSetupCombo = new(this, "SpeakerSetup", 6, false);
-#if !POSIX
- SpeakerSetupCombo.AddItem("#GameUI_Headphones", null);
-#endif
+ if (!IsPosix)
+ SpeakerSetupCombo.AddItem("#GameUI_Headphones", null);
SpeakerSetupCombo.AddItem("#GameUI_2Speakers", null);
-#if !POSIX
- SpeakerSetupCombo.AddItem("#GameUI_4Speakers", null);
- SpeakerSetupCombo.AddItem("#GameUI_5Speakers", null);
- SpeakerSetupCombo.AddItem("#GameUI_7Speakers", null);
-#endif
+ if (!IsPosix) {
+ SpeakerSetupCombo.AddItem("#GameUI_4Speakers", null);
+ SpeakerSetupCombo.AddItem("#GameUI_5Speakers", null);
+ SpeakerSetupCombo.AddItem("#GameUI_7Speakers", null);
+ }
SpokenLanguageCombo = new(this, "AudioSpokenLanguage", 6, false);
SoundMuteLoseFocusCheckButton = new(this, "snd_mute_losefocus", "#GameUI_SndMuteLoseFocus", "snd_mute_losefocus");
@@ -77,10 +76,8 @@ public override void OnResetData() {
ConVarRef snd_surround_speakers = new("snd_surround_speakers");
int speakers = snd_surround_speakers.GetInt();
-#if POSIX
- if (speakers == 0)
+ if (IsPosix && speakers == 0)
speakers = 2;
-#endif
if (speakers < 0)
speakers = 2;
diff --git a/Source.Common/Formats/Keyvalues/KeyValues.cs b/Source.Common/Formats/Keyvalues/KeyValues.cs
index 1ff497ba2..a964f2211 100644
--- a/Source.Common/Formats/Keyvalues/KeyValues.cs
+++ b/Source.Common/Formats/Keyvalues/KeyValues.cs
@@ -271,20 +271,12 @@ public static bool EvaluateConditional(Span str) {
bNot = true;
if (str.Contains("$WIN32", StringComparison.OrdinalIgnoreCase))
- return IsPC() ^ bNot;
+ return !bNot;
if (str.Contains("$WINDOWS", StringComparison.OrdinalIgnoreCase))
-#if WIN32
- return !bNot;
-#else
- return bNot;
-#endif
+ return IsWindows ? !bNot : bNot;
if (str.Contains("$OSX", StringComparison.OrdinalIgnoreCase))
-#if OSX
- return !bNot;
-#else
- return bNot;
-#endif
+ return IsOSX ? !bNot : bNot;
if (str.Contains("$LINUX", StringComparison.OrdinalIgnoreCase))
#if LINUX
return !bNot;
@@ -292,11 +284,7 @@ public static bool EvaluateConditional(Span str) {
return bNot;
#endif
if (str.Contains("$POSIX", StringComparison.OrdinalIgnoreCase))
-#if OSX || LINUX
- return !bNot;
-#else
- return bNot;
-#endif
+ return IsPosix ? !bNot : bNot;
return false;
}
diff --git a/Source.Common/Platform.cs b/Source.Common/Platform.cs
index 86ff29302..dcf149b8a 100644
--- a/Source.Common/Platform.cs
+++ b/Source.Common/Platform.cs
@@ -1,33 +1,38 @@
using Source.Common;
using System.Diagnostics;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Source;
-public static class PlatformMacros
+public delegate bool MessageBoxFn(ReadOnlySpan title, ReadOnlySpan info, bool showOkAndCancel);
+
+public static class Platform
{
- [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsPC() => true;
- [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsConsole() => false;
- [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsX360() => false;
- [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsRetail() => false;
- [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSX()
+ public const bool IsWindows
+#if WIN32
+ = true;
+#else
+ = false;
+#endif
+
+ public const bool IsOSX
#if OSX
- => true;
+ = true;
#else
- => false;
+ = false;
+#endif
+
+ public const bool IsPosix
+#if POSIX
+ = true;
+#else
+ = false;
#endif
- [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsPlatform64Bits() => IntPtr.Size == 8;
public const int MAX_PATH = 260;
public const int MAX_OSPATH = 260;
-}
-public delegate bool MessageBoxFn(ReadOnlySpan title, ReadOnlySpan info, bool showOkAndCancel);
-
-public static class Platform
-{
readonly static Lazy __timer = new(() => {
Stopwatch stopwatch = new();
stopwatch.Start();
diff --git a/Source.Engine/ConSys.cs b/Source.Engine/ConSys.cs
index 9821e1a56..c40a4fd26 100644
--- a/Source.Engine/ConSys.cs
+++ b/Source.Engine/ConSys.cs
@@ -709,18 +709,12 @@ public static void PrintF(ReadOnlySpan msg) {
}
public static void NPrintF(int idx, ReadOnlySpan text) {
#if !SWDS
- if (IsPC())
- conPanel!.Con_NPrintf(idx, text);
- else
- PrintF(text);
+ conPanel!.Con_NPrintf(idx, text);
#endif
}
public static void NXPrintF(in Con_NPrint_s info, ReadOnlySpan text) {
#if !SWDS
- if (IsPC())
- conPanel!.Con_NXPrintf(in info, text);
- else
- PrintF(text);
+ conPanel!.Con_NXPrintf(in info, text);
#endif
}
diff --git a/Source.Engine/DispInfo.cs b/Source.Engine/DispInfo.cs
index 3311fb97d..36f57aff7 100644
--- a/Source.Engine/DispInfo.cs
+++ b/Source.Engine/DispInfo.cs
@@ -272,7 +272,7 @@ public bool CopyCoreDispData(Model world, MaterialSystem_SortInfo[] sortInfos, C
MatSys.SurfSetupSurfaceContext(ref ctx, ref GetParent());
#endif
- if (IsPC() && restoring) {
+ if (restoring) {
#if !SWDS
if (NumLightmaps() > 1)
BumpSTexCoordOffset = ctx.BumpSTexCoordOffset;
diff --git a/Source.Engine/MatSysInterface.cs b/Source.Engine/MatSysInterface.cs
index a6cab83e7..a50553786 100644
--- a/Source.Engine/MatSysInterface.cs
+++ b/Source.Engine/MatSysInterface.cs
@@ -300,9 +300,6 @@ private void InitDebugMaterials() {
}
private ITexture? CreatePowerOfTwoFBTexture() {
- if (IsX360())
- return null;
-
return materials.CreateNamedRenderTargetTextureEx2(
"_rt_PowerOfTwoFB",
1024, 1024, RenderTargetSizeMode.Default,
@@ -388,10 +385,6 @@ private void InitDebugMaterials() {
strcpy(textureName, MaterialDefines.FULL_FRAME_FRAMEBUFFER);
CreateRenderTargetFlags rtFlags = extraFlags | CreateRenderTargetFlags.HDR;
- if (IsX360()) {
- // just make the system memory texture only
- rtFlags |= CreateRenderTargetFlags.NoEDRAM;
- }
return materials.CreateNamedRenderTargetTextureEx2(
textureName.SliceNullTerminatedString(),
1, 1, RenderTargetSizeMode.FullFrameBuffer, materials.GetBackBufferFormat(),
@@ -401,27 +394,16 @@ private void InitDebugMaterials() {
}
private ITexture? CreateFullFrameDepthTexture() {
- if (IsX360()) {
- return materials.CreateNamedRenderTargetTextureEx2("_rt_FullFrameDepth", 1, 1,
- RenderTargetSizeMode.FullFrameBuffer, materials.GetShadowDepthTextureFormat(), MaterialRenderTargetDepth.None,
- TextureFlags.ClampS | TextureFlags.ClampT | TextureFlags.PointSample,
- CreateRenderTargetFlags.NoEDRAM);
- }
- else
- materials.AddTextureAlias("_rt_FullFrameDepth", "_rt_PowerOfTwoFB");
+ materials.AddTextureAlias("_rt_FullFrameDepth", "_rt_PowerOfTwoFB");
return null;
}
private ITexture? CreateResolvedFullFrameDepthTexture() {
- if (IsPC()) {
- return materials.CreateNamedRenderTargetTextureEx2("_rt_ResolvedFullFrameDepth", 1, 1,
- RenderTargetSizeMode.FullFrameBuffer, ImageFormat.RGBA8888, MaterialRenderTargetDepth.Separate,
- TextureFlags.ClampS | TextureFlags.ClampT | TextureFlags.PointSample,
- CreateRenderTargetFlags.NoEDRAM);
- }
-
- return null;
+ return materials.CreateNamedRenderTargetTextureEx2("_rt_ResolvedFullFrameDepth", 1, 1,
+ RenderTargetSizeMode.FullFrameBuffer, ImageFormat.RGBA8888, MaterialRenderTargetDepth.Separate,
+ TextureFlags.ClampS | TextureFlags.ClampT | TextureFlags.PointSample,
+ CreateRenderTargetFlags.NoEDRAM);
}
///
@@ -450,13 +432,12 @@ private void InitWellKnownRenderTargets() {
// Create the render targets upon which mods may rely
- if (IsPC())
- // Create for all mods as vgui2 uses it for 3D painting
- g_PowerOfTwoFBTexture.Init(CreatePowerOfTwoFBTexture());
+ // Create for all mods as vgui2 uses it for 3D painting
+ g_PowerOfTwoFBTexture.Init(CreatePowerOfTwoFBTexture());
// Create these for all mods because the engine references them
if (HardwareConfig.GetDXSupportLevel() >= 80) {
- if (IsPC() && HardwareConfig.GetDXSupportLevel() >= 90 && HardwareConfig.GetHDRType() == HDRType.Float)
+ if (HardwareConfig.GetDXSupportLevel() >= 90 && HardwareConfig.GetHDRType() == HDRType.Float)
// Used for building HDR Cubemaps
g_BuildCubemaps16BitTexture.Init(CreateBuildCubemaps16BitTexture());
@@ -468,11 +449,9 @@ private void InitWellKnownRenderTargets() {
g_QuarterSizedFBTexture1.Init(CreateQuarterSizedFBTexture(1, 0));
}
- if (IsPC()) {
- g_TeenyFBTexture0.Init(CreateTeenyFBTexture(0));
- g_TeenyFBTexture1.Init(CreateTeenyFBTexture(1));
- g_TeenyFBTexture2.Init(CreateTeenyFBTexture(2));
- }
+ g_TeenyFBTexture0.Init(CreateTeenyFBTexture(0));
+ g_TeenyFBTexture1.Init(CreateTeenyFBTexture(1));
+ g_TeenyFBTexture2.Init(CreateTeenyFBTexture(2));
g_FullFrameFBTexture0.Init(CreateFullFrameFBTexture(0));
g_FullFrameFBTexture1.Init(CreateFullFrameFBTexture(1));
diff --git a/Source.Engine/SV.cs b/Source.Engine/SV.cs
index 6eb28af3a..29cd0b4dd 100644
--- a/Source.Engine/SV.cs
+++ b/Source.Engine/SV.cs
@@ -485,7 +485,7 @@ internal void Frame(bool finalTick) {
}
- if (IsPC() && sv.IsMultiplayer())
+ if (sv.IsMultiplayer())
Steam3Server().RunFrame();
}
diff --git a/Source.Engine/Server/GameServer.cs b/Source.Engine/Server/GameServer.cs
index 188f7d2cd..05442e423 100644
--- a/Source.Engine/Server/GameServer.cs
+++ b/Source.Engine/Server/GameServer.cs
@@ -209,7 +209,7 @@ public int PrecacheModel(ReadOnlySpan name, Res flags, Model? model = null
slot.SetModel(model);
bool loadNow;
- loadNow = (slot.GetModel() == null && ((flags & Res.Preload) != 0 || IsX360()));
+ loadNow = (slot.GetModel() == null && (flags & Res.Preload) != 0);
if (CommandLine.FindParm("-nopreload") != 0 || CommandLine.FindParm("-nopreloadmodels") != 0)
loadNow = false;
else if (sv_forcepreload.GetInt() != 0 || CommandLine.FindParm("-preload") != 0)
@@ -718,7 +718,7 @@ internal bool SpawnServer(ReadOnlySpan mapName, ReadOnlySpan mapFile
#elif LINUX
ev.SetString( "os", "LINUX" );
#elif OSX
- ev.etString( "os", "OSX" );
+ ev.SetString( "os", "OSX" );
#else
#error Please define your platform
#endif
diff --git a/Source.Engine/VGuiBaseUIInterface.cs b/Source.Engine/VGuiBaseUIInterface.cs
index 52832fb4b..14fcc3115 100644
--- a/Source.Engine/VGuiBaseUIInterface.cs
+++ b/Source.Engine/VGuiBaseUIInterface.cs
@@ -652,26 +652,24 @@ public void Init() {
staticGameDLLPanel.SetCursor(CursorCode.None);
staticGameDLLPanel.SetZPos(135);
- if (IsPC()) {
- Common.TimestampedLog("Building Panels (staticDebugSystemPanel)");
+ Common.TimestampedLog("Building Panels (staticDebugSystemPanel)");
- staticDebugSystemPanel = new DebugSystemPanel(staticPanel, "Engine Debug System");
- staticDebugSystemPanel.SetZPos(125);
+ staticDebugSystemPanel = new DebugSystemPanel(staticPanel, "Engine Debug System");
+ staticDebugSystemPanel.SetZPos(125);
- // DemoUIPanel.InstallDemoUI(staticEngineToolsPanel);
- // DemoUIPanel2.Install(staticClientDLLPanel, staticEngineToolsPanel, true);
+ // DemoUIPanel.InstallDemoUI(staticEngineToolsPanel);
+ // DemoUIPanel2.Install(staticClientDLLPanel, staticEngineToolsPanel, true);
- // FogUIPanel.InstallFogUI(staticEngineToolsPanel);
+ // FogUIPanel.InstallFogUI(staticEngineToolsPanel);
- TxViewPanel.Install(staticEngineToolsPanel);
+ TxViewPanel.Install(staticEngineToolsPanel);
- Common.TimestampedLog("Install perf tools");
+ Common.TimestampedLog("Install perf tools");
- EnginePerfTools.InstallPerformanceToolsUI(staticEngineToolsPanel);
+ EnginePerfTools.InstallPerformanceToolsUI(staticEngineToolsPanel);
- // colorcorrectiontools.InstallColorCorrectionUI(staticEngineToolsPanel);
- // colorcorrectiontools.Init();
- }
+ // colorcorrectiontools.InstallColorCorrectionUI(staticEngineToolsPanel);
+ // colorcorrectiontools.Init();
if (CommandLine.CheckParm("-tools"))
staticGameDLLPanel.SetVisible(true);
@@ -695,13 +693,11 @@ public void Init() {
// - DemoUIPanel (if we even do demos)
// - FogUIPanel
- if (IsPC()) {
- Con.CreateConsolePanel(staticEngineToolsPanel);
- VGuiDrawTree.CreateDrawTreePanel(staticEngineToolsPanel);
- TextureListPanel.CreateTextureListPanel(staticEngineToolsPanel);
- CL.CreateEntityReportPanel(staticEngineToolsPanel);
- CreateVProfPanels(staticEngineToolsPanel);
- }
+ Con.CreateConsolePanel(staticEngineToolsPanel);
+ VGuiDrawTree.CreateDrawTreePanel(staticEngineToolsPanel);
+ TextureListPanel.CreateTextureListPanel(staticEngineToolsPanel);
+ CL.CreateEntityReportPanel(staticEngineToolsPanel);
+ CreateVProfPanels(staticEngineToolsPanel);
staticEngineToolsPanel.LoadControlSettings("scripts/EngineVGuiLayout.res");
@@ -716,9 +712,7 @@ public void Init() {
staticGameUIFuncs.Initialize(engineAPI);
staticGameUIFuncs.Start();
- if (IsPC()) {
- staticGameConsole = engineAPI.GetRequiredService();
- }
+ staticGameConsole = engineAPI.GetRequiredService();
if (staticGameConsole != null) {
staticGameConsole.Initialize();
@@ -1005,7 +999,7 @@ public bool Key_Event(in InputEvent ev) {
bool down = ev.Type != InputEventType.IE_ButtonReleased;
ButtonCode code = (ButtonCode)ev.Data;
- if (IsPC() && IsShiftKeyDown()) {
+ if (IsShiftKeyDown()) {
switch (code) {
case ButtonCode.KeyF1:
if (down)
@@ -1021,30 +1015,26 @@ public bool Key_Event(in InputEvent ev) {
}
}
-#if WIN32
- if (IsPC() && code == ButtonCode.KeyBackquote && (IsAltKeyDown() || IsCtrlKeyDown()))
+ if (IsWindows && code == ButtonCode.KeyBackquote && (IsAltKeyDown() || IsCtrlKeyDown()))
return true;
-#endif
if (down && code == ButtonCode.KeyEscape && !clientDLL.HandleUiToggle()) {
- if (IsPC()) {
- if (IsGameUIVisible()) {
- ReadOnlySpan levelName = engineClient.GetLevelName();
- if (!levelName.IsEmpty && levelName.Length > 0) {
- Cbuf.AddText("gameui_hide");
- if (IsDebugSystemVisible())
- Cbuf.AddText("debugsystemui 0");
- }
+ if (IsGameUIVisible()) {
+ ReadOnlySpan levelName = engineClient.GetLevelName();
+ if (!levelName.IsEmpty && levelName.Length > 0) {
+ Cbuf.AddText("gameui_hide");
+ if (IsDebugSystemVisible())
+ Cbuf.AddText("debugsystemui 0");
}
- else {
- Cbuf.AddText("gameui_activate");
- }
- return true;
}
+ else {
+ Cbuf.AddText("gameui_activate");
+ }
+ return true;
}
if (surface.HandleInputEvent(in ev)) {
- if (IsPC() && (code == ButtonCode.KeyBackquote))
+ if (code == ButtonCode.KeyBackquote)
return false;
return true;
}
diff --git a/Source.GUI.Controls/ComboBox.cs b/Source.GUI.Controls/ComboBox.cs
index 2455969c1..e2d3598fa 100644
--- a/Source.GUI.Controls/ComboBox.cs
+++ b/Source.GUI.Controls/ComboBox.cs
@@ -18,11 +18,10 @@ public override void ApplySchemeSettings(IScheme scheme) {
SetFont(scheme.GetFont("Marlett", IsProportional()));
SetContentAlignment(Alignment.West);
-#if OSX
- SetTextInset(-3, 0);
-#else
- SetTextInset(QuickPropScale(3), 0);
-#endif
+ if (IsOSX)
+ SetTextInset(-3, 0);
+ else
+ SetTextInset(QuickPropScale(3), 0);
SetDefaultBorder(scheme.GetBorder("ScrollBarButtonBorder"));
SetDefaultColor(GetSchemeColor("ComboBoxButton.ArrowColor", scheme), GetSchemeColor("ComboBoxButton.BgColor", scheme));
diff --git a/Source.GUI.Controls/HTML.cs b/Source.GUI.Controls/HTML.cs
index 2e73fac23..7284fd50a 100644
--- a/Source.GUI.Controls/HTML.cs
+++ b/Source.GUI.Controls/HTML.cs
@@ -572,7 +572,7 @@ public override void OnKeyCodeTyped(ButtonCode code) {
}
case ButtonCode.KeyF: {
if (Input.IsKeyDown(ButtonCode.KeyLControl) || Input.IsKeyDown(ButtonCode.KeyRControl)
- || (IsOSX() && (Input.IsKeyDown(ButtonCode.KeyLWin) || Input.IsKeyDown(ButtonCode.KeyRWin)))) {
+ || (IsOSX && (Input.IsKeyDown(ButtonCode.KeyLWin) || Input.IsKeyDown(ButtonCode.KeyRWin)))) {
if (!FindDialogVisible())
ShowFindDialog();
else
diff --git a/Source.GUI.Controls/TextEntry.cs b/Source.GUI.Controls/TextEntry.cs
index 228cf69e4..8242de999 100644
--- a/Source.GUI.Controls/TextEntry.cs
+++ b/Source.GUI.Controls/TextEntry.cs
@@ -732,7 +732,7 @@ public override void OnKeyCodeTyped(ButtonCode code) {
bool winkey = Input.IsKeyDown(ButtonCode.KeyLWin) || Input.IsKeyDown(ButtonCode.KeyRWin);
bool fallThrough = false;
- if ((ctrl || (winkey && IsOSX())) && !alt) {
+ if ((ctrl || (winkey && IsOSX)) && !alt) {
switch (code) {
case ButtonCode.KeyA:
SelectAllText(false);
diff --git a/Source.MaterialSystem/Material.cs b/Source.MaterialSystem/Material.cs
index dff33b0d4..e278725a7 100644
--- a/Source.MaterialSystem/Material.cs
+++ b/Source.MaterialSystem/Material.cs
@@ -1006,9 +1006,9 @@ private bool ShouldSkipVar(KeyValues var, out bool isConditional) {
else if (0 == stricmp(cond, "ldr"))
shouldSkip = materials.HardwareConfig.GetHDRType() != HDRType.None;
else if (0 == stricmp(cond, "360"))
- shouldSkip = !IsX360();
+ shouldSkip = true;
else if (0 == stricmp(cond, "gameconsole"))
- shouldSkip = !IsConsole();
+ shouldSkip = true;
else
Warning($"unrecognized conditional test {varName} in {GetName()}\n");
diff --git a/Source.MaterialSystem/MaterialSystem.cs b/Source.MaterialSystem/MaterialSystem.cs
index 1c2374e33..d19191d85 100644
--- a/Source.MaterialSystem/MaterialSystem.cs
+++ b/Source.MaterialSystem/MaterialSystem.cs
@@ -62,7 +62,7 @@ public class MaterialSystem : IMaterialSystemInternal, IShaderUtil
public readonly MaterialSystem_Config Config;
readonly static ConVar mat_vsync = new("mat_vsync", "0", 0, "Force sync to vertical retrace", 0, 1);
- readonly static ConVar mat_forcehardwaresync = new(IsPC() ? "1" : "0", 0);
+ readonly static ConVar mat_forcehardwaresync = new("1", 0);
readonly static ConVar mat_trilinear = new("1", 0);
readonly static ConVar mat_forceaniso = new("16", FCvar.Archive); // 0 = Bilinear, 1 = Trilinear, 2+ = Aniso
readonly static ConVar mat_filterlightmaps = new("1", 0);
@@ -705,14 +705,12 @@ public bool SetMode(IWindow window, MaterialSystem_Config config) {
TextureManager.FreeStandardRenderTargets();
TextureManager.AllocateStandardRenderTargets();
if (!previouslyUsingGraphics) {
- if (IsPC()) {
- TextureManager.RestoreRenderTargets();
- TextureManager.RestoreNonRenderTargetTextures();
- if (MaterialSystem.CanUseEditorMaterials())
- MathLib.Init(2.2f, 2.2f, 0.0f, (int)IMaterialSystem.OVERBRIGHT);
+ TextureManager.RestoreRenderTargets();
+ TextureManager.RestoreNonRenderTargetTextures();
+ if (MaterialSystem.CanUseEditorMaterials())
+ MathLib.Init(2.2f, 2.2f, 0.0f, (int)IMaterialSystem.OVERBRIGHT);
- AllocateStandardTextures();
- }
+ AllocateStandardTextures();
}
// Copy over that state which isn't stored currently in convars
@@ -900,12 +898,10 @@ private void AllocateStandardTextures() {
public void ReleaseStandardTextures() {
if (StandardTexturesAllocated) {
- if (IsPC()) {
- ShaderAPI.DeleteTexture(BlackTextureHandle);
- ShaderAPI.DeleteTexture(WhiteTextureHandle);
- ShaderAPI.DeleteTexture(GreyTextureHandle);
- ShaderAPI.DeleteTexture(GreyAlphaZeroTextureHandle);
- }
+ ShaderAPI.DeleteTexture(BlackTextureHandle);
+ ShaderAPI.DeleteTexture(WhiteTextureHandle);
+ ShaderAPI.DeleteTexture(GreyTextureHandle);
+ ShaderAPI.DeleteTexture(GreyAlphaZeroTextureHandle);
ShaderAPI.DeleteTexture(FullbrightLightmapTextureHandle);
ShaderAPI.DeleteTexture(FlatNormalTextureHandle);
ShaderAPI.DeleteTexture(FullbrightBumpedLightmapTextureHandle);
diff --git a/Source.SDLSystem/SDL3_System.Linux.cs b/Source.SDLSystem/SDL3_System.Linux.cs
new file mode 100644
index 000000000..4630d17dd
--- /dev/null
+++ b/Source.SDLSystem/SDL3_System.Linux.cs
@@ -0,0 +1,55 @@
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Source.SDLManager;
+
+public unsafe partial class SDL3_System
+{
+ const string FontConfig = "libfontconfig.so.1";
+ const int FcMatchPattern = 0;
+ const int FcResultMatch = 0;
+
+ [DllImport(FontConfig)] static extern nint FcNameParse(byte* name);
+ [DllImport(FontConfig)] static extern int FcConfigSubstitute(nint config, nint pattern, int kind);
+ [DllImport(FontConfig)] static extern void FcDefaultSubstitute(nint pattern);
+ [DllImport(FontConfig)] static extern nint FcFontMatch(nint config, nint pattern, out int result);
+ [DllImport(FontConfig)] static extern int FcPatternGetString(nint pattern, byte* obj, int n, out byte* value);
+ [DllImport(FontConfig)] static extern void FcPatternDestroy(nint pattern);
+
+ public ReadOnlySpan GetSystemFontPath(ReadOnlySpan fontName, int weight = 0, bool italic = false) {
+ try {
+ byte[] name = Encoding.UTF8.GetBytes(new string(fontName) + '\0');
+ nint pattern;
+ fixed (byte* pName = name)
+ pattern = FcNameParse(pName);
+ if (pattern == 0)
+ return null;
+
+ try {
+ FcConfigSubstitute(0, pattern, FcMatchPattern);
+ FcDefaultSubstitute(pattern);
+
+ nint match = FcFontMatch(0, pattern, out int result);
+ if (match == 0)
+ return null;
+
+ try {
+ fixed (byte* pFile = "file"u8)
+ if (result == FcResultMatch && FcPatternGetString(match, pFile, 0, out byte* file) == FcResultMatch && file != null)
+ return Marshal.PtrToStringUTF8((nint)file);
+ }
+ finally {
+ FcPatternDestroy(match);
+ }
+ }
+ finally {
+ FcPatternDestroy(pattern);
+ }
+ }
+ catch (Exception ex) {
+ Assert($"GetSystemFontPath: {ex.Message}");
+ }
+
+ return null;
+ }
+}
diff --git a/Source.SDLSystem/SDL3_System.OSX.cs b/Source.SDLSystem/SDL3_System.OSX.cs
new file mode 100644
index 000000000..284de7ff3
--- /dev/null
+++ b/Source.SDLSystem/SDL3_System.OSX.cs
@@ -0,0 +1,8 @@
+namespace Source.SDLManager;
+
+public unsafe partial class SDL3_System
+{
+ public ReadOnlySpan GetSystemFontPath(ReadOnlySpan fontName, int weight = 0, bool italic = false) {
+ return null;
+ }
+}
diff --git a/Source.SDLSystem/SDL3_System.Win32.cs b/Source.SDLSystem/SDL3_System.Win32.cs
new file mode 100644
index 000000000..3d384e386
--- /dev/null
+++ b/Source.SDLSystem/SDL3_System.Win32.cs
@@ -0,0 +1,74 @@
+using CommunityToolkit.HighPerformance;
+
+using Microsoft.Win32;
+
+namespace Source.SDLManager;
+
+public unsafe partial class SDL3_System
+{
+#pragma warning disable CA1416 // Validate platform compatibility (WIN32 ifdef catches this instead)
+ static string[] possibleKeys = [@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", @"SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts"];
+
+ struct Entry
+ {
+ public string Name;
+ public int Index;
+ public int Weight;
+ public bool Italic;
+ public string AbsPath;
+ }
+ List? Entries;
+
+ public ReadOnlySpan GetEntryPath(ReadOnlySpan name, int weight, bool italic) {
+ if (Entries == null) {
+ Entries = [];
+ string windowsDirectory = Environment.GetEnvironmentVariable("windir")!;
+ string fontsPath = Path.Combine(windowsDirectory, "Fonts");
+ foreach (var keyPath in possibleKeys) {
+ using var baseKey = Registry.LocalMachine.OpenSubKey(keyPath, false);
+ if (baseKey is null)
+ continue;
+
+ foreach (var valueName in baseKey.GetValueNames()) {
+ var value = baseKey.GetValue(valueName);
+
+ string absPath = Path.Combine(fontsPath, (string)value!);
+ int i = 0;
+ foreach (var fontfile in GetFontConditions(absPath)) {
+ Entries.Add(new() {
+ AbsPath = absPath,
+ Index = i++,
+ Italic = fontfile.Italic,
+ Weight = fontfile.Weight,
+ Name = fontfile.Name
+ });
+ }
+ }
+ }
+ }
+
+ Span entries = Entries.AsSpan();
+
+ string? consideration = null;
+ int closestDistance = int.MaxValue;
+
+ for (int i = 0; i < entries.Length; i++) {
+ ref Entry entry = ref entries[i];
+
+ if (entry.Italic == italic && name.Equals(entry.Name, StringComparison.OrdinalIgnoreCase)) {
+ int distance = Math.Abs(entry.Weight - weight);
+ if (distance < closestDistance) {
+ consideration = entry.AbsPath;
+ closestDistance = distance;
+ }
+ }
+ }
+
+ return consideration;
+ }
+
+ public ReadOnlySpan GetSystemFontPath(ReadOnlySpan fontName, int weight = 0, bool italic = false) {
+ return GetEntryPath(fontName, weight, italic);
+ }
+#pragma warning restore CA1416 // Validate platform compatibility
+}
diff --git a/Source.SDLSystem/SDL3_System.cs b/Source.SDLSystem/SDL3_System.cs
index 181217d2b..cf364d52b 100644
--- a/Source.SDLSystem/SDL3_System.cs
+++ b/Source.SDLSystem/SDL3_System.cs
@@ -7,13 +7,9 @@
using System.Text;
using CommunityToolkit.HighPerformance;
-#if WIN32
-using Microsoft.Win32;
-#endif
-
namespace Source.SDLManager;
-public unsafe class SDL3_System(ICommandLine commandLine) : ISystem
+public unsafe partial class SDL3_System(ICommandLine commandLine) : ISystem
{
public bool CommandLineParamExists(ReadOnlySpan paramName) {
return commandLine.FindParm(paramName) != 0;
@@ -158,124 +154,6 @@ public void ShellExecuteEx(ReadOnlySpan command, ReadOnlySpan file,
throw new NotImplementedException();
}
-#if WIN32
-#pragma warning disable CA1416 // Validate platform compatibility (WIN32 ifdef catches this instead)
- static string[] possibleKeys = [@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", @"SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts"];
-
- struct Entry
- {
- public string Name;
- public int Index;
- public int Weight;
- public bool Italic;
- public string AbsPath;
- }
- List? Entries;
-
- public ReadOnlySpan GetEntryPath(ReadOnlySpan name, int weight, bool italic) {
- if (Entries == null) {
- Entries = [];
- string windowsDirectory = Environment.GetEnvironmentVariable("windir")!;
- string fontsPath = Path.Combine(windowsDirectory, "Fonts");
- foreach (var keyPath in possibleKeys) {
- using var baseKey = Registry.LocalMachine.OpenSubKey(keyPath, false);
- if (baseKey is null)
- continue;
-
- foreach (var valueName in baseKey.GetValueNames()) {
- var value = baseKey.GetValue(valueName);
-
- string absPath = Path.Combine(fontsPath, (string)value!);
- int i = 0;
- foreach (var fontfile in GetFontConditions(absPath)) {
- Entries.Add(new() {
- AbsPath = absPath,
- Index = i++,
- Italic = fontfile.Italic,
- Weight = fontfile.Weight,
- Name = fontfile.Name
- });
- }
- }
- }
- }
-
- Span entries = Entries.AsSpan();
-
- string? consideration = null;
- int closestDistance = int.MaxValue;
-
- for (int i = 0; i < entries.Length; i++) {
- ref Entry entry = ref entries[i];
-
- if (entry.Italic == italic && name.Equals(entry.Name, StringComparison.OrdinalIgnoreCase)) {
- int distance = Math.Abs(entry.Weight - weight);
- if (distance < closestDistance) {
- consideration = entry.AbsPath;
- closestDistance = distance;
- }
- }
- }
-
- return consideration;
- }
-
- public ReadOnlySpan GetSystemFontPath(ReadOnlySpan fontName, int weight = 0, bool italic = false) {
- return GetEntryPath(fontName, weight, italic);
- }
-#pragma warning restore CA1416 // Validate platform compatibility
-#elif LINUX
- const string FontConfig = "libfontconfig.so.1";
- const int FcMatchPattern = 0;
- const int FcResultMatch = 0;
-
- [DllImport(FontConfig)] static extern nint FcNameParse(byte* name);
- [DllImport(FontConfig)] static extern int FcConfigSubstitute(nint config, nint pattern, int kind);
- [DllImport(FontConfig)] static extern void FcDefaultSubstitute(nint pattern);
- [DllImport(FontConfig)] static extern nint FcFontMatch(nint config, nint pattern, out int result);
- [DllImport(FontConfig)] static extern int FcPatternGetString(nint pattern, byte* obj, int n, out byte* value);
- [DllImport(FontConfig)] static extern void FcPatternDestroy(nint pattern);
-
- public ReadOnlySpan GetSystemFontPath(ReadOnlySpan fontName, int weight = 0, bool italic = false) {
- try {
- byte[] name = Encoding.UTF8.GetBytes(new string(fontName) + '\0');
- nint pattern;
- fixed (byte* pName = name)
- pattern = FcNameParse(pName);
- if (pattern == 0)
- return null;
-
- try {
- FcConfigSubstitute(0, pattern, FcMatchPattern);
- FcDefaultSubstitute(pattern);
-
- nint match = FcFontMatch(0, pattern, out int result);
- if (match == 0)
- return null;
-
- try {
- fixed (byte* pFile = "file"u8)
- if (result == FcResultMatch && FcPatternGetString(match, pFile, 0, out byte* file) == FcResultMatch && file != null)
- return Marshal.PtrToStringUTF8((nint)file);
- }
- finally {
- FcPatternDestroy(match);
- }
- }
- finally {
- FcPatternDestroy(pattern);
- }
- }
- catch (Exception ex) {
- Assert($"GetSystemFontPath: {ex.Message}");
- }
-
- return null;
- }
-#else
-#error Please implement System.GetSystemFontPath for this platform
-#endif
-
private static ushort SwapUInt16(ushort val) {
return (ushort)((val >> 8) | (val << 8));
}
diff --git a/Source.ShaderAPI.Gl46/MeshMgr.cs b/Source.ShaderAPI.Gl46/MeshMgr.cs
index d06781410..955b46bce 100644
--- a/Source.ShaderAPI.Gl46/MeshMgr.cs
+++ b/Source.ShaderAPI.Gl46/MeshMgr.cs
@@ -16,9 +16,7 @@ public class MeshMgr : IMeshMgr
internal IMaterialSystem MaterialSystem;
internal void Flush() {
- if (IsPC()) {
- BufferedMesh.Flush();
- }
+ BufferedMesh.Flush();
}
internal void DiscardVertexBuffers() {
diff --git a/Source.ShaderAPI.Gl46/ShaderAPIGl46.cs b/Source.ShaderAPI.Gl46/ShaderAPIGl46.cs
index 7d081558c..75c9ea8b0 100644
--- a/Source.ShaderAPI.Gl46/ShaderAPIGl46.cs
+++ b/Source.ShaderAPI.Gl46/ShaderAPIGl46.cs
@@ -346,10 +346,7 @@ public void SetLinearToGammaConversionTextures(ShaderAPITextureHandle_t srgbWrit
ShaderAPITextureHandle_t LinearToGammaTableIdentityTexture;
public float LinearToGamma_HardwareSpecific(float linear) {
- if (IsPC())
- return MathLib.SrgbLinearToGamma(linear);
- else
- throw new NotImplementedException();
+ return MathLib.SrgbLinearToGamma(linear);
}
public void SetDefaultState() {
@@ -1577,68 +1574,66 @@ private void ExportTextureList() {
DebugDataExportFrame = CurrentFrame;
- if (IsPC()) {
- if (DebugTextureList != null)
- DebugTextureList = null;
-
- DebugTextureList = new KeyValues("TextureList");
+ if (DebugTextureList != null)
+ DebugTextureList = null;
- TextureMemoryUsedTotal = 0;
- TextureMemoryUsedPicMip1 = 0;
- TextureMemoryUsedPicMip2 = 0;
- foreach (var texkvp in Textures) {
- var tex = texkvp.Value;
- TextureMemoryUsedTotal += tex.GetMemUsage();
+ DebugTextureList = new KeyValues("TextureList");
- // Compute picmip memory usage
- {
- nuint numBytes = tex.GetMemUsage();
+ TextureMemoryUsedTotal = 0;
+ TextureMemoryUsedPicMip1 = 0;
+ TextureMemoryUsedPicMip2 = 0;
+ foreach (var texkvp in Textures) {
+ var tex = texkvp.Value;
+ TextureMemoryUsedTotal += tex.GetMemUsage();
- if (tex.Levels > 1) {
- if (tex.GetWidth() > 4 || tex.GetHeight() > 4 || tex.GetDepth() > 4) {
- nuint topmipsize = (nuint)ImageLoader.GetMemRequired(tex.GetWidth(), tex.GetHeight(), tex.GetDepth(), tex.GetImageFormat(), false);
- numBytes -= topmipsize;
+ // Compute picmip memory usage
+ {
+ nuint numBytes = tex.GetMemUsage();
- TextureMemoryUsedPicMip1 += numBytes;
+ if (tex.Levels > 1) {
+ if (tex.GetWidth() > 4 || tex.GetHeight() > 4 || tex.GetDepth() > 4) {
+ nuint topmipsize = (nuint)ImageLoader.GetMemRequired(tex.GetWidth(), tex.GetHeight(), tex.GetDepth(), tex.GetImageFormat(), false);
+ numBytes -= topmipsize;
- if (tex.GetWidth() > 8 || tex.GetHeight() > 8 || tex.GetDepth() > 8) {
- nuint othermipsizeRatio = (nuint)(((tex.GetWidth() > 8) ? 2 : 1) * ((tex.GetHeight() > 8) ? 2 : 1) * ((tex.GetDepth() > 8) ? 2 : 1));
- nuint othermipsize = topmipsize / othermipsizeRatio;
- numBytes -= othermipsize;
- }
+ TextureMemoryUsedPicMip1 += numBytes;
- TextureMemoryUsedPicMip1 += numBytes;
- }
- else {
- TextureMemoryUsedPicMip1 += numBytes;
- TextureMemoryUsedPicMip2 += numBytes;
+ if (tex.GetWidth() > 8 || tex.GetHeight() > 8 || tex.GetDepth() > 8) {
+ nuint othermipsizeRatio = (nuint)(((tex.GetWidth() > 8) ? 2 : 1) * ((tex.GetHeight() > 8) ? 2 : 1) * ((tex.GetDepth() > 8) ? 2 : 1));
+ nuint othermipsize = topmipsize / othermipsizeRatio;
+ numBytes -= othermipsize;
}
+
+ TextureMemoryUsedPicMip1 += numBytes;
}
else {
TextureMemoryUsedPicMip1 += numBytes;
TextureMemoryUsedPicMip2 += numBytes;
}
}
+ else {
+ TextureMemoryUsedPicMip1 += numBytes;
+ TextureMemoryUsedPicMip2 += numBytes;
+ }
+ }
- if (!DebugGetAllTextures) // && tex.LastBoundFrame != CurrentFrame, todo SetTextureState
- continue;
-
- if (tex.LastBoundFrame != CurrentFrame)
- tex.TimesBoundThisFrame = 0;
-
- KeyValues pSubKey = DebugTextureList.CreateNewKey();
- pSubKey.SetString("Name", tex.DebugName.String());
- pSubKey.SetString("TexGroup", tex.TextureGroupName.String());
- pSubKey.SetInt("Size", (int)tex.GetMemUsage());
- if (tex.GetCount() > 1)
- pSubKey.SetInt("Count", tex.GetCount());
- pSubKey.SetString("Format", ImageLoader.GetName(tex.GetImageFormat()));
- pSubKey.SetInt("Width", tex.GetWidth());
- pSubKey.SetInt("Height", tex.GetHeight());
+ if (!DebugGetAllTextures) // && tex.LastBoundFrame != CurrentFrame, todo SetTextureState
+ continue;
- pSubKey.SetInt("BindsMax", tex.TimesBoundMax);
- pSubKey.SetInt("BindsFrame", tex.TimesBoundThisFrame);
- }
+ if (tex.LastBoundFrame != CurrentFrame)
+ tex.TimesBoundThisFrame = 0;
+
+ KeyValues pSubKey = DebugTextureList.CreateNewKey();
+ pSubKey.SetString("Name", tex.DebugName.String());
+ pSubKey.SetString("TexGroup", tex.TextureGroupName.String());
+ pSubKey.SetInt("Size", (int)tex.GetMemUsage());
+ if (tex.GetCount() > 1)
+ pSubKey.SetInt("Count", tex.GetCount());
+ pSubKey.SetString("Format", ImageLoader.GetName(tex.GetImageFormat()));
+ pSubKey.SetInt("Width", tex.GetWidth());
+ pSubKey.SetInt("Height", tex.GetHeight());
+
+ pSubKey.SetInt("BindsMax", tex.TimesBoundMax);
+ pSubKey.SetInt("BindsFrame", tex.TimesBoundThisFrame);
}
}
diff --git a/Source.StdShader.Gl46/VertexLitGenericHelper.cs b/Source.StdShader.Gl46/VertexLitGenericHelper.cs
index 55bda996f..726207594 100644
--- a/Source.StdShader.Gl46/VertexLitGenericHelper.cs
+++ b/Source.StdShader.Gl46/VertexLitGenericHelper.cs
@@ -234,9 +234,7 @@ private void DrawVertexLitGeneric_Internal(BaseVSShader shader, IMaterialVar[] p
// bool hasEnvmap = (!hasFlashlight) && (info.Envmap != -1) && parms[info.Envmap].IsTexture();
bool hasLegacyEnvSphereMap = hasEnvmap && IsFlagSet(parms, MaterialVarFlags.EnvMapSphere);
- bool hasNormal = vertexLitGeneric || hasEnvmap || hasFlashlight || seamlessBase || seamlessDetail;
- if (IsPC())
- hasNormal = true;
+ bool hasNormal = true;
bool halfLambert = IsFlagSet(parms, MaterialVarFlags.HalfLambert);
shaderShadow!.EnableAlphaTest(isAlphaTested);
@@ -280,7 +278,7 @@ private void DrawVertexLitGeneric_Internal(BaseVSShader shader, IMaterialVar[] p
else
shaderShadow.EnableSRGBRead(Sampler.Sampler0, true);
- if (IsOSX() && !HardwareConfig.CanDoSRGBReadFromRTs()) {
+ if (IsOSX && !HardwareConfig.CanDoSRGBReadFromRTs()) {
ITexture? baseTexture = parms[info.BaseTexture].GetTextureValue();
if (baseTexture != null && baseTexture.IsRenderTarget())
bSRGBInputAdapter = true;
@@ -898,7 +896,7 @@ private void DrawVertexLitGeneric_Internal(BaseVSShader shader, IMaterialVar[] p
dynamicCmdsOut.SetDepthFeatheringPixelShaderConstant(13, GetFloatParam(info.DepthBlendScale, parms, 50.0f));
float pixelFogType = shaderAPI.GetPixelFogCombo() == 1 ? 1.0f : 0.0f;
- float fWriteDepthToAlpha = writeDepthToAlpha && IsPC() ? 1.0f : 0.0f;
+ float fWriteDepthToAlpha = writeDepthToAlpha ? 1.0f : 0.0f;
float fWriteWaterFogToDestAlpha = (shaderAPI.GetPixelFogCombo() == 1 && writeWaterFogToAlpha) ? 1.0f : 0.0f;
float vertexAlpha = hasVertexAlpha ? 1.0f : 0.0f;
diff --git a/Usings/GlobalUsings.cs b/Usings/GlobalUsings.cs
index 6ef7cb3f5..ab0ae46c5 100644
--- a/Usings/GlobalUsings.cs
+++ b/Usings/GlobalUsings.cs
@@ -1,6 +1,6 @@
global using static Source.Dbg;
global using static Source.Common.CFormatting;
-global using static Source.PlatformMacros;
+global using static Source.Platform;
global using static Source.Common.MemUtils;
global using static Source.Common.ThreadUtils;
global using static Source.Common.Engine.EngineSoundGlobals;
diff --git a/usings_readme.txt b/usings_readme.txt
index 5da7c2df3..312773e08 100644
--- a/usings_readme.txt
+++ b/usings_readme.txt
@@ -1,6 +1,6 @@
These Usings files are to allow:
1. Defining typedefs among multiple projects
- 2. Static libraries being defined only once in a project (see Dbg, PlatformMacros, etc.)
+ 2. Static libraries being defined only once in a project (see Dbg, Platform, etc.)
- Keep all using Type = type; statements in these files, where possible
- Do NOT overpopulate GlobalUsings; every engine project will probably use this file!!!