Got the octree data to the GPU and it's traversing it, but it having some corruption issues. Endianness???
This commit is contained in:
@@ -63,6 +63,7 @@ private:
|
||||
|
||||
std::shared_ptr<sf::RenderWindow> window;
|
||||
std::shared_ptr<Old_Map> map;
|
||||
std::shared_ptr<Map> octree;
|
||||
std::shared_ptr<Camera> camera;
|
||||
std::shared_ptr<CLCaster> raycaster;
|
||||
std::shared_ptr<LightHandle> light_handle;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <GL/glew.h>
|
||||
#include <unordered_map>
|
||||
#include "Logger.h"
|
||||
#include "map/Map.h"
|
||||
|
||||
#ifdef linux
|
||||
#include <CL/cl.h>
|
||||
@@ -86,23 +87,79 @@ struct PackedData;
|
||||
|
||||
class CLCaster {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
enum ERROR_CODES {
|
||||
SHARING_NOT_SUPPORTED = 800,
|
||||
OPENCL_NOT_SUPPORTED = 801,
|
||||
OPENCL_ERROR = 802,
|
||||
ERR = 803
|
||||
};
|
||||
/**
|
||||
* CLCaster is the beginning and end to all interaction with the GPU.
|
||||
*
|
||||
* It queries devices, manages the creation of various data structures as well
|
||||
* as they syncing between the GPU. It Handles computing of the cast as well
|
||||
* as rendering of the computed cast.
|
||||
*
|
||||
*/
|
||||
|
||||
CLCaster();
|
||||
virtual ~CLCaster();
|
||||
|
||||
// Queries hardware, creates the command queue and context, and compiles kernel
|
||||
bool init();
|
||||
|
||||
// Creates a texture to send to the GPU via height and width
|
||||
// Creates a viewport vector array via vertical and horizontal fov
|
||||
bool create_viewport(int width, int height, float v_fov, float h_fov) ;
|
||||
|
||||
// Light controllers own the copy of the PackedData array.
|
||||
// We receive a pointer to the array and USE_HOST_POINTER to map the memory to the GPU
|
||||
bool assign_lights(std::vector<PackedData> *data) ;
|
||||
|
||||
// We take a ptr to the map and create the map, and map_dimensions buffer for the GPU
|
||||
bool assign_map(std::shared_ptr<Old_Map> map);
|
||||
bool release_map();
|
||||
|
||||
// We take a ptr to the map and create the map, and map_dimensions buffer for the GPU
|
||||
bool assign_octree(std::shared_ptr<Map> octree);
|
||||
bool release_octree();
|
||||
|
||||
// We take a ptr to the camera and create a camera direction and position buffer
|
||||
bool assign_camera(std::shared_ptr<Camera> camera);
|
||||
bool release_camera();
|
||||
|
||||
// Creates 3 buffers relating to the texture atlas: texture_atlas, atlas_dim, and tile_dim
|
||||
// With these on the GPU we can texture any quad with an atlas tile
|
||||
bool create_texture_atlas(sf::Texture *t, sf::Vector2i tile_dim);
|
||||
|
||||
// Check to make sure that the buffers have been initiated and set them as kernel args
|
||||
bool validate() ;
|
||||
|
||||
// Aquires the GL objects, runs the kernel, releases back the GL objects
|
||||
bool compute() ;
|
||||
|
||||
// Take the viewport sprite and draw it to the screen
|
||||
void draw(sf::RenderWindow* window) ;
|
||||
|
||||
// Load the saved device config from a file
|
||||
bool load_config();
|
||||
|
||||
// Save the chosen device config to a file
|
||||
void save_config();
|
||||
// ================================== DEBUG =======================================
|
||||
|
||||
// Re compile the kernel and revalidate the args
|
||||
bool debug_quick_recompile();
|
||||
|
||||
// Modify the viewport matrix
|
||||
void test_edit_viewport(int width, int height, float v_fov, float h_fov);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Device is a storage container for device data we retrieve from OpenCL
|
||||
*
|
||||
* The data is mainly queries as strings or integer types and stored into
|
||||
* respective containers. We store this data into a file and retrieve it later
|
||||
* to let users select a preferred compute device and keep track of their choice
|
||||
*/
|
||||
* Device is a storage container for device data we retrieve from OpenCL
|
||||
*
|
||||
* The data is mainly queries as strings or integer types and stored into
|
||||
* respective containers. We store this data into a file and retrieve it later
|
||||
* to let users select a preferred compute device and keep track of their choice
|
||||
*/
|
||||
class device {
|
||||
|
||||
public:
|
||||
@@ -140,66 +197,6 @@ public:
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Hardware caster is the beginning and end to all interaction with the GPU.
|
||||
*
|
||||
* It queries devices, manages the creation of various data structures as well
|
||||
* as they syncing between the GPU. It Handles computing of the cast as well
|
||||
* as rendering of the computed cast.
|
||||
*
|
||||
*/
|
||||
CLCaster();
|
||||
virtual ~CLCaster();
|
||||
|
||||
|
||||
// Queries hardware, creates the command queue and context, and compiles kernel
|
||||
bool init();
|
||||
|
||||
// Creates a texture to send to the GPU via height and width
|
||||
// Creates a viewport vector array via vertical and horizontal fov
|
||||
bool create_viewport(int width, int height, float v_fov, float h_fov) ;
|
||||
|
||||
// Light controllers own the copy of the PackedData array.
|
||||
// We receive a pointer to the array and USE_HOST_POINTER to map the memory to the GPU
|
||||
bool assign_lights(std::vector<PackedData> *data) ;
|
||||
|
||||
// We take a ptr to the map and create the map, and map_dimensions buffer for the GPU
|
||||
bool assign_map(std::shared_ptr<Old_Map> map);
|
||||
bool release_map();
|
||||
|
||||
// We take a ptr to the camera and create a camera direction and position buffer
|
||||
bool assign_camera(std::shared_ptr<Camera> camera);
|
||||
bool release_camera();
|
||||
|
||||
// Creates 3 buffers relating to the texture atlas: texture_atlas, atlas_dim, and tile_dim
|
||||
// With these on the GPU we can texture any quad with an atlas tile
|
||||
bool create_texture_atlas(sf::Texture *t, sf::Vector2i tile_dim);
|
||||
|
||||
// Check to make sure that the buffers have been initiated and set them as kernel args
|
||||
bool validate() ;
|
||||
|
||||
// Aquires the GL objects, runs the kernel, releases back the GL objects
|
||||
bool compute() ;
|
||||
|
||||
// Take the viewport sprite and draw it to the screen
|
||||
void draw(sf::RenderWindow* window) ;
|
||||
|
||||
// Load the saved device config from a file
|
||||
bool load_config();
|
||||
|
||||
// Save the chosen device config to a file
|
||||
void save_config();
|
||||
// ================================== DEBUG =======================================
|
||||
|
||||
// Re compile the kernel and revalidate the args
|
||||
bool debug_quick_recompile();
|
||||
|
||||
// Modify the viewport matrix
|
||||
void test_edit_viewport(int width, int height, float v_fov, float h_fov);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Cycle through the OpenCL devices and store *all* of their data, not super useful
|
||||
bool query_hardware();
|
||||
|
||||
@@ -281,6 +278,7 @@ private:
|
||||
|
||||
std::shared_ptr<Camera> camera;
|
||||
std::shared_ptr<Old_Map> map;
|
||||
std::shared_ptr<Map> octree;
|
||||
|
||||
std::vector<PackedData> *lights;
|
||||
int light_count = 0;
|
||||
|
||||
@@ -7,10 +7,35 @@
|
||||
#include "CLCaster.h"
|
||||
#include "LightHandle.h"
|
||||
|
||||
|
||||
// Typical light workflow:
|
||||
// 1.) Create light prototype with desired values
|
||||
// 2.) Submit prototype to the LightController
|
||||
/**
|
||||
* Light Handle :
|
||||
* - Contains data relating to movement, and a reference to the rbgi, direction, and position
|
||||
* elements in the LightController.
|
||||
* - Resultant of the use of LightController.create_light(LightPrototype). Cannot be self instantiated.
|
||||
* - On deconstruction, light data is removed from the LightController via a reference and the light disappears
|
||||
*
|
||||
* LightPrototype :
|
||||
* - Contains the desired starting values for the light. The LightHandler object will then be
|
||||
* instantiated using this data
|
||||
*
|
||||
* PackedData :
|
||||
* - We need to single out the data that the GPU needs into a single contiguous
|
||||
* array. PackedData holds the values for position, direction, and rgbi
|
||||
*
|
||||
* LightController :
|
||||
* - Contains the PackedData array in a static sized array.
|
||||
* Empty light slots are set to 0 and still sent over the line
|
||||
* TODO: This introduces light limits and inefficiencies
|
||||
* - Contains a factory that takes LightPrototypes and generates unique ptr LightHandles.
|
||||
* Each light handle is given a light index enabling light removal.
|
||||
*
|
||||
* Typical light workflow:
|
||||
* 1.) Create light prototype with desired values
|
||||
* 2.) Submit prototype to the LightController
|
||||
* 3.) Get a light handle back from the controller
|
||||
* - The handle is unsafe and will break if it exceeds PackedData's lifetime
|
||||
*
|
||||
*/
|
||||
|
||||
struct LightPrototype {
|
||||
|
||||
@@ -56,8 +81,10 @@ public:
|
||||
LightController(std::shared_ptr<CLCaster> raycaster);
|
||||
~LightController();
|
||||
|
||||
// find a free light 'slot' and create
|
||||
// find a free light 'slot' and create the light
|
||||
// LightHandles are single instance single lifetime data structures
|
||||
std::shared_ptr<LightHandle> create_light(LightPrototype light_prototype);
|
||||
|
||||
void remove_light(unsigned int light_index);
|
||||
|
||||
void recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Event> event) override;
|
||||
|
||||
@@ -6,29 +6,6 @@
|
||||
#include "Vector4.hpp"
|
||||
|
||||
|
||||
// Light Handle :
|
||||
// - Contains data relating to movement, and a reference to the rbgi, direction, and position
|
||||
// elements in the LightController.
|
||||
// - Resultant of the use of LightController.create_light(LightPrototype). Cannot be self instantiated.
|
||||
// - On deconstruction, light data is removed from the LightController and the light disappears
|
||||
|
||||
// LightPrototype :
|
||||
// - Contains the desired starting values for the light. The LightHandler object will then be
|
||||
// instantiated using this data
|
||||
|
||||
// PackedData :
|
||||
// - We need to single out the data that the GPU needs into a single contiguous
|
||||
// array. PackedData holds the values for position, direction, and rgbi
|
||||
|
||||
// LightController :
|
||||
// - Contains the PackedData array in a static sized array.
|
||||
// Empty light slots are set to 0 and still sent over the line
|
||||
// TODO: This introduces light limits and inefficiencies
|
||||
// - Contains a factory that takes LightPrototypes and generates unique ptr LightHandles.
|
||||
// Each light handle is given a light index enabling light removal.
|
||||
|
||||
|
||||
|
||||
struct LightPrototype;
|
||||
class LightController;
|
||||
struct PackedData;
|
||||
|
||||
@@ -95,7 +95,7 @@ private:
|
||||
};
|
||||
|
||||
// Mask for counting the previous valid bits
|
||||
const uint8_t count_mask_8[8]{
|
||||
const uint8_t count_mask_8[8] = {
|
||||
0x1, 0x3, 0x7, 0xF,
|
||||
0x1F, 0x3F, 0x7F, 0xFF
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user