Пример #1
0
        protected override void Render()
        {
            if (isResizing)
            {
                return;
            }

            commandList.Begin();

            if (DrawModeCpu)
            {
                if (!renderOnce)
                {
                    Raytracer.RenderCpuNew();
                }

                if (!isResizing)
                {
                    unsafe
                    {
                        fixed(RgbaFloat *pixelDataPtr = Raytracer.FrameBuffer)
                        {
                            GraphicsDevice.UpdateTexture(transferTexture, (IntPtr)pixelDataPtr,
                                                         transferTexture.Width * transferTexture.Height * (uint)sizeof(RgbaFloat), 0, 0, 0,
                                                         transferTexture.Width, transferTexture.Height, 1, 0, 0);
                        }
                    }
                }
            }
            else
            {
                RenderGpu();
            }

            commandList.SetFramebuffer(GraphicsDevice.MainSwapchain.Framebuffer);
            commandList.SetPipeline(graphicsPipeline);
            commandList.SetGraphicsResourceSet(0, graphicsSet);
            commandList.Draw(3);
            commandList.End();

            if (!DrawModeCpu)
            {
                var rayCountView = GraphicsDevice.Map <uint>(rayCountReadback, MapMode.Read);
                var rPF          = rayCountView[0];
                GraphicsDevice.Unmap(rayCountReadback);
            }

            base.Render();
        }