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=
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)
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)
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>
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)
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)
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)
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>
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)
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)
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)
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)
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>
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)
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)
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)
* Add a "windows_runtime=dynamic_release" option for Unreal
* Enable parallel building
Diffs=
66d9f1725 Better premake support for Visual Studio (#7779)
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)
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=
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)
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=
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=
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)
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=
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=
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=
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)