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
GSoC 2023: Final Checkpoint #4752
Closed
Closed
Conversation
This file contains 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
jbinvnt
force-pushed
the
gsoc-2023-final-checkpoint
branch
from
September 22, 2023 22:57
3f22cd2
to
ef643c7
Compare
Note: The |
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.
Google Summer of Code 2023 Final Report
My original GSoC project proposal may be viewed here.
Initial Notes About this Pull Request
This PR will contain my final report on work that I did during Google Summer of Code 2023. Although it is expected that code from this branch will be revised and merged at a later date, this particular pull request should not be edited after this year's GSoC ends. Closing this PR and instead doing the future work on a new branch will preserve the record of what was done for GSoC.
Commits from Last Year
Several of the commits on this branch match those from my GSoC 2022 PR #4330. That is because this branch rebases the shader features I created last year onto the current version of
master
(including my GSoC 2023 work).About the Project
This project restructures portions of OpenSCAD's rendering code to help the transition to modern OpenGL capabilities. My initial work focused on consolidating duplicate instructions into a single class that can be used across different types of renderers. Readability improvements were also implemented in a few places. My final topic of work involved allowing an initial build to be made with OpenGL Core 3.2, the first GL version that fully removes deprecated immediate/fixed-function/legacy API calls. The process of building modern replacements for all those features is an ongoing effort. Fortunately, I did some of that work already: my GSoC project last year was to enable GLSL shaders for the F6 render view. The final commits here involve updating the GSoC 2022 code to be compatible with the latest changes I made this year.
Pull Request Structure
I presented my work this summer in a modular fashion with incrementally merged PRs. Also note that all branches are prefixed
gsoc-2023-
.This Year
From newest to oldest
Last year
Topline Summary of Enhancements
Detailed Description of Changes
To reiterate, the diff of this particular PR actually reflects mainly my work from GSoC 2022. To see the changes introduced from 2023, look at the individual pull requests linked above.
Building with a Core Profile
With normal build settings, OpenSCAD builds using an OpenGL Core profile will currently fail due to the use of legacy calls. The option that I created to fix this can be activated by adding the flag
-DDISABLE_FIXEDFUNCTION_GL="ON"
to CMake.For my testing, I used GLAD to switch from a compatibility profile to core. GLAD support was added in #4549 and can be activated with
-DUSE_GLAD="ON"
. And to get the CLI that generates the header files, I installed the Python module usingpip3 install git+https://github.com/Dav1dde/glad.git
.Generally the GLAD command structure to use is kept in the README. However, that may not match exactly what was used to produce a certain development configuration. So the most accurate reference may be in the auto-generated comments at the beginning of the header files themselves.
Using the Vertex State Manager
A
VertexStateManager
wraps common operations for initialization and activation of vertex arrays. Previously, slight variations of these operations were duplicated across functions in classes likeCGALRenderer
andOpenCSGRenderer
. Now, when a modernization is implemented for one function, it can take effect across all renderers at once.Objects of type
VertexStateManager
are intended to be scoped within a larger rendering function. Initialization takes references to both the current renderer and the vertex array to be managed.Source
For example, instead of replicating the decision logic for setting the vertex array's size,
vsm.initializeSize
can be called with the number of vertices. Other functions can also be added later toVertexStateManager
as reusable parts of modern OpenGL rendering processes are discovered.Testing
Running a core profile build as described above requires a few extra steps to run without crashing. First, enabling all experimental
vertex-...
features in the settings menu is required. Secondly, because F5 mode still relies on OpenCSG, previews are likely to cause a segfault until the necessary future work is done. F6 renders do not cause an error, but nothing is shown because of the viewport's reliance on legacy calls.This PR doesn't introduce any CI test failures beyond those that might be present in the current
master
branch that it is based on.Challenges Encountered
Legacy OpenGL has deep roots in the OpenSCAD codebase. Full modernization will require a long-term effort. Moreover, the interdependence of many features means that even after some functions are updated to use shaders, the results can't fully work in a Core Profile build until many other portions are brought up-to-date as well.
Work to modernize the fundamental rendering is also happening in parallel with other changes to extension loading and dependencies. These different aspects will require ongoing coordination to proceed in harmony, but fortunately I think that aspect has been going well so far.
Last GSoC Commit
I plan to contribute to this feature as a volunteer after GSoC ends. The last commit I made for GSoC will likely have its hash change after a pre-merge rebase. The most reliable way to find it is going to be looking at the top commit of #4738.
Future Work
Future work will be a step-by-step process of creating shader-based replacements for functionality that is now disabled by the macro. Also, so that current builds of
master
can be functional, the GLAD header files are left on a compatibility profile. When everything is ready to switch to a version of OpenGL Core in the future, they can be regenerated.