cleaned up an unused file, added check for sharing
This commit is contained in:
@@ -2,10 +2,12 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
#include <CL/cl.h>
|
#include <CL/cl.h>
|
||||||
#include <CL/opencl.h>
|
#include <CL/opencl.h>
|
||||||
|
#include <GL/glx.h>
|
||||||
|
|
||||||
#elif defined _WIN32
|
#elif defined _WIN32
|
||||||
#include <CL/cl_gl.h>
|
#include <CL/cl_gl.h>
|
||||||
@@ -35,15 +37,21 @@ public:
|
|||||||
~CL_Wrapper();
|
~CL_Wrapper();
|
||||||
|
|
||||||
int acquire_platform_and_device();
|
int acquire_platform_and_device();
|
||||||
int create_shared_context();
|
|
||||||
|
int create_shared_context();
|
||||||
|
int create_cl_context();
|
||||||
|
|
||||||
int create_command_queue();
|
int create_command_queue();
|
||||||
|
|
||||||
int compile_kernel(std::string kernel_source, bool is_path, std::string kernel_name);
|
int compile_kernel(std::string kernel_source, bool is_path, std::string kernel_name);
|
||||||
|
|
||||||
int create_buffer(std::string buffer_name, cl_uint size, void* data);
|
int create_buffer(std::string buffer_name, cl_uint size, void* data);
|
||||||
int create_buffer(std::string buffer_name, cl_uint size, void* data, cl_mem_flags flags);
|
int create_buffer(std::string buffer_name, cl_uint size, void* data, cl_mem_flags flags);
|
||||||
int set_kernel_arg(std::string kernel_name, int index, std::string buffer_name);
|
|
||||||
int store_buffer(cl_mem, std::string buffer_name);
|
int store_buffer(cl_mem, std::string buffer_name);
|
||||||
|
|
||||||
|
int set_kernel_arg(std::string kernel_name, int index, std::string buffer_name);
|
||||||
int run_kernel(std::string kernel_name, const int work_size);
|
int run_kernel(std::string kernel_name, const int work_size);
|
||||||
|
|
||||||
bool assert(int error_code, std::string function_name);
|
bool assert(int error_code, std::string function_name);
|
||||||
|
|
||||||
cl_device_id getDeviceID();
|
cl_device_id getDeviceID();
|
||||||
@@ -56,7 +64,7 @@ private:
|
|||||||
|
|
||||||
int error = 0;
|
int error = 0;
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
bool cl_khr_gl_sharing_fallback = false;
|
||||||
|
|
||||||
cl_platform_id platform_id;
|
cl_platform_id platform_id;
|
||||||
cl_device_id device_id;
|
cl_device_id device_id;
|
||||||
|
|||||||
@@ -2,16 +2,18 @@
|
|||||||
#include <SFML/System/Vector3.hpp>
|
#include <SFML/System/Vector3.hpp>
|
||||||
#include <SFML/System/Vector2.hpp>
|
#include <SFML/System/Vector2.hpp>
|
||||||
#include <SFML/Graphics/Color.hpp>
|
#include <SFML/Graphics/Color.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
#include <list>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#define _USE_MATH_DEFINES
|
#include "util.hpp"
|
||||||
#include <math.h>
|
#include <deque>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#define _USE_MATH_DEFINES
|
||||||
#include <deque>
|
#include <math.h>
|
||||||
|
|
||||||
#define CHUNK_DIM 32
|
#define CHUNK_DIM 32
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,24 @@
|
|||||||
#include "CL_Wrapper.h"
|
#include "CL_Wrapper.h"
|
||||||
|
|
||||||
CL_Wrapper::CL_Wrapper() {
|
CL_Wrapper::CL_Wrapper() {
|
||||||
|
|
||||||
|
acquire_platform_and_device();
|
||||||
|
|
||||||
|
if (cl_khr_gl_sharing_fallback){
|
||||||
|
create_cl_context();
|
||||||
|
} else {
|
||||||
|
create_shared_context();
|
||||||
|
}
|
||||||
|
|
||||||
|
create_command_queue();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CL_Wrapper::~CL_Wrapper() {
|
CL_Wrapper::~CL_Wrapper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CL_Wrapper::acquire_platform_and_device(){
|
int CL_Wrapper::acquire_platform_and_device(){
|
||||||
|
|
||||||
// Get the number of platforms
|
// Get the number of platforms
|
||||||
@@ -88,37 +100,72 @@ int CL_Wrapper::acquire_platform_and_device(){
|
|||||||
platform_id = current_best_device.platform;
|
platform_id = current_best_device.platform;
|
||||||
device_id = current_best_device.id;
|
device_id = current_best_device.id;
|
||||||
|
|
||||||
|
// Test for sharing
|
||||||
|
size_t ext_str_size = 1024;
|
||||||
|
char *ext_str = new char[ext_str_size];
|
||||||
|
clGetDeviceInfo(device_id, CL_DEVICE_EXTENSIONS, ext_str_size, ext_str, &ext_str_size);
|
||||||
|
|
||||||
|
if (std::string(ext_str).find("cl_khr_gl_sharing") == std::string::npos){
|
||||||
|
std::cout << "No support for the cl_khr_gl_sharing extension";
|
||||||
|
cl_khr_gl_sharing_fallback = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete ext_str;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int CL_Wrapper::create_cl_context() {
|
||||||
|
|
||||||
|
// If the device doesn't support sharing then we have to create a regular context
|
||||||
|
cl_context_properties context_properties[] = {
|
||||||
|
CL_CONTEXT_PLATFORM, (cl_context_properties)platform_id
|
||||||
|
};
|
||||||
|
|
||||||
|
context = clCreateContext(
|
||||||
|
context_properties,
|
||||||
|
1,
|
||||||
|
&device_id,
|
||||||
|
nullptr, nullptr,
|
||||||
|
&error
|
||||||
|
);
|
||||||
|
|
||||||
|
if (assert(error, "clCreateContext"))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int CL_Wrapper::create_shared_context() {
|
int CL_Wrapper::create_shared_context() {
|
||||||
|
|
||||||
// Hurray for standards!
|
// Hurray for standards!
|
||||||
// Setup the context properties to grab the current GL context
|
// Setup the context properties to grab the current GL context
|
||||||
|
|
||||||
#ifdef linux
|
#ifdef linux
|
||||||
|
|
||||||
cl_context_properties context_properties[] = {
|
cl_context_properties context_properties[] = {
|
||||||
CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(),
|
CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(),
|
||||||
CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(),
|
CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(),
|
||||||
CL_CONTEXT_PLATFORM, (cl_context_properties)platform,
|
CL_CONTEXT_PLATFORM, (cl_context_properties)platform_id,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
#elif defined _WIN32
|
#elif defined _WIN32
|
||||||
|
|
||||||
// TODO: Clean this up next time I'm on a windows machine
|
|
||||||
//cl_context_properties context_properties[] = {
|
|
||||||
// CL_CONTEXT_PLATFORM, (cl_context_properties) platformIds[0],
|
|
||||||
// CL_GL_CONTEXT_KHR, (cl_context_properties) wglGetCurrentContext(),
|
|
||||||
// CL_WGL_HDC_KHR, (cl_context_properties) wglGetCurrentDC(),
|
|
||||||
// 0
|
|
||||||
//};
|
|
||||||
HGLRC hGLRC = wglGetCurrentContext();
|
HGLRC hGLRC = wglGetCurrentContext();
|
||||||
HDC hDC = wglGetCurrentDC();
|
HDC hDC = wglGetCurrentDC();
|
||||||
cl_context_properties context_properties[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)platform_id, CL_GL_CONTEXT_KHR, (cl_context_properties)hGLRC, CL_WGL_HDC_KHR, (cl_context_properties)hDC, 0 };
|
cl_context_properties context_properties[] = {
|
||||||
|
CL_CONTEXT_PLATFORM, (cl_context_properties)platform_id,
|
||||||
|
CL_GL_CONTEXT_KHR, (cl_context_properties)hGLRC,
|
||||||
|
CL_WGL_HDC_KHR, (cl_context_properties)hDC,
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#elif defined TARGET_OS_MAC
|
#elif defined TARGET_OS_MAC
|
||||||
|
|
||||||
CGLContextObj glContext = CGLGetCurrentContext();
|
CGLContextObj glContext = CGLGetCurrentContext();
|
||||||
CGLShareGroupObj shareGroup = CGLGetShareGroup(glContext);
|
CGLShareGroupObj shareGroup = CGLGetShareGroup(glContext);
|
||||||
cl_context_properties context_properties[] = {
|
cl_context_properties context_properties[] = {
|
||||||
@@ -237,9 +284,9 @@ int CL_Wrapper::set_kernel_arg(
|
|||||||
|
|
||||||
int CL_Wrapper::create_buffer(std::string buffer_name, cl_uint size, void* data, cl_mem_flags flags) {
|
int CL_Wrapper::create_buffer(std::string buffer_name, cl_uint size, void* data, cl_mem_flags flags) {
|
||||||
|
|
||||||
cl_mem buff = clCreateBuffer(
|
cl_mem buff = clCreateBuffer(
|
||||||
getContext(), flags,
|
getContext(), flags,
|
||||||
size, data, &error
|
size, data, &error
|
||||||
);
|
);
|
||||||
|
|
||||||
if (assert(error, "clCreateBuffer"))
|
if (assert(error, "clCreateBuffer"))
|
||||||
@@ -253,9 +300,9 @@ int CL_Wrapper::create_buffer(std::string buffer_name, cl_uint size, void* data,
|
|||||||
|
|
||||||
int CL_Wrapper::create_buffer(std::string buffer_name, cl_uint size, void* data) {
|
int CL_Wrapper::create_buffer(std::string buffer_name, cl_uint size, void* data) {
|
||||||
|
|
||||||
cl_mem buff = clCreateBuffer(
|
cl_mem buff = clCreateBuffer(
|
||||||
getContext(), CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
getContext(), CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||||
size, data, &error
|
size, data, &error
|
||||||
);
|
);
|
||||||
|
|
||||||
if (assert(error, "clCreateBuffer"))
|
if (assert(error, "clCreateBuffer"))
|
||||||
@@ -278,8 +325,8 @@ int CL_Wrapper::run_kernel(std::string kernel_name, const int work_size){
|
|||||||
|
|
||||||
cl_kernel kernel = kernel_map.at(kernel_name);
|
cl_kernel kernel = kernel_map.at(kernel_name);
|
||||||
|
|
||||||
error = clEnqueueAcquireGLObjects(getCommandQueue(), 1, &buffer_map.at("image_buffer"), 0, 0, 0);
|
error = clEnqueueAcquireGLObjects(getCommandQueue(), 1, &buffer_map.at("image_buffer"), 0, 0, 0);
|
||||||
if (assert(error, "clEnqueueAcquireGLObjects"))
|
if (assert(error, "clEnqueueAcquireGLObjects"))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
//error = clEnqueueTask(command_queue, kernel, 0, NULL, NULL);
|
//error = clEnqueueTask(command_queue, kernel, 0, NULL, NULL);
|
||||||
@@ -294,8 +341,8 @@ int CL_Wrapper::run_kernel(std::string kernel_name, const int work_size){
|
|||||||
clFinish(getCommandQueue());
|
clFinish(getCommandQueue());
|
||||||
|
|
||||||
// What if errors out and gl objects are never released?
|
// What if errors out and gl objects are never released?
|
||||||
error = clEnqueueReleaseGLObjects(getCommandQueue(), 1, &buffer_map.at("image_buffer"), 0, NULL, NULL);
|
error = clEnqueueReleaseGLObjects(getCommandQueue(), 1, &buffer_map.at("image_buffer"), 0, NULL, NULL);
|
||||||
if (assert(error, "clEnqueueReleaseGLObjects"))
|
if (assert(error, "clEnqueueReleaseGLObjects"))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
39
src/Map.cpp
39
src/Map.cpp
@@ -1,9 +1,4 @@
|
|||||||
#pragma once
|
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
#include <iostream>
|
|
||||||
#include <SFML/System/Vector3.hpp>
|
|
||||||
#include <SFML/System/Vector2.hpp>
|
|
||||||
#include "util.hpp"
|
|
||||||
|
|
||||||
Map::Map(sf::Vector3i position) {
|
Map::Map(sf::Vector3i position) {
|
||||||
|
|
||||||
@@ -136,24 +131,24 @@ void Map::generate_octree() {
|
|||||||
// ////// for (int y = 0; y < dim.y; y++) {
|
// ////// for (int y = 0; y < dim.y; y++) {
|
||||||
// //// double height = 0;
|
// //// double height = 0;
|
||||||
//
|
//
|
||||||
// //// z += -x*2 * std::sin(std::sqrt(abs(x*2 - y*2 - 47))) -
|
// //// z += -x*2 * std::sin(std::sqrt(abs(x*2 - y*2 - 47))) -
|
||||||
// //// (y*2 + 47) * std::sin(std::sqrt(std::abs(y*2 + 47 + x*2 / 2)));
|
// //// (y*2 + 47) * std::sin(std::sqrt(std::abs(y*2 + 47 + x*2 / 2)));
|
||||||
// ////
|
// ////
|
||||||
//
|
//
|
||||||
// //// //z += x * std::sin(std::sqrt(std::abs(y - x + 1))) *
|
// //// //z += x * std::sin(std::sqrt(std::abs(y - x + 1))) *
|
||||||
// //// // std::cos(std::sqrt(std::abs(y + x + 1))) +
|
// //// // std::cos(std::sqrt(std::abs(y + x + 1))) +
|
||||||
// //// // (y + 1) *
|
// //// // (y + 1) *
|
||||||
// //// // std::cos(std::sqrt(std::abs(y - x + 1))) *
|
// //// // std::cos(std::sqrt(std::abs(y - x + 1))) *
|
||||||
// //// // std::sin(std::sqrt(std::abs(y + x + 1)));
|
// //// // std::sin(std::sqrt(std::abs(y + x + 1)));
|
||||||
// ////
|
// ////
|
||||||
// //// // Pathological
|
// //// // Pathological
|
||||||
// //// //z += 0.5 +
|
// //// //z += 0.5 +
|
||||||
// //// // (std::pow(std::sin(std::sqrt(100 * std::pow(x/20, 2) + std::pow(y/20, 2))), 2) - 0.5) /
|
// //// // (std::pow(std::sin(std::sqrt(100 * std::pow(x/20, 2) + std::pow(y/20, 2))), 2) - 0.5) /
|
||||||
// //// // (1 + 0.001 * std::pow(std::pow(x/20, 2) - 2 * x/20 * y/20 + std::pow(y/20, 2), 2));
|
// //// // (1 + 0.001 * std::pow(std::pow(x/20, 2) - 2 * x/20 * y/20 + std::pow(y/20, 2), 2));
|
||||||
//
|
//
|
||||||
// //// // Ackleys
|
// //// // Ackleys
|
||||||
// //// //z += 20 + M_E -
|
// //// //z += 20 + M_E -
|
||||||
// //// // (20 / (std::pow(M_E, 0.2) * std::sqrt((std::pow(x / 16.0, 2) + std::pow(y / 16.0, 2) + 1) / 2))) -
|
// //// // (20 / (std::pow(M_E, 0.2) * std::sqrt((std::pow(x / 16.0, 2) + std::pow(y / 16.0, 2) + 1) / 2))) -
|
||||||
// //// // std::pow(M_E, 0.5 * std::cos(2 * M_PI * x / 16.0) + cos(2 * M_PI * y / 16.0));
|
// //// // std::pow(M_E, 0.5 * std::cos(2 * M_PI * x / 16.0) + cos(2 * M_PI * y / 16.0));
|
||||||
//
|
//
|
||||||
// //// //
|
// //// //
|
||||||
@@ -365,18 +360,6 @@ void Map::setVoxel(sf::Vector3i world_position, int val) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Map::moveLight(sf::Vector2f in) {
|
|
||||||
//
|
|
||||||
// sf::Vector3f light_spherical = CartToSphere(global_light);
|
|
||||||
//
|
|
||||||
// light_spherical.y += in.y;
|
|
||||||
// light_spherical.x += in.x;
|
|
||||||
//
|
|
||||||
// global_light = SphereToCart(light_spherical);
|
|
||||||
//
|
|
||||||
// return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Chunk::set(int type) {
|
void Chunk::set(int type) {
|
||||||
for (int i = 0; i < CHUNK_DIM * CHUNK_DIM * CHUNK_DIM; i++) {
|
for (int i = 0; i < CHUNK_DIM * CHUNK_DIM * CHUNK_DIM; i++) {
|
||||||
voxel_data[i] = 0;
|
voxel_data[i] = 0;
|
||||||
|
|||||||
@@ -1,138 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifdef linux
|
|
||||||
|
|
||||||
#elif defined _WIN32
|
|
||||||
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
|
|
||||||
#include <CL/cl_gl.h>
|
|
||||||
#include <CL/cl.h>
|
|
||||||
#include <CL/opencl.h>
|
|
||||||
|
|
||||||
#elif defined TARGET_OS_MAC
|
|
||||||
# include <OpenGL/OpenGL.h>
|
|
||||||
# include <OpenCL/opencl.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef TARGET_OS_MAC
|
|
||||||
int IsExtensionSupported(
|
|
||||||
const char* support_str,
|
|
||||||
const char* ext_string,
|
|
||||||
size_t ext_buffer_size) {
|
|
||||||
|
|
||||||
size_t offset = 0;
|
|
||||||
|
|
||||||
const char* space_substr = strnstr(ext_string + offset, " ", ext_buffer_size - offset);
|
|
||||||
|
|
||||||
size_t space_pos = space_substr ? space_substr - ext_string : 0;
|
|
||||||
|
|
||||||
while (space_pos < ext_buffer_size) {
|
|
||||||
|
|
||||||
if( strncmp(support_str, ext_string + offset, space_pos) == 0 ) {
|
|
||||||
// Device supports requested extension!
|
|
||||||
printf("Info: Found extension support ‘%s’!\n", support_str);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Keep searching -- skip to next token string
|
|
||||||
offset = space_pos + 1;
|
|
||||||
space_substr = strnstr(ext_string + offset, " ", ext_buffer_size - offset);
|
|
||||||
space_pos = space_substr ? space_substr - ext_string : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "Warning: Extension not supported " << support_str << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline int test_for_gl_cl_sharing() {
|
|
||||||
|
|
||||||
|
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
#if defined (__APPLE__) || defined(MACOSX)
|
|
||||||
static const char *CL_GL_SHARING_EXT = "cl_APPLE_gl_sharing";
|
|
||||||
#else
|
|
||||||
static const char* CL_GL_SHARING_EXT = "cl_khr_gl_sharing";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cl_uint num_devices;
|
|
||||||
clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, 0, NULL, &num_devices);
|
|
||||||
|
|
||||||
cl_device_id *devices = (cl_device_id *) calloc(sizeof(cl_device_id), num_devices);
|
|
||||||
clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, num_devices, devices, NULL);
|
|
||||||
|
|
||||||
// Get string containing supported device extensions
|
|
||||||
size_t ext_size = 1024;
|
|
||||||
char *ext_string = (char *) malloc(ext_size);
|
|
||||||
err = clGetDeviceInfo(devices[0], CL_DEVICE_EXTENSIONS, ext_size, ext_string, &ext_size);
|
|
||||||
|
|
||||||
free(devices);
|
|
||||||
|
|
||||||
// Search for GL support in extension string (space delimited)
|
|
||||||
//int supported = IsExtensionSupported(CL_GL_SHARING_EXT, ext_string, ext_size);
|
|
||||||
int supported = 0;
|
|
||||||
if (supported) {
|
|
||||||
// Device supports context sharing with OpenGL
|
|
||||||
printf("Found GL Sharing Support!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline int query_platform_devices() {
|
|
||||||
|
|
||||||
int error = 0;
|
|
||||||
// Get the number of platforms
|
|
||||||
cl_uint platform_count = 0;
|
|
||||||
clGetPlatformIDs(0, nullptr, &platform_count);
|
|
||||||
|
|
||||||
// Fetch the platforms
|
|
||||||
std::vector<cl_platform_id> platformIds(platform_count);
|
|
||||||
clGetPlatformIDs(platform_count, platformIds.data(), nullptr);
|
|
||||||
|
|
||||||
|
|
||||||
for (unsigned int q = 0; q < platform_count; q++) {
|
|
||||||
|
|
||||||
// From stackoverflow, gets and lists the compute devices
|
|
||||||
cl_uint num_devices, i;
|
|
||||||
error = clGetDeviceIDs(platformIds[q], CL_DEVICE_TYPE_ALL, 0, NULL, &num_devices);
|
|
||||||
|
|
||||||
cl_device_id *devices = (cl_device_id *)calloc(sizeof(cl_device_id), num_devices);
|
|
||||||
error = clGetDeviceIDs(platformIds[q], CL_DEVICE_TYPE_ALL, num_devices, devices, NULL);
|
|
||||||
|
|
||||||
char buf[128];
|
|
||||||
for (i = 0; i < num_devices; i++) {
|
|
||||||
clGetDeviceInfo(devices[i], CL_DEVICE_NAME, 128, buf, NULL);
|
|
||||||
fprintf(stdout, "Device %s supports ", buf);
|
|
||||||
|
|
||||||
clGetDeviceInfo(devices[i], CL_DEVICE_VERSION, 128, buf, NULL);
|
|
||||||
fprintf(stdout, "%s\n", buf);
|
|
||||||
|
|
||||||
|
|
||||||
//cl_device_type a;
|
|
||||||
//clGetDeviceInfo(devices[i], CL_DEVICE_TYPE, 128, &a, NULL);
|
|
||||||
//std::cout << a << std::endl;
|
|
||||||
|
|
||||||
//cl_uint b;
|
|
||||||
//clGetDeviceInfo(devices[i], CL_DEVICE_MAX_CLOCK_FREQUENCY, 128, &b, NULL);
|
|
||||||
//std::cout << b << std::endl;
|
|
||||||
|
|
||||||
//cl_uint c;
|
|
||||||
//clGetDeviceInfo(devices[i], CL_DEVICE_MAX_COMPUTE_UNITS, 128, &c, NULL);
|
|
||||||
//std::cout << c << std::endl;
|
|
||||||
|
|
||||||
std::cout << devices[i] << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(devices);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
26
src/main.cpp
26
src/main.cpp
@@ -25,7 +25,6 @@
|
|||||||
#include <OpenCL/cl_ext.h>
|
#include <OpenCL/cl_ext.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#include "TestPlatform.cpp"
|
|
||||||
#include "Map.h"
|
#include "Map.h"
|
||||||
#include "Curses.h"
|
#include "Curses.h"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
@@ -65,21 +64,14 @@ sf::Texture window_texture;
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
|
CL_Wrapper c;
|
||||||
|
|
||||||
Map m(sf::Vector3i (50, 50, 50));
|
//Map m(sf::Vector3i (50, 50, 50));
|
||||||
m.generate_octree();
|
//m.generate_octree();
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
//sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML");
|
//sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML");
|
||||||
|
|
||||||
//// Setup CL, instantiate and pass in values to the kernel
|
|
||||||
//CL_Wrapper c;
|
|
||||||
//query_platform_devices();
|
|
||||||
//c.acquire_platform_and_device();
|
|
||||||
//c.create_shared_context();
|
|
||||||
//c.create_command_queue();
|
|
||||||
|
|
||||||
//if (c.compile_kernel("../kernels/ray_caster_kernel.cl", true, "min_kern") < 0) {
|
//if (c.compile_kernel("../kernels/ray_caster_kernel.cl", true, "min_kern") < 0) {
|
||||||
// std::cin.get();
|
// std::cin.get();
|
||||||
// return -1;
|
// return -1;
|
||||||
@@ -320,15 +312,15 @@ int main() {
|
|||||||
// // ==== DELTA TIME LOCKED ====
|
// // ==== DELTA TIME LOCKED ====
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// float l[] = {
|
// float l[] = {
|
||||||
// light[9] * sin(delta_time / 1) + light[7] * cos(delta_time / 1),
|
// light[9] * sin(delta_time / 1) + light[7] * cos(delta_time / 1),
|
||||||
// light[8],
|
// light[8],
|
||||||
// light[9] * cos(delta_time / 1) - light[7] * sin(delta_time / 1)
|
// light[9] * cos(delta_time / 1) - light[7] * sin(delta_time / 1)
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// float l2[] = {
|
// float l2[] = {
|
||||||
// l[0] * cos(delta_time) - l[2] * sin(delta_time),
|
// l[0] * cos(delta_time) - l[2] * sin(delta_time),
|
||||||
// l[0] * sin(delta_time) + l[2] * cos(delta_time),
|
// l[0] * sin(delta_time) + l[2] * cos(delta_time),
|
||||||
// l[2]
|
// l[2]
|
||||||
// };
|
// };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user