Commit Graph

103 Commits

Author SHA1 Message Date
Aaron Hill 6e1f00edf2
render: Implement more PixelBender features (#11800) 2023-07-01 13:50:43 -04:00
David Wendt 5b93a9e316 flv: Add new crate for FLV (de)muxing 2023-06-30 16:14:28 -06: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
Aaron Hill cd2c7f6f2f tests: Enable tracing_subscriber in tests
Previously, we weren't displaying any Ruffle logs when running tests.
2023-06-14 17:15:31 -05:00
Nathan Adams eb70a4f361 core: Update gc_arena to 63dab12871321e0e5ada10ff1f1de8f4cf1764f9 2023-06-03 09:11:06 +02:00
Moulins 011cdd96ba core: don't keep strong references to interned strings in the interner.
This is done by implementing a simple WeakSet which clears its stale
entries during tracing.
2023-04-27 00:17:31 +02:00
TÖRÖK Attila 309f761387 chore: Select "desktop" as the default workspace member
This makes the cargo command to run the player simpler.
2023-04-09 12:26:18 -07:00
TÖRÖK Attila 0f7c362069 wgpu: Update to wgpu 0.15.1, naga 0.11.0, and naga_oil 0.5.0 2023-03-12 16:30:13 -05:00
Aaron Hill d72a8e7125 core: Run frames for 'orphan' AVM2 MovieClips
When a MovieClip is an 'orphan' (it has no parent),
it still has frames run (including frame scripts). Some SWFS
like SteamBirds and 'This is the Only Level TOO' rely on this behavior,
so we need to implement it.

The overall idea is straightforward - we keep a global list of
orphan movies, which we add to whenever we unset the parent for a movie.
This list stores weak references for consistency with Flash.
When we run a frame, we process entries in the root movie list,
in addition to the normal recursive processing from the `Stage`.

However, exactly matching Flash's output turned out to be quite tricky.
The particular sequence of calls I make in `run_all_phases_avm2` makes Ruffle
pass two complicated test cases, but there could still be lurking bugs.

This is enough to get SteamBirds to the first level (which doesn't
render due to a different error).
2023-03-06 20:53:35 -06:00
Aaron Hill fc3c2a2297 Update wgpu
This requires us to bump naga as well, and switch to a fork
of naga_oil that compiles against the latest naga.
2023-01-23 11:31:04 +01:00
Aaron Hill 6fe7af58d5 Move back to upstream wgpu repository
We're relying on unreleased changes, so we depend on the latest commit
from their repository.
2023-01-23 11:31:04 +01:00
Nathan Adams fb78a39125 wgpu: Switch to experimental crate naga_oil for combining shaders 2023-01-10 09:39:28 +01:00
Moulins d332a174c3 Bump `gc-arena` to current master revision
This required small changes to some Debug impls that were missed in #8964
2023-01-06 18:22:43 -05:00
Mike Welsh 696c9062d3 chore: Inherit cargo metadata from workspace
Use workspace inheritance added in Rust 1.64 to de-duplicate
various settings across all packages.
2022-12-16 15:53:59 -08:00
Aaron Hill b8745f0ff1 avm2: Partially implement Stage3D for wgpu backend
This PR implements core 'stage3D' APIs. We are now able
to render at least two demos from the Context3D docs - a simple
triangle render, and a rotating cube.

Implemented in this PR:
* Stage3D access and Context3D creation
* IndexBuffer3D and VertexBuffer3D creation, uploading, and usage
* Program3D uploading and usage (via `naga-agal`)
* Context3D: configureBackBuffer, clear, drawTriangles, and present

Not yet implemented:
* Any 'dispose()' methods
* Depth and stencil buffers
* Context3D texture apis
* Scissor rectangle

General implementation strategy:

A new `Object` variant is added for each of the Stage3D objects
(VertexBuffer3D, Program3D, etc). This stores a handle to the
parent `Context3D`, and (depending on the object) a handle
to the underlying native resource, via `Rc<dyn
SomeRenderBackendTrait>`).

