Commit Graph

1274 Commits

Author SHA1 Message Date
csmartdalton
b806d1a1cb Deploy golden testing on android through an apk
We used to deploy our android golden tests through a console app that we launched from the adb shell. However, this won't work anymore if we want Vulkan validation layers. Switch to an apk instead.

Also clean up and improve upon our tooling:
* Add signal handlers to notify the python server when the app crashes
* Rename dump_gms_and_goldens.py ... -> deploy_tools.py gms goldens ...
* Pipe stdout and stderr to to the python server
* Replace most instances of exit(-1) with abort()

Diffs=
2024-08-22 22:53:11 +00:00
bodymovin
7bf3e2074a mark dirty when constraint changes
mark the constraint dirty when its values change

Diffs=
b2d27b6bd mark dirty when constraint changes (#7909)
2024-08-22 15:58:36 +00:00
umberto-sonnino
e5079d16ab Fix Android goldens
It also removes premake5 alpha and bump a few deps

Diffs=
5c14a4a30 Fix Android goldens (#7902)
2024-08-22 07:56:47 +00:00
csmartdalton
ee2f4b77cb Improve Vulkan loading and organization
Load the Vulkan library at runtime and build our own dispatch table. This alleviates the need for DYLD_FALLBACK_LIBRARY_PATH on Mac/MoltenVK, will allow us to continue targeting Android 21 (which doesn't have Vulkan libraries to link against), and removes our requirement for the $VULKAN_SDK environment variable during build.

Split out the lower level functionality within
PLSRenderContextVulkanImpl to a new "VulkanContext" class, which also hosts the Vulkan dispatch table.

Instead of using Vulkan APIs directly to initialize our context, use the vk-bootstrap library. (We only incorporate this library for tests and path_fiddle; it's not part of the core renderer.)

Split out the headless functionality from fiddle_context_vulkan into a separate class. We don't build GLFW on Android and will need a Vulkan context.

Diffs=
46a3045ae Improve Vulkan loading and organization (#7873)
2024-08-22 06:36:55 +00:00
rivessamr
d757c5c69b Add webp decoder.
We've been needing this for a while for the game engines but we also need it to support decoding webp images for use in the editor with the Rive Renderer.

I haven't instrumented the build properly to use SIMD extensions, but I left some notes for how to do so. This PR unblocks the use of WebP, let's do some perf improvements in a follow up that perhaps the runtime team can own?

Diffs=
160d9eefb Add webp decoder. (#7883)
2024-08-22 04:37:47 +00:00
rivessamr
866f2311a7 iOS images unpremult SIMD support
Support for SIMD instructions for unpremult

First checkin, using rive::int16x4 instructions : 1 pixel at a time
Further checkin, using rive::int16x4 instructions : 2 pixels at a time
Last checkin, avoid computation when opaque pixels (assume there will be enough opaque pixels to warrant this)

Thanks to Chris for the SIMD instructions usage in rive

More checkins: move the decode and unpremult to the rive decoder - this requires modifications to build files. The benefits are we are now running tests on this path. However, there are some issues with decoding two images for tests:

"../../test/assets/bad.jpg" ... Apple Preview app cannot open this image, however, the current test says that it should be not null
And
"../../test/assets/bad.png", Apple Preview app can load this images, however, the current test says that it should be null

Diffs=
e992059d6 iOS images unpremult SIMD support (#7875)

Co-authored-by: rivessamr <suki@rive.app>
2024-08-21 18:34:45 +00:00
bodymovin
38404a22c7 add arithmetic operation and group converters
two new converters:
- arithmetic operation, that applies a basic arithmetic operation to an input
- group converter: this is a special converter that is used to apply a sequence of converters to a data bound property.

https://github.com/user-attachments/assets/50a0226c-343f-4252-923b-4f0c51ca6c8b

Diffs=
ad34dd4da add arithmetic operation and group converters (#7801)
2024-08-19 22:19:32 +00:00
susan101566
cba75d653a editor: setting up the update callbacks for n-slicing
I did some refactoring on image and mesh, where I created a 'deformer' that manages which mesh to show.
I also abstracted out the parts in Mesh that deals with rendering specifically, called MeshDrawable.
There's also a simple UI gated behind a feature flag that shows the N Slicing panel, where you can create, delete, update axis data (hold alt to show the remove axis button).
The behavior is that when you create a mesh, the nslicer is deleted and vice versa.

I mostly tested this manually. I added a print in the temp mesh's update, and made sure that when any axis gets deleted or updated, the print would trigger.

I could add an auto test?! I need to look into that, but wanted to send this out to get some feedback on the approach.

Next up: I'll add the algorithm for actually updating the render buffers in the temp mesh.

doc: https://www.notion.so/rive-app/9-Slice-Tech-Proposal-Image-only-50b25ea8e79c4efabb681110e288f064#15f3a49ce3534baeafc31c37fb30cc0b

Diffs=
f99c93181 editor: setting up the update callbacks for n-slicing (#7869)
2024-08-19 21:08:05 +00:00
philter
eb5d7911eb Fix for bug in Runtime LayoutComponent proxy
This bug caused layout proxies to be drawn out of order causing layout rendering issues in the runtimes.

Diffs=
85343a4e1 Fix for bug in Runtime LayoutComponent proxy (#7867)
2024-08-17 02:53:22 +00:00
bodymovin
9777dc7965 chore: release v6.0.4 6.0.4 2024-08-16 23:37:47 +00:00
bodymovin
f99c6abba7 Updating version files 2024-08-16 23:37:42 +00:00
bodymovin
ee742390a8 iOS images: back to rendering to a cg context with unmultiplying.
The method I was using to extract the pixel data doesn't always return RGBA and you cannot force Core Graphics to return RGBA (I tried CGImageCreateCopyWithColorSpace but it only works when the components per pixel match). This is particularly problematic with PNG8 where the image data is a palette, Core Graphics will return 8 bits per pixel in this case.

We let Core Graphics do the conversion by letting it render to a context and then grab the buffer as we did before. This only works with pre-multiplied alpha (the context cannot store un-multiplied, tried that too, fails on creation). So I've also re-introduced the un-multiply logic but I hand rolled it as the SIMD was failing.

Current:
```
            // CG only supports premultiplied alpha. Unmultiply now.
            size_t imageSizeInBytes = image.height * image.width * 4;
            for (size_t i = 0; i < imageSizeInBytes; i += 4)
            {
                auto alpha = image.pixels[i + 3];
                if (alpha != 0.0f)
                {
                    auto alphaFactor = 255.0f / alpha;
                    for (size_t j = 0; j < 3; j++)
                    {
                        image.pixels[i + j] *= alphaFactor;
                    }
                }
            }
```

Not working SIMD attempt (should 255/rgba.a actually do floating point here or is this the problem?) @csmartdalton:
```
            // CG only supports premultiplied alpha. Unmultiply now.
            size_t imageSizeInBytes = image.height * image.width * 4;
            for (size_t i = 0; i < imageSizeInBytes; i += 4)
            {
                auto rgba = rive::simd::load<uint8_t, 4>(&image.pixels[i]);
                if (rgba.a != 0)
                {
                    rive::simd::store(&image.pixels[i], rgba.rgb * 255 / rgba.a);
                }
            }
```

This now works with both the dwarf and the problematic png from here: https://2dimensions.slack.com/archives/CLLCU09T6/p1723735670398969?thread_ts=1723673292.651149&cid=CLLCU09T6

Diffs=
ccfcbffdf iOS images: back to rendering to a cg context with unmultiplying. (#7868)

Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
2024-08-16 23:02:40 +00:00
bodymovin
c0347a1e24 Use artboard properties as transition conditions
Adding support for transition conditions based on artboard properties.
transition_artboard_condition extends from transition_viewmodel_condition.
It might be good to rename  transition_viewmodel_condition to transition_property_condition at some point since it is extensible enough to support viewmodels, but also with other properties like here.

Diffs=
93cc33b45 Use artboard properties as transition conditions (#7796)
2024-08-16 17:42:20 +00:00
philter
b5c58e3252 Init NestedAnimation's nestedArtboard as nullptr
This should fix an issue with nested events not bubbling up on Windows and web editor.

Diffs=
c5fc07de9 Init NestedAnimation's nestedArtboard as nullptr (#7857)
2024-08-15 23:31:32 +00:00
csmartdalton
6e4f464c92 added some simple windows build scripts to make building on windows from powershell or command prompt easier
added build_rive.bat and build_rive.ps1 to build from the command prompt and PowerShell respectively.
also added some setup scripts to the scripts folder to auto-set the path to the correct location

Diffs=
fb7756072 added some simple windows build scripts to make building on windows from powershell or command prompt easier (#7800)
2024-08-15 19:33:40 +00:00
bodymovin
724db3ec15 chore: release v6.0.3 6.0.3 2024-08-15 04:53:51 +00:00
bodymovin
06a14195fb Updating version files 2024-08-15 04:53:46 +00:00
susan101566
a7a7cb5e1c editor: nine-slicing core data type definitions
This PR adds the core data types to support n-slicing. There are three main types: Axis, NSlicer and NSlicerTileMode.
1. Axis: I didn't want to make this super specific, since it could be used for grids later. So rn, it just represents some position in some dimension, and can either be a value in terms of a positional unit (like 10px) or bounds percentage (like 10%).
2. NSlicer: It's as simple as a component gets, we'll just use it to be a parent of all the n-slicer Axes, and have it be a child of Image later.
3. NSlicerTileMode: The main data here is 'style'. We said to use patchX and patchY separately from patchIndex. The last one is persisted in file, while the other two are actually used at runtime.

The non-json files are auto generated, with the runtime json files copy pasted from the dev/defs version. I verified that the editor still runs, and the runtime also runs without error.

Next up, I'll use these definitions to change editor behavior.

Documentation: https://www.notion.so/rive-app/9-Slice-Tech-Proposal-Image-only-50b25ea8e79c4efabb681110e288f064#15f3a49ce3534baeafc31c37fb30cc0b

For a rough direction of how to implement nine-slicing, check out this research branch: https://github.com/rive-app/rive/compare/master...susan/nine-slice-research

Diffs=
ed56d2de6 editor: nine-slicing core data type definitions (#7840)
2024-08-14 22:06:00 +00:00
dskuza
a5d304692d chore: release v6.0.2 6.0.2 2024-08-14 20:18:11 +00:00
dskuza
899d1cbc62 Updating version files 2024-08-14 20:18:05 +00:00
dskuza
36209a69b0 Do not render frames on iOS if view size width or height is 0
TL;DR: Do not request to draw frames when the host view's size width _or_ height is 0.

Some users were experiencing issues (and crashes, when Metal API validation is enabled) when a frame is resized to zero. This has been difficult to reproduce locally when testing scenarios that users were seeing (sometimes it's just how the developer(s) have implemented view presentation / dismissal). However, I was able to verify this crash / fix when:

1. Initially sizing a Rive view to a valid size (i.e > 0)
2. After 3 seconds, resizing the view to 0

Immediately after `2`, the crash would occur. With this fix, it doesn't.

Diffs=
7a55a6db3 Do not render frames on iOS if view size width or height is 0 (#7846)

Co-authored-by: David Skuza <david@rive.app>
2024-08-14 19:41:54 +00:00
luigi-rosso
86a5211ffe remove no-op simd unmultiply
Should've done this in tandem with this: https://github.com/rive-app/rive/pull/7820

Diffs=
87c967127 remove no-op simd unmultiply (#7836)

Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
2024-08-14 19:23:43 +00:00
bodymovin
8fef85d164 fix hovered state of group listeners
fixes #7838

Diffs=
4fb978a92 fix hovered state of group listeners (#7839)
2024-08-14 01:20:05 +00:00
luigi-rosso
3a0880ecda Update version to macosx 11 for runtime.
Sorry for the churn in the premake file, someone didn't use the right formatter in a previous commit.

We had to bump to 11 for this:
```
../../../../../../pls/renderer/metal/background_shader_compiler.mm:215:42: error: 'MTLLanguageVersion2_3' is only available on macOS 11.0 or newer [-Werror,-Wunguarded-availability-new]
        compileOptions.languageVersion = MTLLanguageVersion2_3; // On mac, we need version 2.3+
                                         ^~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLLibrary.h:190:5: note: 'MTLLanguageVersion2_3' has been marked as being introduced in macOS 11.0 here, but the deployment target is macOS 10.6.0
    MTLLanguageVersion2_3 API_AVAILABLE(macos(11.0), ios(14.0)) = (2 << 16) + 3,
    ^
../../../../../../pls/renderer/metal/background_shader_compiler.mm:215:42: note: enclose 'MTLLanguageVersion2_3' in an @available check to silence this warning
        compileOptions.languageVersion = MTLLanguageVersion2_3; // On mac, we need version 2.3+
                                         ^~~~~~~~~~~~~~~~~~~~~
../../../../../../pls/renderer/metal/background_shader_compiler.mm:220:28: error: 'setPreserveInvariance:' is only available on macOS 11.0 or newer [-Werror,-Wunguarded-availability-new]
            compileOptions.preserveInvariance = YES;
```

Diffs=
e75b8fa63 Update version to macosx 11 for runtime. (#7829)
2024-08-13 22:59:05 +00:00
bodymovin
1bb5bbb4f8 chore: release v6.0.1 6.0.1 2024-08-13 08:36:31 +00:00
bodymovin
f368b6e88b Updating version files 2024-08-13 08:36:25 +00:00
luigi-rosso
9846f45993 Decode image data directly on iOS
...instead of rendering to a core graphics context and then copying the context's buffer.

Seems like our alpha un-premultiply logic is no longer taking affect: 1c92334558/packages/runtime_ios/Source/Renderer/RenderContextManager.mm (L74-L82)

Expected:
<img src="https://rive-public-testing.s3.us-west-1.amazonaws.com/golden-tests/ios/2024-07-31/127/golden/mesh.png"/>
Currently:
<img src="https://rive-public-testing.s3.us-west-1.amazonaws.com/golden-tests/ios/2024-07-31/127/iphone-15-pro-max/mesh.png"/>

Thread with details here: https://2dimensions.slack.com/archives/C06ER4J62BA/p1722438338690329

This fixes the issue by extracting the decoded PNG bytes directly (which are un-premultiplied).

Diffs=
714b8894f Decode image data directly on iOS (#7820)

Co-authored-by: Chris Dalton <chris@rive.app>
Co-authored-by: Luigi Rosso <luigi-rosso@users.noreply.github.com>
2024-08-12 23:49:33 +00:00
damzobridge
3cc51d917c feat: add nested text run getters and setters in Unity
This PR introduces new methods to get and set text run values in nested artboards in Unity

### Unity
- Added to `Artboard` class in Unity:
  - `GetTextRunValue(string runName)`
  - `SetTextRunValueAtPath(string runName, string path, string value)`
  - `GetTextRunValueAtPath(string runName, string path)`

### rive-cpp
- Exposed in `Artboard` class:
  - `TextValueRun* getTextRun(const std::string& name) const;`

Diffs=
55de8286c feat: add nested text run getters and setters in Unity (#7808)
2024-08-12 20:48:01 +00:00
bodymovin
2eb6558e0b add two data converters
this PR adds the UI to create converters in the editor, and includes the first two:
- a rounder that accepts a property for rounding
- a toString converter that can convert for now numbers and enum. It could be extended to colors and booleans in the future.

https://github.com/user-attachments/assets/2946d8ea-0fdf-4039-83d4-79b5fdfc6169

https://github.com/user-attachments/assets/ec60b523-ecb2-4453-9280-c99822706b2e

Diffs=
2c0927fc5 add two data converters (#7742)
2024-08-09 22:28:02 +00:00
blakdragan7
8cebc40f11 added a blt command for render targets that do not support VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT
Currently, render targets that do not have the VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT flag will not work and just cause a crash. This adds an offscreen texture that can be used as an input attachment in its place and then a copy command to update the render target at the end.

Diffs=
8c7ac0329 added a blt command for render targets that do not support VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT (#7757)
2024-08-09 04:44:07 +00:00
csmartdalton
c629746fcf Better premake support for Visual Studio
* Add a "windows_runtime=dynamic_release" option for Unreal
* Enable parallel building

Diffs=
66d9f1725 Better premake support for Visual Studio (#7779)
2024-08-08 18:43:16 +00:00
csmartdalton
87b8cf7273 Add Xcode support to build_rive.sh
Add an "xcode" option that generates and builds an xcode workspace.

Add -Wshorten-64-to-32 to non-Xcode builds and fix more warnings.

Diffs=
f0da6a7a0 Add Xcode support to build_rive.sh (#7780)
2024-08-08 16:31:06 +00:00
csmartdalton
3ed8b1be6c Fix static assertion in ResourceAllocationCounts
We can't assert the size of the struct is equal to the size of VecType because clang might allocate unused space in the vector. Insead ensure all the elements are of type size_t by asserting that the class is the size of kNumElements size_ts.

Diffs=
2024-08-08 00:56:03 +00:00
rivessamr
2ff9459e9f Added support for xcode builds
Diffs=
c12b0bb24 Added support for xcode builds (#7774)
2024-08-08 00:44:13 +00:00
philter
e70a386b23 Add width/height overrides for NestedArtboardLayout
Adds the ability to override width and height for NestedArtboardLayout. This allows each NestedArtboardLayout instance to respond to be sized differently. This is not supported in the NestedArtboard Node and Leaf types, since those are resized using differently (Node uses scale and Leaf uses a combination of scale/fit/alignment).

Implemented via FFI as discussed with @luigi-rosso because NestedArtboardLayout modifying the "taken" layoutNode directly could result in race conditions and other conflicts.

https://github.com/user-attachments/assets/c323a94f-f392-4c10-ac01-af112f70a256

Diffs=
0dc0b435f Add width/height overrides for NestedArtboardLayout (#7736)
2024-08-07 18:43:42 +00:00
bodymovin
7cef0b9d8b refactor conditions
refactor code:
- adds template for comparing view models
- unifies evaluate method for view model and input conditions

Diffs=
1131f30e6 refactor conditions (#7747)
2024-08-06 23:11:09 +00:00
philter
c8da275616 Fix layout shape hug in CPP
Diffs=
35a52873c Fix layout shape hug in CPP (#7770)
2024-08-06 21:09:21 +00:00
csmartdalton
1a46af0289 Move COVERAGE_PLANE_IDX to 3
Coverage can't be bound as an input attachment in atomic mode. Move it
to the end so the framebuffer can use fewer attachments in Vulkan.

Diffs=
2024-08-06 20:50:37 +00:00
csmartdalton
546a43814a Use fixed function color blend in Vulkan
In atomic mode with no advanced blend, update Vulkan to use fixed
function color blend instead of an input attachment for color.

The biggest system-wide change is that we now have a
"fixedFunctionColorBlend" flag in pls::ShaderMiscFlags. This is the
correct way that we should have done this all along, and allows backends
to opt into the feature without requiring them to implicitly use it when
certian conditions are met.

The biggest Vulkan change here is that since this changes the entire
pipeline layout, we have to compile different fragment shaders. To do
this, we collapse the "spirv/*.vert" and "spirv/*.frag" variants of the
shaders into single ".main" files, then compile them up to 3 times --
once with `-DVERTEX`, once with `-DFRAGMENT`, and once with
`-DFIXED_FUNCTION_COLOR_BLEND -DFRAGMENT`.

Diffs=
2024-08-05 23:00:15 +00:00
csmartdalton
bc367aded1 Add a premake message when Xcode command line tools isn't installed
Diffs=
949c70600 Add a premake message when Xcode command line tools isn't installed (#7756)
2024-08-05 22:51:21 +00:00
csmartdalton
bfee5e365b Move support variables for assert() behind "#ifndef NDEBUG"
assert() switches on NDEBUG, so the support variables for asserts should also switch on "#ifndef NDEBUG" (not "#ifdef DEBUG").

Diffs=
2024-08-05 17:06:05 +00:00
csmartdalton
8a333b7931 Make shader type conversions explicit
Distinguish constructors from type conversions.

Constructors are called "make_*()", live in common.glsl, and only accept arguments of the same type as the underlying object.

Type conversions are called "cast_*_to_*()", live in the language-specific files, and only convert one single argument to a vector of equal width.

Diffs=
2024-08-05 16:48:47 +00:00
csmartdalton
87d53cfc4d Tidy up Vulkan extension wrangling
Diffs=
2024-08-05 16:36:29 +00:00
bodymovin
7ce3619a72 add data converter and data types for conversion
First PR for converters support.
It adds the abstract data_converter class
And adds new data value objects that can be passed between converters to easily transform one type of data to another

https://github.com/user-attachments/assets/e8a0fdee-8845-4d0d-a894-c948c2b0a209

Diffs=
4bf7c7545 add data converter and data types for conversion (#7734)
2024-08-03 02:29:46 +00:00
csmartdalton
355ac4bd3b Specialize SPIR-V for pls::ShaderFeatures
Add specialization constants to PLS shaders when compiling to SPIR-V. Set these constants on VkPipelines based on pls::ShaderFeatures.

Add a new shader switch, "@FIXED_FUNCTION_COLOR_BLEND", to explicitly turn on direct-to-framebuffer rendering. We used to implicitly make this switch based on @ENABLE_ADVANCED_BLEND, which broke the model that a superset of shader features was always compatible with any subset. This also allows us to specialize Vulkan shaders before making the switch to direct-to-framebuffer rendering.

Diffs=
2024-08-02 06:27:25 +00:00
csmartdalton
5d8aef4cd6 Finish atomic mode in Vulkan
This gets the Vulkan backend wrapped up functionally (though not optimized) by implementing "atomic mode" mode with input attachments.

The coverage plane is still a storage texture, since it needs atomic operations, but color and clip are input attachments.

Next up we can finally start optimizing.

Diffs=
2024-08-01 18:52:42 +00:00
bodymovin
08dce8b96a add listener actions support for databind
adds support for manipulating view model values from state machines through listener actions

https://github.com/user-attachments/assets/7ddd4cd2-a04d-4d33-98de-b1f29aa24755

Diffs=
d9f5701ec add listener actions support for databind (#7710)
2024-08-01 01:15:39 +00:00
damzobridge
f885144da0 feat: add min macos version to minification script
This PR addresses the issue where Unity projects on MacOS lower than 14 (Sonoma) would crash if the Rive plugin is present.

`Function GD has a deployment target (0x00020006) which is incompatible with this OS (0x00020005).`

If we don't specify a minimum version, it looks like the shader minification script uses the OS version on the GitHub runner (Sonoma).

In this PR, we set the minimum OS to MacOS 13 (Ventura) so that the shaders still support Ventura even when built with the Sonoma runners.

Diffs=
2024-07-31 23:27:47 +00:00
philter
4f695e92b9 Fix alignment when flex wrap enabled
Fixes an issue where layout alignment wasn't working when flex wrap was enabled.

**Before:**

https://github.com/user-attachments/assets/0486c436-0049-49d8-8483-b6fdbf1cf2d5

**After:**

https://github.com/user-attachments/assets/0014e624-6b83-4417-a93d-6e1adea41bd3

Diffs=
dcb165130 Fix alignment when flex wrap enabled (#7722)
2024-07-31 01:24:15 +00:00
csmartdalton
5e8b602843 Buildsystem fixes for build_rive.sh and PLS shaders
build_rive.sh wasn't catching all the build errors with just 'set -e'. Add 'set -o pipefail' to catch the errors being piped into 'grep -v'.

The complicated logic in premake5_pls_renderer.lua that was being executed as a bash "if" had an issue. Rewrite this logic in Lua.

Diffs=
fbfa3b545 Buildsystem fixes for build_rive.sh and PLS shaders (#7716)
2024-07-29 22:55:06 +00:00