Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
49 changes: 30 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ project(FunGT)
# ════════════════════════════════════════════════════════════════════════════
option(FUNGT_USE_CUDA "Enable CUDA backend for NVIDIA GPUs" ON)
option(FUNGT_USE_SYCL "Enable SYCL backend for Intel GPUs" ON)
set(SYCL_CUDA_ARCH sm_75 CACHE STRING "NVIDIA GPU architecture for SYCL CUDA backend")
set_property(CACHE SYCL_CUDA_ARCH PROPERTY STRINGS sm_50 sm_52 sm_53 sm_60 sm_61 sm_62 sm_70 sm_72 sm_75 sm_80 sm_86 sm_87 sm_89 sm_90)

# Allow FUNGT_BASE_DIR to be set externally (command line, environment, or cache)
# Priority: 1. Cache variable, 2. Environment variable, 3. Default fallback
Expand Down Expand Up @@ -104,9 +106,6 @@ if(UNIX)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/release/linux)

# ALWAYS use SYCL compiler (required for funlib)
# set(CMAKE_CXX_COMPILER /home/juanchuletas/Documents/Development/FunGT/toolchain/sycl/linux_x64/dpcpp/bin/clang++)

# Add the prebuilt ImGui library
add_library(imgui STATIC IMPORTED)
set_target_properties(imgui PROPERTIES
Expand Down Expand Up @@ -169,6 +168,7 @@ include_directories(
${FUNGT_BASE_DIR}/AnimatedModel
${FUNGT_BASE_DIR}/Textures
${FUNGT_BASE_DIR}/vendor/stb_image
${FUNGT_BASE_DIR}/vendor/glm/include
${FUNGT_BASE_DIR}/Imgui_Setup
${FUNGT_BASE_DIR}/Material
${FUNGT_BASE_DIR}/Mesh
Expand Down Expand Up @@ -258,21 +258,24 @@ set(SOURCE_FILES
${FUNGT_BASE_DIR}/CubeMap/cube_map.cpp
${FUNGT_BASE_DIR}/ParticleSimulation/particle_simulation.cpp
${FUNGT_BASE_DIR}/ParticleSimulation/particle_simulation_rtc.cpp
${FUNGT_BASE_DIR}/ParticleSimulation/particle_simulation_sycl_ops.cpp
${FUNGT_BASE_DIR}/ParticleSimulation/particle_rtc_sycl_ops.cpp
${FUNGT_BASE_DIR}/Random/random.cpp
${FUNGT_BASE_DIR}/Path_Manager/path_manager.cpp
${FUNGT_BASE_DIR}/InfoWindow/infowindow.cpp
${FUNGT_BASE_DIR}/GUI/gui.cpp
${FUNGT_BASE_DIR}/GUI/particle_rtc_window.cpp
${FUNGT_BASE_DIR}/GUI/physics/simulation_controller_window.cpp
${FUNGT_BASE_DIR}/GUI/demo_particles_window.cpp
${FUNGT_BASE_DIR}/GUI/render_action_window.cpp
${FUNGT_BASE_DIR}/GUI/physics/debug_rigidbody_renderer.cpp
${FUNGT_BASE_DIR}/SimpleModel/simple_model.cpp
${FUNGT_BASE_DIR}/SimpleGeometry/simple_geometry.cpp
${FUNGT_BASE_DIR}/Physics/Collisions/simple_collision.cpp
${FUNGT_BASE_DIR}/Physics/Collisions/manifold_collision.cpp
${FUNGT_BASE_DIR}/Physics/CollisionManager/collision_manager.cpp
${FUNGT_BASE_DIR}/Physics/Collider/collider.cpp
${FUNGT_BASE_DIR}/Physics/Clothing/clothing.cpp
${FUNGT_BASE_DIR}/Physics/AnimationCreator/key_frame_recorder.cpp
${FUNGT_BASE_DIR}/Physics/AnimationCreator/animation_exporter.cpp
${FUNGT_BASE_DIR}/ViewPort/viewport.cpp
${FUNGT_BASE_DIR}/ViewPort/progressive_path_tracer_viewport.cpp
${FUNGT_BASE_DIR}/Renders/framebuffer.cpp
Expand Down Expand Up @@ -359,15 +362,13 @@ if (WIN32)
find_package(GLEW REQUIRED)
find_package(glfw3 REQUIRED)
find_package(assimp REQUIRED)
find_package(glm REQUIRED)

target_link_libraries(FunGT
PRIVATE
OpenGL::GL
glfw
GLEW::GLEW
assimp::assimp
glm::glm
)

elseif (UNIX)
Expand Down Expand Up @@ -456,13 +457,6 @@ elseif (UNIX)
message(FATAL_ERROR "Assimp library not found!")
endif()

find_package(glm CONFIG REQUIRED)
if(glm_FOUND)
message(STATUS "glm found")
else()
message(FATAL_ERROR "glm not found!")
endif()

# Link libraries
target_include_directories(FunGT PRIVATE ${OpenCL_INCLUDE_DIRS})
target_link_libraries(FunGT
Expand All @@ -472,7 +466,6 @@ elseif (UNIX)
glfw
GLEW::GLEW
assimp::assimp
glm::glm
dl
funlib
imgui
Expand All @@ -481,21 +474,39 @@ elseif (UNIX)
pbr_core
${PBR_CUDA_LIB}
${PBR_SYCL_LIB}
$<$<BOOL:${FUNGT_USE_CUDA}>:CUDA::cudart_static> # CHANGE TO cudart_static
$<$<BOOL:${FUNGT_USE_CUDA}>:CUDA::cudart_static>
$<$<BOOL:${FUNGT_USE_CUDA}>:CUDA::cuda_driver>
)

# ════════════════════════════════════════════════════════════════════════
# SYCL compilation flags (always applied because funlib requires it)
# SYCL compilation flags (per-file, not blanket)
# ════════════════════════════════════════════════════════════════════════
if(CUDAToolkit_FOUND)
message(STATUS "CUDA SYCL backend enabled")
set(SYCL_TARGETS nvptx64-nvidia-cuda,spir64)
set(SYCL_CUDA_ARCH_ARGS
"-Xsycl-target-backend=nvptx64-nvidia-cuda"
"--offload-arch=${SYCL_CUDA_ARCH}"
)
else()
set(SYCL_TARGETS spir64)
set(SYCL_CUDA_ARCH_ARGS "")
endif()
target_compile_options(FunGT PRIVATE -fsycl -fsycl-targets=${SYCL_TARGETS})
target_link_options(FunGT PRIVATE -fsycl -fsycl-targets=${SYCL_TARGETS})

set(SYCL_SOURCES
${FUNGT_BASE_DIR}/InfoDevice/sycl_backend.cpp
${FUNGT_BASE_DIR}/ParticleSimulation/particle_simulation_sycl_ops.cpp
${FUNGT_BASE_DIR}/ParticleSimulation/particle_rtc_sycl_ops.cpp
${FUNGT_BASE_DIR}/PBR/Space/space.cpp
)

list(JOIN SYCL_CUDA_ARCH_ARGS " " SYCL_CUDA_ARCH_STR)

set_source_files_properties(${SYCL_SOURCES}
PROPERTIES COMPILE_FLAGS "-fsycl -fsycl-targets=${SYCL_TARGETS} ${SYCL_CUDA_ARCH_STR}"
)

target_link_options(FunGT PRIVATE -fsycl -fsycl-targets=${SYCL_TARGETS} ${SYCL_CUDA_ARCH_ARGS})

if(FUNGT_USE_SYCL)
target_compile_definitions(FunGT PRIVATE FUNGT_USE_SYCL)
Expand Down
1 change: 1 addition & 0 deletions ComputationalGeom/aabb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Vector/vector3.hpp"
#include "gpu/include/fgt_cpu_device.hpp"
#include <cmath>
#include <cfloat>
class AABB {

public:
Expand Down
79 changes: 79 additions & 0 deletions GUI/demo_particles_window.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#include "demo_particles_window.hpp"
#include "ParticleSimulation/particle_simulation.hpp"
#include "ParticleSimulation/particle_simulation_sycl_ops.hpp"

void ParticleSimDemoWindow::onImGuiRender() {
m_frameCount++;
auto currentTime = std::chrono::high_resolution_clock::now();
float elapsed = std::chrono::duration<float>(currentTime - m_lastFPSTime).count();

if (elapsed >= 0.5f) {
m_measuredFPS = m_frameCount / elapsed;
m_frameCount = 0;
m_lastFPSTime = currentTime;
}

ImGui::Begin("Particle Demos");

if (!m_sceneManager) {
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "No scene manager");
ImGui::End();
return;
}

const auto& allObjects = m_sceneManager->getRenderable();
std::shared_ptr<ParticleSimulation> particleSim = nullptr;

for (auto& obj : allObjects) {
auto sim = std::dynamic_pointer_cast<ParticleSimulation>(obj);
if (sim) {
particleSim = sim;
break;
}
}

if (!particleSim) {
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "No particle simulation");
ImGui::End();
return;
}

ImGui::TextColored(ImVec4(0.4f, 0.7f, 1.0f, 1.0f), "Active:");
ImGui::SameLine();
ImGui::Text("%s", particleSim_getDemoName(particleSim->getCurrentDemo()).c_str());
ImGui::Separator();

if (ImGui::BeginCombo("##Demo", particleSim_getDemoName(m_selectedDemoIndex).c_str())) {
for (int i = 0; i < particleSim_getDemoCount(); i++) {
bool isSelected = (m_selectedDemoIndex == i);
if (ImGui::Selectable(particleSim_getDemoName(i).c_str(), isSelected)) {
m_selectedDemoIndex = i;
if (m_autoApply) {
particleSim->loadDemo(m_selectedDemoIndex);
}
}
if (isSelected) {
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}

ImGui::TextWrapped("%s", m_descriptions[m_selectedDemoIndex].c_str());

if (ImGui::Button("Load Demo", ImVec2(-1, 0))) {
particleSim->loadDemo(m_selectedDemoIndex);
}

ImGui::Checkbox("Auto-load", &m_autoApply);

if (ImGui::CollapsingHeader("Info")) {
ImGui::Text("Particles: %zu", particleSim->getParticleCount());
ImGui::Text("Measured FPS: %.1f", m_measuredFPS);
ImGui::Text("ImGui FPS: %.1f", ImGui::GetIO().Framerate);
ImGui::Text("Frame time: %.2f ms", 1000.0f / m_measuredFPS);
ImGui::Text("Recommended: %d", m_recommendedCounts[m_selectedDemoIndex]);
}

ImGui::End();
}
89 changes: 5 additions & 84 deletions GUI/demo_particles_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
#define _PARTICLE_SIM_DEMO_WINDOW_H_
#include "imgui_window.hpp"
#include "SceneManager/scene_manager.hpp"
#include "ParticleSimulation/particle_simulation.hpp"
#include "ParticleSimulation/particle_demos.hpp"
#include <memory>
#include <chrono>
#include <vector>
#include <string>

class ParticleSimulation;

class ParticleSimDemoWindow : public ImGuiWindow {
private:
std::shared_ptr<SceneManager> m_sceneManager;
int m_selectedDemoIndex;
bool m_autoApply;

// FPS measurement
std::chrono::high_resolution_clock::time_point m_lastFPSTime;
int m_frameCount;
float m_measuredFPS;
Expand Down Expand Up @@ -42,87 +43,7 @@ class ParticleSimDemoWindow : public ImGuiWindow {
{
}

void onImGuiRender() override {
// Measure FPS
m_frameCount++;
auto currentTime = std::chrono::high_resolution_clock::now();
float elapsed = std::chrono::duration<float>(currentTime - m_lastFPSTime).count();

if (elapsed >= 0.5f) { // Update twice per second for smooth display
m_measuredFPS = m_frameCount / elapsed;
m_frameCount = 0;
m_lastFPSTime = currentTime;
}

ImGui::Begin("Particle Demos");

if (!m_sceneManager) {
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "No scene manager");
ImGui::End();
return;
}

const auto& allObjects = m_sceneManager->getRenderable();
std::shared_ptr<ParticleSimulation> particleSim = nullptr;

for (auto& obj : allObjects) {
auto sim = std::dynamic_pointer_cast<ParticleSimulation>(obj);
if (sim) {
particleSim = sim;
break;
}
}

if (!particleSim) {
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "No particle simulation");
ImGui::End();
return;
}

// Current demo indicator (compact)
ImGui::TextColored(ImVec4(0.4f, 0.7f, 1.0f, 1.0f), "Active:");
ImGui::SameLine();
ImGui::Text("%s", fgt::demoNames[particleSim->getCurrentDemo()].c_str());
ImGui::Separator();

// Demo selection
if (ImGui::BeginCombo("##Demo", fgt::demoNames[m_selectedDemoIndex].c_str())) {
for (int i = 0; i < fgt::demoNames.size(); i++) {
bool isSelected = (m_selectedDemoIndex == i);
if (ImGui::Selectable(fgt::demoNames[i].c_str(), isSelected)) {
m_selectedDemoIndex = i;
if (m_autoApply) {
particleSim->loadDemo(m_selectedDemoIndex);
}
}
if (isSelected) {
ImGui::SetItemDefaultFocus();
}
}
ImGui::EndCombo();
}

// Compact description
ImGui::TextWrapped("%s", m_descriptions[m_selectedDemoIndex].c_str());

// Load button
if (ImGui::Button("Load Demo", ImVec2(-1, 0))) {
particleSim->loadDemo(m_selectedDemoIndex);
}

ImGui::Checkbox("Auto-load", &m_autoApply);

// Collapsing info section
if (ImGui::CollapsingHeader("Info")) {
ImGui::Text("Particles: %zu", particleSim->getParticleCount());
ImGui::Text("Measured FPS: %.1f", m_measuredFPS);
ImGui::Text("ImGui FPS: %.1f", ImGui::GetIO().Framerate);
ImGui::Text("Frame time: %.2f ms", 1000.0f / m_measuredFPS);
ImGui::Text("Recommended: %d", m_recommendedCounts[m_selectedDemoIndex]);
}

ImGui::End();
}
void onImGuiRender() override;
};

#endif // _PARTICLE_SIM_DEMO_WINDOW_H_
7 changes: 5 additions & 2 deletions GUI/imgui_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "imgui_window.hpp"
#include "Layer/layer.hpp"
#include "InfoDevice/gpu_device_info.hpp"
#include "Path_Manager/path_manager.hpp"
#include "render_settings_window.hpp"
#include <memory>

Expand Down Expand Up @@ -191,8 +192,10 @@ class ImGuiLayer : public Layer {
io.Fonts->Clear();

// Load your font file (TTF)
//
std::string fontPath = getAssetPath("GUI/fonts/Nunito/static/Nunito-Regular.ttf");
ImFont* myFont = io.Fonts->AddFontFromFileTTF(
"/home/juanchuletas/Documents/Development/FunGT/GUI/fonts/Nunito/static/Nunito-Regular.ttf", 18.0f
fontPath.c_str(), 18.0f
);

if (myFont == nullptr)
Expand Down Expand Up @@ -358,4 +361,4 @@ class ImGuiLayer : public Layer {
}
};

#endif // _IMGUI_LAYER_H_
#endif // _IMGUI_LAYER_H_
1 change: 1 addition & 0 deletions GUI/particle_rtc_window.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "particle_rtc_window.hpp"
#include "ParticleSimulation/particle_simulation_rtc.hpp"
#include <imgui.h>
#include <curl/curl.h>
static size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp) {
Expand Down
3 changes: 1 addition & 2 deletions GUI/particle_rtc_window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
#define PARTICLE_RTC_WINDOW_HPP

#include "GUI/imgui_window.hpp"
#include "ParticleSimulation/particle_simulation_rtc.hpp"
#include <string>
#include <future>
#include <atomic>
#include <memory>


class ParticleRTC;



Expand Down
Loading