// // Created by Bradley Austin Davis on 2018/10/21 // Copyright 2014 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #pragma once #include #include #include #ifdef USE_GL #include #include #include #else #include #include #endif class RenderThread : public GenericThread { using Parent = GenericThread; public: QWindow* _window{ nullptr }; #ifdef USE_GL gl::Context _context; #else vks::Context& _context{ vks::Context::get() }; const vk::Device& _device{ _context.device }; vk::SurfaceKHR _surface; vk::RenderPass _renderPass; vks::Swapchain _swapchain; vk::Semaphore acquireComplete, renderComplete; std::vector _framebuffers; vk::Extent2D _extent; void setupFramebuffers(); void setupRenderPass(); #endif std::mutex _mutex; gpu::ContextPointer _gpuContext; // initialized during window creation std::shared_ptr _backend; std::atomic _presentCount{ 0 }; QElapsedTimer _elapsed; size_t _frameIndex{ 0 }; std::mutex _frameLock; std::queue _pendingFrames; std::queue _pendingSize; gpu::FramePointer _activeFrame; uint32_t _externalTexture{ 0 }; void move(const glm::vec3& v); glm::mat4 _correction; gpu::PipelinePointer _presentPipeline; void resize(const QSize& newSize); void setup() override; bool process() override; void shutdown() override; void submitFrame(const gpu::FramePointer& frame); void initialize(QWindow* window); void renderFrame(gpu::FramePointer& frame); };