Commit Graph

892 Commits

Author SHA1 Message Date
Aaron Hill da8d5bce3c naga-agal: Fix bugs and add tests for new ops 2023-05-24 13:34:15 -05:00
Mike Welsh 3257cc44cf naga-agal: Implement m33 and m34 ops 2023-05-24 13:34:15 -05:00
Mike Welsh 35ef04eadc naga-agal: Implement kil op 2023-05-24 13:34:15 -05:00
Mike Welsh f97bb9c2f1 naga-agal: Implement log, exp, pow, ddx, ddy, min, rsq, sge ops 2023-05-24 13:34:15 -05:00
Aaron Hill cc567c4e40 agal: Correctly check vertex_input_expressions cache
We need to use the same logic that we use for `get_varying_pointer`,
since the AGAL shader can access vertex inputs in any order.
2023-05-23 17:20:29 -05:00
renovate[bot] 5d2477fe98 chore(deps): lock file maintenance rust dependencies 2023-05-22 19:12:08 +03:00
Aaron Hill 5d48484d99 agal: Add support for indirect register loads
These are poorly documented, but from looking at OpenFL
and AGALMiniAssembler, they allow performing loads of the
form `vc[va0.x + offset]` - that is, computing a dynamic register
number, instead of using the register number present in the opcode.
2023-05-21 09:40:11 -05:00
Aaron Hill 5d62ef90f2 wgpu: Use intermediate buffer for Context3DCommand::CopyBitmapToTexture
In a previous PR, I introduced an optimization that used
`copy_texture_to_texture` to copy directly from a BitmapData GPU
texture to a Stage3D GPU texture.

Unfortunately, this optimization is incorrect. A BitmapData GPU
texture can be modified at any time by normal AVM2 code - in
particular, in might be modified before we submit the encoded
`copy_texture_to_texture` command. This shows up in Sniper Team,
which re-uses BitmapData objects for multiple distinct textures.
The previous 'optimization' resulted in the wrong BitmapData contents
getting uploaded to a texture (since it was changed before the copy
command was submitted).
2023-05-20 17:38:26 -05:00
Aaron Hill 0864853d44 avm2: Allow passing `null` to `Context3D.setProgram`
This clears the vertex and fragment shader programs
(bringing the Context3D back to its initial state).
2023-05-20 16:23:03 -05:00
Aaron Hill 7619594b1c agal: Implement Float1 to vec4f conversion 2023-05-18 16:12:22 -05:00
Aaron Hill 7004e98b23 avm2: Don't validate Context3DVertexBufferFormat when buffer is null
This matches Flash Player's behavior - some SWFS try to pass in 'null'
for both the buffer and format.
2023-05-18 15:14:29 -05:00
iwannabethedev 8cd5414c5d
Fix overflow bug in `shape_utils::winding_number_line()` 2023-05-17 07:21:13 +03: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
Aaron Hill bd2be88711 wgpu: Fix MSAA and depth buffer handling in SetRenderToTexture
When multisampling is enabled, we should create a new multisampled texture,
and use the existing texture as the resolve buffer. We also need to
call `update_has_depth_texture` to keep our pipeline aware of whether
or not we currently have a depth buffer attached.

