Beispiel #1
0
 public void BeginFrame(string id)
 {
     FrameTracker tracker = new FrameTracker();
     _frames.Push(tracker);
     WriteASCII(id, incrementSize: false);
     tracker.SizeOffsetInStream = _stream.Position;
     WriteBigE(0, incrementSize: false); // Size placeholder
 }
Beispiel #2
0
        public void BeginFrame(string id)
        {
            FrameTracker tracker = new FrameTracker();

            _frames.Push(tracker);
            WriteASCII(id, incrementSize: false);
            tracker.SizeOffsetInStream = _stream.Position;
            WriteBigE(0, incrementSize: false); // Size placeholder
        }
 public void CreateDriverCore()
 {
     Session         = new Session(sessionId++);
     FrameTracker    = new FrameTracker(DevTools);
     WebView         = new WebView(DevTools, FrameTracker, this);
     Mouse           = new ChromeDriverMouse(WebView, Session);
     Keyboard        = new ChromeDriverKeyboard(WebView);
     ElementUtils    = new ElementUtils(WebView, Session);
     ElementCommands = new ElementCommands(WebView, Session, ElementUtils, this);
     WindowCommands  = new WindowCommands(WebView, Session, this);
 }
Beispiel #4
0
        internal void PreDraw(FrameTracker tracker, int swapchainIndex)
        {
            //Update the scene data
            SceneData sceneData = new SceneData(
                tracker.FrameNumber,
                (float)tracker.ElapsedTime,
                tracker.DeltaTime);

            sceneDataBuffer.Write(sceneData, SceneData.SIZE * swapchainIndex);

            gbufferTechnique.PreDraw(swapchainIndex);
            shadowTechnique.PreDraw(swapchainIndex, sunDirection, shadowDistance);
        }
Beispiel #5
0
        public void EndFrame()
        {
            FrameTracker tracker = _frames.Pop();

            long currentPosition = _stream.Position;

            _stream.Seek(tracker.SizeOffsetInStream, SeekOrigin.Begin);
            WriteBigE(tracker.Size, incrementSize: false);
            _stream.Seek(currentPosition, SeekOrigin.Begin);

            if (_frames.Count > 0)
            {
                _frames.Peek().Size += tracker.Size + tracker.HeaderSize; // parent frame size increase
            }
        }
Beispiel #6
0
        public void Draw(FrameTracker frameTracker)
        {
            if (commandbuffers == null || commandbuffers.Length == 0)
            {
                throw new Exception($"[{nameof(Window)}] No command buffers have been created yet");
            }
            ThrowIfDisposed();

            //If the scene is dirty we re-record the command-buffers
            if (scene?.Dirty == true)
            {
                logicalDevice.WaitIdle();
                CreateRenderCommands(scene);
            }

            int swapchainIndex = swapchain.AcquireNextImage(semaphore: imageAvailableSemaphore);

            //Wait for the previous submit of this buffer to be done
            waitFences[swapchainIndex].Wait();
            waitFences[swapchainIndex].Reset();

            //Give the scene a chance to prepare some data for drawing
            scene?.PreDraw(frameTracker, swapchainIndex);

            //Once we have acquired an image we submit a commandbuffer for writing to it
            graphicsQueue.Submit(
                waitSemaphore: imageAvailableSemaphore,
                waitDstStageMask: PipelineStages.ColorAttachmentOutput,
                commandBuffer: commandbuffers[swapchainIndex],
                signalSemaphore: renderFinishedSemaphore,
                fence: waitFences[swapchainIndex]
                );

            //Once rendering to the framebuffer is done we can present it
            presentQueue.PresentKhr(
                waitSemaphore: renderFinishedSemaphore,
                swapchain: swapchain,
                imageIndex: swapchainIndex);

            //Set the window title mostly for debugging purposes
            nativeWindow.Title =
                $"{title} - {hostDevice.Name} - {nativeWindow.ClientRect.Size} - Fps: {frameTracker.SmoothedFps:N1}";
        }
Beispiel #7
0
        private void DrawDebugOverlay()
        {
            spriteBatch.Begin();

            spriteBatch.Rect(new Color(0, 0, 0, 0.5f), new Vector2(0, 0), new Vector2(200, 50));
            spriteBatch.Print(Color.White, new Vector2(2, 0), String.Format("fps: {0} ", Math.Floor(FrameTracker.GetAverageFramerate())));
            spriteBatch.Print(Color.White, new Vector2(2, 12), "campos" + FormatVector(Camera.Position));
            spriteBatch.Print(Color.White, new Vector2(2, 24), "camlookat" + FormatVector(Camera.View.Forward));

            spriteBatch.End();
        }