Commit Graph

250 Commits

Author SHA1 Message Date
TÖRÖK Attila e468047ec5 chore: Make web-sys a workspace-level dependency
Thereby deduplicating the version number of it.
2024-09-18 11:28:27 +02:00
Tom Schuster 0ac25b5808 chore: Update web-sys and js-sys 2024-08-20 21:18:36 +02:00
Kamil Jarosz 2ba5e47b59 render: Implement drawing lines using WebGL
This patch provides an efficient implementation of draw_line
and draw_line_rect for WebGL using Gl::LINE_STRIP.
2024-07-02 23:40:50 +02:00
Kamil Jarosz 7dd4d2006e render: Add primitives for drawing lines
This patch adds draw_line and draw_line_rect methods to CommandHandler,
providing empty impls to be overridden by corresponding backends.

The ability to draw lines is described using a new bitflags struct
RenderBackendFeatures, which contains a set of features
supported by the given render backend.
Currently, it contains a DRAW_LINES flag, which informs whether
the backend supports drawing lines as primitives.
2024-07-02 23:40:50 +02:00
Kamil Jarosz 28b86490cc render: Draw quads using Gl::TRIANGLE_FAN for WebGL
This patch changes the mode of drawing quads to Gl::TRIANGLE_FAN.
This makes the buffers smaller, as we need only 4 vertices instead of 6,
and allows them to be reused for rendering lines.
2024-07-02 23:40:50 +02:00
Kamil Jarosz 07df84a486 render: Add WebGlRenderBackend::draw_quad
Moving draw_rect to draw_quad prevents code duplication when
methods related to drawing lines are added.
2024-07-02 23:40:50 +02:00
Nathan Adams aa804e520b web: Store StageQuality in builder, do the defaulting in JS 2024-06-08 08:42:04 +02:00
Nathan Adams bb5ec64670 chore: Use workspace version for wasm-bindgen 2024-04-04 17:29:00 +02:00
Nathan Adams 45a2ab69c0 chore: Use workspace version for thiserror 2024-04-04 17:29:00 +02:00
Nathan Adams 2b2be8a992 chore: Use workspace version for log 2024-04-04 17:29:00 +02:00
Nathan Adams ab8b1c654c chore: Use workspace version for js-sys 2024-04-04 17:29:00 +02:00
Nathan Adams 937664e737 chore: Use workspace version for bytemuck 2024-04-04 17:29:00 +02:00
TÖRÖK Attila 36413a70f2 chore: Remove or ignore any unused deps detected by cargo-machete 2024-04-01 22:29:38 +02:00
sleepycatcoding 1b41abf3a3 chore: Remove unused dependencies 2024-03-25 17:45:26 +01:00
renovate[bot] 3f9f19b7ac fix(deps): update rust dependencies 2024-03-14 16:45:29 +01:00
TÖRÖK Attila 2e52ee9f33 chore: Bump `js-sys` and `web-sys` to `v0.3.69` 2024-03-04 19:01:04 +01:00
TÖRÖK Attila 7f268bf50e chore: Update `wasm-bindgen` to `v0.2.92`, wasm-bindgen-futures to `v0.4.42` 2024-03-04 19:01:04 +01:00
renovate[bot] 35d72115a4 fix(deps): update wasm-bindgen 2024-03-02 02:42:45 +01:00
renovate[bot] 6b89737093 fix(deps): update rust dependencies 2024-02-19 11:32:22 +01:00
renovate[bot] 637b277481 web: chore: Bump wasm-bindgen to 0.2.91 2024-02-16 09:48:30 +01:00
Nathan Adams 70fbb4a7ac render: Move away from SyncHandle.retrieve_offscreen_texture to RenderBackend::resolve_sync_handle 2024-02-02 00:59:45 +01:00
renovate[bot] 3737725a21 fix(deps): update rust dependencies 2024-01-30 09:23:15 +01:00
Nathan Adams fcb74d8fbc wgpu: Deduplicate common gradients from a single Mesh 2024-01-27 21:37:22 +01:00
Nathan Adams e479d12af0 render: Make Mesh a struct, not just an alias for Vec<Draw> 2024-01-27 21:37:22 +01:00
Aaron Hill 1cb24b41b0 render: Support PixelBender ByteArray/Vector.<Number> input/output
When ActionScript uses a ByteArray/Vector.<Number> as a shader input
or target, we create a temporary Rgba32Float texture, and copy the
input float32 bytes to/from the texture.

Unfortunately, wgpu doesn't seem to support an Rgb32Float (3-channel)
texture. When the shader uses 3 channels, we use a Rgba32Float
(4-channel) texture, and manually insert/remove padding for the
alpha channels. This isn't very efficient, but it's the simplest
solution.