Makes progress on #10641 (it has a stack overflow after
this PR, due to an unrelated issue).
2023-05-15 09:34:30 -05:00
renovate[bot] 5b26d1b2ee fix(deps): update wasm-bindgen 2023-05-15 10:00:49 +03:00
relrelb 4a26ceb14b render: Use `swf::Point<Twips>` in more places 2023-05-14 22:48:41 +03:00
relrelb 220f8cd1cf render: Use `swf::Point<Twips>` in `shape_hit_test()` 2023-05-14 22:48:41 +03:00
relrelb 25a1d53f72 render: Use `swf::Point<Twips>` in `calculate_shape_bounds()` 2023-05-14 22:48:41 +03:00
relrelb 598c8cde0e render: Use `swf::Point<Twips>` in `DrawCommand::CurveTo` 2023-05-14 22:48:41 +03:00
relrelb 544e445d2f render: Use `swf::Point<Twips>` in `DrawCommand::LineTo` 2023-05-14 22:48:41 +03:00
relrelb e5c7d70f3f render: Use `swf::Point<Twips>` in `DrawCommand::MoveTo` 2023-05-14 22:48:41 +03:00
iwannabethedev a023e11098 render: Clean-up. 2023-05-12 22:42:44 +02:00
iwannabethedev 77e1cc96c2 render: Fix of panic in #10955. 2023-05-12 22:42:44 +02:00
relrelb 660acac427 swf: Use `PointDelta<Twips>` in `ShapeRecord` 2023-05-11 08:55:44 +03:00
relrelb b93a32af0f swf: Use `Point<Twips>` in `StyleChangeData::move_to`
No functionality change.
2023-05-11 08:55:44 +03:00
Aaron Hill e488cc9f7a wgpu: Allow unaligned writes to IndexBuffer3D
wgpu requires buffer copy sizes and offsets to be 4-byte aligned.
Unfortunately, ActionScript can perform 2-byte aligned uploads
into an IndexBuffer3D.

To support this, we now keep a copy of the IndexBuffer3D on the CPU.
When performing an upload to the buffer, we round the offset down
and the size up to the nearest 4-byte aligned value. The cpu buffer
is used to fill out the write with existing data, so that we don't
corrupt the contents of the GPU buffer.

To avoid introducing a new RefCell, I've changed IndexBuffer3D
to use a `Box` instead of an `Rc` to store the trait object.
This allows us to pass a mutable reference down to the backend.
2023-05-10 18:20:29 -05:00
Nathan Adams 2b6829692c wgpu: Resize textures if they're bigger than the system supports 2023-05-05 19:03:15 +02:00
Aaron Hill 22c13d41da wgpu: Use Context3DCommand by value 2023-05-05 11:43:43 -05:00
Nathan Adams c5293bd981 core: Don't actually apply a filter if it's unsupported, just copy 2023-05-03 21:15:48 +02:00
Nathan Adams 50a0298d30 render: Fix calculations in PixelRegion::clamp_with_intersection (+ new test) 2023-05-03 21:15:48 +02:00
Nathan Adams adabb81804 core: Introduce PixelRegion::clamp_with_intersection and made most operations with two overlapping regions use it 2023-05-03 21:15:48 +02:00
iwannabethedev 49962edf3a render: Fix obsolete/wrong documentation. 2023-05-03 09:26:37 +03:00
relrelb 85a9ec77c5 render: Fix wgpu renderer name 2023-05-03 01:12:19 +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
relrelb 24079518d9 tests: Expand `Matrix` unit tests to cover `PointDelta`s 2023-04-29 22:29:37 +03:00
relrelb ef79d556b4 tests: Allow trailing commas in `Matrix` unit tests 2023-04-29 22:29:37 +03:00
relrelb 3046d68da1 swf: Introduce `PointDelta`
Generally, when transforming a difference between two points, `p1`
and `p2`, with a matrix `m`, we would like the following property
to hold:

```
m * (p1 - p2) == m * p1 - m * p2
```

Unfortunately, it wasn't like this before, because matrices have a
translation component, which is non-linear. In `m * p1 - m * p2`,
the translations of `m * p1` and `m * p2` are the same and therefore
cancel out each other. However, in `m * (p1 - p2)` the translation
stays.

In order to preserve this property, introduce a new `PointDelta`
type which is not subject to translation when transformed by a matrix.

For now, the following operations are supported:

* `Point - Point -> PointDelta`
* `Point + PointDelta -> Point`
* `Point += PointDelta`
* `Point - PointDelta -> Point`
* `Point -= PointDelta`

