Skip to content

Commit 46133d2

Browse files
committed
polish for release
1 parent a2c23ee commit 46133d2

7 files changed

Lines changed: 17 additions & 69 deletions

File tree

docs/src/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ High-performance ray-triangle intersection engine with BVH acceleration for CPU
66

77
- **Fast BVH acceleration** for ray-triangle intersection
88
- **CPU and GPU support** via KernelAbstractions.jl
9+
- **MultiTypeSet**: GPU-safe heterogeneous collections with compile-time type-stable dispatch for materials, textures, lights, etc.
10+
- **GPU TLAS**: Two-level acceleration structure (BLAS/TLAS) with instanced geometry, per-instance transforms, and GPU-first design
911
- **Analysis tools**: centroid calculation, illumination analysis, view factors for radiosity
1012
- **Makie integration** for visualization
1113

src/Raycore.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ include("kernel-abstractions.jl")
4848
include("kernels.jl")
4949
include("ray_intersection_session.jl")
5050
include("soa.jl")
51-
include("heterovec.jl")
51+
include("multitypeset.jl")
5252
include("unrolled.jl")
5353

5454
# Macros
@@ -61,9 +61,9 @@ export Ray, RayDifferentials, Triangle, TriangleMesh, AccelPrimitive, BVH, Bound
6161
export BLAS, TLAS, InstanceDescriptor, BVHNode2, build_blas, build_tlas, INVALID_NODE
6262
export Instance, n_instances, n_geometries, build_triangle, is_degenerate_face
6363

64-
# TLASBuilder (new MultiTypeSet-style API)
65-
export TLASBuilder, TLASHandle, StaticTLAS, INVALID_HANDLE
66-
export sync!, update_instance!, update!, n_total_instances
64+
# TLAS (GPU two-level acceleration structure)
65+
export TLASHandle, StaticTLAS, INVALID_HANDLE
66+
export sync!, update!, n_total_instances
6767

6868
# BVH4 types (HIPRT-style 4-wide nodes)
6969
export BVHNode4, BLAS4, TLAS4, build_blas4, closest_hit4, any_hit4
@@ -86,7 +86,7 @@ export @get, @set, similar_soa
8686
# GPU-safe unrolled iteration
8787
export FastClosure, for_unrolled, map_unrolled, reduce_unrolled, sum_unrolled, getindex_unrolled
8888

89-
# HeterogeneousVector for type-stable heterogeneous collections
89+
# MultiTypeSet - type-stable heterogeneous collections
9090
export SetKey, MultiTypeSet, StaticMultiTypeSet, TextureRef
9191
export is_invalid, is_valid, with_index, n_slots, deref, get_static, to_tuple
9292
export maybe_convert_field, store_texture, rebuild_static!

src/instanced-bvh.jl

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,7 @@ mutable struct TLAS{Backend}
203203
next_instance_id::UInt32
204204
end
205205

206-
# Legacy alias for compatibility
207-
const TLASBuilder = TLAS
208-
209-
# Note: _get_isbits_ptr is defined in heterovec.jl and reused here
206+
# Note: _get_isbits_ptr is defined in multitypeset.jl and reused here
210207

211208
# ==============================================================================
212209
# Instance - High-level wrapper for instanced geometry
@@ -2051,29 +2048,6 @@ end
20512048
# Use TLAS(meshes, metadata_fn) for per-triangle metadata, or
20522049
# TLAS([Instance(mesh1), Instance(mesh2), ...]) for the new Instance API.
20532050

