2022-12-03 11:54:34 -05:00
|
|
|
/*
|
|
|
|
* Created by Brett Terpstra 6920201 on 03/12/22.
|
|
|
|
* Copyright (c) 2022 Brett Terpstra. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* contains the opencl raytracing code. The file name is a pun (I hope that was implied otherwise I guess I'm lame)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef STEP_3_OPEN_RAY_TRACING_H
|
|
|
|
#define STEP_3_OPEN_RAY_TRACING_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <engine/util/std.h>
|
|
|
|
#include <config.h>
|
|
|
|
#include <engine/image/image.h>
|
|
|
|
#include <engine/types.h>
|
|
|
|
#include <engine/world.h>
|
|
|
|
#include <engine/util/memory_util.h>
|
|
|
|
|
|
|
|
#ifdef COMPILE_OPENCL
|
|
|
|
|
|
|
|
#include <opencl/cl.h>
|
2022-12-10 14:25:09 -05:00
|
|
|
#include "engine/raytracing.h"
|
2022-12-03 11:54:34 -05:00
|
|
|
|
|
|
|
namespace Raytracing {
|
|
|
|
|
|
|
|
class OpenClRaytracer {
|
|
|
|
private:
|
|
|
|
CLProgram* program;
|
|
|
|
Image& image;
|
2022-12-12 02:07:59 -05:00
|
|
|
Camera& camera;
|
2022-12-03 11:54:34 -05:00
|
|
|
size_t localWorks[2]{8, 8};
|
2022-12-10 14:25:09 -05:00
|
|
|
size_t maxTriangleSize = 0;
|
|
|
|
size_t objectCount = 0;
|
2022-12-03 11:54:34 -05:00
|
|
|
public:
|
2022-12-10 14:25:09 -05:00
|
|
|
OpenClRaytracer(const std::string& programLocation, Image& image, Camera& camera, World& world);
|
2022-12-03 11:54:34 -05:00
|
|
|
|
|
|
|
~OpenClRaytracer();
|
|
|
|
|
2022-12-10 14:25:09 -05:00
|
|
|
void storeObjects(unsigned char* buffer, size_t totalWorldBytes);
|
2022-12-12 02:07:59 -05:00
|
|
|
void updateCameraInformation();
|
2022-12-10 14:25:09 -05:00
|
|
|
|
|
|
|
unsigned char* createObjectBuffer(const std::vector<Object*>& objects, size_t totalWorldBytes);
|
2022-12-03 11:54:34 -05:00
|
|
|
|
|
|
|
void run();
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif //STEP_3_OPEN_RAY_TRACING_H
|