Dumb slang...

This commit is contained in:
2026-11-09 19:48:48 +01:00
parent b6f4a9c432
commit 918eb97342
4 changed files with 11 additions and 9 deletions
Binary file not shown.
+1 -1
View File
@@ -155,7 +155,7 @@ void ray_march_compute(uint32_t3 location: SV_DispatchThreadID, uint32_t3 local_
Hit h;
Span s;
bool hit = tracer.trace(stacks[stack_index], h, r, s);
bool hit = tracer.trace(stack_index, h, r, s);
ToroidalStructureTableTracer.Cursor cursor = table_tracer.begin(r, s);
Cell cell;
+7 -4
View File
@@ -134,6 +134,9 @@ public interface IVoxelHit<let N : uint32_t>
public bool shouldHit(VoxelCacheParameters<N> parameters, uint32_t node_index, uint32_t child_index);
}
static const uint32_t WG_COUNT = 256;
groupshared uint32_t stack[5 * WG_COUNT];
public struct VoxelCacheTracer<let N : int, H : IVoxelHit<N>> : IVoxelCache
{
typedef VoxelTraceStack GroupSharedData;
@@ -144,7 +147,7 @@ public struct VoxelCacheTracer<let N : int, H : IVoxelHit<N>> : IVoxelCache
public H voxel_hit;
public VoxelCacheParameters<N> parameters;
public bool trace<L : ILodPolicy>(uint32_t root, inout VoxelTraceStack stack, Ray r, L lod, float offset_t, out Hit v)
public bool trace<L : ILodPolicy>(uint32_t root, uint32_t thread_id, Ray r, L lod, float offset_t, out Hit v)
{
// Ray mirroring
r.origin += float3(1.);
@@ -174,7 +177,7 @@ public struct VoxelCacheTracer<let N : int, H : IVoxelHit<N>> : IVoxelCache
{
this.parameters.usage_buffer[current_node_index] = this.frame_timestamp;
}
stack.stack[10 - scale_exp / 2] = current_node_index;
stack[thread_id + WG_COUNT * (10 - scale_exp / 2)] = current_node_index;
[loop]
for (uint32_t iter = 0; iter < 500; iter++)
@@ -186,7 +189,7 @@ public struct VoxelCacheTracer<let N : int, H : IVoxelHit<N>> : IVoxelCache
{
scale_exp -= 2;
current_node_index = current_node.pointer();
stack.stack[10 - scale_exp / 2] = current_node_index;
stack[thread_id + WG_COUNT * (10 - scale_exp / 2)] = current_node_index;
child_index = get_children_index(pos, scale_exp) ^ child_mirror;
current_node = this.parameters.structure_pool[current_node_index].pointers[child_index];
// Write usage
@@ -254,7 +257,7 @@ public struct VoxelCacheTracer<let N : int, H : IVoxelHit<N>> : IVoxelCache
}
scale_exp = 23 - common_depth;
current_node_index = stack.stack[10 - scale_exp / 2];
current_node_index = stack[thread_id + WG_COUNT * (10 - scale_exp / 2)];
}
v.hit = false;
+3 -4
View File
@@ -57,8 +57,7 @@ public interface IVoxelCache
{
// The voxel cache tracer needs to store a small stack.
// Keeping it in registers is wastefull thus using groupshared memory is the best option
associatedtype GroupSharedData;
public bool trace<L : ILodPolicy>(uint32_t root, inout GroupSharedData data, Ray r, L lod, float offset_t, out Hit v);
public bool trace<L : ILodPolicy>(uint32_t root, uint32_t thread_id, Ray r, L lod, float offset_t, out Hit v);
}
public struct Tracer<S : IStructure, C : IVoxelCache, L : ILodPolicy>
@@ -68,7 +67,7 @@ public struct Tracer<S : IStructure, C : IVoxelCache, L : ILodPolicy>
public C cache;
public L lod;
public bool trace(inout C.GroupSharedData gsData, out Hit h, Ray r, Span s)
public bool trace(uint32_t thread_id, out Hit h, Ray r, Span s)
{
/* loop: next cell -> cache.trace -> early out */
S.Cursor cursor = this.structure.begin(r, s);
@@ -81,7 +80,7 @@ public struct Tracer<S : IStructure, C : IVoxelCache, L : ILodPolicy>
while (this.structure.next(cursor, cell))
{
if (cache.trace(cell.cache_pointer, gsData, cell.local_ray, lod, cell.t, h))
if (cache.trace(cell.cache_pointer, thread_id, cell.local_ray, lod, cell.t, h))
{
return true;
}