This fixes a crash when loading an ATF 'compressed alpha'
texture under wasm. The rust-side jpegxr wrapper was calling
C functions that trigger a WASM ABI bug.
See d49988f40f
for more details
This builds on our existing playerglobal versioning support
to add in AIR versioning. We closely follow the avmplus implementation:
* When an SWF is loaded, we chose either a FlashPlayer or AIR
APIVersion for its SWF version, based on our configured player runtime.
* When loading playerglobals, we look at the player runtime. In AIR
mode, we map FlashPlayer-versioned definitions to the closest AIR
version. This ensures that all runtime APIVersions are in the
same series (either AIR or FlashPlayer). In FlashPlayer mode,
all AIR-versioned definitions get mapped to VM_INTERNAL, hiding
them from user code.
Part of our existing api versioning code was implemented incorrectly.
Within playerglobals, we need to treat all unmarked namespaces as
VM_INTERNAL - this allows things like playerglobal script
initializer "initproperty" opcodes to see any VM_INTERNAL AIR
definitions (when we run under FlashPlayer mode). Previously, we
were using AllVersions, which would result in those VM_INTERNAL
definitions being hidden from other playerglobal code, which is
not correct.
Using this support, I've added a stub for the AIR-only
'flash.net.DatagramSocket'. I've also extended the test framework
with a new 'player_options.runtime' config option, which can be
set to "AIR" or "FlashPlayer" to configure the test runtime mode.
I've also added two new tests:
* 'air_hidden_lookup' runs under the FlashPlayer runtime, and verifies
that a list of classes (currently just "DatagramSocket" are
inacessible).
* 'air_datagram_socket', which uses `player_options.runtime = "AIR"`
to construct an instance of `flash.net.DatagramSocket`. We can
extend this test once we implement more of `DatagramSocket`
With this commit, we have all of the needed infrastructure to start
implementing and testing AIR-only classes and methods.
This preserves object identity across a serialization
round-trip. Unfortunately, we don't currently implement this
correctly in flash_lso, so I've added a stub message.
Once flash_lso is fixed, this code will start working. For now,
it just allows us to detect (via the stub) if this is actually
used by an SWF.
* avm2: Use RawTable to implement 'public index' iteration
This makes our implementation more closely aligned with avmplus.
In particular, it's now possible to delete keys from an object
while iterating without disturbing the iteration order (as long
as those keys were already produced by the iterator).
This is based on @Bale001's work on RawTable-based iteration
A few tests had their output changed (they depend on the exact
object iteration order, and don't neccessarily match Flash Player
exactly).
* Use Cell to store index fields
* Remove outdated comment
This relieves some headaches with on connect callback and spawning of the
sending async task, since some SWFs like to send data before the connect event
is called.
Both of these are handled automatically by the browser in the
web backend. This makes the desktop client store cookies between
requests (though they are discarded when the desktop player is closed),
and set the "Content-Type" header based on the mime-type supplied
in the URLRequest.
Since wgpu hasn't yet released a version with this feature, I manually
backported it to the 0.17 branch.
This doesn't work on Windows (HLSL), but works on all other platforms.
Some experimentation with Pixel Bender Studio shows
that Opcode::Loop has a 23-byte payload. I haven't tried to
figure out how to interpet the payload yet, but we can now
skip over the opcode instead of bailing out entirely.
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.
* 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.
This feature is disabled by default. When enabled, you can use
`ruffle_render::renderdoc::begin_frame_capture` and
`ruffle_render::renderdoc::end_frame_capture` to manually trigger
a RenderDoc frame capture (if Ruffle wasn't launched by RenderDoc,
this logs an error).
This is very useful when debugging Stage3D/PixelBender bugs, as you
can produce a capture containing only the relevant graphics calls.
* 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
We use an `lru::LruCache` inside `ShaderModuleAgal`. This automatically
gives us the proper garbage-collection behavior (when the Flash
Program3D instance is garbage collected, we'll drop the
`ShaderModuleAgal` and the cache).
The cache is keyed on the data needed to compile the shader (vertex
attributes and sampler overrides). This lets us avoid shader
recompilations when a Stage3D program repeatedly uses the same
Program3D with different sampler overrides / vertex attribute formats.
I've moved our special entity handling logic into
a `custom_unescape` function. This lets us move off
of our fork of `quick-xml` back onto the crates.io release
* Bump bitflags to 2.0.0
* Sprinkle Clone, Copy, Eq, PartialEq, and Debug derives where needed
* Call `bits` on bitflags, as it is now a method
* Switch from `from_bits_truncate` to `from_bits_retain` on bitflags where needed
* Bump h263-rs for the bitflags 2.0.0 dependency
As part of porting to bitflags 2.0.0, see:
https://kodraus.github.io/rust/2022/10/07/bitflags2.html#upgrading-to-2x
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).
This is a very large diff, but most of it comes from test files and
output.
This PR ads partial support for the following Stage3D shader features:
* Normal (square), rectangle, and cube textures
* Varying and temporary registers
* Lots of opcodes
The combination of these allows us to get a raytracing program
fully working in Ruffle. I've included it as image test.
Currently, this test is very slow (about 90 seconds on my machine),
as the code I'm using (https://github.com/saharan/OGSL) includes
its own shader language and compiler. THe raytracing demo
first compiles its own shader language to AGAL, and then starts
rendering the scene.
Limitations:
* Many opcodes are still unimplemented
* Most non-default texture options (e.g. mipmaps) are not implemented
`build_output_stream` now takes in a `timeout` parameter - I've
passed in `None` to keep the current behavior.
cpal addded lots of new `SampleFormat` enum values. For now, I'm
just returning an error if we encounter any of them - a quick test
showed that desktop audio is still working on my Linux machine.