mirror of
https://github.com/w23/xash3d-fwgs
synced 2024-12-14 21:20:26 +01:00
46 lines
1.5 KiB
C
46 lines
1.5 KiB
C
#pragma once
|
|
|
|
#include "vk_core.h"
|
|
#include "vk_buffer.h"
|
|
|
|
struct rt_vk_ray_accel_s {
|
|
// Stores AS built data. Lifetime similar to render buffer:
|
|
// - some portion lives for entire map lifetime
|
|
// - some portion lives only for a single frame (may have several frames in flight)
|
|
// TODO: unify this with render buffer
|
|
// Needs: AS_STORAGE_BIT, SHADER_DEVICE_ADDRESS_BIT
|
|
vk_buffer_t accels_buffer;
|
|
struct alo_pool_s *accels_buffer_alloc;
|
|
|
|
// Temp: lives only during a single frame (may have many in flight)
|
|
// Used for building ASes;
|
|
// Needs: AS_STORAGE_BIT, SHADER_DEVICE_ADDRESS_BIT
|
|
vk_buffer_t scratch_buffer;
|
|
VkDeviceAddress accels_buffer_addr, scratch_buffer_addr;
|
|
|
|
// Temp-ish: used for making TLAS, contains addressed to all used BLASes
|
|
// Lifetime and nature of usage similar to scratch_buffer
|
|
// TODO: unify them
|
|
// Needs: SHADER_DEVICE_ADDRESS, STORAGE_BUFFER, AS_BUILD_INPUT_READ_ONLY
|
|
vk_buffer_t tlas_geom_buffer;
|
|
VkDeviceAddress tlas_geom_buffer_addr;
|
|
r_flipping_buffer_t tlas_geom_buffer_alloc;
|
|
|
|
// TODO need several TLASes for N frames in flight
|
|
VkAccelerationStructureKHR tlas;
|
|
|
|
// Per-frame data that is accumulated between RayFrameBegin and End calls
|
|
struct {
|
|
uint32_t scratch_offset; // for building dynamic blases
|
|
} frame;
|
|
};
|
|
|
|
extern struct rt_vk_ray_accel_s g_accel;
|
|
|
|
qboolean RT_VkAccelInit(void);
|
|
void RT_VkAccelShutdown(void);
|
|
void RT_VkAccelNewMap(void);
|
|
void RT_VkAccelFrameBegin(void);
|
|
struct vk_combuf_s;
|
|
void RT_VkAccelPrepareTlas(struct vk_combuf_s *combuf);
|