Conversation
…unctions in GPU benchmark test Co-authored-by: Copilot <copilot@github.com>
…chmark execution Co-authored-by: Copilot <copilot@github.com>
…layground into develop
…tor rendering logic to improve realtime interaction handling and parameter change dispatching. Introduce new policies for low-resolution previews and streamline the decision-making process for rendering tasks. Add unit tests to validate the new behavior and ensure correct handling of parameter changes in various rendering modes.
…sues and improve state transitions. Ensure Force mode uses exact realtime for parameter edits, decouple interaction end from streaming preview, and enhance unit tests to align with userspec. Document state transition traces and fix Auto/Off mode parameter handling
…plement asynchronous preview rendering and enhance frame presentation quality handling. Introduce new PreviewBackendPolicy and FramePresentationTypes for improved rendering decisions. Refactor related methods to support quality-based frame promotion and presentation
…ontroller.h, RenderWorkflowController_tests.cpp] Introduce frame presentation source enumeration, enhance rendering decision logic, and implement render workflow controller with unit tests for frame presentation handling
…tate management with unit tests for rendering decisions
…y] Introduce PresentedFrameLedger and PreviewResultAcceptancePolicy for improved frame presentation management and acceptance criteria. Refactor rendering logic to utilize new policies and enhance unit tests for validation
…nhance frame presentation logic and acceptance criteria. Introduce presented frame handling, improve stale view management during camera interaction, and add unit tests for validation
…enderUpdateCoordinator] Refactor rendering interaction logic to improve real-time mode handling and fallback mechanisms. Introduce new structures and methods for better state management and enhance unit tests for validation
…factor rendering execution path logic for realtime interactions. Introduce new enum for frame execution paths and enhance unit tests for accurate frame selection and execution behavior
…inator] Refactor rendering logic to improve job cancellation handling and state management. Introduce deque for pending results, enhance budget checks, and update unit tests for better validation of rendering behavior
…or rendering logic to support StaticFullFrameProbe. Update job scheduling and handling, enhance unit tests for validation of new rendering behavior
…completion with polling. Refactor event handling logic to improve stability and prevent race conditions. Update buffer management to avoid premature recycling of GPU-owned resources
…, detailing OpenCL command queue management, core invariants, main types, published generations, conservative policies, safe mode, and kernel launch procedures
… management and access control. Introduce GpuAccessCoordinator class to manage resource registrations, access requests, and event tracking. Add GpuKernelAccessGuard for scoped access management during GPU operations. Enhance MeshPreparationProgram and FunctionEvaluatorTool to utilize new access management features. Create OpenClEventRegistry for event tracking and completion handling. Add unit tests for GpuAccessCoordinator to validate access workflows and resource state management
…vironment variable dependency for initialization
…og warnings for dropped links during model copy
…screen resize and preserve content during rendering
… improve responsiveness during resizing
…stability during updates and remove unused MVP-based approach comments
…ture specification for new library items. Implement tasks for symmetry operations, basic primitives, deformation modifiers, and mechanical parts. Ensure comprehensive metadata and validation requirements are met for all entries
There was a problem hiding this comment.
Pull request overview
This PR spans build tooling, GPU synchronization/lifecycle safety, render/preview interaction policy, and related specifications/docs. The core thrust is making GPU resource access deterministic across multiple OpenCL queues (with explicit tracking/waiting) while expanding and hardening the render-mode/preview scheduling logic through extracted policy code and new unit tests.
Changes:
- Introduces GPU access coordination primitives (resource generations + event tracking) and applies them to key OpenCL kernel dispatch paths and buffer/image lifecycles.
- Refactors/extends render update decision logic into testable policy headers and adds extensive unit coverage for stamps, presentation acceptance, progressive buffer reuse, etc.
- Updates build configuration and third-party deps (lib3mf), and adds/updates specs and architecture documentation.
Reviewed changes
Copilot reviewed 120 out of 141 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| specs/030-library-extension/data-model.md | Adds Feature 030 library data model/spec notes. |
| specs/030-library-extension/contracts/library-api.yaml | Documents MCP tool contract for library entry creation/validation. |
| specs/030-library-extension/checklists/requirements.md | Adds a spec quality checklist for the library extension feature. |
| specs/029-render-mode-behavior/userspec.md | Adds end-user requirements for render-mode behavior. |
| specs/029-render-mode-behavior/state-transition-trace.md | Adds a traced state-transition narrative for render/interaction flow. |
| review.md | Captures a human review of a large render-mode related diff. |
| gladius/vcpkg-overlay-ports/lib3mf/vcpkg.json | Bumps lib3mf overlay version. |
| gladius/vcpkg-overlay-ports/lib3mf/portfile.cmake | Updates lib3mf source ref and port configuration; switches to patch-based fixes. |
| gladius/vcpkg-overlay-ports/lib3mf/lib3mf_vcpkg.patch | Removes an older lib3mf patch. |
| gladius/vcpkg-overlay-ports/lib3mf/fix-lib3mf-config-root.patch | Adds a patch correcting lib3mf config root path. |
| gladius/tests/unittests/ui/render/RenderUpdateTypes_tests.cpp | Adds unit tests for render stamp masks and task result freshness. |
| gladius/tests/unittests/ui/render/ProgressiveBufferPolicy_tests.cpp | Adds regression tests for progressive buffer continuation rules. |
| gladius/tests/unittests/ui/render/PreviewResultAcceptancePolicy_tests.cpp | Adds unit tests for preview acceptance/rejection decisions. |
| gladius/tests/unittests/ui/render/PreviewBackendPolicy_tests.cpp | Adds tests for choosing preview backend strategy. |
| gladius/tests/unittests/ui/render/PresentedFrameLedger_tests.cpp | Adds tests for presentation quality regression prevention. |
| gladius/tests/unittests/ui/render/InteractiveRenderPathPolicy_tests.cpp | Adds tests for interactive path selection (Force/Auto/Off). |
| gladius/tests/unittests/ui/render/DisplayFrameSelector_tests.cpp | Adds tests for choosing which buffer/image to display. |
| gladius/tests/unittests/ui/render/AsyncRenderController_tests.cpp | Adds tests for job cancellation behavior based on epoch/view-epoch. |
| gladius/tests/unittests/ui/OrbitalCamera_tests.cpp | Adds tests around zoom interpolation and snapping. |
| gladius/tests/unittests/SpatialMeshResource_tests.cpp | Adds tests for mesh quality diagnostics and messaging. |
| gladius/tests/unittests/ResourceDependencyGraph_tests.cpp | Adds boolean-object dependency coverage. |
| gladius/tests/unittests/MeshFwnBenchmark_tests.cpp | Adjusts includes for benchmark tests. |
| gladius/tests/unittests/MeshBVH_tests.cpp | Adds duplicate-vertex mesh test + propagates quality stats assertions. |
| gladius/tests/unittests/Importer3mfMerge_test.cpp | Adds NanoVDB open-mesh diagnostics/behavior tests and helper to generate 3mf. |
| gladius/tests/unittests/ComputeCore_tests.cpp | Adds regression test around Document destruction with in-flight refresh. |
| gladius/tests/integrationtests/RayMarchPerf_tests.cpp | Switches camera settling to snap-to-target for perf determinism. |
| gladius/tests/apitests/CMakeLists.txt | Copies a library 3mf file into testdata for API/integration usage. |
| gladius/src/ui/render/RenderUpdateTypes.h | Introduces render stamps/masks and task request/result types. |
| gladius/src/ui/render/RenderModeUpdatePolicy.h | Adds policy helpers for legacy preview suppression + parameter dispatch classification. |
| gladius/src/ui/render/RealtimeRaymarchController.h | Extends/defines realtime raymarch controller API and config. |
| gladius/src/ui/render/ProgressiveBufferPolicy.h | Adds a pure policy for safe progressive buffer continuation. |
| gladius/src/ui/render/PreviewResultAcceptancePolicy.h | Adds metadata-only preview acceptance policy. |
| gladius/src/ui/render/PreviewBackendPolicy.h | Adds metadata-only preview backend selection policy. |
| gladius/src/ui/render/PresentedFrameLedger.h | Adds a presentation ledger to prevent quality regressions. |
| gladius/src/ui/render/InteractiveRenderPathPolicy.h | Adds metadata-only policy for interactive path selection. |
| gladius/src/ui/render/FramePresentationTypes.h | Adds frame presentation quality/source enums and ranking helpers. |
| gladius/src/ui/render/DisplayFrameSelector.h | Adds metadata-only selection for display frame source. |
| gladius/src/ui/render/AsyncRenderTypes.h | Extends async render job/result metadata (view epoch, coordinator stamp, quality/source). |
| gladius/src/ui/render/AsyncRenderController.h | Adds presentation-controller integration and view-epoch handling; makes worker queue shareable. |
| gladius/src/ui/OrbitalCamera.h | Adds snapToTarget() API. |
| gladius/src/ui/OrbitalCamera.cpp | Implements snapping and changes update clamping/tolerance behavior. |
| gladius/src/ui/ModelEditor.h | Extends function call node creation API to accept example constants. |
| gladius/src/ui/ModelEditor.cpp | Improves per-frame flag clearing order, exception safety, and library-drop constant prewiring. |
| gladius/src/ui/MeshSdfSettingsDialog.h | Adds a mesh-quality issue provider callback. |
| gladius/src/ui/MeshSdfSettingsDialog.cpp | Displays mesh topology diagnostics and offers recovery actions in UI. |
| gladius/src/ui/MainWindow.cpp | Integrates parameter-change classification, render window shortcut timing, progress UI, and issue providers. |
| gladius/src/SpatialMeshResource.h | Exposes mesh quality diagnostics accessors and message formatting API. |
| gladius/src/ResourceContext.h | Adds GPU resource handle accessor for metrics buffer. |
| gladius/src/ResourceContext.cpp | Registers a metrics buffer resource with GPU access coordinator. |
| gladius/src/RenderProgram.cpp | Wraps kernel launches with access guards and explicit wait lists. |
| gladius/src/nodes/ToCommandStreamVisitor.cpp | Normalizes model signature to pos and simplifies output seeding. |
| gladius/src/nodes/Model.cpp | Makes model copy resilient to stale output links (drops and warns instead of throwing). |
| gladius/src/ModelState.h | Makes compilation state atomic and lock-free. |
| gladius/src/MeshVoxelGridManager.h | Updates APIs to accept PrimitiveDataBuffer (with resource tracking). |
| gladius/src/MeshVoxelGridManager.cpp | Adds guarded kernel dispatch for voxel grid build. |
| gladius/src/MeshSdfMethod.h | Adds MeshQualityIssueSummary aggregation type. |
| gladius/src/MeshBVH.h | Adds MeshQualityDiagnostics to BVH/mesh data for topology issues. |
| gladius/src/mcp/tools/RenderingTool.cpp | Switches camera settling to snap-to-target. |
| gladius/src/mcp/tools/FunctionEvaluatorTool.cpp | Adds guarded kernel evaluation with payload snapshot + wait list. |
| gladius/src/kernel/sdf.cl | Adjusts NanoVDB sampling scaling. |
| gladius/src/io/3mf/ResourceDependencyGraph.h | Adds BooleanObject processing hook. |
| gladius/src/io/3mf/ResourceDependencyGraph.cpp | Implements BooleanObject dependency tracking. |
| gladius/src/io/3mf/LibraryExampleExtractor.h | Adds API for extracting example constants from library 3mf files. |
| gladius/src/io/3mf/Importer3mf.h | Adds boolean object build helpers and mesh-id collection helpers. |
| gladius/src/io/3mf/FrontlitThicknessSolver.cpp | Avoids implicit narrowing by explicitly transforming doubles to floats. |
| gladius/src/ImageRGBA.h | Adds GPU resource generation tracking and safe retirement around mutations/destruction. |
| gladius/src/GLImageBuffer.cpp | Ensures write occurs on readpixel setup and clears dirty state. |
| gladius/src/Document.h | Adds explicit destructor contract around joining async workers; adds mesh-quality summary getter. |
| gladius/src/Document.cpp | Implements destructor joining workers; adds mesh-quality aggregation and NanoVDB policy enforcement. |
| gladius/src/ComputeContext.h | Adds GPU access coordinator/event registry APIs and safe-mode toggles. |
| gladius/src/ComputeContext.cpp | Implements queue ID tracking, event registry integration, and resource-idle waits. |
| gladius/src/compute/RenderPayloadSnapshot.h | Adds snapshot of common render payload GPU handles for guarded dispatch. |
| gladius/src/compute/Rendering.cpp | Switches thumbnail camera settling to snap-to-target. |
| gladius/src/compute/ProgramManager.h | Adds preview/optimized source update helpers. |
| gladius/src/compute/ProgramManager.cpp | Implements preview-only vs optimized source publication separation. |
| gladius/src/compute/OpenClEventRegistry.h | Adds event-ID → cl::Event registry API. |
| gladius/src/compute/OpenClEventRegistry.cpp | Implements event recording/polling/waiting and cleanup. |
| gladius/src/compute/MeshPreparationProgram.cpp | Adds guarded dispatch/wait-list handling for mesh preparation kernels. |
| gladius/src/compute/GpuKernelAccessGuard.h | Adds RAII guard for declaring GPU resource accesses and collecting wait lists. |
| gladius/src/compute/GpuKernelAccessGuard.cpp | Implements access planning, wait-event resolution, and completion recording. |
| gladius/src/compute/GpuAccessCoordinator.h | Adds core GPU-free coordination model for resources/generations/access plans/retirements. |
| gladius/src/compute/ComputeCore.h | Adds parameter generation, optimized source generation plumbing, and member order safety notes. |
| gladius/src/CMakeLists.txt | Adds MSVC/Ninja job-pool tuning and refines precompiled header strategy. |
| gladius/src/CLProgram.h | Adds explicit wait-list kernel enqueue API. |
| gladius/src/CLProgram.cpp | Improves OpenCL dump env var parsing to accept more truthy values. |
| gladius/src/Buffer.h | Adds GPU resource generation tracking and safe retirement around mutations/destruction. |
| gladius/CMakePresets.json | Moves build parallelism env var + adds build preset job counts. |
| gladius/CMakeLists.txt | Adds MSVC heap setting and Ninja job pool controls. |
| docs/architecture/gpu_access_coordination.md | Adds architecture documentation for the GPU access coordination invariant and workflow. |
| .serena/memories/library-best-practices.md | Adds library authoring best practices guidance for 3MF library items. |
Comment on lines
+9
to
+17
| | Field | Type | Constraints | Description | | ||
| |-------|------|-------------|-------------| | ||
| | name | string | `lower_snake_case`, unique within category | Human-readable entry name (e.g., "symmetry_y") | | ||
| | category | enum | One of: primitives, csg, modifiers, operations, mechanical, lattices, textures | Library category | | ||
| | description | string | Non-empty, ≤100 characters | One-sentence human-readable description | | ||
| | tags | string[] | Minimum 5 items, unique entries | Searchable keywords (e.g., "symmetry", "mirror", "transformation") | | ||
| | tagged_function_id | integer | Positive, unique within entry | Resource ID of the primary exportable function | | ||
| | thumbnail_path | string | Relative path to PNG in library directory | Path to rendered preview image | | ||
| | shipped | boolean | Default: false | Whether this item is part of the shipped library | |
Comment on lines
+93
to
+97
| 4. **Function return type consistency**: | ||
| - primitives/csg/mechanical/lattices → `float shape` (SDF) | ||
| - modifiers/operations → `vec3 result` (position transform) or `float shape` (if SDF modifier) | ||
| - textures → `vec3 color` (color output) | ||
| 5. **Parameter naming**: All parameters use `lowerCamelCase`, no reserved GLSL names (pos, normal, etc.) as parameter names without prefix |
Comment on lines
+108
to
+122
| program_snippet: | | ||
| // Function: symmetryY (ID: 1) | ||
| vec3 symmetryY(vec3 pos) { | ||
| return vec3(-pos.x, -pos.y, pos.z); | ||
| } | ||
|
|
||
| // Function: main (ID: 2) [root] | ||
| (float shape) main(vec3 pos) { | ||
| float radius = 10.0; | ||
| vec3 p = symmetryY(pos); | ||
| shape = length(p) - radius; | ||
| } | ||
| function_id: 1 | ||
| description: "Point reflection across YZ plane (mirrors X and Z coordinates)" | ||
| tags: |
Comment on lines
+74
to
+81
| ### In Auto mode the transition between "fast enough" and "not fast enough" should only happen towards the faster version during interactions | ||
| If the system is in Auto mode and it decides that the model is too slow to render in full quality while I interact, it should switch to a simpler rendering mode. But it than should stay in that mode until I stop interacting. It should not switch back and forth while I am dragging a slider or moving the camera. | ||
|
|
||
| --- | ||
|
|
||
| ### How the renderer decides what is "fast enough" for Auto mode | ||
| The time for the high quality rendering in static mode should be measured and used as a baseline for deciding what is "fast enough" for Auto mode. If the high quality rendering takes more than 100ms, then Auto mode should switch to a simpler rendering mode during interactions. If it takes less than 100ms, then Auto mode should use the high quality rendering during interactions. | ||
|
|
Comment on lines
+88
to
+89
| ### How catch-up is sequenced after interaction ends | ||
| When I stop interacting, the system should start a catch-up process to produce a full-quality current result if the current frame is not already full-quality. This process should be done in the background and should not block the UI. The system should first render a final frame in the current mode (which may be a low-res preview) and then start rendering the full-quality result. If the full-quality result takes a long time to produce, it should be rendered progressively, starting with a low-res preview by rendering more lines in full-quality mode.The time of the high quality rendering in static mode should be measured (s. above). |
Comment on lines
+322
to
+323
| public: | ||
|
|
Comment on lines
16
to
21
| explicit Buffer(ComputeContext & context) | ||
| : m_ComputeContext(context) | ||
| , m_gpuResource(m_ComputeContext.gpuAccessCoordinator().registerResource( | ||
| GpuResourceKind::Buffer, typeid(T).name())) | ||
| { | ||
| } |
Comment on lines
+5
to
+12
| ### Required Metadata | ||
| - **Name**: lower_snake_case, descriptive, no spaces or special chars except hyphens/underscores | ||
| - **Description**: One sentence explaining what the item does and key parameters | ||
| - **Tags**: Minimum 5 relevant keywords for discoverability (e.g., "primitive", "cone", "taper", "basic") | ||
| - **Tagged Function**: Exactly one function marked as tagged. Return type depends on purpose: | ||
| - `float shape` for SDF primitives/modifiers | ||
| - `vec3 result` for position transformations (symmetry, rotation, etc.) | ||
| - `vec3 color` for textures/materials |
…uidelines for optimized shell command execution
…ing shell thickness intervals and validation; update ShellExporter and MeshExportDialog for shell generation mode integration; add unit tests for ShellThicknessPartition functionality
…t-thickness shell bands; update ShellExporter to integrate OpenVDB generation mode; add unit tests for shell signed distance evaluation
… and surface-driven shell generation; update ShellExporter for new generation mode; enhance MeshExportDialog for shell export options; add unit tests for variable shell signed distance functionality
…rface extraction methods; add Layered Marching Cubes option; update PaletteExtractionOptions structure; enhance derivePaletteFromMesh function; add unit test for Layered Marching Cubes palette derivation
…shell material order; implement translucency scoring and shell reordering functions; add unit tests for shell material ordering functionality
…B mapping for target and achieved colors; ensure color values are clamped between 0 and 1 [MeshExportDialog] Set palette options to always convert colors to sRGB during palette derivation
…e for thickness field sampling and shell SDF computations
…esource in active access evaluation
…unce; prevent premature rendering state transitions
…20% for improved responsiveness
…o use optional for pending deletions
…alidation messages; [FrontlitThicknessSolver, OpenVdbShellGenerator] Refactor thickness solver and shell generator for improved error handling and resource management; [ShellMaterialOrdering, ShellThicknessPartition] Optimize material ordering and thickness partitioning logic; [PaletteExtractor, MeshExportDialog] Enhance palette extraction and UI dialog functionality; [tests] Update unit tests for consistency and coverage
…dditional warning flags for MSVC [GamepadActionDispatcher] Handle cancellation action by deselecting in the gamepad action dispatcher
…ource ID and generation for improved clarity
…ctionality with snapshot management; add SaveSnapshot structure and related methods
…Implement document identity management for save operations; enhance snapshot handling and add thumbnail attachment functionality
…ge renderable scene generations and their associated resources and programs [RenderSceneState] Refactor RenderSceneState to streamline context management and resource access [RenderSession] Introduce RenderSession class to encapsulate scene resources and inputs for rendering [RenderSessionInputs] Add RenderSessionInputs struct to hold per-dispatch values for a render session [NodeBase] Refactor NodeBase methods to use inline definitions for improved readability [ComputeCore_tests] Enhance ComputeCore tests to validate render session behavior and scene generation revisions
… ensure target-local PCH to avoid MSVC compilation issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements across build configuration, GPU resource management, and documentation for Gladius. The most significant changes include enhanced GPU buffer lifecycle management, new build parallelism controls for MSVC/Ninja, and new documentation on GPU access coordination and library best practices.
GPU Resource Management Improvements:
Bufferclass now tracks and safely retires GPU resource generations before buffer mutation or release, ensuring no cross-queue races and proper resource cleanup. This includes waiting for GPU resource idleness, retiring generations, and handling errors robustly. (gladius/src/Buffer.h) [1] [2] [3] [4] [5] [6]gpuResourceHandle()accessor toBufferfor external resource tracking. (gladius/src/Buffer.h)Build System and Parallelism Controls:
/Zm200for more compiler heap and per-pool job limits. (gladius/CMakeLists.txt,gladius/src/CMakeLists.txt) [1] [2]CMAKE_BUILD_PARALLEL_LEVELto the environment and addingjobsto build presets. (gladius/CMakePresets.json) [1] [2] [3]Documentation Additions:
docs/architecture/gpu_access_coordination.md).serena/memories/library-best-practices.md)OpenCL and Diagnostics:
CLProgramnow supports passing explicit wait lists for cross-queue synchronization. (gladius/src/CLProgram.h) [1] [2]gladius/src/CLProgram.cpp)These changes collectively make GPU resource usage safer, builds more robust on Windows, and improve both developer and user documentation.