As a consequence, the expression `position + global_to_local_matrix * mouse_delta`
in `update_drag()` now ignores translation, which fixes #817.
2023-04-29 22:29:37 +03:00
relrelb 60ffe07ae7 chore: Use `swf::Point` in many places
Convert nearly all instances of `(Twips, Twips)` (maybe besides in
`shape_utils.rs`) to `swf::Point<Twips>`.
2023-04-27 22:14:03 +03:00
Aaron Hill 3bb8c8fb4f wgpu: Update wgpu to 0.16.0 and naga to 0.12.0 2023-04-25 09:24:53 -05:00
Nathan Adams d9241c914e chore: Hold wgpu and naga back until naga_oil updates to naga 0.12 2023-04-24 01:22:07 +02:00
renovate[bot] 3b3c08a354 chore(deps): lock file maintenance rust dependencies 2023-04-24 01:22:07 +02:00
Nathan Adams 4f4327b152 wgpu: Fix drawing a transparent bitmap with MSAA 2023-04-18 23:15:42 +02:00
Aaron Hill 962cf92223 avm2: Implement Context3D.setSamplerStateAt
This fixes pixelated backgrounds in Fancy Pants World 4 Part 3
2023-04-05 16:44:07 -07:00
Mike Welsh 7a6e6cf214 naga-agal: Add fractal shader test 2023-04-05 12:22:13 -07:00
Mike Welsh b578849958 naga-agal: Allow boolean binary ops with multiple components 2023-04-05 12:22:13 -07:00
Mike Welsh e92e530321 naga-agal: Support `abs` op 2023-04-05 12:22:13 -07:00
Mike Welsh 792cfd82c7 avm2: Implement `Context3D.setColorMask` 2023-04-05 12:22:13 -07:00
Mike Welsh e07bde884e render: Inline `CommandList` methods 2023-04-04 13:10:45 -07:00
Mike Welsh 7779416894 render: Fix masker-in-masker rendering
Flash does not support nested mask regions and instead merges them
into a single clip region.

For example, this occurs when using a dynamic text field as a mask.
One mask layer contains the glyphs, while the second layer is the
bounds of the text field. The text field bounds end up being
ignored when the text field is used as a mask, allowing the text
outside the bounds to be visible.

Add `CommandList::maskers_in_progress` to keep track of the mask
state and discard drawing commands for inner maskers.

Fixes #9664.
2023-04-04 13:10:45 -07:00
Nathan Adams 06bc4e1403 wgpu: Fix sync issue introduced in #9753 and added test 2023-04-04 11:11:57 -07:00
TÖRÖK Attila 2ad43994b8 video: Don't do colorspace conversion in the video backend 2023-04-04 00:15:07 -07: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
TÖRÖK Attila c9a2c636c9 render/webgl: Make use of Bitmap::to_rgb() to avoid making an alpha channel for Yuv420p bitmaps 2023-04-04 00:15:07 -07:00
TÖRÖK Attila ba43b0930f render: Add Bitmap::to_rgb() 2023-04-04 00:15:07 -07:00
TÖRÖK Attila 5f94476b2a render: Add BitmapFormat::Yuv420p and BitmapFormat::Yuva420p 2023-04-04 00:15:07 -07:00
TÖRÖK Attila 322e17a5ab render: Bitmap::bytes_per_pixel() -> Bitmap::length_for_size() 2023-04-04 00:15:07 -07:00
Mike Welsh 549a06d00f wgpu: Slight optimization to color shader
The color doesn't change per pixel, so calculate the color in the
vertex stage instead of the fragment stage.
2023-04-03 14:33:37 -07:00
renovate[bot] cd3ad90d61 chore(deps): lock file maintenance rust dependencies 2023-04-02 22:00:49 -07:00
Aaron Hill a2fa362091 wgpu: Implement double buffering for Context3D
This matches the Context3D docs. Calling 'present' swaps
the buffers.

I wasn't certain if we actually need a double-buffered depth
texture, but I included one just to be safe.
2023-04-02 19:24:23 -07:00
Aaron Hill 671ebdfa8f wgpu: Execute Context3D commands immediately
Now that most of the complicated Context3D methods have been
implemented, we can simplify the overall design. Instead of queueing
up commands and having `present` execute them in a loop, we
can execute each command immediately. The key insight is that
a `RenderPass` is only needed for `DrawTriangles`, so we don't
have to store it in `Context3D` and deal with complicated lifetime
issues.

