# PrecompiledGraphicsState

> Provides statistics about precompiled graphics pipeline state loading on the current graphics device.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine.Rendering](/engine/7000.0/script-reference/unityengine/rendering.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public static class PrecompiledGraphicsState
```

## Remarks

Some graphics backends can load pipeline state objects (PSOs) from a precompiled state database instead of compiling them at runtime. This reduces stuttering caused by shader compilation. On Direct3D 12, this database is Microsoft's [D3D12 Advanced Shader Delivery - State Object Database](https://microsoft.github.io/DirectX-Specs/d3d/StateObjectDatabase.html). Use this class to query how effectively the graphics backend uses the precompiled state database.

Check [SystemInfo.supportsPrecompiledGraphicsStateStats](/engine/7000.0/script-reference/unityengine/systeminfo/supportsprecompiledgraphicsstatestats.md) before calling [PrecompiledGraphicsState.GetStats](/engine/7000.0/script-reference/unityengine/rendering/precompiledgraphicsstate/getstats.md). When it's false, the current graphics device doesn't report these statistics and [PrecompiledGraphicsState.GetStats](/engine/7000.0/script-reference/unityengine/rendering/precompiledgraphicsstate/getstats.md) returns a zeroed [PrecompiledGraphicsStateStats](/engine/7000.0/script-reference/unityengine/rendering/precompiledgraphicsstatestats.md).

Additional Resources: [SystemInfo.supportsPrecompiledGraphicsStateStats](/engine/7000.0/script-reference/unityengine/systeminfo/supportsprecompiledgraphicsstatestats.md), [PrecompiledGraphicsState.GetStats](/engine/7000.0/script-reference/unityengine/rendering/precompiledgraphicsstate/getstats.md), [PrecompiledGraphicsStateStats](/engine/7000.0/script-reference/unityengine/rendering/precompiledgraphicsstatestats.md).

## Examples

```csharp
using UnityEngine;
using UnityEngine.Rendering;

public static class PrecompiledGraphicsStateExample
{
    public static void LogStatistics()
    {
        if (!SystemInfo.supportsPrecompiledGraphicsStateStats)
        {
            Debug.Log("Precompiled graphics state statistics aren't available on the current graphics device.");
            return;
        }

        PrecompiledGraphicsStateStats stats = PrecompiledGraphicsState.GetStats();
        Debug.Log($"Created: {stats.createdCount}, precompiled misses: {stats.precompiledCacheMissCount}, all-cache misses: {stats.allCachesMissCount}");
    }
}
```

## Static Methods

| Method                                                                                                 | Description                                                                            |
| ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
| [GetStats](/engine/7000.0/script-reference/unityengine/rendering/precompiledgraphicsstate/getstats.md) | Returns counters describing precompiled graphics pipeline state cache hits and misses. |
