MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / invoke

Method invoke

crates/optix/src/denoiser.rs:259–404  ·  view source on GitHub ↗
(
        &self,
        stream: &Stream,
        guide_images: DenoiserGuideImages,
        input_image: Image,
        parameters: DenoiserParams,
        out_buffer: &mut impl GpuBuffer<T>,
    )

Source from the content-addressed store, hash-verified

257 /// - `input_image` was larger than the dimensions specified in [`setup_state`].
258 #[track_caller]
259 pub fn invoke<T: DeviceCopy>(
260 &self,
261 stream: &Stream,
262 guide_images: DenoiserGuideImages,
263 input_image: Image,
264 parameters: DenoiserParams,
265 out_buffer: &mut impl GpuBuffer<T>,
266 ) -> Result<()> {
267 let state_lock = self.state.lock().unwrap();
268 let state = state_lock.as_ref().expect(
269 "State was not initialized before invoking the denoiser, call Denoiser::setup_state first"
270 );
271 let state_width = state.width;
272 let state_height = state.height;
273
274 assert!(
275 state_width >= input_image.width,
276 "State was created with an image width of {} but the input image had a width of {}",
277 state_width,
278 input_image.width
279 );
280
281 assert!(
282 state_height >= input_image.height,
283 "State was created with an image height of {} but the input image had a height of {}",
284 state_height,
285 input_image.height
286 );
287
288 assert_ne!(
289 self.kind,
290 DenoiserModelKind::Aov,
291 "Use Denoiser::invoke_aov for AOV models, not invoke"
292 );
293
294 let input_bytes = input_image.bytes_used();
295 let buf_len_bytes = out_buffer.len() * std::mem::size_of::<T>();
296 assert!(
297 buf_len_bytes >= input_bytes as usize,
298 "Denoiser out_buffer not large enough, expected at least {} bytes, but found {}",
299 input_bytes,
300 buf_len_bytes
301 );
302
303 if self.options.guide_albedo {
304 assert!(
305 guide_images.albedo.is_some(),
306 "Denoiser was created with guide_albedo but a guide image was not provided during invocation"
307 );
308 }
309
310 if self.options.guide_normal {
311 assert!(
312 guide_images.normal.is_some(),
313 "Denoiser was created with guide_normal but a guide image was not provided during invocation"
314 );
315 }
316

Callers 2

mainFunction · 0.45
final_imageMethod · 0.45

Calls 9

null_optix_imageFunction · 0.85
bytes_usedMethod · 0.80
expectMethod · 0.45
as_refMethod · 0.45
lenMethod · 0.45
to_rawMethod · 0.45
cloneMethod · 0.45
as_rawMethod · 0.45
as_device_ptrMethod · 0.45

Tested by

no test coverage detected