Switched names, thinking about how to do kernel args, and buffers.

Need to do a bit more reading on how to set up interop.
Also need to figure out the buffer thing for regular primative buffers, and also image buffers
This commit is contained in:
2016-08-28 22:40:29 -07:00
parent 5dea2494a0
commit 0c70c24a52
7 changed files with 193 additions and 40 deletions

View File

@@ -1,13 +1,13 @@
#include "Clapper.h"
#include "CL_Wrapper.h"
Clapper::Clapper() {
CL_Wrapper::CL_Wrapper() {
}
Clapper::~Clapper() {
CL_Wrapper::~CL_Wrapper() {
}
int Clapper::acquire_platform_and_device(){
int CL_Wrapper::acquire_platform_and_device(){
// Get the number of platforms
cl_uint plt_cnt = 0;
@@ -84,7 +84,7 @@ int Clapper::acquire_platform_and_device(){
return 0;
};
int Clapper::create_shared_context() {
int CL_Wrapper::create_shared_context() {
// Hurray for standards!
// Setup the context properties to grab the current GL context
@@ -137,19 +137,24 @@ int Clapper::create_shared_context() {
return 0;
}
int Clapper::create_command_queue(){
int CL_Wrapper::create_command_queue(){
// / And the cl command queue
auto commandQueue = clCreateCommandQueue(context, device_id, 0, &error);
if (context && device_id) {
// And the cl command queue
command_queue = clCreateCommandQueue(context, device_id, 0, &error);
if (assert(error, "clCreateCommandQueue"))
if (assert(error, "clCreateCommandQueue"))
return -1;
return 0;
}
else {
std::cout << "Failed creating the command queue, context or device_id not initialized";
return -1;
return 0;
}
}
int Clapper::compile_kernel(std::string kernel_source, bool is_path, std::string kernel_name) {
int CL_Wrapper::compile_kernel(std::string kernel_source, bool is_path, std::string kernel_name) {
const char* source;
@@ -202,11 +207,47 @@ int Clapper::compile_kernel(std::string kernel_source, bool is_path, std::string
kernel_map.emplace(std::make_pair(kernel_name, kernel));
}
cl_device_id Clapper::getDeviceID(){ return device_id; };
cl_platform_id Clapper::getPlatformID(){ return platform_id; };
cl_context Clapper::getContext(){ return context; };
int CL_Wrapper::set_kernel_arg(
cl_kernel kernel,
int index,
int size,
void* buffer,
std::string kernel_name){
bool Clapper::assert(int error_code, std::string function_name){
};
int CL_Wrapper::store_buffer(cl_mem, std::string buffer_name){
buffer_map.emplace(std::make_pair(buffer_name, cl_mem));
};
int CL_Wrapper::run_kernel(std::string kernel_name){
WORKER_SIZE = 10;
size_t global_work_size[1] = { WORKER_SIZE };
cl_mem kernel = kernel_map.at(kernel_name);
error = clEnqueueNDRangeKernel(
command_queue, kernel,
1, NULL, global_work_size,
NULL, 0, NULL, NULL);
if (assert(error, "clCreateCommandQueue"))
return -1;
};
cl_device_id CL_Wrapper::getDeviceID(){ return device_id; };
cl_platform_id CL_Wrapper::getPlatformID(){ return platform_id; };
cl_context CL_Wrapper::getContext(){ return context; };
bool CL_Wrapper::assert(int error_code, std::string function_name){
// Just gonna do a little jump table here, just error codes so who cares
std::string err_msg = "Error : ";

View File

@@ -27,7 +27,7 @@
#include "Curses.h"
#include "util.hpp"
#include "RayCaster.h"
#include "Clapper.h"
#include "CL_Wrapper.h"
const int WINDOW_X = 150;
const int WINDOW_Y = 150;
@@ -36,7 +36,7 @@ const int WINDOW_Y = 150;
int main(){
Clapper c;
CL_Wrapper c;
c.acquire_platform_and_device();
c.create_shared_context();