-
-
Notifications
You must be signed in to change notification settings - Fork 160
gl_engine/shader: Introduced binary shader caching #3897
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
base: main
Are you sure you want to change the base?
Conversation
a821049
to
2dcd2cf
Compare
2dcd2cf
to
9941559
Compare
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.
Pull Request Overview
This PR implements a binary shader caching system for the OpenGL renderer to improve performance by eliminating redundant shader compilation on subsequent application runs. The system automatically stores compiled OpenGL shader binaries to disk and attempts to load them before falling back to source compilation.
- Introduces
GlShaderCache
class with persistent binary shader storage and retrieval functionality - Integrates caching into existing
GlProgram
compilation pipeline with transparent fallback behavior - Adds OpenGL 4.1+ binary shader API support via
glGetProgramBinary
/glProgramBinary
extensions
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
tvgGlShaderCache.h | Defines GlShaderCache class interface for binary shader caching operations |
tvgGlShaderCache.cpp | Implements shader cache functionality with file I/O and hash-based naming |
tvgGlProgram.cpp | Integrates shader caching into program compilation with cache-first loading |
tvgGl.h | Adds OpenGL 4.1 binary shader API constants and function pointer declarations |
tvgGl.cpp | Implements dynamic loading of binary shader API functions with version checking |
meson.build | Adds new shader cache source files to build configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
94fa894
to
95cb9bd
Compare
@hermet @SergeyLebedkin Binary shader support is an OpenGL 4.1+ feature, while our requirement is OpenGL 3. I added a helper function glIsProgramBinarySupportAvailable() in tvgGl.h to check runtime availability. This is the first runtime capability check in the project, so I’m not sure if this approach aligns with our design principles. Although my MacBook Air supports OpenGL 4.1, it still returns GL_NUM_PROGRAM_BINARY_FORMATS = 0, meaning binary shader support isn’t available. I’m waiting for GPU access on a cloud platform to test the performance improvement in another environment. While waiting, I’ll continue investigating the stroke rendering issue on the GL engine. |
@wenjieshen Looks good, if the binary shaders doesn't working, we can fallback to a normal scenario. |
@wenjieshen Could you please double-check this as well? a few systems might use this |
@hermet Understood, I’ll pause the PR. |
@wenjieshen I mean we can hold support v3 for binary shaders. I didn't mean hold this PR. Please go proceed. :) Thanks. |
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.
@wenjieshen Please check comments and please respect thorvg coding convention.
Thanks.
9057eb4
to
e7ff8e7
Compare
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.
Most your comments are unnecesary. Don't need to add comments for saying code itself.
We'd rather leave comments when it needs a unusual, special context and purposes.
7ce8965
to
498162c
Compare
2a2f4db
to
3b8869a
Compare
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.
see comments
#include "tvgGlShaderCache.h" | ||
|
||
#ifdef _WIN32 | ||
#define WIN32_LEAN_AND_MEAN |
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.
3b8869a
to
10876eb
Compare
@wenjieshen Please check your commit message. I marked some inappropriate msg (recommend to remove), Thanks.
|
5f1bd2d
to
b775c14
Compare
@hermet Thank you. I have updated the commit message. |
Implement binary shader caching system to improve OpenGL performance by: - Add GlShaderCache class with read/write functionality for compiled shaders - Support OpenGL binary shader format - Add proper OpenGL ARB extension loading for glGetProgramBinary/glProgramBinary - Integrate caching into GlProgram compilation pipeline This reduces shader compilation overhead on subsequent application runs, significantly improving startup performance for OpenGL-based rendering. Related issue: thorvg#2884
b775c14
to
3a7a8a6
Compare
We've implemented a comprehensive binary shader caching system to significantly improve OpenGL rendering performance on macOS by eliminating redundant shader compilation overhead on subsequent application runs.
This feature introduces the
GlShaderCache
class that provides persistent storage and retrieval of compiled OpenGL shader binaries. The system automatically caches compiled shader programs to the user's cache directory using a hash-based naming scheme and attempts to load cached binaries before falling back to source compilation.Key implementation details:
glGetProgramBinary
/glProgramBinary
extensionsGlProgram
compilation pipelineThe caching mechanism works transparently:
Performance benefits:
issue: #2884