From 1da221659de6bbdc51e496a0848fac8baaf9851c Mon Sep 17 00:00:00 2001 From: Patrick Mours Date: Tue, 29 Oct 2024 11:29:22 +0100 Subject: [PATCH] Fix #129251: Broken OptiX denoiser output Looks like some recent changes in the driver broke an assumption the OptiX denoiser code in Cycles made about being able to set it up with a different input size than later used to invoke it, which caused broken output on older GPU architectures. This commit fixes that by ensuring the input image size passed to `optixDenoiserSetup` matches that passed to `optixDenoiserInvoke`, even when no tiling is used (which is the common case). Pull Request: https://projects.blender.org/blender/blender/pulls/129398 --- intern/cycles/integrator/denoiser_optix.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/intern/cycles/integrator/denoiser_optix.cpp b/intern/cycles/integrator/denoiser_optix.cpp index 04692a59767..80184c839b3 100644 --- a/intern/cycles/integrator/denoiser_optix.cpp +++ b/intern/cycles/integrator/denoiser_optix.cpp @@ -297,6 +297,9 @@ bool OptiXDenoiser::denoise_configure_if_needed(DenoiseContext &context) denoiser_device_, optixDenoiserComputeMemoryResources(optix_denoiser_, tile_size.x, tile_size.y, &sizes_)); + const bool tiled = tile_size.x < context.buffer_params.width || + tile_size.y < context.buffer_params.height; + /* Allocate denoiser state if tile size has changed since last setup. */ state_.device = denoiser_device_; state_.alloc_to_device(sizes_.stateSizeInBytes + sizes_.withOverlapScratchSizeInBytes); @@ -306,8 +309,8 @@ bool OptiXDenoiser::denoise_configure_if_needed(DenoiseContext &context) optix_denoiser_, 0, /* Work around bug in r495 drivers that causes artifacts when denoiser setup is called * on a stream that is not the default stream. */ - tile_size.x + sizes_.overlapWindowSizeInPixels * 2, - tile_size.y + sizes_.overlapWindowSizeInPixels * 2, + tile_size.x + (tiled ? sizes_.overlapWindowSizeInPixels * 2 : 0), + tile_size.y + (tiled ? sizes_.overlapWindowSizeInPixels * 2 : 0), state_.device_pointer, sizes_.stateSizeInBytes, state_.device_pointer + sizes_.stateSizeInBytes,