SciChart WPF 2D Charts > Advanced 2D Charting Topics > Enabling The Visual Xccelerator Engine
Enabling The Visual Xccelerator Engine

What is the Visual Xccelerator Engine?

The Visual Xccelerator Engine (VXccelEngine2D/3D.dll) is a proprietary, in-house, C++ cross platform 3D graphics engine which we have built in order to bring our high performance 2D & 3D Charts to a number of platforms, including Windows (WPF), Mobile (iOS, Android), as well as future platforms including Mac OSX, Linux and in web browsers with Javascript & WebAssembly.

The engine is entirely hardware accelerated and platform agnostic: targetting DirectX on Windows, Metal on iOS / Mac OSX, OpenGL ES 2/3 on Android and WebGL in the browser.

In our WPF Charts Visual Xccelerator is used to get absolutely insane performance: now you can render millions, tens of millions, hundreds of millions or even in excess of a billion data-points in real-time depending on chart type and hardware configuration.

Hardware requirements & Software Fallback

Visual Xccelerator Engine requires a DirectX 9c capable (DirectX 11 preferred) graphics card with at least 256 Mb of VRAM. Less Video RAM than this can cause problems and automatic downgrade to software rendering which is slower. Without a GPU capable of DirectX hardware acceleration, the charts will automatically fall back to software rendering as well.

See Troubleshooting Visual Xccelerator Issues on low-end Graphics Adapters for more information.

How to Enable it

In SciChart WPF, the hardware-accelerated renderer called VisualXcceleratorRenderSurface is used by SciChartSurface as the default render. It requires the VisualXccelerator Engine to perform hardware-accelerated drawing, so the Engine is started behind the scenes as well.

Normally SciChart uses autodetection to determine whether hardware acceleration is supported by a running machine. If it is, the graphics engine is started and VisualXcceleratorRenderSurface is used for rendering. Otherwise, SciChart falls back automatically to software rendering and one of the software renderers (HighQualityRenderSurface) is applied. The Engine does not start in this case.

Please find more info about available Renderer Plugins in the following documentation article: Renderer Plugins

How to check it is Enabled

There is a way to check whether the hardware-accelerated renderer is used for drawing. To do this, check whether the value of the RenderSurface property on a SciChartSurface is of the appropriate type:

Hardware-accelerated rendering check
Copy Code
if (sciChartSurface.RenderSurface.GetType() == typeof (VisualXcceleratorRenderSurface))
{
    // Hardware-accelerated rendering is enabled!
}

How to Disable it

Besides automatic fallback to software rendering when hardware requirements are not met, hardware-accelerated rendering can be disabled explicitly in several ways:

  1. Setting the VisualXcceleratorEngine.IsEnabledByDefault static property to “False”. It should be set before the SciChartSurface constructor is executed

  2. Explicitly specifying the desired renderer.

    This can be done by setting appropriate RenderSurface instance to the RenderSurface property on a SciChartSurface (either in XAML or in code):

    Setting RenderSurface
    Copy Code
            <!--  Render SciChart using High Quality Render Surface  --> 
            <s:SciChartSurface>
                <s:SciChartSurface.RenderSurface>
                    <s:HighQualityRenderSurface />
                </s:SciChartSurface.RenderSurface>
                <!-- Other SciChartSurface settings -->
            </s:SciChartSurface>

    Please find more info about available renderer plugins in the Renderer Plugins documentation article

  3. Setting the VisualXcceleratorEngine.IsEnabled attached property to “False” on a SciChartSurface instance:

    Disabling VisualXcceleratorEngine
    Copy Code
    <s:SciChartSurface s:VisualXcceleratorEngine.IsEnabled="True">
       
         <!-- Other SciChartSurface settings -->
     
    </s:SciChartSurface>

How to Configure Automatic Fallback

The automatic fallback to software rendering occurs when used hardware is not supported by the VisualXccelerator Engine. Please look at the Troubleshooting Visual Xccelerator Issues on low-end Graphics Adapter to learn more about such cases.

