Merge branch 'main' into sceneapi_script_autotest

This commit is contained in:
jackalbe
2021-04-13 17:54:57 -05:00
1725 changed files with 35703 additions and 520825 deletions
@@ -22,6 +22,7 @@
#include <AzCore/Module/ModuleManagerBus.h>
#include <AzCore/Slice/SliceSystemComponent.h>
#include <AzCore/std/string/conversions.h>
#include <AzCore/StringFunc/StringFunc.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <AzCore/Utils/Utils.h>
@@ -31,7 +32,6 @@
#include <AzFramework/FileTag/FileTagComponent.h>
#include <AzFramework/Input/System/InputSystemComponent.h>
#include <AzFramework/Platform/PlatformDefaults.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzFramework/Components/AzFrameworkConfigurationSystemComponent.h>
#include <AzToolsFramework/Archive/ArchiveComponent.h>
@@ -66,7 +66,7 @@ namespace AssetBundler
AzToolsFramework::AssetFileInfoListComparison::Reflect(context);
AzToolsFramework::AssetBundleSettings::Reflect(context);
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
[[maybe_unused]] AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
AZ_Assert(fileIO != nullptr, "AZ::IO::FileIOBase must be ready for use.\n");
m_assetSeedManager = AZStd::make_unique<AzToolsFramework::AssetSeedManager>();
@@ -86,7 +86,7 @@ namespace AssetBundler
bool ApplicationManager::Run()
{
const AzFramework::CommandLine* parser = GetCommandLine();
const AZ::CommandLine* parser = GetCommandLine();
bool shouldPrintHelp = ShouldPrintHelp(parser);
@@ -196,7 +196,7 @@ namespace AssetBundler
// Get Generic Command Info
////////////////////////////////////////////////////////////////////////////////////////////
CommandType ApplicationManager::GetCommandType(const AzFramework::CommandLine* parser, [[maybe_unused]] bool suppressErrors)
CommandType ApplicationManager::GetCommandType(const AZ::CommandLine* parser, [[maybe_unused]] bool suppressErrors)
{
// Verify that the user has only typed in one sub-command
size_t numMiscValues = parser->GetNumMiscValues();
@@ -247,12 +247,12 @@ namespace AssetBundler
}
}
bool ApplicationManager::ShouldPrintHelp(const AzFramework::CommandLine* parser)
bool ApplicationManager::ShouldPrintHelp(const AZ::CommandLine* parser)
{
return parser->HasSwitch(AssetBundler::HelpFlag) || parser->HasSwitch(AssetBundler::HelpFlagAlias);
}
bool ApplicationManager::ShouldPrintVerbose(const AzFramework::CommandLine* parser)
bool ApplicationManager::ShouldPrintVerbose(const AZ::CommandLine* parser)
{
return parser->HasSwitch(AssetBundler::VerboseFlag);
}
@@ -368,17 +368,10 @@ namespace AssetBundler
// Store Detailed Command Info
////////////////////////////////////////////////////////////////////////////////////////////
AZ::Outcome<SeedsParams, AZStd::string> ApplicationManager::ParseSeedsCommandData(const AzFramework::CommandLine* parser)
AZ::Outcome<SeedsParams, AZStd::string> ApplicationManager::ParseSeedsCommandData(const AZ::CommandLine* parser)
{
using namespace AzToolsFramework;
auto validateArgsOutcome = ValidateInputArgs(parser, m_allSeedsArgs);
if (!validateArgsOutcome.IsSuccess())
{
OutputHelpSeeds();
return AZ::Failure(validateArgsOutcome.TakeError());
}
SeedsParams params;
params.m_ignoreFileCase = parser->HasSwitch(IgnoreFileCaseFlag);
@@ -467,15 +460,8 @@ namespace AssetBundler
return AZStd::string::format(FailureMessage, arg1, arg2);
}
AZ::Outcome<AssetListsParams, AZStd::string> ApplicationManager::ParseAssetListsCommandData(const AzFramework::CommandLine* parser)
AZ::Outcome<AssetListsParams, AZStd::string> ApplicationManager::ParseAssetListsCommandData(const AZ::CommandLine* parser)
{
auto validateArgsOutcome = ValidateInputArgs(parser, m_allAssetListsArgs);
if (!validateArgsOutcome.IsSuccess())
{
OutputHelpAssetLists();
return AZ::Failure(validateArgsOutcome.TakeError());
}
AssetListsParams params;
// Read in Platform arg
@@ -537,15 +523,8 @@ namespace AssetBundler
return AZ::Success(params);
}
AZ::Outcome<ComparisonRulesParams, AZStd::string> ApplicationManager::ParseComparisonRulesCommandData(const AzFramework::CommandLine* parser)
AZ::Outcome<ComparisonRulesParams, AZStd::string> ApplicationManager::ParseComparisonRulesCommandData(const AZ::CommandLine* parser)
{
auto validateArgsOutcome = ValidateInputArgs(parser, m_allComparisonRulesArgs);
if (!validateArgsOutcome.IsSuccess())
{
OutputHelpComparisonRules();
return AZ::Failure(validateArgsOutcome.TakeError());
}
ScopedTraceHandler traceHandler;
ComparisonRulesParams params;
@@ -572,7 +551,7 @@ namespace AssetBundler
break;
case 1:
params.m_comparisonRulesStepAction = ComparisonRulesStepAction::Add;
params.m_destinationLine = static_cast<size_t>(AzFramework::StringFunc::ToInt(parser->GetSwitchValue(AddComparisonStepArg, 0).c_str()));
params.m_destinationLine = static_cast<size_t>(AZ::StringFunc::ToInt(parser->GetSwitchValue(AddComparisonStepArg, 0).c_str()));
break;
default:
return AZ::Failure(AZStd::string::format("Invalid command: \"--%s\" cannot have more than one input value.", AddComparisonStepArg));
@@ -604,7 +583,7 @@ namespace AssetBundler
}
params.m_comparisonRulesStepAction = ComparisonRulesStepAction::Remove;
params.m_initialLine = static_cast<size_t>(AzFramework::StringFunc::ToInt(parser->GetSwitchValue(RemoveComparisonStepArg, 0).c_str()));
params.m_initialLine = static_cast<size_t>(AZ::StringFunc::ToInt(parser->GetSwitchValue(RemoveComparisonStepArg, 0).c_str()));
}
// Read in Move Comparison Step arg
@@ -625,8 +604,8 @@ namespace AssetBundler
}
params.m_comparisonRulesStepAction = ComparisonRulesStepAction::Move;
params.m_initialLine = static_cast<size_t>(AzFramework::StringFunc::ToInt(parser->GetSwitchValue(MoveComparisonStepArg, 0).c_str()));
params.m_destinationLine = static_cast<size_t>(AzFramework::StringFunc::ToInt(parser->GetSwitchValue(MoveComparisonStepArg, 1).c_str()));
params.m_initialLine = static_cast<size_t>(AZ::StringFunc::ToInt(parser->GetSwitchValue(MoveComparisonStepArg, 0).c_str()));
params.m_destinationLine = static_cast<size_t>(AZ::StringFunc::ToInt(parser->GetSwitchValue(MoveComparisonStepArg, 1).c_str()));
}
// Read in Edit Comparison Step arg
@@ -642,12 +621,12 @@ namespace AssetBundler
if (parser->GetNumSwitchValues(EditComparisonStepArg) != 1)
{
return AZ::Failure(AZStd::string::format(
"Invalid command: \"--%s\" requires exatly one input value (the line number of the Comparison Step you wish to edit)",
"Invalid command: \"--%s\" requires exactly one input value (the line number of the Comparison Step you wish to edit)",
EditComparisonStepArg));
}
params.m_comparisonRulesStepAction = ComparisonRulesStepAction::Edit;
params.m_initialLine = static_cast<size_t>(AzFramework::StringFunc::ToInt(parser->GetSwitchValue(EditComparisonStepArg, 0).c_str()));
params.m_initialLine = static_cast<size_t>(AZ::StringFunc::ToInt(parser->GetSwitchValue(EditComparisonStepArg, 0).c_str()));
// When editing a Comparison Step, we can only accept one input for every value type
auto parseComparisonTypesForEditOutcome = ParseComparisonTypesAndPatternsForEditCommand(parser, params);
@@ -686,7 +665,7 @@ namespace AssetBundler
return AZ::Success(params);
}
AZ::Outcome<void, AZStd::string> ApplicationManager::ParseComparisonTypesAndPatterns(const AzFramework::CommandLine* parser, ComparisonRulesParams& params)
AZ::Outcome<void, AZStd::string> ApplicationManager::ParseComparisonTypesAndPatterns(const AZ::CommandLine* parser, ComparisonRulesParams& params)
{
int filePatternsConsumed = 0;
size_t numComparisonTypes = parser->GetNumSwitchValues(ComparisonTypeArg);
@@ -770,7 +749,7 @@ namespace AssetBundler
return AZ::Success();
}
AZ::Outcome<void, AZStd::string> ApplicationManager::ParseComparisonTypesAndPatternsForEditCommand(const AzFramework::CommandLine* parser, ComparisonRulesParams& params)
AZ::Outcome<void, AZStd::string> ApplicationManager::ParseComparisonTypesAndPatternsForEditCommand(const AZ::CommandLine* parser, ComparisonRulesParams& params)
{
if (parser->HasSwitch(ComparisonTypeArg))
{
@@ -855,7 +834,7 @@ namespace AssetBundler
return AZ::Success();
}
AZ::Outcome<void, AZStd::string> ApplicationManager::ParseComparisonRulesFirstAndSecondInputArgs(const AzFramework::CommandLine* parser, ComparisonRulesParams& params)
AZ::Outcome<void, AZStd::string> ApplicationManager::ParseComparisonRulesFirstAndSecondInputArgs(const AZ::CommandLine* parser, ComparisonRulesParams& params)
{
if (params.m_comparisonTypeList.size() > 1 && (parser->HasSwitch(ComparisonFirstInputArg) || parser->HasSwitch(ComparisonSecondInputArg)))
{
@@ -926,15 +905,8 @@ namespace AssetBundler
return AZ::Success();
}
AZ::Outcome<ComparisonParams, AZStd::string> ApplicationManager::ParseCompareCommandData(const AzFramework::CommandLine* parser)
AZ::Outcome<ComparisonParams, AZStd::string> ApplicationManager::ParseCompareCommandData(const AZ::CommandLine* parser)
{
auto validateArgsOutcome = ValidateInputArgs(parser, m_allCompareArgs);
if (!validateArgsOutcome.IsSuccess())
{
OutputHelpCompare();
return AZ::Failure(validateArgsOutcome.TakeError());
}
ComparisonParams params;
// Read in Platform arg
@@ -1024,15 +996,8 @@ namespace AssetBundler
return AZ::Success(params);
}
AZ::Outcome<BundleSettingsParams, AZStd::string> ApplicationManager::ParseBundleSettingsCommandData(const AzFramework::CommandLine* parser)
AZ::Outcome<BundleSettingsParams, AZStd::string> ApplicationManager::ParseBundleSettingsCommandData(const AZ::CommandLine* parser)
{
auto validateArgsOutcome = ValidateInputArgs(parser, m_allBundleSettingsArgs);
if (!validateArgsOutcome.IsSuccess())
{
OutputHelpBundleSettings();
return AZ::Failure(validateArgsOutcome.TakeError());
}
BundleSettingsParams params;
// Read in Platform arg
@@ -1099,7 +1064,7 @@ namespace AssetBundler
return AZ::Success(params);
}
AZ::Outcome<BundlesParamsList, AZStd::string> ApplicationManager::ParseBundleSettingsAndOverrides(const AzFramework::CommandLine* parser, const char* commandName)
AZ::Outcome<BundlesParamsList, AZStd::string> ApplicationManager::ParseBundleSettingsAndOverrides(const AZ::CommandLine* parser, const char* commandName)
{
// Read in Bundle Settings File args
auto bundleSettingsOutcome = GetArgsList<FilePath>(parser, BundleSettingsFileArg, commandName);
@@ -1235,15 +1200,8 @@ namespace AssetBundler
return AZ::Success(bundleParamsList);
}
AZ::Outcome<BundlesParamsList, AZStd::string> ApplicationManager::ParseBundlesCommandData(const AzFramework::CommandLine* parser)
AZ::Outcome<BundlesParamsList, AZStd::string> ApplicationManager::ParseBundlesCommandData(const AZ::CommandLine* parser)
{
auto validateArgsOutcome = ValidateInputArgs(parser, m_allBundlesArgs);
if (!validateArgsOutcome.IsSuccess())
{
OutputHelpBundles();
return AZ::Failure(validateArgsOutcome.TakeError());
}
auto parseSettingsOutcome = ParseBundleSettingsAndOverrides(parser, BundlesCommand);
if (!parseSettingsOutcome.IsSuccess())
{
@@ -1253,16 +1211,8 @@ namespace AssetBundler
return AZ::Success(parseSettingsOutcome.TakeValue());
}
AZ::Outcome<BundleSeedParams, AZStd::string> ApplicationManager::ParseBundleSeedCommandData(const AzFramework::CommandLine* parser)
AZ::Outcome<BundleSeedParams, AZStd::string> ApplicationManager::ParseBundleSeedCommandData(const AZ::CommandLine* parser)
{
auto validateArgsOutcome = ValidateInputArgs(parser, m_allBundleSeedArgs);
if (!validateArgsOutcome.IsSuccess())
{
OutputHelpBundles();
return AZ::Failure(validateArgsOutcome.TakeError());
}
BundleSeedParams params;
params.m_addSeedList = GetAddSeedArgList(parser);
@@ -1278,7 +1228,7 @@ namespace AssetBundler
return AZ::Success(params);
}
AZ::Outcome<void, AZStd::string> ApplicationManager::ValidateInputArgs(const AzFramework::CommandLine* parser, const AZStd::vector<const char*>& validArgList)
AZ::Outcome<void, AZStd::string> ApplicationManager::ValidateInputArgs(const AZ::CommandLine* parser, const AZStd::vector<const char*>& validArgList)
{
for (const auto& paramInfo : *parser)
{
@@ -1291,7 +1241,7 @@ namespace AssetBundler
for (const auto& validArg : validArgList)
{
if (AzFramework::StringFunc::Equal(paramInfo.m_option, validArg))
if (AZ::StringFunc::Equal(paramInfo.m_option, validArg))
{
isValidArg = true;
break;
@@ -1300,14 +1250,14 @@ namespace AssetBundler
if (!isValidArg)
{
return AZ::Failure(AZStd::string::format("Invalid command: \"--%s\" is not a valid argument for this sub-command.", paramInfo.m_option.c_str()));
return AZ::Failure(AZStd::string::format("Unknown argument: \"--%s\" is not an unknown argument for this sub-command.", paramInfo.m_option.c_str()));
}
}
return AZ::Success();
}
AZ::Outcome<AZStd::string, AZStd::string> ApplicationManager::GetFilePathArg(const AzFramework::CommandLine* parser, const char* argName, const char* subCommandName, bool isRequired)
AZ::Outcome<AZStd::string, AZStd::string> ApplicationManager::GetFilePathArg(const AZ::CommandLine* parser, const char* argName, const char* subCommandName, bool isRequired)
{
if (!parser->HasSwitch(argName))
{
@@ -1328,7 +1278,7 @@ namespace AssetBundler
template <typename T>
AZ::Outcome<AZStd::vector<T>, AZStd::string> ApplicationManager::GetArgsList(const AzFramework::CommandLine* parser, const char* argName, const char* subCommandName, bool isRequired)
AZ::Outcome<AZStd::vector<T>, AZStd::string> ApplicationManager::GetArgsList(const AZ::CommandLine* parser, const char* argName, const char* subCommandName, bool isRequired)
{
AZStd::vector<T> args;
@@ -1352,7 +1302,7 @@ namespace AssetBundler
return AZ::Success(args);
}
AZ::Outcome<AzFramework::PlatformFlags, AZStd::string> ApplicationManager::GetPlatformArg(const AzFramework::CommandLine* parser)
AZ::Outcome<AzFramework::PlatformFlags, AZStd::string> ApplicationManager::GetPlatformArg(const AZ::CommandLine* parser)
{
using namespace AzFramework;
PlatformFlags platform = AzFramework::PlatformFlags::Platform_NONE;
@@ -1395,7 +1345,7 @@ namespace AssetBundler
return platformFlags;
}
AZStd::vector<AZStd::string> ApplicationManager::GetAddSeedArgList(const AzFramework::CommandLine* parser)
AZStd::vector<AZStd::string> ApplicationManager::GetAddSeedArgList(const AZ::CommandLine* parser)
{
AZStd::vector<AZStd::string> addSeedList;
size_t numAddSeedArgs = parser->GetNumSwitchValues(AddSeedArg);
@@ -1406,7 +1356,7 @@ namespace AssetBundler
return addSeedList;
}
AZStd::vector<AZStd::string> ApplicationManager::GetSkipArgList(const AzFramework::CommandLine* parser)
AZStd::vector<AZStd::string> ApplicationManager::GetSkipArgList(const AZ::CommandLine* parser)
{
AZStd::vector<AZStd::string> skipList;
size_t numArgs = parser->GetNumSwitchValues(SkipArg);
@@ -1920,10 +1870,12 @@ namespace AssetBundler
AZStd::vector<AZStd::string> destructiveOverwriteFilePaths = comparisonOperations.GetDestructiveOverwriteFilePaths();
if (!destructiveOverwriteFilePaths.empty())
{
#if defined(AZ_ENABLE_TRACING)
for (const AZStd::string& path : destructiveOverwriteFilePaths)
{
AZ_Error(AssetBundler::AppWindowName, false, "Asset List file ( %s ) already exists, running this command would perform a destructive overwrite.", path.c_str());
}
#endif
AZ_Printf(AssetBundler::AppWindowName, "\nRun your command again with the ( --%s ) arg if you want to save over the existing file.\n\n", AllowOverwritesFlag)
hasError = true;
continue;
@@ -2028,7 +1980,7 @@ namespace AssetBundler
AZStd::string assetListFilePath = FilePath(params.m_assetListFile.AbsolutePath(), platformName).AbsolutePath();
if (!assetListFilePath.empty())
{
if (!AzFramework::StringFunc::EndsWith(assetListFilePath, AssetSeedManager::GetAssetListFileExtension()))
if (!AZ::StringFunc::EndsWith(assetListFilePath, AssetSeedManager::GetAssetListFileExtension()))
{
AZ_Error(AppWindowName, false, "Cannot set Asset List file to ( %s ): file extension must be ( %s ).", assetListFilePath.c_str(), AssetSeedManager::GetAssetListFileExtension());
return false;
@@ -2041,7 +1993,7 @@ namespace AssetBundler
}
// Make the path relative to the engine root folder before saving
AzFramework::StringFunc::Replace(assetListFilePath, GetEngineRoot(), "");
AZ::StringFunc::Replace(assetListFilePath, GetEngineRoot(), "");
bundleSettings.m_assetFileInfoListPath = assetListFilePath;
}
@@ -2050,14 +2002,14 @@ namespace AssetBundler
AZStd::string outputBundlePath = FilePath(params.m_outputBundlePath.AbsolutePath(), platformName).AbsolutePath();
if (!outputBundlePath.empty())
{
if (!AzFramework::StringFunc::EndsWith(outputBundlePath, AssetBundleSettings::GetBundleFileExtension()))
if (!AZ::StringFunc::EndsWith(outputBundlePath, AssetBundleSettings::GetBundleFileExtension()))
{
AZ_Error(AppWindowName, false, "Cannot set Output Bundle Path to ( %s ): file extension must be ( %s ).", outputBundlePath.c_str(), AssetBundleSettings::GetBundleFileExtension());
return false;
}
// Make the path relative to the engine root folder before saving
AzFramework::StringFunc::Replace(outputBundlePath, GetEngineRoot(), "");
AZ::StringFunc::Replace(outputBundlePath, GetEngineRoot(), "");
bundleSettings.m_bundleFilePath = outputBundlePath;
}
@@ -2341,7 +2293,7 @@ namespace AssetBundler
AZStd::string platformSpecificAssetCatalogPath;
if (assetCatalogFile.empty())
{
AzFramework::StringFunc::Path::ConstructFull(
AZ::StringFunc::Path::ConstructFull(
PlatformAddressedAssetCatalog::GetAssetRootForPlatform(platformId).c_str(),
AssetBundler::AssetCatalogFilename,
platformSpecificAssetCatalogPath);
@@ -2489,7 +2441,7 @@ namespace AssetBundler
if (params.m_generateDebugFile)
{
debugListFileAbsolutePath = assetListFileAbsolutePath;
AzFramework::StringFunc::Path::ReplaceExtension(debugListFileAbsolutePath, AssetFileDebugInfoList::GetAssetListDebugFileExtension());
AZ::StringFunc::Path::ReplaceExtension(debugListFileAbsolutePath, AssetFileDebugInfoList::GetAssetListDebugFileExtension());
AZ_TracePrintf(AssetBundler::AppWindowName, "Saving Asset List Debug file to ( %s )...\n", debugListFileAbsolutePath.c_str());
}
@@ -2706,7 +2658,7 @@ namespace AssetBundler
AZ_Printf(AppWindowName, " --%-25s-Outputs the contents of the Seed List file after performing any specified operations.\n", PrintFlag);
AZ_Printf(AppWindowName, " --%-25s-Specifies the platform(s) referenced by all Seed operations.\n", PlatformArg);
AZ_Printf(AppWindowName, "%-31s---Requires an existing cache of assets for the input platform(s).\n", "");
AZ_Printf(AppWindowName, "%-31s---Defaults to all enabled platforms. Platforms can be changed by modifying AssetProcessorPlatformConfig.ini.\n", "");
AZ_Printf(AppWindowName, "%-31s---Defaults to all enabled platforms. Platforms can be changed by modifying AssetProcessorPlatformConfig.setreg.\n", "");
AZ_Printf(AppWindowName, " --%-25s-Updates the path hints stored in the Seed List file.\n", UpdateSeedPathArg);
AZ_Printf(AppWindowName, " --%-25s-Removes the path hints stored in the Seed List file.\n", RemoveSeedPathArg);
AZ_Printf(AppWindowName, " --%-25s-Allows input file path to still match if the file path case is different than on disk.\n", IgnoreFileCaseFlag);
@@ -2729,7 +2681,7 @@ namespace AssetBundler
AZ_Printf(AppWindowName, "%-31s---This will include Seed List files for the Lumberyard Engine and all enabled Gems.\n", "");
AZ_Printf(AppWindowName, " --%-25s-Specifies the platform(s) to generate an Asset List file for.\n", PlatformArg);
AZ_Printf(AppWindowName, "%-31s---Requires an existing cache of assets for the input platform(s).\n", "");
AZ_Printf(AppWindowName, "%-31s---Defaults to all enabled platforms. Platforms can be changed by modifying AssetProcessorPlatformConfig.ini.\n", "");
AZ_Printf(AppWindowName, "%-31s---Defaults to all enabled platforms. Platforms can be changed by modifying AssetProcessorPlatformConfig.setreg.\n", "");
AZ_Printf(AppWindowName, " --%-25s-[Testing] Specifies the Asset Catalog file referenced by all Asset List operations.\n", AssetCatalogFileArg);
AZ_Printf(AppWindowName, "%-31s---Designed to be used in Unit Tests.\n", "");
AZ_Printf(AppWindowName, " --%-25s-Outputs the contents of the Asset List file after adding any specified seed files.\n", PrintFlag);
@@ -2793,7 +2745,7 @@ namespace AssetBundler
AZ_Printf(AppWindowName, "%-31s---Leave list blank to just print the final comparison result.\n", "");
AZ_Printf(AppWindowName, " --%-25s-Specifies the platform(s) referenced when determining which Asset List files to compare.\n", PlatformArg);
AZ_Printf(AppWindowName, "%-31s---All input Asset List files must exist for all specified platforms\n", "");
AZ_Printf(AppWindowName, "%-31s---Defaults to all enabled platforms. Platforms can be changed by modifying AssetProcessorPlatformConfig.ini.\n", "");
AZ_Printf(AppWindowName, "%-31s---Defaults to all enabled platforms. Platforms can be changed by modifying AssetProcessorPlatformConfig.setreg.\n", "");
AZ_Printf(AppWindowName, " --%-25s-Allow destructive overwrites of files. Include this arg in automation.\n", AllowOverwritesFlag);
AZ_Printf(AppWindowName, " --%-25s-Specifies the game project to use rather than the current default project set in bootstrap.cfg's project_path.\n", ProjectArg);
}
@@ -2809,7 +2761,7 @@ namespace AssetBundler
AZ_Printf(AppWindowName, " --%-25s-Sets the maximum size for a single Bundle (in MB). Default size is (%i MB).\n", MaxBundleSizeArg, AssetBundleSettings::GetMaxBundleSizeInMB());
AZ_Printf(AppWindowName, "%-31s---Bundles larger than this limit will be divided into a series of smaller Bundles and named accordingly.\n", "");
AZ_Printf(AppWindowName, " --%-25s-Specifies the platform(s) referenced by all Bundle Settings operations.\n", PlatformArg);
AZ_Printf(AppWindowName, "%-31s---Defaults to all enabled platforms. Platforms can be changed by modifying AssetProcessorPlatformConfig.ini.\n", "");
AZ_Printf(AppWindowName, "%-31s---Defaults to all enabled platforms. Platforms can be changed by modifying AssetProcessorPlatformConfig.setreg.\n", "");
AZ_Printf(AppWindowName, " --%-25s-Outputs the contents of the Bundle Settings file after modifying any specified values.\n", PrintFlag);
AZ_Printf(AppWindowName, " --%-25s-Specifies the game project to use rather than the current default project set in bootstrap.cfg's project_path.\n", ProjectArg);
}
+21 -42
View File
@@ -47,7 +47,7 @@ namespace AssetBundler
const char* AssetCatalogFileArg = "overrideAssetCatalogFile";
const char* AllowOverwritesFlag = "allowOverwrites";
const char* IgnoreFileCaseFlag = "ignoreFileCase";
const char* ProjectArg = "project";
const char* ProjectArg = "project-path";
// Seeds
const char* SeedsCommand = "seeds";
@@ -607,9 +607,9 @@ namespace AssetBundler
if (!filePath.empty())
{
m_validPath = true;
m_originalPath = m_absolutePath = filePath;
AzFramework::StringFunc::Path::Normalize(m_originalPath);
ComputeAbsolutePath(m_absolutePath, platform, checkFileCase, ignoreFileCase);
m_absolutePath = AZ::IO::PathView(filePath).LexicallyNormal();
m_originalPath = m_absolutePath;
ComputeAbsolutePath(platform, checkFileCase, ignoreFileCase);
}
}
@@ -621,12 +621,12 @@ namespace AssetBundler
const AZStd::string& FilePath::AbsolutePath() const
{
return m_absolutePath;
return m_absolutePath.Native();
}
const AZStd::string& FilePath::OriginalPath() const
{
return m_originalPath;
return m_originalPath.Native();
}
bool FilePath::IsValid() const
@@ -639,60 +639,37 @@ namespace AssetBundler
return m_errorString;
}
void FilePath::ComputeAbsolutePath(AZStd::string& filePath, const AZStd::string& platformIdentifier, bool checkFileCase, bool ignoreFileCase)
void FilePath::ComputeAbsolutePath(const AZStd::string& platformIdentifier, bool checkFileCase, bool ignoreFileCase)
{
if (AzToolsFramework::AssetFileInfoListComparison::IsTokenFile(filePath))
if (AzToolsFramework::AssetFileInfoListComparison::IsTokenFile(m_absolutePath.Native()))
{
return;
}
if (!platformIdentifier.empty())
{
AssetBundler::AddPlatformIdentifier(filePath, platformIdentifier);
}
const char* appRoot = nullptr;
AzFramework::ApplicationRequests::Bus::BroadcastResult(appRoot, &AzFramework::ApplicationRequests::GetAppRoot);
#if AZ_TRAIT_OS_USE_WINDOWS_FILE_PATHS
AZStd::string driveString;
AzFramework::StringFunc::Path::GetDrive(appRoot, driveString);
if (AzFramework::StringFunc::FirstCharacter(filePath.c_str()) == AZ_CORRECT_FILESYSTEM_SEPARATOR)
{
AzFramework::StringFunc::Path::ConstructFull(driveString.c_str(), filePath.c_str(), filePath, true);
}
#endif
if (!AzFramework::StringFunc::Path::IsRelative(filePath.c_str()))
{
// it is already an absolute path
AzFramework::StringFunc::Path::Normalize(filePath);
}
else
{
AzFramework::StringFunc::Path::ConstructFull(appRoot, m_absolutePath.c_str(), m_absolutePath, true);
AssetBundler::AddPlatformIdentifier(m_absolutePath.Native(), platformIdentifier);
}
AZ::IO::Path enginePath = AZ::IO::PathView(AZ::Utils::GetEnginePath());
m_absolutePath = enginePath / m_absolutePath;
if (checkFileCase)
{
QDir rootDir(appRoot);
QString relFilePath = rootDir.relativeFilePath(m_absolutePath.c_str());
if (AzToolsFramework::AssetUtils::UpdateFilePathToCorrectCase(QString(appRoot), relFilePath))
AZ::IO::Path relFilePath = m_absolutePath.LexicallyProximate(enginePath);
if (AzToolsFramework::AssetUtils::UpdateFilePathToCorrectCase(enginePath.Native(), relFilePath.Native()))
{
if (ignoreFileCase)
{
AzFramework::StringFunc::Path::ConstructFull(appRoot, relFilePath.toUtf8().data(), m_absolutePath, true);
m_absolutePath = (enginePath / relFilePath).String();
}
else
{
AZStd::string absfilePath(rootDir.filePath(relFilePath).toUtf8().data());
AzFramework::StringFunc::Path::Normalize(absfilePath);
if (!AZ::StringFunc::Equal(absfilePath.c_str(), m_absolutePath.c_str(), true))
AZ::IO::Path absfilePath = (enginePath / relFilePath).LexicallyNormal();
if (absfilePath != AZ::IO::PathView(m_absolutePath))
{
m_errorString = AZStd::string::format("File case mismatch, file ( %s ) does not exist on disk, did you mean file ( %s ). \
Please run the command again with the correct file path or use ( --%s ) arg if you want to allow case insensitive file match.\n",
m_absolutePath.c_str(), rootDir.filePath(relFilePath.toUtf8().data()).toUtf8().data(), IgnoreFileCaseFlag);
m_errorString = AZStd::string::format("File case mismatch, file ( %s ) does not exist on disk, did you mean file ( %s )."
" Please run the command again with the correct file path or use ( --%s ) arg if you want to allow case insensitive file match.\n",
m_absolutePath.c_str(), absfilePath.c_str(), IgnoreFileCaseFlag);
m_validPath = false;
}
}
@@ -731,10 +708,12 @@ m_absolutePath.c_str(), rootDir.filePath(relFilePath.toUtf8().data()).toUtf8().d
void ScopedTraceHandler::ReportErrors()
{
m_reportingError = true;
#if defined(AZ_ENABLE_TRACING)
for (const AZStd::string& error : m_errors)
{
AZ_Error(AssetBundler::AppWindowName, false, error.c_str());
}
#endif
ClearErrors();
m_reportingError = false;
+4 -4
View File
@@ -14,7 +14,7 @@
#include <AzCore/std/string/string.h>
#include <AzCore/Debug/TraceMessageBus.h>
#include <AzCore/IO/SystemFile.h> //AZ_MAX_PATH_LEN
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Outcome/Outcome.h>
#include <AzFramework/Platform/PlatformDefaults.h>
#include <AzToolsFramework/Asset/AssetBundler.h>
@@ -246,10 +246,10 @@ namespace AssetBundler
AZStd::string ErrorString() const;
bool IsValid() const;
private:
void ComputeAbsolutePath(AZStd::string& filePath, const AZStd::string& platformIdentifier, bool checkFileCase, bool ignoreFileCase);
void ComputeAbsolutePath(const AZStd::string& platformIdentifier, bool checkFileCase, bool ignoreFileCase);
AZStd::string m_absolutePath;
AZStd::string m_originalPath;
AZ::IO::Path m_absolutePath;
AZ::IO::Path m_originalPath;
AZStd::string m_errorString;
bool m_validPath = false;
};
+51 -35
View File
@@ -12,8 +12,9 @@
#include <AzFramework/API/ApplicationAPI.h>
#include <source/utils/utils.h>
#include <AzCore/Settings/SettingsRegistryImpl.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <Utils/Utils.h>
#include <AzFramework/IO/LocalFileIO.h>
@@ -36,10 +37,27 @@ namespace AssetBundler
AZ::IO::FileIOBase::SetInstance(nullptr);
AZ::IO::FileIOBase::SetInstance(m_localFileIO);
m_tempDir = new UnitTest::ScopedTemporaryDirectory();
auto settingsRegistry = AZ::SettingsRegistry::Get();
if (settingsRegistry == nullptr)
{
m_settingsRegistry = AZStd::make_unique<AZ::SettingsRegistryImpl>();
settingsRegistry = m_settingsRegistry.get();
AZ::SettingsRegistry::Register(settingsRegistry);
}
settingsRegistry->Get(m_oldEngineRoot.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
settingsRegistry->Set(AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder, m_tempDir->GetDirectory());
}
void TearDown() override
{
// Reset Engine Path if there was an existing Settings Registry from before
auto settingsRegistry = AZ::SettingsRegistry::Get();
settingsRegistry->Set(AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder, m_oldEngineRoot.Native());
if(settingsRegistry == m_settingsRegistry.get())
{
AZ::SettingsRegistry::Unregister(settingsRegistry);
m_settingsRegistry.reset();
}
delete m_tempDir;
AZ::IO::FileIOBase::SetInstance(nullptr);
delete m_localFileIO;
@@ -53,7 +71,7 @@ namespace AssetBundler
void NormalizePathKeepCase(AZStd::string& /*path*/) override {}
void CalculateBranchTokenForEngineRoot(AZStd::string& /*token*/) const override {}
const char* GetAppRoot() const override
const char* GetEngineRoot() const override
{
return m_tempDir->GetDirectory();
}
@@ -61,56 +79,55 @@ namespace AssetBundler
AZ::IO::FileIOBase* m_priorFileIO = nullptr;
AZ::IO::FileIOBase* m_localFileIO = nullptr;
UnitTest::ScopedTemporaryDirectory* m_tempDir = nullptr;
AZStd::unique_ptr<AZ::SettingsRegistryInterface> m_settingsRegistry;
AZ::IO::Path m_oldEngineRoot;
};
TEST_F(MockUtilsTest, DISABLED_TestFilePath_StartsWithAFileSeparator_Valid)
{
AZStd::string relFilePath = "Foo/foo.xml";
AzFramework::StringFunc::Prepend(relFilePath, AZ_CORRECT_FILESYSTEM_SEPARATOR);
AZStd::string absoluteFilePath;
#if AZ_TRAIT_OS_USE_WINDOWS_FILE_PATHS
AZStd::string driveString;
AzFramework::StringFunc::Path::GetDrive(GetAppRoot(), driveString);
AzFramework::StringFunc::Path::ConstructFull(driveString.c_str(), relFilePath.c_str(), absoluteFilePath, true);
#else
absoluteFilePath = relFilePath;
#endif
FilePath filePath(relFilePath);
AZ::IO::Path relFilePath = "Foo/foo.xml";
AZ::IO::Path absoluteFilePath = AZ::IO::PathView(GetEngineRoot()).RootPath();
absoluteFilePath /= relFilePath;
absoluteFilePath = absoluteFilePath.LexicallyNormal();
FilePath filePath(relFilePath.Native());
EXPECT_STREQ(filePath.AbsolutePath().c_str(), absoluteFilePath.c_str());
}
TEST_F(MockUtilsTest, TestFilePath_RelativePath_Valid)
{
AZStd::string relFilePath = "Foo\\foo.xml";
AZStd::string absoluteFilePath;
AzFramework::StringFunc::Path::ConstructFull(GetAppRoot(), relFilePath.c_str(), absoluteFilePath, true);
FilePath filePath(relFilePath);
EXPECT_EQ(filePath.AbsolutePath(), absoluteFilePath);
AZ::IO::Path relFilePath = "Foo\\foo.xml";
AZ::IO::Path absoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / relFilePath).LexicallyNormal();
FilePath filePath(relFilePath.Native());
EXPECT_EQ(AZ::IO::PathView{ filePath.AbsolutePath() }, absoluteFilePath);
}
#if !AZ_TRAIT_USE_WINDOWS_FILE_API
// When using Windows file API the the AZ::IO::Path comparisons are case insensitive
TEST_F(MockUtilsTest, TestFilePath_CasingMismatch_Error_valid)
{
AZStd::string relFilePath = "Foo\\Foo.xml";
AZStd::string wrongCaseRelFilePath = "Foo\\foo.xml";
AZStd::string correctAbsoluteFilePath;
AZStd::string wrongCaseAbsoluteFilePath;
AzFramework::StringFunc::Path::ConstructFull(GetAppRoot(), relFilePath.c_str(), correctAbsoluteFilePath, true);
AzFramework::StringFunc::Path::ConstructFull(GetAppRoot(), wrongCaseRelFilePath.c_str(), wrongCaseAbsoluteFilePath, true);
AZ::IO::Path relFilePath = "Foo\\Foo.xml";
AZ::IO::Path wrongCaseRelFilePath = "Foo\\foo.xml";
AZ::IO::Path correctAbsoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / relFilePath).LexicallyNormal();
AZ::IO::Path wrongCaseAbsoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / wrongCaseRelFilePath).LexicallyNormal();
AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle;
AZ::IO::FileIOBase::GetInstance()->Open(correctAbsoluteFilePath.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeCreatePath, fileHandle);
FilePath filePath(wrongCaseAbsoluteFilePath, true, false);
FilePath filePath(wrongCaseAbsoluteFilePath.Native(), true, false);
EXPECT_FALSE(filePath.IsValid());
EXPECT_TRUE(filePath.ErrorString().find("File case mismatch") != AZStd::string::npos);
EXPECT_TRUE(filePath.ErrorString().contains("File case mismatch"));
}
#endif
TEST_F(MockUtilsTest, TestFilePath_NoFileExists_NoError_valid)
{
AZStd::string relFilePath = "Foo\\Foo.xml";
AZStd::string absoluteFilePath;
AzFramework::StringFunc::Path::ConstructFull(GetAppRoot(), relFilePath.c_str(), absoluteFilePath, true);
FilePath filePath(absoluteFilePath, true, false);
AZ::IO::Path relFilePath = "Foo\\Foo.xml";
AZ::IO::Path absoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / relFilePath).LexicallyNormal();
FilePath filePath(absoluteFilePath.Native(), true, false);
EXPECT_TRUE(filePath.IsValid());
EXPECT_TRUE(filePath.ErrorString().empty());
}
@@ -119,13 +136,12 @@ namespace AssetBundler
{
AZStd::string relFilePath = "Foo\\Foo.xml";
AZStd::string wrongCaseRelFilePath = "Foo\\foo.xml";
AZStd::string correctAbsoluteFilePath;
AZStd::string wrongCaseAbsoluteFilePath;
AzFramework::StringFunc::Path::ConstructFull(GetAppRoot(), relFilePath.c_str(), correctAbsoluteFilePath, true);
AzFramework::StringFunc::Path::ConstructFull(GetAppRoot(), wrongCaseRelFilePath.c_str(), wrongCaseAbsoluteFilePath, true);
AZ::IO::Path correctAbsoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / relFilePath).LexicallyNormal();
AZ::IO::Path wrongCaseAbsoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / wrongCaseRelFilePath).LexicallyNormal();
AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle;
AZ::IO::FileIOBase::GetInstance()->Open(correctAbsoluteFilePath.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeCreatePath, fileHandle);
FilePath filePath(wrongCaseAbsoluteFilePath, true, true);
FilePath filePath(wrongCaseAbsoluteFilePath.Native(), true, true);
EXPECT_TRUE(filePath.IsValid());
EXPECT_STREQ(filePath.AbsolutePath().c_str(), correctAbsoluteFilePath.c_str());
}
+1 -3
View File
@@ -18,8 +18,6 @@ endif()
add_subdirectory(AssetBuilderSDK)
add_subdirectory(AssetBuilder)
include(${CMAKE_CURRENT_SOURCE_DIR}/Platform/${PAL_PLATFORM_NAME}/PAL_${PAL_PLATFORM_NAME_LOWERCASE}.cmake)
ly_add_target(
NAME AssetProcessor.Static STATIC
NAMESPACE AZ
@@ -63,7 +61,7 @@ ly_add_source_properties(
)
ly_add_target(
NAME AssetProcessor ${PAL_TRAIT_BUILD_ASSETPROCESSOR_APPLICATION_TYPE}
NAME AssetProcessor APPLICATION
NAMESPACE AZ
AUTOMOC
AUTOUIC
@@ -1,13 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set (PAL_TRAIT_BUILD_ASSETPROCESSOR_APPLICATION_TYPE APPLICATION)
@@ -1,13 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set (PAL_TRAIT_BUILD_ASSETPROCESSOR_APPLICATION_TYPE APPLICATION)
@@ -1,13 +0,0 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set (PAL_TRAIT_BUILD_ASSETPROCESSOR_APPLICATION_TYPE APPLICATION)
@@ -2261,8 +2261,6 @@ namespace AssetProcessor
{
// note, intentional scope created for the statement finalizer
const char* statementToUse = wasAlreadyInDatabase ? UPDATE_PRODUCT : INSERT_PRODUCT;
StatementAutoFinalizer autoFinalizer;
if (wasAlreadyInDatabase)
{
@@ -2285,7 +2283,7 @@ namespace AssetProcessor
if(statement->Step() == Statement::SqlError)
{
AZ_Error(LOG_NAME, false, "Failed to execute the %s statement", statementToUse);
AZ_Error(LOG_NAME, false, "Failed to execute the %s statement", wasAlreadyInDatabase ? UPDATE_PRODUCT : INSERT_PRODUCT);
return false;
}
@@ -36,7 +36,7 @@ namespace AssetProcessor
m_platforms.push_back(QString::fromUtf8(info.m_identifier.c_str()));
}
bool computedCacheRoot = AssetUtilities::ComputeProjectCacheRoot(m_cacheRoot);
[[maybe_unused]] bool computedCacheRoot = AssetUtilities::ComputeProjectCacheRoot(m_cacheRoot);
AZ_Assert(computedCacheRoot, "Could not compute cache root for AssetCatalog");
// save 30mb for this. Really large projects do get this big (and bigger)
@@ -341,10 +341,10 @@ namespace AssetProcessor
{
auto settingsRegistry = AZ::SettingsRegistry::Get();
AZ::SettingsRegistryInterface::FixedValueString cacheRootFolder;
settingsRegistry->Get(cacheRootFolder, AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder);
settingsRegistry->Get(cacheRootFolder, AZ::SettingsRegistryMergeUtils::FilePathKey_CacheProjectRootFolder);
QString tempRegistryFile = QString("%1/%2").arg(workSpace).arg("assetcatalog.xml.tmp");
QString platformCacheDir = QString::fromUtf8(cacheRootFolder.c_str(), aznumeric_cast<int>(cacheRootFolder.size()));
QString platformCacheDir = QString("%1/%2").arg(cacheRootFolder.c_str()).arg(platform);
QString actualRegistryFile = QString("%1/%2").arg(platformCacheDir).arg("assetcatalog.xml");
AZ_TracePrintf(AssetProcessor::DebugChannel, "Creating asset catalog: %s --> %s\n", tempRegistryFile.toUtf8().constData(), actualRegistryFile.toUtf8().constData());
@@ -359,7 +359,7 @@ namespace AssetProcessor
if (!registryDir.exists())
{
QString absPath = registryDir.absolutePath();
bool makeDirResult = AZ::IO::SystemFile::CreateDir(absPath.toUtf8().constData());
[[maybe_unused]] bool makeDirResult = AZ::IO::SystemFile::CreateDir(absPath.toUtf8().constData());
AZ_Warning(AssetProcessor::ConsoleChannel, makeDirResult, "Failed create folder %s", platformCacheDir.toUtf8().constData());
}
@@ -739,8 +739,6 @@ namespace AssetProcessor
QMutexLocker locker(&m_registriesMutex);
const auto& productDependencies = m_registries[platform].GetAssetDependencies(id);
auto itr = m_registries[platform].m_assetDependencies.find(id);
if (itr == m_registries[platform].m_assetDependencies.end())
@@ -284,7 +284,7 @@ namespace AssetProcessor
for (const auto& settingsKey : settingsToCopy)
{
AZ::SettingsRegistryInterface::FixedValueString settingsValue;
bool settingsCopied = settingsRegistry->Get(settingsValue, settingsKey)
[[maybe_unused]] bool settingsCopied = settingsRegistry->Get(settingsValue, settingsKey)
&& registry.Set(settingsKey, settingsValue);
AZ_Warning("Settings Registry Builder", settingsCopied, "Unable to copy setting %s from AssetProcessor settings registry"
" to local settings registry", settingsKey.c_str());
@@ -150,7 +150,7 @@ namespace AssetProcessor
return true;
}
bool NativeLegacyRCCompiler::Execute(const QString& inputFile, const QString& watchFolder, const QString& platformIdentifier,
bool NativeLegacyRCCompiler::Execute(const QString& inputFile, const QString& watchFolder, const QString& platformIdentifier,
const QString& params, const QString& dest, const AssetBuilderSDK::JobCancelListener* jobCancelListener, Result& result) const
{
if (!this->m_resourceCompilerInitialized)
@@ -177,7 +177,7 @@ namespace AssetProcessor
AZ_TracePrintf("RC Builder", "Executing RC.EXE: '%s' ...\n", processLaunchInfo.m_commandlineParameters.c_str());
AZ_TracePrintf("Rc Builder", "Executing RC.EXE with working directory: '%s' ...\n", processLaunchInfo.m_workingDirectory.c_str());
AzFramework::ProcessWatcher* watcher = AzFramework::ProcessWatcher::LaunchProcess(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT);
if (!watcher)
@@ -256,7 +256,6 @@ namespace AssetProcessor
QString cmdLine;
if (!dest.isEmpty())
{
QString projectName = AssetUtilities::ComputeProjectName();
QString projectPath = AssetUtilities::ComputeProjectPath();
int portNumber = 0;
@@ -264,12 +263,12 @@ namespace AssetProcessor
AZStd::string appBranchToken;
AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::CalculateBranchTokenForEngineRoot, appBranchToken);
cmdLine = QString("\"%1\" /p=%2 %3 /unattended=true /gameroot=\"%4\" /watchfolder=\"%6\" /targetroot=\"%5\" /logprefix=\"%5/\" /port=%7 /gamesubdirectory=\"%8\" /branchtoken=\"%9\"");
cmdLine = cmdLine.arg(inputFile, platformIdentifier, params, projectPath, dest, watchFolder).arg(portNumber).arg(projectName).arg(appBranchToken.c_str());
cmdLine = QString("\"%1\" --platform=%2 %3 --unattended=true --project-path=\"%4\" --watchfolder=\"%6\" --targetroot=\"%5\" --logprefix=\"%5/\" --port=%7 --branchtoken=\"%8\"");
cmdLine = cmdLine.arg(inputFile, platformIdentifier, params, projectPath, dest, watchFolder).arg(portNumber).arg(appBranchToken.c_str());
}
else
{
cmdLine = QString("\"%1\" /p=%2 %3").arg(inputFile, platformIdentifier, params);
cmdLine = QString("\"%1\" --platform=%2 %3").arg(inputFile, platformIdentifier, params);
}
return cmdLine;
}
@@ -365,7 +364,7 @@ namespace AssetProcessor
return static_cast<AZ::u32>(crc);
}
//! Constructor to initialize the internal builders and a general internal builder uuid that is used for bus
//! Constructor to initialize the internal builders and a general internal builder uuid that is used for bus
//! registration. This constructor is helpful for deriving other classes from this builder for purposes like
//! unit testing.
InternalRecognizerBasedBuilder::InternalRecognizerBasedBuilder(QHash<QString, BuilderIdAndName> inputBuilderByIdMap, AZ::Uuid internalBuilderUuid)
@@ -471,32 +470,32 @@ namespace AssetProcessor
// inside of each such recognizer is a map of [platform] --> options for that platform.
// so visualizing this whole struct in summary might look something like
// "Internal RC Builder" :
// "Internal RC Builder" :
// {
// { <----- list of recognizers for that RC builder starts here
// regex: "*.tif",
// builderUUID : "12345-12354-123145",
// platformSpecsByPlatform :
// {
// builderUUID : "12345-12354-123145",
// platformSpecsByPlatform :
// {
// "pc" : "streaming = 1",
// "ios" : "streaming = 0"
// }
// },
// {
// {
// regex: "*.png",
// builderUUID : "12345-12354-123145",
// platformSpecsByPlatform :
// {
// builderUUID : "12345-12354-123145",
// platformSpecsByPlatform :
// {
// "pc" : "split=1"
// }
// },
// },
// "Internal Copy Builder",
// {
// {
// regex: "*.cfg",
// builderUUID : "12345-12354-123145",
// platformSpecsByPlatform :
// {
// builderUUID : "12345-12354-123145",
// platformSpecsByPlatform :
// {
// "pc" : "copy",
// "ios" : "copy"
// }
@@ -517,7 +516,7 @@ namespace AssetProcessor
for (auto internalAssetRecognizer : *internalRecognizerList)
{
// so referring to the structure explanation above, internalAssetRecognizer is
// so referring to the structure explanation above, internalAssetRecognizer is
// one of those objects that has the regex in it, (along with list of commands to apply per platform)
if (internalAssetRecognizer->m_platformSpecsByPlatform.size() == 0)
{
@@ -560,7 +559,7 @@ namespace AssetProcessor
if (builderInfo.GetType() == BuilderIdAndName::Type::REGISTERED_BUILDER)
{
AssetBuilderSDK::AssetBuilderDesc builderDesc = CreateBuilderDesc(builderId, builderPatterns);
// RC Builder also needs to include its platforms and its RC command lines so that if you change this, the jobs
// are re-evaluated.
size_t currentHash = 0;
@@ -626,7 +625,7 @@ namespace AssetProcessor
}
}
}
}
return foundAny;
@@ -646,11 +645,11 @@ namespace AssetProcessor
QString requestedBuilderID = QString(azBuilderId.c_str());
response.m_result = AssetBuilderSDK::CreateJobsResultCode::Failed;
QDir watchFolder(request.m_watchFolder.c_str());
QString normalizedPath = watchFolder.absoluteFilePath(request.m_sourceFile.c_str());
normalizedPath = AssetUtilities::NormalizeFilePath(normalizedPath);
// Locate recognizers that match the file
InternalRecognizerPointerContainer recognizers;
if (!GetMatchingRecognizers(request.m_enabledPlatforms, normalizedPath, recognizers))
@@ -803,15 +802,15 @@ namespace AssetProcessor
// If the job fails due to a networking issue, we will attempt to retry RetriesForJobNetworkError times
int retryCount = 0;
do
do
{
++retryCount;
ProcessLegacyRCJob(request, rcParam, assetRecognizer->m_productAssetType, jobCancelListener, response);
AZ_Warning("RC Builder", response.m_resultCode != AssetBuilderSDK::ProcessJobResult_NetworkIssue, "RC.exe reported a network connection issue. %s",
AZ_Warning("RC Builder", response.m_resultCode != AssetBuilderSDK::ProcessJobResult_NetworkIssue, "RC.exe reported a network connection issue. %s",
retryCount <= AssetProcessor::RetriesForJobNetworkError ? "Attempting to retry job." : "Maximum retry attempts exceeded, giving up.");
} while (response.m_resultCode == AssetBuilderSDK::ProcessJobResult_NetworkIssue && retryCount <= AssetProcessor::RetriesForJobNetworkError);
}
if (jobCancelListener.IsCancelled())
@@ -873,7 +872,7 @@ namespace AssetProcessor
workDir.removeRecursively();
}
}
bool InternalRecognizerBasedBuilder::SaveProcessJobRequestFile(const char* requestFileDir, const char* requestFileName, const AssetBuilderSDK::ProcessJobRequest& request)
{
AZStd::string finalFullPath;
@@ -886,7 +885,7 @@ namespace AssetProcessor
return true;
}
bool InternalRecognizerBasedBuilder::LoadProcessJobResponseFile(const char* responseFileDir, const char* responseFileName, AssetBuilderSDK::ProcessJobResponse& response, bool& responseLoaded)
{
responseLoaded = false;
@@ -914,7 +913,7 @@ namespace AssetProcessor
return true;
}
void InternalRecognizerBasedBuilder::ProcessLegacyRCJob(const AssetBuilderSDK::ProcessJobRequest& request, QString rcParam,
void InternalRecognizerBasedBuilder::ProcessLegacyRCJob(const AssetBuilderSDK::ProcessJobRequest& request, QString rcParam,
AZ::Uuid productAssetType, const AssetBuilderSDK::JobCancelListener& jobCancelListener, AssetBuilderSDK::ProcessJobResponse& response)
{
// Process this job
@@ -954,7 +953,7 @@ namespace AssetProcessor
response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Failed;
return;
}
if (!responseFromRCCompiler)
{
if(rcResult.m_exitCode != 0)
@@ -1094,7 +1093,7 @@ namespace AssetProcessor
AzFramework::StringFunc::Path::Join(dest.toUtf8().constData(), productName.c_str(), joinedPath);
productName.swap(joinedPath);
}
// update it in the structure to be absolute normalized path.
product.m_productFileName = productName;
@@ -1139,10 +1138,10 @@ namespace AssetProcessor
}
void InternalRecognizerBasedBuilder::ProcessCopyJob(
const AssetBuilderSDK::ProcessJobRequest& request,
AZ::Uuid productAssetType,
bool outputProductDependencies,
const AssetBuilderSDK::JobCancelListener& jobCancelListener,
const AssetBuilderSDK::ProcessJobRequest& request,
AZ::Uuid productAssetType,
bool outputProductDependencies,
const AssetBuilderSDK::JobCancelListener& jobCancelListener,
AssetBuilderSDK::ProcessJobResponse& response)
{
AssetBuilderSDK::JobProduct jobProduct(request.m_fullPath, productAssetType);
@@ -1151,7 +1150,7 @@ namespace AssetProcessor
{
jobProduct.m_dependenciesHandled = true; // Copy jobs are meant to be used for assets that have no dependencies and just need to be copied.
}
response.m_outputProducts.push_back(jobProduct);
response.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success;
@@ -364,10 +364,12 @@ namespace AssetProcessor
if (!results.isEmpty())
{
#if defined(AZ_ENABLE_TRACING)
for (const AssetProcessor::QueueElementID& result : results)
{
AZ_TracePrintf(AssetProcessor::DebugChannel, "OnEscalateJobsBySourceUUID: %s --> %s\n", sourceUuid.ToString<AZStd::string>().c_str(), result.GetInputAssetName().toUtf8().constData());
}
#endif
m_RCQueueSortModel.OnEscalateJobs(escalationList);
}
// do not print a warning out when this fails, its fine for things to escalate jobs as a matter of course just to "make sure" they are escalated
@@ -410,6 +410,7 @@ namespace AssetProcessor
AssetProcessor::SetThreadLocalJobId(builderParams.m_rcJob->GetJobEntry().m_jobRunKey);
AssetUtilities::JobLogTraceListener jobLogTraceListener(builderParams.m_rcJob->m_jobDetails.m_jobEntry);
#if defined(AZ_ENABLE_TRACING)
QString sourceFullPath(builderParams.m_processJobRequest.m_fullPath.c_str());
auto failReason = builderParams.m_processJobRequest.m_jobDescription.m_jobParameters.find(AZ_CRC(AssetProcessor::AutoFailReasonKey));
if (failReason != builderParams.m_processJobRequest.m_jobDescription.m_jobParameters.end())
@@ -456,6 +457,7 @@ namespace AssetProcessor
}
});
}
#endif
// note that this line below is printed out to be consistent with the output from a job that normally failed, so
// applications reading log file will find it.
@@ -481,6 +483,7 @@ namespace AssetProcessor
AssetBuilderSDK::JobCancelListener JobCancelListener(builderParams.m_rcJob->m_jobDetails.m_jobEntry.m_jobRunKey);
result.m_resultCode = AssetBuilderSDK::ProcessJobResult_Failed; // failed by default
#if defined(AZ_ENABLE_TRACING)
auto warningMessage = builderParams.m_processJobRequest.m_jobDescription.m_jobParameters.find(AZ_CRC(AssetProcessor::JobWarningKey));
if (warningMessage != builderParams.m_processJobRequest.m_jobDescription.m_jobParameters.end())
{
@@ -492,6 +495,7 @@ namespace AssetProcessor
AZ_Warning(AssetBuilderSDK::WarningWindow, false, "%s", token.c_str());
}
}
#endif
// create a temporary directory for Builder to work in.
// lets make it as a subdir of a known temp dir
@@ -108,11 +108,13 @@ void FileWatcherUnitTestRunner::StartTest()
if (outstandingFiles.count() > 0)
{
#if defined(AZ_ENABLE_TRACING)
AZ_TracePrintf(AssetProcessor::DebugChannel, "Timed out waiting for file changes: %d / %d missed\n", outstandingFiles.count(), maxFiles);
for (const QString& pending : outstandingFiles)
{
AZ_TracePrintf(AssetProcessor::DebugChannel, "Missed file: %s", pending.toUtf8().data());
}
#endif
Q_EMIT UnitTestFailed("Missed files waiting for file changes");
return;
}
@@ -308,4 +310,4 @@ void FileWatcherUnitTestRunner::StartTest()
#if !AZ_TRAIT_DISABLE_FAILED_ASSET_PROCESSOR_TESTS
REGISTER_UNIT_TEST(FileWatcherUnitTestRunner)
#endif // !AZ_TRAIT_DISABLE_FAILED_ASSET_PROCESSOR_TESTS
#endif // !AZ_TRAIT_DISABLE_FAILED_ASSET_PROCESSOR_TESTS
@@ -33,6 +33,7 @@
#include <AzToolsFramework/ToolsComponents/ToolsAssetCatalogComponent.h>
#include <AzToolsFramework/AssetBrowser/AssetBrowserComponent.h>
#include <AzToolsFramework/SourceControl/PerforceComponent.h>
#include <AzToolsFramework/Prefab/PrefabSystemComponent.h>
namespace AssetProcessor
{
@@ -153,6 +154,7 @@ AZ::ComponentTypeList AssetProcessorAZApplication::GetRequiredSystemComponents()
}
components.push_back(azrtti_typeid<AzToolsFramework::PerforceComponent>());
components.push_back(azrtti_typeid<AzToolsFramework::Prefab::PrefabSystemComponent>());
return components;
}
@@ -508,7 +510,6 @@ bool ApplicationManager::StartAZFramework()
AZ::ComponentApplication::StartupParameters params;
QString projectName = AssetUtilities::ComputeProjectName();
AZ::SettingsRegistryInterface& registry = *AZ::SettingsRegistry::Get();
// Prevent loading of gems in the Create method of the ComponentApplication
params.m_loadDynamicModules = false;
@@ -11,6 +11,7 @@
*/
#include "ApplicationManagerBase.h"
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzCore/std/sort.h>
@@ -1592,10 +1593,9 @@ void ApplicationManagerBase::BuilderLogV(const AZ::Uuid& builderId, const char*
if (m_builderDescMap.find(builderId) != m_builderDescMap.end())
{
const AssetBuilderSDK::AssetBuilderDesc& builderDesc = m_builderDescMap[builderId];
char messageBuffer[1024];
azvsnprintf(messageBuffer, 1024, message, list);
AZ_TracePrintf(AssetProcessor::ConsoleChannel, "Builder name : %s Message : %s.\n", builderDesc.m_name.c_str(), messageBuffer);
AZ_TracePrintf(AssetProcessor::ConsoleChannel, "Builder name : %s Message : %s.\n", m_builderDescMap[builderId].m_name.c_str(), messageBuffer);
}
else
{
@@ -1691,7 +1691,7 @@ bool ApplicationManagerBase::CheckSufficientDiskSpace(const QString& savePath, q
}
qint64 bytesFree = 0;
bool result = AzToolsFramework::ToolsFileUtils::GetFreeDiskSpace(savePath, bytesFree);
[[maybe_unused]] bool result = AzToolsFramework::ToolsFileUtils::GetFreeDiskSpace(savePath, bytesFree);
AZ_Assert(result, "Unable to determine the amount of free space on drive containing path (%s).", savePath.toUtf8().constData());
@@ -1717,7 +1717,15 @@ void ApplicationManagerBase::RemoveOldTempFolders()
return;
}
QString startFolder = rootDir.absolutePath();
QString startFolder;
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
if (AZ::IO::Path userPath; settingsRegistry->Get(userPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectUserPath))
{
startFolder = QString::fromUtf8(userPath.c_str(), aznumeric_cast<int>(userPath.Native().size()));
}
}
QDir root;
if (!AssetUtilities::CreateTempRootFolder(startFolder, root))
{
@@ -1521,10 +1521,10 @@ namespace AssetProcessor
//! Given a scan folder path, get its complete info
const AssetProcessor::ScanFolderInfo* PlatformConfiguration::GetScanFolderByPath(const QString& scanFolderPath) const
{
QString normalized = AssetUtilities::NormalizeFilePath(scanFolderPath);
AZ::IO::Path scanFolderPathView(scanFolderPath.toUtf8().constData());
for (int pathIdx = 0; pathIdx < m_scanFolders.size(); ++pathIdx)
{
if (QString::compare(m_scanFolders[pathIdx].ScanPath(), normalized, Qt::CaseSensitive) == 0)
if (AZ::IO::PathView(m_scanFolders[pathIdx].ScanPath().toUtf8().constData()) == scanFolderPathView)
{
return &m_scanFolders[pathIdx];
}
@@ -1478,7 +1478,14 @@ to ensure that the address is correct. Asset Processor won't be running in serve
return false;
}
#endif
return AzToolsFramework::AssetUtils::UpdateFilePathToCorrectCase(rootPath, relativePathFromRoot);
AZStd::string relPathFromRoot = relativePathFromRoot.toUtf8().constData();
if(AzToolsFramework::AssetUtils::UpdateFilePathToCorrectCase(rootPath.toUtf8().constData(), relPathFromRoot))
{
relativePathFromRoot = QString::fromUtf8(relPathFromRoot.c_str(), aznumeric_cast<int>(relPathFromRoot.size()));
return true;
}
return false;
}
BuilderFilePatternMatcher::BuilderFilePatternMatcher(const AssetBuilderSDK::AssetBuilderPattern& pattern, const AZ::Uuid& builderDescID)
@@ -192,7 +192,6 @@ namespace CrashHandler
return;
}
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
#if AZ_TRAIT_CRASHHANDLER_CONVERT_MULTIBYTE_CHARS
wchar_t pathStr[AZ_MAX_PATH_LEN];
+1
View File
@@ -103,6 +103,7 @@ namespace FileUtil
if (ftimeModify == nullptr && ftimeCreate == nullptr && ftimeAccess == nullptr)
{
FindClose(hFind);
return true;
}
+1 -1
View File
@@ -114,7 +114,7 @@ PakSystemFile* PakSystem::Open(const char* a_path, const char* a_mode)
dirToSearch = PathHelpers::GetDirectory(dirToSearch);
AZ::IO::LocalFileIO localFileIO;
bool foundOK = localFileIO.FindFiles(dirToSearch.c_str(), "*.pak", [&](const char* filePath) -> bool
localFileIO.FindFiles(dirToSearch.c_str(), "*.pak", [&](const char* filePath) -> bool
{
const string foundFilename(filePath);
if (StringHelpers::EqualsIgnoreCase(PathHelpers::FindExtension(foundFilename), "pak"))
@@ -288,7 +288,10 @@ ZipDir::CachePtr ZipDir::CacheFactory::MakeCache (const char* szFile)
m_f = NULL; // we don't own the file anymore - it's in possession of the cache instance
// try to serialize into the memory
size_t nSizeSerialized = m_treeFileEntries.Serialize (cache->GetRoot());
#if !defined(NDEBUG)
size_t nSizeSerialized =
#endif
m_treeFileEntries.Serialize (cache->GetRoot());
assert (nSizeSerialized == nSizeRequired);
@@ -523,10 +526,9 @@ bool ZipDir::CacheFactory::BuildFileEntryMap()
{
case ZipFile::EXTRA_NTFS:
{
ZipFile::ExtraNTFSHeader& ntfsHdr = *(ZipFile::ExtraNTFSHeader*)pAttrData;
extra.nLastModifyTime = *(uint64*)(pAttrData + sizeof(ZipFile::ExtraNTFSHeader));
uint64 accTime = *(uint64*)(pAttrData + sizeof(ZipFile::ExtraNTFSHeader) + 8);
uint64 crtTime = *(uint64*)(pAttrData + sizeof(ZipFile::ExtraNTFSHeader) + 16);
//uint64 accTime = *(uint64*)(pAttrData + sizeof(ZipFile::ExtraNTFSHeader) + 8);
//uint64 crtTime = *(uint64*)(pAttrData + sizeof(ZipFile::ExtraNTFSHeader) + 16);
}
break;
}
@@ -1699,7 +1699,10 @@ bool ZipDir::CacheRW::WriteCDR(FILE* fTarget, bool encryptCDR)
//arrFiles.SortByFileOffset();
size_t nSizeCDR = arrFiles.GetStats().nSizeCDR;
void* pCDR = malloc(nSizeCDR);
size_t nSizeCDRSerialized = arrFiles.MakeZipCDR(m_lCDROffset, pCDR, encryptCDR);
#if !defined(NDEBUG)
size_t nSizeCDRSerialized =
#endif
arrFiles.MakeZipCDR(m_lCDROffset, pCDR, encryptCDR);
assert (nSizeCDRSerialized == nSizeCDR);
if (encryptCDR)
@@ -1931,9 +1934,6 @@ bool ZipDir::CacheRW::EncryptArchive(EncryptionChange change, IEncryptPredicate*
FileRecordList arrFiles(GetRoot());
arrFiles.SortByFileOffset();
// the total size of data in the queue
unsigned nQueueSize = 0;
size_t unusedSpace = 0;
size_t lastDataEnd = 0;
@@ -1974,8 +1974,6 @@ bool ZipDir::CacheRW::EncryptArchive(EncryptionChange change, IEncryptPredicate*
return false;
}
bool methodChanged = false;
ZipFile::ushort oldMethod = entry->nMethod;
ZipFile::ushort newMethod = oldMethod;
if (change == ENCRYPT)
@@ -65,7 +65,7 @@ void logmessage(const char* text, ...)
error += ret;
bufferlen -= ret;
int count = vsnprintf(error, bufferlen, text, arg);
vsnprintf(error, bufferlen, text, arg);
AZ_TracePrintf(0, szBuffer);
@@ -169,7 +169,6 @@ bool CSTLHelper::FromFile(const std::string& rFileName, std::vector<uint8_t>&
return false;
}
size_t nNumRead = 0;
rIn.resize(fileSize);
AZ::IO::SystemFile::SizeType actualReadAmount = inputFile.Read(fileSize, &rIn[0]);
@@ -276,7 +275,7 @@ bool CSTLHelper::AppendToFile(const std::string& rFileName, const std::vector<ui
return false;
}
AZ::IO::SystemFile::SizeType bytesWritten = outputFile.Write(rOut.data(), rOut.size());
[[maybe_unused]] AZ::IO::SystemFile::SizeType bytesWritten = outputFile.Write(rOut.data(), rOut.size());
AZ_Warning("ShaderCompiler", bytesWritten == rOut.size(), "Did not write out all the data to the file: %s", rFileName.c_str());
return true;
}
@@ -56,14 +56,15 @@ void CCrySimpleCache::Init()
std::string CCrySimpleCache::CreateFileName(const tdHash& rHash) const
{
std::string Name;
Name = CSTLHelper::Hash2String(rHash);
AZStd::string Name;
Name = CSTLHelper::Hash2String(rHash).c_str();
char Tmp[4] = "012";
Tmp[0] = Name.c_str()[0];
Tmp[1] = Name.c_str()[1];
Tmp[2] = Name.c_str()[2];
return SEnviropment::Instance().m_CachePath + Tmp + "/" + Name;
AZ::IO::Path resultFileName = SEnviropment::Instance().m_CachePath / Tmp / Name;
return std::string{ resultFileName.c_str(), resultFileName.Native().size() };
}
@@ -159,7 +160,6 @@ bool CCrySimpleCache::LoadCacheFile(const std::string& filename)
uint32_t num = 0;
uint64_t nFilePos = 0;
uint64_t nFilePos2 = 0;
//////////////////////////////////////////////////////////////////////////
AZ::IO::SystemFile cacheFile;
@@ -303,7 +303,8 @@ void CCrySimpleCache::ThreadFunc_SavePendingCacheEntries()
if (pPendingCacheEntry)
{
CSTLHelper::AppendToFile(SEnviropment::Instance().m_CachePath + "Cache.dat", *pPendingCacheEntry);
AZ::IO::Path cacheDatPath = SEnviropment::Instance().m_CachePath / "Cache.dat";
CSTLHelper::AppendToFile(std::string{ cacheDatPath.c_str(), cacheDatPath.Native().size() }, *pPendingCacheEntry);
delete pPendingCacheEntry;
}
} while (!bListEmpty);
@@ -180,7 +180,7 @@ void CCrySimpleErrorLog::SendMail()
char DispFilename[1024];
azsprintf(DispFilename, "%d-%s", a + 1, err->GetFilename().c_str());
std::string sErrorFile = SEnviropment::Instance().m_ErrorPath + Filename;
std::string sErrorFile = (SEnviropment::Instance().m_ErrorPath / Filename).c_str();
std::vector<uint8_t> bytes;
std::string text = err->GetFileContents();
@@ -211,7 +211,7 @@ void CCrySimpleErrorLog::SendMail()
CSMTPMailer::tstrcol bcc;
CSMTPMailer mail("", "", SEnviropment::Instance().m_MailServer);
bool res = mail.Send(SEnviropment::Instance().m_FailEMail, Rcpt, cc, bcc, err->GetErrorName(), body, Attachment);
mail.Send(SEnviropment::Instance().m_FailEMail, Rcpt, cc, bcc, err->GetErrorName(), body, Attachment);
a = 0;
body = mailBody;
@@ -133,12 +133,12 @@ protected:
Ret += CreateInfoText("<b>Setup</b>:", "");
Ret += CreateInfoText("Root", SEnviropment::Instance().m_Root);
Ret += CreateInfoText("CompilerPath", SEnviropment::Instance().m_CompilerPath);
Ret += CreateInfoText("CachePath", SEnviropment::Instance().m_CachePath);
Ret += CreateInfoText("TempPath", SEnviropment::Instance().m_TempPath);
Ret += CreateInfoText("ErrorPath", SEnviropment::Instance().m_ErrorPath);
Ret += CreateInfoText("ShaderPath", SEnviropment::Instance().m_ShaderPath);
Ret += CreateInfoText("Root", SEnviropment::Instance().m_Root.c_str());
Ret += CreateInfoText("CompilerPath", SEnviropment::Instance().m_CompilerPath.c_str());
Ret += CreateInfoText("CachePath", SEnviropment::Instance().m_CachePath.c_str());
Ret += CreateInfoText("TempPath", SEnviropment::Instance().m_TempPath.c_str());
Ret += CreateInfoText("ErrorPath", SEnviropment::Instance().m_ErrorPath.c_str());
Ret += CreateInfoText("ShaderPath", SEnviropment::Instance().m_ShaderPath.c_str());
Ret += CreateInfoText("FailEMail", SEnviropment::Instance().m_FailEMail);
Ret += CreateInfoText("MailServer", SEnviropment::Instance().m_MailServer);
Ret += CreateInfoText("port", SEnviropment::Instance().m_port);
@@ -170,7 +170,9 @@ bool CCrySimpleJob::ExecuteCommand(const std::string& rCmd, std::string& outErro
threadIdStream << threadId;
// Multiple threads could execute a command, therefore the temporary file has to be unique per thread.
std::string stdErrorTempFilename = SEnviropment::Instance().m_TempPath + "stderr_" + threadIdStream.str() + ".log";
AZ::IO::Path errorTempFilePath = SEnviropment::Instance().m_TempPath / AZStd::string::format("stderr_%s.log", threadIdStream.str().c_str());
std::string stdErrorTempFilename{ errorTempFilePath.c_str(), errorTempFilePath.Native().size() };
CCrySimpleFileGuard FGTmpOutput(stdErrorTempFilename); // Delete file at the end of this function
std::string systemCmd = rCmd;
@@ -282,7 +282,7 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
shaderPath = AZStd::string::format("%s%s/", SEnviropment::Instance().m_ShaderPath.c_str(), language.c_str());
}
NormalizePath(shaderPath);
shaderPath = AZ::IO::PathView(shaderPath).LexicallyNormal().Native();
if (!IsPathValid(shaderPath))
{
State(ECSJS_ERROR);
@@ -347,17 +347,14 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
static AZStd::atomic_long nTmpCounter = { 0 };
++nTmpCounter;
char tmpstr[64];
azsprintf(tmpstr, "%ld", static_cast<long>(nTmpCounter));
const auto tmpIndex = AZStd::string::format("%ld", static_cast<long>(nTmpCounter));
const AZ::IO::Path TmpIn = SEnviropment::Instance().m_TempPath / (tmpIndex + ".In");
const AZ::IO::Path TmpOut = SEnviropment::Instance().m_TempPath / (tmpIndex + ".Out");
CCrySimpleFileGuard FGTmpIn(TmpIn.c_str());
CCrySimpleFileGuard FGTmpOut(TmpOut.c_str());
CSTLHelper::ToFile(TmpIn.c_str(), std::vector<uint8_t>(pProgram, &pProgram[strlen(pProgram)]));
const std::string TmpIn = SEnviropment::Instance().m_TempPath + tmpstr + ".In";
const std::string TmpOut = SEnviropment::Instance().m_TempPath + tmpstr + ".Out";
CCrySimpleFileGuard FGTmpIn(TmpIn);
CCrySimpleFileGuard FGTmpOut(TmpOut);
CSTLHelper::ToFile(TmpIn, std::vector<uint8_t>(pProgram, &pProgram[strlen(pProgram)]));
const AZStd::string compilerPath = SEnviropment::Instance().m_CompilerPath.c_str();
AZ::IO::Path compilerPath = SEnviropment::Instance().m_CompilerPath;
AZStd::string command;
if (m_Version >= EPV_V0022)
{
@@ -370,7 +367,7 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
return false;
}
AZStd::string commandStringToFormat = compilerPath + compilerExecutable;
AZStd::string commandStringToFormat = (compilerPath / compilerExecutable).Native();
#if defined(AZ_PLATFORM_LINUX) || defined(AZ_PLATFORM_MAC)
// Surrounding compiler path+executable with quotes to support spaces in the path.
@@ -392,7 +389,7 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
return false;
}
AZStd::string fxcLocation = compilerPath + fxcCompilerExecutable;
AZ::IO::Path fxcLocation = compilerPath / fxcCompilerExecutable;
// Handle an extra string parameter to specify the base directory where the fxc compiler is located
command = AZStd::move(AZStd::string::format(commandStringToFormat.c_str(), fxcLocation.c_str(), pEntry, pProfile, TmpOut.c_str(), TmpIn.c_str()));
@@ -434,7 +431,7 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
AZStd::string insertPattern = "\\\"";
// Search for the next space until that path exists. Then we assume that's the path to the executable.
size_t startPos = command.find(compilerPath);
size_t startPos = command.find(compilerPath.Native());
for (size_t pos = command.find(" ", startPos); pos != AZStd::string::npos; pos = command.find(" ", pos + 1))
{
if (AZ::IO::SystemFile::Exists(command.substr(startPos, pos - startPos).c_str()))
@@ -449,7 +446,7 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
command = AZStd::move(AZStd::string::format(pCompileFlags, pEntry, pProfile, TmpOut.c_str(), TmpIn.c_str()));
}
command = compilerPath + command;
command = compilerPath.Native() + command;
}
AZStd::string hardwareTarget;
@@ -540,11 +537,13 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
std::string tags = pTags ? pTags : "";
std::string filteredError;
CSTLHelper::Replace(filteredError, outError, TmpIn + ".patched", "%filename%"); // DXPS does its own patching
CSTLHelper::Replace(filteredError, filteredError, TmpIn, "%filename%");
AZ::IO::Path patchFilePath = TmpIn;
patchFilePath.ReplaceFilename(AZ::IO::PathView{ AZStd::string{ TmpIn.Filename().Native() } + ".patched" });
CSTLHelper::Replace(filteredError, outError, patchFilePath.c_str(), "%filename%"); // DXPS does its own patching
CSTLHelper::Replace(filteredError, filteredError, TmpIn.c_str(), "%filename%");
// replace any that don't have the full path
CSTLHelper::Replace(filteredError, filteredError, std::string(tmpstr) + ".In.patched", "%filename%"); // DXPS does its own patching
CSTLHelper::Replace(filteredError, filteredError, std::string(tmpstr) + ".In", "%filename%");
CSTLHelper::Replace(filteredError, filteredError, (tmpIndex + ".In.patched").c_str(), "%filename%"); // DXPS does its own patching
CSTLHelper::Replace(filteredError, filteredError, (tmpIndex + ".In").c_str(), "%filename%");
CSTLHelper::Replace(filteredError, filteredError, "\r\n", "\n");
@@ -552,11 +551,11 @@ bool CCrySimpleJobCompile::Compile(const TiXmlElement* pElement, std::vector<uin
throw new CCompilerError(pEntry, filteredError, ccs, sIP, pShaderRequestLine, pProgram, project, platform.c_str(), compiler.c_str(), language.c_str(), tags, pProfile);
}
if (!CSTLHelper::FromFile(TmpOut, rVec))
if (!CSTLHelper::FromFile(TmpOut.c_str(), rVec))
{
State(ECSJS_ERROR_FILEIO);
std::string errorString("Could not read: ");
errorString += TmpOut;
errorString += std::string(TmpOut.c_str(), TmpOut.Native().size());
CrySimple_ERROR(errorString.c_str());
return false;
}
@@ -19,6 +19,7 @@
#include <Core/Common.h>
#include <tinyxml/tinyxml.h>
#include <AzCore/Debug/Trace.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/std/string/string.h>
@@ -30,7 +31,7 @@ CCrySimpleJobGetShaderList::CCrySimpleJobGetShaderList(uint32_t requestIP, std::
bool CCrySimpleJobGetShaderList::Execute(const TiXmlElement* pElement)
{
AZStd::string shaderListFilename;
AZ::IO::Path shaderListFilename;
const char* project = pElement->Attribute("Project");
const char* shaderList = pElement->Attribute("ShaderList");
@@ -38,7 +39,10 @@ bool CCrySimpleJobGetShaderList::Execute(const TiXmlElement* pElement)
const char* compiler = pElement->Attribute("Compiler");
const char* language = pElement->Attribute("Language");
shaderListFilename = AZStd::string::format("./Cache/%s%s-%s-%s/%s", project, platform, compiler, language, shaderList);
shaderListFilename = project;
shaderListFilename /= "Cache";
shaderListFilename /= AZStd::string::format("%s-%s-%s", platform, compiler, language);
shaderListFilename /= shaderList;
//open the file and read into the rVec
@@ -23,6 +23,7 @@
#include <Core/WindowsAPIImplementation.h>
#include <AzCore/Debug/Trace.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/IO/SystemFile.h>
CCrySimpleJobRequest::CCrySimpleJobRequest(EProtocolVersion Version, uint32_t requestIP)
@@ -41,7 +42,7 @@ bool CCrySimpleJobRequest::Execute(const TiXmlElement* pElement)
return false;
}
AZStd::string shaderListFilename;
AZ::IO::Path shaderListFilename;
if (m_Version >= EPV_V0023)
{
const char* project = pElement->Attribute("Project");
@@ -64,20 +65,16 @@ bool CCrySimpleJobRequest::Execute(const TiXmlElement* pElement)
AZStd::string compiler = pElement->Attribute("Compiler");
AZStd::string language = pElement->Attribute("Language");
shaderListFilename = AZStd::string::format("%s%s-%s-%s/%s", project, platform.c_str(), compiler.c_str(), language.c_str(), shaderList);
shaderListFilename = project;
shaderListFilename /= "Cache";
shaderListFilename /= AZStd::string::format("%s-%s-%s", platform.c_str(), compiler.c_str(), language.c_str());
shaderListFilename /= shaderList;
}
else
{
// In previous versions Platform attribute is the shader list filename directly
shaderListFilename = pElement->Attribute("Platform");
}
if (shaderListFilename.length() >= AZ_MAX_PATH_LEN)
{
State(ECSJS_ERROR);
CrySimple_ERROR("Shader list filename is too long");
return false;
}
std::string shaderRequestLine(shaderRequest);
tdEntryVec toks;
@@ -71,15 +71,6 @@
AZStd::atomic_long CCrySimpleServer::ms_ExceptionCount = {0};
const static std::string SHADER_PROFILER = "NVShaderPerf" EXTENSION;
const static std::string SHADER_PATH_SOURCE = "Source";
const static std::string SHADER_PATH_BINARY = "Binary";
const static std::string SHADER_PATH_HALFSTRIPPED = "HalfStripped";
const static std::string SHADER_PATH_DISASSEMBLED = "DisAsm";
const static std::string SHADER_PATH_STRIPPPED = "Stripped";
const static std::string SHADER_PATH_CACHE = "Cache";
static const bool autoDeleteJobWhenDone = true;
static const int sleepTimeWhenWaiting = 10;
@@ -335,7 +326,6 @@ void CompileJob::Process()
}
const char* pVersion = pElement->Attribute("Version");
const char* pPlatform = pElement->Attribute("Platform");
const char* pHardwareTarget = nullptr;
//new request type?
@@ -575,31 +565,45 @@ void TickThread()
//////////////////////////////////////////////////////////////////////////
void LoadCache()
{
const std::string& cachePath = SEnviropment::Instance().m_CachePath;
if (CCrySimpleCache::Instance().LoadCacheFile(cachePath + "Cache.dat"))
AZ::IO::Path cacheDatFile{ SEnviropment::Instance().m_CachePath };
AZ::IO::Path cacheBakFile = cacheDatFile;
cacheDatFile /= "Cache.dat";
cacheBakFile /= "Cache.bak";
if (CCrySimpleCache::Instance().LoadCacheFile(cacheDatFile.c_str()))
{
AZ::IO::Path cacheBakFile2 = cacheBakFile;
cacheBakFile2.ReplaceFilename("Cache.bak2");
printf("Creating cache backup...\n");
AZ::IO::SystemFile::Delete((cachePath + "Cache.bak2").c_str());
printf("Move %s to %s\n", (cachePath + "Cache.bak").c_str(), (cachePath + "Cache.bak2").c_str());
AZ::IO::SystemFile::Rename((cachePath + "Cache.bak").c_str(), (cachePath + "Cache.bak2").c_str());
printf("Copy %s to %s\n", (cachePath + "Cache.dat").c_str(), (cachePath + "Cache.bak").c_str());
CopyFileOnPlatform((cachePath + "Cache.dat").c_str(), (cachePath + "Cache.bak").c_str(), FALSE);
AZ::IO::SystemFile::Delete(cacheBakFile2.c_str());
printf("Move %s to %s\n", cacheBakFile.c_str(), cacheBakFile2.c_str());
AZ::IO::SystemFile::Rename(cacheBakFile.c_str(), cacheBakFile2.c_str());
printf("Copy %s to %s\n", cacheDatFile.c_str(), cacheBakFile.c_str());
CopyFileOnPlatform(cacheDatFile.c_str(), cacheBakFile.c_str(), false);
printf("Cache backup done.\n");
}
else
{
// Restoring backup cache!
printf("Cache file corrupted!!!\n");
if (AZ::IO::SystemFile::Exists(cacheDatFile.c_str()))
{
printf("Cache file corrupted!!!\n");
AZ::IO::SystemFile::Delete(cacheDatFile.c_str());
}
printf("Restoring backup cache...\n");
AZ::IO::SystemFile::Delete((cachePath + "Cache.dat").c_str());
printf("Copy %s to %s\n", (cachePath + "Cache.bak").c_str(), (cachePath + "Cache.dat").c_str());
CopyFileOnPlatform((cachePath + "Cache.bak").c_str(), (cachePath + "Cache.dat").c_str(), FALSE);
if (!CCrySimpleCache::Instance().LoadCacheFile(cachePath + "Cache.dat"))
printf("Copy %s to %s\n", cacheBakFile.c_str(), cacheDatFile.c_str());
CopyFileOnPlatform(cacheBakFile.c_str(), cacheDatFile.c_str(), false);
if (!CCrySimpleCache::Instance().LoadCacheFile(cacheDatFile.c_str()))
{
// Backup file corrupted too!
printf("Backup file corrupted too!!!\n");
if (AZ::IO::SystemFile::Exists(cacheDatFile.c_str()))
{
printf("Backup file corrupted too!!!\n");
AZ::IO::SystemFile::Delete(cacheDatFile.c_str());
}
printf("Deleting cache completely\n");
AZ::IO::SystemFile::Delete((cachePath + "Cache.dat").c_str());
AZ::IO::SystemFile::Delete(cacheDatFile.c_str());
}
}
@@ -664,56 +668,9 @@ CCrySimpleServer::CCrySimpleServer()
CrySimple_SECURE_END
}
bool GetBaseDirectory(AZStd::string& baseDir)
{
char executableDir[AZ_MAX_PATH_LEN];
if (AZ::Utils::GetExecutableDirectory(executableDir, AZ_MAX_PATH_LEN) == AZ::Utils::ExecutablePathResult::Success)
{
AZStd::string_view executableDirView(executableDir);
if (executableDirView.size() > 1 && !executableDirView.ends_with(AZ_CORRECT_FILESYSTEM_SEPARATOR) && executableDirView.size() < AZStd::size(executableDir) - 1)
{
executableDir[executableDirView.size()] = AZ_CORRECT_FILESYSTEM_SEPARATOR;
executableDir[executableDirView.size() + 1] = '\0';
executableDirView = { executableDir, executableDirView.size() + 1 };
}
baseDir = AZStd::string(executableDir);
return true;
}
else
{
return false;
}
}
void NormalizePath(AZStd::string& pathToNormalize)
{
AzFramework::StringFunc::Root::Normalize(pathToNormalize);
}
void NormalizePath(std::string& pathToNormalize)
{
AZStd::string tempString = pathToNormalize.c_str();
NormalizePath(tempString);
pathToNormalize = tempString.c_str();
}
bool IsPathValid(const AZStd::string& path)
{
// Calculating base directory every time.
// It's slower than using a cached value, but safer.
AZStd::string baseDir;
if (GetBaseDirectory(baseDir))
{
AZStd::string basePath(AZ::IO::Path(baseDir).LexicallyNormal().Native());
AZStd::string subPath(AZ::IO::Path(path).LexicallyNormal().Native());
return strncmp(basePath.c_str(), subPath.c_str(), basePath.size()) == 0;
}
else
{
return false;
}
return AZ::IO::PathView(path).IsRelativeTo(AZ::IO::PathView(SEnviropment::Instance().m_Root));
}
bool IsPathValid(const std::string& path)
@@ -724,48 +681,29 @@ bool IsPathValid(const std::string& path)
void CCrySimpleServer::Init()
{
char executableDir[AZ_MAX_PATH_LEN];
AZ::Utils::GetExecutableDirectory(executableDir, AZ_MAX_PATH_LEN);
AZStd::string_view executableDirView(executableDir);
if (executableDirView.size() > 1 && !executableDirView.ends_with(AZ_CORRECT_FILESYSTEM_SEPARATOR) && executableDirView.size() < AZStd::size(executableDir) - 1)
{
executableDir[executableDirView.size()] = AZ_CORRECT_FILESYSTEM_SEPARATOR;
executableDir[executableDirView.size() + 1] = '\0';
executableDirView = { executableDir, executableDirView.size() + 1 };
}
SEnviropment::Instance().m_Root = std::string(executableDir);
AZStd::string baseDir;
GetBaseDirectory(baseDir);
SEnviropment::Instance().m_CompilerPath = baseDir.c_str();
SEnviropment::Instance().m_CompilerPath += "/Compiler/";
SEnviropment::Instance().m_CachePath = SEnviropment::Instance().m_Root + "Cache/";
SEnviropment::Instance().m_Root = AZ::Utils::GetExecutableDirectory();
SEnviropment::Instance().m_CompilerPath = SEnviropment::Instance().m_Root / "Compiler";
SEnviropment::Instance().m_CachePath = SEnviropment::Instance().m_Root / "Cache";
if (SEnviropment::Instance().m_TempPath.empty())
{
SEnviropment::Instance().m_TempPath = SEnviropment::Instance().m_Root + "Temp/";
SEnviropment::Instance().m_TempPath = SEnviropment::Instance().m_Root / "Temp";
}
if (SEnviropment::Instance().m_ErrorPath.empty())
{
SEnviropment::Instance().m_ErrorPath = SEnviropment::Instance().m_Root + "Error/";
SEnviropment::Instance().m_ErrorPath = SEnviropment::Instance().m_Root / "Error";
}
if (SEnviropment::Instance().m_ShaderPath.empty())
{
SEnviropment::Instance().m_ShaderPath = SEnviropment::Instance().m_Root + "Shaders/";
SEnviropment::Instance().m_ShaderPath = SEnviropment::Instance().m_Root / "Shaders";
}
NormalizePath(SEnviropment::Instance().m_Root);
NormalizePath(SEnviropment::Instance().m_CompilerPath);
NormalizePath(SEnviropment::Instance().m_CachePath);
NormalizePath(SEnviropment::Instance().m_ErrorPath);
NormalizePath(SEnviropment::Instance().m_TempPath);
NormalizePath(SEnviropment::Instance().m_ShaderPath);
AZ::IO::SystemFile::CreateDir(SEnviropment::Instance().m_ErrorPath.c_str());
AZ::IO::SystemFile::CreateDir(SEnviropment::Instance().m_TempPath.c_str());
AZ::IO::SystemFile::CreateDir(SEnviropment::Instance().m_CachePath.c_str());
AZ::IO::SystemFile::CreateDir(SEnviropment::Instance().m_ShaderPath.c_str());
SEnviropment::Instance().m_Root = SEnviropment::Instance().m_Root.LexicallyNormal();
SEnviropment::Instance().m_CompilerPath = SEnviropment::Instance().m_CompilerPath.LexicallyNormal();
SEnviropment::Instance().m_CachePath = SEnviropment::Instance().m_CachePath.LexicallyNormal();
SEnviropment::Instance().m_ErrorPath = SEnviropment::Instance().m_ErrorPath.LexicallyNormal();
SEnviropment::Instance().m_TempPath = SEnviropment::Instance().m_TempPath.LexicallyNormal();
SEnviropment::Instance().m_ShaderPath = SEnviropment::Instance().m_ShaderPath.LexicallyNormal();
if (SEnviropment::Instance().m_Caching)
{
@@ -15,6 +15,7 @@
#define __CRYSIMPLESERVER__
#include <Core/Common.h>
#include <AzCore/IO//Path/Path.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/containers/unordered_set.h>
#include <AzCore/std/containers/unordered_map.h>
@@ -24,11 +25,6 @@
extern bool g_Success;
bool GetExecutableDirectory(AZStd::string& executableDir);
bool GetBaseDirectory(AZStd::string& baseDir);
void NormalizePath(AZStd::string& pathToNormalize);
void NormalizePath(std::string& pathToNormalize);
bool IsPathValid(const AZStd::string& path);
bool IsPathValid(const std::string& path);
@@ -42,12 +38,12 @@ class CCrySimpleSock;
class SEnviropment
{
public:
std::string m_Root;
std::string m_CompilerPath;
std::string m_CachePath;
std::string m_TempPath;
std::string m_ErrorPath;
std::string m_ShaderPath;
AZ::IO::Path m_Root;
AZ::IO::Path m_CompilerPath;
AZ::IO::Path m_CachePath;
AZ::IO::Path m_TempPath;
AZ::IO::Path m_ErrorPath;
AZ::IO::Path m_ShaderPath;
std::string m_FailEMail;
std::string m_MailServer;
@@ -554,7 +554,6 @@ bool CCrySimpleSock::Recv(std::vector<uint8_t>& rVec)
if (size.m_Data64 > MAX_DATA_SIZE)
{
int WSAError = WSAGetLastError();
char acTmp[MAX_ERROR_MESSAGE_SIZE];
azsprintf(acTmp, "Error while receiving size of data - Size is greater than max support data size.");
CrySimple_ERROR(acTmp);
@@ -74,7 +74,7 @@ void CShaderList::Add(const std::string& rShaderListName, const char* pLine)
CCrySimpleMutexAutoLock Lock2(m_Mutex2); //load/save mutex
m_ShaderLists[rShaderListName] = new CShaderListFile(rShaderListName);
it = m_ShaderLists.find(rShaderListName);
it->second->Load((SEnviropment::Instance().m_CachePath + rShaderListName).c_str());
it->second->Load((SEnviropment::Instance().m_CachePath / AZStd::string_view{ rShaderListName.c_str(), rShaderListName.size() }).c_str());
}
}
it->second->InsertLine(pLine);
@@ -65,7 +65,7 @@ public:
}
if (azstricmp(strKey.c_str(), "TempDir") == 0)
{
SEnviropment::Instance().m_TempPath = AddSlash(strValue);
SEnviropment::Instance().m_TempPath = AZStd::string_view{ strValue.c_str(), strValue.size() };
}
if (azstricmp(strKey.c_str(), "MailServer") == 0)
{
+3 -2
View File
@@ -1387,13 +1387,14 @@ XmlNodeRef XmlParser::parseSource(const IXmlBufferSource* source)
bufferSize = sizeof(buffer) / sizeof(buffer[0])
};
m_pImpl->beginParse();
int bytesRead;
while (bytesRead = source->Read(buffer, bufferSize))
int bytesRead = source->Read(buffer, bufferSize);
while (bytesRead)
{
if (!m_pImpl->parse(buffer, bytesRead))
{
break;
}
bytesRead = source->Read(buffer, bufferSize);
}
return m_pImpl->endParse(m_errorString);
}
@@ -52,13 +52,12 @@ AZ_POP_DISABLE_WARNING
static char* cJSON_strdup(const char* str)
{
size_t len;
char* copy;
size_t len = strlen(str) + 1;
char* copy = (char*)cJSON_malloc(len);
len = strlen(str) + 1;
if (!(copy = (char*)cJSON_malloc(len))) return 0;
memcpy(copy,str,len);
return copy;
if (!copy) return 0;
memcpy(copy,str,len);
return copy;
}
void cJSON_InitHooks(cJSON_Hooks* hooks)
@@ -209,7 +208,15 @@ static char *print_string_ptr(const char *str)
const char *ptr;char *ptr2,*out;int len=0;unsigned char token;
if (!str) return cJSON_strdup("");
ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;}
ptr=str;
token = *ptr;
while (token && ++len)
{
if (strchr("\"\\\b\f\n\r\t",token)) len++;
else if (token<32) len+=5;
ptr++;
token = *ptr;
}
out=(char*)cJSON_malloc(len+3);
if (!out) return 0;
@@ -325,8 +332,8 @@ static const char *parse_array(cJSON *item,const char *value)
while (*value==',')
{
cJSON *new_item;
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
cJSON *new_item = cJSON_New_Item();
if (!new_item) return 0; /* memory fail */
child->next=new_item;new_item->prev=child;child=new_item;
value=skip(parse_value(child,skip(value+1)));
if (!value) return 0; /* memory fail */
@@ -415,8 +422,8 @@ static const char *parse_object(cJSON *item,const char *value)
while (*value==',')
{
cJSON *new_item;
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
cJSON* new_item = cJSON_New_Item();
if (!new_item) return 0; /* memory fail */
child->next=new_item;new_item->prev=child;child=new_item;
value=skip(parse_string(child,skip(value+1)));
if (!value) return 0;
@@ -349,7 +349,6 @@ int GetOptions(int argc, char** argv, Options* psOptions)
{
int i;
int fullShaderChain = -1;
int hashOut = 0;
InitOptions(psOptions);
@@ -412,8 +411,6 @@ int GetOptions(int argc, char** argv, Options* psOptions)
uint64_t hash = hash64((const uint8_t*)psOptions->outputShaderFile, (uint32_t)strlen(psOptions->outputShaderFile), 0);
uint32_t high = (uint32_t)(hash >> 32);
uint32_t low = (uint32_t)(hash & 0x00000000FFFFFFFF);
dir = strrchr(psOptions->outputShaderFile, '\\');
@@ -484,7 +481,6 @@ int Run(const char* srcPath, const char* destPath, GLLang language, int flags, c
Timer_t timer;
int compiledOK = 0;
double crossCompileTime = 0;
double glslCompileTime = 0;
HLSLcc_SetMemoryFunctions(malloc_hook, calloc_hook, free_hook, realloc_hook);
-11
View File
@@ -628,11 +628,6 @@ const uint32_t* DecodeDeclaration(Shader* psShader, const uint32_t* pui32Token,
{
ui32TokenLength = pui32Token[1];
{
int iTupleSrc = 0, iTupleDest = 0;
// const uint32_t ui32ConstCount = pui32Token[1] - 2;
// const uint32_t ui32TupleCount = (ui32ConstCount / 4);
CUSTOMDATA_CLASS eClass = DecodeCustomDataClass(pui32Token[0]);
const uint32_t ui32NumVec4 = (ui32TokenLength - 2) / 4;
uint32_t uIdx = 0;
@@ -671,8 +666,6 @@ const uint32_t* DecodeDeclaration(Shader* psShader, const uint32_t* pui32Token,
}
case OPCODE_DCL_UNORDERED_ACCESS_VIEW_RAW:
{
ResourceBinding* psBinding = NULL;
ConstantBuffer* psBuffer = NULL;
psDecl->ui32NumOperands = 1;
psDecl->sUAV.ui32GloballyCoherentAccess = DecodeAccessCoherencyFlags(*pui32Token);
@@ -725,8 +718,6 @@ const uint32_t* DecodeDeclaration(Shader* psShader, const uint32_t* pui32Token,
}
case OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED:
{
ResourceBinding* psBinding = NULL;
ConstantBuffer* psBuffer = NULL;
psDecl->ui32NumOperands = 1;
psDecl->sUAV.ui32GloballyCoherentAccess = 0;
@@ -739,8 +730,6 @@ const uint32_t* DecodeDeclaration(Shader* psShader, const uint32_t* pui32Token,
}
case OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW:
{
ResourceBinding* psBinding = NULL;
ConstantBuffer* psBuffer = NULL;
psDecl->ui32NumOperands = 1;
psDecl->sUAV.ui32GloballyCoherentAccess = 0;
@@ -407,8 +407,6 @@ static void SetupRegisterUsage(const Shader* psShader, const uint32_t ui32Token0
// In dx9 there is only one constant buffer per shader.
static void DeclareConstantBuffer(const Shader* psShader, Declaration* psDecl)
{
DECLUSAGE_DX9 eUsage = (DECLUSAGE_DX9)0;
uint32_t ui32UsageIndex = 0;
// Pick any constant register in the table. Might not start at c0 (e.g. when register(cX) is used).
uint32_t ui32RegNum = psShader->sInfo.psConstantBuffers->asVars[0].ui32StartOffset / 16;
OPERAND_TYPE_DX9 ui32RegType = OPERAND_TYPE_DX9_CONST;
@@ -446,9 +444,6 @@ static void DeclareConstantBuffer(const Shader* psShader, Declaration* psDecl)
static void DecodeDeclarationDX9(const Shader* psShader, const uint32_t ui32Token0, const uint32_t ui32Token1, Declaration* psDecl)
{
DECLUSAGE_DX9 eUsage = DecodeUsageDX9(ui32Token0);
uint32_t ui32UsageIndex = DecodeUsageIndexDX9(ui32Token0);
uint32_t ui32RegNum = DecodeOperandRegisterNumberDX9(ui32Token1);
uint32_t ui32RegType = DecodeOperandTypeDX9(ui32Token1);
if (psShader->eShaderType == VERTEX_SHADER)
+9 -10
View File
@@ -73,7 +73,7 @@ static void ReadInputSignatures(const uint32_t* pui32Tokens, ShaderInfo* psShade
InOutSignature* psSignatures;
const uint32_t* pui32FirstSignatureToken = pui32Tokens;
const uint32_t ui32ElementCount = *pui32Tokens++;
const uint32_t ui32Key = *pui32Tokens++;
/* const uint32_t ui32Key = */ *pui32Tokens++;
psSignatures = hlslcc_malloc(sizeof(InOutSignature) * ui32ElementCount);
psShaderInfo->psInputSignatures = psSignatures;
@@ -116,7 +116,7 @@ static void ReadOutputSignatures(const uint32_t* pui32Tokens, ShaderInfo* psShad
InOutSignature* psSignatures;
const uint32_t* pui32FirstSignatureToken = pui32Tokens;
const uint32_t ui32ElementCount = *pui32Tokens++;
const uint32_t ui32Key = *pui32Tokens++;
/* const uint32_t ui32Key = */ *pui32Tokens++;
psSignatures = hlslcc_malloc(sizeof(InOutSignature) * ui32ElementCount);
psShaderInfo->psOutputSignatures = psSignatures;
@@ -258,10 +258,10 @@ static const uint32_t* ReadConstantBuffer(ShaderInfo* psShaderInfo, const uint32
if (psShaderInfo->ui32MajorVersion >= 5)
{
uint32_t StartTexture = *pui32VarToken++;
uint32_t TextureSize = *pui32VarToken++;
uint32_t StartSampler = *pui32VarToken++;
uint32_t SamplerSize = *pui32VarToken++;
/* uint32_t StartTexture = */ *pui32VarToken++;
/* uint32_t TextureSize = */ *pui32VarToken++;
/* uint32_t StartSampler = */ *pui32VarToken++;
/* uint32_t SamplerSize = */ *pui32VarToken++;
}
psVar->haveDefaultValue = 0;
@@ -314,8 +314,8 @@ static void ReadResources(const uint32_t* pui32Tokens, ShaderInfo* psShaderInfo)
uint32_t ui32NumResourceBindings = *pui32Tokens++;
uint32_t ui32ResourceBindingOffset = *pui32Tokens++;
uint32_t ui32ShaderModel = *pui32Tokens++;
uint32_t ui32CompileFlags = *pui32Tokens++;//D3DCompile flags? http://msdn.microsoft.com/en-us/library/gg615083(v=vs.85).aspx
/* uint32_t ui32ShaderModel = */ *pui32Tokens++;
/* uint32_t ui32CompileFlags = */ *pui32Tokens++;//D3DCompile flags? http://msdn.microsoft.com/en-us/library/gg615083(v=vs.85).aspx
//Resources
pui32ResourceBindings = (const uint32_t*)((const char*)pui32FirstToken + ui32ResourceBindingOffset);
@@ -408,7 +408,7 @@ static void ReadInterfaces(const uint32_t* pui32Tokens, ShaderInfo* psShaderInfo
const uint32_t ui32ClassInstanceCount = *pui32Tokens++;
const uint32_t ui32ClassTypeCount = *pui32Tokens++;
const uint32_t ui32InterfaceSlotRecordCount = *pui32Tokens++;
const uint32_t ui32InterfaceSlotCount = *pui32Tokens++;
/* const uint32_t ui32InterfaceSlotCount = */ *pui32Tokens++;
const uint32_t ui32ClassInstanceOffset = *pui32Tokens++;
const uint32_t ui32ClassTypeOffset = *pui32Tokens++;
const uint32_t ui32InterfaceSlotOffset = *pui32Tokens++;
@@ -663,7 +663,6 @@ static int IsOffsetInType(ShaderVarType* psType, uint32_t parentOffset, uint32_t
int GetShaderVarFromOffset(const uint32_t ui32Vec4Offset, const uint32_t* pui32Swizzle, ConstantBuffer* psCBuf, ShaderVarType** ppsShaderVar, int32_t* pi32Index, int32_t* pi32Rebase)
{
uint32_t i;
const uint32_t ui32BaseByteOffset = ui32Vec4Offset * 16;
uint32_t ui32ByteOffset = ui32Vec4Offset * 16;
+4 -4
View File
@@ -18,7 +18,7 @@
#if defined(_WIN32) && !defined(PORTABLE)
#include <AzCore/PlatformDef.h>
AZ_PUSH_DISABLE_WARNING(4115, "-Wunknown-warning-option")
AZ_PUSH_DISABLE_WARNING(4115, "-Wunknown-warning-option") // 4115: named type definition in parentheses
#include <d3dcompiler.h>
AZ_POP_DISABLE_WARNING
#pragma comment(lib,"d3dcompiler.lib")
@@ -181,7 +181,6 @@ void AddVersionDependentCode(HLSLCrossCompilerContext* psContext)
// #extension directive must occur before any non-preprocessor token
if (EmulateDepthClamp(psContext->psShader->eTargetLanguage) && (psContext->psShader->eShaderType == VERTEX_SHADER || psContext->psShader->eShaderType == PIXEL_SHADER))
{
char* szInOut = psContext->psShader->eShaderType == VERTEX_SHADER ? "out" : "in";
ui32DepthClampImp = AddImport(psContext, SYMBOL_EMULATE_DEPTH_CLAMP, 0, 0);
bformata(glsl, "#if IMPORT_%d > 0\n", ui32DepthClampImp);
@@ -920,7 +919,6 @@ void WritePostStepTrace(HLSLCrossCompilerContext* psContext, uint32_t uStep)
uint16_t uOpcodeWriteMask = GetOpcodeWriteMask(psInstruction->eOpcode);
uint8_t uOperand = 0;
OPERAND_TYPE eOperandType = OPERAND_TYPE_NULL;
SHADER_VARIABLE_TYPE eVarToFlags = TO_FLAG_NONE;
Operand* psOperand = NULL;
uint32_t uiIgnoreSwizzle = 0;
@@ -1725,10 +1723,12 @@ void RemoveDoubleUnderscores(char* szName)
size_t length;
length = strlen(szName);
position = szName;
while (position = strstr(position, "__"))
position = strstr(position, "__");
while (position)
{
position[1] = '0';
position += 2;
position = strstr(position, "__");
}
}
@@ -299,8 +299,9 @@ void PreDeclareStructType(HLSLCrossCompilerContext* psContext, const char* Name,
if (psType->Class == SVC_STRUCT)
{
#if !defined(NDEBUG)
uint32_t unnamed_struct = strcmp(Name, "$Element") == 0 ? 1 : 0;
#endif
//Not supported at the moment
ASSERT(!unnamed_struct);
@@ -483,6 +484,7 @@ char* GetDeclaredOutputName(const HLSLCrossCompilerContext* psContext,
&psContext->psShader->sInfo,
&psOut);
(void)(foundOutput);
ASSERT(foundOutput);
if (eShaderType == GEOMETRY_SHADER)
@@ -590,7 +592,6 @@ static void DeclareInput(
{
if (iNumComponents == 1)
{
const uint32_t regNum = psDecl->asOperands[0].ui32RegisterNumber;
const uint32_t arraySize = psDecl->asOperands[0].aui32ArraySizes[0];
psContext->psShader->abScalarInput[psDecl->asOperands[0].ui32RegisterNumber] = -1;
@@ -1134,7 +1135,6 @@ void AddUserOutput(HLSLCrossCompilerContext* psContext, const Declaration* psDec
case VERTEX_SHADER:
{
int iNumComponents = 4; //GetMaxComponentFromComponentMask(&psDecl->asOperands[0]);
const char* Interpolation = "";
int stream = 0;
char* OutputName = GetDeclaredOutputName(psContext, VERTEX_SHADER, psOperand, &stream);
@@ -1413,7 +1413,9 @@ void DeclareBufferVariable(HLSLCrossCompilerContext* psContext, const uint32_t u
{
const char* Name = psCBuf->Name;
bstring StructName;
#if !defined(NDEBUG)
uint32_t unnamed_struct = strcmp(psCBuf->asVars[0].Name, "$Element") == 0 ? 1 : 0;
#endif
bstring glsl = *psContext->currentGLSLString;
ASSERT(psCBuf->ui32NumVars == 1);
@@ -1489,7 +1491,9 @@ void DeclarePLSVariable(HLSLCrossCompilerContext* psContext, const uint32_t ui32
(void)eResourceType;
const char* Name = plsVar->Name;
#if !defined(NDEBUG)
uint32_t unnamed_struct = strcmp(plsVar->asVars[0].Name, "$Element") == 0 ? 1 : 0;
#endif
bstring glsl = *psContext->currentGLSLString;
ASSERT(plsVar->ui32NumVars == 1);
@@ -1970,7 +1974,6 @@ void TranslateDeclaration(HLSLCrossCompilerContext* psContext, const Declaration
}
case OPCODE_DCL_TEMPS:
{
uint32_t i = 0;
const uint32_t ui32NumTemps = psDecl->value.ui32NumTemps;
if (psContext->flags & HLSLCC_FLAG_AVOID_TEMP_REGISTER_ALIASING && psContext->psShader->eShaderType != HULL_SHADER)
@@ -2106,7 +2109,6 @@ void TranslateDeclaration(HLSLCrossCompilerContext* psContext, const Declaration
const char* Precision = "highp";
const char* outputName = "PixOutput";
const char* qualifier = psContext->rendertargetUse[regNum] & OUTPUT_RENDERTARGET ? "inout" : "in";
bformata(glsl, "layout(location = %d) ", regNum);
bformata(glsl, "inout %s vec%d %s%d;\n", Precision, numElements, outputName, regNum);
@@ -943,8 +943,7 @@ static void TranslateTexCoord(HLSLCrossCompilerContext* psContext,
static int GetNumTextureDimensions(HLSLCrossCompilerContext* psContext,
const RESOURCE_DIMENSION eResDim)
{
int constructor = 0;
bstring glsl = *psContext->currentGLSLString;
(void)(psContext);
switch (eResDim)
{
@@ -1441,7 +1440,6 @@ static void TranslateShaderStorageStore(HLSLCrossCompilerContext* psContext, Ins
{
bstring glsl = *psContext->currentGLSLString;
ShaderVarType* psVarType = NULL;
uint32_t ui32DataTypeFlag = TO_FLAG_INTEGER;
int component;
int srcComponent = 0;
@@ -1450,7 +1448,6 @@ static void TranslateShaderStorageStore(HLSLCrossCompilerContext* psContext, Ins
Operand* psDestByteOff = 0;
Operand* psSrc = 0;
int structured = 0;
int groupshared = 0;
switch (psInst->eOpcode)
{
@@ -1474,7 +1471,6 @@ static void TranslateShaderStorageStore(HLSLCrossCompilerContext* psContext, Ins
ASSERT(psInst->asOperands[0].eSelMode == OPERAND_4_COMPONENT_MASK_MODE);
if (psInst->asOperands[0].ui32CompMask & (1 << component))
{
SHADER_VARIABLE_TYPE eSrcDataType = GetOperandDataType(psContext, psSrc);
uint32_t swizzle = 0;
if (structured && psDest->eType != OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY)
{
@@ -1575,7 +1571,6 @@ static void TranslateShaderPLSStore(HLSLCrossCompilerContext* psContext, Instruc
{
bstring glsl = *psContext->currentGLSLString;
ShaderVarType* psVarType = NULL;
uint32_t ui32DataTypeFlag = TO_FLAG_INTEGER;
int component;
int srcComponent = 0;
@@ -1607,7 +1602,6 @@ static void TranslateShaderPLSStore(HLSLCrossCompilerContext* psContext, Instruc
ASSERT(psInst->asOperands[0].eSelMode == OPERAND_4_COMPONENT_MASK_MODE);
if (psInst->asOperands[0].ui32CompMask & (1 << component))
{
SHADER_VARIABLE_TYPE eSrcDataType = GetOperandDataType(psContext, psSrc);
ASSERT(psDest->eType != OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY);
@@ -1999,7 +1993,6 @@ static void TranslateShaderPLSLoad(HLSLCrossCompilerContext* psContext, Instruct
bstring glsl = *psContext->currentGLSLString;
ShaderVarType* psVarType = NULL;
uint32_t aui32Swizzle[4] = { OPERAND_4_COMPONENT_X };
uint32_t ui32DataTypeFlag = TO_FLAG_INTEGER;
int component;
int destComponent = 0;
@@ -2833,7 +2826,6 @@ void SetDataTypes(HLSLCrossCompilerContext* psContext, Instruction* psInst, cons
case OPCODE_IMM_ATOMIC_CMP_EXCH:
{
Operand* dest = &psInst->asOperands[1];
Operand* destAddr = &psInst->asOperands[2];
ShaderVarType* type = LookupStructuredVar(psContext, dest, NULL, 0);
eNewType = type->Type;
break;
@@ -4485,7 +4477,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
case OPCODE_LD_MS:
{
ResourceBinding* psBinding = 0;
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[0]);
uint32_t ui32FetchTypeToFlags;
#ifdef _DEBUG
AddIndentation(psContext);
@@ -5120,7 +5111,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
// Here's the description of what bitfieldExtract actually does
// https://www.opengl.org/registry/specs/ARB/gpu_shader5.txt
int numComponents = psInst->asOperands[0].iNumComponents;
AddIndentation(psContext);
bcatcstr(glsl, "{\n");
@@ -5456,7 +5446,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
}
case OPCODE_RESINFO:
{
const RESOURCE_DIMENSION eResDim = psContext->psShader->aeResourceDims[psInst->asOperands[2].ui32RegisterNumber];
const RESINFO_RETURN_TYPE eResInfoReturnType = psInst->eResInfoReturnType;
uint32_t destElemCount = GetNumSwizzleElements(&psInst->asOperands[0]);
uint32_t destElem;
@@ -1406,7 +1406,6 @@ void TranslateVariableName(HLSLCrossCompilerContext* psContext, const Operand* p
{
bool hasConstructor = false;
bstring glsl = *psContext->currentGLSLString;
int numComponents = GetNumSwizzleElements(psOperand);
*pui32IgnoreSwizzle = 0;
@@ -1747,7 +1746,6 @@ char ResourceGroupPrefix(ResourceGroup eResGroup)
void ResourceName(bstring output, Shader* psShader, const char* szName, ResourceGroup eGroup, const char* szSecondaryName, ResourceGroup eSecondaryGroup, uint32_t ui32ArrayOffset, const char* szModifier)
{
int i = 0;
const char* pBracket;
@@ -1784,7 +1782,6 @@ void TextureName(bstring output, Shader* psShader, const uint32_t ui32TextureReg
ResourceBinding* psTextureBinding = 0;
ResourceBinding* psSamplerBinding = 0;
int found;
uint32_t ui32ArrayOffset = 0;
const char* szModifier = bCompare ? "c" : "";
found = GetResourceFromBindingPoint(RGROUP_TEXTURE, ui32TextureRegister, &psShader->sInfo, &psTextureBinding);
@@ -52,11 +52,10 @@ AZ_POP_DISABLE_WARNING
static char* cJSON_strdup(const char* str)
{
size_t len;
char* copy;
size_t len = strlen(str) + 1;
char* copy = (char*)cJSON_malloc(len);
len = strlen(str) + 1;
if (!(copy = (char*)cJSON_malloc(len))) return 0;
if (!copy) return 0;
memcpy(copy,str,len);
return copy;
}
@@ -209,7 +208,15 @@ static char *print_string_ptr(const char *str)
const char *ptr;char *ptr2,*out;int len=0;unsigned char token;
if (!str) return cJSON_strdup("");
ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;}
ptr=str;
token = *ptr;
while (token && ++len)
{
if (strchr("\"\\\b\f\n\r\t",token)) len++;
else if (token<32) len+=5;
ptr++;
token = *ptr;
}
out=(char*)cJSON_malloc(len+3);
if (!out) return 0;
@@ -325,8 +332,8 @@ static const char *parse_array(cJSON *item,const char *value)
while (*value==',')
{
cJSON *new_item;
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
cJSON *new_item = cJSON_New_Item();
if (!new_item) return 0; /* memory fail */
child->next=new_item;new_item->prev=child;child=new_item;
value=skip(parse_value(child,skip(value+1)));
if (!value) return 0; /* memory fail */
@@ -415,8 +422,8 @@ static const char *parse_object(cJSON *item,const char *value)
while (*value==',')
{
cJSON *new_item;
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
cJSON *new_item = cJSON_New_Item();
if (!new_item) return 0; /* memory fail */
child->next=new_item;new_item->prev=child;child=new_item;
value=skip(parse_string(child,skip(value+1)));
if (!value) return 0;
@@ -352,7 +352,6 @@ int GetOptions(int argc, char** argv, Options* psOptions)
{
int i;
int fullShaderChain = -1;
int hashOut = 0;
InitOptions(psOptions);
@@ -415,9 +414,6 @@ int GetOptions(int argc, char** argv, Options* psOptions)
uint64_t hash = hash64((const uint8_t*)psOptions->outputShaderFile, (uint32_t)strlen(psOptions->outputShaderFile), 0);
uint32_t high = (uint32_t)(hash >> 32);
uint32_t low = (uint32_t)(hash & 0x00000000FFFFFFFF);
dir = strrchr(psOptions->outputShaderFile, '\\');
if (!dir)
@@ -186,7 +186,6 @@ void MarkTextureAsShadow(ShaderInfo* psShaderInfo, Declaration* psDeclList, cons
{
(void)psShaderInfo;
ResourceBinding* psBinding = 0;
Declaration* psDecl = psDeclList;
uint32_t i;
@@ -733,11 +732,6 @@ const uint32_t* DecodeDeclaration(ShaderData* psShader, const uint32_t* pui32Tok
{
ui32TokenLength = pui32Token[1];
{
int iTupleSrc = 0, iTupleDest = 0;
//const uint32_t ui32ConstCount = pui32Token[1] - 2;
//const uint32_t ui32TupleCount = (ui32ConstCount / 4);
CUSTOMDATA_CLASS eClass = DecodeCustomDataClass(pui32Token[0]);
const uint32_t ui32NumVec4 = (ui32TokenLength - 2) / 4;
uint32_t uIdx = 0;
@@ -776,9 +770,6 @@ const uint32_t* DecodeDeclaration(ShaderData* psShader, const uint32_t* pui32Tok
}
case OPCODE_DCL_UNORDERED_ACCESS_VIEW_RAW:
{
ResourceBinding* psBinding = NULL;
ConstantBuffer* psBuffer = NULL;
psDecl->ui32NumOperands = 1;
psDecl->sUAV.ui32GloballyCoherentAccess = DecodeAccessCoherencyFlags(*pui32Token);
psDecl->sUAV.bCounter = 0;
@@ -830,9 +821,6 @@ const uint32_t* DecodeDeclaration(ShaderData* psShader, const uint32_t* pui32Tok
}
case OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED:
{
ResourceBinding* psBinding = NULL;
ConstantBuffer* psBuffer = NULL;
psDecl->ui32NumOperands = 1;
psDecl->sUAV.ui32GloballyCoherentAccess = 0;
@@ -844,9 +832,6 @@ const uint32_t* DecodeDeclaration(ShaderData* psShader, const uint32_t* pui32Tok
}
case OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW:
{
ResourceBinding* psBinding = NULL;
ConstantBuffer* psBuffer = NULL;
psDecl->ui32NumOperands = 1;
psDecl->sUAV.ui32GloballyCoherentAccess = 0;
@@ -1512,7 +1497,6 @@ void AllocateHullPhaseArrays(const uint32_t* pui32Tokens,
while (1) //Keep going until we reach the first non-declaration token, or the end of the shader.
{
uint32_t ui32TokenLength = DecodeInstructionLength(*pui32CurrentToken);
const uint32_t bExtended = DecodeIsOpcodeExtended(*pui32CurrentToken);
const OPCODE_TYPE eOpcode = DecodeOpcodeType(*pui32CurrentToken);
if (eOpcode == OPCODE_CUSTOMDATA)
@@ -408,8 +408,6 @@ static void SetupRegisterUsage(const ShaderData* psShader, const uint32_t ui32To
// In dx9 there is only one constant buffer per shader.
static void DeclareConstantBuffer(const ShaderData* psShader, Declaration* psDecl)
{
DECLUSAGE_DX9 eUsage = (DECLUSAGE_DX9)0;
uint32_t ui32UsageIndex = 0;
// Pick any constant register in the table. Might not start at c0 (e.g. when register(cX) is used).
uint32_t ui32RegNum = psShader->sInfo.psConstantBuffers->asVars[0].ui32StartOffset / 16;
OPERAND_TYPE_DX9 ui32RegType = OPERAND_TYPE_DX9_CONST;
@@ -447,9 +445,7 @@ static void DeclareConstantBuffer(const ShaderData* psShader, Declaration* psDec
static void DecodeDeclarationDX9(const ShaderData* psShader, const uint32_t ui32Token0, const uint32_t ui32Token1, Declaration* psDecl)
{
DECLUSAGE_DX9 eUsage = DecodeUsageDX9(ui32Token0);
uint32_t ui32UsageIndex = DecodeUsageIndexDX9(ui32Token0);
uint32_t ui32RegNum = DecodeOperandRegisterNumberDX9(ui32Token1);
/*uint32_t ui32UsageIndex = DecodeUsageIndexDX9(ui32Token0);*/
uint32_t ui32RegType = DecodeOperandTypeDX9(ui32Token1);
if (psShader->eShaderType == VERTEX_SHADER)
@@ -9,7 +9,29 @@
#include <malloc.h>
#endif
void* (*hlslcc_malloc)(size_t size) = malloc;
void* (*hlslcc_calloc)(size_t num,size_t size) = calloc;
void (*hlslcc_free)(void *p) = free;
void* (*hlslcc_realloc)(void *p,size_t size) = realloc;
// Wrapping these functions since we are taking the address of them and the std functions are dllimport which produce
// warning C4232
void* std_malloc(size_t size)
{
return malloc(size);
}
void* std_calloc(size_t num, size_t size)
{
return calloc(num, size);
}
void std_free(void* p)
{
free(p);
}
void* std_realloc(void* p, size_t size)
{
return realloc(p, size);
}
void* (*hlslcc_malloc)(size_t size) = std_malloc;
void* (*hlslcc_calloc)(size_t num,size_t size) = std_calloc;
void (*hlslcc_free)(void *p) = std_free;
void* (*hlslcc_realloc)(void *p,size_t size) = std_realloc;
@@ -12,4 +12,4 @@ extern void* (*hlslcc_realloc)(void *p,size_t size);
#define bstr__alloc hlslcc_malloc
#define bstr__free hlslcc_free
#define bstr__realloc hlslcc_realloc
#endif
#endif
+10 -12
View File
@@ -64,7 +64,7 @@ static void ReadInputSignatures(const uint32_t* pui32Tokens,
InOutSignature* psSignatures;
const uint32_t* pui32FirstSignatureToken = pui32Tokens;
const uint32_t ui32ElementCount = *pui32Tokens++;
const uint32_t ui32Key = *pui32Tokens++;
/*const uint32_t ui32Key =*/ *pui32Tokens++;
psSignatures = hlslcc_malloc(sizeof(InOutSignature) * ui32ElementCount);
psShaderInfo->psInputSignatures = psSignatures;
@@ -114,7 +114,7 @@ static void ReadOutputSignatures(const uint32_t* pui32Tokens,
InOutSignature* psSignatures;
const uint32_t* pui32FirstSignatureToken = pui32Tokens;
const uint32_t ui32ElementCount = *pui32Tokens++;
const uint32_t ui32Key = *pui32Tokens++;
/*const uint32_t ui32Key =*/ *pui32Tokens++;
psSignatures = hlslcc_malloc(sizeof(InOutSignature) * ui32ElementCount);
psShaderInfo->psOutputSignatures = psSignatures;
@@ -170,7 +170,7 @@ static void ReadPatchConstantSignatures(const uint32_t* pui32Tokens,
InOutSignature* psSignatures;
const uint32_t* pui32FirstSignatureToken = pui32Tokens;
const uint32_t ui32ElementCount = *pui32Tokens++;
const uint32_t ui32Key = *pui32Tokens++;
/*const uint32_t ui32Key =*/ *pui32Tokens++;
psSignatures = hlslcc_malloc(sizeof(InOutSignature) * ui32ElementCount);
psShaderInfo->psPatchConstantSignatures = psSignatures;
@@ -338,10 +338,10 @@ static const uint32_t* ReadConstantBuffer(ShaderInfo* psShaderInfo,
if (psShaderInfo->ui32MajorVersion >= 5)
{
uint32_t StartTexture = *pui32VarToken++;
uint32_t TextureSize = *pui32VarToken++;
uint32_t StartSampler = *pui32VarToken++;
uint32_t SamplerSize = *pui32VarToken++;
/* uint32_t StartTexture = */ *pui32VarToken++;
/* uint32_t TextureSize = */ *pui32VarToken++;
/* uint32_t StartSampler = */ *pui32VarToken++;
/* uint32_t SamplerSize = */ *pui32VarToken++;
}
psVar->haveDefaultValue = 0;
@@ -395,8 +395,8 @@ static void ReadResources(const uint32_t* pui32Tokens,//in
uint32_t ui32NumResourceBindings = *pui32Tokens++;
uint32_t ui32ResourceBindingOffset = *pui32Tokens++;
uint32_t ui32ShaderModel = *pui32Tokens++;
uint32_t ui32CompileFlags = *pui32Tokens++;//D3DCompile flags? http://msdn.microsoft.com/en-us/library/gg615083(v=vs.85).aspx
/*uint32_t ui32ShaderModel =*/ *pui32Tokens++;
/*uint32_t ui32CompileFlags =*/ *pui32Tokens++;//D3DCompile flags? http://msdn.microsoft.com/en-us/library/gg615083(v=vs.85).aspx
//Resources
pui32ResourceBindings = (const uint32_t*)((const char*)pui32FirstToken + ui32ResourceBindingOffset);
@@ -490,7 +490,7 @@ static void ReadInterfaces(const uint32_t* pui32Tokens,
const uint32_t ui32ClassInstanceCount = *pui32Tokens++;
const uint32_t ui32ClassTypeCount = *pui32Tokens++;
const uint32_t ui32InterfaceSlotRecordCount = *pui32Tokens++;
const uint32_t ui32InterfaceSlotCount = *pui32Tokens++;
/*const uint32_t ui32InterfaceSlotCount =*/ *pui32Tokens++;
const uint32_t ui32ClassInstanceOffset = *pui32Tokens++;
const uint32_t ui32ClassTypeOffset = *pui32Tokens++;
const uint32_t ui32InterfaceSlotOffset = *pui32Tokens++;
@@ -788,7 +788,6 @@ int GetShaderVarFromOffset(const uint32_t ui32Vec4Offset,
int32_t* pi32Rebase)
{
uint32_t i;
const uint32_t ui32BaseByteOffset = ui32Vec4Offset * 16;
uint32_t ui32ByteOffset = ui32Vec4Offset * 16;
@@ -870,7 +869,6 @@ void LoadShaderInfo(const uint32_t ui32MajorVersion,
const uint32_t* pui32Outputs11 = psChunks->pui32Outputs11;
const uint32_t* pui32OutputsWithStreams = psChunks->pui32OutputsWithStreams;
const uint32_t* pui32PatchConstants = psChunks->pui32PatchConstants;
const uint32_t* pui32Effects10Data = psChunks->pui32Effects10Data;
psInfo->eTessOutPrim = TESSELLATOR_OUTPUT_UNDEFINED;
psInfo->eTessPartitioning = TESSELLATOR_PARTITIONING_UNDEFINED;
@@ -227,9 +227,9 @@ void PreDeclareStructType(bstring glsl, const char* Name, const struct ShaderVar
if(psType->Class == SVC_STRUCT)
{
#if defined(_DEBUG)
uint32_t unnamed_struct = strcmp(Name, "$Element") == 0 ? 1 : 0;
#endif
//Not supported at the moment
ASSERT(!unnamed_struct);
@@ -307,13 +307,16 @@ const char* GetDeclaredOutputName(const HLSLCrossCompilerContext* psContext,
char* cstr;
InOutSignature* psOut;
int foundOutput = GetOutputSignatureFromRegister(
psContext->currentPhase,
psOperand->ui32RegisterNumber,
psOperand->ui32CompMask,
psContext->psShader->ui32CurrentVertexOutputStream,
&psContext->psShader->sInfo,
&psOut);
#if defined(_DEBUG)
int foundOutput =
#endif
GetOutputSignatureFromRegister(
psContext->currentPhase,
psOperand->ui32RegisterNumber,
psOperand->ui32CompMask,
psContext->psShader->ui32CurrentVertexOutputStream,
&psContext->psShader->sInfo,
&psOut);
ASSERT(foundOutput);
@@ -463,7 +466,6 @@ static void DeclareInput(
{
if(iNumComponents == 1)
{
const uint32_t regNum = psDecl->asOperands[0].ui32RegisterNumber;
const uint32_t arraySize = psDecl->asOperands[0].aui32ArraySizes[0];
psContext->psShader->abScalarInput[psDecl->asOperands[0].ui32RegisterNumber] = -1;
@@ -1154,7 +1156,10 @@ void DeclareBufferVariable(HLSLCrossCompilerContext* psContext, const uint32_t u
bstring glsl)
{
bstring StructName;
uint32_t unnamed_struct = strcmp(psCBuf->asVars[0].Name, "$Element") == 0 ? 1 : 0;
#if defined(_DEBUG)
uint32_t unnamed_struct =
#endif
strcmp(psCBuf->asVars[0].Name, "$Element") == 0 ? 1 : 0;
ASSERT(psCBuf->ui32NumVars == 1);
ASSERT(unnamed_struct);
@@ -1868,7 +1873,6 @@ Would generate a vec2 and a vec3. We discard the second one making .z invalid!
}
case OPCODE_DCL_TEMPS:
{
uint32_t i = 0;
const uint32_t ui32NumTemps = psDecl->value.ui32NumTemps;
if(ui32NumTemps > 0)
@@ -289,7 +289,6 @@ static void GLSLAddComparision(HLSLCrossCompilerContext* psContext, Instruction*
static void GLSLAddMOVBinaryOp(HLSLCrossCompilerContext* psContext, const Operand* pDest, Operand* pSrc)
{
int numParenthesis = 0;
int destComponents = GetMaxComponentFromComponentMask(pDest);
int srcSwizzleCount = GetNumSwizzleElements(pSrc);
uint32_t writeMask = GetOperandWriteMask(pDest);
@@ -318,7 +317,6 @@ static void GLSLAddMOVCBinaryOp(HLSLCrossCompilerContext* psContext, const Opera
uint32_t destElem;
const SHADER_VARIABLE_TYPE eDestType = GetOperandDataType(psContext, pDest);
const SHADER_VARIABLE_TYPE eSrc0Type = GetOperandDataType(psContext, src0);
/*
for each component in dest[.mask]
if the corresponding component in src0 (POS-swizzle)
@@ -499,9 +497,6 @@ static void GLSLCallTernaryOp(HLSLCrossCompilerContext* psContext,
uint32_t dataType)
{
bstring glsl = *psContext->currentShaderString;
uint32_t src2SwizCount = GetNumSwizzleElements(&psInst->asOperands[src2]);
uint32_t src1SwizCount = GetNumSwizzleElements(&psInst->asOperands[src1]);
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
uint32_t destMask = GetOperandWriteMask(&psInst->asOperands[dest]);
@@ -532,9 +527,6 @@ static void GLSLCallHelper3(HLSLCrossCompilerContext* psContext,
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_FLOAT;
bstring glsl = *psContext->currentShaderString;
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMask(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
uint32_t src2SwizCount = GetNumSwizzleElements(&psInst->asOperands[src2]);
uint32_t src1SwizCount = GetNumSwizzleElements(&psInst->asOperands[src1]);
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
int numParenthesis = 0;
@@ -558,8 +550,6 @@ GLSLCallHelper2(HLSLCrossCompilerContext* psContext, const char* name, Instructi
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_FLOAT;
bstring glsl = *psContext->currentShaderString;
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMask(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
uint32_t src1SwizCount = GetNumSwizzleElements(&psInst->asOperands[src1]);
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
int isDotProduct = (strncmp(name, "dot", 3) == 0) ? 1 : 0;
@@ -583,8 +573,6 @@ GLSLCallHelper2Int(HLSLCrossCompilerContext* psContext, const char* name, Instru
{
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_INT;
bstring glsl = *psContext->currentShaderString;
uint32_t src1SwizCount = GetNumSwizzleElements(&psInst->asOperands[src1]);
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMask(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
int numParenthesis = 0;
@@ -606,8 +594,6 @@ GLSLCallHelper2UInt(HLSLCrossCompilerContext* psContext, const char* name, Instr
{
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_UINT;
bstring glsl = *psContext->currentShaderString;
uint32_t src1SwizCount = GetNumSwizzleElements(&psInst->asOperands[src1]);
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMask(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
int numParenthesis = 0;
@@ -628,7 +614,6 @@ static void GLSLCallHelper1(HLSLCrossCompilerContext* psContext, const char* nam
{
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_FLOAT;
bstring glsl = *psContext->currentShaderString;
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMask(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
int numParenthesis = 0;
@@ -653,7 +638,6 @@ static void GLSLCallHelper1Int(HLSLCrossCompilerContext* psContext,
{
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_INT;
bstring glsl = *psContext->currentShaderString;
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMask(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
int numParenthesis = 0;
@@ -818,9 +802,7 @@ static void GLSLTranslateTexelFetchOffset(HLSLCrossCompilerContext* psContext, I
// Currently supports floating point coord only, so not used for texelFetch.
static void GLSLTranslateTexCoord(HLSLCrossCompilerContext* psContext, const RESOURCE_DIMENSION eResDim, Operand* psTexCoordOperand)
{
int numParenthesis = 0;
uint32_t flags = TO_AUTO_BITCAST_TO_FLOAT;
bstring glsl = *psContext->currentShaderString;
uint32_t opMask = OPERAND_4_COMPONENT_MASK_ALL;
switch (eResDim)
@@ -866,9 +848,7 @@ static void GLSLTranslateTexCoord(HLSLCrossCompilerContext* psContext, const RES
static int GLSLGetNumTextureDimensions(HLSLCrossCompilerContext* psContext, const RESOURCE_DIMENSION eResDim)
{
int constructor = 0;
bstring glsl = *psContext->currentShaderString;
(void)psContext;
switch (eResDim)
{
case RESOURCE_DIMENSION_TEXTURE1D:
@@ -1299,7 +1279,6 @@ static void GLSLTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext,
{
bstring glsl = *psContext->currentShaderString;
ShaderVarType* psVarType = NULL;
uint32_t ui32DataTypeFlag = TO_FLAG_INTEGER;
int component;
int srcComponent = 0;
@@ -1308,7 +1287,6 @@ static void GLSLTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext,
Operand* psDestByteOff = 0;
Operand* psSrc = 0;
int structured = 0;
int groupshared = 0;
switch (psInst->eOpcode)
{
@@ -1329,11 +1307,9 @@ static void GLSLTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext,
for (component = 0; component < 4; component++)
{
const char* swizzleString[] = {".x", ".y", ".z", ".w"};
ASSERT(psInst->asOperands[0].eSelMode == OPERAND_4_COMPONENT_MASK_MODE);
if (psInst->asOperands[0].ui32CompMask & (1 << component))
{
SHADER_VARIABLE_TYPE eSrcDataType = GetOperandDataType(psContext, psSrc);
if (structured && psDest->eType != OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY)
{
@@ -1432,11 +1408,7 @@ static void GLSLTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext,
static void GLSLTranslateShaderStorageLoad(HLSLCrossCompilerContext* psContext, Instruction* psInst)
{
bstring glsl = *psContext->currentShaderString;
ShaderVarType* psVarType = NULL;
uint32_t aui32Swizzle[4] = {OPERAND_4_COMPONENT_X};
uint32_t ui32DataTypeFlag = TO_FLAG_INTEGER;
int component;
int destComponent = 0;
Operand* psDest = 0;
Operand* psSrcAddr = 0;
Operand* psSrcByteOff = 0;
@@ -2268,7 +2240,6 @@ void SetDataTypes(HLSLCrossCompilerContext* psContext, Instruction* psInst, cons
// Only ever to int->float promotion (or int->uint), never the other way around
for (i = 0; i < i32InstCount; ++i, psInst++)
{
int k = 0;
if (psInst->ui32NumOperands == 0)
continue;
@@ -2644,9 +2615,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
{
uint32_t dstCount = GetNumSwizzleElements(&psInst->asOperands[0]);
uint32_t srcCount = GetNumSwizzleElements(&psInst->asOperands[1]);
uint32_t ui32DstFlags = TO_FLAG_DESTINATION;
const SHADER_VARIABLE_TYPE eSrcType = GetOperandDataType(psContext, &psInst->asOperands[1]);
const SHADER_VARIABLE_TYPE eDestType = GetOperandDataType(psContext, &psInst->asOperands[0]);
#ifdef _DEBUG
AddIndentation(psContext);
@@ -2683,8 +2651,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
case OPCODE_ITOF: // signed to float
case OPCODE_UTOF: // unsigned to float
{
const SHADER_VARIABLE_TYPE eDestType = GetOperandDataType(psContext, &psInst->asOperands[0]);
const SHADER_VARIABLE_TYPE eSrcType = GetOperandDataType(psContext, &psInst->asOperands[1]);
uint32_t dstCount = GetNumSwizzleElements(&psInst->asOperands[0]);
uint32_t srcCount = GetNumSwizzleElements(&psInst->asOperands[1]);
@@ -2886,7 +2852,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
case OPCODE_DP2:
{
SHADER_VARIABLE_TYPE eDestDataType = GetOperandDataType(psContext, &psInst->asOperands[0]);
int numParenthesis2 = 0;
#ifdef _DEBUG
AddIndentation(psContext);
@@ -3918,7 +3883,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
case OPCODE_LD_MS:
{
ResourceBinding* psBinding = 0;
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[0]);
#ifdef _DEBUG
AddIndentation(psContext);
if (psInst->eOpcode == OPCODE_LD)
@@ -4463,8 +4427,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
}
case OPCODE_RESINFO:
{
const RESOURCE_DIMENSION eResDim = psContext->psShader->aeResourceDims[psInst->asOperands[2].ui32RegisterNumber];
const RESINFO_RETURN_TYPE eResInfoReturnType = psInst->eResInfoReturnType;
uint32_t destElemCount = GetNumSwizzleElements(&psInst->asOperands[0]);
uint32_t destElem;
#ifdef _DEBUG
@@ -4474,7 +4436,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
for (destElem = 0; destElem < destElemCount; ++destElem)
{
const char* swizzle[] = {".x", ".y", ".z", ".w"};
GetResInfoData(psContext, psInst, psInst->asOperands[2].aui32Swizzle[destElem], destElem);
}
@@ -1677,7 +1677,6 @@ void TranslateOperandWithMask(HLSLCrossCompilerContext* psContext, const Operand
{
bstring glsl = *psContext->currentShaderString;
uint32_t ui32IgnoreSwizzle = 0;
SHADER_VARIABLE_TYPE eType = GetOperandDataTypeEx(psContext, psOperand, TypeFlagsToSVTType(ui32TOFlag));
if (psContext->psShader->ui32MajorVersion <= 3)
{
@@ -113,7 +113,6 @@ void TranslateToMETAL(HLSLCrossCompilerContext* psContext, ShaderLang* planguage
{
int hasStageInput = 0;
int hasOutput = 0;
int inputDeclLength = blength(psContext->parameterDeclarations);
if (blength(psContext->stagedInputDeclarations) > 0)
{
hasStageInput = 1;
@@ -189,7 +188,6 @@ void TranslateToMETAL(HLSLCrossCompilerContext* psContext, ShaderLang* planguage
{
int hasStageInput = 0;
int hasOutput = 0;
int inputDeclLength = blength(psContext->parameterDeclarations);
if (blength(psContext->stagedInputDeclarations) > 0)
{
hasStageInput = 1;
@@ -284,7 +284,9 @@ void PreDeclareStructTypeMETAL(bstring metal, const char* Name, const struct Sha
if (psType->Class == SVC_STRUCT)
{
#if defined(_DEBUG)
uint32_t unnamed_struct = strcmp(Name, "$Element") == 0 ? 1 : 0;
#endif
//Not supported at the moment
ASSERT(!unnamed_struct);
@@ -335,7 +337,10 @@ char* GetDeclaredOutputNameMETAL(const HLSLCrossCompilerContext* psContext,
char* cstr;
InOutSignature* psOut;
int foundOutput = GetOutputSignatureFromRegister(
#if defined(_DEBUG)
int foundOutput =
#endif
GetOutputSignatureFromRegister(
psContext->currentPhase,
psOperand->ui32RegisterNumber,
psOperand->ui32CompMask,
@@ -422,7 +427,6 @@ static void DeclareInput(
{
InOutSignature* psSignature = NULL;
int emptyQualifier = 0;
const char* type = "float";
if (minPrecision == OPERAND_MIN_PRECISION_FLOAT_16)
@@ -506,7 +510,6 @@ static void DeclareInput(
psContext->psShader->abScalarInput[psDecl->asOperands[0].ui32RegisterNumber] = -1;
}
const uint32_t regNum = psDecl->asOperands[0].ui32RegisterNumber;
const uint32_t arraySize = psDecl->asOperands[0].aui32ArraySizes[0];
bformata(metal, " [%d]", arraySize);
@@ -714,7 +717,6 @@ void AddBuiltinOutputMETAL(HLSLCrossCompilerContext* psContext, const Declaratio
if (OutputNeedsDeclaringMETAL(psContext, &psDecl->asOperands[0], arrayElements ? arrayElements : 1))
{
char* OutputName = GetDeclaredOutputNameMETAL(psContext, VERTEX_SHADER, &psDecl->asOperands[0]);
psContext->currentShaderString = &psContext->declaredOutputs;
metal = *psContext->currentShaderString;
InOutSignature* psSignature = NULL;
@@ -826,8 +828,6 @@ void AddUserOutputMETAL(HLSLCrossCompilerContext* psContext, const Declaration*
case VERTEX_SHADER:
{
int iNumComponents = 4;//GetMaxComponentFromComponentMaskMETAL(&psDecl->asOperands[0]);
const char* Interpolation = "";
int stream = 0;
char* OutputName = GetDeclaredOutputNameMETAL(psContext, VERTEX_SHADER, psOperand);
bformata(metal, "%s%d %s [[ user(varying%d) ]];\n", type, iNumComponents, OutputName, psDecl->asOperands[0].ui32RegisterNumber);
@@ -850,7 +850,9 @@ void DeclareBufferVariableMETAL(HLSLCrossCompilerContext* psContext, const uint3
(void)ui32BindingPoint;
bstring StructName;
#if !defined(NDEBUG)
uint32_t unnamed_struct = strcmp(psCBuf->asVars[0].Name, "$Element") == 0 ? 1 : 0;
#endif
ASSERT(psCBuf->ui32NumVars == 1);
ASSERT(unnamed_struct);
@@ -1320,7 +1322,6 @@ char* GetSamplerTypeMETAL(HLSLCrossCompilerContext* psContext,
static void TranslateResourceTexture(HLSLCrossCompilerContext* psContext, const Declaration* psDecl, uint32_t samplerCanDoShadowCmp)
{
bstring metal = *psContext->currentShaderString;
ShaderData* psShader = psContext->psShader;
const char* samplerTypeName = GetSamplerTypeMETAL(psContext,
psDecl->value.eResourceDimension,
@@ -1534,9 +1535,7 @@ void TranslateDeclarationMETAL(HLSLCrossCompilerContext* psContext, const Declar
{
const Operand* psOperand = &psDecl->asOperands[0];
int iNumComponents = 4;//GetMaxComponentFromComponentMask(psOperand);
const char* StorageQualifier = "";
const char* InputName = GetDeclaredInputNameMETAL(psContext, PIXEL_SHADER, psOperand);
const char* Interpolation = "";
DeclareInput(psContext, psDecl,
"user", (OPERAND_MIN_PRECISION)psOperand->eMinPrecision, iNumComponents, INDEX_1D, InputName);
@@ -1545,7 +1544,6 @@ void TranslateDeclarationMETAL(HLSLCrossCompilerContext* psContext, const Declar
}
case OPCODE_DCL_TEMPS:
{
uint32_t i = 0;
const uint32_t ui32NumTemps = psDecl->value.ui32NumTemps;
if (ui32NumTemps > 0)
@@ -327,7 +327,6 @@ static void METALAddComparision(HLSLCrossCompilerContext* psContext, Instruction
static void METALAddMOVBinaryOp(HLSLCrossCompilerContext* psContext, const Operand* pDest, Operand* pSrc)
{
int numParenthesis = 0;
int destComponents = GetMaxComponentFromComponentMaskMETAL(pDest);
int srcSwizzleCount = GetNumSwizzleElementsMETAL(pSrc);
uint32_t writeMask = GetOperandWriteMaskMETAL(pDest);
@@ -356,7 +355,6 @@ static void METALAddMOVCBinaryOp(HLSLCrossCompilerContext* psContext, const Oper
uint32_t destElem;
const SHADER_VARIABLE_TYPE eDestType = GetOperandDataTypeMETAL(psContext, pDest);
const SHADER_VARIABLE_TYPE eSrc0Type = GetOperandDataTypeMETAL(psContext, src0);
/*
for each component in dest[.mask]
if the corresponding component in src0 (POS-swizzle)
@@ -566,9 +564,6 @@ static void METALCallTernaryOp(HLSLCrossCompilerContext* psContext, const char*
int dest, int src0, int src1, int src2, uint32_t dataType)
{
bstring glsl = *psContext->currentShaderString;
uint32_t src2SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src2]);
uint32_t src1SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src1]);
uint32_t src0SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src0]);
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[dest]);
uint32_t destMask = GetOperandWriteMaskMETAL(&psInst->asOperands[dest]);
@@ -596,9 +591,6 @@ static void METALCallHelper3(HLSLCrossCompilerContext* psContext, const char* na
bstring glsl = *psContext->currentShaderString;
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMaskMETAL(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
uint32_t src2SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src2]);
uint32_t src1SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src1]);
uint32_t src0SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src0]);
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[dest]);
int numParenthesis = 0;
@@ -625,8 +617,6 @@ static void METALCallHelper2(HLSLCrossCompilerContext* psContext, const char* na
bstring glsl = *psContext->currentShaderString;
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMaskMETAL(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
uint32_t src1SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src1]);
uint32_t src0SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src0]);
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[dest]);
int isDotProduct = (strncmp(name, "dot", 3) == 0) ? 1 : 0;
@@ -650,8 +640,6 @@ static void METALCallHelper2Int(HLSLCrossCompilerContext* psContext, const char*
{
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_INT;
bstring glsl = *psContext->currentShaderString;
uint32_t src1SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src1]);
uint32_t src0SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src0]);
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[dest]);
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMaskMETAL(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
int numParenthesis = 0;
@@ -673,8 +661,6 @@ static void METALCallHelper2UInt(HLSLCrossCompilerContext* psContext, const char
{
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_UINT;
bstring glsl = *psContext->currentShaderString;
uint32_t src1SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src1]);
uint32_t src0SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src0]);
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[dest]);
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMaskMETAL(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
int numParenthesis = 0;
@@ -696,7 +682,6 @@ static void METALCallHelper1(HLSLCrossCompilerContext* psContext, const char* na
{
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_FLOAT;
bstring glsl = *psContext->currentShaderString;
uint32_t src0SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src0]);
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[dest]);
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMaskMETAL(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
int numParenthesis = 0;
@@ -742,7 +727,6 @@ static void METALTranslateTexelFetch(HLSLCrossCompilerContext* psContext,
bstring metal)
{
int numParenthesis = 0;
uint32_t destCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[0]);
AddIndentation(psContext);
METALAddAssignToDest(psContext, &psInst->asOperands[0], TypeFlagsToSVTTypeMETAL(METALResourceReturnTypeToFlag(psBinding->ui32ReturnType)), 4, &numParenthesis);
@@ -998,7 +982,6 @@ static void METALTranslateTexCoord(HLSLCrossCompilerContext* psContext,
const RESOURCE_DIMENSION eResDim,
Operand* psTexCoordOperand)
{
int numParenthesis = 0;
uint32_t flags = TO_AUTO_BITCAST_TO_FLOAT;
bstring glsl = *psContext->currentShaderString;
uint32_t opMask = OPERAND_4_COMPONENT_MASK_ALL;
@@ -1059,9 +1042,7 @@ static void METALTranslateTexCoord(HLSLCrossCompilerContext* psContext,
static int METALGetNumTextureDimensions(HLSLCrossCompilerContext* psContext,
const RESOURCE_DIMENSION eResDim)
{
int constructor = 0;
bstring glsl = *psContext->currentShaderString;
(void)psContext;
switch (eResDim)
{
case RESOURCE_DIMENSION_TEXTURE1D:
@@ -1176,7 +1157,6 @@ static void METALTranslateTextureSample(HLSLCrossCompilerContext* psContext, Ins
int numParenthesis = 0;
const char* funcName = "sample";
const char* offset = "";
const char* depthCmpCoordType = "";
const char* gradSwizzle = "";
@@ -1515,7 +1495,6 @@ static void METALTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext
{
bstring metal = *psContext->currentShaderString;
ShaderVarType* psVarType = NULL;
uint32_t ui32DataTypeFlag = TO_FLAG_INTEGER;
int component;
int srcComponent = 0;
@@ -1524,7 +1503,6 @@ static void METALTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext
Operand* psDestByteOff = 0;
Operand* psSrc = 0;
int structured = 0;
int groupshared = 0;
switch (psInst->eOpcode)
{
@@ -1549,7 +1527,6 @@ static void METALTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext
ASSERT(psInst->asOperands[0].eSelMode == OPERAND_4_COMPONENT_MASK_MODE);
if (psInst->asOperands[0].ui32CompMask & (1 << component))
{
SHADER_VARIABLE_TYPE eSrcDataType = GetOperandDataTypeMETAL(psContext, psSrc);
if (structured && psDest->eType != OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY)
{
@@ -1764,11 +1741,7 @@ static void METALTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext
static void METALTranslateShaderStorageLoad(HLSLCrossCompilerContext* psContext, Instruction* psInst)
{
bstring metal = *psContext->currentShaderString;
ShaderVarType* psVarType = NULL;
uint32_t aui32Swizzle[4] = { OPERAND_4_COMPONENT_X };
uint32_t ui32DataTypeFlag = TO_FLAG_INTEGER;
int component;
int destComponent = 0;
Operand* psDest = 0;
Operand* psSrcAddr = 0;
Operand* psSrcByteOff = 0;
@@ -1939,11 +1912,6 @@ static void METALTranslateShaderStorageLoad(HLSLCrossCompilerContext* psContext,
if (psVar->Class != SVC_SCALAR)
{
static const char* const m_swizzlers[] = { "x", "y", "z", "w" };
if (bytes > 16)
{
int i = 0;
}
int offset = (bytes % 16) / 4;
if (offset == 0)
{
@@ -2338,7 +2306,10 @@ void TranslateAtomicMemOpMETAL(HLSLCrossCompilerContext* psContext, Instruction*
else
{
ResourceBinding* psRes;
int foundResource = GetResourceFromBindingPoint(RGROUP_UAV,
#if defined(_DEBUG)
int foundResource =
#endif
GetResourceFromBindingPoint(RGROUP_UAV,
dest->ui32RegisterNumber,
&psContext->psShader->sInfo,
&psRes);
@@ -2655,7 +2626,6 @@ void SetDataTypesMETAL(HLSLCrossCompilerContext* psContext, Instruction* psInst,
// Only ever to int->float promotion (or int->uint), never the other way around
for (i = 0; i < i32InstCount; ++i, psInst++)
{
int k = 0;
if (psInst->ui32NumOperands == 0)
{
continue;
@@ -3065,14 +3035,16 @@ void DetectAtomicInstructionMETAL(HLSLCrossCompilerContext* psContext, Instructi
return;
}
ShaderVarType* psVarType = NULL;
if (dest->eType == OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY)
{
}
else
{
ResourceBinding* psRes;
int foundResource = GetResourceFromBindingPoint(RGROUP_UAV,
#if defined(_DEBUG)
int foundResource =
#endif
GetResourceFromBindingPoint(RGROUP_UAV,
dest->ui32RegisterNumber,
&psContext->psShader->sInfo,
&psRes);
@@ -3120,9 +3092,6 @@ void TranslateInstructionMETAL(HLSLCrossCompilerContext* psContext, Instruction*
{
uint32_t dstCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[0]);
uint32_t srcCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[1]);
uint32_t ui32DstFlags = TO_FLAG_DESTINATION;
const SHADER_VARIABLE_TYPE eSrcType = GetOperandDataTypeMETAL(psContext, &psInst->asOperands[1]);
const SHADER_VARIABLE_TYPE eDestType = GetOperandDataTypeMETAL(psContext, &psInst->asOperands[0]);
#ifdef _DEBUG
AddIndentation(psContext);
@@ -3165,8 +3134,6 @@ void TranslateInstructionMETAL(HLSLCrossCompilerContext* psContext, Instruction*
case OPCODE_ITOF://signed to float
case OPCODE_UTOF://unsigned to float
{
const SHADER_VARIABLE_TYPE eDestType = GetOperandDataTypeMETAL(psContext, &psInst->asOperands[0]);
const SHADER_VARIABLE_TYPE eSrcType = GetOperandDataTypeMETAL(psContext, &psInst->asOperands[1]);
uint32_t dstCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[0]);
uint32_t srcCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[1]);
uint32_t destMask = GetOperandWriteMaskMETAL(&psInst->asOperands[0]);
@@ -3676,7 +3643,6 @@ void TranslateInstructionMETAL(HLSLCrossCompilerContext* psContext, Instruction*
case OPCODE_GATHER4_PO_C:
{
//dest, coords, offset, tex, sampler, srcReferenceValue
const RESOURCE_DIMENSION eResDim = psContext->psShader->aeResourceDims[psInst->asOperands[3].ui32RegisterNumber];
#ifdef _DEBUG
AddIndentation(psContext);
@@ -4303,7 +4269,6 @@ void TranslateInstructionMETAL(HLSLCrossCompilerContext* psContext, Instruction*
case OPCODE_LD_MS:
{
ResourceBinding* psBinding = 0;
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[0]);
#ifdef _DEBUG
AddIndentation(psContext);
if (psInst->eOpcode == OPCODE_LD)
@@ -4830,8 +4795,6 @@ void TranslateInstructionMETAL(HLSLCrossCompilerContext* psContext, Instruction*
}
case OPCODE_RESINFO:
{
const RESOURCE_DIMENSION eResDim = psContext->psShader->aeResourceDims[psInst->asOperands[2].ui32RegisterNumber];
const RESINFO_RETURN_TYPE eResInfoReturnType = psInst->eResInfoReturnType;
uint32_t destElemCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[0]);
uint32_t destElem;
#ifdef _DEBUG
@@ -4841,7 +4804,6 @@ void TranslateInstructionMETAL(HLSLCrossCompilerContext* psContext, Instruction*
for (destElem = 0; destElem < destElemCount; ++destElem)
{
const char* swizzle[] = { ".x", ".y", ".z", ".w" };
GetResInfoDataMETAL(psContext, psInst, psInst->asOperands[2].aui32Swizzle[destElem], destElem);
}
@@ -1606,7 +1606,6 @@ static void METALMETALTranslateVariableNameWithMask(HLSLCrossCompilerContext* ps
{
// Array of matrices is treated as array of vec4s in HLSL,
// but that would mess up uniform types in metal. Do gymnastics.
SHADER_VARIABLE_TYPE eType2 = GetOperandDataTypeMETAL(psContext, psOperand->psSubOperand[0]);
uint32_t opFlags = TO_FLAG_INTEGER;
if (psVarType && (psVarType->Class == SVC_MATRIX_COLUMNS || psVarType->Class == SVC_MATRIX_ROWS) && (psVarType->Elements > 1))
@@ -1689,7 +1688,6 @@ static void METALMETALTranslateVariableNameWithMask(HLSLCrossCompilerContext* ps
}
else if (psOperand->psSubOperand[1] != NULL)
{
SHADER_VARIABLE_TYPE eType2 = GetOperandDataTypeMETAL(psContext, psOperand->psSubOperand[1]);
bcatcstr(metal, "[");
TranslateOperandMETAL(psContext, psOperand->psSubOperand[1], TO_FLAG_INTEGER);
bcatcstr(metal, "]");
@@ -2151,7 +2149,6 @@ void TranslateOperandWithMaskMETAL(HLSLCrossCompilerContext* psContext, const Op
{
bstring metal = *psContext->currentShaderString;
uint32_t ui32IgnoreSwizzle = 0;
SHADER_VARIABLE_TYPE eType = GetOperandDataTypeExMETAL(psContext, psOperand, TypeFlagsToSVTTypeMETAL(ui32TOFlag));
if (ui32TOFlag & TO_FLAG_NAME_ONLY)
{
@@ -37,7 +37,6 @@ namespace News
return false;
}
QImage image = reader.read();
int nBytes = image.sizeInBytes();
QPixmap pixmap(filename);
QByteArray data;
@@ -39,7 +39,6 @@ namespace News
pbuf->sputn(m_resource.GetData().data(), m_resource.GetData().size());
Aws::String awsUrl;
bool good = ss->good();
if (!s3Connector.PutObject(
m_resource.GetId().toStdString().c_str(),
ss,
@@ -1,138 +0,0 @@
<RCJobs>
<!--
DefaultProperties can be override from command line
pak_root - defines output folder for *.pak-s (required for NAnt build system)
-->
<DefaultProperties
game="RPGSample"
engine="Engine"
loc="LY_Localization"
src="."
trg="TempRC\"
pak_root=".\Build"
vertex_index="u16"
streaming="auto"
/>
<Properties
xml_types="*.animevents;*.animsettings;*.adb;*.bspace;*.cdf;*.chrparams;*.comb;*.dlg;*.ent;*.fsq;*.fxl;*.ik;*.json;*.lmg;*.mtl;*.setup;*.xml;*.node;*.veg"
non_xml_types="*.ag;*.gfx;*.png;*.usm;*.ogg;*.txt;*.anm;*.cal;*.i_caf;*.skel;*.skin;*.grd;*.grp;*.cfg;*.csv;*.lua;*.dat;*.ini;*.xls;*.as;*.lut;*.mp2;*.mp3;*.xma"
src_game="${game}"
src_engine="${src}\${engine}"
src_loc="${src}\${loc}"
trg_game="${trg}\${game}"
trg_engine="${trg}\${engine}"
trg_loc="${trg}\${loc}"
pak_game="${pak_root}\${game}"
pak_engine="${pak_root}\${engine}"
vtx_idx="${vertex_index}"
plat="${p}"
do_streaming="0"
/>
<if do_streaming="0">
<Properties dont_streaming="1" />
</if>
<if do_streaming="1">
<Properties dont_streaming="0" />
</if>
<ConvertJob>
<Job input="*.i_caf" animConfigFolder="Animations" sourceroot="${src_game}" targetroot="${trg_game}" cafAlignTracks="1" dbaStreamPrepare="1" />
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="*.cgf" VertexPositionFormat="exporter" SplitLODs="1" vertexindexformat="${vtx_idx}" />
<Job sourceroot="${src_engine}" targetroot="${trg_engine}" input="*.cgf" VertexPositionFormat="exporter" SplitLODs="1" vertexindexformat="${vtx_idx}" />
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="*.cga" VertexPositionFormat="exporter" SplitLODs="1" vertexindexformat="${vtx_idx}" />
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="*.tif" imagecompressor="${imagecompressor}" streaming="${do_streaming}" />
<Job sourceroot="${src_engine}" targetroot="${trg_engine}" input="*.tif" imagecompressor="${imagecompressor}" streaming="${do_streaming}" />
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="*.dds" copyonly="${dont_streaming}" />
<Job sourceroot="${src_engine}" targetroot="${trg_engine}" input="*.dds" copyonly="${dont_streaming}" />
</ConvertJob>
<PakJob>
<Job sourceroot="${trg_game}" input="Difficulty\*.*" zip="${pak_game}\GameData.pak" />
<Job sourceroot="${trg_game}" input="Libs\*.*" zip="${pak_game}\GameData.pak" />
<Job sourceroot="${trg_game}" input="Materials\*.*" zip="${pak_game}\GameData.pak" />
<Job sourceroot="${trg_game}" input="Prefabs\*.*" zip="${pak_game}\GameData.pak" />
<Job sourceroot="${trg_game}" input="Levels\*.*xml" zip="${pak_game}\GameData.pak" exclude="*filelist.*" />
<Job sourceroot="${trg_game}" input="Levels\*.*dds" zip="${pak_game}\GameData.pak" exclude="*filelist.*" />
<Job sourceroot="${trg_game}" input="Animations\*.*" zip="${pak_game}\Animations.pak" />
<Job sourceroot="${trg_game}" input="Objects\*.anm" zip="${pak_game}\Animations.pak" />
<Job sourceroot="${trg_game}" input="Objects\*.*" zip="${pak_game}\Objects.pak" exclude="Objects\level_specific\*.*;Objects\multiplayer\*.*;Objects\weapons\*.*;Objects\characters\*.*;Objects\props\*.*;*.anm" />
<Job sourceroot="${trg_game}" input="Objects\multiplayer\*.*" zip="${pak_game}\ObjectsMP.pak" exclude="*.anm" />
<Job sourceroot="${trg_game}" input="Objects\weapons\*.*" zip="${pak_game}\Weapons.pak" exclude="*.anm" />
<Job sourceroot="${trg_game}" input="Objects\characters\*.*" zip="${pak_game}\Characters.pak" exclude="*.anm" />
<Job sourceroot="${trg_game}" input="Objects\props\*.*" zip="${pak_game}\Characters.pak" exclude="*.anm" />
<Job sourceroot="${trg_game}" input="Objects\level_specific\*.*" zip="${pak_game}\LevelSpecific.pak" exclude="*.anm" />
<Job sourceroot="${trg_game}" input="Textures\*.*" zip="${pak_game}\Textures.pak" />
<Job sourceroot="${trg_game}" input="Sounds\*.*" zip="${pak_game}\Sounds.pak" zip_compression="0" />
<Job sourceroot="${trg_game}" input="Videos\*.*" zip="${pak_game}\Videos.pak" zip_compression="0" />
<Job sourceroot="${trg_game}" input="Entities\*.*" zip="${pak_game}\Scripts.pak" />
<Job sourceroot="${trg_game}" input="Scripts\*.*" zip="${pak_game}\Scripts.pak" />
<Job sourceroot="${trg_engine}" input="Shaders\*.ext;Shaders\*.cfi;Shaders\*.cfx" zip="${pak_engine}\Shaders.pak" />
<Job sourceroot="${trg_engine}" input="Config\*.*;Fonts\*.*;EngineAssets\*.*;Libs\*.*" exclude="*.tif" zip="${pak_engine}\Engine.pak"/>
<Job sourceroot="${trg_game}\Levels" input="*.*" targetroot="${pak_game}\Levels" copyonly="1" exclude="*.tif;*\ShaderCache\*"/>
</PakJob>
<CopyJob>
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="*.chr" copyonly="1"/>
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="*.skin" copyonly="1" />
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="${xml_types}" overwriteextension="xml" xmlfilterfile="${_rc_exe_folder}xmlfilter.txt" copyonly="1"/>
<Job sourceroot="${src_engine}" targetroot="${trg_engine}" input="${xml_types}" overwriteextension="xml" xmlfilterfile="${_rc_exe_folder}xmlfilter.txt" copyonly="1"/>
<Job sourceroot="${src_game}\Levels" input="*.*" targetroot="${trg_game}\Levels" copyonly="1" exclude="*.tif;*\ShaderCache\*"/>
<Job sourceroot="${src_game}\Animations" input="*.ag" targetroot="${trg_game}\Animations" copyonly="1"/>
<Job sourceroot="${src_game}\Textures" input="*.gfx;*.png;*.usm" targetroot="${trg_game}\Textures" copyonly="1"/>
<Job sourceroot="${src_game}\Difficulty" input="*.cfg;*.xls" targetroot="${trg_game}\Difficulty" copyonly="1" />
<Job sourceroot="${src_game}\Libs" input="*.cfg;*.dat;*.gfx;*.lua;*.lut;*.txt;*.usm" targetroot="${trg_game}\Libs" copyonly="1" />
<Job sourceroot="${src_game}\Sounds" input="*.bnk;*.wem" targetroot="${trg_game}\Sounds" copyonly="1" />
<Job sourceroot="${src_game}\Videos" input="*.txt;*.usm" targetroot="${trg_game}\Videos" copyonly="1" />
<Job sourceroot="${src_game}\Objects" input="*.anm;*.cal;*.gfx;*.grd;*.grp" targetroot="${trg_game}\Objects" copyonly="1" />
<Job sourceroot="${src_game}\Entities" input="*" targetroot="${trg_game}\Entities" copyonly="1" />
<Job sourceroot="${src_game}\Scripts" input="*" targetroot="${trg_game}\Scripts" copyonly="1" />
<Job sourceroot="${src_engine}\Shaders" input="*.ext;*.cfx;*.cfi;*.txt" targetroot="${trg_engine}\Shaders" copyonly="1" />
<Job sourceroot="${src_engine}\Config" input="*.cfg;*.dat;*.ini;*.txt" targetroot="${trg_engine}\Config" copyonly="1" />
<Job sourceroot="${src_engine}\EngineAssets" input="*.cfg;*.dat;*.ini;*.txt" targetroot="${trg_engine}\EngineAssets" copyonly="1" />
<Job sourceroot="${src_engine}\Fonts" input="*.ttf;*.txt" targetroot="${trg_engine}\Fonts" copyonly="1" />
<Job sourceroot="${src}" input="*.cfg" targetroot="${pak_root}" copyonly="1" />
<Job sourceroot="${src}\Bin64vc141" targetroot="${pak_root}\Bin64vc141" input="*.exe" copyonly="1"/>
<Job sourceroot="${src}\Bin64vc141" targetroot="${pak_root}\Bin64vc141" input="*.dll" copyonly="1"/>
</CopyJob>
<CleanJob>
<Job input="" targetroot="${trg}" clean_targetroot="1" />
</CleanJob>
<ValidateJob>
<Run Job="ConvertJob"/>
<Job input="" targetroot="${trg}" clean_targetroot="1" refs_scan="1" />
</ValidateJob>
<Run Job="ConvertJob"/>
<Run Job="CopyJob"/>
<Run Job="PakJob"/>
<Run Job="CleanJob"/>
</RCJobs>
@@ -1,138 +0,0 @@
<RCJobs>
<!--
DefaultProperties can be override from command line
pak_root - defines output folder for *.pak-s (required for NAnt build system)
-->
<DefaultProperties
game="RPGSample"
engine="Engine"
loc="LY_Localization"
src="."
trg="TempRC\"
pak_root=".\Build"
vertex_index="u16"
streaming="auto"
/>
<Properties
xml_types="*.animevents;*.animsettings;*.adb;*.bspace;*.cdf;*.chrparams;*.comb;*.dlg;*.ent;*.fsq;*.fxl;*.ik;*.json;*.lmg;*.mtl;*.setup;*.xml;*.node;*.veg"
non_xml_types="*.ag;*.gfx;*.png;*.usm;*.ogg;*.txt;*.anm;*.cal;*.i_caf;*.skel;*.skin;*.grd;*.grp;*.cfg;*.csv;*.lua;*.dat;*.ini;*.xls;*.as;*.lut;*.mp2;*.mp3;*.xma"
src_game="${game}"
src_engine="${src}\${engine}"
src_loc="${src}\${loc}"
trg_game="${trg}\${game}"
trg_engine="${trg}\${engine}"
trg_loc="${trg}\${loc}"
pak_game="${pak_root}\${game}"
pak_engine="${pak_root}\${engine}"
vtx_idx="${vertex_index}"
plat="${p}"
do_streaming="0"
/>
<if do_streaming="0">
<Properties dont_streaming="1" />
</if>
<if do_streaming="1">
<Properties dont_streaming="0" />
</if>
<ConvertJob>
<Job input="*.i_caf" animConfigFolder="Animations" sourceroot="${src_game}" targetroot="${trg_game}" cafAlignTracks="1" dbaStreamPrepare="1" />
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="*.cgf" VertexPositionFormat="exporter" SplitLODs="1" vertexindexformat="${vtx_idx}" />
<Job sourceroot="${src_engine}" targetroot="${trg_engine}" input="*.cgf" VertexPositionFormat="exporter" SplitLODs="1" vertexindexformat="${vtx_idx}" />
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="*.cga" VertexPositionFormat="exporter" SplitLODs="1" vertexindexformat="${vtx_idx}" />
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="*.tif" imagecompressor="${imagecompressor}" streaming="${do_streaming}" />
<Job sourceroot="${src_engine}" targetroot="${trg_engine}" input="*.tif" imagecompressor="${imagecompressor}" streaming="${do_streaming}" />
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="*.dds" copyonly="${dont_streaming}" />
<Job sourceroot="${src_engine}" targetroot="${trg_engine}" input="*.dds" copyonly="${dont_streaming}" />
</ConvertJob>
<PakJob>
<Job sourceroot="${trg_game}" input="Difficulty\*.*" zip="${pak_game}\GameData.pak" />
<Job sourceroot="${trg_game}" input="Libs\*.*" zip="${pak_game}\GameData.pak" />
<Job sourceroot="${trg_game}" input="Materials\*.*" zip="${pak_game}\GameData.pak" />
<Job sourceroot="${trg_game}" input="Prefabs\*.*" zip="${pak_game}\GameData.pak" />
<Job sourceroot="${trg_game}" input="Levels\*.*xml" zip="${pak_game}\GameData.pak" exclude="*filelist.*" />
<Job sourceroot="${trg_game}" input="Levels\*.*dds" zip="${pak_game}\GameData.pak" exclude="*filelist.*" />
<Job sourceroot="${trg_game}" input="Animations\*.*" zip="${pak_game}\Animations.pak" />
<Job sourceroot="${trg_game}" input="Objects\*.anm" zip="${pak_game}\Animations.pak" />
<Job sourceroot="${trg_game}" input="Objects\*.*" zip="${pak_game}\Objects.pak" exclude="Objects\level_specific\*.*;Objects\multiplayer\*.*;Objects\weapons\*.*;Objects\characters\*.*;Objects\props\*.*;*.anm" />
<Job sourceroot="${trg_game}" input="Objects\multiplayer\*.*" zip="${pak_game}\ObjectsMP.pak" exclude="*.anm" />
<Job sourceroot="${trg_game}" input="Objects\weapons\*.*" zip="${pak_game}\Weapons.pak" exclude="*.anm" />
<Job sourceroot="${trg_game}" input="Objects\characters\*.*" zip="${pak_game}\Characters.pak" exclude="*.anm" />
<Job sourceroot="${trg_game}" input="Objects\props\*.*" zip="${pak_game}\Characters.pak" exclude="*.anm" />
<Job sourceroot="${trg_game}" input="Objects\level_specific\*.*" zip="${pak_game}\LevelSpecific.pak" exclude="*.anm" />
<Job sourceroot="${trg_game}" input="Textures\*.*" zip="${pak_game}\Textures.pak" />
<Job sourceroot="${trg_game}" input="Sounds\*.*" zip="${pak_game}\Sounds.pak" zip_compression="0" />
<Job sourceroot="${trg_game}" input="Videos\*.*" zip="${pak_game}\Videos.pak" zip_compression="0" />
<Job sourceroot="${trg_game}" input="Entities\*.*" zip="${pak_game}\Scripts.pak" />
<Job sourceroot="${trg_game}" input="Scripts\*.*" zip="${pak_game}\Scripts.pak" />
<Job sourceroot="${trg_engine}" input="Shaders\*.ext;Shaders\*.cfi;Shaders\*.cfx" zip="${pak_engine}\Shaders.pak" />
<Job sourceroot="${trg_engine}" input="Config\*.*;Fonts\*.*;EngineAssets\*.*;Libs\*.*" exclude="*.tif" zip="${pak_engine}\Engine.pak"/>
<Job sourceroot="${trg_game}\Levels" input="*.*" targetroot="${pak_game}\Levels" copyonly="1" exclude="*.tif;*\ShaderCache\*"/>
</PakJob>
<CopyJob>
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="*.chr" copyonly="1"/>
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="*.skin" copyonly="1" />
<Job sourceroot="${src_game}" targetroot="${trg_game}" input="${xml_types}" overwriteextension="xml" xmlfilterfile="${_rc_exe_folder}xmlfilter.txt" copyonly="1"/>
<Job sourceroot="${src_engine}" targetroot="${trg_engine}" input="${xml_types}" overwriteextension="xml" xmlfilterfile="${_rc_exe_folder}xmlfilter.txt" copyonly="1"/>
<Job sourceroot="${src_game}\Levels" input="*.*" targetroot="${trg_game}\Levels" copyonly="1" exclude="*.tif;*\ShaderCache\*"/>
<Job sourceroot="${src_game}\Animations" input="*.ag" targetroot="${trg_game}\Animations" copyonly="1"/>
<Job sourceroot="${src_game}\Textures" input="*.gfx;*.png;*.usm" targetroot="${trg_game}\Textures" copyonly="1"/>
<Job sourceroot="${src_game}\Difficulty" input="*.cfg;*.xls" targetroot="${trg_game}\Difficulty" copyonly="1" />
<Job sourceroot="${src_game}\Libs" input="*.cfg;*.dat;*.gfx;*.lua;*.lut;*.txt;*.usm" targetroot="${trg_game}\Libs" copyonly="1" />
<Job sourceroot="${src_game}\Sounds" input="*.bnk;*.wem" targetroot="${trg_game}\Sounds" copyonly="1" />
<Job sourceroot="${src_game}\Videos" input="*.txt;*.usm" targetroot="${trg_game}\Videos" copyonly="1" />
<Job sourceroot="${src_game}\Objects" input="*.anm;*.cal;*.gfx;*.grd;*.grp" targetroot="${trg_game}\Objects" copyonly="1" />
<Job sourceroot="${src_game}\Entities" input="*" targetroot="${trg_game}\Entities" copyonly="1" />
<Job sourceroot="${src_game}\Scripts" input="*" targetroot="${trg_game}\Scripts" copyonly="1" />
<Job sourceroot="${src_engine}\Shaders" input="*.ext;*.cfx;*.cfi;*.txt" targetroot="${trg_engine}\Shaders" copyonly="1" />
<Job sourceroot="${src_engine}\Config" input="*.cfg;*.dat;*.ini;*.txt" targetroot="${trg_engine}\Config" copyonly="1" />
<Job sourceroot="${src_engine}\EngineAssets" input="*.cfg;*.dat;*.ini;*.txt" targetroot="${trg_engine}\EngineAssets" copyonly="1" />
<Job sourceroot="${src_engine}\Fonts" input="*.ttf;*.txt" targetroot="${trg_engine}\Fonts" copyonly="1" />
<Job sourceroot="${src}" input="*.cfg" targetroot="${pak_root}" copyonly="1" />
<Job sourceroot="${src}\Bin64vc142" targetroot="${pak_root}\Bin64vc142" input="*.exe" copyonly="1"/>
<Job sourceroot="${src}\Bin64vc142" targetroot="${pak_root}\Bin64vc142" input="*.dll" copyonly="1"/>
</CopyJob>
<CleanJob>
<Job input="" targetroot="${trg}" clean_targetroot="1" />
</CleanJob>
<ValidateJob>
<Run Job="ConvertJob"/>
<Job input="" targetroot="${trg}" clean_targetroot="1" refs_scan="1" />
</ValidateJob>
<Run Job="ConvertJob"/>
<Run Job="CopyJob"/>
<Run Job="PakJob"/>
<Run Job="CleanJob"/>
</RCJobs>
@@ -3,10 +3,10 @@
DefaultProperties can be overriden from command line.
-->
<DefaultProperties
p="pc"
game="automatedtesting"
src="cache\${game}\${p}"
trg="${game}_${p}_paks"
platform="pc"
project-path="AutomatedTesting"
src="${project-path}\Cache\${platform}"
trg="${project-path}\user\paks\${platform}"
/>
<Properties
@@ -14,14 +14,14 @@
levels_pak_types="levels\*.*"
levels_pak_excludes="*\leveldata\*;*.pak"
gems_pak_types="gems\*.json;${game}\gems.json;${game}\gem\*.*"
gems_pak_types="gems\*.json;gem\*.*"
gems_pak_excludes=""
shader_pak_types="shaders\*.ext;shaders\*.cfi;shaders\*.cfx"
shader_pak_excludes=""
src_game="${src}\${game}"
trg_paks="${trg}\${game}"
src_game="${src}"
trg_paks="${trg}"
/>
<!--
@@ -31,12 +31,9 @@
<IfNot SkipLevelPaks="1">
<Job sourceroot="${src_game}\levels" targetroot="${trg_paks}\levels" input="*.pak" copyonly="1"/>
</IfNot>
<Job sourceroot="${src_game}\config" targetroot="${trg_paks}\config" input="game.xml" copyonly="1"/>
<Job sourceroot="${src_game}\config" targetroot="${trg_paks}\config" input="editor.xml" copyonly="1"/>
<Job sourceroot="${src_game}\config" targetroot="${trg_paks}\config" input="*.awslogicalmappings.json" copyonly="1"/>
<Job sourceroot="${src_game}\config" targetroot="${trg_paks}\config" input="launcher.deployment.json" copyonly="1"/>
<Job sourceroot="${src}" targetroot="${trg}" input="engine.json" copyonly="1"/>
<Job sourceroot="${src}" targetroot="${trg}" input="engineroot.txt" copyonly="1"/>
<Job sourceroot="${src}" targetroot="${trg}" input="bootstrap.cfg" copyonly="1" recursive="0"/>
<Job sourceroot="${src}" targetroot="${trg}" input="system_windows_pc.cfg" copyonly="1" recursive="0"/>
</CopyJob>
@@ -4,10 +4,10 @@
Sounds pak properties moved here in order to override them.
-->
<DefaultProperties
p="pc"
game="automatedtesting"
src="Cache\${game}\${p}"
trg="${game}_${p}_paks"
platform="pc"
project-path="AutomatedTesting"
src="${project-path}\Cache\${platform}"
trg="${project-path}\user\paks\${platform}"
sounds_pak_types="sounds\*.*"
sounds_pak_excludes=""
@@ -39,19 +39,18 @@
shader_pak_excludes=""
engine_pak_types="fonts\*.*;engineassets\*.*;config\*.*"
engine_pak_excludes="config\editor.xml;config\game.xml"
gems_pak_types="gems\*.json;${game}\gems.json;${game}\gem\*.*"
gems_pak_types="gems\*.json;gem\*.*"
gems_pak_excludes=""
video_pak_types="*.mp4;*.mkv;*.webm;*.mov;*.bk2"
video_pak_excludes=""
misc_pak_types="*.*"
misc_pak_excludes="*cmakelists.*;editor\*.*;${levels_pak_types};${levels_pak_excludes};${game_data_pak_types};${game_data_pak_excludes};${animation_pak_types};${animation_pak_excludes};${objects_pak_types};${objects_pak_excludes};${character_pak_types};${character_pak_excludes};${textures_pak_types};${textures_pak_excludes};${sounds_pak_types};${sounds_pak_excludes};${scripts_pak_types};${scripts_pak_excludes};${shader_pak_types};${shader_pak_excludes};${engine_pak_types};${engine_pak_excludes};${gems_pak_types};${gems_pak_excludes};${video_pak_types}"
misc_pak_excludes="*cmakelists.*;editor\*.*;${levels_pak_types};${levels_pak_excludes};${game_data_pak_types};${game_data_pak_excludes};${animation_pak_types};${animation_pak_excludes};${objects_pak_types};${objects_pak_excludes};${character_pak_types};${character_pak_excludes};${textures_pak_types};${textures_pak_excludes};${sounds_pak_types};${sounds_pak_excludes};${scripts_pak_types};${scripts_pak_excludes};${shader_pak_types};${shader_pak_excludes};${engine_pak_types};${gems_pak_types};${gems_pak_excludes};${video_pak_types}"
src_game="${src}\${game}"
trg_paks="${trg}\${game}"
src_game="${src}"
trg_paks="${trg}"
/>
<!--
@@ -59,12 +58,9 @@
-->
<CopyJob>
<Job sourceroot="${src_game}\levels" targetroot="${trg_paks}\levels" input="*.pak" copyonly="1"/>
<Job sourceroot="${src_game}\config" targetroot="${trg_paks}\config" input="game.xml" copyonly="1"/>
<Job sourceroot="${src_game}\config" targetroot="${trg_paks}\config" input="editor.xml" copyonly="1"/>
<Job sourceroot="${src_game}\config" targetroot="${trg_paks}\config" input="*.awslogicalmappings.json" copyonly="1"/>
<Job sourceroot="${src_game}\config" targetroot="${trg_paks}\config" input="launcher.deployment.json" copyonly="1"/>
<Job sourceroot="${src}" targetroot="${trg}" input="engine.json" copyonly="1"/>
<Job sourceroot="${src}" targetroot="${trg}" input="engineroot.txt" copyonly="1"/>
<Job sourceroot="${src}" targetroot="${trg}" input="*.cfg" copyonly="1" recursive="0"/>
<Job sourceroot="${src}" targetroot="${trg}" input="*.xml" copyonly="1" recursive="0"/>
</CopyJob>
@@ -85,7 +81,7 @@
<Job sourceroot="${src_game}" input="${video_pak_types}" zip="${trg_paks}\videos.pak" exclude="${video_pak_excludes}" zip_compression="0" />
<Job sourceroot="${src_game}" input="${shader_pak_types}" zip="${trg_paks}\shaders.pak" exclude="${shader_pak_excludes}" />
<Job sourceroot="${src_game}" input="${engine_pak_types}" zip="${trg_paks}\engine.pak" exclude="${engine_pak_excludes}" />
<Job sourceroot="${src_game}" input="${engine_pak_types}" zip="${trg_paks}\engine.pak" />
<Job sourceroot="${src_game}" input="${misc_pak_types}" zip="${trg_paks}\misc.pak" exclude="${misc_pak_excludes}" />
<Job sourceroot="${src}" input="${gems_pak_types}" zip="${trg_paks}\gems\gems.pak" exclude="${gems_pak_excludes}" />
@@ -1,95 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#include "ResourceCompiler_precompiled.h"
#include "CmdLine.h"
#include "Config.h"
//////////////////////////////////////////////////////////////////////////
static void AddParameterToConfig(Config* config, const char* parameter)
{
// Split on key/value pair
const string p = parameter;
const size_t splitterPos = p.find('=');
if (splitterPos != string::npos)
{
const string key = p.substr(0, splitterPos);
const string value = p.substr(splitterPos + 1);
if (!key.empty())
{
config->SetKeyValue(eCP_PriorityCmdline, key.c_str(), value.c_str());
}
}
else
{
config->SetKeyValue(eCP_PriorityCmdline, p.c_str(), "");
}
}
//////////////////////////////////////////////////////////////////////////
//Return true if the parameter is a file spec
/////////////////////////////////////////////////////////////////////////
static bool isValidFileSpecCheck(const string& path)
{
if (path[0] == '-')
{
return false;
}
//Since Macs can have '/' in the file paths check for '='
//to confirm that it is a file spec and not a config argument.
if (path[0] == '/')
{
const size_t equalPos = path.find('=');
if (equalPos != string::npos)
{
return false;
}
else
{
//You can have a config argument that does not have a '='. Use
//extension path to determine if it is a file spec.
return PathHelpers::FindExtension(path) != "";
}
}
return true;
}
//////////////////////////////////////////////////////////////////////////
void CmdLine::Parse(const std::vector<string>& args, Config* config, string& fileSpec)
{
assert(config);
fileSpec.clear();
for (int i = 1; i < (int)args.size(); ++i)
{
const char* const parameter = args[i].c_str();
bool isValidFileSpec = isValidFileSpecCheck(string(parameter));
if (isValidFileSpec)
{
if (fileSpec.empty())
{
fileSpec = parameter;
}
}
else
{
AddParameterToConfig(config, parameter + 1);
}
}
}
-26
View File
@@ -1,26 +0,0 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
// Original file Copyright Crytek GMBH or its affiliates, used under license.
#ifndef CRYINCLUDE_TOOLS_RC_RESOURCECOMPILER_CMDLINE_H
#define CRYINCLUDE_TOOLS_RC_RESOURCECOMPILER_CMDLINE_H
#pragma once
class Config;
// Command line parser
namespace CmdLine
{
void Parse(const std::vector<string>& args, Config* config, string& fileSpec);
};
#endif // CRYINCLUDE_TOOLS_RC_RESOURCECOMPILER_CMDLINE_H
@@ -1294,7 +1294,7 @@ void ResourceCompiler::LogMultiLine(const char* szText)
void ResourceCompiler::ShowHelp(const bool bDetailed)
{
RCLog("");
RCLog("Usage: RC filespec /p=<platform> [/Key1=Value1] [/Key2=Value2] etc...");
RCLog("Usage: RC filespec --platform=<platform> [--Key1=Value1] [--Key2=Value2] etc...");
if (bDetailed)
{
@@ -2372,8 +2372,6 @@ typedef std::set<const char*, stl::less_strcmp<const char*> > References;
void ResourceCompiler::ScanForAssetReferences(std::vector<string>& outReferences, const string& refsRoot)
{
const IConfig* const config = &m_multiConfig.getConfig();
const char* const scanRoot = ".";
RCLog("Scanning for asset references in \"%s\"", scanRoot);
@@ -2526,8 +2524,6 @@ static bool MatchesWildcardsSet(const string& str, const std::vector<string>& ma
//////////////////////////////////////////////////////////////////////////
void ResourceCompiler::SaveAssetReferences(const std::vector<string>& references, const string& filename, const string& includeMasksStr, const string& excludeMasksStr)
{
const IConfig* const config = &m_multiConfig.getConfig();
std::vector<string> includeMasks;
StringHelpers::Split(includeMasksStr, ";", false, includeMasks);
@@ -2868,8 +2864,6 @@ int ResourceCompiler::ProcessJobFile()
//////////////////////////////////////////////////////////////////////////
void ResourceCompiler::ExtractJobDefaultProperties(std::vector<string>& properties, const XmlNodeRef& jobNode)
{
IConfig* const config = &m_multiConfig.getConfig();
if (jobNode->isTag("DefaultProperties"))
{
// Attributes are config modifiers.
@@ -3109,12 +3103,12 @@ int ResourceCompiler::EvaluateJobXmlNode(CPropertyVars& properties, XmlNodeRef&
// Check current platform property against start-up platform setting
// Reason: This setting cannot be modified after start-up
const char* pCurrentPlatform = NULL;
if (config->GetKeyValue("p", pCurrentPlatform) && pCurrentPlatform)
if (config->GetKeyValue("platform", pCurrentPlatform) && pCurrentPlatform)
{
int currentPlatformIndex = FindPlatform(pCurrentPlatform);
if (GetMultiplatformConfig().getActivePlatform() != currentPlatformIndex)
{
RCLogWarning("The platform property '/p=%s' is ignored because it can only be specified on the command-line", pCurrentPlatform);
RCLogWarning("The platform property '--platform=%s' is ignored because it can only be specified on the command-line", pCurrentPlatform);
}
}
@@ -3257,6 +3251,8 @@ void ResourceCompiler::RegisterDefaultKeys()
{
RegisterKey("_debug", ""); // hidden key for debug-related activities. parsing is module-dependent and subject to change without prior notice.
RegisterKey("project-path", "Path to project. Used to find files related to the project.");
RegisterKey("project-name", R"(Name of the project. It's value is derived from the project.json file "project_name" field.)");
RegisterKey("wait",
"wait for an user action on start and/or finish of RC:\n"
"0-don't wait (default),\n"
@@ -3267,7 +3263,7 @@ void ResourceCompiler::RegisterDefaultKeys()
RegisterKey("wx", "pause and display message box in case of warning or error");
RegisterKey("recursive", "traverse input directory with sub folders");
RegisterKey("refresh", "force recompilation of resources with up to date timestamp");
RegisterKey("p", "to specify platform (for supported names see [_platform] sections in ini)");
RegisterKey("platform", "to specify platform (for supported names see [_platform] sections in ini)");
RegisterKey("pi", "provides the platform id from the Asset Processor");
RegisterKey("statistics", "log statistics to rc_stats_* files");
RegisterKey("dependencies",
@@ -3281,7 +3277,6 @@ void ResourceCompiler::RegisterDefaultKeys()
RegisterKey("logfiles", "to suppress generating log file rc_log.log");
RegisterKey("logprefix", "prepends this prefix to every log file name used (by default the prefix is the exe's folder).");
RegisterKey("logtime", "logs time passed: 0=off, 1=on (default)");
RegisterKey("gameroot", "The root of the current game project. Used to find files related to the current game.");
RegisterKey("watchfolder", "The watched root folder that this file is located in. Used to produce the relative asset name.");
RegisterKey("nosourcecontrol", "Boolean - if true, disables initialization of source control. Disabling Source Control in the editor automatically disables it here, too.");
RegisterKey("sourceroot", "list of source folders separated by semicolon");
@@ -3334,7 +3329,6 @@ void ResourceCompiler::RegisterDefaultKeys()
RegisterKey("job", "Process a job xml file");
RegisterKey("jobtarget", "Run only a job with specific name instead of whole job-file. Used only with /job option");
RegisterKey("unittest", "Run the unit tests for resource compiler and nothing else");
RegisterKey("gamesubdirectory", "The relative path to game folder from root from @devroot@. Defines @devassets@ when concatenated with @devroot@. Used to find files related to the this game.");
RegisterKey("unattended", "Prevents RC from opening any dialogs or message boxes");
RegisterKey("createjobs", "Instructs RC to read the specified input file (a CreateJobsRequest) and output a CreateJobsResponse");
RegisterKey("port", "Specifies the port that should be used to connect to the asset processor. If not set, the default from the bootstrap cfg will be used instead");
@@ -204,9 +204,6 @@ bool ZipEncryptor::ParseKey(uint32 outputKey[4], const char* inputString)
return false;
}
const char* p = inputString;
const char* end = p + len;
size_t i = 0;
while (i != numBytes)
{
+38 -16
View File
@@ -31,7 +31,6 @@
#include <ResourceCompiler.h>
#include <IResourceCompilerHelper.h>
#include <CmdLine.h>
#include <CryLibrary.h>
#include <ZipEncryptor.h>
@@ -295,7 +294,7 @@ static bool RegisterConvertors(ResourceCompiler* pRc)
strDir.append(AZ_CORRECT_FILESYSTEM_SEPARATOR_STRING);
AZ::IO::LocalFileIO localFile;
bool foundOK = localFile.FindFiles(strDir.c_str(), CryLibraryDefName("ResourceCompiler*"), [&](const char* pluginFilename) -> bool
localFile.FindFiles(strDir.c_str(), CryLibraryDefName("ResourceCompiler*"), [&](const char* pluginFilename) -> bool
{
#if defined(AZ_PLATFORM_WINDOWS)
HMODULE hPlugin = CryLoadLibrary(pluginFilename);
@@ -413,7 +412,21 @@ int rcmain(int argc, char** argv, [[maybe_unused]] char** envp)
bool enableSourceControl = settings.value("RC_EnableSourceControl", true).toBool();
mainConfig.SetKeyValue(eCP_PriorityCmdline, "nosourcecontrol", enableSourceControl ? "0" : "1");
CmdLine::Parse(args, &mainConfig, fileSpec);
AZ::CommandLine commandLine;
commandLine.Parse(argc, argv);
for (auto&& [option, value] : commandLine)
{
if (!option.empty())
{
mainConfig.SetKeyValue(EConfigPriority::eCP_PriorityCmdline, option.c_str(), value.c_str());
}
else
{
fileSpec = commandLine.GetMiscValue(0).c_str();
}
}
// initialize rc (also initializes logs)
rc.Init(mainConfig);
@@ -518,16 +531,20 @@ int rcmain(int argc, char** argv, [[maybe_unused]] char** envp)
// Obtain target platform
int platform;
{
string platformStr = mainConfig.GetAsString("p", "", "");
string platformStr = mainConfig.GetAsString("platform", "", "");
if (platformStr.empty())
{
platformStr = mainConfig.GetAsString("p", "", "");
}
if (platformStr.empty())
{
if (!mainConfig.GetAsBool("version", false, true))
{
RCLog("Platform (/p) not specified, defaulting to 'pc'.");
RCLog("Platform (-p) not specified, defaulting to 'pc'.");
RCLog("");
}
platformStr = "pc";
mainConfig.SetKeyValue(eCP_PriorityCmdline, "p", platformStr.c_str());
mainConfig.SetKeyValue(eCP_PriorityCmdline, "platform", platformStr.c_str());
}
platform = rc.FindPlatform(platformStr.c_str());
@@ -548,7 +565,7 @@ int rcmain(int argc, char** argv, [[maybe_unused]] char** envp)
}
}
const IConfig& config = rc.GetMultiplatformConfig().getConfig();
IConfig& config = rc.GetMultiplatformConfig().getConfig();
{
RCLog("Initializing pak management");
@@ -567,23 +584,28 @@ int rcmain(int argc, char** argv, [[maybe_unused]] char** envp)
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_O3deUserRegistry(settingsRegistry, AZ_TRAIT_OS_PLATFORM_CODENAME, {});
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(settingsRegistry, commandLine, false);
string projectPath = config.GetAsString("gameroot", "", "");
const auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString::format(
"%s/project_path", AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey);
string projectPath = config.GetAsString("project-path", "", "");
if (!projectPath.empty())
{
const auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString::format(
"%s/project_path", AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey);
settingsRegistry.Set(projectPathKey, projectPath.c_str());
}
string gameName = config.GetAsString("gamesubdirectory", "", "");
if (!gameName.empty())
// Update the Runtime FilePaths and project settings
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(settingsRegistry);
// Set the project-path and project-name entries from the Settings registry into the RC config structure
if (AZ::IO::FixedMaxPathString projPath; settingsRegistry.Get(projPath, AZ::SettingsRegistryMergeUtils::FilePathKey_ProjectPath))
{
const auto projectNameKey = AZ::SettingsRegistryInterface::FixedValueString::format(
"%s/project_name", AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey);
settingsRegistry.Set(projectNameKey, gameName.c_str());
config.SetKeyValue(eCP_PriorityCmdline, "project-path", projPath.c_str());
}
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(settingsRegistry);
const auto projectNameKey = AZ::SettingsRegistryInterface::FixedValueString::format(
"%s/project_name", AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey);
if (AZ::IO::FixedMaxPathString projName; settingsRegistry.Get(projName, projectNameKey))
{
config.SetKeyValue(eCP_PriorityCmdline, "project-name", projName.c_str());
}
// and because we're a tool, add the tool folders:
if (AZ::SettingsRegistryInterface::FixedValueString appRoot; settingsRegistry.Get(appRoot, AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder))
{
@@ -28,7 +28,6 @@ set(FILES
PakHelpers.h
PakManager.h
CfgFile.cpp
CmdLine.cpp
Config.cpp
DependencyList.cpp
ExcelExport.cpp
@@ -40,7 +39,6 @@ set(FILES
ResourceCompiler_precompiled.h
TextFileReader.cpp
CfgFile.h
CmdLine.h
Config.h
ConvertContext.h
DebugLog.h
@@ -948,8 +948,6 @@ bool AlembicCompiler::CompileStaticMeshData(GeomCache::Node& node, Alembic::AbcG
// Check basic mesh parameters
Alembic::AbcGeom::IPolyMeshSchema& meshSchema = mesh.getSchema();
Alembic::AbcGeom::MeshTopologyVariance topologyVariance = meshSchema.getTopologyVariance();
Alembic::Abc::TimeSampling& meshTimeSampling = *meshSchema.getTimeSampling();
size_t numMeshSamples = meshSchema.getNumSamples();
std::shared_ptr<GeomCache::Mesh> pMesh(new GeomCache::Mesh);
pMesh->m_constantStreams = GeomCacheFile::EStreams(0);
@@ -1999,8 +1997,8 @@ bool AlembicCompiler::CompileFullMesh(GeomCache::Mesh& mesh, const size_t curren
// Compute mesh hash
uint64 meshHash = 0;
size_t numVertexHashes = abcVertexHashes.size();
for (size_t i = 0; i < abcVertexHashes.size(); ++i)
const size_t numVertexHashes = abcVertexHashes.size();
for (size_t i = 0; i < numVertexHashes; ++i)
{
uint64 vertexHash = abcVertexHashes[i];
AlembicCompilerHashCombine<uint64>(meshHash, vertexHash);
@@ -2346,7 +2344,7 @@ bool AlembicCompiler::CompileVertices(std::vector<AlembicCompilerVertex>& vertic
else
{
assert(meshData.m_positions.size() == vertices.size());
if (!meshData.m_positions.size() == vertices.size())
if (meshData.m_positions.size() != vertices.size())
{
return false;
}
@@ -45,7 +45,7 @@ void GeomCacheDiskWriteThread::Write(std::vector<char>& buffer, long offset, int
// Write and clear current read buffer
const size_t bufferSize = buffer.size();
m_bytesWritten += bufferSize;
size_t bytesWritten = fwrite(buffer.data(), 1, bufferSize, m_fileHandle);
/*size_t bytesWritten =*/ fwrite(buffer.data(), 1, bufferSize, m_fileHandle);
//RCLog("Written %Iu/%Iu bytes with error: %d", bytesWritten, bufferSize, ferror(m_fileHandle));
}
@@ -50,7 +50,6 @@ namespace AZ
application.Start(descriptor);
AssetBuilderSDK::InitializeSerializationContext();
bool result = false;
AssetBuilderSDK::ProcessJobResponse response;
// Read ProcessJobRequest.xml from the output folder
@@ -275,12 +275,21 @@ void DataWriter::ExpandBuffer(const uint32 addBytes)
const uint32 newBufferSize = m_currentBufferSize + BUFFERINCREASESIZE;
if (m_outputBuffer)
{
m_outputBuffer = realloc(m_outputBuffer, newBufferSize);
void* tmpBuffer = realloc(m_outputBuffer, newBufferSize);
AZ_Assert(
tmpBuffer != nullptr,
"realloc failed, this is possible when allocating a large data array whose size is comparable to RAM size, and also when "
"the memory is highly segmented");
if (tmpBuffer)
{
m_outputBuffer = tmpBuffer;
m_currentBufferSize = newBufferSize;
}
}
else
{
m_outputBuffer = malloc(newBufferSize);
m_currentBufferSize = newBufferSize;
}
m_currentBufferSize = newBufferSize;
}
}
@@ -422,22 +422,22 @@ bool CStatCGFCompiler::DebugDumpCGF(const char* sourceFileName, const char* outp
}
{
const CPhysicalizeInfoCGF* pPhys = pCGF->GetPhysicalizeInfo();
//const CPhysicalizeInfoCGF* pPhys = pCGF->GetPhysicalizeInfo();
fprintf(f, "\t" "PhysicalizeInfo: (not printed yet)\n");
}
{
CExportInfoCGF* pExport = pCGF->GetExportInfo();
//CExportInfoCGF* pExport = pCGF->GetExportInfo();
fprintf(f, "\t" "ExportInfo: (not printed yet)\n");
}
{
CSkinningInfo* pSkin = pCGF->GetSkinningInfo();
//CSkinningInfo* pSkin = pCGF->GetSkinningInfo();
fprintf(f, "\t" "SkinningInfo: (not printed yet)\n");
}
{
SFoliageInfoCGF* pSkin = pCGF->GetFoliageInfo();
//SFoliageInfoCGF* pSkin = pCGF->GetFoliageInfo();
fprintf(f, "\t" "FoliageInfo: (not printed yet)\n");
}
@@ -797,7 +797,7 @@ bool CStatCGFCompiler::Process()
sourceWatchFolder = m_CC.m_config->GetAsString("sourceroot", "", "").c_str();
if (sourceWatchFolder.empty())
{
sourceWatchFolder = m_CC.m_config->GetAsString("gameroot", "", "").c_str();
sourceWatchFolder = m_CC.m_config->GetAsString("project-path", "", "").c_str();
}
}
@@ -81,8 +81,6 @@ namespace AZ
result += SceneAPI::Events::Process(containerContext);
result += SceneAPI::Events::Process<ContainerExportContext>(containerContext, Phase::Filling);
const SceneAPI::Containers::SceneGraph& graph = context.m_scene.GetGraph();
ProcessMeshType(containerContext, content, targetNodes, PHYS_GEOM_TYPE_NONE);
result += SceneAPI::Events::Process<ContainerExportContext>(containerContext, Phase::Finalizing);
@@ -58,9 +58,7 @@ namespace AZ
return SceneEvents::ProcessingResult::Ignored;
}
const SceneContainers::SceneGraph& graph = context.m_scene.GetGraph();
const SceneDataTypes::IGroup& group = context.m_group;
const SceneContainers::SceneGraph& graph = context.m_scene.GetGraph();
SceneEvents::ProcessingResultCombiner result;
@@ -146,4 +144,4 @@ namespace AZ
return SceneEvents::ProcessingResult::Success;
}
} // namespace RC
} // namespace AZ
} // namespace AZ
@@ -146,7 +146,7 @@ namespace AZ
AZ::CommandLine* commandLine = application.GetAzCommandLine();
AZStd::string overrideProjectPath = m_context.m_config->GetAsString("gameroot", "", "").c_str();
AZStd::string overrideProjectPath = m_context.m_config->GetAsString("project-path", "", "").c_str();
if (!overrideProjectPath.empty())
{
auto overrideArgs = AZStd::string::format(
@@ -158,18 +158,6 @@ namespace AZ
commandLine->Parse(commandLineArgs);
}
AZStd::string overrideProjectName = m_context.m_config->GetAsString("gamesubdirectory", "", "").c_str();
if (!overrideProjectName.empty())
{
auto gameNameOverride = AZStd::string::format("--regset=%s/project_name=%s", AZ::SettingsRegistryMergeUtils::ProjectSettingsRootKey,
overrideProjectName.c_str());
AZ::CommandLine::ParamContainer commandLineArgs;
commandLine->Dump(commandLineArgs);
commandLineArgs.emplace_back(gameNameOverride.c_str(), gameNameOverride.size());
commandLine->Parse(commandLineArgs);
}
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_CommandLine(registry, *commandLine, false);
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(registry);
@@ -298,7 +286,7 @@ namespace AZ
//the project name can be overridden, check it
AZStd::string overrideProjectName;
overrideProjectName = m_context.m_config->GetAsString("gamesubdirectory", "", "");
overrideProjectName = m_context.m_config->GetAsString("project-name", "", "");
if (!overrideProjectName.empty())
{
connectionSettings.m_projectName = overrideProjectName;
@@ -319,12 +307,12 @@ namespace AZ
bool SceneCompiler::LoadAndExportScene(const AssetBuilderSDK::ProcessJobRequest& request, AssetBuilderSDK::ProcessJobResponse& response)
{
const string platformName = m_context.m_config->GetAsString("p", "<unknown>", "<invalid>");
const string platformName = m_context.m_config->GetAsString("platform", "<unknown>", "<invalid>");
AZ_TraceContext("Platform", platformName.c_str());
if (platformName == "<unknown>")
{
AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "No target platform provided - this compiler requires the /p=platformIdentifier option\n");
AZ_TracePrintf(SceneAPI::Utilities::ErrorWindow, "No target platform provided - this compiler requires the --platform=platformIdentifier option\n");
return false;
}
@@ -35,7 +35,7 @@ protected:
{
sceneCoreModule = AZ::DynamicModuleHandle::Create("SceneCore");
AZ_Assert(sceneCoreModule, "ResourceCompilerScene unit tests failed to create SceneCore module.");
bool loaded = sceneCoreModule->Load(false);
[[maybe_unused]] bool loaded = sceneCoreModule->Load(false);
AZ_Assert(loaded, "ResourceCompilerScene unit tests failed to load SceneCore module.");
auto init = sceneCoreModule->GetFunction<AZ::InitializeDynamicModuleFunction>(AZ::InitializeDynamicModuleFunctionName);
AZ_Assert(init, "ResourceCompilerScene unit tests failed to find the initialization function the SceneCore module.");
@@ -44,7 +44,7 @@ protected:
{
sceneDataModule = AZ::DynamicModuleHandle::Create("SceneData");
AZ_Assert(sceneDataModule, "ResourceCompilerScene unit tests failed to create SceneData module.");
bool loaded = sceneDataModule->Load(false);
[[maybe_unused]] bool loaded = sceneDataModule->Load(false);
AZ_Assert(loaded, "ResourceCompilerScene unit tests failed to load SceneData module.");
auto init = sceneDataModule->GetFunction<AZ::InitializeDynamicModuleFunction>(AZ::InitializeDynamicModuleFunctionName);
AZ_Assert(init, "ResourceCompilerScene unit tests failed to find the initialization function the SceneData module.");
@@ -54,7 +54,7 @@ protected:
{
fbxSceneBuilderModule = AZ::DynamicModuleHandle::Create("FbxSceneBuilder");
AZ_Assert(fbxSceneBuilderModule, "ResourceCompilerScene unit tests failed to create FbxSceneBuilder module.");
bool loaded = fbxSceneBuilderModule->Load(false);
[[maybe_unused]] bool loaded = fbxSceneBuilderModule->Load(false);
AZ_Assert(loaded, "ResourceCompilerScene unit tests failed to load FbxSceneBuilder module.");
}
}
@@ -74,8 +74,6 @@ namespace AZ
AZStd::shared_ptr<const FbxBlendShapeWrapper> FbxMeshWrapper::GetBlendShape(int index) const
{
int deformerCount = m_fbxMesh->GetDeformerCount();
int blendshapeCount = m_fbxMesh->GetDeformerCount(FbxDeformer::eBlendShape);
FbxBlendShape* blendShape = static_cast<FbxBlendShape*>(m_fbxMesh->GetDeformer(index, FbxDeformer::eBlendShape));
return blendShape ? AZStd::make_shared<const FbxBlendShapeWrapper>(blendShape) : nullptr;
}
@@ -507,7 +507,6 @@ namespace AZ
return Events::ProcessingResult::Ignored;
}
Events::ProcessingResultCombiner combinedAnimationResult;
aiNode* currentNode = context.m_sourceNode.GetAssImpNode();
// In:
// Key index
@@ -106,10 +106,6 @@ namespace AZ
RenamedNodesMap::SanitizeNodeName(nodeName, context.m_scene.GetGraph(), context.m_currentGraphPosition, "BlendShape");
AZ_TraceContext("Blend shape name", nodeName);
int firstMeshVertexIndex = -1;
int previousMeshVertexIndex = -1;
int verticesInMeshFace = 0;
AZStd::bitset<SceneData::GraphData::BlendShapeData::MaxNumUVSets> uvSetUsedFlags;
for (AZ::u8 uvSetIndex = 0; uvSetIndex < SceneData::GraphData::BlendShapeData::MaxNumUVSets; ++uvSetIndex)
{
@@ -131,16 +127,17 @@ namespace AZ
context.m_sourceSceneSystem.SwapVec3ForUpAxis(vertex);
context.m_sourceSceneSystem.ConvertUnit(vertex);
blendShapeData->AddPosition(vertex);
blendShapeData->SetVertexIndexToControlPointIndexMap(vertIdx, vertIdx);
// Add normals
AZ::Vector3 normal;
if (aiAnimMesh->HasNormals())
{
normal = AssImpSDKWrapper::AssImpTypeConverter::ToVector3(aiAnimMesh->mNormals[vertIdx]);
AZ::Vector3 normal(AssImpSDKWrapper::AssImpTypeConverter::ToVector3(aiAnimMesh->mNormals[vertIdx]));
context.m_sourceSceneSystem.SwapVec3ForUpAxis(normal);
normal.NormalizeSafe();
blendShapeData->AddNormal(normal);
}
blendShapeData->AddVertex(vertex, normal);
blendShapeData->SetVertexIndexToControlPointIndexMap(vertIdx, vertIdx);
// Add tangents and bitangents
if (aiAnimMesh->HasTangentsAndBitangents())
@@ -64,7 +64,6 @@ namespace AZ
return meshDataResult.GetError();
}
const SceneData::GraphData::MeshData* const parentMeshData(meshDataResult.GetValue());
int parentMeshIndex = parentMeshData->GetSdkMeshIndex();
size_t vertexCount = parentMeshData->GetVertexCount();
@@ -144,7 +144,6 @@ namespace AZ
}
blendShapeIndex++;
int blendShapeChannelCount = pDeformer->GetBlendShapeChannelCount();
int stackCount = context.m_sourceScene.GetAnimationStackCount();
auto animStackWrapper = context.m_sourceScene.GetAnimationStackAt(0);
const FbxSDKWrapper::FbxTimeWrapper startTime = animStackWrapper->GetLocalTimeSpan().GetStartTime();
@@ -248,7 +248,8 @@ namespace AZ
sceneSystem.SwapVec3ForUpAxis(meshVertexNormal);
meshVertexNormal.Normalize();
blendShape->AddVertex(meshVertexPosition, meshVertexNormal);
blendShape->AddPosition(meshVertexPosition);
blendShape->AddNormal(meshVertexNormal);
// Add face
{
@@ -39,6 +39,7 @@ namespace AZ
AZ_TracePrintf(SceneAPI::Utilities::LogWindow, "AssImpSceneWrapper::LoadSceneFromFile %s", fileName);
AZ_TraceContext("Filename", fileName);
m_importer.SetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, false);
m_importer.SetPropertyBool(AI_CONFIG_IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES, false);
m_sceneFileName = fileName;
m_assImpScene = m_importer.ReadFile(fileName,
aiProcess_Triangulate //Triangulates all faces of all meshes
@@ -30,6 +30,8 @@ namespace AZ
virtual ~IAnimationData() override = default;
void CloneAttributesFrom([[maybe_unused]] const IGraphObject* sourceObject) override {}
virtual size_t GetKeyFrameCount() const = 0;
virtual const MatrixType& GetKeyFrame(size_t index) const = 0;
virtual double GetTimeStepBetweenFrames() const = 0;
@@ -43,6 +45,8 @@ namespace AZ
virtual ~IBlendShapeAnimationData() override = default;
void CloneAttributesFrom([[maybe_unused]] const IGraphObject* sourceObject) override {}
virtual const char* GetBlendShapeName() const = 0;
virtual size_t GetKeyFrameCount() const = 0;
virtual double GetKeyFrame(size_t index) const = 0;
@@ -46,12 +46,15 @@ namespace AZ
virtual ~IBlendShapeData() override = default;
void CloneAttributesFrom([[maybe_unused]] const IGraphObject* sourceObject) override {}
virtual size_t GetUsedControlPointCount() const = 0;
virtual int GetControlPointIndex(int vertexIndex) const = 0;
virtual int GetUsedPointIndexForControlPoint(int controlPointIndex) const = 0;
virtual unsigned int GetVertexCount() const = 0;
virtual unsigned int GetFaceCount() const = 0;
virtual const Face& GetFaceInfo(unsigned int index) const = 0;
virtual const AZ::Vector3& GetPosition(unsigned int index) const = 0;
virtual const AZ::Vector3& GetNormal(unsigned int index) const = 0;
@@ -31,6 +31,8 @@ namespace AZ
virtual ~IBoneData() override = default;
void CloneAttributesFrom([[maybe_unused]] const IGraphObject* sourceObject) override {}
virtual const MatrixType& GetWorldTransform() const = 0;
void GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const override
@@ -47,6 +47,8 @@ namespace AZ
~IMaterialData() override = default;
void CloneAttributesFrom([[maybe_unused]] const IGraphObject* sourceObject) override {}
void GetDebugOutput(AZ::SceneAPI::Utilities::DebugOutput& output) const override
{
output.Write("MaterialName", GetMaterialName());
@@ -51,6 +51,15 @@ namespace AZ
virtual ~IMeshData() override = default;
void CloneAttributesFrom(const IGraphObject* sourceObject) override
{
if (const auto* typedSource = azrtti_cast<const IMeshData*>(sourceObject))
{
SetUnitSizeInMeters(typedSource->GetUnitSizeInMeters());
SetOriginalUnitSizeInMeters(typedSource->GetOriginalUnitSizeInMeters());
}
}
virtual unsigned int GetVertexCount() const = 0;
virtual bool HasNormalData() const = 0;
@@ -36,6 +36,8 @@ namespace AZ
virtual ~IMeshVertexBitangentData() override = default;
void CloneAttributesFrom([[maybe_unused]] const IGraphObject* sourceObject) override {}
virtual size_t GetCount() const = 0;
virtual const AZ::Vector3& GetBitangent(size_t index) const = 0;
virtual void SetBitangent(size_t vertexIndex, const AZ::Vector3& bitangent) = 0;
@@ -47,4 +49,4 @@ namespace AZ
} // DataTypes
} // SceneAPI
} // AZ
} // AZ
@@ -88,6 +88,8 @@ namespace AZ
virtual ~IMeshVertexColorData() override = default;
void CloneAttributesFrom([[maybe_unused]] const IGraphObject* sourceObject) override {}
virtual const AZ::Name& GetCustomName() const = 0;
virtual size_t GetCount() const = 0;
@@ -47,6 +47,8 @@ namespace AZ
virtual ~IMeshVertexTangentData() override = default;
void CloneAttributesFrom([[maybe_unused]] const IGraphObject* sourceObject) override {}
virtual size_t GetCount() const = 0;
virtual const AZ::Vector4& GetTangent(size_t index) const = 0;
virtual void SetTangent(size_t vertexIndex, const AZ::Vector4& tangent) = 0;
@@ -57,4 +59,4 @@ namespace AZ
};
} // DataTypes
} // SceneAPI
} // AZ
} // AZ
@@ -36,6 +36,8 @@ namespace AZ
virtual ~IMeshVertexUVData() override = default;
void CloneAttributesFrom([[maybe_unused]] const IGraphObject* sourceObject) override {}
virtual const AZ::Name& GetCustomName() const = 0;
virtual size_t GetCount() const = 0;
@@ -36,6 +36,8 @@ namespace AZ
virtual ~ISkinWeightData() override = default;
void CloneAttributesFrom([[maybe_unused]] const IGraphObject* sourceObject) override {}
virtual size_t GetVertexCount() const = 0;
virtual size_t GetLinkCount(size_t vertexIndex) const = 0;
virtual const Link& GetLink(size_t vertexIndex, size_t linkIndex) const = 0;

Some files were not shown because too many files have changed in this diff Show More