-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenGL is literal hell on earth, I cri everytiem Ref: #2
- Loading branch information
1 parent
3248e9d
commit 0130ec6
Showing
11 changed files
with
272 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// infoware - C++ System information Library | ||
// | ||
// Written in 2016 by nabijaczleweli <[email protected]> and ThePhD <[email protected]> | ||
// | ||
// To the extent possible under law, the author(s) have dedicated all copyright and related | ||
// and neighboring rights to this software to the public domain worldwide. This software is | ||
// distributed without any warranty. | ||
// | ||
// You should have received a copy of the CC0 Public Domain Dedication along with this software. | ||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/> | ||
|
||
|
||
#include "infoware/gpu.hpp" | ||
#include <iostream> | ||
|
||
|
||
int main() { | ||
for(auto&& props : iware::gpu::device_properties()) | ||
std::cout << props.cache_size << ' '; | ||
std::cout << '\n'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// infoware - C++ System information Library | ||
// | ||
// Written in 2016 by nabijaczleweli <[email protected]> and ThePhD <[email protected]> | ||
// | ||
// To the extent possible under law, the author(s) have dedicated all copyright and related | ||
// and neighboring rights to this software to the public domain worldwide. This software is | ||
// distributed without any warranty. | ||
// | ||
// You should have received a copy of the CC0 Public Domain Dedication along with this software. | ||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/> | ||
|
||
|
||
#include "infoware/gpu.hpp" | ||
#include <iostream> | ||
|
||
|
||
int main() { | ||
for(auto&& props : iware::gpu::device_properties()) | ||
std::cout << props.memory_size << ' '; | ||
std::cout << '\n'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// infoware - C++ System information Library | ||
// | ||
// Written in 2016 by nabijaczleweli <[email protected]> and ThePhD <[email protected]> | ||
// | ||
// To the extent possible under law, the author(s) have dedicated all copyright and related | ||
// and neighboring rights to this software to the public domain worldwide. This software is | ||
// distributed without any warranty. | ||
// | ||
// You should have received a copy of the CC0 Public Domain Dedication along with this software. | ||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/> | ||
|
||
|
||
#include "infoware/gpu.hpp" | ||
#include <iostream> | ||
|
||
|
||
int main() { | ||
for(auto&& props : iware::gpu::device_properties()) | ||
std::cout << props.name << ' '; | ||
std::cout << '\n'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// infoware - C++ System information Library | ||
// | ||
// Written in 2016 by nabijaczleweli <[email protected]> and ThePhD <[email protected]> | ||
// | ||
// To the extent possible under law, the author(s) have dedicated all copyright and related | ||
// and neighboring rights to this software to the public domain worldwide. This software is | ||
// distributed without any warranty. | ||
// | ||
// You should have received a copy of the CC0 Public Domain Dedication along with this software. | ||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/> | ||
|
||
|
||
#include "infoware/gpu.hpp" | ||
#include <iostream> | ||
|
||
|
||
int main() { | ||
for(auto&& props : iware::gpu::device_properties()) | ||
switch(props.vendor) { | ||
case iware::gpu::vendor_t::intel: | ||
std::cout << "Intel "; | ||
break; | ||
case iware::gpu::vendor_t::AMD: | ||
std::cout << "AMD "; | ||
break; | ||
case iware::gpu::vendor_t::NVidia: | ||
std::cout << "NVidia "; | ||
break; | ||
case iware::gpu::vendor_t::unknown: | ||
std::cout << "Unknown "; | ||
break; | ||
} | ||
std::cout << '\n'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// infoware - C++ System information Library | ||
// | ||
// Written in 2016 by nabijaczleweli <[email protected]> and ThePhD <[email protected]> | ||
// | ||
// To the extent possible under law, the author(s) have dedicated all copyright and related | ||
// and neighboring rights to this software to the public domain worldwide. This software is | ||
// distributed without any warranty. | ||
// | ||
// You should have received a copy of the CC0 Public Domain Dedication along with this software. | ||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/> | ||
|
||
|
||
#pragma once | ||
|
||
|
||
#include <cstdint> | ||
#include <string> | ||
#include <vector> | ||
|
||
|
||
namespace iware { | ||
namespace gpu { | ||
enum class vendor_t { | ||
intel, | ||
AMD, | ||
NVidia, | ||
unknown, | ||
}; | ||
|
||
struct device_properties_t { | ||
vendor_t vendor; | ||
std::string name; | ||
std::size_t memory_size; | ||
std::size_t cache_size; | ||
}; | ||
|
||
|
||
/// Returns all GPU's properties. | ||
std::vector<device_properties_t> device_properties(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ | |
|
||
|
||
#include "cpu.hpp" | ||
#include "gpu.hpp" | ||
#include "system.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// infoware - C++ System information Library | ||
// | ||
// Written in 2016 by nabijaczleweli <[email protected]> and ThePhD <[email protected]> | ||
// | ||
// To the extent possible under law, the author(s) have dedicated all copyright and related | ||
// and neighboring rights to this software to the public domain worldwide. This software is | ||
// distributed without any warranty. | ||
// | ||
// You should have received a copy of the CC0 Public Domain Dedication along with this software. | ||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/> | ||
|
||
|
||
#ifdef INFOWARE_USE_OPENCL | ||
|
||
|
||
#include "infoware/gpu.hpp" | ||
#include <cstdlib> | ||
#ifdef __APPLE__ | ||
#include <OpenCL/opencl.h> | ||
#else | ||
#include <CL/cl.h> | ||
#endif | ||
|
||
|
||
static iware::gpu::vendor_t parse_vendor(const char* name) { | ||
if(!strcmp(name, "Intel(R) Corporation")) | ||
return iware::gpu::vendor_t::intel; | ||
else if(!strcmp(name, "Advanced Micro Devices, Inc.")) | ||
return iware::gpu::vendor_t::AMD; | ||
else if(!strcmp(name, "NVIDIA Corporation")) | ||
return iware::gpu::vendor_t::NVidia; | ||
else | ||
return iware::gpu::vendor_t::unknown; | ||
} | ||
|
||
|
||
std::vector<iware::gpu::device_properties_t> iware::gpu::device_properties() { | ||
cl_platform_id platforms[64]; | ||
cl_uint platforms_used; | ||
clGetPlatformIDs(sizeof platforms / sizeof(*platforms), platforms, &platforms_used); | ||
|
||
std::vector<iware::gpu::device_properties_t> ret; | ||
for(auto i = 0u; i < platforms_used; ++i) { | ||
cl_device_id devices[64]; | ||
cl_uint devices_used; | ||
clGetDeviceIDs(platforms[i], CL_DEVICE_TYPE_GPU, sizeof devices / sizeof(*devices), devices, &devices_used); | ||
|
||
for(auto j = 0u; j < devices_used; ++j) { | ||
char name[256]; | ||
cl_ulong cache; | ||
cl_ulong memory; | ||
|
||
clGetDeviceInfo(devices[j], CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, sizeof(cache), &cache, nullptr); | ||
clGetDeviceInfo(devices[j], CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(memory), &memory, nullptr); | ||
clGetDeviceInfo(devices[j], CL_DEVICE_VENDOR, sizeof name, &name, nullptr); | ||
const auto vendor = parse_vendor(name); | ||
clGetDeviceInfo(devices[j], CL_DEVICE_NAME, sizeof name, &name, nullptr); | ||
|
||
ret.push_back({vendor, name, memory, cache}); | ||
} | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// infoware - C++ System information Library | ||
// | ||
// Written in 2016 by nabijaczleweli <[email protected]> and ThePhD <[email protected]> | ||
// | ||
// To the extent possible under law, the author(s) have dedicated all copyright and related | ||
// and neighboring rights to this software to the public domain worldwide. This software is | ||
// distributed without any warranty. | ||
// | ||
// You should have received a copy of the CC0 Public Domain Dedication along with this software. | ||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/> | ||
|
||
|
||
// OpenGL is literaly hitler to initialise a windowless context for, so no game. | ||
// Leave it for someone smarter than me :G |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// infoware - C++ System information Library | ||
// | ||
// Written in 2016 by nabijaczleweli <[email protected]> and ThePhD <[email protected]> | ||
// | ||
// To the extent possible under law, the author(s) have dedicated all copyright and related | ||
// and neighboring rights to this software to the public domain worldwide. This software is | ||
// distributed without any warranty. | ||
// | ||
// You should have received a copy of the CC0 Public Domain Dedication along with this software. | ||
// If not, see <http://creativecommons.org/publicdomain/zero/1.0/> | ||
|
||
|
||
#ifndef INFOWARE_USE_OPENCL | ||
|
||
|
||
#include "infoware/gpu.hpp" | ||
|
||
|
||
std::vector<iware::gpu::device_properties_t> iware::gpu::device_properties() { | ||
return {}; | ||
} | ||
|
||
|
||
#endif |