Program Listing for File opengl-version.h

Return to documentation for file (include\gpu-utility\opengl-version.h)

/******************************************************************************
(c) Intel Corporation.

This software and the related documents are Intel copyrighted materials,
and your use of them is governed by the express license under which they
were provided to you ("License"). Unless the License provides otherwise,
you may not use, modify, copy, publish, distribute, disclose or transmit
this software or the related documents without Intel's prior written
permission.

 This software and the related documents are provided as is, with no express
or implied warranties, other than those that are expressly stated in the
License.

******************************************************************************/

#pragma once

#include <utility>
#include <mutex>
#include <string>

struct GPADispatchTable;

namespace gpa {
namespace gpu_utility {

// TODO(tatauis): There's duplicated code of GLVersion in TraceLayer, which should be taken from Rainier in future
// but there's no easy way to share utils code between layers, especially when one of layers is located in different repository

class GLVersion
{
public:
    using Version = std::pair<uint32_t, uint32_t>;

    struct Desc
    {
        Version version{0U, 0U};
        bool isES{false};

        bool operator==(const Desc& desc) const;
        operator bool() const;
    };

    explicit GLVersion(const GPADispatchTable& dispatchTable);

    GLVersion(const GLVersion&) = delete;
    GLVersion& operator=(const GLVersion&) = delete;

    GLVersion(GLVersion&&) noexcept = delete;
    GLVersion& operator=(GLVersion&&) noexcept = delete;

    const Version& GetVersion() const
    {
        return mDesc.version;
    }

    bool IsES() const
    {
        return mDesc.isES;
    }

    const Desc& GetDesc() const
    {
        return mDesc;
    }

    const std::string& AsString() const;

    void Reset();
    bool Update();

private:
    const GPADispatchTable& mDispatchTable;
    Desc mDesc;
    mutable std::string mVersionStr;
    std::mutex mMutex;
};

}  // namespace gpu_utility
}  // namespace gpa