File indexing completed on 2024-05-12 05:31:42

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2023 Xaver Hugl <xaver.hugl@gmail.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #pragma once
0010 
0011 #include <chrono>
0012 #include <epoxy/gl.h>
0013 
0014 #include "kwin_export.h"
0015 
0016 namespace KWin
0017 {
0018 
0019 class KWIN_EXPORT GLRenderTimeQuery
0020 {
0021 public:
0022     explicit GLRenderTimeQuery();
0023     ~GLRenderTimeQuery();
0024 
0025     void begin();
0026     void end();
0027 
0028     /**
0029      * fetches the result of the query. If rendering is not done yet, this will block!
0030      */
0031     std::chrono::nanoseconds result();
0032 
0033 private:
0034     GLuint m_query = 0;
0035     bool m_hasResult = false;
0036     std::chrono::nanoseconds m_cpuStart = std::chrono::nanoseconds::zero();
0037     std::chrono::nanoseconds m_cpuEnd = std::chrono::nanoseconds::zero();
0038 };
0039 
0040 }