| 29 | } |
| 30 | |
| 31 | Asset::LoadResult Shader::load() |
| 32 | { |
| 33 | // Special case for Null renderer that doesn't need shaders |
| 34 | if (IsNullRenderer()) |
| 35 | { |
| 36 | return LoadResult::Ok; |
| 37 | } |
| 38 | |
| 39 | // Load shader cache (it may call compilation or gather cached data) |
| 40 | ShaderCacheResult shaderCache; |
| 41 | if (LoadShaderCache(shaderCache)) |
| 42 | { |
| 43 | LOG(Error, "Cannot load \'{0}\' shader cache.", ToString()); |
| 44 | return LoadResult::Failed; |
| 45 | } |
| 46 | MemoryReadStream shaderCacheStream(shaderCache.Data.Get(), shaderCache.Data.Length()); |
| 47 | |
| 48 | // Create shader from cache |
| 49 | if (_shader->Create(shaderCacheStream)) |
| 50 | { |
| 51 | LOG(Error, "Cannot load shader \'{0}\'", ToString()); |
| 52 | return LoadResult::Failed; |
| 53 | } |
| 54 | |
| 55 | #if COMPILE_WITH_SHADER_COMPILER |
| 56 | RegisterForShaderReloads(this, shaderCache); |
| 57 | #endif |
| 58 | return LoadResult::Ok; |
| 59 | } |
| 60 | |
| 61 | void Shader::unload(bool isReloading) |
| 62 | { |