The temporary textures themselves aren't cached anywhere - if this
becomes a performance issue, we could look into using some of our
existing wgpu texture/buffer pooling code.
2024-01-24 08:31:52 -05:00
renovate[bot] e0a22b56ce fix(deps): update wasm-bindgen 2024-01-15 17:24:02 -05:00
Aaron Hill 47db84473a avm2: Improve handling of Stage3D profile
We now validate the passed in profile, and return the selected profile
from 'Context3D.profile'. We don't yet alter the available
registers/textures based on the profile.
2024-01-07 22:34:33 +01:00
TÖRÖK Attila 217585daa8 chore: Delegate `[lints]` in `Cargo.toml` of all packages to the workspace 2024-01-05 11:28:19 +01:00
renovate[bot] a0c33382bf fix(deps): update wasm-bindgen 2023-12-04 12:08:22 +01:00
TÖRÖK Attila ca25f82900 chore: Bump wasm-bindgen to 0.2.89 (0.2.88 got yanked) 2023-11-28 21:43:41 -05:00
renovate[bot] acadb2b2d3 fix(deps): update wasm-bindgen 2023-11-07 12:18:50 +01:00
renovate[bot] 37e2c06034 fix(deps): update rust dependencies 2023-09-18 00:00:45 +02:00
relrelb 8031f9dd3a webgl: Apply color transform on gradient records
As described in #10517, Flash Player applies color transforms on
each gradient record, and then blends between those transformed colors.
2023-08-05 10:28:40 +03:00
Aaron Hill 583caa3389
avm2: Implement DisplayObject.blendShader (#12238) 2023-07-26 23:25:26 +00:00
Nathan Adams 77c0dac64b webgl: Implement pixel snapping 2023-07-22 00:34:17 +02:00
Nathan Adams 289f73c85f core: Add pixel snapping (default auto) to Bitmaps, and force it for cacheAsBitmap 2023-07-22 00:34:17 +02:00
Moulins 3ea67668c0 render: make Context3D renderers fully GC-agnostic
The 'gc_arena' dependency was only used to manipulate the `GcCell`s
containing the vertex and fragment shaders; replacing these by a
reference to a plain old `Cell` means tha  the Context3D traits and
types do not need to interact with GC'd object anymore.

As a knock-on effect, we can also remove the `Activation` parameter
from most of the `Context3DObject` methods.
2023-07-14 16:06:36 -06:00
moulins f5b4fbce77
Upgrade to new `gc-arena` API (#11182)
* core: add temporary, ruffle-internal copy of `gc-arena` crate

This will allow bumping the upstream `gc-arena` version while
reexporting our own version of the old `GcCell` API, so that
Ruffle's code can be gradually migrated.

Once the migration is done, this crate should be removed.

* core: bump `gc-arena` to kyren/gc-arena#56

Add back the removed `GcCell` to our internal facade crate

* core: bump `gc-arena` to current master

This bump renames `Gc::allocate` to `Gc::new`

* core: rename `GcCell::allocate` to `GcCell::new`, to match `Gc`

* core: bump gc-arena to (slighly after) v0.3.1

Add typedefs for old `*Context` names in the gc-arena facade crate

* core: replace uses of `CollectionContext<'_>` by `&Collection`

* core: Add `gc()` convenience method for `*Context` and `Activation` types

This allows shortening most instances of `[activation.]context.gc_context`
to `activation.gc()` or `context.gc()` (but not all instances, because of
borrowck) Note that this doesn't actually do these shortenings to avoid
major code churn.
2023-07-09 17:04:25 -04:00
Aaron Hill 3006356410 render: Suppress clippy::arc_with_non_send_sync for now 2023-07-04 20:50:46 +02:00
Nathan Adams f43560ab88 render: Switch to providing cacheAsBitmap entries all at once on submit frame 2023-06-24 01:42:04 +02:00
Nathan Adams 2594453831 render: Add render_offscreen_for_cache for more optimised CacheAsBitmap 2023-06-24 01:42:04 +02:00
Nathan Adams fe742194b1 core: Implement cacheAsBitmap behaviour 2023-06-24 01:42:04 +02:00
Nathan Adams 2427daf05c webgl: Don't hold onto an old copy of bitmap data for each image 2023-06-18 00:47:51 +02:00
Aaron Hill 69fce3f7f8
wpgu: Initial implementation of PixelBender shader execution (#11441)
* wpgu: Initial implementation of PixelBender shader execution

The implementation is split across four crates:
* `ruffle_render` now holds the main PixelBender bytecode parsing
   implementation (previously, this was in `ruffle_core`).
* `ruffle_core` holds some helper functions for converting between
   AVM2 `Value`s and the PixelBender vector types.
* `naga-pixelbender` (newly created) constructs a Naga `Module`
  from parsed PixelBender bytecode
* `ruffle_render_wgpu` sets up the render pipeline for the shader
  constructed by `naga-pixelbender`, and actually executes the shader.

The Actionscript-side shader parameters are passed in through uniforms.
This allows us to cache the compiled `naga::Module` and associated
wgpu types inside `ShaderData`, when it's first created. Each invocation
of a `ShaderJob` only needs to create a bind group and render pass.

Limitations:

* Only a few of the PixelBender opcodes are implemented - however, this is
enough to get Stemlands cannon rotation working, as well as a cool
"donut" shader that I found and included as a test.
* PixelBender matrix types are not supported.
* Only BitmapData is supported as an input/output type - Flash Player
  also supports using Vector and ByteArray
* ShaderJob execution is always synchronous.

* Adjust comments

* Address review comments
2023-06-15 22:50:24 +00:00
renovate[bot] fc933f485f fix(deps): update wasm-bindgen 2023-06-15 20:50:04 +02:00
renovate[bot] f969bdce71 fix(deps): update wasm-bindgen 2023-05-17 06:44:50 +03:00
relrelb 1065662e84 web: Use `JsValue::from_bool()` 2023-05-15 21:04:47 +03:00
renovate[bot] 5b26d1b2ee fix(deps): update wasm-bindgen 2023-05-15 10:00:49 +03:00
iwannabethedev 307f364d6f
web: Log used renderer
Log which renderer-backend was actually used in the
browser console.
2023-05-02 23:59:57 +03:00
TÖRÖK Attila 493971ab8a render: Make RenderBackend::update_texture() take a Bitmap (like register_bitmap()) 2023-04-04 00:15:07 -07:00