private static TagContainer SetupDIContainer(Options options, out GraphicsDevice graphicsDevice) { var diContainer = new TagContainer(); diContainer.AddTag(options); var graphicsDeviceOptions = new GraphicsDeviceOptions() { Debug = true, HasMainSwapchain = false, PreferDepthRangeZeroToOne = true, PreferStandardClipSpaceYDirection = true, }; graphicsDevice = options.Backend switch { ZZMapsGraphicsBackend.Vulkan => GraphicsDevice.CreateVulkan(graphicsDeviceOptions), ZZMapsGraphicsBackend.D3D11 => GraphicsDevice.CreateD3D11(graphicsDeviceOptions), _ => throw new InvalidOperationException($"Unknown backend {options.Backend}") }; diContainer.AddTag(graphicsDevice); diContainer.AddTag(graphicsDevice.ResourceFactory); var pipelineCollection = new PipelineCollection(graphicsDevice); pipelineCollection.AddShaderResourceAssemblyOf <zzre.materials.ModelStandardMaterial>(); pipelineCollection.AddShaderResourceAssemblyOf <MapStandardMaterial>(); diContainer.AddTag(pipelineCollection); var resourcePools = options.ResourcePath .Select(dirInfo => new FileResourcePool(dirInfo.FullName) as IResourcePool); resourcePools = resourcePools.Concat(options.PAK .Select(fileInfo => new PAKParallelResourcePool(fileInfo.FullName))); var combinedResourcePool = new CombinedResourcePool(resourcePools.Reverse().ToArray()); diContainer.AddTag <IResourcePool>(combinedResourcePool); diContainer.AddTag <IAssetLoader <Texture> >(new RefCachedAssetLoader <Texture>( new TextureAssetLoader(diContainer))); diContainer.AddTag <IAssetLoader <ClumpBuffers> >(new RefCachedAssetLoader <ClumpBuffers>( new ClumpAssetLoader(diContainer))); var mappedDb = new MappedDB(); for (int i = 1; i <= 6; i++) { using var tableStream = combinedResourcePool.FindAndOpen($"Data/_fb0x0{i}.fbs"); if (tableStream == null) { continue; } var table = new Table(); table.Read(tableStream); mappedDb.AddTable(table); } diContainer.AddTag(mappedDb); return(diContainer); }