@ -70,11 +70,11 @@ namespace AZ
return AZ : : Success ( shaderSourceData ) ;
}
void GetAbsolutePathToAzslFile ( const AZStd : : string & shader TemplatePathAndFile , AZStd : : string specifiedShaderPathAndName , AZStd : : string & absoluteAzslPath )
void GetAbsolutePathToAzslFile ( const AZStd : : string & shader SourceFileFullPath , AZStd : : string specifiedShaderPathAndName , AZStd : : string & absoluteAzslPath )
{
AZStd : : string sourcePath ;
AzFramework : : StringFunc : : Path : : GetFullPath ( shader TemplatePathAndFile. data ( ) , sourcePath ) ;
AzFramework : : StringFunc : : Path : : GetFullPath ( shader SourceFileFullPath. c_str ( ) , sourcePath ) ;
AzFramework : : StringFunc : : Path : : Normalize ( specifiedShaderPathAndName ) ;
bool shaderNameHasPath = ( specifiedShaderPathAndName . find ( AZ_CORRECT_FILESYSTEM_SEPARATOR ) ! = AZStd : : string : : npos ) ;
@ -82,15 +82,27 @@ namespace AZ
// Join will handle overlapping directory structures for us
AzFramework : : StringFunc : : Path : : Join ( sourcePath . data ( ) , specifiedShaderPathAndName . data ( ) , absoluteAzslPath , shaderNameHasPath /* handle directory overlap? */ , false /* be case insensitive? */ ) ;
AzFramework : : StringFunc : : Path : : ReplaceExtension ( absoluteAzslPath , " azsl " ) ;
// The builders used to automatically set the ".azsl" extension, but no more, because that would make the .shader file confusing to read.
// Here we just detect the issue and instruct the user what to change.
// (There's no need to return a failure code, the builder will eventually fail anyway when it can't find the file).
if ( ! IO : : FileIOBase : : GetInstance ( ) - > Exists ( absoluteAzslPath . c_str ( ) ) )
{
AZStd : : string absoluteAzslPathWithForcedExtension = absoluteAzslPath ;
AzFramework : : StringFunc : : Path : : ReplaceExtension ( absoluteAzslPathWithForcedExtension , " azsl " ) ;
if ( IO : : FileIOBase : : GetInstance ( ) - > Exists ( absoluteAzslPathWithForcedExtension . c_str ( ) ) )
{
AZ_Error ( ShaderBuilderUtilityName , false , " When the .shader file references a .azsl file, it must include the \" .azsl \" extension. " ) ;
}
}
}
AZStd : : shared_ptr < ShaderFiles > PrepareSourceInput (
[[maybe_unused]] const char * builderName ,
const AZStd : : string & shaderAssetSourcePath ,
const AZStd : : string & shader SourceFileFull Path,
RPI : : ShaderSourceData & sourceAsset )
{
auto shaderAssetSourceFileParseOutput = ShaderBuilderUtility : : LoadShaderDataJson ( shaderAssetSourcePath ) ;
auto shaderAssetSourceFileParseOutput = ShaderBuilderUtility : : LoadShaderDataJson ( shader SourceFileFull Path) ;
if ( ! shaderAssetSourceFileParseOutput . IsSuccess ( ) )
{
AZ_Error ( builderName , false , " Failed to load/parse Shader Descriptor JSON: %s " , shaderAssetSourceFileParseOutput . GetError ( ) . c_str ( ) ) ;
@ -100,7 +112,7 @@ namespace AZ
AZStd : : shared_ptr < ShaderFiles > files ( new ShaderFiles ) ;
const AZStd : : string & specifiedAzslName = sourceAsset . m_source ;
ShaderBuilderUtility : : GetAbsolutePathToAzslFile ( shader Asset SourcePath, specifiedAzslName , files - > m_azslSourceFullPath ) ;
ShaderBuilderUtility : : GetAbsolutePathToAzslFile ( shader SourceFileFull Path, specifiedAzslName , files - > m_azslSourceFullPath ) ;
// specifiedAzslName may have a relative path on it so need to strip it
AzFramework : : StringFunc : : Path : : GetFileName ( specifiedAzslName . c_str ( ) , files - > m_azslFileName ) ;