From 9f887a5c3cbbdcc4ef708e30574ef035009b7394 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Mon, 3 Apr 2023 11:38:37 +0200 Subject: [PATCH] Check shader after loading it, throw an exception with a message on failure. This is better than having a random nullref happen, if the shaders cannot be loaded for whatever reason. --- Assets/Scripts/Core/Fsr2Pipeline.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Assets/Scripts/Core/Fsr2Pipeline.cs b/Assets/Scripts/Core/Fsr2Pipeline.cs index 80d9f99..f6b9686 100644 --- a/Assets/Scripts/Core/Fsr2Pipeline.cs +++ b/Assets/Scripts/Core/Fsr2Pipeline.cs @@ -108,7 +108,11 @@ namespace FidelityFX private void LoadComputeShader(string name, Fsr2.InitializationFlags flags, ref ComputeShader shaderRef, out int kernelIndex) { if (shaderRef == null) + { shaderRef = ContextDescription.Callbacks.LoadComputeShader(name); + if (shaderRef == null) + throw new MissingReferenceException($"Shader '{name}' could not be loaded! Please ensure it is included in the project correctly."); + } kernelIndex = shaderRef.FindKernel("CS");