Demond
Topic Author
Posts: 11
Joined: 06 Feb 2023, 23:32

Low performance when using BackgroundEffectBehavior.BlurEffect on many elements

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?
<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>
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

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

11 Mar 2024, 12:06

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?
 
Demond
Topic Author
Posts: 11
Joined: 06 Feb 2023, 23:32

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

11 Mar 2024, 14:19

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!
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

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

27 Mar 2024, 11:04

Thanks for the ticket, we've found the source of the problem and fixed it for the next release.

Who is online

Users browsing this forum: Bing [Bot] and 3 guests