/// @fn TheadEnd /// @brief スレッド終了 void D3D9DeviceThread::ThreadEnd() { if (!thread_life_) return; std::lock(device_task_mutex_, draw_task_mutex_); while (!device_task_.empty() || !draw_task_.empty()) { if (!device_task_.empty()) { device_task_.pop(); } if (!draw_task_.empty()) { draw_task_.pop(); } } device_task_mutex_.unlock(); draw_task_mutex_.unlock(); DrawCall(); thread_life_ = false; while (!device_thread_.joinable()) { DrawCall(); } device_thread_.join(); }
void SpriteRenderer::Draw(Texture& texture, glm::vec2 position, float rotation, glm::vec2 scale, unsigned int layer) { drawcalls.push_back(DrawCall(texture, position, glm::vec2(rotation), scale, layer)); }
void FForwardPlusRenderer::DrawScene(const FCamera& Camera, class IScene* Scene) { FProfiler::Get().PushSection("Rendering", "Forward+"); FMaterialParameters::FlushShaderResources(GraphicsContext->GetImmediateContext()); CurrentViewport = Camera.GetViewport(); // Setup buffers UpdateFrameData(Camera, Scene); { FProfiler::Get().PushSection("Rendering", "Depth-Normal PrePass"); // We use the result of this pass for both SSAO and Light Culling (we need depth information for that). DoDepthNormalPrePass(Camera, Scene); if (SSAOEnabled.AsBoolean()) { AmbientOcclusion->Apply(CurrentViewport, DepthTarget.Get(), NormalTarget.Get(), OcclusionTarget.Get()); MaterialManager->SetGlobalResourceView(FScreenSpaceAmbientOcclusion::kAmbientOcclusionMap, OcclusionTarget->GetRenderResource()); } FProfiler::Get().PopSection(); } { FProfiler::Get().PushSection("Rendering", "Shadow Maps Pass"); // Render shadow maps if (ShadowMappingEnabled.AsBoolean()) ShadowMapping->GatherShadowMaps(Scene); FProfiler::Get().PopSection(); } { FProfiler::Get().PushSection("Rendering", "Light Culling Pass"); // Perform light culling and upload light buffers LightPass->Apply(this, ShadowMapping.Get(), DepthTarget.Get(), Scene, Camera); FProfiler::Get().PopSection(); } { FProfiler::Get().PushSection("Rendering", "Scene Pass"); // Render the scene in forward fashion DoScenePass(Camera, Scene); FProfiler::Get().PopSection(); } { FProfiler::Get().PushSection("Rendering", "HDR Post Process Pass"); HighDynamicRangeTarget->ResolveFrom(GraphicsContext->GetImmediateContext(), HighDynamicRangeMSAATarget.Get()); HighDynamicRange->Apply(CurrentViewport, HighDynamicRangeTarget.Get(), GraphicsContext->GetBackBuffer()); FProfiler::Get().PopSection(); } FProfiler::Get().PopSection(); #if DEBUG FViewport Fullscreen(0, 0, GraphicsContext->GetWidth(), GraphicsContext->GetHeight()); D3D11_VIEWPORT Viewport = Fullscreen.CreateRenderViewport(); ID3D11RenderTargetView* RenderTarget = GraphicsContext->GetBackBuffer(); GraphicsContext->GetImmediateContext()->RSSetViewports(1, &Viewport); GraphicsContext->GetImmediateContext()->ClearDepthStencilView(GraphicsContext->GetDepthStencil(), D3D11_CLEAR_STENCIL | D3D11_CLEAR_DEPTH, 1.0f, 0); GraphicsContext->GetImmediateContext()->OMSetRenderTargets(1, &RenderTarget, GraphicsContext->GetDepthStencil()); if (ShowHdrDebug.AsBoolean()) { HighDynamicRange->DebugHdr(SpriteBatch.Get()); FInstanceBuffer InstanceBuffer = FInstanceBuffer::Identity; FDrawCall DrawCall(GraphicsContext->GetImmediateContext(), &InstanceBuffer, nullptr); SpriteBatch->Render(DrawCall); } #endif }