Added display for settings buffer data

master
mitchellhansen 7 years ago
parent 6464fceece
commit d431352e8f

@ -156,7 +156,10 @@ public:
bool create_settings_buffer(); bool create_settings_buffer();
bool release_settings_buffer(); bool release_settings_buffer();
bool add_to_settings_buffer(std::string setting_name, std::string define_accessor_name, int64_t *value);
template<typename T>
bool add_to_settings_buffer(std::string setting_name, std::string define_accessor_name, T value);
bool overwrite_setting(std::string settings_name, int64_t *value); bool overwrite_setting(std::string settings_name, int64_t *value);
bool remove_from_settings_buffer(std::string setting_name); bool remove_from_settings_buffer(std::string setting_name);
@ -175,6 +178,9 @@ public:
virtual void event_handler(VrEventPublisher *publisher, std::unique_ptr<vr::Event> event) override; virtual void event_handler(VrEventPublisher *publisher, std::unique_ptr<vr::Event> event) override;
bool decimal = false;
bool hex = false;
bool binary = false;
// ================================ // ================================
private: private:

@ -33,11 +33,11 @@ bool Application::init_clcaster() {
if (!raycaster->init()) if (!raycaster->init())
abort(); abort();
raycaster->add_to_settings_buffer("octree_dimensions", "OCTDIM", (int64_t*)&MAP_X); raycaster->add_to_settings_buffer("octree_dimensions", "OCTDIM", MAP_X);
// TODO: ALLOW RVALUES FOR SETTINGS BUFFER // TODO: ALLOW RVALUES FOR SETTINGS BUFFER
int64_t oct_enabled = 0; int64_t oct_enabled = 0;
raycaster->add_to_settings_buffer("using_octree", "OCTENABLED", &oct_enabled); raycaster->add_to_settings_buffer("using_octree", "OCTENABLED", oct_enabled);
map = std::make_shared<Map>(MAP_X); map = std::make_shared<Map>(MAP_X);

@ -1,3 +1,4 @@
#include <iomanip>
#include "CLCaster.h" #include "CLCaster.h"
CLCaster::CLCaster() {} CLCaster::CLCaster() {}
@ -109,7 +110,7 @@ bool CLCaster::assign_octree(std::shared_ptr<Map> map) {
if (!create_buffer("octree_attachment_buffer", map->octree.buffer_size * sizeof(uint64_t), map->octree.attachment_buffer)) if (!create_buffer("octree_attachment_buffer", map->octree.buffer_size * sizeof(uint64_t), map->octree.attachment_buffer))
return false; return false;
add_to_settings_buffer("octree_root_index", "OCTREE_ROOT_INDEX", (int64_t*)&map->octree.root_index); add_to_settings_buffer("octree_root_index", "OCTREE_ROOT_INDEX", map->octree.root_index);
return true; return true;
} }
@ -356,6 +357,58 @@ void CLCaster::render_gui() {
}; };
} }
ImGui::Checkbox("HEX", &hex); ImGui::SameLine();
ImGui::Checkbox("DECIMAL", &decimal); ImGui::SameLine();
ImGui::Checkbox("BINARY", &binary);
std::stringstream ss;
int columns = 1;
if (binary) {columns++;} if (decimal) {columns++;} if (hex) {columns++;}
ImGui::Columns(columns, NULL, true);
for (auto const& x : settings_buffer_indices) {
int offset = 150;
int count = 1;
ImGui::Text(x.first.c_str());
ImGui::NextColumn();
if (decimal) {
ImGui::SetColumnOffset(count, offset);
offset += 150; count++;
ss << std::dec << std::to_string(settings_buffer[x.second]);
ImGui::Text(ss.str().c_str());
ss.clear();
ss.str("");
ImGui::NextColumn();
}
if (hex){
ImGui::SetColumnOffset(count, offset);
offset += 150; count++;
ss << "0x" << std::setfill ('0') << std::setw(sizeof(int64_t)*2) << std::hex << settings_buffer[x.second];
ImGui::Text(ss.str().c_str());
ss.clear();
ss.str("");
ImGui::NextColumn();
}
if (binary) {
ImGui::SetColumnOffset(count, offset);
offset += 150; count++;
ss << "b" << std::setfill('0') << std::setw(sizeof(int64_t) * 2) << std::bitset<64>(settings_buffer[x.second]);
ImGui::Text(ss.str().c_str());
ss.clear();
ss.str("");
ImGui::NextColumn();
}
}
ImGui::End(); ImGui::End();
} }
@ -967,6 +1020,98 @@ bool CLCaster::cl_assert(int error_code) {
} }
void CLCaster::set_define(std::string name, std::string value) {
defines_map[name] = value;
}
void CLCaster::remove_define(std::string name) {
defines_map.erase(name);
}
template<typename T>
bool CLCaster::add_to_settings_buffer(std::string setting_name, std::string define_accessor_name, T value) {
bool success = true;
if (settings_buffer == nullptr){
Logger::log("Trying to push settings to an uninitialized settings buffer", Logger::LogLevel::ERROR, __LINE__, __FILE__);
success = false;
} else if (defines_map.count(define_accessor_name)) {
Logger::log("Define name already present in the defines map", Logger::LogLevel::ERROR, __LINE__, __FILE__);
success = false;
} else {
if (settings_buffer_position < SETTINGS_BUFFER_SIZE) {
defines_map[define_accessor_name] = std::to_string(settings_buffer_position);
settings_buffer[settings_buffer_position] = (int64_t)value;
settings_buffer_indices[setting_name] = settings_buffer_position;
settings_buffer_position++;
} else {
Logger::log("Settings buffer has reached the maximum size of " + std::to_string(SETTINGS_BUFFER_SIZE) + " elements", Logger::LogLevel::ERROR, __LINE__, __FILE__);
success = false;
}
}
return success;
}
template bool CLCaster::add_to_settings_buffer(std::string, std::string, int);
template bool CLCaster::add_to_settings_buffer(std::string, std::string, long);
template bool CLCaster::add_to_settings_buffer(std::string, std::string, bool);
template bool CLCaster::add_to_settings_buffer(std::string, std::string, char);
template bool CLCaster::add_to_settings_buffer(std::string, std::string, uint64_t);
bool CLCaster::create_settings_buffer() {
settings_buffer = new int64_t[SETTINGS_BUFFER_SIZE]();
if (!create_buffer("settings_buffer", sizeof(int64_t) * SETTINGS_BUFFER_SIZE, settings_buffer, CL_MEM_USE_HOST_PTR))
return false;
return true;
}
bool CLCaster::remove_from_settings_buffer(std::string setting_name) {
Logger::log("remove_from_settings_buffer() not implimented", Logger::LogLevel::WARN, __LINE__, __FILE__);
return false;
}
bool CLCaster::release_settings_buffer() {
if (!release_buffer("settings_buffer"))
return false;
return true;
}
bool CLCaster::overwrite_setting(std::string settings_name, int64_t *value) {
bool success = true;
if (settings_buffer == nullptr){
Logger::log("Trying to push settings to an uninitialized settings buffer", Logger::LogLevel::ERROR, __LINE__, __FILE__);
success = false;
} else {
if (settings_buffer_indices.count(settings_name)) {
unsigned int postion = settings_buffer_indices[settings_name];
settings_buffer[postion] = *value;
} else {
Logger::log("No setting matching [" + settings_name +"]", Logger::LogLevel::ERROR, __LINE__, __FILE__);
success = false;
}
}
return success;
}
std::string CLCaster::cl_err_lookup(int error_code) { std::string CLCaster::cl_err_lookup(int error_code) {
std::string err_msg = ""; std::string err_msg = "";
@ -1167,87 +1312,14 @@ std::string CLCaster::cl_err_lookup(int error_code) {
} }
void CLCaster::set_define(std::string name, std::string value) {
defines_map[name] = value;
}
void CLCaster::remove_define(std::string name) {
defines_map.erase(name);
}
bool CLCaster::add_to_settings_buffer(std::string setting_name, std::string define_accessor_name, int64_t *value) {
bool success = true;
if (settings_buffer == nullptr){
Logger::log("Trying to push settings to an uninitialized settings buffer", Logger::LogLevel::ERROR, __LINE__, __FILE__);
success = false;
} else if (defines_map.count(define_accessor_name)) {
Logger::log("Define name already present in the defines map", Logger::LogLevel::ERROR, __LINE__, __FILE__);
success = false;
} else {
if (settings_buffer_position < SETTINGS_BUFFER_SIZE) {
defines_map[define_accessor_name] = std::to_string(settings_buffer_position);
settings_buffer[settings_buffer_position] = *value;
settings_buffer_position++;
} else {
Logger::log("Settings buffer has reached the maximum size of " + std::to_string(SETTINGS_BUFFER_SIZE) + " elements", Logger::LogLevel::ERROR, __LINE__, __FILE__);
success = false;
}
}
return success;
}
bool CLCaster::create_settings_buffer() { /*
* ==================================================
settings_buffer = new int64_t[SETTINGS_BUFFER_SIZE]; *
if (!create_buffer("settings_buffer", sizeof(int64_t) * SETTINGS_BUFFER_SIZE, settings_buffer, CL_MEM_USE_HOST_PTR)) * CL DEVICE
return false; *
return true; * ==================================================
} */
bool CLCaster::remove_from_settings_buffer(std::string setting_name) {
Logger::log("remove_from_settings_buffer() not implimented", Logger::LogLevel::WARN, __LINE__, __FILE__);
return false;
}
bool CLCaster::release_settings_buffer() {
if (!release_buffer("settings_buffer"))
return false;
return true;
}
bool CLCaster::overwrite_setting(std::string settings_name, int64_t *value) {
bool success = true;
if (settings_buffer == nullptr){
Logger::log("Trying to push settings to an uninitialized settings buffer", Logger::LogLevel::ERROR, __LINE__, __FILE__);
success = false;
} else {
if (settings_buffer_indices.count(settings_name)) {
unsigned int postion = settings_buffer_indices[settings_name];
settings_buffer[postion] = *value;
} else {
Logger::log("No setting matching [" + settings_name +"]", Logger::LogLevel::ERROR, __LINE__, __FILE__);
success = false;
}
}
return success;
}
CLCaster::device::device(cl_device_id device_id, cl_platform_id platform_id) { CLCaster::device::device(cl_device_id device_id, cl_platform_id platform_id) {

Loading…
Cancel
Save