Fix crash when CAS shader is missing

This commit is contained in:
Wojtek Figat
2024-11-20 23:08:32 +01:00
parent e8b46f8b19
commit d4b663cd1a
2 changed files with 5 additions and 3 deletions

View File

@@ -35,16 +35,17 @@ void ContrastAdaptiveSharpeningPass::Dispose()
bool ContrastAdaptiveSharpeningPass::setupResources()
{
// Lazy-load shader
if (!_shader)
if (_lazyInit && !_shader)
{
_lazyInit = false;
_shader = Content::LoadAsyncInternal<Shader>(TEXT("Shaders/CAS"));
if (!_shader)
return false;
return true;
#if COMPILE_WITH_DEV_ENV
_shader.Get()->OnReloading.Bind<ContrastAdaptiveSharpeningPass, &ContrastAdaptiveSharpeningPass::OnShaderReloading>(this);
#endif
}
if (!_shader->IsLoaded())
if (!_shader || !_shader->IsLoaded())
return true;
const auto shader = _shader->GetShader();

View File

@@ -13,6 +13,7 @@ class ContrastAdaptiveSharpeningPass : public RendererPass<ContrastAdaptiveSharp
private:
AssetReference<Shader> _shader;
GPUPipelineState* _psCAS = nullptr;
bool _lazyInit = true;
public:
bool CanRender(const RenderContext& renderContext);