@ -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 ) {