GetCriticalAssetFilters()
Signed-off-by: Dayo Lawal <lawalfua@amazon.com>
This commit is contained in:
+7
-1
@@ -62,6 +62,11 @@ namespace AtomToolsFramework
|
||||
void Destroy() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AzFramework::AssetSystemStatusBus::Handler overrides...
|
||||
void AssetSystemAvailable() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AZ::ComponentApplication overrides...
|
||||
void QueryApplicationType(AZ::ApplicationTypeQuery& appType) const override;
|
||||
@@ -79,7 +84,8 @@ namespace AtomToolsFramework
|
||||
void OnExceptionMessage(AZStd::string_view message) override;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual AZStd::string GetBuildTargetName();
|
||||
virtual AZStd::string GetBuildTargetName() const;
|
||||
virtual AZStd::vector<AZStd::string> GetCriticalAssetFilters() const;
|
||||
|
||||
virtual void LoadSettings();
|
||||
virtual void UnloadSettings();
|
||||
|
||||
+40
-5
@@ -39,7 +39,7 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
namespace AtomToolsFramework
|
||||
{
|
||||
AZStd::string AtomToolsApplication::GetBuildTargetName()
|
||||
AZStd::string AtomToolsApplication::GetBuildTargetName() const
|
||||
{
|
||||
return AZStd::string("AtomTools");
|
||||
}
|
||||
@@ -69,7 +69,7 @@ namespace AtomToolsFramework
|
||||
|
||||
void AtomToolsApplication::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
Application::Reflect(context);
|
||||
Base::Reflect(context);
|
||||
|
||||
AzToolsFramework::AssetBrowser::AssetBrowserEntry::Reflect(context);
|
||||
AzToolsFramework::AssetBrowser::RootAssetBrowserEntry::Reflect(context);
|
||||
@@ -82,13 +82,12 @@ namespace AtomToolsFramework
|
||||
|
||||
if (auto behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context))
|
||||
{
|
||||
AZStd::string fileName = GetBuildTargetName() + ".general";
|
||||
// this will put these methods into the 'azlmbr.AtomTools.general' module
|
||||
auto addGeneral = [fileName](AZ::BehaviorContext::GlobalMethodBuilder methodBuilder)
|
||||
auto addGeneral = [](AZ::BehaviorContext::GlobalMethodBuilder methodBuilder)
|
||||
{
|
||||
methodBuilder->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
|
||||
->Attribute(AZ::Script::Attributes::Category, "Editor")
|
||||
->Attribute(AZ::Script::Attributes::Module, fileName);
|
||||
->Attribute(AZ::Script::Attributes::Module, "AtomTools");
|
||||
};
|
||||
// The reflection here is based on patterns in CryEditPythonHandler::Reflect
|
||||
addGeneral(behaviorContext->Method(
|
||||
@@ -150,6 +149,42 @@ namespace AtomToolsFramework
|
||||
Base::Destroy();
|
||||
}
|
||||
|
||||
AZStd::vector<AZStd::string> AtomToolsApplication::GetCriticalAssetFilters() const
|
||||
{
|
||||
// List of common asset filters for things that need to be compiled to run the material editor
|
||||
// Some of these things will not be necessary once we have proper support for queued asset loading and reloading
|
||||
return AZStd::vector<AZStd::string>({ "passes/", "config/" });
|
||||
}
|
||||
|
||||
void AtomToolsApplication::AssetSystemAvailable()
|
||||
{
|
||||
bool connectedToAssetProcessor = false;
|
||||
|
||||
// When the AssetProcessor is already launched it should take less than a second to perform a connection
|
||||
// but when the AssetProcessor needs to be launch it could take up to 15 seconds to have the AssetProcessor initialize
|
||||
// and able to negotiate a connection when running a debug build
|
||||
// and to negotiate a connection
|
||||
|
||||
AzFramework::AssetSystem::ConnectionSettings connectionSettings;
|
||||
AzFramework::AssetSystem::ReadConnectionSettingsFromSettingsRegistry(connectionSettings);
|
||||
connectionSettings.m_connectionDirection =
|
||||
AzFramework::AssetSystem::ConnectionSettings::ConnectionDirection::ConnectToAssetProcessor;
|
||||
connectionSettings.m_connectionIdentifier = GetBuildTargetName();
|
||||
connectionSettings.m_loggingCallback = []([[maybe_unused]] AZStd::string_view logData)
|
||||
{
|
||||
AZ_TracePrintf("Atom Tools", "%.*s", aznumeric_cast<int>(logData.size()), logData.data());
|
||||
};
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(
|
||||
connectedToAssetProcessor, &AzFramework::AssetSystemRequestBus::Events::EstablishAssetProcessorConnection, connectionSettings);
|
||||
|
||||
if (connectedToAssetProcessor)
|
||||
{
|
||||
CompileCriticalAssets(GetCriticalAssetFilters());
|
||||
}
|
||||
|
||||
AzFramework::AssetSystemStatusBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void AtomToolsApplication::CompileCriticalAssets(const AZStd::vector<AZStd::string> &assetFiltersArray)
|
||||
{
|
||||
AZ_TracePrintf(GetBuildTargetName().c_str(), "Compiling critical assets.\n");
|
||||
|
||||
@@ -51,7 +51,7 @@ AZ_POP_DISABLE_WARNING
|
||||
namespace MaterialEditor
|
||||
{
|
||||
//! This function returns the build system target name of "MaterialEditor
|
||||
AZStd::string MaterialEditorApplication::GetBuildTargetName()
|
||||
AZStd::string MaterialEditorApplication::GetBuildTargetName() const
|
||||
{
|
||||
#if !defined (LY_CMAKE_TARGET)
|
||||
#error "LY_CMAKE_TARGET must be defined in order to add this source file to a CMake executable target"
|
||||
@@ -117,36 +117,11 @@ namespace MaterialEditor
|
||||
Base::Destroy();
|
||||
}
|
||||
|
||||
void MaterialEditorApplication::AssetSystemAvailable()
|
||||
AZStd::vector<AZStd::string> MaterialEditorApplication::GetCriticalAssetFilters() const
|
||||
{
|
||||
bool connectedToAssetProcessor = false;
|
||||
|
||||
// When the AssetProcessor is already launched it should take less than a second to perform a connection
|
||||
// but when the AssetProcessor needs to be launch it could take up to 15 seconds to have the AssetProcessor initialize
|
||||
// and able to negotiate a connection when running a debug build
|
||||
// and to negotiate a connection
|
||||
|
||||
AzFramework::AssetSystem::ConnectionSettings connectionSettings;
|
||||
AzFramework::AssetSystem::ReadConnectionSettingsFromSettingsRegistry(connectionSettings);
|
||||
connectionSettings.m_connectionDirection = AzFramework::AssetSystem::ConnectionSettings::ConnectionDirection::ConnectToAssetProcessor;
|
||||
connectionSettings.m_connectionIdentifier = GetBuildTargetName();
|
||||
connectionSettings.m_loggingCallback = []([[maybe_unused]] AZStd::string_view logData)
|
||||
{
|
||||
AZ_TracePrintf("Material Editor", "%.*s", aznumeric_cast<int>(logData.size()), logData.data());
|
||||
};
|
||||
AzFramework::AssetSystemRequestBus::BroadcastResult(connectedToAssetProcessor,
|
||||
&AzFramework::AssetSystemRequestBus::Events::EstablishAssetProcessorConnection, connectionSettings);
|
||||
|
||||
if (connectedToAssetProcessor)
|
||||
{
|
||||
// List of common asset filters for things that need to be compiled to run the material editor
|
||||
// Some of these things will not be necessary once we have proper support for queued asset loading and reloading
|
||||
const AZStd::vector<AZStd::string> assetFiltersArray = { "passes/", "config/", "MaterialEditor/" };
|
||||
|
||||
CompileCriticalAssets(assetFiltersArray);
|
||||
}
|
||||
|
||||
AzFramework::AssetSystemStatusBus::Handler::BusDisconnect();
|
||||
// List of common asset filters for things that need to be compiled to run the material editor
|
||||
// Some of these things will not be necessary once we have proper support for queued asset loading and reloading
|
||||
return AZStd::vector<AZStd::string>({ "passes/", "config/", "MaterialEditor" });
|
||||
}
|
||||
|
||||
void MaterialEditorApplication::ProcessCommandLine(const AZ::CommandLine& commandLine)
|
||||
@@ -164,7 +139,7 @@ namespace MaterialEditor
|
||||
{
|
||||
const AZStd::string openDocumentPath = commandLine.GetMiscValue(openDocumentIndex);
|
||||
|
||||
AZ_Printf("MaterialEditor", "Opening document: %s", openDocumentPath.c_str());
|
||||
AZ_Printf(GetBuildTargetName().c_str(), "Opening document: %s", openDocumentPath.c_str());
|
||||
MaterialDocumentSystemRequestBus::Broadcast(&MaterialDocumentSystemRequestBus::Events::OpenDocument, openDocumentPath);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,13 +46,9 @@ namespace MaterialEditor
|
||||
void Destroy() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AzFramework::AssetSystemStatusBus::Handler overrides...
|
||||
void AssetSystemAvailable() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ProcessCommandLine(const AZ::CommandLine& commandLine) override;
|
||||
void StartInternal() override;
|
||||
AZStd::string GetBuildTargetName() override;
|
||||
AZStd::string GetBuildTargetName() const override;
|
||||
AZStd::vector<AZStd::string> GetCriticalAssetFilters() const override;
|
||||
};
|
||||
} // namespace MaterialEditor
|
||||
|
||||
+5
-34
@@ -47,7 +47,7 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
namespace ShaderManagementConsole
|
||||
{
|
||||
AZStd::string ShaderManagementConsoleApplication::GetBuildTargetName()
|
||||
AZStd::string ShaderManagementConsoleApplication::GetBuildTargetName() const
|
||||
{
|
||||
#if !defined (LY_CMAKE_TARGET)
|
||||
#error "LY_CMAKE_TARGET must be defined in order to add this source file to a CMake executable target"
|
||||
@@ -100,40 +100,11 @@ namespace ShaderManagementConsole
|
||||
Base::Destroy();
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleApplication::AssetSystemAvailable()
|
||||
AZStd::vector<AZStd::string> ShaderManagementConsoleApplication::GetCriticalAssetFilters() const
|
||||
{
|
||||
// Try connect to AP first before try to launch it manually.
|
||||
bool connected = false;
|
||||
auto ConnectToAssetProcessorWithIdentifier = [&connected](AzFramework::AssetSystem::AssetSystemRequests* assetSystemRequests)
|
||||
{
|
||||
// When the AssetProcessor is already launched it should take less than a second to perform a connection
|
||||
// but when the AssetProcessor needs to be launch it could take up to 15 seconds to have the AssetProcessor initialize
|
||||
// and able to negotiate a connection when running a debug build
|
||||
// and to negotiate a connection
|
||||
|
||||
AzFramework::AssetSystem::ConnectionSettings connectionSettings;
|
||||
AzFramework::AssetSystem::ReadConnectionSettingsFromSettingsRegistry(connectionSettings);
|
||||
connectionSettings.m_connectionDirection = AzFramework::AssetSystem::ConnectionSettings::ConnectionDirection::ConnectToAssetProcessor;
|
||||
connectionSettings.m_connectionIdentifier = "Shader Management Console";
|
||||
connectionSettings.m_loggingCallback = []([[maybe_unused]] AZStd::string_view logData)
|
||||
{
|
||||
AZ_TracePrintf("Shader Management Console", "%.*s", aznumeric_cast<int>(logData.size()), logData.data());
|
||||
};
|
||||
|
||||
connected = assetSystemRequests->EstablishAssetProcessorConnection(connectionSettings);
|
||||
};
|
||||
AzFramework::AssetSystemRequestBus::Broadcast(ConnectToAssetProcessorWithIdentifier);
|
||||
|
||||
if (connected)
|
||||
{
|
||||
// List of common asset filters for things that need to be compiled to run the material editor
|
||||
// Some of these things will not be necessary once we have proper support for queued asset loading and reloading
|
||||
const AZStd::vector<AZStd::string> assetFiltersArray = { "passes/", "config/" };
|
||||
|
||||
CompileCriticalAssets(assetFiltersArray);
|
||||
}
|
||||
|
||||
AzFramework::AssetSystemStatusBus::Handler::BusDisconnect();
|
||||
// List of common asset filters for things that need to be compiled to run the material editor
|
||||
// Some of these things will not be necessary once we have proper support for queued asset loading and reloading
|
||||
return AZStd::vector<AZStd::string>({ "passes/", "config/" });
|
||||
}
|
||||
|
||||
void ShaderManagementConsoleApplication::ProcessCommandLine()
|
||||
|
||||
+2
-6
@@ -43,13 +43,9 @@ namespace ShaderManagementConsole
|
||||
void Destroy() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// AzFramework::AssetSystemStatusBus::Handler overrides...
|
||||
void AssetSystemAvailable() override;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ProcessCommandLine();
|
||||
void StartInternal() override;
|
||||
AZStd::string GetBuildTargetName() override;
|
||||
AZStd::string GetBuildTargetName() const override;
|
||||
AZStd::vector<AZStd::string> GetCriticalAssetFilters() const override;
|
||||
};
|
||||
} // namespace ShaderManagementConsole
|
||||
|
||||
Reference in New Issue
Block a user