/// <summary> /// /// </summary> public override void LoadAttachments(IEnumerable <Resource.IDescriptor> resources) { // - Skip buffer creation if no resources to load if (resources.Count() <= 0) { return; } // - Creates a command buffer for data transfer var commands = GraphicDevice.Handle.AllocateCommandBuffer(Commands[0], CommandBufferLevel.Primary); commands.Begin(CommandBufferUsageFlags.OneTimeSubmit); foreach (Resource.IDescriptor res in resources) { switch (res) { case Shape.Descriptor shape: // - Loads the geometry Geometry pointer = GeometryDispatcher.Load(shape); // - Set resource loaded in the source thread shape.SourceScheduler.Add(() => { shape.SetResource(pointer); shape.SetState(Resource.State.Loaded); }); break; default: throw new Exception($"Resource {res.GetType().Name} does not has a loader."); } } { // - Upload invalidated vertexs VertexManager.Upload(commands, 1000); // - Upload invalidated indexes IndexManager.Upload(commands, 1000); } commands.End(); // - Perform all attachment operations GraphicDevice.GraphicQueue.Submit ( new SubmitInfo { CommandBuffers = new[] { commands } }, null ); // - Free attachment command buffer Commands[0].FreeCommandBuffers(commands); // - Wait the GPU (we must operate only when GPU is idle) GraphicDevice.Handle.WaitIdle(); }