Low performance when using BackgroundEffectBehavior.BlurEffect on many elements
Posted: 10 Mar 2024, 08:10
Hello! I noticed in RenderDoc how the background is rendered several times in the offscreen. Each background is rendered into its own separate offscreen texture. The number of textures corresponds to the number of elements with this effect. Is this behavior advisable and am I using this effect correctly? Why is the background re-rendered into a separate offscreen texture? Why can't I use the background texture directly?
Code: Select all
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=NoesisGUI.GUI.Extensions">
<Grid.Resources>
<ResourceDictionary>
<Style TargetType="Rectangle">
<Setter Property="Width" Value="100" />
<Setter Property="Height" Value="32" />
<Setter Property="Margin" Value="0 4 0 0" />
<Setter Property="Fill" Value="#40FFFFFF" />
<Setter Property="noesis:StyleInteraction.Behaviors">
<Setter.Value>
<noesis:StyleBehaviorCollection>
<noesis:BackgroundEffectBehavior Source="{Binding ElementName=BGImage}">
<BlurEffect Radius="10"/>
</noesis:BackgroundEffectBehavior>
</noesis:StyleBehaviorCollection>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Grid.Resources>
<Border>
<Image x:Name="BGImage" Source="Background.jpg" Stretch="Fill"/>
</Border>
<StackPanel Orientation="Horizontal">
<StackPanel>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
</StackPanel>
<Span Width="40" />
<StackPanel>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
</StackPanel>
<Span Width="40" />
<StackPanel>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
</StackPanel>
<Span Width="40" />
<StackPanel>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
</StackPanel>
<Span Width="40" />
<StackPanel>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
<Rectangle/>
</StackPanel>
</StackPanel>
</Grid>