Commit Graph

51 Commits

Author SHA1 Message Date
Nathan Adams 0cca4983e4 wgpu: Merge gradient shaders together 2023-03-06 23:22:09 +01:00
Nathan Adams 622abe60d1 wgpu: Extract T->Color lookup from gradient shader to Mesh construction 2023-03-06 23:22:09 +01:00
Nathan Adams edd7f80341 wgpu: Fix blown out colors when transforming them above 100% - fixes #9698 2023-02-24 19:01:41 +01:00
Nathan Adams e73389aa71 wgpu: Implement blur filter 2023-02-05 18:41:43 +01:00
Nathan Adams 284a58c817 avm2: Implement BitmapData.apply_filter for ColorMatrixFilter 2023-02-05 18:41:43 +01:00
Nathan Adams 013a2424ef wgpu: Only use uniform buffers for gradients, we don't need storage buffers now that we squeeze the ratios into alignment 2023-02-05 18:02:19 +01:00
Nathan Adams f9b378b29a wgpu: Changed most pipelines & shaders to only use Pos, not Pos and Color, as vertex attribs 2023-02-05 18:02:19 +01:00
Nathan Adams 7b1c101c81 wgpu: Fix repeat & reflect gradients 2023-01-29 17:17:44 +01:00
Nathan Adams 1bfa69ade2 wgpu: Guard against infinite loops in gradient shader - fixes #9260 2023-01-23 23:25:30 +01:00
Aaron Hill ffc393e3e8 render: Work around naga_oil duplicate definition bug 2023-01-23 11:31:04 +01:00
Aaron Hill 0fe8ef6c2d Get naga_oil shaders working 2023-01-23 11:31:04 +01:00
Nathan Adams 2e7201334d wgpu: Detect if buffers are unusable on web and fail to create wgpu renderer if so 2023-01-12 18:37:28 +01:00
Nathan Adams 8db8e4669a wgpu: Implement Multiply blend mode as a trivial blend 2023-01-12 10:54:03 -05:00
Nathan Adams 09608c2abc wgpu: Implement Screen blend mode as a trivial blend 2023-01-12 10:54:03 -05:00
Nathan Adams 62f9b11417 wgpu: Fixed color shader working in correct color space 2023-01-10 09:39:28 +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 4e5749a7e4 wgpu: When push constants are available, use those for Transforms 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 cb6d72b49b wgpu: Split up gradient shader based on type and repeat 2023-01-03 03:39:13 +01:00
Nathan Adams a79e73fb12 wgpu: Clean up gradient shaders by bringing out common shared source into a same file 2023-01-03 03:39:13 +01:00
Nathan Adams 91561e8c35 wgpu: Reduce gradient.ratios uniform memory by 4x 2023-01-03 03:39:13 +01:00
Nathan Adams 312e72451f wgpu: Reduce gradient.colors uniform memory by 4x 2023-01-03 03:39:13 +01:00
Nathan Adams c0ec5c5010 wgpu: Split up blend modes into their own shaders for performance 2023-01-03 03:39:13 +01:00
Nathan Adams c6045a4f24 wgpu: Multiply can't be trivial blend mode because of 0 alpha 2023-01-03 03:39:13 +01:00
Nathan Adams f253abdbd1 wgpu: Made Multiply, Add and Subtract blend modes use bitmap+blend 2023-01-03 03:39:13 +01:00
Nathan Adams 7e564185b5 wgpu: Handle alpha correctly for add or subtract blendmodes 2023-01-03 03:39:13 +01:00
Nathan Adams b0e345335f wgpu: Workaround naga-vulkan bug with default position in switch statement 2023-01-03 03:39:13 +01:00
Nathan Adams 8311ddb0da wgpu: Allow for different sized subcommand list targets, but don't use them yet 2023-01-03 03:39:13 +01:00
Nathan Adams 7904c3d4f0 wgpu: Implement all blend modes 2023-01-03 03:39:13 +01:00
Nathan Adams f9333e2626 wgpu: Perform command rendering recursively and chunk up blends. Blends are still not implemented, it just copies to parent. 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
Nathan Adams 0ac2a3f361 wgpu: Try lower limits when full aren't available, and use uniforms for gradients if storage won't work 2022-09-04 18:55:13 -07: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 4a38d36cd7 wgpu: Output premultiplied alpha 2022-04-17 08:33:51 -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 bfe0ee2563 wgpu: Fix gradient shader on vulkan backend
A regression in naga caused a mistranslation of the gradient shader
on the vulkan backend. This caused radial gradients to be rendered
as linear gradients on the vulkan backend. dx12 seems unaffected.

This seems to be cased by a switch statement starting with a default
case Re-order the case statements to avoid this. Looks like it's been
fixed in naga master.
2022-01-22 20:54:18 -08:00
Mike Welsh 1e28e1da11 chore: Bump to wgpu 0.12 2022-01-19 13:20:27 -08: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
Mike Welsh 9067dd3668 wgpu: Allow GL as a graphics backend option 2021-10-24 17:20:19 -07:00
Mike Welsh decc38a45c wgpu: Use uniforms instead of push constants 2021-10-24 17:20:19 -07:00
Mike Welsh f343aff502 wgpu: Use a single render pass and push constants
Switch to a single render pass for the whole frame, as opposed to
a render pass per draw call. This should be a large improvement to
performance. This currently requires some unsafe to work around a
self-reference between RenderPass and CommandEncoder in Frame;
this could eventually be cleaned up by changing RenderBackend
to return a Frame object instead of using begin_frame/end_frame
pairs.

Also switch to using push constants for the transform/color
uniforms.
2020-12-27 00:44:11 -08:00
Nathan Adams 8436be7d55 render: Mark the gradient buffer as readonly in wgpu renderer 2020-10-25 12:07:58 -07:00
Nathan Adams 20ff951d5e render: Split off common mesh binds into a mesh bind group for wgpu renderer 2020-10-23 13:02:27 -07:00
Nathan Adams bbd8fc768c render: Store view_matrix as a global in wgpu renderer, and only change it when changed 2020-10-17 04:16:24 -07:00
Nathan Adams 4dd5fcfd6a render: Don't make a new sampler for each bitmap in wgpu renderer 2020-10-17 04:16:24 -07:00
Mike Welsh 103c7a98f0 wgpu: Implement linear RGB gradients 2020-05-22 11:03:16 -07:00
Nathan Adams 1aa3e423d7 render: Changed gradient uniform in wgpu shader to a SSBO instead of UBO, saving 192 bytes on each buffer 2020-05-10 23:48:11 -07:00