The old behavior gave us implicit double-buffering behavior,
since nothing would get rendered until a 'present' call.
Now that a 'drawTriangles' call will immediately submit
a draw command, we need to implement actual double buffering.
This is done in the next commit.
2023-04-02 19:24:23 -07:00
Aaron Hill 7809000170 wgpu: Fix filter texture copy size calculation
I incorrectly changed this in #10373

Fixes #10380
2023-04-01 11:04:55 -05:00
Mike Welsh b62040884c core: Make `DisplayObject::global_to_local` fallible
* `global_to_local` returns `None` if the object has zero scale.
 * Adjust AVM `globalToLocal` methods to return the untransformed
   point on failure.
 * Add `DisplayObject::mouse_to_local` to handle AVM `mouseX`
   and `mouseY` coordinates. For zero scale objects, these end up
   returning values based on the twips-to-pixels scale,
   divided by 20.
2023-03-31 16:26:11 -07:00
Mike Welsh 54b7094c16 render: Make `Matrix::inverse` fallible
* Add `Matrix::determinant`.
 * Rename `Matrix::invert` to `inverse`.
 * `Matrix::inverse` return an `Option`, with `None` returned
    for non-invertible matrices.
 * AMV `Matrix::invert` duplicates the code as the behavior is
   different (works in f64 and not twips, etc.)
2023-03-31 16:26:11 -07:00
Nathan Adams adadb8a26d wgpu: Use swap_remove instead of remove for buffer pool 2023-03-31 16:57:52 +02:00
Nathan Adams c51ba098f6 render: Rename PixelRegion's (min|max)_(x|y) to (x|y)_(min|max) 2023-03-31 16:57:52 +02:00
Nathan Adams 94e5aa8f34 core: Fix calculating dirty area of BitmapData.draw() with rotation 2023-03-31 16:57:52 +02:00
Nathan Adams f0ebefd624 tests: Add bitmapdata recursive draw test 2023-03-31 16:57:52 +02:00
Nathan Adams c85910b46d wgpu: Fixed panic when rendering texture to itself, by always rendering to an intermediary 2023-03-31 16:57:52 +02:00
Nathan Adams 78f9bb13d6 render: Fix PixelRegion::for_region_i32 for negative coordinates 2023-03-31 16:57:52 +02:00
Nathan Adams e614265c17 core: Move fill_rect from BitmapData to bitmap_data_operations, fixed a bug when using non-standard values, and added better tests for fill_rect showing the bug 2023-03-31 16:57:52 +02:00
Nathan Adams 311a165149 wgpu: Reintroduce texture promoting; only preassign buffer when the texture is frequently written/&read 2023-03-31 16:57:52 +02:00
Nathan Adams 6e859891af render: Take in dirty region in update_texture, only upload those pixels 2023-03-31 16:57:52 +02:00
Nathan Adams 137593b6a6 render: Extract (u32, u32, u32, u32) to PixelRegion 2023-03-31 16:57:52 +02:00
Nathan Adams 4ccc75c4d6 wgpu: Changed AlwaysIncompatible to AlwaysCompatible, whoops 2023-03-31 16:57:52 +02:00
Nathan Adams 71ef10b94b wgpu: Reuse buffers for BitmapData.draw, preferring smallest buffer available 2023-03-31 16:57:52 +02:00
Nathan Adams 2cc1db6f8e wgpu: Enable BufferPool to reuse existing buffers if they're compatible 2023-03-31 16:57:52 +02:00
Nathan Adams e0bd911f2f render: Only copy a possible dirty area for bitmapdata.draw & read 2023-03-31 16:57:52 +02:00
relrelb 236a97bf31 render: Replace `ColorTransform` with `swf::ColorTransform` 2023-03-29 23:27:20 -07:00
relrelb d71617209a render: Remove `RenderBackend::register_glyph_shape`
Use just `RenderBackend::register_shape` instead.
2023-03-30 01:46:04 +03:00
renovate[bot] 5052e942b5 chore(deps): lock file maintenance rust dependencies 2023-03-28 09:31:15 +03:00
Aaron Hill a52cb7461e wgpu: Implement MSAA support for Stage3D
When we receieve a nonzero 'antiAlias' parameter, we create
create a non-multisampled resolve buffer to use with WGPU.

