@@ -392,14 +392,13 @@ inline T* CResourceManager::CreateShader(const char* name, const char* filename
392392 FS.update_path (cname, " $game_shaders$" , cname);
393393 file = FS.r_open (cname);
394394 }
395- R_ASSERT2 (file, cname);
395+ R_ASSERT3 (file, " Shader file doesnt exist: " , cname);
396396
397397 // Duplicate and zero-terminate
398398 const auto size = file->length ();
399399 char * const data = (LPSTR)_alloca (size + 1 );
400400 CopyMemory (data, file->pointer (), size);
401401 data[size] = 0 ;
402- FS.r_close (file);
403402
404403 // Select target
405404 LPCSTR c_target = ShaderTypeTraits<T>::GetCompilationTarget ();
@@ -417,8 +416,9 @@ inline T* CResourceManager::CreateShader(const char* name, const char* filename
417416#endif
418417
419418 // Compile
420- HRESULT const _hr = GEnv.Render ->shader_compile (name, (DWORD const *)data, size,
421- c_entry, c_target, flags, (void *&)sh);
419+ HRESULT const _hr = GEnv.Render ->shader_compile (name, file, c_entry, c_target, flags, (void *&)sh);
420+
421+ FS.r_close (file);
422422
423423 VERIFY (SUCCEEDED (_hr));
424424
@@ -432,10 +432,10 @@ inline T* CResourceManager::CreateShader(const char* name, const char* filename
432432}
433433
434434template <typename T>
435- inline void CResourceManager::DestroyShader (const T* sh)
435+ bool CResourceManager::DestroyShader (const T* sh)
436436{
437437 if (0 == (sh->dwFlags & xr_resource_flagged::RF_REGISTERED))
438- return ;
438+ return false ;
439439
440440 typename ShaderTypeTraits<T>::MapType& sh_map = GetShaderMap<typename ShaderTypeTraits<T>::MapType>();
441441
@@ -445,7 +445,9 @@ inline void CResourceManager::DestroyShader(const T* sh)
445445 if (iterator != sh_map.end ())
446446 {
447447 sh_map.erase (iterator);
448- return ;
448+ return true ;
449449 }
450+
450451 Msg (" ! ERROR: Failed to find compiled shader '%s'" , sh->cName .c_str ());
452+ return false ;
451453}
0 commit comments