using System; namespace UnityEngine.Rendering.UnifiedRayTracing { /// /// Helper functions for querying the shader type and filename for a given backend. /// public static class BackendHelpers { /// /// Builds a file path with the right extension for the given . /// /// Backend for which the shader will be loaded. /// Path to the shader file, without any extension. /// The file path. public static string GetFileNameOfShader(RayTracingBackend backend, string fileName) { string postFix = backend switch { RayTracingBackend.Hardware => "raytrace", RayTracingBackend.Compute => "compute", _ => throw new ArgumentOutOfRangeException(nameof(backend), backend, null) }; return $"{fileName}.{postFix}"; } /// /// Returns the of shader used by the given . /// /// Backend for which the shader will be loaded. /// The Type of the shader. public static Type GetTypeOfShader(RayTracingBackend backend) { Type shaderType = backend switch { RayTracingBackend.Hardware => typeof(RayTracingShader), RayTracingBackend.Compute => typeof(ComputeShader), _ => throw new ArgumentOutOfRangeException(nameof(backend), backend, null) }; return shaderType; } } }