The fallback can be configured through the couple of attached properties defined in the SciChart.Charting.VisualXcceleratorEngine class:

  • VisualXcceleratorEngine.FallbackType - allows to assign a renderer that will be used for drawing in case of fallback. This is the type of RenderSurfaceBase which is created if current hardware is not supported by Visual Xccelerator Engine. It is set to HighQualityRenderSurface by default. Please look at the Renderer Plugins article to learn more about renderers available in SciChart.

  • VisualXcceleratorEngine.DowngradeWithoutException - allows to specify whether automatic fallback should happen silently. If set to “False”, an exception will be thrown in such case. The default value is “True”, which allows for automatic fallback.

These properties can be set on a SciChartSurface in XAML, as shown in the following code snippet:

Setting FallbackType
Copy Code
<!--
FallbackType means fall back to this renderer if DirectX not supported
DowngradeWithoutException=False means it will throw exception if you don't support DirectX, otherwise, silent downgrade (set to True by default)
-->
<s:SciChartSurface s:VisualXcceleratorEngine.FallbackType="{x:Type s:HighQualityRenderSurface}"
                   s:VisualXcceleratorEngine.DowngradeWithoutException="False">
   
     <!-- the rest of the SciChartSurface configuration -->
 
</s:SciChartSurface>

Checking VisualXccelerator Engine Status

It is possible to check parameters of the current running engine instance. Only one instance of the VisualXccelerator Engine can be running at the same time on a PC, so its parameters can be obtained from the static properties of the SciChart.Charting.VisualXcceleratorEngine class:

  • VisualXcceleratorEngine.IsRunning - returns a value indicating whether there is a running instance of VisualXccelerator Engine
  • VisualXcceleratorEngine.IsUsingD3D9 - returns a value indicating whether VisualXccelerator Engine runs in the DirectX 9 mode
  • VisualXcceleratorEngine.DirectXMode - returns the DirectX mode that VisualXccelerator Engine is configured with
  • VisualXcceleratorEngine.AntiAliasingMode - returns the Anti-Aliasing mode that VisualXccelerator Engine is configured with
  • VisualXcceleratorEngine.IsEnabledByDefault - returns a value indicating whether the hardware-accelerated renderering is enabled by default

Starting VisualXccelerator Engine Explicitly

Although SciChart tries to start the VisualXccelerator Engine automatically, there are use-cases when it is useful to start the Engine explicitly. For instance, this approach can be used to configure the Engine explicitly or reduce the startup application time. Please find more info about the latter in the Startup Application Performance article

Explicit engine startup is possible via the methods from the SciChart.Charting.VisualXcceleratorEngine class. There is a synchronous and an asynchronous version of the static RestartEngine() method:

Explicit engine startup
Copy Code
public static void SciChart.Charting.VisualXcceleratorEngine.RestartEngine(VxRenderSettings renderSettings = null);
public static void SciChart.Charting.VisualXcceleratorEngine.RestartEngineAsync(VxRenderSettings renderSettings = null);

It is recommended wrapping calls to these methods in a try-catch block: if the Engine cannot start, it will throw an exception with a sufficient message.

The usage can be demonstrated by the following code snippet. Here, the Engine starts in async manner in an App constructor:

Try-catch wrapping
Copy Code
        public App()
        {
            // Start Visual Xccelerator Engine asynchronously
            Task.Run(() =>
            {
                try
                {
                    VisualXcceleratorEngine.UseAutoShutdown = false;
                    VisualXcceleratorEngine.RestartEngine();
                }
                catch
                {
                    // Suppress Vx init errors. In this case rendering
            // will occur with a fallback to a software renderer
                }
            });
 
            // Do other app initialization
            InitializeComponent();
        }

By default, the Engine is started asynchronously during the Loaded event of SciChartSurface. With the API described above, it can be started or restarted manually at any time.

Configuring Visual Xccelerator Engine Shutdown

There is no explicit way to shut down the engine. This is done intentionally, since stopping the engine during rendering pass would cause a runtime error and result in a non-recoverable crash. However, setting the VisualXcceleratorEngine.UseAutoShutdown property to “True” makes the engine to shut down immefiately if there is no SciChartSurface using it. Otherwise, the engine will shut down when the last renderer instance that is using it is disposed or finalized.

Configuring Visual Xccelerator Engine Parameters

