Version: Unity 6.6 Alpha (6000.6)
LanguageEnglish
  • C#

GraphicsApiValidation

class in UnityEngine.Rendering

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Provides programmatic access to graphics API debug layer validation errors.

Use this class to detect and respond to graphics API validation errors at runtime. It's intended for test frameworks, diagnostic tools, and other systems that need to react to validation errors rather than just log them.

Validation is implemented per graphics backend, so the way you enable it depends on the active GraphicsDeviceType. With Direct3D 12, launch Unity with the -force-d3d12-debug-as-errors command line argument. When you don't specify a backend-specific argument, or when the debug layer fails to initialize, GraphicsApiValidation.IsValidationActive returns false and Unity doesn't report errors.

Call GraphicsApiValidation.IsValidationSupported first to check whether the current graphics backend exposes a validation implementation. When it returns false the other members have no effect and return default values.

Additional resources: GraphicsApiValidation.IsValidationSupported, GraphicsApiValidation.IsValidationActive, GraphicsApiValidation.IsValidationRequested, GraphicsApiValidation.GetValidationErrorCount, GraphicsApiValidation.ClearValidationErrors.

using UnityEngine;
using UnityEngine.Rendering;

public static class GraphicsApiValidationExample { public static void CheckForErrors() { if (!GraphicsApiValidation.IsValidationSupported() || !GraphicsApiValidation.IsValidationActive()) return;

GraphicsApiValidation.ClearValidationErrors();

// ... run code that issues graphics commands ...

int count = GraphicsApiValidation.GetValidationErrorCount(); for (int i = 0; i < count; i++) { Debug.LogError(GraphicsApiValidation.GetValidationError(i)); } } }

Static Methods

Method Description
ClearValidationErrorsClears any accumulated graphics API validation errors.
GetValidationErrorReturns a specific graphics API validation error message by index.
GetValidationErrorCountReturns the number of graphics API validation errors accumulated since the last call to GraphicsApiValidation.ClearValidationErrors.
GetValidationErrorsDroppedCountReturns the number of graphics API validation errors that were dropped because the internal error buffer was full.
IsValidationActiveReturns whether graphics API validation is active and the debug layer initialized successfully.
IsValidationErrorLoggingSuppressedReturns whether immediate logging of graphics API validation errors is currently suppressed.
IsValidationRequestedReturns whether graphics API validation was requested via a backend-specific command line argument (for example, -force-d3d12-debug-as-errors on Direct3D 12).
IsValidationSupportedReturns whether the current graphics backend exposes a validation implementation.
SetValidationErrorLoggingSuppressedControls whether graphics API validation errors are logged immediately as the debug layer reports them.