[ATOM-15058] Remove Automatic Entry Point Detection (#3150)

.shader files must declare at least  one entry function.

Signed-off-by: garrieta <garrieta@amazon.com>
This commit is contained in:
galibzon
2021-08-17 08:21:39 -05:00
committed by GitHub
parent d1cedba042
commit 4cac875589
9 changed files with 65 additions and 118 deletions
@@ -809,91 +809,6 @@ namespace AZ
return success;
}
//! Returns a list of acceptable default entry point names
static void GetAcceptableDefaultEntryPoints(
const AZStd::vector<FunctionData>& azslFunctionDataList,
AZStd::unordered_map<AZStd::string, RPI::ShaderStageType>& defaultEntryPoints)
{
for (const auto& func : azslFunctionDataList)
{
if (!func.m_hasShaderStageVaryings)
{
// Not declaring any semantics for a shader entry is valid, but unusual.
// A shader entry with no semantics must be explicitly listed and won't be selected by default.
continue;
}
if (func.m_name.starts_with("VS") || func.m_name.ends_with("VS"))
{
defaultEntryPoints[func.m_name] = RPI::ShaderStageType::Vertex;
AZ_TracePrintf(
ShaderBuilderUtilityName, "Assuming \"%s\" is a valid Vertex shader entry point.\n", func.m_name.c_str());
}
else if (func.m_name.starts_with("PS") || func.m_name.ends_with("PS"))
{
defaultEntryPoints[func.m_name] = RPI::ShaderStageType::Fragment;
AZ_TracePrintf(
ShaderBuilderUtilityName, "Assuming \"%s\" is a valid Fragment shader entry point.\n",
func.m_name.c_str());
}
else if (func.m_name.starts_with("CS") || func.m_name.ends_with("CS"))
{
defaultEntryPoints[func.m_name] = RPI::ShaderStageType::Compute;
AZ_TracePrintf(
ShaderBuilderUtilityName, "Assuming \"%s\" is a valid Compute shader entry point.\n", func.m_name.c_str());
}
}
}
// DEPRECATED [ATOM-15472
//! Returns a list of acceptable default entry point names
//! This function
static void GetAcceptableDefaultEntryPoints(
const AzslData& azslData, AZStd::unordered_map<AZStd::string, RPI::ShaderStageType>& defaultEntryPoints)
{
return GetAcceptableDefaultEntryPoints(azslData.m_functions, defaultEntryPoints);
}
void GetDefaultEntryPointsFromFunctionDataList(
const AZStd::vector<FunctionData> azslFunctionDataList,
AZStd::unordered_map<AZStd::string, RPI::ShaderStageType>& shaderEntryPoints)
{
AZStd::unordered_map<AZStd::string, RPI::ShaderStageType> defaultEntryPoints;
GetAcceptableDefaultEntryPoints(azslFunctionDataList, defaultEntryPoints);
for (const auto& functionData : azslFunctionDataList)
{
for (const auto& defaultEntryPoint : defaultEntryPoints)
{
// Equal defaults to case insensitive compares...
if (AzFramework::StringFunc::Equal(defaultEntryPoint.first.c_str(), functionData.m_name.c_str()))
{
shaderEntryPoints[defaultEntryPoint.first] = defaultEntryPoint.second;
break; // stop looping default entry points and go to the next shader function
}
}
}
}
AZStd::string GetAcceptableDefaultEntryPointNames(const AzslData& azslData)
{
AZStd::unordered_map<AZStd::string, RPI::ShaderStageType> defaultEntryPointList;
GetAcceptableDefaultEntryPoints(azslData, defaultEntryPointList);
AZStd::vector<AZStd::string> defaultEntryPointNamesList;
for (const auto& shaderEntryPoint : defaultEntryPointList)
{
defaultEntryPointNamesList.push_back(shaderEntryPoint.first);
}
AZStd::string shaderEntryPoints;
AzFramework::StringFunc::Join(
shaderEntryPoints, defaultEntryPointNamesList.begin(), defaultEntryPointNamesList.end(), ", ");
return AZStd::move(shaderEntryPoints);
}
} // namespace ShaderBuilderUtility
} // namespace ShaderBuilder
} // AZ