# VariantsUploadedToGpuLastFrame

> Provides parameters and methods for tracking shader variants that have been uploaded to the GPU driver during the last frame at runtime.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine.Shaders](/engine/6000.7/script-reference/unityengine/shaders.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public static class VariantsUploadedToGpuLastFrame
```

## Remarks

This class provides access to shader variants that were uploaded to the GPU driver during the last frame. To reduce shader stutters, use the class to find shader variants that aren't warmed up, and add them to a [ShaderVariantCollection](/engine/6000.7/script-reference/unityengine/shadervariantcollection.md) or a [GraphicsStateCollection](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection.md).

Note: You can only use this class in a built application, not in the Unity Editor.

Additional Resources: [ShaderVariantCollection](/engine/6000.7/script-reference/unityengine/shadervariantcollection.md), [GraphicsStateCollection](/engine/6000.7/script-reference/unityengine/rendering/graphicsstatecollection.md), [VariantsUploadedToGpuLastFrame.UploadData](/engine/6000.7/script-reference/unityengine/shaders/variantsuploadedtogpulastframe/uploaddata.md).

## Examples

```csharp
using UnityEngine;
using UnityEngine.Shaders;

/*
    Attach this script to a GameObect. When run in the player, it reports shader variants sent to the
    GPU driver for compilation during the last frame in the console.
*/
public class VariantsUploadedToGpuLogger : MonoBehaviour
{
    void Update()
    {
        uint variantCount = VariantsUploadedToGpuLastFrame.count;
        if (variantCount > 0)
        {
            Debug.Log("Sent " + variantCount + " variants to the GPU.");
            for (uint variantIndex = 0; variantIndex < variantCount; ++variantIndex)
            {
                VariantsUploadedToGpuLastFrame.UploadData d;
                if (!VariantsUploadedToGpuLastFrame.TryGetUploadData(variantIndex, out d))
                    continue;

                string keywords = "'";
                for (uint keywordIndex = 0; keywordIndex < d.keywords.Length; ++keywordIndex)
                {
                    if (keywordIndex != 0)
                        keywords += " ";
                    keywords += d.keywords[keywordIndex].name;
                }
                keywords += "'";
                string passId = "subshader " + (d.passIdentifier.SubshaderIndex + 1) + " pass " + (d.passIdentifier.PassIndex + 1);
                string description = "Shader " + d.shader.name + " " + passId + " stages " + d.stages;
                Debug.Log(description + " keywords " + keywords + " uploaded in " + d.uploadTimeInMilliseconds + " ms.");
            }
        }
    }
}
```

## Static Properties

| Property                                                                                             | Description                                                                      |
| ---------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| [count](/engine/6000.7/script-reference/unityengine/shaders/variantsuploadedtogpulastframe/count.md) | The number of shader variants submitted to the GPU driver during the last frame. |

## Static Methods

| Method                                                                                                                     | Description                                                                                                                                                                                       |
| -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [GetUploadData](/engine/6000.7/script-reference/unityengine/shaders/variantsuploadedtogpulastframe/getuploaddata.md)       | Gets the [VariantsUploadedToGpuLastFrame.UploadData](/engine/6000.7/script-reference/unityengine/shaders/variantsuploadedtogpulastframe/uploaddata.md) for the shader variant at the given index. |
| [TryGetUploadData](/engine/6000.7/script-reference/unityengine/shaders/variantsuploadedtogpulastframe/trygetuploaddata.md) | Fetches the [VariantsUploadedToGpuLastFrame.UploadData](/engine/6000.7/script-reference/unityengine/shaders/variantsuploadedtogpulastframe/uploaddata.md) for the shader variant at given index.  |

## Structs

| Struct                                                                                                                                        | Description                                                      |
| --------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [VariantsUploadedToGpuLastFrame.UploadData](/engine/6000.7/script-reference/unityengine/shaders/variantsuploadedtogpulastframe/uploaddata.md) | Represents a shader variant that was uploaded to the GPU driver. |
