Having some performance issues on a new windows install. Going to pull device selection out to the GUI and do further testing
This commit is contained in:
@@ -43,6 +43,54 @@ struct device {
|
|||||||
bool cl_gl_sharing = false;
|
bool cl_gl_sharing = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct device_info {
|
||||||
|
cl_uint cl_device_address_bits;
|
||||||
|
cl_bool cl_device_available;
|
||||||
|
cl_bool cl_device_compiler_available;
|
||||||
|
cl_bool cl_device_endian_little;
|
||||||
|
cl_bool cl_device_error_correction_support;
|
||||||
|
char cl_device_extensions[1024];
|
||||||
|
cl_ulong cl_device_global_mem_cache_size;
|
||||||
|
cl_uint cl_device_global_mem_cacheline_size;
|
||||||
|
cl_ulong cl_device_global_mem_size;
|
||||||
|
cl_bool cl_device_image_support;
|
||||||
|
size_t cl_device_image2d_max_height;
|
||||||
|
size_t cl_device_image2d_max_width;
|
||||||
|
size_t cl_device_image3d_max_depth;
|
||||||
|
size_t cl_device_image3d_max_height;
|
||||||
|
size_t cl_device_image3d_max_width;
|
||||||
|
cl_ulong cl_device_local_mem_size;
|
||||||
|
cl_uint cl_device_max_clock_frequency;
|
||||||
|
cl_uint cl_device_max_compute_units;
|
||||||
|
cl_uint cl_device_max_constant_args;
|
||||||
|
cl_ulong cl_device_max_constant_buffer_size;
|
||||||
|
cl_ulong cl_device_max_mem_alloc_size;
|
||||||
|
size_t cl_device_max_parameter_size;
|
||||||
|
cl_uint cl_device_max_read_image_args;
|
||||||
|
cl_uint cl_device_max_samplers;
|
||||||
|
size_t cl_device_max_work_group_size;
|
||||||
|
cl_uint cl_device_max_work_item_dimensions;
|
||||||
|
size_t cl_device_max_work_item_sizes[3];
|
||||||
|
cl_uint cl_device_max_write_image_args;
|
||||||
|
cl_uint cl_device_mem_base_addr_align;
|
||||||
|
cl_uint cl_device_min_data_type_align_size;
|
||||||
|
char cl_device_name[128];
|
||||||
|
cl_platform_id cl_device_platform;
|
||||||
|
cl_uint cl_device_preferred_vector_width_char;
|
||||||
|
cl_uint cl_device_preferred_vector_width_short;
|
||||||
|
cl_uint cl_device_preferred_vector_width_int;
|
||||||
|
cl_uint cl_device_preferred_vector_width_long;
|
||||||
|
cl_uint cl_device_preferred_vector_width_float;
|
||||||
|
cl_uint cl_device_preferred_vector_width_double;
|
||||||
|
char cl_device_profile[256];
|
||||||
|
size_t cl_device_profiling_timer_resolution;
|
||||||
|
cl_device_type cl_device_type;
|
||||||
|
char cl_device_vendor[128];
|
||||||
|
cl_uint cl_device_vendor_id;
|
||||||
|
char cl_device_version[128];
|
||||||
|
char cl_driver_version[128];
|
||||||
|
};
|
||||||
|
|
||||||
struct raycaster_settings {
|
struct raycaster_settings {
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -98,6 +146,7 @@ public:
|
|||||||
// Modify the viewport matrix
|
// Modify the viewport matrix
|
||||||
void test_edit_viewport(int width, int height, float v_fov, float h_fov);
|
void test_edit_viewport(int width, int height, float v_fov, float h_fov);
|
||||||
|
|
||||||
|
void gui();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -105,6 +154,8 @@ private:
|
|||||||
// Also checks for the sharing extension
|
// Also checks for the sharing extension
|
||||||
int acquire_platform_and_device();
|
int acquire_platform_and_device();
|
||||||
|
|
||||||
|
int query_hardware();
|
||||||
|
|
||||||
// With respect to the individual platforms implementation of sharing
|
// With respect to the individual platforms implementation of sharing
|
||||||
// create a shared cl_gl context
|
// create a shared cl_gl context
|
||||||
int create_shared_context();
|
int create_shared_context();
|
||||||
|
|||||||
42
src/main.cpp
42
src/main.cpp
@@ -40,12 +40,12 @@
|
|||||||
#include "imgui/imgui-SFML.h"
|
#include "imgui/imgui-SFML.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
|
|
||||||
const int WINDOW_X = 1440;
|
const int WINDOW_X = 1536;
|
||||||
const int WINDOW_Y = 900;
|
const int WINDOW_Y = 1024;
|
||||||
const int WORK_SIZE = WINDOW_X * WINDOW_Y;
|
const int WORK_SIZE = WINDOW_X * WINDOW_Y;
|
||||||
|
|
||||||
const int MAP_X = 512;
|
const int MAP_X = 256;
|
||||||
const int MAP_Y = 512;
|
const int MAP_Y = 256;
|
||||||
const int MAP_Z = 256;
|
const int MAP_Z = 256;
|
||||||
|
|
||||||
float elap_time(){
|
float elap_time(){
|
||||||
@@ -97,14 +97,14 @@ int main() {
|
|||||||
_map.generate_octree();
|
_map.generate_octree();
|
||||||
_map.a.print_block(0);
|
_map.a.print_block(0);
|
||||||
_map.test_map();
|
_map.test_map();
|
||||||
std::cin.get();
|
//std::cin.get();
|
||||||
return 0;
|
//return 0;
|
||||||
// =============================
|
// =============================
|
||||||
|
|
||||||
sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML");
|
sf::RenderWindow window(sf::VideoMode(WINDOW_X, WINDOW_Y), "SFML");
|
||||||
window.setMouseCursorVisible(false);
|
window.setMouseCursorVisible(false);
|
||||||
window.setKeyRepeatEnabled(false);
|
window.setKeyRepeatEnabled(false);
|
||||||
window.setFramerateLimit(60);
|
window.setFramerateLimit(120);
|
||||||
window.setVerticalSyncEnabled(false);
|
window.setVerticalSyncEnabled(false);
|
||||||
|
|
||||||
ImGui::SFML::Init(window);
|
ImGui::SFML::Init(window);
|
||||||
@@ -219,7 +219,18 @@ int main() {
|
|||||||
fps.frame(delta_time);
|
fps.frame(delta_time);
|
||||||
fps.draw();
|
fps.draw();
|
||||||
|
|
||||||
ImGui::Begin("Camera");
|
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar;
|
||||||
|
bool window_show = true;
|
||||||
|
ImGui::Begin("Camera", &window_show, window_flags);
|
||||||
|
|
||||||
|
if (ImGui::BeginMenuBar())
|
||||||
|
{
|
||||||
|
if (ImGui::BeginMenu("Menu"))
|
||||||
|
{
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
ImGui::EndMenuBar();
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::Columns(2);
|
ImGui::Columns(2);
|
||||||
|
|
||||||
@@ -277,16 +288,27 @@ int main() {
|
|||||||
handle->set_position(light);
|
handle->set_position(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Menu
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (ImGui::CollapsingHeader("Window options"))
|
||||||
|
{
|
||||||
|
if (ImGui::TreeNode("Style"))
|
||||||
|
{
|
||||||
|
ImGui::ShowStyleEditor();
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
}
|
||||||
//light_pos[0] = static_cast<float>(sin(elapsed_time) * 100.0f + 300.0f);
|
//light_pos[0] = static_cast<float>(sin(elapsed_time) * 100.0f + 300.0f);
|
||||||
//light_pos[1] = static_cast<float>(sin(elapsed_time) * 100.0f + 300.0f);
|
//light_pos[1] = static_cast<float>(sin(elapsed_time) * 100.0f + 300.0f);
|
||||||
|
|
||||||
//sf::Vector3f light(light_pos[0], light_pos[1], light_pos[2]);
|
//sf::Vector3f light(light_pos[0], light_pos[1], light_pos[2]);
|
||||||
//handle->set_position(light);
|
//handle->set_position(light);
|
||||||
|
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
|
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ Hardware_Caster::~Hardware_Caster() {
|
|||||||
|
|
||||||
int Hardware_Caster::init() {
|
int Hardware_Caster::init() {
|
||||||
|
|
||||||
|
query_hardware();
|
||||||
|
|
||||||
// Initialize opencl up to the point where we start assigning buffers
|
// Initialize opencl up to the point where we start assigning buffers
|
||||||
error = acquire_platform_and_device();
|
error = acquire_platform_and_device();
|
||||||
if(vr_assert(error, "aquire_platform_and_device"))
|
if(vr_assert(error, "aquire_platform_and_device"))
|
||||||
@@ -265,6 +267,11 @@ void Hardware_Caster::test_edit_viewport(int width, int height, float v_fov, flo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Hardware_Caster::gui() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int Hardware_Caster::acquire_platform_and_device() {
|
int Hardware_Caster::acquire_platform_and_device() {
|
||||||
|
|
||||||
// Get the number of platforms
|
// Get the number of platforms
|
||||||
@@ -420,6 +427,103 @@ int Hardware_Caster::acquire_platform_and_device() {
|
|||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int Hardware_Caster::query_hardware() {
|
||||||
|
|
||||||
|
// Get the number of platforms
|
||||||
|
cl_uint plt_cnt = 0;
|
||||||
|
clGetPlatformIDs(0, nullptr, &plt_cnt);
|
||||||
|
|
||||||
|
// Fetch the platforms
|
||||||
|
std::map<cl_platform_id, std::vector<device_info>> plt_ids;
|
||||||
|
|
||||||
|
// buffer before map init
|
||||||
|
std::vector<cl_platform_id> plt_buf(plt_cnt);
|
||||||
|
clGetPlatformIDs(plt_cnt, plt_buf.data(), nullptr);
|
||||||
|
|
||||||
|
// Map init
|
||||||
|
for (auto id : plt_buf) {
|
||||||
|
plt_ids.emplace(std::make_pair(id, std::vector<device_info>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// For each platform, populate its devices
|
||||||
|
for (unsigned int i = 0; i < plt_cnt; i++) {
|
||||||
|
|
||||||
|
cl_uint deviceIdCount = 0;
|
||||||
|
error = clGetDeviceIDs(plt_buf[i], CL_DEVICE_TYPE_ALL, 0, nullptr, &deviceIdCount);
|
||||||
|
|
||||||
|
// Check to see if we even have OpenCL on this machine
|
||||||
|
if (deviceIdCount == 0) {
|
||||||
|
std::cout << "There appears to be no devices, or none at least supporting OpenCL" << std::endl;
|
||||||
|
return OPENCL_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the device ids
|
||||||
|
std::vector<cl_device_id> deviceIds(deviceIdCount);
|
||||||
|
error = clGetDeviceIDs(plt_buf[i], CL_DEVICE_TYPE_ALL, deviceIdCount, deviceIds.data(), NULL);
|
||||||
|
|
||||||
|
if (vr_assert(error, "clGetDeviceIDs"))
|
||||||
|
return OPENCL_ERROR;
|
||||||
|
|
||||||
|
for (unsigned int q = 0; q < deviceIdCount; q++) {
|
||||||
|
|
||||||
|
device_info d;
|
||||||
|
|
||||||
|
cl_device_id id = deviceIds[q];
|
||||||
|
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_ADDRESS_BITS, sizeof(cl_uint), &d.cl_device_address_bits, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_AVAILABLE, sizeof(cl_bool), &d.cl_device_available, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_COMPILER_AVAILABLE, sizeof(cl_bool), &d.cl_device_compiler_available, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_ENDIAN_LITTLE, sizeof(cl_bool), &d.cl_device_endian_little, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_ERROR_CORRECTION_SUPPORT, sizeof(cl_bool), &d.cl_device_error_correction_support, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_EXTENSIONS, sizeof(char)*1024, &d.cl_device_extensions, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, sizeof(cl_ulong), &d.cl_device_global_mem_cache_size, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, sizeof(cl_uint), &d.cl_device_global_mem_cacheline_size, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(cl_ulong), &d.cl_device_global_mem_size, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_IMAGE_SUPPORT, sizeof(cl_bool), &d.cl_device_image_support, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof(size_t), &d.cl_device_image2d_max_height, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof(size_t), &d.cl_device_image2d_max_width, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof(size_t), &d.cl_device_image3d_max_depth, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof(size_t), &d.cl_device_image3d_max_height, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof(size_t), &d.cl_device_image3d_max_width, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(cl_ulong), &d.cl_device_local_mem_size, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(size_t), &d.cl_device_max_clock_frequency, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(size_t), &d.cl_device_max_compute_units, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MAX_CONSTANT_ARGS, sizeof(size_t), &d.cl_device_max_constant_args, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, sizeof(cl_ulong), &d.cl_device_max_constant_buffer_size, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &d.cl_device_max_mem_alloc_size, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MAX_PARAMETER_SIZE, sizeof(size_t), &d.cl_device_max_parameter_size, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MAX_READ_IMAGE_ARGS, sizeof(cl_uint), &d.cl_device_max_read_image_args, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MAX_SAMPLERS, sizeof(cl_uint), &d.cl_device_max_samplers, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(cl_ulong), &d.cl_device_max_work_group_size, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(cl_ulong), &d.cl_device_max_work_item_dimensions, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(size_t)*3, &d.cl_device_max_work_item_sizes, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, sizeof(cl_uint), &d.cl_device_max_write_image_args, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof(cl_uint), &d.cl_device_mem_base_addr_align, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, sizeof(cl_uint), &d.cl_device_min_data_type_align_size, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_NAME, sizeof(char)*128, &d.cl_device_name, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_PLATFORM, sizeof(cl_platform_id), &d.cl_device_platform, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_PREFERRED_GLOBAL_ATOMIC_ALIGNMENT, sizeof(cl_uint), &d.cl_device_preferred_vector_width_char, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, sizeof(cl_uint), &d.cl_device_preferred_vector_width_short, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, sizeof(cl_uint), &d.cl_device_preferred_vector_width_int, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, sizeof(cl_uint), &d.cl_device_preferred_vector_width_long, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, sizeof(cl_uint), &d.cl_device_preferred_vector_width_float, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, sizeof(cl_uint), &d.cl_device_preferred_vector_width_double, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_PROFILE, sizeof(char) * 256, &d.cl_device_profile, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_PROFILING_TIMER_RESOLUTION, sizeof(size_t), &d.cl_device_profiling_timer_resolution, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_TYPE, sizeof(cl_device_type), &d.cl_device_type, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_VENDOR, sizeof(char)*128, &d.cl_device_vendor, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_VENDOR_ID, sizeof(cl_uint), &d.cl_device_vendor_id, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DEVICE_VERSION, sizeof(char)*128, &d.cl_device_version, NULL);
|
||||||
|
clGetDeviceInfo(id, CL_DRIVER_VERSION, sizeof(char)*128, &d.cl_driver_version, NULL);
|
||||||
|
|
||||||
|
plt_ids.at(d.cl_device_platform).push_back(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int Hardware_Caster::create_shared_context() {
|
int Hardware_Caster::create_shared_context() {
|
||||||
|
|
||||||
// Hurray for standards!
|
// Hurray for standards!
|
||||||
@@ -526,7 +630,7 @@ int Hardware_Caster::compile_kernel(std::string kernel_source, bool is_path, std
|
|||||||
|
|
||||||
// Try and build the program
|
// Try and build the program
|
||||||
// "-cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations"
|
// "-cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations"
|
||||||
error = clBuildProgram(program, 1, &device_id, NULL, NULL, NULL);
|
error = clBuildProgram(program, 1, &device_id, "-cl-finite-math-only -cl-fast-relaxed-math -cl-unsafe-math-optimizations", NULL, NULL);
|
||||||
|
|
||||||
// Check to see if it errored out
|
// Check to see if it errored out
|
||||||
if (vr_assert(error, "clBuildProgram")) {
|
if (vr_assert(error, "clBuildProgram")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user