Commit Graph

714 Commits

Author SHA1 Message Date
renovate[bot] 4e75c3890a fix(deps): update rust dependencies 2023-08-28 07:39:35 +02:00
Aaron Hill 158beaffa5 wgpu: Bail out early when trying to set empty program constants
There's nothing to do in this case, and we want to avoid trying
to construct a `NonZeroU64` for the size.
2023-08-27 13:53:40 -04:00
renovate[bot] 2f4c7d2fe3 fix(deps): update rust dependencies 2023-08-21 08:59:07 +02:00
renovate[bot] 1f4bfcf10d fix(deps): update rust dependencies 2023-08-18 23:32:15 +02:00
renovate[bot] 93f08d7738 chore(deps): lock file maintenance rust dependencies 2023-08-14 23:58:45 +02:00
Nathan Adams da090f0bd7 render: Move filter size calculation from wgpu to render/swf 2023-08-12 13:00:27 +02:00
renovate[bot] a4b179e1e0 chore(deps): lock file maintenance rust dependencies 2023-08-08 23:19:16 +02:00
TÖRÖK Attila 6a975cdc5b render/wgpu: Add WgpuRenderBackend<SwapChainTarget>::recreate_surface(). 2023-08-04 21:04:29 +02:00
relrelb 006393c581 chore: Appease nightly clippy 2023-08-01 22:44:00 +03:00
TÖRÖK Attila 6d6d665332 wgpu: Use correct (shifted) zero value in DisplacementMapFilter shader 2023-08-01 12:54:56 +02:00
Aaron Hill 583caa3389
avm2: Implement DisplayObject.blendShader (#12238) 2023-07-26 23:25:26 +00:00
TÖRÖK Attila 1c1a4aee18 wgpu: Don't use blur pass scaling (it was observed to not be needed) 2023-07-26 13:03:11 +02:00
renovate[bot] 3e63a88c34 chore(deps): lock file maintenance rust dependencies 2023-07-25 08:23:28 +03:00
TÖRÖK Attila 0cf6a68d05 wgpu: Make the blur filter support fractional sizes fairly accurately 2023-07-24 04:44:22 +02:00
Aaron Hill cd9efb2dfa wgpu: Ignore zero width/height Stage3D scissor rect
This matches Flash's behavior, and prevents wgpu from panicking.
2023-07-23 17:05:27 -04:00
Aaron Hill 5a5206c8df wgpu: Correctly pass PixelBender int params to shader
The shader expects an array of i32s, but we were writing
bitcasted f32s to the array.
2023-07-23 13:22:40 -04: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
Nathan Adams b201e19cc7 wgpu: Don't create an extra fresh texture for applying filters to a CAB 2023-07-20 23:19:20 +02:00
Nathan Adams 400ff32723 wgpu: Implement a naive DisplacementMap filter 2023-07-20 12:41:30 +02:00
Nathan Adams b1ba144166 wgpu: Implement Bevel filter 2023-07-19 22:59:33 +02:00
Nathan Adams 5597535471 wgpu: Store wgpu::Instance in Descriptors 2023-07-19 21:36:30 +02:00
Nathan Adams 030c3c50e8 wgpu: Make `request_adapter_and_device` take in wgpu::Instance by ref 2023-07-19 21:36:30 +02:00
Nathan Adams a35ea3d9f2 wgpu: Sum up all center blur pixels before multiplying 2023-07-17 23:33:30 +02:00
Nathan Adams 18e343c6ad wgpu: Shift blur uvs over to the left of the kernel 2023-07-17 23:33:30 +02:00
Nathan Adams 8ecd9d0181 wgpu: Precompute left_weight in blur shader 2023-07-17 23:33:30 +02:00
Nathan Adams 13eda1361a wgpu: Use push constants for blur buffer, when supported 2023-07-17 23:33:30 +02:00
Nathan Adams 0076d65865 wgpu: Speed up blur filter by about 50% 2023-07-17 23:33:30 +02:00
renovate[bot] 268403faad chore(deps): lock file maintenance rust dependencies 2023-07-17 09:55:56 +03:00
Nathan Adams cd2d01bf6f wgpu: Fix crash when not using push constants 2023-07-16 00:31:50 +02:00
Nathan Adams ee7412d733 wgpu: Fix off-by-one in blur size calculation 2023-07-15 01:49:57 +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
Nathan Adams 5c13d323b3 wgpu: Implement the undocumented ability to disable compositeSource for glow/shadow 2023-07-12 18:51:11 +02:00
Nathan Adams c9a241f12b wgpu: When sampling outside of blur texture, use 0 2023-07-12 18:51:11 +02:00
Nathan Adams 6f98b3d596 wgpu: Saturate alpha in glow shader 2023-07-12 18:51:11 +02:00
Nathan Adams 8cb6e5bdf0 wgpu: Implement drop shadow filter 2023-07-12 18:51:11 +02:00
Nathan Adams aab03290be wgpu: Add extra set of UVs to glow filter, to support separate blur rects 2023-07-12 18:51:11 +02:00
Nathan Adams aba2394732 wgpu: Respect alpha for glows 2023-07-12 18:51:11 +02:00
Nathan Adams 1aa2ac28c2 wgpu: Slight opimitsation to blur filter by not needing to calculate full_width per fragment 2023-07-12 18:51:11 +02:00
Nathan Adams 30e7a1eac6 core: Account for filter size changes when drawing cacheAsBitmaps 2023-07-12 18:51:11 +02:00
Nathan Adams b30c522f9c wgpu: Implement glow filter 2023-07-12 18:51:11 +02:00
renovate[bot] f0607d6a1f chore(deps): lock file maintenance rust dependencies 2023-07-11 22:42:51 +02: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 9d3e96e3a4
render: Implement more Pixelbender opcodes, and fix matrices (#11896) 2023-07-09 16:54:26 +00:00
Aaron Hill b6fae8e214 wgpu: Cache Program3D bind group layout
The bind group layout only depends on the texture registers
(and 2D/cubemap type) accessed by the fragment shader, not on
the runtime texture bound with Context3D. This means that we can
build and cache it when we compile the AGAL program to a Naga
module.

Since the bind group layout is used for the overall pipeline, I've
refactored the shader caching code into `ShaderPairAgal`, which
holds both the vertex and fragment shader bytecode, and compiles
both in the `compile` function.
2023-07-09 12:39:10 -04:00
Aaron Hill e9f4a92073 wgpu: Only log 'unsupported' warning once per filter type
This eliminates the console spam produced when an object with
an unsupported filter was onscreen.
2023-07-07 22:38:35 +02:00
Aaron Hill 852367b09b wgpu: Use a vec4f for pixelbender ZEROED_OUT_OF_RANGE_MODE_INDEX
This could really be a single f32 (or even a boolean), but wgpu
on web requires a minimum size of 16 bytes for uniforms.
2023-07-05 21:23:22 +02:00
Aaron Hill 3006356410 render: Suppress clippy::arc_with_non_send_sync for now 2023-07-04 20:50:46 +02:00
Aaron Hill f22bef99b4 core: Fix some Clippy lints on the latest nightly 2023-07-04 20:50:46 +02:00
Nathan Adams 4ac13de2f3 wgpu: Switch PASS_SCALES to be accumulative scales, for better calculation of size upfront 2023-07-03 20:13:40 +02:00
renovate[bot] 13b1078142 chore(deps): lock file maintenance rust dependencies 2023-07-03 08:28:13 +03:00
Aaron Hill 6e1f00edf2
render: Implement more PixelBender features (#11800) 2023-07-01 13:50:43 -04:00
Nathan Adams 97ad60e66a wgpu: Pad out the BlurUniforms 2023-06-28 22:42:31 +02:00
Nathan Adams 7e96a2fdad wgpu: Blur size is whole kernel width, minus one and half it for the shader 2023-06-28 22:42:31 +02:00
Nathan Adams b90bebc65d wgpu: Blur filter is fallible, if nothing happened then just blit 2023-06-28 22:42:31 +02:00
Nathan Adams c0e932422f wgpu: Change blur to 2-pass separable box blur, multiplied by quality 2023-06-28 22:42:31 +02:00
Nathan Adams 447cd2a5f6 wgpu: Move create_filter_vertices to FilterSource::vertices 2023-06-28 22:42:31 +02:00
Nathan Adams fd0d414d02 wgpu: Add FilterSource::for_entire_texture convenience method 2023-06-28 22:42:31 +02:00
Nathan Adams 1096d7d35e wgpu: Create a FilterSource for common arg set, and removed need for #[allow(clippy::too_many_arguments)] 2023-06-28 22:42:31 +02:00
Nathan Adams 7f4d855de9 wgpu: Move Surface::apply_filter to Filters::apply, removing need for a surface at all 2023-06-28 22:42:31 +02:00
Nathan Adams 7c751d6be8 wgpu: Implement Default for TexturePool 2023-06-28 22:42:31 +02:00
Nathan Adams 4f6bac7840 wgpu: Refactor out filters into their own files 2023-06-28 22:42:31 +02:00
Aaron Hill ad8457b54d wgpu: Remove 'TextureWrapper.format' field
We can already get the foramt from the wgpu::Texture
2023-06-28 16:26:19 -04:00
Aaron Hill 54dd160897 wgpu: Remove 'width' and 'height' fields from Texture
This is already stored in wgpu::Texture
2023-06-28 13:00:49 -04:00
Nathan Adams 96e3d36a6e wgpu: Don't mark the filters as needing push constants 2023-06-26 23:18:45 +02:00
Nathan Adams e37958351e wgpu: Removed most uniforms from filters, they're not used or needed 2023-06-26 22:07:52 +02:00
renovate[bot] 3057aa59dd chore(deps): lock file maintenance rust dependencies 2023-06-25 21:53:00 -04:00
renovate[bot] f62dd17284 fix(deps): update rust crate indexmap to v2 2023-06-25 20:27:33 -04:00
Lord-McSweeney 8c40e97ab5 wgpu: nit: Fix incorrect label in blur filter 2023-06-26 00:00:03 +02:00
Nathan Adams fd4eaef2b6 wgpu: Don't create cacheAsBitmap for textures that are too large 2023-06-25 22:58:22 +02:00
Nathan Adams 628d8f66ad render: Add filters to BitmapCacheEntry 2023-06-25 21:58:46 +02:00
Nathan Adams 44c870ba91 wgpu: Move run_copy_pipeline to utils 2023-06-25 21:58:46 +02:00
Nathan Adams 4dde126e64 wgpu: Take in a &wgpu::Texture not our own texture as we don't need omore than that 2023-06-25 21:58:46 +02:00
Nathan Adams 0c71b83e36 wgpu: Don't perform copy inside Surface::apply_filter 2023-06-25 21:58:46 +02:00
Lord-McSweeney 08dfbc96be wgpu: Slight changes to blur filter 2023-06-24 16:55:40 +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 36aee1efcf wgpu: Specialise render_offscreen_for_cache to render directly to the texture 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 97c36b442a wgpu: Switch Multiply back to a complex shader, with dst.a==0 fix 2023-06-22 14:23:15 +02:00
TÖRÖK Attila 7bbaeb2a61 chore: Bump ouroboros to 0.17.0. 2023-06-17 18:49:05 -05:00
renovate[bot] 7a21756ddb chore(deps): lock file maintenance rust dependencies 2023-06-17 11:00:52 -05: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
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
renovate[bot] a621472336 chore(deps): lock file maintenance rust dependencies 2023-06-09 20:17:25 +03:00
Aaron Hill d44c9cceb1 wgpu: Cache compiled naga-agal shader module
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.
2023-06-08 02:57:47 -05:00
renovate[bot] f1fe998869 chore(deps): lock file maintenance rust dependencies 2023-06-04 22:53:18 -05:00
Aaron Hill 2cd518013c
wgpu: Don't skip alpha/erase blend modes for BitmapData.draw (#11323)
We can skip these when we're drawing to a fresh buffer, but not when we're blending over an existing BitmapData texture.
2023-06-02 21:16:05 +00:00
Aaron Hill 999e2f5b71 wgpu: Implement Context3D.setScissorRectangle 2023-06-02 14:56:14 -05:00
relrelb abb0e33431 chore: Use Rust's `OnceCell`/`OnceLock`
They were stabilized in Rust 1.70.0, which was released yesterday.
This removes the `once_cell` dependency.
2023-06-02 22:21:38 +03:00
Aaron Hill 12e078bb2d wgpu: Fix calculation of image row padding 2023-05-28 23:35:53 -05:00
Nathan Adams b29a784968 wgpu: Remove render callback as it's no longer used 2023-05-24 23:50:48 +02:00
Nathan Adams b9322ba93a desktop: Render game separately to UI, blit both onto surface 2023-05-24 23:50:48 +02:00
Mike Welsh c00b4bf55c desktop: Initial GUI work 2023-05-24 23:50:48 +02:00
renovate[bot] 5d2477fe98 chore(deps): lock file maintenance rust dependencies 2023-05-22 19:12:08 +03: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 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
renovate[bot] f969bdce71 fix(deps): update wasm-bindgen 2023-05-17 06:44:50 +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
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
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
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 792cfd82c7 avm2: Implement `Context3D.setColorMask` 2023-04-05 12:22:13 -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 493971ab8a render: Make RenderBackend::update_texture() take a Bitmap (like register_bitmap()) 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
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 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 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] 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
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
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
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