Commit Graph

717 Commits

Author SHA1 Message Date
Nathan Adams c3423b86f8 wgpu: Use vertex buffer and staging belt for bevel filter 2024-01-27 21:37:22 +01:00
Nathan Adams 7e0bd48061 wgpu: Use vertex buffer and staging belt for glow filter 2024-01-27 21:37:22 +01:00
Nathan Adams 2722a6588e wgpu: Use vertex buffer and staging belt for simple filters 2024-01-27 21:37:22 +01:00
Nathan Adams 9320de354c wgpu: Use staging belt and single buffer for filter arguments 2024-01-27 21:37:22 +01:00
Nathan Adams 76d07faacf wgpu: Make sync index Option<> in make_queue_sync_handle 2024-01-27 21:37:22 +01:00
Nathan Adams f99f89122a wgpu: Remove uniform encoder 2024-01-27 21:37:22 +01:00
Nathan Adams de975a9727 wgpu: Merge Transforms and ColorAdjustments 2024-01-27 21:37:22 +01:00
Nathan Adams 1231d2fead wgpu: Extract out ESTIMATED_OBJECTS_PER_CHUNK, set it to 200 2024-01-27 21:37:22 +01:00
Nathan Adams 574e83f3a3 wgpu: Use max_uniform_buffer_binding_size from adapter 2024-01-27 21:37:22 +01:00
Nathan Adams befce41e11 wgpu: Remove push constant support - simplifies code significantly, and it should be same perf now 2024-01-27 21:37:22 +01:00
Nathan Adams fd604b3a18 wgpu: Try using a single buffer/bindgroup for transform/colortransforms, no longer dynamically allocated 2024-01-27 21:37:22 +01:00
Nathan Adams 6824f33cc6 wgpu: Add limits to BufferBuilder (but currently not respected for Meshes) 2024-01-27 21:37:22 +01:00
Aaron Hill 820e7e828a wgpu: Allow Stage3D texture upload where source is smaller than dest
Fancy Pants World 4 relies on this behavior.
2024-01-25 00:30:10 +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] 262dff83a4 fix(deps): update rust dependencies 2024-01-22 03:09:33 +01:00
Nathan Adams c63f51f823 web: Enable webgpu 2024-01-21 19:36:08 +01:00
Nathan Adams 4d16e24889 wgpu: Update wgpu and naga to 0.19 2024-01-21 19:36:08 +01:00
Aaron Hill e73819d531 Use supported_sample_count for Context3D sample count
This rounds the requested sample count down to a value
that's supported by the device.
2024-01-21 12:47:13 -05:00
TÖRÖK Attila d153290fd6 nits: Fix a whole bunch of typos all over the place 2024-01-17 23:59:19 +01:00
Aaron Hill b5f28f6caa wgpu: Add support for Stage3D anisotropic filtering
Instead of binding every supported sampler combination
and selecting the correct index in our AGAL builder,
we now determine the correct sampler on the wgpu side,
and create one sampler binding per texture slot.
2024-01-16 18:08:28 -05:00
renovate[bot] 3c115238fd fix(deps): update rust dependencies 2024-01-16 01:13:38 +01:00
renovate[bot] e0a22b56ce fix(deps): update wasm-bindgen 2024-01-15 17:24:02 -05:00
renovate[bot] a328deab11 fix(deps): update rust dependencies 2024-01-08 02:59:04 +01: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] 91d0520a43 fix(deps): update rust dependencies 2024-01-01 02:03:54 +01:00
TÖRÖK Attila badac4176c chore: Stop allowing previously buggy lint `clippy::extra_unused_type_parameters`
The corresponding Clippy issue was fixed long ago.
2023-12-25 19:20:53 -05:00
renovate[bot] 216a8f3b14 fix(deps): update rust dependencies 2023-12-25 10:09:07 +01:00
Aaron Hill 837143bb12 naga-agal: Fix handling of sampler overrides
After some testing, and looking at OpenFL, I believe I've
determined the correct behavior for AGAL sampling:

Each time a Context3D.setProgram or Context3D.setSamplerStateAt
call is made, the sampler config for the used texture slot(s)
is updated with the new wrapping/filter behavior. For setProgram,
this comes from all of the 'tex' opcodes used within the program.

However, when the 'ignoresampler' flag is set in a 'tex' opcode,
the setProgram call does *not* override the existing sampler config.
As a result, that program will sample with the behavior determined
by the most recent setSamplerStateAt or setProgram call involving
the used texture slot(s).

