wg_engine: alpha premultiplied bug fix#4070
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes an alpha premultiplication bug in the WebGPU engine by introducing a texture preprocessing stage using compute shaders. The preprocessing handles alpha premultiplication for non-premultiplied textures and channel shuffling for ARGB format textures to convert them to the universal RGBA format.
Key changes:
- Added compute shaders for texture preprocessing (premultiplication and channel shuffling)
- Modified fragment shader to remove redundant alpha premultiplication
- Updated texture handling to track premultiplication and shuffle state
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tvgWgShaderSrc.h | Added declaration for compute shader source |
| tvgWgShaderSrc.cpp | Implemented three compute shader variants and fixed fragment shader alpha handling |
| tvgWgRenderData.h | Added metadata fields to track texture state |
| tvgWgRenderData.cpp | Updated texture initialization to detect format and premultiplication needs |
| tvgWgPipelines.h | Added compute pipeline declarations and release method |
| tvgWgPipelines.cpp | Implemented compute pipeline initialization and cleanup |
| tvgWgCompositor.h | Added staging texture and preprocessing queue |
| tvgWgCompositor.cpp | Implemented texture preprocessing logic in flush operation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c4a61fe to
c761414
Compare
Fixes an alpha premultiplication bug in the WebGPU engine by introducing a texture preprocessing stage using compute shaders. The preprocessing handles alpha premultiplication for non-premultiplied textures and channel shuffling for ARGB format textures to convert them to the universal RGBA format. Added compute shaders for texture preprocessing (premultiplication and channel shuffling) Modified fragment shader to remove redundant alpha premultiplication Updated texture handling to track premultiplication and shuffle state #4041
c761414 to
c6d4ad1
Compare
|
882f621 to
ee0ce46
Compare
| WGPURenderPipeline tint_effect{}; | ||
| WGPURenderPipeline tritone_effect{}; | ||
| // compute shaders | ||
| WGPUComputePipeline compute_alpha_premult_shuffle{}; |
There was a problem hiding this comment.
nit: since we have multiple *_shuffle names, is it possible for you to consider a more descriptive suffix for these specific cases (like _bgr / _swizzle) to make the intent a bit clearer at call sites? Totally optional.
1f2f79f to
f2ae0e8
Compare
ed8518f to
21f0f8f
Compare
5cb1306 to
f076d22
Compare
a00fdaa to
9bd7217
Compare
Fixes an alpha premultiplication bug in the WebGPU engine by introducing
a texture preprocessing stage using compute shaders.
The preprocessing handles alpha premultiplication for non-premultiplied textures and
channel shuffling for ARGB format textures to convert them to the universal RGBA format.
Added compute shaders for texture preprocessing (premultiplication and channel shuffling)
Modified fragment shader to remove redundant alpha premultiplication
Updated texture handling to track premultiplication and shuffle state
#4041