Several tests were already requesting antialiasing, so their
output images are now anti-aliased without any changes to
the tests themselves.
2023-03-26 18:05:41 -07:00
Aaron Hill b140029e95 render: Fix BitmapData.applyFilter with non-full sourceRect
Previously, we were scaling down the source image to fit into
the smaller sourceRect, instead of cropping at the original scale.
This broke the background textures in Fancy Pants World 4 Part 2,
as the scaled-down output image resulted in a smaller rectangle
being returned from 'getColorBoundsRect'

We now crop the image by properly constructing the UV-coordinate
transformation matrix. We were also using the wrong value for the
'destPoint' y coordinate, which I fixed.

This slightly changes the image output of two tests - the new images
now more closely match the Flash output.
2023-03-25 18:44:01 -07:00
relrelb 39b53c76d6 ci: Deny warnings on Web
As suggested in https://github.com/ruffle-rs/ruffle/pull/6935#pullrequestreview-967181111.
2023-03-24 19:16:32 -07:00
Nathan Adams eb44cc5395 render: Made ShapeHandle an Arc of an internal, droppable mesh 2023-03-23 01:44:27 -07:00
Nathan Adams cc8ac4fde1 render: Remove RenderBackend::replace_shape 2023-03-23 01:44:27 -07:00
Mike Welsh 1d12fc6169 render: Fix types depending on `tessellator` feature 2023-03-22 20:30:39 +01:00
renovate[bot] d7c842a139 chore(deps): lock file maintenance rust dependencies 2023-03-21 14:27:27 +01:00
renovate[bot] f6f646a756 chore(deps): lock file maintenance rust dependencies 2023-03-19 19:45:30 -07:00
Nathan Adams 078672782c wgpu: Skip Alpha/Erase blends with no parent Layer 2023-03-19 14:59:48 -07:00
Mike Welsh 2d6d8ea0f4 core: Fix BitmapData.colorTransform
* Pixels with 0 alpha are not affected by color transforms.
 * Color channels should be clamped to the 0-255 range.
 * A color transform with only an alpha multiplier of >1 has no
   effect.
2023-03-19 09:59:13 +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
Nathan Adams bc9e1d7c14 swf: Rename HAS_FILL_WINDING_RULE to NON_ZERO_WINDING_RULE 2023-03-18 19:14:08 -07:00
Nathan Adams 6987c81623 render: Respect HAS_FILL_WINDING_RULE 2023-03-18 19:14:08 -07:00
Nathan Adams e7b812c2cd render: Glyphs are assumed to have HAS_FILL_WINDING_RULE 2023-03-18 19:14:08 -07:00
Aaron Hill 580c18844e naga-agal: Remove 'do_extend'
This was a leftover from before we started usiung vec4 everywhere
for compatibility with AGAL. There are a few specific opcodes that
don't need extension, but it doesn't depend on the destination
register.
2023-03-17 20:11:59 -05:00
Aaron Hill 1e973af747 avm2: Implement Context3D.setRenderToTexture/setRenderToBackBuffer
In the process, I fixed a bug where we were clearing the depth
and stencil buffers with the incorrect value.

This makes Fancy Pants World 4 Part 1 playable to completion
(though there are still some rendering issues that need
to be fixed).
2023-03-17 20:11:59 -05:00
Aaron Hill 1edcbe438d core: Avoid several BitmapData GPU -> CPU sync
We don't need to perform a sync when getting the width/height,
getting or setting the 'disposed' status, or uploading to
a Context3D texture.

The Context3D change (using `copy_texture_to_texture` instead
of relying on the CPU pixels) has the added advantage of avoiding
a validation error when our source image row length isn't aligned
to `COPY_BYTES_PER_ROW_ALIGNMENT`

This dramatically speeds up the Fancy Pants World 4 loading time
(on a branch with my XML prs merged). Without this change, my
machine spends around 10 seconds on a blank white screen after
clicking 'Play'. With this change, the time spent on that screen
is reduced to around 1-2 seconds.
2023-03-17 04:56:03 -05:00
Aaron Hill 53c6011ade render: Support more Context3D texture formats
None of these formats can currently be implemented
correctly with wgpu, so we just use Rgba8Unorm instead.

