VoxelCache refactor
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
RWStructuredBuffer<uint32_t> count_buffer;
|
||||
[[vk::binding(1, 0)]]
|
||||
RWStructuredBuffer<uint32_t> index_buffer;
|
||||
[[vk::binding(2, 0)]]
|
||||
RWStructuredBuffer<uint32_t> compacted_buffer;
|
||||
|
||||
[[vk::push_constant]]
|
||||
uniform uint32_t write_compact;
|
||||
|
||||
[[vk::binding(0, 1)]]
|
||||
RWStructuredBuffer<uint32_t> reduced_buffer;
|
||||
@@ -157,5 +162,18 @@ void scatter(
|
||||
{
|
||||
index_buffer[sum2] = thread_index * 2 + 1;
|
||||
}
|
||||
|
||||
if (write_compact != 0)
|
||||
{
|
||||
if (count_buffer[thread_index * 2] != 0 && sum1 < total)
|
||||
{
|
||||
compacted_buffer[sum1] = count_buffer[thread_index * 2];
|
||||
}
|
||||
|
||||
if (count_buffer[thread_index * 2 + 1] != 0 && sum2 < total)
|
||||
{
|
||||
compacted_buffer[sum2] = count_buffer[thread_index * 2 + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
+3
-6
@@ -82,14 +82,12 @@ RWStructuredBuffer<StructurePoolElement> structure_pool;
|
||||
[[vk::binding(1, 0)]]
|
||||
RWStructuredBuffer<uint32_t> attributes_pool[2];
|
||||
[[vk::binding(2, 0)]]
|
||||
RWStructuredBuffer<LocationPoolElement> location_pool;
|
||||
[[vk::binding(3, 0)]]
|
||||
RWStructuredBuffer<RequestBufferElement> request_buffer;
|
||||
[[vk::binding(4, 0)]]
|
||||
[[vk::binding(3, 0)]]
|
||||
RWStructuredBuffer<uint32_t> usage_buffer;
|
||||
[[vk::binding(5, 0)]]
|
||||
[[vk::binding(4, 0)]]
|
||||
RWStructuredBuffer<StructurePointer> structure_table_pointer;
|
||||
[[vk::binding(6, 0)]]
|
||||
[[vk::binding(5, 0)]]
|
||||
RWStructuredBuffer<Atomic<uint32_t>> structure_table_request_buffer;
|
||||
|
||||
ByteColor fetch_color(uint32_t index, uint32_t child_index)
|
||||
@@ -172,7 +170,6 @@ void gi(uint32_t3 location: SV_DispatchThreadID, uint32_t3 local_location: SV_Gr
|
||||
var voxel_cache : VoxelCache;
|
||||
voxel_cache.structure_pool = structure_pool;
|
||||
voxel_cache.attributes_pool = attributes_pool;
|
||||
voxel_cache.location_pool = location_pool;
|
||||
voxel_cache.request_buffer = request_buffer;
|
||||
voxel_cache.usage_buffer = usage_buffer;
|
||||
voxel_cache.structure_table_pointer = structure_table_pointer;
|
||||
|
||||
@@ -81,17 +81,10 @@ public struct RequestBufferElement
|
||||
public Atomic<uint32_t> requests[64];
|
||||
}
|
||||
|
||||
public struct LocationPoolElement
|
||||
{
|
||||
public uint32_t structure_id;
|
||||
public uint32_t structure_locator;
|
||||
}
|
||||
|
||||
public struct VoxelCache
|
||||
{
|
||||
public RWStructuredBuffer<StructurePoolElement> structure_pool;
|
||||
public RWStructuredBuffer<uint32_t> attributes_pool[2];
|
||||
public RWStructuredBuffer<LocationPoolElement> location_pool;
|
||||
public RWStructuredBuffer<RequestBufferElement> request_buffer;
|
||||
public RWStructuredBuffer<uint32_t> usage_buffer;
|
||||
public RWStructuredBuffer<StructurePointer> structure_table_pointer;
|
||||
@@ -356,7 +349,7 @@ public HitInformation ray_cast(
|
||||
context.ray_direction,
|
||||
position - float3(current_voxel),
|
||||
chunk_index,
|
||||
t_adv,
|
||||
max(t_adv, 0.01),
|
||||
stack_index,
|
||||
context.frame_timestamp,
|
||||
context.cache_report);
|
||||
|
||||
+4
-6
@@ -82,14 +82,12 @@ RWStructuredBuffer<StructurePoolElement> structure_pool;
|
||||
[[vk::binding(1, 0)]]
|
||||
RWStructuredBuffer<uint32_t> attributes_pool[2];
|
||||
[[vk::binding(2, 0)]]
|
||||
RWStructuredBuffer<LocationPoolElement> location_pool;
|
||||
[[vk::binding(3, 0)]]
|
||||
RWStructuredBuffer<RequestBufferElement> request_buffer;
|
||||
[[vk::binding(4, 0)]]
|
||||
[[vk::binding(3, 0)]]
|
||||
RWStructuredBuffer<uint32_t> usage_buffer;
|
||||
[[vk::binding(5, 0)]]
|
||||
[[vk::binding(4, 0)]]
|
||||
RWStructuredBuffer<StructurePointer> structure_table_pointer;
|
||||
[[vk::binding(6, 0)]]
|
||||
[[vk::binding(5, 0)]]
|
||||
RWStructuredBuffer<Atomic<uint32_t>> structure_table_request_buffer;
|
||||
|
||||
ByteColor fetch_color(uint32_t index, uint32_t child_index)
|
||||
@@ -156,7 +154,6 @@ void ray_march_compute(uint32_t3 location: SV_DispatchThreadID, uint32_t3 local_
|
||||
var voxel_cache : VoxelCache;
|
||||
voxel_cache.structure_pool = structure_pool;
|
||||
voxel_cache.attributes_pool = attributes_pool;
|
||||
voxel_cache.location_pool = location_pool;
|
||||
voxel_cache.request_buffer = request_buffer;
|
||||
voxel_cache.usage_buffer = usage_buffer;
|
||||
voxel_cache.structure_table_pointer = structure_table_pointer;
|
||||
@@ -179,6 +176,7 @@ void ray_march_compute(uint32_t3 location: SV_DispatchThreadID, uint32_t3 local_
|
||||
let hit_pos = hit.hit_pos;
|
||||
let hit_normal = fetch_normal(hit.node_index, hit.child_index);
|
||||
let hit_albedo = fetch_color(hit.node_index, hit.child_index).float_color;
|
||||
// let hit_albedo = hit.color;
|
||||
|
||||
gbuffer_position.Store(location.xy, float4(hit_pos, 1.));
|
||||
gbuffer_normal.Store(location.xy, float4(hit_normal, 1.));
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user