gl: convert straight alpha to premultiplied alpha on texture upload#4046
gl: convert straight alpha to premultiplied alpha on texture upload#4046wenjieshen wants to merge 1 commit into
Conversation
6973178 to
6ea9cb2
Compare
There was a problem hiding this comment.
Pull request overview
This PR moves straight-alpha to premultiplied-alpha conversion from GPU fragment shaders to CPU during texture upload, improving rendering correctness for images with transparency. The conversion uses OpenMP parallelization to maintain performance while fixing the rendering issue described in #2863.
Key changes:
- CPU-side alpha premultiplication during texture upload with parallel processing
- Color space metadata update to reflect premultiplied format after conversion
- Shader comments marking straight-alpha paths as forbidden in GL
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/renderer/gl_engine/tvgGlShaderSrc.cpp | Added comments marking straight-alpha conversion paths as forbidden in GL implementation |
| src/renderer/gl_engine/tvgGlRenderer.cpp | Implemented CPU-side alpha premultiplication with buffered conversion and color space mapping |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8d0bf4d to
ec940ce
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ec940ce to
0b91e0e
Compare
0b91e0e to
2d9e273
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Convert images with straight alpha to premultiplied alpha during texture upload instead of in the shader. Moves the premultiplication from GPU (per-fragment) to CPU (once during upload), Updates the shader to indicate straight alpha formats as already forbidden. #4041
2d9e273 to
5017e23
Compare
SergeyLebedkin
left a comment
There was a problem hiding this comment.
will grad the solution for wg
approved
|
|
||
| if (!image->premultiplied && image->channelSize == sizeof(uint32_t)) { | ||
| auto buffer = (uint32_t*)malloc(image->w * image->h * sizeof(uint32_t)); | ||
| auto h = static_cast<int32_t>(image->h); |
There was a problem hiding this comment.
@wenjieshen openmp is not the best for this. can't use the gpu power?
3601f9b to
9dc94fd
Compare
882f621 to
ee0ce46
Compare
|
Convert to draft until completion of the GPGPU version by referring to WebGPU engines. |
1f2f79f to
f2ae0e8
Compare
ed8518f to
21f0f8f
Compare
5cb1306 to
f076d22
Compare
a00fdaa to
9bd7217
Compare
The problematic file in #2863 performs correctly.

PicturePngshows a difference of less than 1%.Picture*andImage*is not observed significant regression.Related issues #4041