The handling of opaque compressed textures is a little
sketchy - it should work for 'normal' SWFs that upload
an opaque BitmapData, but we might need to manually
adjust the alpha values if
2023-03-16 17:40:41 -05:00
Aaron Hill 1dd0d237ab render: Correctly handle BYTES_4 vertex data
Each byte gets normalized into a float in the range [0, 1]
2023-03-16 13:20:11 -05:00
TÖRÖK Attila 96d1f19e6c
chore: Port to bitflags 2.0.0
* 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
2023-03-15 20:06:10 -07:00
Aaron Hill e194883ef6 naga-agal: Correctly access vertex shader FunctionArgument
I had previously applied this fix to fragment shaders,
but I forgot to apply it to vertex shaders as well.
2023-03-15 20:12:21 -05:00
Aaron Hill acbc802c94 avm2: Fix VertexBuffer3D.uploadDataFromByteArray size calculation
We were ignoreing 'data32PerVertex'.
To make the code clearer, I've renamed the variable to
'data32_per_vertex', and made it a 'u8' (as it has a maximum of 64)
2023-03-15 19:52:09 -05:00
Aaron Hill fea885f3af render: Implement Context3DTextureFormat.BGRA using an RGBA texture
Webgl doesn't support BGRA textures, so this lets us use
Stage3D textures on the web backend. As a bonus, this speeds up
uploading an BitmapData to a Context3dTextureFormat.BGRA texture,
since we no longer need to change the format before copying.

