Add shader reloading on header file edit for shaders with compilation errors
This commit is contained in:
@@ -324,15 +324,14 @@ void Asset::Reload()
|
|||||||
Content::AssetReloading(this);
|
Content::AssetReloading(this);
|
||||||
OnReloading(this);
|
OnReloading(this);
|
||||||
|
|
||||||
// Fire unload event
|
|
||||||
// TODO: maybe just call release storage ref or sth? we cannot call onUnload because managed asset objects gets invalidated
|
|
||||||
//onUnload_MainThread();
|
|
||||||
|
|
||||||
ScopeLock lock(Locker);
|
ScopeLock lock(Locker);
|
||||||
|
|
||||||
// Unload current data
|
if (IsLoaded())
|
||||||
unload(true);
|
{
|
||||||
_isLoaded = false;
|
// Unload current data
|
||||||
|
unload(true);
|
||||||
|
_isLoaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Start reloading process
|
// Start reloading process
|
||||||
startLoading();
|
startLoading();
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
#include "Engine/Profiler/ProfilerCPU.h"
|
#include "Engine/Profiler/ProfilerCPU.h"
|
||||||
#include "Engine/Serialization/MemoryReadStream.h"
|
#include "Engine/Serialization/MemoryReadStream.h"
|
||||||
#include "Engine/Content/Asset.h"
|
#include "Engine/Content/Asset.h"
|
||||||
|
#include "Engine/Content/Content.h"
|
||||||
|
#include "Engine/Content/Assets/Shader.h"
|
||||||
#if USE_EDITOR
|
#if USE_EDITOR
|
||||||
#define COMPILE_WITH_ASSETS_IMPORTER 1 // Hack to use shaders importing in this module
|
#define COMPILE_WITH_ASSETS_IMPORTER 1 // Hack to use shaders importing in this module
|
||||||
#include "Engine/ContentImporters/AssetsImportingManager.h"
|
#include "Engine/ContentImporters/AssetsImportingManager.h"
|
||||||
@@ -56,7 +58,6 @@ using namespace ShadersCompilationImpl;
|
|||||||
class ShadersCompilationService : public EngineService
|
class ShadersCompilationService : public EngineService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ShadersCompilationService()
|
ShadersCompilationService()
|
||||||
: EngineService(TEXT("Shaders Compilation Service"), -100)
|
: EngineService(TEXT("Shaders Compilation Service"), -100)
|
||||||
{
|
{
|
||||||
@@ -250,6 +251,7 @@ namespace
|
|||||||
if (action == FileSystemAction::Delete)
|
if (action == FileSystemAction::Delete)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Get list of assets using this shader file
|
||||||
Array<Asset*> toReload;
|
Array<Asset*> toReload;
|
||||||
{
|
{
|
||||||
ScopeLock lock(ShaderIncludesMapLocker);
|
ScopeLock lock(ShaderIncludesMapLocker);
|
||||||
@@ -260,6 +262,13 @@ namespace
|
|||||||
toReload = file->Value;
|
toReload = file->Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add any shaders that failed to load (eg. due to error in included header)
|
||||||
|
for (Asset* asset : Content::GetAssets())
|
||||||
|
{
|
||||||
|
if (asset->LastLoadFailed() && asset->Is<Shader>() && !toReload.Contains(asset))
|
||||||
|
toReload.Add(asset);
|
||||||
|
}
|
||||||
|
|
||||||
LOG(Info, "Shader include \'{0}\' has been modified.", path);
|
LOG(Info, "Shader include \'{0}\' has been modified.", path);
|
||||||
|
|
||||||
// Wait a little so app that was editing the file (e.g. Visual Studio, Notepad++) has enough time to flush whole file change
|
// Wait a little so app that was editing the file (e.g. Visual Studio, Notepad++) has enough time to flush whole file change
|
||||||
|
|||||||
Reference in New Issue
Block a user