forked from SaschaWillems/OpenCLCapsViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatforminfo.h
More file actions
92 lines (83 loc) · 2.79 KB
/
platforminfo.h
File metadata and controls
92 lines (83 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
*
* OpenCL hardware capability viewer
*
* Copyright (C) 2021 by Sascha Willems (www.saschawillems.de)
*
* This code is free software, you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 3 as published by the Free Software Foundation.
*
* Please review the following information to ensure the GNU Lesser
* General Public License version 3 requirements will be met:
* http://opensource.org/licenses/lgpl-3.0.html
*
* The code is distributed WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU LGPL 3.0 for more details.
*
*/
#include "CL/cl.h"
#include <QVariant>
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include "openclutils.h"
#include "openclfunctions.h"
#include "displayutils.h"
#pragma once
struct PlatformExtension
{
QString name;
cl_version version;
};
typedef std::function<QString(QVariant)> PlatformInfoDisplayFn;
struct PlatformInfoValueDescriptor
{
cl_device_info name;
clValueType valueType;
PlatformInfoDisplayFn displayFunction = nullptr;
PlatformInfoValueDescriptor();
PlatformInfoValueDescriptor(cl_platform_info name, clValueType valueType, PlatformInfoDisplayFn displayFunction = nullptr);
};
struct PlatformInfoValueDetailValue
{
QString name;
QString detail;
QVariant value;
PlatformInfoDisplayFn displayFunction = nullptr;
PlatformInfoValueDetailValue(QString name, QVariant value, PlatformInfoDisplayFn displayFunction = nullptr);
PlatformInfoValueDetailValue(QString name, QString detail, QVariant value, PlatformInfoDisplayFn displayFunction = nullptr);
QString getDisplayValue();
};
struct PlatformInfoValue
{
QString name;
QVariant value;
QString extension;
qint32 enumValue;
PlatformInfoDisplayFn displayFunction = nullptr;
std::vector<PlatformInfoValueDetailValue> detailValues;
PlatformInfoValue(cl_platform_info info, QVariant value, QString extension = "", PlatformInfoDisplayFn displayFunction = nullptr);
void addDetailValue(QString name, QVariant value, PlatformInfoDisplayFn displayFunction = nullptr);
void addDetailValue(QString name, QString detail, QVariant value, PlatformInfoDisplayFn displayFunction = nullptr);
QString getDisplayValue();
};
class PlatformInfo
{
private:
void readOpenCLVersion();
void readPlatformInfoValue(PlatformInfoValueDescriptor descriptor, QString extension = "");
void readExtensions();
bool extensionSupported(const char* name);
public:
cl_platform_id platformId;
std::vector<PlatformInfoValue> platformInfo;
std::vector<PlatformExtension> extensions;
qint32 clVersionMajor;
qint32 clVersionMinor;
void read();
void readExtensionInfo();
QJsonObject toJson();
};