DXC Validation Error Difficult to See in AP Window (#4982)

* DXC Validation Error Difficult to See in AP Window

Renamed ReportErrorMessages() as ReportMessages()
All the message will be printed as a single AZ_Error()
or AZ_Warning() instead of mingled AZ_Error/AZ_Warning/AZ_TRacePrintf
which was making the output hard to read.

Signed-off-by: garrieta <garrieta@amazon.com>
monroegm-disable-blank-issue-2
galibzon 4 years ago committed by GitHub
parent a2eca9de3d
commit b541d69efc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -477,8 +477,8 @@ namespace AZ
preprocessorOptions.m_predefinedMacros.end(), macroDefinitionsToAdd.begin(), macroDefinitionsToAdd.end()); preprocessorOptions.m_predefinedMacros.end(), macroDefinitionsToAdd.begin(), macroDefinitionsToAdd.end());
// Run the preprocessor. // Run the preprocessor.
PreprocessorData output; PreprocessorData output;
PreprocessFile(prependedAzslFilePath, output, preprocessorOptions, true, true); const bool preprocessorSuccess = PreprocessFile(prependedAzslFilePath, output, preprocessorOptions, true, true);
RHI::ReportErrorMessages(ShaderAssetBuilderName, output.diagnostics); RHI::ReportMessages(ShaderAssetBuilderName, output.diagnostics, !preprocessorSuccess);
// Dump the preprocessed string as a flat AZSL file with extension .azslin, which will be given to AZSLc to generate the HLSL file. // Dump the preprocessed string as a flat AZSL file with extension .azslin, which will be given to AZSLc to generate the HLSL file.
AZStd::string superVariantAzslinStemName = shaderFileName; AZStd::string superVariantAzslinStemName = shaderFileName;
if (!supervariantInfo.m_name.IsEmpty()) if (!supervariantInfo.m_name.IsEmpty())

@ -83,11 +83,12 @@ namespace AZ
const AZStd::string& shaderSourcePathForDebug, const AZStd::string& shaderSourcePathForDebug,
const char* toolNameForLog); const char* toolNameForLog);
//! Reports error messages to AZ_Error and/or AZ_Warning, given a text blob that potentially contains many lines of errors and warnings. //! Reports messages with AZ_Error or AZ_Warning (See @reportAsErrors).
//! @param window Debug window name used for AZ Trace functions //! @param window Debug window name used for AZ Trace functions.
//! @param errorMessages String that may contain many lines of errors and warnings //! @param errorMessages Message string.
//! @param return true if Errors were detected and reported (Warnings don't count) //! @param reportAsErrors If true, messages are traced with AZ_Error, otherwise AZ_Warning is used.
bool ReportErrorMessages(AZStd::string_view window, AZStd::string_view errorMessages); //! @returns true If the input text blob contains at least one line with the "error" string.
bool ReportMessages(AZStd::string_view window, AZStd::string_view errorMessages, bool reportAsErrors);
//! Converts from a RHI::ShaderHardwareStage to an RHI::ShaderStage //! Converts from a RHI::ShaderHardwareStage to an RHI::ShaderStage
ShaderStage ToRHIShaderStage(ShaderHardwareStage stageType); ShaderStage ToRHIShaderStage(ShaderHardwareStage stageType);

@ -330,7 +330,7 @@ namespace AZ
// Pump one last time to make sure the streams have been flushed // Pump one last time to make sure the streams have been flushed
pumpOuputStreams(); pumpOuputStreams();
const bool reportedErrors = ReportErrorMessages(toolNameForLog, errorMessages); const bool reportedErrors = ReportMessages(toolNameForLog, errorMessages, exitCode != 0);
if (timedOut) if (timedOut)
{ {
@ -367,32 +367,20 @@ namespace AZ
return true; return true;
} }
bool ReportErrorMessages([[maybe_unused]] AZStd::string_view window, AZStd::string_view errorMessages) bool ReportMessages([[maybe_unused]] AZStd::string_view window, AZStd::string_view errorMessages, bool reportAsErrors)
{ {
// There are more efficient ways to do this, but this approach is simple and gets us moving for now. if (reportAsErrors)
AZStd::vector<AZStd::string> lines;
AzFramework::StringFunc::Tokenize(errorMessages.data(), lines, "\n\r");
bool foundErrors = false;
for (auto& line : lines)
{ {
if (AZStd::string::npos != AzFramework::StringFunc::Find(line, "error")) AZ_Error(window.data(), false, "%.*s", aznumeric_cast<int>(errorMessages.size()), errorMessages.data());
{
AZ_Error(window.data(), false, "%s", line.data());
foundErrors = true;
}
else if (AZStd::string::npos != AzFramework::StringFunc::Find(line, "warning"))
{
AZ_Warning(window.data(), false, "%s", line.data());
} }
else else
{ {
AZ_TracePrintf(window.data(), "%s", line.data()); // Using AZ_Warning instead of AZ_TracePrintf because this function is commonly
} // used to report messages from stderr when executing applications. Applications
// when ran successfully, only output to stderr for errors or warnings.
AZ_Warning(window.data(), false, "%.*s", aznumeric_cast<int>(errorMessages.size()), errorMessages.data());
} }
return AZStd::string::npos != AzFramework::StringFunc::Find(errorMessages, "error");
return foundErrors;
} }
ShaderStage ToRHIShaderStage(ShaderHardwareStage stageType) ShaderStage ToRHIShaderStage(ShaderHardwareStage stageType)

Loading…
Cancel
Save