Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
Hardware profile UI test with a real calibration (SF_HW_PROFILE_IN_TESTS=1), shared-memory size in the panel header, GLX constants only on Linux
islandmed5288b50b2603
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 4e60eb49..6f455ce2 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -529,6 +529,10 @@ if(SCULPTFORGE_BUILD_TESTS)"SCULPTFORGE_BRUSH=$<TARGET_FILE:sf_fake_splat_tools>;SCULPTFORGE_COLMAP=$<TARGET_FILE:sf_fake_splat_tools>;SCULPTFORGE_FFMPEG=$<TARGET_FILE:sf_fake_splat_tools>")endif()endforeach()+ # The hardware profile panel with a real calibration (tests/ui/hardware_profile.sfui).+ if(TEST ui_hardware_profile)+ set_tests_properties(ui_hardware_profile PROPERTIES ENVIRONMENT "SF_HW_PROFILE_IN_TESTS=1")+ endif()# The shell layout again on a 1920x1080 window (docs/ui-design.md §2.3).add_test(NAME ui_shell_layout_1080 COMMAND sculptforge --ui-test ${CMAKE_CURRENT_SOURCE_DIR}/tests/ui/shell_layout.sfui--size 1920x1080 --ui-out ${CMAKE_CURRENT_BINARY_DIR}/ui-shots/shell_layout_1080)diff --git a/src/app/App.cpp b/src/app/App.cppindex 642482dc..dbdd7168 100644--- a/src/app/App.cpp+++ b/src/app/App.cpp@@ -369,6 +369,7 @@ int App::runUiTest(int w, int h, int fps) {updateCameraAspect();updateSpaceMouse(dt);+ hardwareProfileFrameBegin(); // (only with SF_HW_PROFILE_IN_TESTS=1: tests use fixed settings)Demo::beginFrame();ImGui_ImplOpenGL3_NewFrame();ImGui_ImplSDL3_NewFrame();@@ -380,6 +381,7 @@ int App::runUiTest(int w, int h, int fps) {ImGui::NewFrame();ImGui::LogToBuffer(0); // capture every drawn string (0: don't auto-open tree nodes)drawUi();+ drawHardwareProfileOverlay();if (ImGuiContext* g = ImGui::GetCurrentContext()) demo_->setFrameText(g->LogBuffer.c_str());ImGui::LogFinish();ImGui::Render();@@ -388,6 +390,7 @@ int App::runUiTest(int w, int h, int fps) {syncScene();notePerformanceFrame(std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - syncStart).count());viewSamples(); // keeps Fast Navigation's view of the camera current (UI tests read view_samples)+ hardwareProfileFrameEnd();++frames;const std::string shot = demo_->takeShotRequest();if (shot.empty()) continue;diff --git a/src/app/Calibration.cpp b/src/app/Calibration.cppindex 0a5ca53c..05ddd8c5 100644--- a/src/app/Calibration.cpp+++ b/src/app/Calibration.cpp@@ -53,9 +53,11 @@ constexpr GLenum kGL_FRAMEBUFFER_BINDING = 0x8CA6, kGL_VIEWPORT = 0x0BA2, kGL_CU// GL_NVX_gpu_memory_info (KB), GL_ATI_meminfo (KB, 4 values: the first is the pool's free total).constexpr GLenum kGL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX = 0x9047, kGL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX = 0x9049;constexpr GLenum kGL_TEXTURE_FREE_MEMORY_ATI = 0x87FC;+#if defined(__linux__) || defined(__FreeBSD__)// GLX_MESA_query_renderer.constexpr int kGLX_RENDERER_ACCELERATED_MESA = 0x8186, kGLX_RENDERER_VIDEO_MEMORY_MESA = 0x8187,kGLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA = 0x8188;+#endifstruct GlExtra {const GLubyte*(SF_GLAPI* GetStringi)(GLenum, GLuint) = nullptr;diff --git a/src/app/PanelPerformanceProfile.cpp b/src/app/PanelPerformanceProfile.cppindex 69a516d9..0e00c4f5 100644--- a/src/app/PanelPerformanceProfile.cpp+++ b/src/app/PanelPerformanceProfile.cpp@@ -102,9 +102,12 @@ int displayRefreshHz(SDL_Window* window) {bool App::hardwareProfileGoverns() const { return hwProfile_ && hwProfile_->active; }void App::initHardwareProfile() {- // Deterministic runs (UI tests, renders, recordings, demos) and the --measure-* runs keep the fixed defaults.- if (uiConfigDeterministic_ || !options_.renderPath.empty() || !options_.recordPath.empty() || !options_.uiTest.empty() ||- options_.measureIdle > 0.0f || options_.measureStroke > 0.0f)+ // Deterministic runs (UI tests, renders, recordings, demos) and the --measure-* runs keep the fixed defaults; a+ // UI test of this panel turns it on with SF_HW_PROFILE_IN_TESTS=1 (its settings folder is a temporary one).+ const char* inTests = std::getenv("SF_HW_PROFILE_IN_TESTS");+ const bool testThis = !options_.uiTest.empty() && inTests && std::string(inTests) == "1";+ if (!testThis && (uiConfigDeterministic_ || !options_.renderPath.empty() || !options_.recordPath.empty() ||+ !options_.uiTest.empty() || options_.measureIdle > 0.0f || options_.measureStroke > 0.0f))return;hwProfile_ = std::make_shared<HwProfileUi>();HwProfileUi& hw = *hwProfile_;@@ -368,14 +371,21 @@ void App::drawPerformanceProfileSection() {const Calibration& c = p.calibration;const PerformanceSettings& s = p.settings;// "Detected Apple M1 Pro, 21.3 GB unified -> Workstation"- std::string vram = h.vramMB ? formatMegabytes(h.vramMB) : h.gpuKind == GpuKind::Unified || h.gpuKind == GpuKind::Integrated- ? formatMegabytes(s.vramBudgetMB) + " shared"- : std::string("memory unknown");+ // Shared memory shows what the GPU may use (the budget), not what the driver reports (often all of the RAM).+ const bool shared = h.gpuKind == GpuKind::Unified || h.gpuKind == GpuKind::Integrated;+ const std::string vram = shared ? formatMegabytes(s.vramBudgetMB) + " shared"+ : h.vramMB ? formatMegabytes(h.vramMB)+ : std::string("memory unknown");if (fontBold_) ImGui::PushFont(fontBold_);ImGui::TextWrapped("Detected %s, %s -> %s", h.glRenderer.empty() ? "an unknown GPU" : h.glRenderer.c_str(), vram.c_str(),tierName(p.tier));if (fontBold_) ImGui::PopFont();- dim(p.reason);+ // Why (the reason without the "Detected ... -> tier" the line above already says).+ std::string why = p.reason;+ if (const size_t arrow = why.find(" -> "); arrow != std::string::npos)+ if (const size_t open = why.find(" (", arrow); open != std::string::npos && why.back() == ')')+ why = why.substr(open + 2, why.size() - open - 3);+ dim(why);std::string measured;if (c.skipped) measured = "Not measured (skipped): settings from the GPU type and memory sizes.\n";else {diff --git a/tests/ui/hardware_profile.sfui b/tests/ui/hardware_profile.sfuinew file mode 100644index 00000000..e2c702f0--- /dev/null+++ b/tests/ui/hardware_profile.sfui@@ -0,0 +1,34 @@+# Hardware profile (PanelPerformanceProfile.cpp): with SF_HW_PROFILE_IN_TESTS=1 (set by CMake for this test only,+# in the test's temporary settings folder) the app calibrates over the first frames like a first launch, then+# Preferences > Performance shows what it detected and measured, the settings, the frame governor, Re-calibrate and+# the manual overrides. Real GPU, so only the words are checked, not the numbers.+run new_sphere+# (Calibration takes one step per frame, so it is over within the first frames here.)+wait 1+expect_no_text Getting to know this computer+click "Preferences##palette.preferences"+click "Performance##preferences.performance"+wait_for "Frame Governor" 10+expect_text Hardware profile+expect_text Detected+expect_text Triangles+expect_text View budget+expect_text Motion proxy from+expect_text Re-calibrate+hold ctrl+hover "Frame Governor"+expect_help "target frame rate"+hold none+# The governor toggles off and on (saved in the profile).+click "Frame Governor"+expect_status Frame governor off+click "Frame Governor"+expect_status Frame governor on+# The manual overrides open.+click "Manual overrides"+expect_text Draft brushes: automatic+shot panel+# Re-calibrate runs the overlay again and finishes.+click "Re-calibrate"+wait 1+expect_status Calibrated for this computer