@@ -3,9 +3,7 @@ use bevy_ecs::{prelude::*, query::QueryItem};
3
3
use bevy_render:: {
4
4
camera:: { CameraOutputMode , ClearColor , ClearColorConfig , ExtractedCamera } ,
5
5
render_graph:: { NodeRunError , RenderGraphContext , ViewNode } ,
6
- render_resource:: {
7
- BindGroup , BindGroupEntries , PipelineCache , RenderPassDescriptor , TextureViewId ,
8
- } ,
6
+ render_resource:: { BindGroup , PipelineCache , RenderPassDescriptor , TextureViewId } ,
9
7
renderer:: RenderContext ,
10
8
view:: ViewTarget ,
11
9
} ;
@@ -30,9 +28,9 @@ impl ViewNode for UpscalingNode {
30
28
( target, upscaling_target, camera) : QueryItem < Self :: ViewQuery > ,
31
29
world : & World ,
32
30
) -> Result < ( ) , NodeRunError > {
33
- let pipeline_cache = world. get_resource :: < PipelineCache > ( ) . unwrap ( ) ;
34
- let blit_pipeline = world. get_resource :: < BlitPipeline > ( ) . unwrap ( ) ;
35
- let clear_color_global = world. get_resource :: < ClearColor > ( ) . unwrap ( ) ;
31
+ let pipeline_cache = world. resource :: < PipelineCache > ( ) ;
32
+ let blit_pipeline = world. resource :: < BlitPipeline > ( ) ;
33
+ let clear_color_global = world. resource :: < ClearColor > ( ) ;
36
34
37
35
let clear_color = if let Some ( camera) = camera {
38
36
match camera. output_mode {
@@ -48,19 +46,18 @@ impl ViewNode for UpscalingNode {
48
46
ClearColorConfig :: None => None ,
49
47
} ;
50
48
let converted_clear_color = clear_color. map ( Into :: into) ;
51
- let upscaled_texture = target. main_texture_view ( ) ;
49
+ // texture to be upscaled to the output texture
50
+ let main_texture_view = target. main_texture_view ( ) ;
52
51
53
52
let mut cached_bind_group = self . cached_texture_bind_group . lock ( ) . unwrap ( ) ;
54
53
let bind_group = match & mut * cached_bind_group {
55
- Some ( ( id, bind_group) ) if upscaled_texture . id ( ) == * id => bind_group,
54
+ Some ( ( id, bind_group) ) if main_texture_view . id ( ) == * id => bind_group,
56
55
cached_bind_group => {
57
- let bind_group = render_context. render_device ( ) . create_bind_group (
58
- None ,
59
- & blit_pipeline. texture_bind_group ,
60
- & BindGroupEntries :: sequential ( ( upscaled_texture, & blit_pipeline. sampler ) ) ,
61
- ) ;
56
+ let bind_group = blit_pipeline
57
+ . create_bind_group ( render_context. render_device ( ) , main_texture_view) ;
62
58
63
- let ( _, bind_group) = cached_bind_group. insert ( ( upscaled_texture. id ( ) , bind_group) ) ;
59
+ let ( _, bind_group) =
60
+ cached_bind_group. insert ( ( main_texture_view. id ( ) , bind_group) ) ;
64
61
bind_group
65
62
}
66
63
} ;
0 commit comments