Beispiel #1
0
int ModSynch( void )
{
	SET_SEGV_LOCATION();
	statbot = AddBot( &statbotinfo );
	if( !statbot )
		return NS_FAILURE;
	/* Timer to save the database */
	AddTimer( TIMER_TYPE_INTERVAL, SaveStatsTimer, "SaveStatsTimer", DBSAVETIME, NULL );
	/* Timer to output html */
	if( StatServ.html )
	{
		AddTimer( TIMER_TYPE_INTERVAL, HTMLOutputTimer, "HTMLOutputTimer", StatServ.htmltime, NULL );
		/* Initial output at load */
		HTMLOutput();
	}
	/* Timer to reset timeslice stats */
	AddTimer( TIMER_TYPE_DAILY, ResetStatisticsTimer, "ResetStatisticsTimer", 0, NULL );
	/* Timer to average stats */
	AddTimer( TIMER_TYPE_INTERVAL, AverageStatisticsTimer, "AverageStatisticsTimer", TS_ONE_HOUR, NULL );
	/* Initial average at load */
	AverageStatistics();
	/* Timer to delete old channels */
	AddTimer( TIMER_TYPE_INTERVAL, DelOldChanTimer, "DelOldChanTimer", TS_ONE_HOUR, NULL );
	return NS_SUCCESS;
}
//
// Renders the user interface using D2D on top of our D3D12 content.
//
HRESULT D3D12MemoryManagement::RenderUI()
{
    HRESULT hr = S_OK;

    UINT FrameIndex = m_pDXGISwapChain->GetCurrentBackBufferIndex();

    //
    // Acquire the wrapped back buffer object. When we release the wrapped object, it will
    // be placed in a presentable state, and we can call Present directly.
    //
    m_p11On12Device->AcquireWrappedResources(&m_pWrappedBackBuffers[FrameIndex], 1);

    m_pD2DContext->SetTarget(m_pD2DRenderTargets[FrameIndex]);
    m_pD2DContext->BeginDraw();
    m_pD2DContext->SetTransform(D2D1::Matrix3x2F::Identity());

    if (m_bRenderStats)
    {
        //
        // Render statistical information, such as the framerate, memory budget graph,
        // and glitch count.
        //
        m_pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_TRAILING);
        m_pTextFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
        RenderMemoryGraph();

        //
        // Frame statistics (FPS, CPU time, etc).
        //
        {
            D2D1_RECT_F TextRect;

            TextRect.left = 8;
            TextRect.top = 8;
            TextRect.right = 256;
            TextRect.bottom = 256;

            float StatTimeBetweenFrames = AverageStatistics(m_StatTimeBetweenFrames, STATISTIC_COUNT);
            float StatRenderScene = AverageStatistics(m_StatRenderScene, STATISTIC_COUNT);
            float StatRenderUI = AverageStatistics(m_StatRenderUI, STATISTIC_COUNT);

            m_pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING);
            m_pTextFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR);
            wchar_t FPSString[128];
            swprintf_s(
                FPSString,
                _TRUNCATE,
                L"FPS: %d (%.2fms)\n"
                L"Glitch Count: %d\n"
                L"\n"
                L"RenderScene: %.2f ms\n"
                L"RenderUI: %.2f ms",
                (UINT)(1.0f / StatTimeBetweenFrames),
                StatTimeBetweenFrames * 1000.0f,
                GetGlitchCount(),
                StatRenderScene * 1000.0f,
                StatRenderUI * 1000.0f);

            m_pD2DContext->DrawTextW(
                FPSString,
                (UINT)wcslen(FPSString),
                m_pTextFormat,
                &TextRect,
                m_pTextBrush);
        }
    }

    hr = m_pD2DContext->EndDraw();
    if (FAILED(hr))
    {
        LOG_WARNING("D2D EndDraw failed, hr=0x%.8x", hr);
    }

    //
    // Unreference the render target after rendering completes.
    //
    m_pD2DContext->SetTarget(nullptr);

    m_p11On12Device->ReleaseWrappedResources(&m_pWrappedBackBuffers[FrameIndex], 1);

    //
    // Flush D2D based content on the D3D11On12 device to synchronize with D3D12 content.
    //
    m_p11Context->Flush();

    return hr;
}