- Add the following compilation flags for clang
-fpie
-fstack-protector-all
-fstack-check (non-release)
- Add the following compilation flags for gcc
-fpie
-fstack-protector-all
- Fix -Wunused-result errors from above compilation flag updates
- Add _FORTIFY_SOURCE=2 to GCC DEFINES
Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com>
- Remove '-Wno-return-local-addr' warning suppression flag for GCC
- Fixed discovered error resulting from -Wreturn-local-addr
Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com>
* Remove extra ws
Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com>
PAL-ified default thread priority for pthread platforms.
Fix threads not getting named on Apple platforms by setting the thread name ptr on the thread_info struct.
Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com>
* Add support for updating the values of existing keys in associative containers
Signed-off-by: amzn-sj <srikkant@amazon.com>
* Map/Unordered Map serialization updates values corresponding to existing keys by default. Multimaps always add a new entry for existing keys.
Signed-off-by: amzn-sj <srikkant@amazon.com>
* Fix unused parameter warning
Signed-off-by: amzn-sj <srikkant@amazon.com>
* Update comparison function for test case
Signed-off-by: amzn-sj <srikkant@amazon.com>
* Updated all array_view uses with the C++20 span.
The updates were done in the following order
1. `AZStd::array_view<([^>].+)\* ?>` -> `AZStd::span<\1 const>`
2. `AZStd::array_view<(?:const )(.+)>` -> `AZStd::span<const \1>`
3. `AZStd::array_view` -> `AZStd::span`
Removed the implementation of array_view.
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* Added missing whitespace between `const` and the typename for spans.
Updated the ShaderTest comparison of the ShaderResourceGroupLayout span
to compare the sizes as well
Updated comments on some of the methods that stated that they return "an
array" to mention they return "a span".
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* Fixed string_view compilation in GCC 10+.
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* More GCC 10+ Fixes.
GCC 11 seems to have an issue with linkage regarding using a lambda as a default parameter in a function declaration.
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* GCC10+ Fix - Fixed binding to a temporary references.
> error: loop variable ‘pathName’ of type ‘const QString&’ binds to a temporary constructed from type ‘const char* const’ [-Werror=range-loop-construct]
415 | for (const QString& pathName : { "CrySystem",
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* Updated the ObjectStreamWriteOverride Callback to return a
ObjectStreamWriteOverrideResponse.
The ObjectStreamWriteOverrideResponse allows the callback to indicate
that the default ObjectStream::WriteElement behavior should occur if the
callback hasn't implemented the write itself.
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* Fixed forward declaration not matching actual enum class name
Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
* Add unit tests
Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
* Remove unused member
Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
* Add virtual destructor for test class
Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
* Change string literal to not have tabs in it
Signed-off-by: amzn-mike <80125227+amzn-mike@users.noreply.github.com>
Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
At the root the problem is that some editor-only components store information to construct an asset for the runtime component but not the asset itself. This behavior caused the assets to not be correctly detected in two places.
The first place was due to the recent move to PrefDocument to avoid repeated (de)serialization of the PrefabDOM when converting to spawnables. Due to the caching the change from editor-only component to runtime component didn't record the new asset. This has been fixed by allowing assets to be collected on store as well and to check the cache validity when retrieving the list of referenced assets.
The second problem was with loading assets from the in-memory spawnable that's created for Play-In-Editor. Because the newly created assets wouldn't be loaded they need to be explicitly loaded. The original code used the collected list of assets from the PrefabDocument and checked if they were loaded, depending on hot-reloading to trigger a reload on the actual asset. This turned out to not be universally applicable, so instead the Serialize Context is now used to find all the assets that aren't loaded yet and queues a load. This is a bit more expensive to do, but to offset this cost checks are done to only do any operations on assets that haven't been loaded yet which reduces the number of calls to the Asset Manager.
Signed-off-by: AMZN-koppersr <82230785+AMZN-koppersr@users.noreply.github.com>
- Abstracted the platform specific low level profiler API
- Added support for ATrace markers on Android
- Stubbed iOS, Linux, and macOS with unimplemented versions of the low level platform profiler API
Signed-off-by: AMZN-ScottR 24445312+AMZN-ScottR@users.noreply.github.com
* WIP
Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>
* Commit before merging
Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>
* Added new pngs
Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>
* Changes from PR
Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>
* Fixed CRC errors
Signed-off-by: John Jones-Steele <82226755+jjjoness@users.noreply.github.com>
* Adding partial implementation of C++20 concepts and range functions for AZStd::span
The new concepts to discovered existing issues with the PathIterator and deque::iterator classes
PathIterator wasn't properly an input_iterator and therefore the Path classes weren't a range due to an incorrect const_iterator alias
The deque::iterator classes was missing the operator+ friend function that accepted a (ptrdiff_t, deque::iterator) to fulfill the random_access_iterator concepts
The AZStd implementations of (uninitialized_)copy(_n), (uninitialized_)move(_n) and (uninitialized_)file(_n) have been optimized to use memcpy and memset based on fulfilling the contiguous_iterator concept
Fixed invalid AZStd::vector inserts in FrameGraphExecuter.cpp and SliceditorEntityOwnershipService.cpp
The code was trying to copy the underlying addresses for vector<unique_ptr> to a vector<raw pointer> using insert, which it was doing by using memcpy.
relates to #6749
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* Fixed the `fixed_vector` emplace function to not move initialized
elements using uninitialized_move.
This was causing initialized elements of the fixed_vector to be
overwritten with the element at the emplace position.
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* Fixed clang warnings about variables that are set, but never read
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* Updated the `az_has_builtin_is_constant_evaluated` define to not have
"()" as is not a macro.
This helps prevent users from using `az_has_builtin_is_constant_evaluated`
define in a situation where they want to know if the function is being
evaluated in a compile time context.
In that case they need to use the `az_builtin_is_constant_evaluated()`
macro (which of course looks quite similiar) but does not have the word
"has" in it..
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* Updated the AZStd span class to be C++20 compliant.
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* Changed phrase "DoesNotCompiles" to be more grammatically correct.
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* Added more unit test for AZStd span
Fixed an the the return type of the subspan template overload to account
for the source span having a dynamic extent.
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* Removed unused variable from span unit test.
Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
- Currently supports JSON patch operations (add/remove/replace/copy/move/test)
- `GenerateHierarchicalDeltaPatch` provides a patch generation mechanism that produces forward and inverse patches
- Patch application comes with a `PatchApplicationStrategy` functor that allows customizing behavior for patch failure that may be useful for the prefab system
- Serialization to/from JSON patch by way of `AZ::Dom::Value` is supported
Benchmarks provided, split into three categories on the Dom value benchmark payload (payloads with up to 10k entries populated with strings up to 100 characters in length):
- Patch generation based on a deep copy of the affected data
```
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_DeepCopy/10/5 0.024 ms 0.024 ms 29867 items_per_second=41.5541k/s
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_DeepCopy/10/500 0.024 ms 0.024 ms 29867 items_per_second=41.5541k/s
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_DeepCopy/100/5 0.346 ms 0.345 ms 2036 items_per_second=2.89564k/s
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_DeepCopy/100/500 0.375 ms 0.377 ms 1867 items_per_second=2.65529k/s
DomPatchBenchmark/AzDomPatch_Generate_TopLevelReplace/10/5 0.003 ms 0.003 ms 203636 items_per_second=289.616k/s
DomPatchBenchmark/AzDomPatch_Generate_TopLevelReplace/10/500 0.004 ms 0.004 ms 194783 items_per_second=283.321k/s
DomPatchBenchmark/AzDomPatch_Generate_TopLevelReplace/100/5 0.003 ms 0.003 ms 203636 items_per_second=289.616k/s
DomPatchBenchmark/AzDomPatch_Generate_TopLevelReplace/100/500 0.004 ms 0.004 ms 194783 items_per_second=271.002k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_DeepCopy/10/5 0.023 ms 0.024 ms 29867 items_per_second=42.4775k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_DeepCopy/10/500 0.023 ms 0.023 ms 28000 items_per_second=42.6667k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_DeepCopy/100/5 0.341 ms 0.337 ms 2133 items_per_second=2.96765k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_DeepCopy/100/500 0.365 ms 0.361 ms 1948 items_per_second=2.77049k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_DeepCopy/10/5 0.023 ms 0.023 ms 29867 items_per_second=43.4429k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_DeepCopy/10/500 0.023 ms 0.024 ms 29867 items_per_second=42.4775k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_DeepCopy/100/5 0.330 ms 0.330 ms 2133 items_per_second=3.0336k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_DeepCopy/100/500 0.359 ms 0.360 ms 1867 items_per_second=2.77879k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_DeepCopy/10/5 0.023 ms 0.022 ms 29867 items_per_second=44.4532k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_DeepCopy/10/500 0.023 ms 0.023 ms 32000 items_per_second=43.5745k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_DeepCopy/100/5 0.329 ms 0.330 ms 2133 items_per_second=3.0336k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_DeepCopy/100/500 0.357 ms 0.361 ms 1948 items_per_second=2.77049k/s
```
- Patch generation based on a shallow copy of the affected data (this is faster because when using Dom::Value to copy and mutate, we can bypass expensive array and object comparisons for identical values)
```
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_ShallowCopy/10/5 0.010 ms 0.010 ms 74667 items_per_second=99.556k/s
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_ShallowCopy/10/500 0.010 ms 0.010 ms 74667 items_per_second=97.5242k/s
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_ShallowCopy/100/5 0.079 ms 0.078 ms 8960 items_per_second=12.7431k/s
DomPatchBenchmark/AzDomPatch_Generate_SimpleReplace_ShallowCopy/100/500 0.087 ms 0.087 ms 8960 items_per_second=11.4688k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_ShallowCopy/10/5 0.009 ms 0.009 ms 74667 items_per_second=116.553k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_ShallowCopy/10/500 0.009 ms 0.009 ms 74667 items_per_second=113.778k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_ShallowCopy/100/5 0.072 ms 0.071 ms 8960 items_per_second=13.9863k/s
DomPatchBenchmark/AzDomPatch_Generate_KeyRemove_ShallowCopy/100/500 0.087 ms 0.088 ms 7467 items_per_second=11.3783k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_ShallowCopy/10/5 0.014 ms 0.014 ms 49778 items_per_second=72.4044k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_ShallowCopy/10/500 0.014 ms 0.014 ms 56000 items_per_second=70.2745k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_ShallowCopy/100/5 0.118 ms 0.117 ms 5600 items_per_second=8.53333k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayAppend_ShallowCopy/100/500 0.140 ms 0.141 ms 4978 items_per_second=7.07982k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_ShallowCopy/10/5 0.009 ms 0.009 ms 89600 items_per_second=108.196k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_ShallowCopy/10/500 0.009 ms 0.009 ms 74667 items_per_second=108.607k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_ShallowCopy/100/5 0.068 ms 0.068 ms 11200 items_per_second=14.6286k/s
DomPatchBenchmark/AzDomPatch_Generate_ArrayPrepend_ShallowCopy/100/500 0.082 ms 0.082 ms 8960 items_per_second=12.2009k/s
```
- Patch application
```
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_ShallowCopy/10/5 0.001 ms 0.001 ms 560000 items_per_second=874.146k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_ShallowCopy/10/500 0.001 ms 0.001 ms 560000 items_per_second=874.146k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_ShallowCopy/100/5 0.004 ms 0.004 ms 172308 items_per_second=250.63k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_ShallowCopy/100/500 0.004 ms 0.004 ms 179200 items_per_second=260.655k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_DeepCopy/10/5 0.005 ms 0.005 ms 112000 items_per_second=193.73k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_DeepCopy/10/500 0.005 ms 0.005 ms 112000 items_per_second=193.73k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_DeepCopy/100/5 0.052 ms 0.052 ms 10000 items_per_second=19.3939k/s
DomPatchBenchmark/AzDomPatch_Apply_SimpleReplace_DeepCopy/100/500 0.052 ms 0.052 ms 11200 items_per_second=19.373k/s
DomPatchBenchmark/AzDomPatch_Apply_TopLevelReplace/10/5 0.001 ms 0.001 ms 640000 items_per_second=910.222k/s
DomPatchBenchmark/AzDomPatch_Apply_TopLevelReplace/10/500 0.001 ms 0.001 ms 640000 items_per_second=910.222k/s
DomPatchBenchmark/AzDomPatch_Apply_TopLevelReplace/100/5 0.001 ms 0.001 ms 640000 items_per_second=910.222k/s
DomPatchBenchmark/AzDomPatch_Apply_TopLevelReplace/100/500 0.001 ms 0.001 ms 640000 items_per_second=910.222k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_ShallowCopy/10/5 0.001 ms 0.001 ms 560000 items_per_second=896k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_ShallowCopy/10/500 0.001 ms 0.001 ms 640000 items_per_second=871.489k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_ShallowCopy/100/5 0.004 ms 0.004 ms 160000 items_per_second=232.727k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_ShallowCopy/100/500 0.004 ms 0.004 ms 165926 items_per_second=235.984k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_DeepCopy/10/5 0.005 ms 0.005 ms 112000 items_per_second=193.73k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_DeepCopy/10/500 0.005 ms 0.005 ms 112000 items_per_second=193.73k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_DeepCopy/100/5 0.053 ms 0.053 ms 10000 items_per_second=18.8235k/s
DomPatchBenchmark/AzDomPatch_Apply_KeyRemove_DeepCopy/100/500 0.051 ms 0.052 ms 10000 items_per_second=19.3939k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_ShallowCopy/10/5 0.001 ms 0.001 ms 497778 items_per_second=692.561k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_ShallowCopy/10/500 0.001 ms 0.001 ms 497778 items_per_second=692.561k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_ShallowCopy/100/5 0.006 ms 0.006 ms 112000 items_per_second=174.829k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_ShallowCopy/100/500 0.006 ms 0.006 ms 100000 items_per_second=177.778k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_DeepCopy/10/5 0.005 ms 0.005 ms 112000 items_per_second=193.73k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_DeepCopy/10/500 0.005 ms 0.005 ms 100000 items_per_second=188.235k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_DeepCopy/100/5 0.053 ms 0.052 ms 11200 items_per_second=19.373k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayAppend_DeepCopy/100/500 0.052 ms 0.053 ms 11200 items_per_second=18.8632k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_ShallowCopy/10/5 0.001 ms 0.001 ms 560000 items_per_second=874.146k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_ShallowCopy/10/500 0.001 ms 0.001 ms 560000 items_per_second=874.146k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_ShallowCopy/100/5 0.004 ms 0.004 ms 179200 items_per_second=260.655k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_ShallowCopy/100/500 0.004 ms 0.004 ms 179200 items_per_second=260.655k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_DeepCopy/10/5 0.005 ms 0.005 ms 100000 items_per_second=193.939k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_DeepCopy/10/500 0.005 ms 0.005 ms 100000 items_per_second=193.939k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_DeepCopy/100/5 0.052 ms 0.052 ms 11200 items_per_second=19.373k/s
DomPatchBenchmark/AzDomPatch_Apply_ArrayPrepend_DeepCopy/100/500 0.053 ms 0.053 ms 10000 items_per_second=18.8235k/s
```
At a glance, patch generation using `GenerateHierarchicalDeltaPatch` is slower than applying its created patches, but not prohibitively so. Ideally patches shouldn't be recreated unnecessarily, but especially when diffing `Value`s that have been copied and then mutated, a generate + apply operation similar to what prefabs currently do is reasonably fast.
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
* Add Dom::Path class for representing positions in a Dom
This also adds Value support for doing a path-based lookup.
The serialized representation is presently compliant with the JSON-pointer spec but the implementation supports Node types and may be later expanded if we require additional functionality (e.g. XPath style conditional querying).
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
Updates and fixes to support GCC for Linux
Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com>
Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
* A bit of Generic DOM tidying/fixup
- Refactor out a test fixture for all DOM tests / benchmarks
- Optimize `GetType` implementation to not use `AZStd::variant::visit` (benchmark included to A/B the implementations)
- Tag a few more mutating Value functions with "Mutable" to avoid astonishing copy-on-writes
Benchmark results for GetType implementation:
```
DomValueBenchmark/AzDomValueGetType_UsingVariantIndex 18.2 ns 18.0 ns 40727273 items_per_second=443.667M/s
DomValueBenchmark/AzDomValueGetType_UsingVariantVisit 32.2 ns 32.2 ns 21333333 items_per_second=248.242M/s
```
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
* Change GetValues() to take in const positions.
To support this, span needed some template deductions to correctly convert from non-const containers to const ones.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Removed the most problematic template deduction rules.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Remove duplicate validate_iterator methods.
iterator type is a pointer, not a value, so "const iterator" and "const const_iterator" produce the same function signature.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
* Fixed the span types.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>