Calling methods on Context3D does not usually result in an immediate
call to a `wgpu` method. Instead, we queue up commands in our
`Context3D` instance, and execute them all on a call to `present`.
This avoids some nasty wgpu lifetime issues, and is very similar
to the approah we use for normal rendering.

The actual rendering happens on a `Texture`, with dimensions
determined by `createBackBuffer`. During 'Stage' rendering,
we render all of these Stage3D textures *behind* the normal
stage (but in front of the overall stage background color).
2022-11-25 21:43:00 -07:00
Aaron Hill d0230a2bea render: Add 'naga-agal' crate to compile AGAL shaders to Naga
This is the first part of the Stage3D implementation, and can
be reviewed independently.

Stage3D shaders use the Adobe Graphics Assembly Language (AGAL),
which is a binary shader format. It supports vertex attributes,
varying registers, program constants (uniforms), and texture sampling.

This PR only implements a few parts of AGAL:
* The 'mov' and 'm44' opcodes
* Vertex attributes, varying registers, program constants, and 'output'
 registers (position or color, depending on shader type)

This is sufficient to get a non-trivial Stage3D program
running (the rotating cube demo from the Adobe docs).

The output of `naga-agal` is a `naga::Module`. This can be passed
directly to wgpu, or compiled into a shader language using
a Naga backend (glsl, wgsl, SPIR-V, etc). The test suite
output WGSL files, and uses the 'insta' crate to compare against
saved files on disk.

Currently, the only real way to write AGAL bytecode is using
the Adobe-provided 'AGALMiniAssembler' flash class.
This class assembles the textual reprentation of AGAL into
the binary format.

To make writing tests easier, I've added a 'agal_compiler' test, which
can easily be modified to add more Agal textual assembly.
2022-10-17 13:22:02 -05:00
relrelb 178bf4fe24 chore: Extract Cargo `edition` to `[workspace.package]`
This is possible since Rust 1.64.0: https://blog.rust-lang.org/2022/09/22/Rust-1.64.0.html#cargo-improvements-workspace-inheritance-and-multi-target-builds
2022-10-14 22:13:29 +03:00
= 7c839ef8ae video: Add software video crate, moved VideoDecoder to it 2022-09-04 17:46:58 -07:00
= b7cf800f88 video: Made ruffle_video crate, moved core video Error to it 2022-09-04 17:46:58 -07:00
Nathan Adams c4488fc883 render: Removed common_tess and moved tessellator to render 2022-08-14 18:38:14 -07:00
Nathan Adams bc0c7cbccb render: Made new render crate, moved Bitmap stuff to it 2022-08-14 18:38:14 -07:00
Aaron Hill f629a91e53
avm2: Allow implementing classes in ActionScript in custom `playerglobal`
This PR adds support for building a custom `playerglobal.swf`, which can be used
to implement builtin Flash classes in ActionScript. This file is embedded into Ruffle
using `include_bytes!`, and loaded during initialization.
As an example, the `Point` class is reimplemented
in ActionScript, and `flash.text.AntiAliasType` is added.

The ActionScript compilation process is performed by `core/build.rs`.
See that file, along with `core/src/avm2/globals/README.md`, for
more details.
2022-06-15 22:00:17 +03:00
David Wendt ac86dee3a6 tests: Add a library defining the file format for Ruffle test input.
I intend to share this code across both Ruffle and FlashTAS (another project that allows running input tests on Flash Player), hence why it's a separate library from Ruffle's tests crate.
2022-04-25 16:29:07 -06:00
David Wendt 79ebcc6dd3 web: Add a crate for a stub binary that builds a Safari Web Extension 2022-04-12 22:14:22 -07:00
Moulins 1911aa9a6b Move core::string into separate ruffle_wstr crate. 2022-03-26 13:42:57 -07:00
TÖRÖK Attila 483028707f web: Add custom profiles to separate the build cache for the two wasm modules 2022-01-13 12:28:00 -08:00
TÖRÖK Attila 3869950578 video/vp6: Add VP6[A] video decoding support
Gated behind the "vp6" feature, enabled by default.
Utilizing a heavily stripped-down version of the NihAV project,
retaining only the VP6 decoder, relicensed under MIT.
Including VP6WithAlpha decoding, proper FrameDependency reporting,
and cropping the unwanted encoded pixels on the right/bottom manually.
2021-10-04 22:33:06 -07:00
David Wendt 76272fd22c video: Always optimize codecs on all profiles. 2021-08-21 14:13:55 -06:00
Aaron Hill 08d0829177 Move all SWF tests out of `core` to new `tests` package
This allows `regressions_tests.rs` to depend on other crates in the
workspace, such as `render`, without introducing a cyclic dependency.

