From d1ad0d16f4557319e2bb69d7d576064d26ec3c37 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 18 Aug 2021 07:10:54 -0700 Subject: [PATCH] Fix crash with --wavefront integrator running on CPU. Issue #170. --- src/pbrt/wavefront/integrator.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pbrt/wavefront/integrator.cpp b/src/pbrt/wavefront/integrator.cpp index fc5780d..c378b11 100644 --- a/src/pbrt/wavefront/integrator.cpp +++ b/src/pbrt/wavefront/integrator.cpp @@ -234,10 +234,13 @@ WavefrontPathIntegrator::WavefrontPathIntegrator( // Allocate storage for all of the queues/buffers... #ifdef PBRT_BUILD_GPU_RENDERER - CUDATrackedMemoryResource *mr = - dynamic_cast(memoryResource); - CHECK(mr); - size_t startSize = mr->BytesAllocated(); + size_t startSize = 0; + if (Options->useGPU) { + CUDATrackedMemoryResource *mr = + dynamic_cast(memoryResource); + CHECK(mr); + startSize = mr->BytesAllocated(); + } #endif // PBRT_BUILD_GPU_RENDERER // Compute number of scanlines to render per pass @@ -292,8 +295,13 @@ WavefrontPathIntegrator::WavefrontPathIntegrator( stats = alloc.new_object(maxDepth, alloc); #ifdef PBRT_BUILD_GPU_RENDERER - size_t endSize = mr->BytesAllocated(); - pathIntegratorBytes += endSize - startSize; + if (Options->useGPU) { + CUDATrackedMemoryResource *mr = + dynamic_cast(memoryResource); + CHECK(mr); + size_t endSize = mr->BytesAllocated(); + pathIntegratorBytes += endSize - startSize; + } #endif // PBRT_BUILD_GPU_RENDERER } -- GitLab