This makes Solarmax2 playable on the web backend.
2023-03-13 13:30:15 -05:00
Nathan Adams b527054a1e
render: Make retrieve_offscreen_texture pass the raw buffer (#9936) 2023-03-13 00:00:42 +00:00
Aaron Hill de8448e00a
avm2: Implement Stage3D depth test, blend factors, and fix bugs (#9845) 2023-03-12 23:43:58 +00:00
TÖRÖK Attila 109e151fa6 render/all: Clamp gradient focal point to be between -/+0.98 2023-03-12 23:54:59 +01: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
TÖRÖK Attila 7d3a2d14b7 render/wgpu: Delete the now unused buffer bug detection shader 2023-03-12 15:53:16 -05:00
TÖRÖK Attila d356b7258a wgpu: Fix gradient regression 2023-03-07 20:35:29 +01:00
Nathan Adams 026efe7f18 render: Moved out some Gradient fields into webgl as it's no longer needed in wgpu 2023-03-06 23:22:09 +01:00
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
renovate[bot] 130144a76d fix(deps): update rust dependencies 2023-03-05 20:43:46 -06:00
relrelb 83c15b8033 render: Replace `BoundingBox` with `swf::Rectangle` 2023-03-04 21:54:23 +02:00
relrelb abcdc2a851 render: Enable `serde`'s `derive` feature
Otherwise `cargo check` fails when run right from the `render/`
directory.
2023-03-04 21:54:23 +02:00
Aaron Hill 2748b95c86 avm2: Improve Stage3D support for textures, register types, and opcodes
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
2023-03-03 15:58:46 -06:00
Nathan Adams 545193b098 swf: Deduplicate GradientFilter again 2023-02-28 16:25:12 +01:00
Nathan Adams f79015e201 render: Use swf Filter types where possible. Gradient types had to be split into duplicate classes to allow for different trait impls based on which gradient filter type it is. 2023-02-28 16:25:12 +01:00
Nathan Adams 9224aeca5d swf: Add DropShadowFilter::hide_object(), it's the only time COMPOSITE_SOURCE is used 2023-02-28 16:25:12 +01:00
Nathan Adams b8f7c66980 core: map_point in DisplacementMapFilter is i32 not u32 2023-02-28 16:25:12 +01:00
Nathan Adams 3777210117 core: Angle from swf tag is in radians, convert it to degrees 2023-02-28 16:25:12 +01:00
Nathan Adams acc3180db7 core: Strength in filters is a f32, not u8 2023-02-28 16:25:12 +01:00
Nathan Adams 7da2a061cc swf: ColorMatrixFilter::matrix is actually f32, not Fixed16 2023-02-28 16:25:12 +01:00
Nathan Adams fc00ae8eb6 core: Load filters from PlaceObject tag 2023-02-28 16:25:12 +01:00
Nathan Adams e39fbe871d render: Add Filter::GradientGlowFilter 2023-02-28 16:25:12 +01:00
Nathan Adams bb38a7fa55 render: Add Filter::GradientBevelFilter 2023-02-28 16:25:12 +01:00
Nathan Adams c8030d047d render: Add Filter::GlowFilter 2023-02-28 16:25:12 +01:00
Nathan Adams c9656c429e render: Add Filter::DropShadowFilter 2023-02-28 16:25:12 +01:00
Nathan Adams dbe2efff00 render: Add Filter::DisplacementMapFilter 2023-02-28 16:25:12 +01:00
Nathan Adams f9c7303f01 render: Add Filter::ConvolutionFilter 2023-02-28 16:25:12 +01:00
Nathan Adams 9c1f6ea129 render: Add Filter::BevelFilter 2023-02-28 16:25:12 +01:00
Nathan Adams 5ee3a4b512 avm2: Extract out the Value -> Filter logic into a trait 2023-02-28 16:25:12 +01:00
renovate[bot] 71e24eedba fix(deps): update rust dependencies 2023-02-27 11:48:53 +02:00
relrelb dc9ec40d31 chore: Allow `clippy::bool_to_int_with_if`
Seems like Clippy no longer complains about it.
2023-02-26 13:23:38 +02:00
Nathan Adams 01af1af4d9 webgl: Fixed blown out colortransform in webgl 2023-02-24 19:01:41 +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
Aaron Hill 455124d3ba render: Fix blending onto BitmapData contents
When rendering to an offscreen texture for `Bitmapdata.draw`,
we first render to a temporary frame buffer, and then copy the contents
of the frame buffer back to the target texture. However, this results
in blend modes being incorrectly applied - for example, rendering with
BlendMode.SUBTRACT will subtract against the framebuffer (which starts
with each pixel as 0x00000000), instead of the previous BitmapData
contents.

To fix this, we now use our texture target as the frame buffer
when performing `render_offscreen`. This ensure that we blend
over existing pixels (taking into account the `blendMode` provided
in the `BitmapData.draw` call).

When multisampling is enabled, we use a copy pipeline to copy
the existing contents of our texture to a fresh multisampled frame
buffer (the non-multisampled texture target becomes our resolve buffer).
2023-02-23 09:52:56 -06:00
Nathan Adams 6539262db7 render: Add Quality option to RenderBackend::render_offscreen 2023-02-22 17:36:55 +01:00
relrelb 2aaf337b6a swf: Introduce `BlurFilterFlags` 2023-02-21 16:55:13 +02:00
renovate[bot] a27bd66b58 fix(deps): update rust dependency patches 2023-02-13 04:59:31 +01:00
Aaron Hill c597f9f996 core: Fix Clippy lints on nightly 2023-02-13 03:38:54 +01:00
renovate[bot] fed24aa243 fix(deps): update rust dependencies - wasm-bindgen related 2023-02-13 02:57:52 +01:00
Nathan Adams 0e9b1e4a77 wgpu: Better support for 2x and 8x msaa 2023-02-06 16:08:04 +01:00
Nathan Adams 68761608fc desktop: Add --quality option 2023-02-06 16:08:04 +01:00
Nathan Adams 1cb3ea7bf9 wgpu: Store quality, not sample_count, and calculate the correct sample count per format 2023-02-06 16:08:04 +01:00
Nathan Adams b95983b492 wgpu: Hook up set_quality 2023-02-06 16:08:04 +01:00
Nathan Adams d8e924affc render: Add RenderBackend::set_quality method, and call it from core 2023-02-06 16:08:04 +01:00
Nathan Adams b270d1bbd7 render: Move StageQuality from core to render 2023-02-06 16:08:04 +01:00
Nathan Adams 3411a04cef render: Made render specific Filter enum & structs, as swf ones don't map 1:1 to potential filters 2023-02-05 18:41:43 +01:00