330330< a href =#330 id =330 data-nosnippet > 330</ a > })
331331< a href =#331 id =331 data-nosnippet > 331</ a > }
332332< a href =#332 id =332 data-nosnippet > 332</ a >
333- < a href =#333 id =333 data-nosnippet > 333</ a > < span class ="doccomment "> /// # Safety
333+ < a href =#333 id =333 data-nosnippet > 333</ a > < span class ="doccomment "> /// Encode commands using the raw HAL command encoder.
334334< a href =#334 id =334 data-nosnippet > 334</ a > ///
335- < a href =#335 id =335 data-nosnippet > 335</ a > /// - The raw command encoder handle must not be manually destroyed
336- < a href =#336 id =336 data-nosnippet > 336</ a > </ span > < span class ="kw "> pub unsafe fn </ span > command_encoder_as_hal_mut<
337- < a href =#337 id =337 data-nosnippet > 337</ a > A: hal::Api,
338- < a href =#338 id =338 data-nosnippet > 338</ a > F: FnOnce(< span class ="prelude-ty "> Option</ span > << span class ="kw-2 "> &mut </ span > A::CommandEncoder>) -> R,
339- < a href =#339 id =339 data-nosnippet > 339</ a > R,
340- < a href =#340 id =340 data-nosnippet > 340</ a > >(
341- < a href =#341 id =341 data-nosnippet > 341</ a > < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > ,
342- < a href =#342 id =342 data-nosnippet > 342</ a > id: CommandEncoderId,
343- < a href =#343 id =343 data-nosnippet > 343</ a > hal_command_encoder_callback: F,
344- < a href =#344 id =344 data-nosnippet > 344</ a > ) -> R {
345- < a href =#345 id =345 data-nosnippet > 345</ a > < span class ="macro "> profiling::scope!</ span > (< span class ="string "> "CommandEncoder::as_hal"</ span > );
346- < a href =#346 id =346 data-nosnippet > 346</ a >
347- < a href =#347 id =347 data-nosnippet > 347</ a > < span class ="kw "> let </ span > hub = < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > .hub;
348- < a href =#348 id =348 data-nosnippet > 348</ a >
349- < a href =#349 id =349 data-nosnippet > 349</ a > < span class ="kw "> let </ span > cmd_enc = hub.command_encoders.get(id);
350- < a href =#350 id =350 data-nosnippet > 350</ a > < span class ="kw "> let </ span > < span class ="kw-2 "> mut </ span > cmd_buf_data = cmd_enc.data.lock();
351- < a href =#351 id =351 data-nosnippet > 351</ a > cmd_buf_data.record_as_hal_mut(|opt_cmd_buf| -> R {
352- < a href =#352 id =352 data-nosnippet > 352</ a > hal_command_encoder_callback(opt_cmd_buf.and_then(|cmd_buf| {
353- < a href =#353 id =353 data-nosnippet > 353</ a > cmd_buf
354- < a href =#354 id =354 data-nosnippet > 354</ a > .encoder
355- < a href =#355 id =355 data-nosnippet > 355</ a > .open()
356- < a href =#356 id =356 data-nosnippet > 356</ a > .ok()
357- < a href =#357 id =357 data-nosnippet > 357</ a > .and_then(|encoder| encoder.as_any_mut().downcast_mut())
358- < a href =#358 id =358 data-nosnippet > 358</ a > }))
359- < a href =#359 id =359 data-nosnippet > 359</ a > })
360- < a href =#360 id =360 data-nosnippet > 360</ a > }
361- < a href =#361 id =361 data-nosnippet > 361</ a >
362- < a href =#362 id =362 data-nosnippet > 362</ a > < span class ="doccomment "> /// # Safety
363- < a href =#363 id =363 data-nosnippet > 363</ a > ///
364- < a href =#364 id =364 data-nosnippet > 364</ a > /// - The raw queue handle must not be manually destroyed
365- < a href =#365 id =365 data-nosnippet > 365</ a > </ span > < span class ="kw "> pub unsafe fn </ span > queue_as_hal<A: hal::Api>(
366- < a href =#366 id =366 data-nosnippet > 366</ a > < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > ,
367- < a href =#367 id =367 data-nosnippet > 367</ a > id: QueueId,
368- < a href =#368 id =368 data-nosnippet > 368</ a > ) -> < span class ="prelude-ty "> Option</ span > << span class ="kw "> impl </ span > Deref<Target = A::Queue>> {
369- < a href =#369 id =369 data-nosnippet > 369</ a > < span class ="macro "> profiling::scope!</ span > (< span class ="string "> "Queue::as_hal"</ span > );
370- < a href =#370 id =370 data-nosnippet > 370</ a >
371- < a href =#371 id =371 data-nosnippet > 371</ a > < span class ="kw "> let </ span > queue = < span class ="self "> self</ span > .hub.queues.get(id);
372- < a href =#372 id =372 data-nosnippet > 372</ a >
373- < a href =#373 id =373 data-nosnippet > 373</ a > SimpleResourceGuard::new(queue, < span class ="kw "> move </ span > |queue| queue.raw().as_any().downcast_ref())
374- < a href =#374 id =374 data-nosnippet > 374</ a > }
375- < a href =#375 id =375 data-nosnippet > 375</ a >
376- < a href =#376 id =376 data-nosnippet > 376</ a > < span class ="doccomment "> /// # Safety
377- < a href =#377 id =377 data-nosnippet > 377</ a > ///
378- < a href =#378 id =378 data-nosnippet > 378</ a > /// - The raw blas handle must not be manually destroyed
379- < a href =#379 id =379 data-nosnippet > 379</ a > </ span > < span class ="kw "> pub unsafe fn </ span > blas_as_hal<A: hal::Api>(
380- < a href =#380 id =380 data-nosnippet > 380</ a > < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > ,
381- < a href =#381 id =381 data-nosnippet > 381</ a > id: BlasId,
382- < a href =#382 id =382 data-nosnippet > 382</ a > ) -> < span class ="prelude-ty "> Option</ span > << span class ="kw "> impl </ span > Deref<Target = A::AccelerationStructure>> {
383- < a href =#383 id =383 data-nosnippet > 383</ a > < span class ="macro "> profiling::scope!</ span > (< span class ="string "> "Blas::as_hal"</ span > );
384- < a href =#384 id =384 data-nosnippet > 384</ a >
385- < a href =#385 id =385 data-nosnippet > 385</ a > < span class ="kw "> let </ span > hub = < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > .hub;
386- < a href =#386 id =386 data-nosnippet > 386</ a >
387- < a href =#387 id =387 data-nosnippet > 387</ a > < span class ="kw "> let </ span > blas = hub.blas_s.get(id).get().ok()< span class ="question-mark "> ?</ span > ;
388- < a href =#388 id =388 data-nosnippet > 388</ a >
389- < a href =#389 id =389 data-nosnippet > 389</ a > SnatchableResourceGuard::new(blas)
390- < a href =#390 id =390 data-nosnippet > 390</ a > }
391- < a href =#391 id =391 data-nosnippet > 391</ a >
392- < a href =#392 id =392 data-nosnippet > 392</ a > < span class ="doccomment "> /// # Safety
393- < a href =#393 id =393 data-nosnippet > 393</ a > ///
394- < a href =#394 id =394 data-nosnippet > 394</ a > /// - The raw tlas handle must not be manually destroyed
395- < a href =#395 id =395 data-nosnippet > 395</ a > </ span > < span class ="kw "> pub unsafe fn </ span > tlas_as_hal<A: hal::Api>(
396- < a href =#396 id =396 data-nosnippet > 396</ a > < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > ,
397- < a href =#397 id =397 data-nosnippet > 397</ a > id: TlasId,
398- < a href =#398 id =398 data-nosnippet > 398</ a > ) -> < span class ="prelude-ty "> Option</ span > << span class ="kw "> impl </ span > Deref<Target = A::AccelerationStructure>> {
399- < a href =#399 id =399 data-nosnippet > 399</ a > < span class ="macro "> profiling::scope!</ span > (< span class ="string "> "Tlas::as_hal"</ span > );
400- < a href =#400 id =400 data-nosnippet > 400</ a >
401- < a href =#401 id =401 data-nosnippet > 401</ a > < span class ="kw "> let </ span > hub = < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > .hub;
402- < a href =#402 id =402 data-nosnippet > 402</ a >
403- < a href =#403 id =403 data-nosnippet > 403</ a > < span class ="kw "> let </ span > tlas = hub.tlas_s.get(id).get().ok()< span class ="question-mark "> ?</ span > ;
404- < a href =#404 id =404 data-nosnippet > 404</ a >
405- < a href =#405 id =405 data-nosnippet > 405</ a > SnatchableResourceGuard::new(tlas)
406- < a href =#406 id =406 data-nosnippet > 406</ a > }
407- < a href =#407 id =407 data-nosnippet > 407</ a > }</ code > </ pre > </ div > </ section > </ main > </ body > </ html >
335+ < a href =#335 id =335 data-nosnippet > 335</ a > /// # Panics
336+ < a href =#336 id =336 data-nosnippet > 336</ a > ///
337+ < a href =#337 id =337 data-nosnippet > 337</ a > /// If the command encoder has already been used with the wgpu encoding API.
338+ < a href =#338 id =338 data-nosnippet > 338</ a > ///
339+ < a href =#339 id =339 data-nosnippet > 339</ a > /// # Safety
340+ < a href =#340 id =340 data-nosnippet > 340</ a > ///
341+ < a href =#341 id =341 data-nosnippet > 341</ a > /// - The raw command encoder handle must not be manually destroyed
342+ < a href =#342 id =342 data-nosnippet > 342</ a > </ span > < span class ="kw "> pub unsafe fn </ span > command_encoder_as_hal_mut<
343+ < a href =#343 id =343 data-nosnippet > 343</ a > A: hal::Api,
344+ < a href =#344 id =344 data-nosnippet > 344</ a > F: FnOnce(< span class ="prelude-ty "> Option</ span > << span class ="kw-2 "> &mut </ span > A::CommandEncoder>) -> R,
345+ < a href =#345 id =345 data-nosnippet > 345</ a > R,
346+ < a href =#346 id =346 data-nosnippet > 346</ a > >(
347+ < a href =#347 id =347 data-nosnippet > 347</ a > < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > ,
348+ < a href =#348 id =348 data-nosnippet > 348</ a > id: CommandEncoderId,
349+ < a href =#349 id =349 data-nosnippet > 349</ a > hal_command_encoder_callback: F,
350+ < a href =#350 id =350 data-nosnippet > 350</ a > ) -> R {
351+ < a href =#351 id =351 data-nosnippet > 351</ a > < span class ="macro "> profiling::scope!</ span > (< span class ="string "> "CommandEncoder::as_hal"</ span > );
352+ < a href =#352 id =352 data-nosnippet > 352</ a >
353+ < a href =#353 id =353 data-nosnippet > 353</ a > < span class ="kw "> let </ span > hub = < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > .hub;
354+ < a href =#354 id =354 data-nosnippet > 354</ a >
355+ < a href =#355 id =355 data-nosnippet > 355</ a > < span class ="kw "> let </ span > cmd_enc = hub.command_encoders.get(id);
356+ < a href =#356 id =356 data-nosnippet > 356</ a > < span class ="kw "> let </ span > < span class ="kw-2 "> mut </ span > cmd_buf_data = cmd_enc.data.lock();
357+ < a href =#357 id =357 data-nosnippet > 357</ a > cmd_buf_data.record_as_hal_mut(|opt_cmd_buf| -> R {
358+ < a href =#358 id =358 data-nosnippet > 358</ a > hal_command_encoder_callback(opt_cmd_buf.and_then(|cmd_buf| {
359+ < a href =#359 id =359 data-nosnippet > 359</ a > cmd_buf
360+ < a href =#360 id =360 data-nosnippet > 360</ a > .encoder
361+ < a href =#361 id =361 data-nosnippet > 361</ a > .open()
362+ < a href =#362 id =362 data-nosnippet > 362</ a > .ok()
363+ < a href =#363 id =363 data-nosnippet > 363</ a > .and_then(|encoder| encoder.as_any_mut().downcast_mut())
364+ < a href =#364 id =364 data-nosnippet > 364</ a > }))
365+ < a href =#365 id =365 data-nosnippet > 365</ a > })
366+ < a href =#366 id =366 data-nosnippet > 366</ a > }
367+ < a href =#367 id =367 data-nosnippet > 367</ a >
368+ < a href =#368 id =368 data-nosnippet > 368</ a > < span class ="doccomment "> /// # Safety
369+ < a href =#369 id =369 data-nosnippet > 369</ a > ///
370+ < a href =#370 id =370 data-nosnippet > 370</ a > /// - The raw queue handle must not be manually destroyed
371+ < a href =#371 id =371 data-nosnippet > 371</ a > </ span > < span class ="kw "> pub unsafe fn </ span > queue_as_hal<A: hal::Api>(
372+ < a href =#372 id =372 data-nosnippet > 372</ a > < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > ,
373+ < a href =#373 id =373 data-nosnippet > 373</ a > id: QueueId,
374+ < a href =#374 id =374 data-nosnippet > 374</ a > ) -> < span class ="prelude-ty "> Option</ span > << span class ="kw "> impl </ span > Deref<Target = A::Queue>> {
375+ < a href =#375 id =375 data-nosnippet > 375</ a > < span class ="macro "> profiling::scope!</ span > (< span class ="string "> "Queue::as_hal"</ span > );
376+ < a href =#376 id =376 data-nosnippet > 376</ a >
377+ < a href =#377 id =377 data-nosnippet > 377</ a > < span class ="kw "> let </ span > queue = < span class ="self "> self</ span > .hub.queues.get(id);
378+ < a href =#378 id =378 data-nosnippet > 378</ a >
379+ < a href =#379 id =379 data-nosnippet > 379</ a > SimpleResourceGuard::new(queue, < span class ="kw "> move </ span > |queue| queue.raw().as_any().downcast_ref())
380+ < a href =#380 id =380 data-nosnippet > 380</ a > }
381+ < a href =#381 id =381 data-nosnippet > 381</ a >
382+ < a href =#382 id =382 data-nosnippet > 382</ a > < span class ="doccomment "> /// # Safety
383+ < a href =#383 id =383 data-nosnippet > 383</ a > ///
384+ < a href =#384 id =384 data-nosnippet > 384</ a > /// - The raw blas handle must not be manually destroyed
385+ < a href =#385 id =385 data-nosnippet > 385</ a > </ span > < span class ="kw "> pub unsafe fn </ span > blas_as_hal<A: hal::Api>(
386+ < a href =#386 id =386 data-nosnippet > 386</ a > < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > ,
387+ < a href =#387 id =387 data-nosnippet > 387</ a > id: BlasId,
388+ < a href =#388 id =388 data-nosnippet > 388</ a > ) -> < span class ="prelude-ty "> Option</ span > << span class ="kw "> impl </ span > Deref<Target = A::AccelerationStructure>> {
389+ < a href =#389 id =389 data-nosnippet > 389</ a > < span class ="macro "> profiling::scope!</ span > (< span class ="string "> "Blas::as_hal"</ span > );
390+ < a href =#390 id =390 data-nosnippet > 390</ a >
391+ < a href =#391 id =391 data-nosnippet > 391</ a > < span class ="kw "> let </ span > hub = < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > .hub;
392+ < a href =#392 id =392 data-nosnippet > 392</ a >
393+ < a href =#393 id =393 data-nosnippet > 393</ a > < span class ="kw "> let </ span > blas = hub.blas_s.get(id).get().ok()< span class ="question-mark "> ?</ span > ;
394+ < a href =#394 id =394 data-nosnippet > 394</ a >
395+ < a href =#395 id =395 data-nosnippet > 395</ a > SnatchableResourceGuard::new(blas)
396+ < a href =#396 id =396 data-nosnippet > 396</ a > }
397+ < a href =#397 id =397 data-nosnippet > 397</ a >
398+ < a href =#398 id =398 data-nosnippet > 398</ a > < span class ="doccomment "> /// # Safety
399+ < a href =#399 id =399 data-nosnippet > 399</ a > ///
400+ < a href =#400 id =400 data-nosnippet > 400</ a > /// - The raw tlas handle must not be manually destroyed
401+ < a href =#401 id =401 data-nosnippet > 401</ a > </ span > < span class ="kw "> pub unsafe fn </ span > tlas_as_hal<A: hal::Api>(
402+ < a href =#402 id =402 data-nosnippet > 402</ a > < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > ,
403+ < a href =#403 id =403 data-nosnippet > 403</ a > id: TlasId,
404+ < a href =#404 id =404 data-nosnippet > 404</ a > ) -> < span class ="prelude-ty "> Option</ span > << span class ="kw "> impl </ span > Deref<Target = A::AccelerationStructure>> {
405+ < a href =#405 id =405 data-nosnippet > 405</ a > < span class ="macro "> profiling::scope!</ span > (< span class ="string "> "Tlas::as_hal"</ span > );
406+ < a href =#406 id =406 data-nosnippet > 406</ a >
407+ < a href =#407 id =407 data-nosnippet > 407</ a > < span class ="kw "> let </ span > hub = < span class ="kw-2 "> &</ span > < span class ="self "> self</ span > .hub;
408+ < a href =#408 id =408 data-nosnippet > 408</ a >
409+ < a href =#409 id =409 data-nosnippet > 409</ a > < span class ="kw "> let </ span > tlas = hub.tlas_s.get(id).get().ok()< span class ="question-mark "> ?</ span > ;
410+ < a href =#410 id =410 data-nosnippet > 410</ a >
411+ < a href =#411 id =411 data-nosnippet > 411</ a > SnatchableResourceGuard::new(tlas)
412+ < a href =#412 id =412 data-nosnippet > 412</ a > }
413+ < a href =#413 id =413 data-nosnippet > 413</ a > }</ code > </ pre > </ div > </ section > </ main > </ body > </ html >
0 commit comments