/// <summary> /// Initializes a new instance of the <see cref="LogMessage" /> class. /// </summary> /// <param name="module">The module.</param> /// <param name="type">The type.</param> /// <param name="text">The text.</param> /// <param name="exception">The exception.</param> /// <param name="callerInfo">The caller info.</param> public LogMessage(string module, LogMessageType type, string text, Exception exception, CallerInfo callerInfo) { if (exception != null) { // if file logging is enabled, write it here ErrorFileLogger.WriteExceptionToFile(exception, type.ToString() + ", " + text + ", " + module + ", File: " + (callerInfo?.FilePath ?? "none") + ", Line: " + (callerInfo?.LineNumber.ToString() ?? "none")); } Module = module; Type = type; Text = text; Exception = exception; CallerInfo = callerInfo; }
private static bool DebugReport(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, ulong @object, nuint location, int messageCode, string layerPrefix, string message, IntPtr userData) { string debugMessage = $"{flags}, {@object}, {location}: {message} ([{messageCode}] {layerPrefix})"; switch (GraphicsAdapterFactory.adapterFlags) { default: Debug.WriteLine(debugMessage); return(false); case DeviceCreationFlags.DebugAndBreak: Debug.WriteLine(debugMessage); Debugger.Break(); return(false); case DeviceCreationFlags.DebugAndBreakUnique: int start = message.IndexOf("[ "); int end = message.IndexOf(" ]"); string key = message.Substring(start, end - start); if (ErrorsAlready.TryGetValue(key, out _) == false) { ErrorsAlready[key] = true; Debug.WriteLine(debugMessage); Debugger.Break(); } return(false); case DeviceCreationFlags.DebugAndLogUnique: start = message.IndexOf("[ "); end = message.IndexOf(" ]"); key = message.Substring(start, end - start); if (ErrorsAlready.TryGetValue(key, out _) == false) { ErrorsAlready[key] = true; debugMessage += "\n\nStack Trace: " + (new StackTrace()).ToString(); ErrorFileLogger.WriteLogToFile(debugMessage); } return(false); } }
/// <inheritdoc/> protected override void PrepareContext(float overridefov = -1f) { base.PrepareContext(overridefov); // Init assets if (Context.InitializeDatabase) { databaseFileProvider = InitializeAssetDatabase(); ((DatabaseFileProviderService)Services.GetService <IDatabaseFileProviderService>()).FileProvider = databaseFileProvider; var renderingSettings = new RenderingSettings(); if (Content.Exists(GameSettings.AssetUrl)) { Settings = Content.Load <GameSettings>(GameSettings.AssetUrl); renderingSettings = Settings.Configurations.Get <RenderingSettings>(); // Set ShaderProfile even if AutoLoadDefaultSettings is false (because that is what shaders in effect logs are compiled against, even if actual instantiated profile is different) if (renderingSettings.DefaultGraphicsProfile > 0) { var deviceManager = (GraphicsDeviceManager)graphicsDeviceManager; if (!deviceManager.ShaderProfile.HasValue) { deviceManager.ShaderProfile = renderingSettings.DefaultGraphicsProfile; } } Services.AddService <IGameSettingsService>(this); } // Load several default settings if (AutoLoadDefaultSettings) { var deviceManager = (GraphicsDeviceManager)graphicsDeviceManager; if (renderingSettings.DefaultGraphicsProfile > 0) { deviceManager.PreferredGraphicsProfile = new[] { renderingSettings.DefaultGraphicsProfile }; } deviceManager.PreferredColorSpace = renderingSettings.ColorSpace; renderingSettings.DefaultBackBufferWidth = deviceManager.preferredBackBufferWidth; renderingSettings.DefaultBackBufferHeight = deviceManager.PreferredBackBufferHeight; SceneSystem.InitialSceneUrl = Settings?.DefaultSceneUrl; SceneSystem.OverrideFOV = overridefov; SceneSystem.InitialGraphicsCompositorUrl = Settings?.DefaultGraphicsCompositorUrl; SceneSystem.SplashScreenUrl = Settings?.SplashScreenUrl; SceneSystem.SplashScreenColor = Settings?.SplashScreenColor ?? Color4.Black; SceneSystem.DoubleViewSplashScreen = Settings?.DoubleViewSplashScreen ?? false; } // apply rendersettings Xenko.Graphics.Buffer.CaptureIndexBuffersOfSize = renderingSettings.CaptureIndexBufferOfSize; Xenko.Graphics.Buffer.CaptureVertexBuffersOfSize = renderingSettings.CaptureVertexBufferOfSize; Xenko.Graphics.Buffer.UploadBufferSizeInMB = renderingSettings.UploadBufferSizeInMB; Xenko.Graphics.Buffer.SmallPooledBufferSize = (ulong)renderingSettings.SmallPooledBufferSize; Xenko.Graphics.Buffer.SmallPooledBufferCount = (ulong)renderingSettings.SmallPooledBufferCount; Xenko.Graphics.Buffer.LargePooledBufferSize = (ulong)renderingSettings.LargePooledBufferSize; Xenko.Graphics.Buffer.LargePooledBufferCount = (ulong)renderingSettings.LargedPooledBufferCount; VisibilityGroup.CullSmallFactor = renderingSettings.SmallCullFactor; VisibilityGroup.CullShadowsSmallFactor = renderingSettings.SmallShadowCullFactor; ModelComponent.DefaultShadowCasters = renderingSettings.DefaultShadowCasters; // enable error file logging? if (renderingSettings.DisableErrorFileLog == false) { ErrorFileLogger.EnableGlobalExceptionLogger(); } else { // should already be disabled, but we'll make sure ErrorFileLogger.Disable(); } } }
internal static unsafe void Initialize(OpenXRHmd hmd) { baseHMD = hmd; // make actions for (int i = 0; i < HAND_PATH_COUNT; i++) { for (int j = 0; j < 2; j++) { ActionCreateInfo action_info = new ActionCreateInfo() { Type = StructureType.TypeActionCreateInfo, ActionType = GetActionType((HAND_PATHS)i), }; Span <byte> aname = new Span <byte>(action_info.ActionName, 32); Span <byte> lname = new Span <byte>(action_info.LocalizedActionName, 32); string fullname = ((HAND_PATHS)i).ToString() + "H" + j.ToString() + '\0'; SilkMarshal.StringIntoSpan(fullname.ToLower(), aname); SilkMarshal.StringIntoSpan(fullname, lname); fixed(Silk.NET.OpenXR.Action *aptr = &MappedActions[j, i]) hmd.Xr.CreateAction(hmd.globalActionSet, &action_info, aptr); } } string allInputDetected = ""; // probe bindings for all profiles for (int i = 0; i < InteractionProfiles.Length; i++) { ulong profile = 0; hmd.Xr.StringToPath(hmd.Instance, InteractionProfiles[i], ref profile); List <ActionSuggestedBinding> bindings = new List <ActionSuggestedBinding>(); // for each hand... for (int hand = 0; hand < 2; hand++) { // for each path we want to bind... for (int path = 0; path < HAND_PATH_COUNT; path++) { // list all possible paths that might be valid and pick the first one List <string> possiblePaths = PathPriorities[path]; for (int pathattempt = 0; pathattempt < possiblePaths.Count; pathattempt++) { // get the hand at the start, then put in the attempt string final_path = hand == (int)TouchControllerHand.Left ? "/user/hand/left" : "/user/hand/right"; final_path += possiblePaths[pathattempt]; ulong hp_ulong = 0; hmd.Xr.StringToPath(hmd.Instance, final_path, ref hp_ulong); var suggest = new ActionSuggestedBinding() { Action = MappedActions[hand, path], Binding = hp_ulong }; if (IsPathSupported(hmd, profile, &suggest)) { // note that this controller has a touchpad/thumbstick switch ((HAND_PATHS)path) { case HAND_PATHS.ThumbstickX: HasThumbsticks.Add(profile); break; case HAND_PATHS.TrackpadX: HasTouchpads.Add(profile); break; } if (LogInputDetected) { allInputDetected += "\nGot " + final_path + " for " + InteractionProfiles[i]; } // got one! bindings.Add(suggest); break; } } } } // ok, we got all supported paths for this profile, lets do the final suggestion with all of them if (bindings.Count > 0) { ActionSuggestedBinding[] final_bindings = bindings.ToArray(); fixed(ActionSuggestedBinding *asbptr = &final_bindings[0]) { InteractionProfileSuggestedBinding suggested_bindings = new InteractionProfileSuggestedBinding() { Type = StructureType.TypeInteractionProfileSuggestedBinding, InteractionProfile = profile, CountSuggestedBindings = (uint)final_bindings.Length, SuggestedBindings = asbptr }; OpenXRHmd.CheckResult(hmd.Xr.SuggestInteractionProfileBinding(hmd.Instance, &suggested_bindings), "SuggestInteractionProfileBinding"); } } } if (LogInputDetected) { ErrorFileLogger.WriteLogToFile(allInputDetected); } }