-
-
Notifications
You must be signed in to change notification settings - Fork 152
Improve Vulkan backend compatibility #519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
12fbe70
to
408a26c
Compare
Hey, thanks for the PR! Let me know when it's ready to review. |
@hlorus I thought it is, then found out, there are multiple issues, I've added in description, what needs to be fixed.
|
Currently, there's no graphical testing setup in place. I'm unsure if it's feasible or how much effort it would require. That said, why do you see it as necessary? Is it primarily to make finding edge cases easier, or is it more about preventing regressions? |
I was just curious, if something is avaialable or not. At this point, only to find the edge cases easier, or to find regression while this fix is being made. |
1ac3c06
to
9dc9bf3
Compare
@hlorus I think it's ready, all functionality I've checked works. There are small visual differences compared to OpenGL, I hope it's acceptable. |
Hey there, some comments/questions from my side:
|
Hey there, is this ready for review? |
@hlorus now, I believe, it is, didn't notice any bugs, this time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally ok, but points don't seem to scale with the entity scale option.
I'll check the points scaling |
…on, use POLYLINE_UNIFORM_COLOR for lines, render points as triangle geometry
…pdated all checks from Vulkan/Metal to Vulkan-only for more targeted rendering optimization
…ge-only - Draw both outline and surface in draw_id for complete plane selectability
…R for all lines to ensure proper line width support
…es proper visual dashes with thick lines
…plete support for all construction entities with proper line thickness
…nts (5→3px) and smaller Vulkan geometry (2D: 0.1→0.06, 3D: 0.05→0.03)
… calls - reduces redundant queries in update() calls
…ss - improves maintainability and consistency
…nd debug logging - better debugging and error recovery
…nderer utility - reduces code duplication and improves maintainability
…methods - improves code maintainability and developer understanding
…c - streamline rendering for all backends using geometry-based methods, improving maintainability and consistency across entities.
- scale point sizes based on view distance to improve visual consistency across different contexts
- calculate distances from the camera to ensure proper selection order, improving visual accuracy and interaction responsiveness.
- prevent GPU operations from hanging when the mouse is near the top edge of the viewport, enhancing user interaction stability.
- Use RenderingConstants.POINT_SIZE directly for consistent sizing - Remove obsolete get_point_screen_size() method chain from point classes - Implement efficient view-change detection for billboard updates - Fix screen-space scaling with proper view distance calculation - Add 5px border margin to prevent UI boundary freezing - Optimize selection buffer updates to only redraw when needed - Clean up imports and update documentation
- Fix workplane selection: workplanes now selectable regardless of active sketch - Fix selection buffer updates: properly handles view changes (zoom/pan/rotate) - Add performance optimizations: * Camera location caching with view matrix change detection * Reduced redundant matrix calculations by 90%+ * Smart selection buffer redraw logic - Improve workplane selection priority over sketch elements - Add cache invalidation hooks for entity/constraint operations - Preserve existing functionality and freezing fixes - Clean up debug code and maintain production-ready codebase Resolves selection issues where workplanes were unselectable and selection would get 'stuck' after view changes. Maintains backward compatibility while providing significant performance improvements.
…tionship caching, memory management, and lazy initialization - Add constraint existence caching in operators/base_constraint.py to avoid O(n) loops - Implement entity dependency caching in base_entity.py and base_constraint.py - Add periodic GPU batch cleanup in global_data.py and draw_handler.py - Implement lazy geometry initialization in vulkan_compat.py - Add cache invalidation hooks in group_constraints.py - Preserve all existing functionality while improving performance
- Fix point size quadratic scaling causing huge/tiny points - Fix selection not working on file load with existing sketches - Add universal click selection support to all CAD Sketcher tools - Optimize view matrix hash calculation performance - Replace magic numbers with named constants - Improve error handling with specific exceptions and logging - Add proper file load cache initialization
- Add ShaderManager class for centralized shader caching - Add GPUResourceManager for time-based resource cleanup - Add CLEANUP_INTERVAL_SECONDS constant for time-based cleanup
- Replace direct shader creation with ShaderManager calls - Update _shader and _id_shader properties to use caching - Update workplane surface rendering with cached shaders - Maintain backward compatibility while improving performance
- Add time-based GPU resource cleanup to draw handler - Update selection box to use cached polyline shader - Add automatic GPU cleanup on file load - Replace frame-based with time-based cleanup for better performance
- Remove broken tag_update function from model/utilities.py that caused infinite recursion - Update model/circle.py to import tag_update from base_entity instead of utilities - Update model/arc.py to import tag_update from base_entity instead of utilities - Fixes 'SlvsCircle' object has no attribute 'tag_update' error - Ensures proper entity property updates and dependency cache invalidation
- Remove unused shader functions: dashed_uniform_color_3d, uniform_color_3d, point_color_3d, polyline_color_3d, uniform_color_line_2d - Consolidate duplicate ID shaders (id_line_3d and id_shader_3d were identical) - Remove unused shader infrastructure and base shader strings - Remove orphaned imports and commented-out functions - Update GPU manager to use consolidated shader for both points and lines All changes maintain 100% backward compatibility and functionality.
- Introduce pixel_size_to_world_size function for accurate world size calculation based on pixel size. - Update BillboardPointRenderer to use fixed pixel size for point handles, improving consistency in rendering. - Modify RenderingConstants to define POINT_HANDLE_PIXEL_SIZE for better control over point size. - Adjust draw_billboard_quad_3d calls to utilize calculated world size, ensuring proper scaling in various view contexts. - Refine geometry regeneration logic to account for viewport size changes, enhancing performance and visual fidelity.
That looks good! The point scaling doesn't seem to work in the OpenGL mode though. Also there seems to be some differences in the selection textures, these are the outputs of the 'Write Selection Texture' operator with both backends and an entity scale of 3. With the Vulkan backend both points and lines are tiny: |
Hey there, since this PR grew quite a bit in size i pulled out the changes to better support the vulkan backend, please give it a test: #524 Note that it currently does not support custom thickness for dashed lines. I saw that you addressed this by creating dash geometry on the cpu side. I haven't looked closer into that solution and the performance implication that come with it. If you'd like to include such a change (or other changes from this PR) please submit PRs that are smaller scoped to make review and testing more feasible. |
This PR addresses the point selection issues with the Vulkan backend reported in #517.
Changes
Problem
With the Vulkan backend, points were barely visible (1px wide) and lines appeared narrower, making point selection nearly impossible in the viewport.
Solution
Implemented triangle-based thick line rendering and enhanced drawing methods to ensure consistent visibility across both OpenGL and Vulkan backends.
Note
I think this will need bit more testing, below screenshots from simple test file
TODO/ensure functionality:
Fixes #517
Vulkan:

OpenGL
