@@ -226,12 +226,18 @@ impl FsrContext {
226226 /// The returned [`FsrView`] holds all textures and temporal accumulation
227227 /// state. Multiple views can be created from the same context for
228228 /// multi-camera or split-screen rendering.
229+ ///
230+ /// # Panics
231+ ///
232+ /// Panics if any dimension of `max_render_size` is less than 2, or any
233+ /// dimension of `max_upscale_size` is 0.
229234 pub fn create_view (
230235 & self ,
231236 queue : & wgpu:: Queue ,
232237 max_render_size : [ u32 ; 2 ] ,
233238 max_upscale_size : [ u32 ; 2 ] ,
234239 ) -> FsrView {
240+ FsrView :: validate_sizes ( max_render_size, max_upscale_size) ;
235241 FsrView :: new (
236242 self . device . clone ( ) ,
237243 queue,
@@ -657,6 +663,22 @@ impl FsrContext {
657663}
658664
659665impl FsrView {
666+ fn validate_sizes ( max_render_size : [ u32 ; 2 ] , max_upscale_size : [ u32 ; 2 ] ) {
667+ assert ! (
668+ max_render_size[ 0 ] >= 2 && max_render_size[ 1 ] >= 2 ,
669+ "max_render_size must be at least [2, 2], got [{}, {}] \
670+ (internal half-resolution textures require dimensions >= 1)",
671+ max_render_size[ 0 ] ,
672+ max_render_size[ 1 ] ,
673+ ) ;
674+ assert ! (
675+ max_upscale_size[ 0 ] >= 1 && max_upscale_size[ 1 ] >= 1 ,
676+ "max_upscale_size must be at least [1, 1], got [{}, {}]" ,
677+ max_upscale_size[ 0 ] ,
678+ max_upscale_size[ 1 ] ,
679+ ) ;
680+ }
681+
660682 fn new (
661683 device : wgpu:: Device ,
662684 queue : & wgpu:: Queue ,
@@ -698,12 +720,18 @@ impl FsrView {
698720 ///
699721 /// Resets all temporal history — the next dispatch will behave as the
700722 /// first frame.
723+ ///
724+ /// # Panics
725+ ///
726+ /// Panics if any dimension of `max_render_size` is less than 2, or any
727+ /// dimension of `max_upscale_size` is 0.
701728 pub fn resize (
702729 & mut self ,
703730 queue : & wgpu:: Queue ,
704731 max_render_size : [ u32 ; 2 ] ,
705732 max_upscale_size : [ u32 ; 2 ] ,
706733 ) {
734+ Self :: validate_sizes ( max_render_size, max_upscale_size) ;
707735 self . resources =
708736 resources:: FsrResources :: new ( & self . device , queue, max_render_size, max_upscale_size) ;
709737 self . max_render_size = max_render_size;
0 commit comments