Page 1 of 1

Low performance when using BackgroundEffectBehavior.BlurEffect on many elements

Posted: 10 Mar 2024, 08:10
by Demond
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?
<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>

Re: Low performance when using BackgroundEffectBehavior.BlurEffect on many elements

Posted: 11 Mar 2024, 12:06
by sfernandez
Hi, this looks like something is wrong in our code because if the source of the behavior is always the same it should reuse the offscreen texture for all instances. Could you please report this in our bugtracker?

Re: Low performance when using BackgroundEffectBehavior.BlurEffect on many elements

Posted: 11 Mar 2024, 14:19
by Demond
Hi, this looks like something is wrong in our code because if the source of the behavior is always the same it should reuse the offscreen texture for all instances. Could you please report this in our bugtracker?
I created a ticket #3161. Thanks for the feedback!

Re: Low performance when using BackgroundEffectBehavior.BlurEffect on many elements

Posted: 27 Mar 2024, 11:04
by sfernandez
Thanks for the ticket, we've found the source of the problem and fixed it for the next release.