/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include #include #include #include #include #include namespace AZ { namespace Null { static const char* WindowsAzslShaderHeader = "Builders/ShaderHeaders/Platform/Windows/Null/AzslcHeader.azsli"; static const char* MacAzslShaderHeader = "Builders/ShaderHeaders/Platform/Mac/Null/AzslcHeader.azsli"; ShaderPlatformInterface::ShaderPlatformInterface(uint32_t apiUniqueIndex) : RHI::ShaderPlatformInterface(apiUniqueIndex) { } RHI::APIType ShaderPlatformInterface::GetAPIType() const { return Null::RHIType; } AZ::Name ShaderPlatformInterface::GetAPIName() const { return m_apiName; } RHI::Ptr ShaderPlatformInterface::CreatePipelineLayoutDescriptor() { return AZ::Null::PipelineLayoutDescriptor::Create(); } bool ShaderPlatformInterface::BuildPipelineLayoutDescriptor( [[maybe_unused]] RHI::Ptr pipelineLayoutDescriptorBase, [[maybe_unused]] const ShaderResourceGroupInfoList& srgInfoList, [[maybe_unused]] const RootConstantsInfo& rootConstantsInfo, [[maybe_unused]] const RHI::ShaderCompilerArguments& shaderCompilerArguments) { PipelineLayoutDescriptor* pipelineLayoutDescriptor = azrtti_cast(pipelineLayoutDescriptorBase.get()); AZ_Assert(pipelineLayoutDescriptor, "PipelineLayoutDescriptor should have been created by now"); return pipelineLayoutDescriptor->Finalize() == RHI::ResultCode::Success; } RHI::Ptr ShaderPlatformInterface::CreateShaderStageFunction(const StageDescriptor& stageDescriptor) { RHI::Ptr newShaderStageFunction = ShaderStageFunction::Create(RHI::ToRHIShaderStage(stageDescriptor.m_stageType)); newShaderStageFunction->Finalize(); return newShaderStageFunction; } bool ShaderPlatformInterface::IsShaderStageForRaster(RHI::ShaderHardwareStage shaderStageType) const { bool hasRasterProgram = false; hasRasterProgram |= shaderStageType == RHI::ShaderHardwareStage::Vertex; hasRasterProgram |= shaderStageType == RHI::ShaderHardwareStage::Fragment; return hasRasterProgram; } bool ShaderPlatformInterface::IsShaderStageForCompute(RHI::ShaderHardwareStage shaderStageType) const { return (shaderStageType == RHI::ShaderHardwareStage::Compute); } bool ShaderPlatformInterface::IsShaderStageForRayTracing(RHI::ShaderHardwareStage shaderStageType) const { return (shaderStageType == RHI::ShaderHardwareStage::RayTracing); } AZStd::string ShaderPlatformInterface::GetAzslCompilerParameters(const RHI::ShaderCompilerArguments& shaderCompilerArguments) const { return shaderCompilerArguments.MakeAdditionalAzslcCommandLineString() + " --use-spaces --namespace=dx --root-const=128"; } AZStd::string ShaderPlatformInterface::GetAzslCompilerWarningParameters(const RHI::ShaderCompilerArguments& shaderCompilerArguments) const { return shaderCompilerArguments.MakeAdditionalAzslcWarningCommandLineString(); } bool ShaderPlatformInterface::BuildHasDebugInfo([[maybe_unused]] const RHI::ShaderCompilerArguments& shaderCompilerArguments) const { return ""; } const char* ShaderPlatformInterface::GetAzslHeader([[maybe_unused]] const AssetBuilderSDK::PlatformInfo& platform) const { if (platform.m_identifier == "pc") { return WindowsAzslShaderHeader; } else if (platform.m_identifier == "mac") { return MacAzslShaderHeader; } else { return WindowsAzslShaderHeader; } } bool ShaderPlatformInterface::CompilePlatformInternal( [[maybe_unused]] const AssetBuilderSDK::PlatformInfo& platform, [[maybe_unused]] const AZStd::string& shaderSourcePath, [[maybe_unused]] const AZStd::string& functionName, [[maybe_unused]] RHI::ShaderHardwareStage shaderStage, [[maybe_unused]] const AZStd::string& tempFolderPath, [[maybe_unused]] StageDescriptor& outputDescriptor, [[maybe_unused]] const RHI::ShaderCompilerArguments& shaderCompilerArguments) const { outputDescriptor.m_stageType = shaderStage; return true; } } }