Commit Graph

8 Commits (0b317ee0f5c97bb41561fb0186ab5e8e7c76af79)

Author SHA1 Message Date
Chris Burel 0b317ee0f5
Merge pull request #7566 from aws-lumberyard-dev/fixClangWindowsBuild
Fix clang windows build
4 years ago
bosnichd d0e5f9d20b
Added Async APIs for the various Process*FromList/Region terrain functions. (#7480)
* Added Async APIs for the various Process*FromList terrain functions.

Please note that we are currently defaulting the number of worker threads to one, because splitting the work over multiple threads causes contention when locking various mutexes, resulting in slower overall wall time for async requests split over multiple threads vs one where all the work is done on a single thread. The latter is still preferable over a regular synchronous call because it is just as quick and prevents the main thread from blocking. This should be changed once the mutex contention issues have been addressed, so that async calls automatically split the work between available job manager worker threads, unless the ProcessAsyncParams specify a different desired number of jobs.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Fix Linux builds by adding missing #include

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Added a test for cancellation of terrain async requests, and fix it so that it works.

Note that the benchmarks show this implementation to be slightly slower than the previous one, which I presume is because we're now calling a 'perSurfacePointFunction' in the inner loop; this can probably be addressed, but will result in a lot of code duplication, and I think efforts will be better spent on removing the mutex contention to enable running multiple terrain async jobs at the same time.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Added Async versions for all Process*Region terrain API functions, along with benchmarks.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Fix the newly added terrain async request benchmarks to actually use the async APIs.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Revert to the original version which just calls the synchronous API from the job function, along with some other updates in response to review feedback.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Change the TerrainWorldDebugger to use the async API, along with the following changes:
- TerrainJobContext no longer uses a JobCancelGroup so we can guarantee the completion callbacks of associated jobs will be invoked even if it is cancelled.
- As a result of the above change, the ProcessAsyncCompleteCallback function signature again accepts the associated TerrainJobContext as a param.
- The TerrainProcessAsyncCancellation test has been resurrected and simplified by using binary semaphores instead of condition variables.
- All the async related TerrainSystemBenchmark functions have been simplified by using binary semaphores instead of condition variables.
- Global cancellation of all terrain jobs on deactivation of the TerrainSystem has been reintroduced, but in a different way than before.
- Other miscellaneous changes/fixes made while testing and based on earlier PR feedback.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Updates based on review feedback:
- Go back to using a vector instead of an array (fixed the original problem by adding custom copy/assignment constructors/operators to the WireframeSector struct).
- When calling WireframeSector::Reset, block until any associated in flight has completed.
- Added the concept of a minimum number of positions per terrain job.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Use semaphore instead of binary_semaphore in a bunch of places to account for the race condition where a completion callback fires before we started waiting for it.

Signed-off-by: bosnichd <bosnichd@amazon.com>
4 years ago
Chris Burel 664403c5de Mark benchmark state variables in for loops as unused in benchmarks
Signed-off-by: Chris Burel <burelc@amazon.com>
4 years ago
bosnichd ff4529fc60
Terrain ray cast benchmarks and optimization. (#7303)
* Terrain ray cast benchmarks and optimization:
- Added some benchmarks that exercise terrain ray casting.
- Optimized terrain ray casting by removing an unnecessary AABB intersection check (this was suggested by @invertednormal in the original review, but I forgot to actually remove it until now).
- Fixed a bug where we were not normalizing the ray direction before performing the Moller-Trumbore ray<->triangle intersection calculations.

Signed-off-by: bosnichd <bosnichd@amazon.com>

* Update to make work with changes pulled down from mainline.

Signed-off-by: bosnichd <bosnichd@amazon.com>
4 years ago
Ken Pruiksma b455b915a8
Making terrain query resolution a single float instead of a Vector2 (#7186)
* Making terrain query resolution a single float instead of a Vector2

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Keeping the concept of different x/y step sizes in region queries since that may be useful and is separate from query resolution. Also keeping the concept of different x/y step sizes in physics since that's independent of the terrain gem.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Formatting cleanups

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* A few more minor cleanups

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Added support to convert serialized Vector2 query resolution to a single float.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Switch ray intersection check back to using separate values for x and y resolution

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Fixing new unit tests added to use float query resolution.

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>

* Updating automated test

Signed-off-by: Ken Pruiksma <pruiksma@amazon.com>
4 years ago
amzn-sj 5dc442fcb0
[Terrain] First pass of the ProcessList and ProcessRegion APIs for retrieving surface data (#6729)
* [Terrain] First pass of the ProcessList and ProcessRegion APIs for retrieving surface data

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Add a couple of more tests. The expected values were plugged in based on the values generated by the brute force approach.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Move some declarations out of loops since they can be reused.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Update all the per position callbacks to pass SurfacePoint refs. Construct only one SurfacePoint object outside the loop which can be reused.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Update tests to use the new per position callbacks

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Add ProcessRegion functions to the terrain benchmark.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Change C style static casts to aznumeric_cast. Add maybe_unused to unused params in benchmarks.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Update the ProcessList API functions to use array_view instead of a vector. This includes some additional changes to satisfy build dependencies.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Add ProcessList API functions to benchmarks

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Update the ProcessList API functions to take Vector2 as input positions

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Revert changes to AtomCore library split. Add partial implementation of span(mostly just copied over from array_view) to AzCore std containers.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Adding some const/non-const overloads that were missing in span

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Move input position list generation to a function

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Bring back Vector3 version of ProcessList functions. Rename Vector2 version to follow similar pattern as the Get functions.

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Split span.h into .h/.inl files

Signed-off-by: amzn-sj <srikkant@amazon.com>

* Add [mayby_unused] for unused parameters to fix build errors

Signed-off-by: amzn-sj <srikkant@amazon.com>
4 years ago
Mike Balfour 07c862bd52 Fix string format specifier.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
4 years ago
Mike Balfour 9556c5bf62 Add benchmarks for terrain APIs.
Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com>
4 years ago