public void DoDraw(DateTime dateTime, GpuSwapChain swapChain) { using (var uniformTimeCpuBufferStream = UniformTimeCpuBuffer.AsStream()) using (var uniformTimeCpuBufferWriter = new BinaryWriter(uniformTimeCpuBufferStream)) { float frametime = ((float)(dateTime - StartDateTime).TotalMilliseconds) / 1000; uniformTimeCpuBufferWriter.Write(frametime); } Device.DefaultQueue.WriteBuffer(UniformBuffer, TimeOffset, UniformTimeCpuBuffer); var renderPassDesriptor = new GpuRenderPassDescriptor(new GpuRenderPassColorAttachment[] { new GpuRenderPassColorAttachment(swapChain.GetCurrentTexture().CreateView(), new GpuColorDict { R = 0, B = 0, G = 0, A = 1.0f }) }); var commandEncoder = Device.CreateCommandEncoder(); var passEncoder = commandEncoder.BeginRenderPass(renderPassDesriptor); if (Settings.RenderBundles) { passEncoder.ExecuteBundles(new GpuRenderBundle[] { RenderBundle }); } else { RecordRenderPass(passEncoder); } passEncoder.EndPass(); Device.DefaultQueue.Sumit(new GpuCommandBuffer[] { commandEncoder.Finish() }); }
void DrawFrame() { var renderPassDescriptor = new GpuRenderPassDescriptor(new GpuRenderPassColorAttachment[] { new GpuRenderPassColorAttachment(SwapChain.GetCurrentTexture().CreateView(), new GpuColorDict { R = 0, G = 0, B = 0, A = 0 }) }); renderPassDescriptor.DepthStencilAttachment = new GpuRenderPassDepthStencilAttachment(DepthTexture.CreateView(), 1.0f, GpuStoreOp.Store, null, GpuStoreOp.Store); var commandEncoder = Device.CreateCommandEncoder(); var cpass = commandEncoder.BeginComputePass(); cpass.SetPipeline(ComputePipeline); cpass.SetBindGroup(0, ParticleBindGroups[T % 2]); cpass.Dispatch(NumParticles, 1, 1); cpass.EndPass(); var rpass = commandEncoder.BeginRenderPass(renderPassDescriptor); rpass.SetPipeline(RenderPipeline); rpass.SetVertexBuffer(0, ParticleBuffers[(T + 1) % 2], 0, ParticleBuffers[(T + 1) % 2].Size); rpass.SetVertexBuffer(1, VerticesBuffer, 0, VerticesBuffer.Size); rpass.Draw(3, NumParticles, 0, 0); rpass.EndPass(); Device.DefaultQueue.Sumit(new GpuCommandBuffer[] { commandEncoder.Finish() }); SwapChain.Present(); ++T; }
void DrawFrame() { WriteMatrixToBuffer(UniformCpuBuffer, GetTransformationMatrix()); Device.DefaultQueue.WriteBuffer(UniformBuffer, 0, UniformCpuBuffer); var swapChainTexture = SwapChain.GetCurrentTexture(); GpuRenderPassDescriptor renderPassDescriptor = new GpuRenderPassDescriptor(new GpuRenderPassColorAttachment[] { new GpuRenderPassColorAttachment(swapChainTexture.CreateView(), new GpuColorDict { R = 0.5f, G = 0.5f, B = 0.5f, A = 1.0f }) }) { DepthStencilAttachment = new GpuRenderPassDepthStencilAttachment(DepthTexture.CreateView(), 1.0f, GpuStoreOp.Store, null, GpuStoreOp.Store) }; var commandEncoder = Device.CreateCommandEncoder(); var passEncoder = commandEncoder.BeginRenderPass(renderPassDescriptor); passEncoder.SetPipeline(Pipeline); passEncoder.SetBindGroup(0, UniformBindGroup); passEncoder.SetVertexBuffer(0, VerticesBuffer, 0, VerticesBuffer.Size); passEncoder.Draw(36, 1, 0, 0); passEncoder.EndPass(); commandEncoder.CopyTextureToTexture(new GpuImageCopyTexture(swapChainTexture), new GpuImageCopyTexture(CubeTexture), new GpuExtend3DDict { Width = SwapChainDescriptor.Width, Height = SwapChainDescriptor.Height, Depth = 1 }); Device.DefaultQueue.Sumit(new GpuCommandBuffer[] { commandEncoder.Finish() }); SwapChain.Present(); }
void DrawFrame() { var encoder = Device.CreateCommandEncoder(); var textureView = SwapChain.GetCurrentTexture().CreateView(); var renderpassDescriptor = new GpuRenderPassDescriptor(new GpuRenderPassColorAttachment[] { new GpuRenderPassColorAttachment(textureView, new GpuColorDict { R = 0, G = 0, B = 0, A = 1 }) }); var passEncoder = encoder.BeginRenderPass(renderpassDescriptor); passEncoder.SetPipeline(Pipeline); passEncoder.Draw(3, 1, 0, 0); passEncoder.EndPass(); Device.DefaultQueue.Sumit(new GpuCommandBuffer[] { encoder.Finish() }); SwapChain.Present(); }
void DrawFrame() { UpdateTransformationMatrix(); WriteMatricesToBuffer(UniformCpuBuffer, MvpMatrices); Device.DefaultQueue.WriteBuffer(UniformBuffer, 0, UniformCpuBuffer); GpuRenderPassDescriptor renderPassDescriptor = new GpuRenderPassDescriptor(new GpuRenderPassColorAttachment[] { new GpuRenderPassColorAttachment(SwapChain.GetCurrentTexture().CreateView(), new GpuColorDict { R = 0.5f, G = 0.5f, B = 0.5f, A = 1.0f }) }) { DepthStencilAttachment = new GpuRenderPassDepthStencilAttachment(DepthTexture.CreateView(), 1.0f, GpuStoreOp.Store, null, GpuStoreOp.Store) }; var commandEncoder = Device.CreateCommandEncoder(); var passEncoder = commandEncoder.BeginRenderPass(renderPassDescriptor); passEncoder.SetPipeline(Pipeline); passEncoder.SetBindGroup(0, UniformBindGroup); passEncoder.SetVertexBuffer(0, VerticesBuffer, 0, VerticesBuffer.Size); passEncoder.Draw(36, NumInstances, 0, 0); passEncoder.EndPass(); Device.DefaultQueue.Sumit(new GpuCommandBuffer[] { commandEncoder.Finish() }); SwapChain.Present(); }