Commit Graph

17 Commits

Author SHA1 Message Date
TÖRÖK Attila 9522acf61d render/wgpu: Switch to pipeline-overridable constant for bitmap saturation order toggle
Also call it `late_saturate` instead, to avoid the confusing negation
between the constant name and the (now removed) shader module name.
2024-05-17 22:13:13 +02:00
TÖRÖK Attila f9f4c3bb82 render/wgpu: Drop `naga_oil` in favor of manual string manipulation 2024-05-16 20:24:49 +02:00
Nathan Adams de975a9727 wgpu: Merge Transforms and ColorAdjustments 2024-01-27 21:37:22 +01:00
Nathan Adams befce41e11 wgpu: Remove push constant support - simplifies code significantly, and it should be same perf now 2024-01-27 21:37:22 +01:00
Aaron Hill 8425eab1f0 render: Compile a different version of 'bitmap.wgsl' for Stage3D
When using the bitmap.wgsl shader for normal rendering, we need
to saturate immediately after applying the color transformation
to reproduce Flash Player's behavior. This makes the (possibly
transformed) alpha value get multiplied by a in-range color,
instead of a potentially out-of-range color.

However, Stage3D just applies a no-op color transformation,
and should only saturate at the very end
(not after the intermediate division by the original alpha value).

To support both of these requirements, I've added in a new
`early_saturate` ifdef that controls when we apply 'saturate'.
We then compile the shader twice (once with early_saturate=true
and once with early_saturate=false), and use the two versions
in the right pipelines.

We could use a simpler shader for Stage3D - however, it can't just
be a plain copy, as we need to apply the viewport transformation.
For now, I'm re-using the shader code to keep things simple. If
this becomes a performance issue in stage3d, we could revisit this.
2023-03-19 02:15:26 -05:00
Aaron Hill de8448e00a
avm2: Implement Stage3D depth test, blend factors, and fix bugs (#9845) 2023-03-12 23:43:58 +00:00
Nathan Adams edd7f80341 wgpu: Fix blown out colors when transforming them above 100% - fixes #9698 2023-02-24 19:01:41 +01:00
Aaron Hill 0fe8ef6c2d Get naga_oil shaders working 2023-01-23 11:31:04 +01:00
Nathan Adams ae75a3c166 wgpu: Use push constants for both Transforms and ColorAdjustments, when available 2023-01-10 09:39:28 +01:00
Nathan Adams fb78a39125 wgpu: Switch to experimental crate naga_oil for combining shaders 2023-01-10 09:39:28 +01:00
Nathan Adams 3dd9c4daa3 wgpu: Moved ColorAdjustments into its own bind group, and reuse ColorAdjustments::IDENTITY where we can 2023-01-03 03:39:13 +01:00
Nathan Adams 92044c9c02 wgpu: Merge bitmap bind groups 2 and 3 2022-09-11 09:07:53 +02:00
relrelb 65be2adc63 wgpu: Bump to `0.13.0`
Based on the work in #6717, plus additional adaptions mentioned in
https://github.com/gfx-rs/wgpu/blob/master/CHANGELOG.md#wgpu-013-2022-06-30,
and more not-mentioned but required changes.

Also bump `wasm-bindgen` to `0.2.81` (along with its helper crates), as
required by the new `wgpu` version.

Note that I don't fully understand some of the required changes, notably:
* `wgpu::PresentMode::Mailbox` no longer works on my machine (Windows 11) -
The `wgpu` documentation says that `wgpu::PresentMode::Fifo` is the
only guaranteed to be supported, so I switched over to it instead.
* `self.staging_belt.recall()` doesn't return a `Future` anymore -
I assume it became synchronous so I simply removed the `executor`
from there.
2022-07-02 16:44:37 -07:00
Mike Welsh 121c2577b4 wgpu: Clamp alpha in shaders (fix #6954) 2022-05-12 14:50:25 -07:00
Mike Welsh 9c11870a08 wgpu: Use linear color render target
Always use a non-sRGB texture as the render target so that color
and alpha blending are in sRGB space, matching Flash behavior.

If the surface format requires sRGB, render to an intermediate
linear buffer and copy to the surface as a final render step.
2022-04-15 14:52:33 -07:00
Mike Welsh 26e0432ccc wgpu: Fix some invalid WGSL
naga is currently lenient about some things which are invalid by
the WGSL spec. The Tint WGSL compiler disagreed, so these shaders
failed to compile in Chrome.
2021-10-25 21:59:09 -07:00
Mike Welsh e10d0fcbe7 wgpu: Switch shaders to WGSL 2021-10-24 17:20:19 -07:00