Previously, we were always overriding the opcode sampler config
with the values from Context3D.setSamplerStateAt. However, I didn't
realize that the order of the calls matter, so none of my tests ended
up observing the effect of 'ignoresampler'.

We now need to process AGAL bytecode twice - a quick initial
parse to determine the sampler configs (which need to be updated
when we call 'setProgram'), and a second time when to build the
Naga module (which needs to wait until we have the vertex attributes
available, which can be changed by ActionScript after setting
the program).
2023-12-15 22:05:30 -07:00
TÖRÖK Attila bf9cf92af8 render/wgpu: Update wgpu to 0.18.0, naga to 0.14.1, naga_oil to 0.11.0, egui to 0.24.1 2023-12-14 01:36:42 +01:00
renovate[bot] 3a033f0f28 fix(deps): update rust dependencies 2023-12-11 15:51:12 +01:00
Aaron Hill 44c4080ae4 wgpu: Fix overly strict assertion for setVertexBufferAt
The offsets for bound attributes can overlap, which caused
us to compute the total size incorrectly. Fix this check
to take overlapping into account.
2023-12-08 23:53:39 +01:00
renovate[bot] 40b92e69f7 fix(deps): update rust dependencies 2023-12-05 21:08:16 +01:00
renovate[bot] a0c33382bf fix(deps): update wasm-bindgen 2023-12-04 12:08:22 +01:00
renovate[bot] 6da223a875 fix(deps): update rust dependencies 2023-11-27 09:44:47 +01:00
renovate[bot] 2a83274c7f fix(deps): update rust dependencies 2023-11-19 21:09:42 -05:00
renovate[bot] 32c65e6460 fix(deps): update rust dependencies 2023-11-13 09:10:26 +01:00
renovate[bot] acadb2b2d3 fix(deps): update wasm-bindgen 2023-11-07 12:18:50 +01:00
renovate[bot] 1377a5b07b fix(deps): update rust dependencies 2023-11-01 00:45:43 +01:00
Aaron Hill 46320c6238
wgpu: Round down Context3D sample count to nearest power of 2 (#13762) 2023-10-29 00:18:52 +00:00
Aaron Hill b5097445e6 render: Add support for Context3DTextureFormat.COMPRESSED_ALPHA
This is our first non-rgba texture format (it uses Bc3RgbaUnorm).
ATF files store these textures in a very convoluted way - fortunately,
the 'dds2atf' tool is open-source, which allowed me to figure out
how to decode the texture back to a DXT5/DXT1 texture.
2023-10-23 11:18:27 -04:00
renovate[bot] cd01bfe7d6 fix(deps): update rust dependencies 2023-10-23 02:55:11 +02:00
renovate[bot] 18796a67fe fix(deps): update rust dependencies 2023-10-10 02:15:59 +02:00
Aaron Hill c93020e729 wgpu: Correctly set format when rendering to Stage3D texture
This fixes a panic when trying to render a texture with a type
other than `TextureFormat::Rgba8Unorm`
2023-10-04 22:47:17 -04:00
renovate[bot] 428e89af73 fix(deps): update rust dependencies 2023-10-04 19:19:51 -04:00
Aaron Hill d32b19e350 render: Implement Context3DTextureFormat::RgbaHalfFloat 2023-10-03 18:05:46 -04:00
Aaron Hill 2dcd783261 render: Disable wgpu unused shader output check when possible
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.
2023-09-30 17:59:36 -04:00
Aaron Hill ec7a8ac645
avm2: Add support for Stage3D bytearray/compressed textures (#13180) 2023-09-28 03:03:30 +00:00
renovate[bot] 7e4e4d4c5b fix(deps): update rust dependencies 2023-09-25 11:14:39 +02:00
Aaron Hill 01b1e36ef5
wgpu: Rename DepthBuffer to StencilBuffer and stop providing depth_ops (#13302) 2023-09-24 20:19:14 +00:00
renovate[bot] 37e2c06034 fix(deps): update rust dependencies 2023-09-18 00:00:45 +02:00
renovate[bot] dabc2d56b9 fix(deps): update rust dependencies 2023-09-04 10:25:24 +02:00
Aaron Hill 520045de46 wgpu: Disable Context3D.setRenderToTexture MSAA on WebGL
This is not supported under webgl, and results in a panic
"Tex storage 2D multisample is not supported" if we try to
do it.
2023-08-28 13:33:32 +02:00
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