Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ compile_commands.json
# Debug
*.dSYM/

# clangd
.clangd

# Personal notes, never shared
*.local.md
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ endif()
# ---------------------------------------------------------------------------------------
option(SGL_PIC "Build with position-independent code" OFF)
option(SGL_TESTS "Build sgl tests" OFF)
option(SGL_BENCHMARKS "Build sgl benchmarks" OFF)
option(SGL_INSTALL "Generate install + find_package() rules" "${PROJECT_IS_TOP_LEVEL}")

# ---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -153,6 +154,8 @@ endif()
set(ModuleInterfaceFiles
src/sgl/types.cppm
src/sgl/scalar.cppm
src/sgl/batch.cppm
src/sgl/soa.cppm
src/sgl/sgl.cppm
)

Expand All @@ -178,6 +181,10 @@ if(PROJECT_IS_TOP_LEVEL AND SGL_TESTS)
add_subdirectory(tests)
endif()

if(PROJECT_IS_TOP_LEVEL AND SGL_BENCHMARKS)
add_subdirectory(bench)
endif()

# ---------------------------------------------------------------------------------------
# Install + find_package(sgl) support
# ---------------------------------------------------------------------------------------
Expand Down
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ compiles unchanged against the other.
construction and signed-distance/projection queries, 3D<->2D plane-basis
projection (with batch variants), and full TRS transform composition,
inversion, and point/direction application.
- **Batch queries over SoA data**: points in a box, boxes overlapping a box or
containing a point, ray against many boxes, and bounds, as composable
predicates over float, double or int32 coordinates, returning counts, bit
masks or compacted index lists, over your own arrays or padded, pmr-backed
buffers.
See [docs/soa.md](docs/soa.md).
- **Intersection & spatial queries**: 2D segment intersection, ray-AABB and
segment-AABB tests, closest distance between two 3D segments (for
capsule/clearance checks), point-in-polygon (winding number), segment-polygon,
Expand Down Expand Up @@ -178,11 +184,12 @@ module interface with the matching instruction set.

### Options

| Option | Default | Description |
| -------------- | -------------- | -------------------------------------------- |
| `SGL_TESTS` | `OFF` | Build the GoogleTest unit-test suite |
| `SGL_PIC` | `OFF` | Build with position-independent code |
| `SGL_INSTALL` | top-level only | Generate install + `find_package()` rules |
| Option | Default | Description |
| ---------------- | -------------- | -------------------------------------------- |
| `SGL_TESTS` | `OFF` | Build the GoogleTest unit-test suite |
| `SGL_BENCHMARKS` | `OFF` | Build the Google Benchmark suite |
| `SGL_PIC` | `OFF` | Build with position-independent code |
| `SGL_INSTALL` | top-level only | Generate install + `find_package()` rules |

### Running the tests

Expand Down
23 changes: 23 additions & 0 deletions bench/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
include(FetchContent)
FetchContent_Declare(
googlebenchmark
GIT_REPOSITORY https://github.com/google/benchmark
GIT_TAG v1.9.5
SYSTEM
)

set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "" FORCE)
set(BENCHMARK_ENABLE_WERROR OFF CACHE BOOL "" FORCE)

FetchContent_MakeAvailable(
googlebenchmark
)

add_executable(soa_bench src/soa_bench.cpp)
target_link_libraries(soa_bench PRIVATE sgl sgl_project_flags benchmark::benchmark_main)
# The branchless baselines use & on bools on purpose. A source property, so it lands after -Wall.
set_source_files_properties(src/soa_bench.cpp PROPERTIES
COMPILE_OPTIONS $<$<CXX_COMPILER_ID:Clang,AppleClang>:-Wno-bitwise-instead-of-logical>
)
Loading
Loading