Commit Graph

320 Commits (ffdd3e85acf468dfcf34f02817d1bcf75d0b7f64)

Author SHA1 Message Date
Steve Pham 4d4f10beb8
Clang/GCC compiler settings update [SECURITY] (#7358)
- 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>
4 years ago
Steve Pham 71cc3a2568
Remove -Wno-comment warning suppression
Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com>
4 years ago
amzn-sj 112e310419
[Serialization] Add support for updating the values of existing keys in associative containers (#6832)
* 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>
4 years ago
lumberyard-employee-dm b9824ed172
Updated all array_view uses with the C++20 span. (#7157)
* 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>
4 years ago
Esteban Papp d605b5636d
Merge pull request #5532 from aws-lumberyard-dev/optimization/unused_files
Optimization: remove unused files
4 years ago
Esteban Papp 75f511d851
Merge pull request #6390 from aws-lumberyard-dev/memory/overrideshim_removal
Memory/overrideshim removal
4 years ago
Esteban Papp 6fad254b59 Merge branch 'development' into optimization/unused_files
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

# Conflicts:
#	Code/Editor/IEditorImpl.cpp
#	Code/Editor/IEditorImpl.h
#	Gems/LmbrCentral/Code/Tests/lmbrcentral_editor_tests_files.cmake
4 years ago
Scott Romero 56e7e70735
[development] properly pal-ify Android utilities in AzCore (#7147)
Signed-off-by: AMZN-ScottR 24445312+AMZN-ScottR@users.noreply.github.com
4 years ago
amzn-mike 956a1e59bb
[LYN-9039] Object stream write response change (#7085)
* 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>
4 years ago
lumberyard-employee-dm f3e9e41f4f
Adding partial implementation of C++20 concepts and range functions for AZStd::span (#7102)
* 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>
4 years ago
Chris Galvan 8d0dce2613
Merge pull request #7101 from siretty/fix_build_linux_clang_13
Fix Build on Linux with Clang 13 with Debug, Profile and Release Configuration
4 years ago
Chris Galvan 71640c1c82
Merge pull request #6376 from nemerle/compiletime_filerequest_code2
Compile time reduction - FileRequest & related changes
4 years ago
Daniel Edwards 0a5f472f43 Clang 13: Fix build errors ...
... due to local variables only being written to (but never read).

Signed-off-by: Daniel Edwards <dev@danieledwards.de>
4 years ago
Nicholas Van Sickle 32e2ba754b
Add Dom::Path class for representing positions in a Dom (#7008)
* 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>
4 years ago
Esteban Papp 507a305f67 Cleanup before merge
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
4 years ago
Esteban Papp c978e12efc Merge branch 'development' into memory/overrideshim_removal
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
4 years ago
Steve Pham 59e43813f0
GCC Support for Linux
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>
4 years ago
Nicholas Van Sickle cfd721bce1
A bit of Generic DOM tidying/fixup (#6914)
* 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>
4 years ago
Nicholas Van Sickle f026e543cc
Merge pull request #6395 from aws-lumberyard-dev/nvsickle/GenericDomDocument
Add a generic Value type to the Generic DOM
4 years ago
nemerle 3cac520280 Fix non-unity windows build
Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>
4 years ago
lumberyard-employee-dm 098005afbc
AZStd::basic_string improvements (#6438)
* AZStd::basic_string improvements

The AZStd::basic_string class has a better implementation of the Short
String Optimization, which increases the amount of characters that can
be stored in a `basic_string<char>` from 15 characters to 22
characters(not-including null-terminating characters). For a
`basic_string<wchar_t>` on Windows the amount of characters that can be
stored increases from 7 to 10. Using `basic_string<wchar_t>` on Unix
platforms SSO character amount from 3 to 4 characters.

An additional benefit is that the size of the AZStd::basic_string class
has been reduced from 40 bytes to 32 bytes when using the
AZStd::allocator.
When using a stateless allocator with no non static data members such as
AZStd::stateless_allocator, the size of the AZStd::basic_string is 24
bytes.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Corrected comments and updated type alias to usings for AZStd::basic_string

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Added Benchmarks for the basic_string and basic_fixed_string class

The benchmarks currently measure the speed of the `assign` overloads.
A benchmark has also been added to compare the speed swapping two
`basic_string` instances by 3 memcpy vs 3 pointer swap operations

Speed up string operation when in the iterator overload cases of the
`assign`, `append`, `insert` and `replace` function.
The code was always performing the logic to copy over a string that is
overlapping, without actually checking if the string was overlapping in
the first place.

Added an `az_builtin_is_constant_evaluated` macro that allows use of the
C++20 `std::is_constant_evaluated` feature to determine if an operation
is being performed at compile time vs run time.

That macro is being used to speed up the char_trait operations at run
time, by using the faster standard library functions.
For example char_traits::move now uses "memmove" at runtime, instead of
a for loop.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>

* Simplified string logic in AWSMetricsServiceApiTest.

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
4 years ago
nemerle f1f81c3789 Merge remote-tracking branch 'upstream/development' into compiletime_filerequest_code2 4 years ago
Nicholas Van Sickle e7f573d22a Make Value ctor explicit
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Esteban Papp 09fd52ef73
AzCore Math tests produce errors that need to be disabled in debug (#6678)
* Tests produce errors that need to be disabled in debug

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* PR suggestion

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
4 years ago
Esteban Papp af6af93dff Fixes Linux builds
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
4 years ago
Esteban Papp ddbcc68106 Merge branch 'development' into memory/overrideshim_removal
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

# Conflicts:
#	Code/Framework/AzCore/AzCore/Memory/AllocatorBase.cpp
#	Code/Framework/AzCore/AzCore/Memory/BestFitExternalMapAllocator.cpp
#	Code/Framework/AzCore/AzCore/Memory/BestFitExternalMapSchema.cpp
#	Code/Framework/AzCore/AzCore/Memory/PoolSchema.cpp
#	Code/Framework/AzCore/AzCore/Memory/SystemAllocator.cpp
#	Code/Framework/AzCore/Tests/Memory/AllocatorBenchmarks.cpp
4 years ago
Nicholas Van Sickle acc6248ec9 Move deep comparison / copy to utils
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Esteban Papp 89067fe667
Memory/benchmarks (#5896)
* initial version ported from an old implementation

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* simplification of code

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Fixes a recursive loop

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Removing commented code of different options for getting memory usage of a process

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* PR comment (NULL->nullptr)

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Adds mulit-threaded tests

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Improving runtime and making the whole duration manageable

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Fixes Linux build

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Fixes for mac

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Fixes for HeapSchema to get a default block if none is passed

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Adds recording functionality (disabled) and a benchmark that can run recordings

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Removes Heap allocator from being possible to use as a SystemAllocator since it doesnt allow dynamic allocating (only works with pre-allocated blocks)

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* WIP trying to use SystemAllocator instead of raw reads

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Makes the recorded benchmark more stable

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* More stability changes, improvement on type usage within the benchmark, cleanup of unstable stats

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Adds benchmark files for Android

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Fixes Linux nounity build

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* PR comments

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

* Death test relies on an exception from ocurring, that exception is an access violation, which could not happen (i.e. the memory could be valid for the process)
The test didnt have to be a death test. Also handled the situation better in the code to be able to continue in that scenario (useful for release configurations)"

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
4 years ago
Esteban Papp c548fd7682
Death test relies on an exception from ocurring, that exception is an access violation, which could not happen (i.e. the memory could be valid for the process) (#6683)
The test didnt have to be a death test. Also handled the situation better in the code to be able to continue in that scenario (useful for release configurations)"

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
4 years ago
Nicholas Van Sickle 41c0fb2b02 Address some review feedback
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Nicholas Van Sickle e518faa8be Merge remote-tracking branch 'upstream/development' into nvsickle/GenericDomDocument 4 years ago
Benjamin Jillich 79dd65e1cc
Quaternion shortest equivalent (#6472)
* Added new helper functions to get the shortest equivalent of the rotation. In case the w component of the quaternion is negative the rotation is > 180° and taking the longer path. The quaternion will be inverted in that case to take the shortest path of rotation.
* Added unit test.
* Renamed the angle parameter of the CreateRotationX/Y/Z() functions into angleInRadians.

Signed-off-by: Benjamin Jillich <jillich@amazon.com>
4 years ago
Chris Galvan 24a3014e06
Merge pull request #6318 from aws-lumberyard-dev/PathSerializationSupport
Introduced a Json Serializer for the AzCore mutable path classes
4 years ago
Jeremy Ong 5b76d47e17 Remove time tests that relied on main-thread sleeps
Sleeping in tests and attempting to rely on fine-grained measurements to
check code validity is intrinsically brittle. Wall-clock time is
unreliable in an environment where tests are run under a hypervisor that
may choose to suspend your VM at any point, or in situations where the
OS cannot schedule your thread in time. The correct way to reintroduce
these tests in the future is provide an override for the timestamp
queries that can be injected in the test environment to control the wall
time deterministically.

Signed-off-by: Jeremy Ong <jcong@amazon.com>
4 years ago
Nicholas Van Sickle 37330c43a9 Address some more Generic Dom Value perf feedback
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Nicholas Van Sickle bbd00adade Address some AZ::Dom::Value feedback
- Use a vector for shared string storage (to avoid the double heap allocation for AZStd::string)
- Use a shared heap allocated any for opaque types (instead of an unsafe ref)
- Add a string comparison key lookup benchmark to measure the impact of Name

Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Mike Balfour 1845eba6ee Fixed compile error.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
4 years ago
Mike Balfour a07534ea51 Merge commit '7e5115114ca9500abf67095acb71fbb6087d06c8' into mbalfour/gitflow_211220_stabilization_2111RTE 4 years ago
Nicholas Van Sickle 748f2a5c05 Merge remote-tracking branch 'upstream/development' into nvsickle/GenericDomDocument 4 years ago
amzn-sean fea4d0e6b1
adding TimeSystem unit tests (#6446)
Signed-off-by: amzn-sean <75276488+amzn-sean@users.noreply.github.com>
4 years ago
Nemerle d8e06d9d95 Apply reviewer suggestions
Signed-off-by: Nemerle <nemerle5+git@gmail.com>
4 years ago
Benjamin Jillich d20aa935ba
Quaternion to scaled-axis angle representation (and back) helpers (#6421)
Direct conversion helpers for quaternion to the scaled axis-angle representation and back without the need to convert them first to the axis-angle format and manually scale (or normalize on the way back). This also avoids having to deal with the special case of an identity representation which is 0,0,0 in the scaled axis-angle format while our convention for axis-angle is 0,1,0 for the axis and 0 for the angle.

Added unit tests that check the conversion round-trips from quaternion -> (scaled) axis-angle -> quaternion as well as comparing the scaled axis-angle representations from the direct helper functions as well as the axis-angle while manually scaling/normalizing.

Signed-off-by: Benjamin Jillich <jillich@amazon.com>
4 years ago
Esteban Papp d108fe4804 Addresses PR comments
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
4 years ago
Nicholas Van Sickle 10cb618ba6 Merge remote-tracking branch 'upstream/development' into nvsickle/GenericDomDocument 4 years ago
lumberyard-employee-dm dc9d1a2f31 Introduced a Json Serializer for the AzCore mutable path classes
Added UnitTest for Json Serialization of AzCore Path types

resolves #2477

Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
4 years ago
Nicholas Van Sickle f71b134a84 Ensure JsonSerializer::StoreTypeName stores the correct type for generic types
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Nicholas Van Sickle 8da04f15d3 Add some Value documentation
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
nemerle 5ff65be314 This reduces non-unity build time by ~2% and build size by ~0.5%.
This PR is a 'clean' version of #6199 updated to latest development

Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>
4 years ago
Nicholas Van Sickle d9ac3c2120 Tidy up Type enum
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago
Nicholas Van Sickle cc120c772c Add RapidjsonCopyAndMutate to compare w/ shallow copy
Signed-off-by: Nicholas Van Sickle <nvsickle@amazon.com>
4 years ago