There are several startup parameters that can be provided to configure Visual Xccelerator Engine. They can be set via corresponding properties on an instance of a VxRenderSettings object, which can be passed in to a call of the VisualXcceleratorEngine.RestartEngine(VxRenderSettings) method (see “Starting Visual Xccelerator Engine Explicitly” section above):

  • VxRenderSettings.FullScreenAntiAliasingMode - configures the Anti-Aliasing mode for hardware-accelerated rendering. By default, it is set to “None”

  • VxRenderSettings.DirectXMode - specifies which DirectX version to use for hardware-accelerated rendering. By default, it is set to “Auto”, which means that DirectX 11 is a preferred version

This is how these settings can be used in code:

Using VxRenderSettings
Copy Code
                    // Create VxRenderSettings
                    var renderSettings = new VxRenderSettings
                    {
                        DirectXMode = UseD3D9 ? DirectXMode.DirectX9c : DirectXMode.AutoDetect,
                        FullScreenAntiAliasingMode =
                            Use3DAA4x ?
                                FullScreenAntiAliasingMode.MSAA4x :
                                FullScreenAntiAliasingMode.None,
                    };
                    // Restart 2D engine
                    VisualXcceleratorEngine.RestartEngine(renderSettings);

Also, there is a couple of standalone properties that have impact on rendering with hardware-accelerated renderer:

  • VisualXcceleratorRenderSurface.UseAlternativeFillSource - allows to specify how to fill pixels in the final image after a redraw. If “True”, software method is used, and D3DImage otherwise (may not work properly on some hardware). It is set to “True” by default. This property has to be set on a VisualXcceleratorRenderSurface instance

  • VisualXcceleratorRenderer.EnableForceWaitForGPU - specifies whether to copy the final pixels buffer immediately, or to wait for the GPU to finish rendering. It is set to “False” by default

  • VisualXcceleratorEngine.WriteWarningsToOutput - enables or disables writing GPU test messages to Debug output. Enabled by default

  • VisualXcceleratorEngine.WriteGpuTestLogToFile - enables or disables writing GPU test messages to GpuCapability.log file. Disabled by default

Other configurational properties of the VxRenderSettings class are explained in the paragraph below.

Configuring Visual Xccelerator Engine Memory

It is possible to configure sizes of several memory buffers that are used by the hardware-accelerated renderer. This can be done via corresponding properties on an instance of a VxRenderSettings object, which can be passed in to a call of the VisualXcceleratorEngine.RestartEngine(VxRenderSettings) method (see “Starting Visual Xccelerator Engine Explicitly” section above).

Buffer sizes are provided in Bytes and should be greater than 0. Thus, the minimal possible buffer size is 1B. The default buffer sizes vary between 4 and 8 MB, depending on hardware.

Changing buffer sizes will reduce amount of native memory buffers allocated by the VisualXccelerator renderer but may result in worse performance by reducing number of points available for processing in a single batch.

These settings can be used in code as in the following code snippet:

Setting buffer size
Copy Code
                    var renderSettings = new VxRenderSettings
                    {
                        // Decrease some buffer sizes to 1B to reduce memory usage
                        MaxBandsBufferSize = 1,
                        MaxCandlesBufferSize = 1,
 
                        // Increase buffer size to 16 MB for Lines
                        MaxLinesBufferSize = 16 * 1024 * 1024,
                    };
 
                    // Restart 2D engine
                    VisualXcceleratorEngine.RestartEngine(renderSettings);

Enabling Impossible Mode

ImpossibleMode is an optimization designed to achieve best performance for big data sets in real-time scenarios. Enabling it turns on fast data-processing algorithm which is up to 100x faster for massive data sets such as 1-billion points.

It makes sense to enable this mode when a data set contains 50 million data points or more and chart requires real-time updates. It is applicable to real-time FIFO scenarios as well.

To enable ImpossibleMode set the VisualXcceleratorEngine.EnableImpossibleMode attached property to “True” on a SciChartSurface.

Deployment

Unlike the Direct3D11RenderSurface as part of the SciChart.DirectX package you had to worry about deployment of SharpDX, and in the past you had to worry about the Visual C++ runtime for our 3D Charts.

With the Visual Xccelerator engine neither of these are necessary. Deployment is just as if you had consumed a C# .NET DLL from NuGet. Just reference it in Visual Studio and it just works! 

Learn More

You can learn more about the performance improvements in the Visual Xccelerator Engine at the following page: SciChart WPF v6 'Xccelerated Edition' Up to 100x (10,000%) Faster WPF Charts!

See Also