Split out from #4054
2021-05-04 11:47:59 -07:00
Mike Welsh 35d380f48c chore: Switch to new cargo resolver 2021-04-23 12:44:27 -07:00
Nathan Adams 9ab03b4da6 exporter: Added exporter tool for capturing images of swfs (related to #523) 2020-05-11 01:09:07 -07:00
Mike Welsh fa5c09b0cd web: Add WebGL render backend 2020-05-02 10:38:18 -07:00
Nathan Adams f0445d94b8 render: Add wgpu-rs based renderer, used by desktop 2020-04-30 08:48:33 +02:00
Mike Welsh 834756c167 render: Separate tesselation code into render/common_tess 2020-04-29 23:26:41 -07:00
Mike Welsh 6fb0046bd3 render: Move Glium renderer to separate subcrate 2020-04-29 23:26:41 -07:00
Mike Welsh 87bf0f44c4 render: Move canvas renderer to separate subcrate 2020-04-29 23:26:41 -07:00
Mike Welsh a0bc9d3ec9 chore: Set to abort on panic
This shaves ~20% size off the desktop build.
2020-03-16 01:16:15 -07:00
Mike Welsh cc90d7b0ae chore: Actually don't optimize build dependencies in release profile
Previous commit incorrectly set the override in the dev profile.
2020-02-13 15:28:15 -08:00
Mike Welsh 6ea2a55207 chore: Don't optimize build dependencies
Rust 1.41 shipped with the ability to specify optimization level
per dependency/dev-dependency.

This speeds up a full release build by ~20% on my machine.
2020-02-12 15:43:58 -08:00
Mike Welsh b27bc578e0 core: Add enum_trait_object proc macro
The enum_trait_object attribute macro can be used to define an enum where
each variant holds an implementor of a trait. It implements all
methods to forward to the underlying object, as well as `From` impls.

This an aliternative to using trait objects that gets along nicer
with `gc-arena`.
2019-12-10 01:36:01 -08:00
Nathan Adams 59d39d6572 Added a bulk swf scanning tool 2019-10-11 16:37:15 -07:00
Mike Welsh 52b6832db2 chore: Move swf-rs to ruffle workspace
Move the swf-rs crate into the Ruffle workspace proper instead of
having a separate repo. This makes it easier to make changes to
the SWF parsing code during development. swf-rs can still be
published as its own crate from the subfolder.
2019-10-02 18:58:58 -07:00
Mike Welsh 07c6addb8b core: Remove patch from Cargo.toml 2019-05-08 11:59:46 -07:00
Mike Welsh 5e88f43280 Color transforms 2019-05-01 09:55:54 -07:00
Mike Welsh eb6c23d967 Work 2019-04-30 01:53:21 -07:00
Mike Welsh ee64cc77bc Reforactor 2019-04-27 23:08:59 -07:00
Mike Welsh b7ac6dc2ce Refactor 2019-04-27 18:15:43 -07:00
Mike Welsh b4c25f68f2 Fix timer 2019-04-27 15:50:33 -07:00
Mike Welsh f69381cdda Add lyon 2019-04-27 10:54:37 -07:00
Mike Welsh ba6843cf55 Work 2019-04-26 18:55:06 -07:00
Mike Welsh 3a2b11c511 Initial commit 2019-04-26 14:11:29 -07:00
Mike Welsh 975d31ac58 Work 2019-04-25 20:27:44 -07:00
Mike Welsh 8d4ce5af8a Initial commit 2019-04-25 10:52:22 -07:00