public SkyboxGeneratorContext(SkyboxAsset skybox, IDatabaseFileProviderService fileProviderService) { Skybox = skybox ?? throw new ArgumentNullException(nameof(skybox)); Services = new ServiceRegistry(); Services.AddService(fileProviderService); Content = new ContentManager(Services); Services.AddService <IContentManager>(Content); Services.AddService(Content); GraphicsDevice = GraphicsDevice.New(); GraphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice); Services.AddService(GraphicsDeviceService); var graphicsContext = new GraphicsContext(GraphicsDevice); Services.AddService(graphicsContext); EffectSystem = new EffectSystem(Services); EffectSystem.Compiler = EffectCompilerFactory.CreateEffectCompiler(Content.FileProvider, EffectSystem); Services.AddService(EffectSystem); EffectSystem.Initialize(); ((IContentable)EffectSystem).LoadContent(); ((EffectCompilerCache)EffectSystem.Compiler).CompileEffectAsynchronously = false; RenderContext = RenderContext.GetShared(Services); RenderDrawContext = new RenderDrawContext(Services, RenderContext, graphicsContext); }
public GameStudioBuilderService(SessionViewModel sessionViewModel, GameSettingsProviderService settingsProvider, string buildDirectory, bool createDebugTools = true) : base(buildDirectory) { this.createDebugTools = createDebugTools; if (createDebugTools) { assetBuilderServiceDebugPage = EditorDebugTools.CreateLogDebugPage(GlobalLogger.GetLogger("AssetBuilderService"), "AssetBuilderService"); effectCompilerServiceDebugPage = EditorDebugTools.CreateLogDebugPage(GlobalLogger.GetLogger("EffectCompilerCache"), "EffectCompilerCache"); } SessionViewModel = sessionViewModel ?? throw new ArgumentNullException(nameof(sessionViewModel)); var shaderImporter = new StrideShaderImporter(); var shaderBuildSteps = shaderImporter.CreateSystemShaderBuildSteps(sessionViewModel); shaderBuildSteps.StepProcessed += ShaderBuildStepsStepProcessed; PushBuildUnit(new PrecompiledAssetBuildUnit(AssetBuildUnitIdentifier.Default, shaderBuildSteps, true)); Database = new GameStudioDatabase(this, settingsProvider); const string shaderBundleUrl = "/binary/editor/EditorShadersD3D11.bundle"; if (VirtualFileSystem.FileExists(shaderBundleUrl)) { Builder.ObjectDatabase.BundleBackend.LoadBundleFromUrl("EditorShadersD3D11", Builder.ObjectDatabase.ContentIndexMap, shaderBundleUrl, true).Wait(); } // Use a shared database for our shader system // TODO: Shaders compiled on main thread won't actually be visible to MicroThread build engine (contentIndexMap are separate). // It will still work and cache because EffectCompilerCache caches not only at the index map level, but also at the database level. // Later, we probably want to have a GetSharedDatabase() allowing us to mutate it (or merging our results back with IndexFileCommand.AddToSharedGroup()), // so that database created with MountDatabase also have all the newest shaders. taskScheduler = new EffectPriorityScheduler(ThreadPriority.BelowNormal, Math.Max(1, Environment.ProcessorCount / 2)); TaskSchedulerSelector taskSchedulerSelector = (mixinTree, compilerParameters) => taskScheduler.GetOrCreatePriorityGroup(compilerParameters?.TaskPriority ?? 0); effectCompiler = (EffectCompilerBase)EffectCompilerFactory.CreateEffectCompiler(MicrothreadLocalDatabases.GetSharedDatabase(), taskSchedulerSelector: taskSchedulerSelector); StartPushNotificationsTask(); }
protected override void Initialize() { // --------------------------------------------------------- // Add common GameSystems - Adding order is important // (Unless overriden by gameSystem.UpdateOrder) // --------------------------------------------------------- // Add the input manager // Add it first so that it can obtained by the UI system Input = new InputManager(Services); Services.AddService(Input); GameSystems.Add(Input); // Initialize the systems base.Initialize(); Content.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector; // Add the scheduler system // - Must be after Input, so that scripts are able to get latest input // - Must be before Entities/Camera/Audio/UI, so that scripts can apply // changes in the same frame they will be applied GameSystems.Add(Script); // Add the Font system GameSystems.Add(gameFontSystem); //Add the sprite animation System GameSystems.Add(SpriteAnimation); GameSystems.Add(DebugRenderSystem); GameSystems.Add(DebugTextSystem); GameSystems.Add(ProfilingSystem); EffectSystem = new EffectSystem(Services); Services.AddService(EffectSystem); // prepare effect compilation settings if we have a settings object if (Settings != null) { // align settings with what we may be forcing if (ForceReleaseEffects) { Settings.CompilationMode = CompilationMode.Release; } if (ForceCollectEffects) { // we want to collect effects. make sure they are release versions Settings.EffectCompilation = EffectCompilationMode.Local; Settings.CompilationMode = CompilationMode.Release; } else if (Settings.CompilationMode == CompilationMode.Testing || Settings.CompilationMode == CompilationMode.Debug) { // don't collect debug shaders, we won't want to distribute them! Settings.EffectCompilation = EffectCompilationMode.Local; } } // If requested in game settings, compile effects remotely and/or notify new shader requests EffectSystem.Compiler = EffectCompilerFactory.CreateEffectCompiler(Content.FileProvider, EffectSystem, Settings?.PackageName, ForceCollectEffects ? EffectCompilationMode.Local : (Settings?.EffectCompilation ?? EffectCompilationMode.Local)); // Setup shader compiler settings from a compilation mode. EffectSystem.SetCompilationMode(ForceReleaseEffects || ForceCollectEffects ? CompilationMode.Release : (Settings?.CompilationMode ?? CompilationMode.Release)); GameSystems.Add(EffectSystem); if (Settings != null) { Streaming.SetStreamingSettings(Settings.Configurations.Get <StreamingSettings>()); } GameSystems.Add(Streaming); GameSystems.Add(SceneSystem); // Add the Audio System GameSystems.Add(Audio); // Add the VR System GameSystems.Add(VRDeviceSystem); // TODO: data-driven? Content.Serializer.RegisterSerializer(new ImageSerializer()); OnGameStarted(this); }
public ThumbnailGenerator(EffectCompilerBase effectCompiler) { // create base services Services = new ServiceRegistry(); Services.AddService(MicrothreadLocalDatabases.ProviderService); ContentManager = new ContentManager(Services); Services.AddService <IContentManager>(ContentManager); Services.AddService(ContentManager); GraphicsDevice = GraphicsDevice.New(); GraphicsContext = new GraphicsContext(GraphicsDevice); GraphicsCommandList = GraphicsContext.CommandList; Services.AddService(GraphicsContext); sceneSystem = new SceneSystem(Services); Services.AddService(sceneSystem); fontSystem = new GameFontSystem(Services); Services.AddService(fontSystem.FontSystem); Services.AddService <IFontFactory>(fontSystem.FontSystem); GraphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice); Services.AddService(GraphicsDeviceService); var uiSystem = new UISystem(Services); Services.AddService(uiSystem); var physicsSystem = new Bullet2PhysicsSystem(Services); Services.AddService <IPhysicsSystem>(physicsSystem); gameSystems = new GameSystemCollection(Services) { fontSystem, uiSystem, physicsSystem }; Services.AddService <IGameSystemCollection>(gameSystems); Simulation.DisableSimulation = true; //make sure we do not simulate physics within the editor // initialize base services gameSystems.Initialize(); // create remaining services EffectSystem = new EffectSystem(Services); Services.AddService(EffectSystem); gameSystems.Add(EffectSystem); gameSystems.Add(sceneSystem); EffectSystem.Initialize(); // Mount the same database for the cache EffectSystem.Compiler = EffectCompilerFactory.CreateEffectCompiler(effectCompiler.FileProvider, EffectSystem); // Deactivate the asynchronous effect compilation ((EffectCompilerCache)EffectSystem.Compiler).CompileEffectAsynchronously = false; // load game system content gameSystems.LoadContent(); // create the default fonts var fontItem = OfflineRasterizedSpriteFontFactory.Create(); fontItem.FontType.Size = 22; DefaultFont = OfflineRasterizedFontCompiler.Compile(fontSystem.FontSystem, fontItem, true); // create utility members nullGameTime = new GameTime(); SpriteBatch = new SpriteBatch(GraphicsDevice); UIBatch = new UIBatch(GraphicsDevice); // create the pipeline SetUpPipeline(); }
protected override void Initialize() { // --------------------------------------------------------- // Add common GameSystems - Adding order is important // (Unless overriden by gameSystem.UpdateOrder) // --------------------------------------------------------- // Add the input manager // Add it first so that it can obtained by the UI system Input = new InputManager(Services); Services.AddService(Input); GameSystems.Add(Input); // Initialize the systems base.Initialize(); Content.Serializer.LowLevelSerializerSelector = ParameterContainerExtensions.DefaultSceneSerializerSelector; // Add the scheduler system // - Must be after Input, so that scripts are able to get latest input // - Must be before Entities/Camera/Audio/UI, so that scripts can apply // changes in the same frame they will be applied GameSystems.Add(Script); // Add the Font system GameSystems.Add(gameFontSystem); //Add the sprite animation System GameSystems.Add(SpriteAnimation); GameSystems.Add(DebugTextSystem); GameSystems.Add(ProfilingSystem); EffectSystem = new EffectSystem(Services); Services.AddService(EffectSystem); // If requested in game settings, compile effects remotely and/or notify new shader requests EffectSystem.Compiler = EffectCompilerFactory.CreateEffectCompiler(Content.FileProvider, EffectSystem, Settings?.PackageName, Settings?.EffectCompilation ?? EffectCompilationMode.Local, Settings?.RecordUsedEffects ?? false); // Setup shader compiler settings from a compilation mode. // TODO: We might want to provide overrides on the GameSettings to specify debug and/or optim level specifically. if (Settings != null) { EffectSystem.SetCompilationMode(Settings.CompilationMode); } GameSystems.Add(EffectSystem); if (Settings != null) { Streaming.SetStreamingSettings(Settings.Configurations.Get <StreamingSettings>()); } GameSystems.Add(Streaming); GameSystems.Add(SceneSystem); // Add the Audio System GameSystems.Add(Audio); // Add the VR System GameSystems.Add(VRDeviceSystem); // TODO: data-driven? Content.Serializer.RegisterSerializer(new ImageSerializer()); OnGameStarted(this); }