From d815caf4cdcf940b301823cd3ad615a536aa9ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:17:03 +0300 Subject: [PATCH 01/17] Remove the IsPC platform macro and its checks --- Game.Client/ViewScene.cs | 10 +- Game.Server/BaseEntity.cs | 30 +++--- Game.Shared/AchievementMgr.cs | 2 +- Game.UI/GameUI.cs | 18 ++-- Source.Common/Formats/Keyvalues/KeyValues.cs | 2 +- Source.Common/Platform.cs | 1 - Source.Engine/ConSys.cs | 10 +- Source.Engine/DispInfo.cs | 2 +- Source.Engine/MatSysInterface.cs | 27 ++---- Source.Engine/SV.cs | 2 +- Source.Engine/VGuiBaseUIInterface.cs | 68 ++++++------- Source.MaterialSystem/MaterialSystem.cs | 24 ++--- Source.ShaderAPI.Gl46/MeshMgr.cs | 4 +- Source.ShaderAPI.Gl46/ShaderAPIGl46.cs | 97 +++++++++---------- .../VertexLitGenericHelper.cs | 6 +- 15 files changed, 131 insertions(+), 172 deletions(-) diff --git a/Game.Client/ViewScene.cs b/Game.Client/ViewScene.cs index 02d3ddb0e..c56ef032e 100644 --- a/Game.Client/ViewScene.cs +++ b/Game.Client/ViewScene.cs @@ -31,13 +31,11 @@ public static void UpdateRefractTexture(int x, int y, int w, int h, bool forceUp 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.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.UI/GameUI.cs b/Game.UI/GameUI.cs index bf3470c8d..01afa9cbc 100644 --- a/Game.UI/GameUI.cs +++ b/Game.UI/GameUI.cs @@ -186,20 +186,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/Source.Common/Formats/Keyvalues/KeyValues.cs b/Source.Common/Formats/Keyvalues/KeyValues.cs index 1ff497ba2..9522d8533 100644 --- a/Source.Common/Formats/Keyvalues/KeyValues.cs +++ b/Source.Common/Formats/Keyvalues/KeyValues.cs @@ -271,7 +271,7 @@ 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 diff --git a/Source.Common/Platform.cs b/Source.Common/Platform.cs index 86ff29302..ec07b7e5e 100644 --- a/Source.Common/Platform.cs +++ b/Source.Common/Platform.cs @@ -8,7 +8,6 @@ namespace Source; public static class PlatformMacros { - [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; 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..cec5531df 100644 --- a/Source.Engine/MatSysInterface.cs +++ b/Source.Engine/MatSysInterface.cs @@ -414,14 +414,10 @@ private void InitDebugMaterials() { } 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 +446,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 +463,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/VGuiBaseUIInterface.cs b/Source.Engine/VGuiBaseUIInterface.cs index 52832fb4b..94a0e8e0b 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) @@ -1022,29 +1016,27 @@ public bool Key_Event(in InputEvent ev) { } #if WIN32 - if (IsPC() && code == ButtonCode.KeyBackquote && (IsAltKeyDown() || IsCtrlKeyDown())) + if (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.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.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..eaa4c77c1 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); @@ -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; From 9fd613e9737d5b62383cc598b34f614efe471100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:22:21 +0300 Subject: [PATCH 02/17] Remove the IsConsole platform macro and its checks --- Game.Client/HL2/HudCredits.cs | 2 +- Game.Server/World.cs | 4 ++-- Source.Common/Platform.cs | 1 - Source.MaterialSystem/Material.cs | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) 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.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/Source.Common/Platform.cs b/Source.Common/Platform.cs index ec07b7e5e..a7c125012 100644 --- a/Source.Common/Platform.cs +++ b/Source.Common/Platform.cs @@ -8,7 +8,6 @@ namespace Source; public static class PlatformMacros { - [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() diff --git a/Source.MaterialSystem/Material.cs b/Source.MaterialSystem/Material.cs index dff33b0d4..78d9d86bb 100644 --- a/Source.MaterialSystem/Material.cs +++ b/Source.MaterialSystem/Material.cs @@ -1008,7 +1008,7 @@ private bool ShouldSkipVar(KeyValues var, out bool isConditional) { else if (0 == stricmp(cond, "360")) shouldSkip = !IsX360(); else if (0 == stricmp(cond, "gameconsole")) - shouldSkip = !IsConsole(); + shouldSkip = true; else Warning($"unrecognized conditional test {varName} in {GetName()}\n"); From b08c681ecc5d09f9df2d6fb79edf254d1ec0210d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:23:54 +0300 Subject: [PATCH 03/17] Remove the IsX360 platform macro and its paths --- Game.Client/RenderTexture.cs | 8 -------- Game.Shared/HL2/HL_GameMovement.cs | 2 +- Source.Common/Platform.cs | 1 - Source.Engine/MatSysInterface.cs | 16 +--------------- Source.Engine/Server/GameServer.cs | 2 +- Source.MaterialSystem/Material.cs | 2 +- 6 files changed, 4 insertions(+), 27 deletions(-) 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.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/Source.Common/Platform.cs b/Source.Common/Platform.cs index a7c125012..c98661ef7 100644 --- a/Source.Common/Platform.cs +++ b/Source.Common/Platform.cs @@ -8,7 +8,6 @@ namespace Source; public static class PlatformMacros { - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsX360() => false; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsRetail() => false; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSX() #if OSX diff --git a/Source.Engine/MatSysInterface.cs b/Source.Engine/MatSysInterface.cs index cec5531df..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,14 +394,7 @@ 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; } diff --git a/Source.Engine/Server/GameServer.cs b/Source.Engine/Server/GameServer.cs index 188f7d2cd..2fbd45c6c 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) diff --git a/Source.MaterialSystem/Material.cs b/Source.MaterialSystem/Material.cs index 78d9d86bb..e278725a7 100644 --- a/Source.MaterialSystem/Material.cs +++ b/Source.MaterialSystem/Material.cs @@ -1006,7 +1006,7 @@ 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 = true; else From 137f931d8f34c3740dda38e3f2c2a1dd3fbae0c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:24:55 +0300 Subject: [PATCH 04/17] Remove the IsRetail platform macro and its check --- Game.Client/ViewScene.cs | 2 +- Source.Common/Platform.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Game.Client/ViewScene.cs b/Game.Client/ViewScene.cs index c56ef032e..c67c8ed46 100644 --- a/Game.Client/ViewScene.cs +++ b/Game.Client/ViewScene.cs @@ -26,7 +26,7 @@ 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); diff --git a/Source.Common/Platform.cs b/Source.Common/Platform.cs index c98661ef7..6d43865ec 100644 --- a/Source.Common/Platform.cs +++ b/Source.Common/Platform.cs @@ -8,7 +8,6 @@ namespace Source; public static class PlatformMacros { - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsRetail() => false; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSX() #if OSX => true; From a5c1572527c22c05fe06603c8ce5eedb3b074b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:26:43 +0300 Subject: [PATCH 05/17] Make IsOSX a const --- Source.Common/Platform.cs | 6 +++--- Source.GUI.Controls/HTML.cs | 2 +- Source.GUI.Controls/TextEntry.cs | 2 +- Source.StdShader.Gl46/VertexLitGenericHelper.cs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source.Common/Platform.cs b/Source.Common/Platform.cs index 6d43865ec..a6bbd1d79 100644 --- a/Source.Common/Platform.cs +++ b/Source.Common/Platform.cs @@ -8,11 +8,11 @@ namespace Source; public static class PlatformMacros { - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsOSX() + public const bool IsOSX #if OSX - => true; + = true; #else - => false; + = false; #endif [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsPlatform64Bits() => IntPtr.Size == 8; 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.StdShader.Gl46/VertexLitGenericHelper.cs b/Source.StdShader.Gl46/VertexLitGenericHelper.cs index eaa4c77c1..726207594 100644 --- a/Source.StdShader.Gl46/VertexLitGenericHelper.cs +++ b/Source.StdShader.Gl46/VertexLitGenericHelper.cs @@ -278,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; From fa52ceb9e389d3623f11bc6adc22ce1ac7c5dbde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:27:39 +0300 Subject: [PATCH 06/17] Remove the unused IsPlatform64Bits platform macro --- Source.Common/Platform.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Source.Common/Platform.cs b/Source.Common/Platform.cs index a6bbd1d79..23c5c67d6 100644 --- a/Source.Common/Platform.cs +++ b/Source.Common/Platform.cs @@ -14,7 +14,6 @@ public const bool IsOSX #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; From 3819fbc06b7d6c764ce1aff13d1dee303ba39505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:29:57 +0300 Subject: [PATCH 07/17] Merge PlatformMacros into Platform --- Source.Common/Platform.cs | 10 +++------- Usings/GlobalUsings.cs | 2 +- usings_readme.txt | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Source.Common/Platform.cs b/Source.Common/Platform.cs index 23c5c67d6..aaf48870f 100644 --- a/Source.Common/Platform.cs +++ b/Source.Common/Platform.cs @@ -1,12 +1,13 @@ 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 { public const bool IsOSX #if OSX @@ -17,12 +18,7 @@ public const bool IsOSX 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/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!!! From f6166fde9a44eddcc51528cf6c63cd8765627f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:33:29 +0300 Subject: [PATCH 08/17] Add IsWindows and IsPosix platform constants --- Source.Common/Platform.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source.Common/Platform.cs b/Source.Common/Platform.cs index aaf48870f..dcf149b8a 100644 --- a/Source.Common/Platform.cs +++ b/Source.Common/Platform.cs @@ -9,6 +9,13 @@ namespace Source; public static class Platform { + public const bool IsWindows +#if WIN32 + = true; +#else + = false; +#endif + public const bool IsOSX #if OSX = true; @@ -16,6 +23,13 @@ public const bool IsOSX = false; #endif + public const bool IsPosix +#if POSIX + = true; +#else + = false; +#endif + public const int MAX_PATH = 260; public const int MAX_OSPATH = 260; From 7f970343244a47975ccb26d6f14c2505097d134c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:34:19 +0300 Subject: [PATCH 09/17] Define POSIX for OSX and Linux builds --- Directory.Build.props | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Directory.Build.props b/Directory.Build.props index 8082adb95..1ce1c60f3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -40,6 +40,10 @@ $(DefineConstants);LINUX + + $(DefineConstants);POSIX + + $(DefineConstants);SWDS;DEDICATED From e7e59745452cff803d2e10d18039aabade321fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:43:27 +0300 Subject: [PATCH 10/17] Use platform constants instead of #if blocks where possible --- Game.UI/OptionsDialog.cs | 12 ++++++------ Game.UI/OptionsSubAudio.cs | 19 ++++++++----------- Source.Common/Formats/Keyvalues/KeyValues.cs | 18 +++--------------- Source.Engine/VGuiBaseUIInterface.cs | 4 +--- Source.GUI.Controls/ComboBox.cs | 9 ++++----- 5 files changed, 22 insertions(+), 40 deletions(-) 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 9522d8533..a964f2211 100644 --- a/Source.Common/Formats/Keyvalues/KeyValues.cs +++ b/Source.Common/Formats/Keyvalues/KeyValues.cs @@ -274,17 +274,9 @@ public static bool EvaluateConditional(Span str) { 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.Engine/VGuiBaseUIInterface.cs b/Source.Engine/VGuiBaseUIInterface.cs index 94a0e8e0b..14fcc3115 100644 --- a/Source.Engine/VGuiBaseUIInterface.cs +++ b/Source.Engine/VGuiBaseUIInterface.cs @@ -1015,10 +1015,8 @@ public bool Key_Event(in InputEvent ev) { } } -#if WIN32 - if (code == ButtonCode.KeyBackquote && (IsAltKeyDown() || IsCtrlKeyDown())) + if (IsWindows && code == ButtonCode.KeyBackquote && (IsAltKeyDown() || IsCtrlKeyDown())) return true; -#endif if (down && code == ButtonCode.KeyEscape && !clientDLL.HandleUiToggle()) { if (IsGameUIVisible()) { 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)); From fbd0e265d5181cde924ac39154144b89b846bcbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:43:28 +0300 Subject: [PATCH 11/17] Simplify FindPlatformDirectory --- Game.UI/GameUI.cs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Game.UI/GameUI.cs b/Game.UI/GameUI.cs index 01afa9cbc..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() { From 5baad5e6e4107e4ed645cfb775a55025c1f74858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:47:01 +0300 Subject: [PATCH 12/17] Fix the OSX os string call in the server info event --- Source.Engine/Server/GameServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source.Engine/Server/GameServer.cs b/Source.Engine/Server/GameServer.cs index 2fbd45c6c..05442e423 100644 --- a/Source.Engine/Server/GameServer.cs +++ b/Source.Engine/Server/GameServer.cs @@ -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 From 8a1b8ffac68cc805f37345984f04ad1c1079bc7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:47:01 +0300 Subject: [PATCH 13/17] Add a macOS job to the build workflow --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b22a8e315..019236c06 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-latest] configuration: [Debug, Release] include: - os: ubuntu-latest From d1304623563b328fd0ea733ec0dc234e99888ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 03:59:58 +0300 Subject: [PATCH 14/17] Target the host architecture and build generators as AnyCPU --- Dependencies/Steamworks/Steamworks.csproj | 1 - Directory.Build.props | 11 +++++++++-- Game.Assets/Game.Assets.csproj | 1 - 3 files changed, 9 insertions(+), 4 deletions(-) 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 1ce1c60f3..4ec807c32 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -49,8 +49,15 @@ - x64 - x64 + $([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) + x64;arm64 + x64 + arm64 + x64 + + + + AnyCPU 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) From 9badede40f8c8b00e2849351188b8f6132ec33a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 04:00:48 +0300 Subject: [PATCH 15/17] Split the macOS CI job into Intel and Apple Silicon --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 019236c06..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, macos-latest] + os: [windows-latest, ubuntu-latest, macos-15-intel, macos-latest] configuration: [Debug, Release] include: - os: ubuntu-latest From 12ad707dc8d88a8d89a89bd653161c667a7591da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 04:22:10 +0300 Subject: [PATCH 16/17] Compile *.Win32, *.OSX and *.Linux files only on their platform --- Directory.Build.targets | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 @@ + + + + + + + + + + + + + + + From 78ea7bd5e0ba6e8c96fc382f377155a9945a45b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Tue, 20 Oct 2026 04:22:11 +0300 Subject: [PATCH 17/17] Split SDL3_System font lookup into per-platform files --- Source.SDLSystem/SDL3_System.Linux.cs | 55 ++++++++++++ Source.SDLSystem/SDL3_System.OSX.cs | 8 ++ Source.SDLSystem/SDL3_System.Win32.cs | 74 +++++++++++++++ Source.SDLSystem/SDL3_System.cs | 124 +------------------------- 4 files changed, 138 insertions(+), 123 deletions(-) create mode 100644 Source.SDLSystem/SDL3_System.Linux.cs create mode 100644 Source.SDLSystem/SDL3_System.OSX.cs create mode 100644 Source.SDLSystem/SDL3_System.Win32.cs 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)); }