protected override void InternalDrawCallback(TimeSpan gameTime) { var computeCommandBuffer = this.computeCommandQueue.CommandBuffer(); this.computeData.time += (float)gameTime.TotalSeconds; this.computeData.framecount++; if (!this.paramsData.IsPathTracing) { RotateAround(this.lookFrom, this.lookat, (float)gameTime.TotalSeconds / 1, out this.lookFrom); this.dist_to_focus = (lookFrom - lookat).Length(); this.aperture = 0.01f; this.cam = Camera.Create(lookFrom, lookat, Vector3.UnitY, 25f, (float)this.width / this.height, this.aperture, this.dist_to_focus); this.computeData.cam = this.cam; } computeCommandBuffer.Begin(); computeCommandBuffer.UpdateBufferData(this.constantBuffer, ref this.computeData); computeCommandBuffer.SetComputePipelineState(this.computePipelineState); computeCommandBuffer.SetResourceSet(this.computeResourceSet); computeCommandBuffer.Dispatch(this.threadGroupX, this.threadGroupY, 1); computeCommandBuffer.End(); computeCommandBuffer.Commit(); this.computeCommandQueue.Submit(); this.computeCommandQueue.WaitIdle(); var graphicsCommandBuffer = this.graphicsCommandQueue.CommandBuffer(); graphicsCommandBuffer.Begin(); graphicsCommandBuffer.UpdateBufferData(this.paramsBuffer, ref this.paramsData); RenderPassDescription renderPassDescription = new RenderPassDescription(this.frameBuffer, ClearValue.None); graphicsCommandBuffer.BeginRenderPass(ref renderPassDescription); graphicsCommandBuffer.SetViewports(this.viewports); graphicsCommandBuffer.SetScissorRectangles(this.scissors); graphicsCommandBuffer.SetGraphicsPipelineState(this.graphicsPipelineState); graphicsCommandBuffer.SetResourceSet(this.resourceSet); graphicsCommandBuffer.Draw(3); graphicsCommandBuffer.EndRenderPass(); graphicsCommandBuffer.End(); graphicsCommandBuffer.Commit(); this.graphicsCommandQueue.Submit(); this.graphicsCommandQueue.WaitIdle(); this.paramsData.Samples += this.computeData.samples; }
protected unsafe override void InternalDrawCallback(TimeSpan gameTime) { // Press space key var pressed = this.surface.KeyboardDispatcher.ReadKeyState(WaveEngine.Common.Input.Keyboard.Keys.Space) == WaveEngine.Common.Input.ButtonState.Pressing; IntPtr device = (IntPtr)null; IntPtr wndHandle = (IntPtr)null; if (pressed) { device = this.graphicsContext.NativeDevicePointer; this.renderDoc.API.StartFrameCapture(device, (IntPtr)null); } var commandBuffer = this.commandQueue.CommandBuffer(); commandBuffer.Begin(); RenderPassDescription renderPassDescription = new RenderPassDescription(this.frameBuffer, new ClearValue(ClearFlags.Target, Color.CornflowerBlue)); commandBuffer.BeginRenderPass(ref renderPassDescription); commandBuffer.SetViewports(this.viewports); commandBuffer.SetScissorRectangles(this.scissors); commandBuffer.SetGraphicsPipelineState(this.pipelineState); commandBuffer.SetVertexBuffers(this.vertexBuffers); commandBuffer.Draw((uint)this.vertexData.Length / 2); commandBuffer.EndRenderPass(); commandBuffer.End(); commandBuffer.Commit(); this.commandQueue.Submit(); this.commandQueue.WaitIdle(); if (pressed) { var result = this.renderDoc.API.EndFrameCapture(device, (IntPtr)null); if (result == 1) { this.renderDoc.API.LaunchReplayUI(1, null); } } }
protected override void InternalDrawCallback(TimeSpan gameTime) { var graphicsCommandBuffer = this.graphicsCommandQueue.CommandBuffer(); graphicsCommandBuffer.Begin(); RenderPassDescription renderPassDescription = new RenderPassDescription(this.frameBuffer, ClearValue.None); graphicsCommandBuffer.BeginRenderPass(ref renderPassDescription); graphicsCommandBuffer.SetViewports(this.viewports); graphicsCommandBuffer.SetScissorRectangles(this.scissors); graphicsCommandBuffer.SetGraphicsPipelineState(this.graphicsPipelineState); graphicsCommandBuffer.SetResourceSet(this.resourceSet); graphicsCommandBuffer.Draw(3); graphicsCommandBuffer.EndRenderPass(); graphicsCommandBuffer.End(); graphicsCommandBuffer.Commit(); this.graphicsCommandQueue.Submit(); this.graphicsCommandQueue.WaitIdle(); }
protected override void InternalDrawCallback(TimeSpan gameTime) { // Update this.time += (float)gameTime.TotalSeconds * 0.5f; var viewProj = Matrix4x4.Multiply(this.view, this.proj); this.parameters.viewProj = Matrix4x4.CreateRotationY((float)Math.Sin(this.time) * 0.4f) * viewProj; // Draw var commandBuffer = this.graphicsCommandQueue.CommandBuffer(); commandBuffer.Begin(); commandBuffer.UpdateBufferData(this.constantBuffer, ref this.parameters); RenderPassDescription renderPassDescription = new RenderPassDescription(this.frameBuffer, new ClearValue(ClearFlags.Target, Color.Black)); commandBuffer.BeginRenderPass(ref renderPassDescription); commandBuffer.SetViewports(this.viewports); commandBuffer.SetScissorRectangles(this.scissors); commandBuffer.SetGraphicsPipelineState(this.graphicsPipelineState); commandBuffer.SetResourceSet(this.resourceSet); commandBuffer.SetVertexBuffers(this.vertexBuffers); commandBuffer.DrawInstanced((uint)vertexData.Length, (uint)this.parameters.numLayers); commandBuffer.EndRenderPass(); commandBuffer.End(); commandBuffer.Commit(); this.graphicsCommandQueue.Submit(); this.graphicsCommandQueue.WaitIdle(); }