Skip to content

Commit

Permalink
Implement re-ordering for PLS atomic draws
Browse files Browse the repository at this point in the history
Atomic mode needs a barrier between overlapping draws. Implement re-ordering of non-overlapping draws to minimize barriers.

Add a massively SIMD "IntersectionBoard" class that assigns a minimal "groupIndex" to each draw based on its bounding box. Sort draws based on groupIndex, plus lower priority items like draw type and texture hash. Issue draws in the new order with barriers between different groupIndex values.

Discard draws ahead of time that are empty or offscreen. (IntersectionBoard doesn't support these.)

Now that the draw logic is getting more complex, store PLSDraws in a smart pointer that guarantees we never miss a call to releaseRefs().

New simd features:
  - reduce_add, reduce_min, reduce_max, reduce_and, reduce_or
  - >2 arguments to join
  - zip()
  - more typedefs

Diffs=
d67aeac4d Implement re-ordering for PLS atomic draws (#6417)

Co-authored-by: Chris Dalton <[email protected]>
  • Loading branch information
csmartdalton and csmartdalton committed Jan 8, 2024
1 parent 5d90bc8 commit c238af4
Show file tree
Hide file tree
Showing 13 changed files with 479 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a3788ed8ad14d8046faec27d34c9483ddb7d7cb3
d67aeac4d7643cdb60f7d22c9b2c0005e7838ed9
2 changes: 1 addition & 1 deletion include/rive/math/aabb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define _RIVE_AABB_HPP_

#include "rive/span.hpp"
#include "rive/math/mat2d.hpp"
#include "rive/math/vec2d.hpp"
#include <cstddef>
#include <limits>
Expand Down Expand Up @@ -67,6 +66,7 @@ class AABB
AABB offset(float dx, float dy) const { return {minX + dx, minY + dy, maxX + dx, maxY + dy}; }

IAABB round() const;
IAABB roundOut() const; // Rounds out to integer bounds that fully contain the rectangle.

///
/// Initialize an AABB to values that represent an invalid/collapsed
Expand Down
6 changes: 6 additions & 0 deletions include/rive/math/mat2d.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _RIVE_MAT2D_HPP_
#define _RIVE_MAT2D_HPP_

#include "rive/math/aabb.hpp"
#include "rive/math/vec2d.hpp"
#include <array>
#include <cstddef>
Expand Down Expand Up @@ -44,6 +45,11 @@ class Mat2D
// Sets dst[i] = M * pts[i] for i in 0..n-1.
void mapPoints(Vec2D dst[], const Vec2D pts[], size_t n) const;

// Computes a bounding box that would tightly contain the given points if they were to all be
// transformed by this matrix.
AABB mapBoundingBox(const Vec2D pts[], size_t n) const;
AABB mapBoundingBox(const AABB&) const;

// If returns true, result holds the inverse.
// If returns false, result is unchnaged.
bool invert(Mat2D* result) const;
Expand Down
1 change: 1 addition & 0 deletions include/rive/math/math_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace rive
namespace math
{
constexpr float PI = 3.14159265f;
constexpr float SQRT2 = 1.41421356f;
constexpr float EPSILON = 1.f / (1 << 12); // Common threshold for detecting values near zero.

RIVE_MAYBE_UNUSED inline bool nearly_zero(float a, float tolerance = EPSILON)
Expand Down
Loading

0 comments on commit c238af4

Please sign in to comment.