2054-
# Make closest_hit and any_hit work with both argument orders for compatibility
2055-
"""
2056-
closest_hit(ray::AbstractRay, tlas::TLAS)
2057-
2058-
BVH-compatible argument order for closest_hit.
2059-
Returns (hit_found, triangle, distance, barycentric) - same as BVH.
2060-
"""
2061-
function closest_hit(ray::AbstractRay, tlas::TraversableTLAS)
2062-
hit, tri, t, bary, inst_id = closest_hit(tlas, ray)
2063-
return (hit, tri, t, bary)
2064-
end
2065-
2066-
"""
2067-
any_hit(ray::AbstractRay, tlas::TLAS)
2068-
2069-
BVH-compatible argument order for any_hit.
2070-
Returns (hit_found, triangle, distance, barycentric) - same as BVH.
2071-
"""
2072-
function any_hit(ray::AbstractRay, tlas::TraversableTLAS)
2073-
hit, tri, t, bary, inst_id = any_hit(tlas, ray)
2074-
return (hit, tri, t, bary)
2075-
end
2076-
20772051
"""
20782052
Base.eltype(tlas::TraversableTLAS)
20792053

src/heterovec.jl renamed to src/multitypeset.jl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ============================================================================
2-
# HeterogeneousVector - Type-stable heterogeneous collections for GPU
2+
# MultiTypeSet - Type-stable heterogeneous collections for GPU
33
# ============================================================================
44
# Provides compile-time type-stable dispatch over collections of different types.
55
# Used for materials, textures, media, lights, etc.
@@ -61,11 +61,8 @@ n_slots(smv::StaticMultiTypeSet) = length(smv.data)
6161

6262
# Get the static version - identity for StaticMultiTypeSet, .static field for MultiTypeSet
6363
get_static(smv::StaticMultiTypeSet) = smv
64-
# Fallback for Tuple (used by legacy code paths)
65-
get_static(t::Tuple) = t
6664

6765
# Convert to a flat Tuple of all elements (preserves concrete element types)
68-
to_tuple(t::Tuple) = t
6966
_concat_to_tuple() = ()
7067
_concat_to_tuple(v::AbstractVector, rest...) = (v..., _concat_to_tuple(rest...)...)
7168
to_tuple(smv::StaticMultiTypeSet) = _concat_to_tuple(smv.data...)
@@ -181,10 +178,10 @@ end
181178
# Dummy kernel for argconvert (same pattern as kernel-abstractions.jl)
182179
# ============================================================================
183180

184-
KA.@kernel _heterovec_dummy_kernel() = nothing
181+
KA.@kernel _multitypeset_dummy_kernel() = nothing
185182

186183
function _get_isbits_ptr(backend, gpu_arr)
187-
kernel = _heterovec_dummy_kernel(backend)
184+
kernel = _multitypeset_dummy_kernel(backend)
188185
return KA.argconvert(kernel, gpu_arr)
189186
end
190187

test/runtests.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@ Aqua.test_all(Raycore; ambiguities=(; broken=true))
1414
include("test_intersection.jl")
1515
end
1616
@testset "Type Stability" begin
17-
# include("test_type_stability.jl")
17+
# include("test_type_stability.jl") # disabled: @allocated tests fail on Julia 1.12
1818
end
1919
@testset "Bounds" begin
2020
include("bounds.jl")
2121
end
2222
@testset "Instanced BVH" begin
2323
include("test_instanced_bvh.jl")
2424
end
25-
@testset "HeteroVec" begin
26-
include("test_heterovec.jl")
25+
@testset "MultiTypeSet" begin
26+
include("test_multitypeset.jl")
27+
end
28+
@testset "Unrolled" begin
29+
# include("test_unrolled.jl") # requires BenchmarkTools (not in test deps)
2730
end
2831
end

test/test_instanced_bvh.jl

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -403,34 +403,6 @@ end
403403
@test hit_miss == false
404404
end
405405

406-
@testset "TLAS BVH-compatible API (argument order)" begin
407-
# Test that closest_hit(ray, tlas) works (BVH-compatible order)
408-
v1, v2, v3 = Point3f(0, 0, 0), Point3f(1, 0, 0), Point3f(0, 1, 0)
409-
tri = RTriangle(
410-
SVector(v1, v2, v3),
411-
SVector(Normal3f(0, 0, 1), Normal3f(0, 0, 1), Normal3f(0, 0, 1)),
412-
SVector(Vec3f(0), Vec3f(0), Vec3f(0)),
413-
SVector(Point2f(0, 0), Point2f(1, 0), Point2f(0, 1)),
414-
UInt32(1)
415-
)
416-
417-
blas = build_blas([tri])
418-
identity = Mat4f(I)
419-
instances = [InstanceDescriptor(UInt32(1), UInt32(1), identity, identity, UInt32(0))]
420-
tlas = build_tlas([blas], instances)
421-
422-
ray = Ray(o=Point3f(0.25, 0.25, 1.0), d=Vec3f(0, 0, -1))
423-
424-
# BVH-compatible order (ray first)
425-
hit, prim, dist, bary = closest_hit(ray, tlas)
426-
@test hit == true
427-
@test dist 1.0f0
428-
429-
# any_hit with BVH-compatible order
430-
hit_any, _, _, _ = any_hit(ray, tlas)
431-
@test hit_any == true
432-
end
433-
434406
# ==============================================================================
435407
# Instance API Tests
436408
# ==============================================================================

0 commit comments

Comments
 (0)