Skip to content

Commit

Permalink
vk: rt: fix glitched dynamic geometry by actually tracking counts pro…
Browse files Browse the repository at this point in the history
…perly

We were always trying to build the same amount of geometries, although this count is dynamic.
  • Loading branch information
w23 committed Dec 10, 2024
1 parent 8794685 commit 2b5a02c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ref/vk/vk_ray_accel.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "vk_ray_internal.h"
#include "r_speeds.h"
#include "vk_combuf.h"
#include "vk_staging.h"
#include "vk_math.h"
#include "vk_geometry.h"
#include "vk_render.h"
Expand Down Expand Up @@ -560,6 +559,11 @@ void RT_VkAccelFrameBegin(void) {
}

static void blasFillGeometries(rt_blas_t *blas, const vk_render_geometry_t *geoms, int geoms_count) {
// geoms_count is not constant for dynamic models, and it shouldn't exceed max_geoms by design
ASSERT(geoms_count <= blas->max_geoms);

blas->build.info.geometryCount = geoms_count;

for (int i = 0; i < geoms_count; ++i) {
const vk_render_geometry_t *mg = geoms + i;
const uint32_t prim_count = mg->element_count / 3;
Expand Down Expand Up @@ -597,6 +601,7 @@ struct rt_blas_s* RT_BlasCreate(rt_blas_create_t args) {

blas->debug_name = args.name;
blas->usage = args.usage;
blas->max_geoms = args.geoms_count;

blas->build.info = (VkAccelerationStructureBuildGeometryInfoKHR){
.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR,
Expand Down

0 comments on commit 2b5a02c

Please sign in to comment.