private void RecreateAnimations() { unsafe { var nonEmpty = InstanceLists.Where(e => e.Value.Count > 0); var ptr = (byte *)AnimationUniform.Map(0, nonEmpty.Count() * Animation.MaxInstructions); foreach (var keyList in nonEmpty) { if (!keyList.Value.Updated) { ptr += Animation.SizeStd140; continue; } var(texture, animation) = ((Texture2D, Animation))keyList.Key; if (animation is null) { Animation.WriteNullToBuffer(ptr, out ptr); } else { animation.WriteToBuffer(ptr, out ptr); } } AnimationUniform.Unmap(); } }
public override void OnDraw(Semaphore start, VKImage image) { if (AnyUpdatedInstanceLists) { UpdateLists(); RecreateInstanceBuffers(); RecreateAnimations(); RecreateDescriptorSets(); FinishUpdateLists(); Refresh(); } unsafe { var nonEmpty = InstanceLists.Values.Where(e => e.Count > 0); var ptr = TimeUniform.Map(0, nonEmpty.Count()); foreach (var list in nonEmpty) { *(ptr++) = new ListTime { Time = (float)list.TimeSinceLastUpdate }; } TimeUniform.Unmap(); } var graphicsCommandBuffer = GetCommandBuffer(image); Graphics.ComputeQueueFamily.First.Submit( start, PipelineStages.ComputeShader, ComputeCommandBuffers[image], ComputeSemaphore ); Graphics.GraphicsQueueFamily.First.Submit( ComputeSemaphore, PipelineStages.ColorAttachmentOutput, graphicsCommandBuffer, FinishedSemaphore ); }
public void SetCamera(Matrix4x4 view, Matrix4x4 projection) { unsafe { var ptr = CameraUniform.Map(0, 1); * ptr = new CameraUniformBlock { View = view, Projection = projection }; CameraUniform.Unmap(); } }