FShaderType::FShaderType( const TCHAR* InName, const TCHAR* InSourceFilename, const TCHAR* InFunctionName, uint32 InFrequency, ConstructSerializedType InConstructSerializedRef ): Name(InName), SourceFilename(InSourceFilename), FunctionName(InFunctionName), Frequency(InFrequency), ConstructSerializedRef(InConstructSerializedRef), GlobalListLink(this) { for (int32 Platform = 0; Platform < SP_NumPlatforms; Platform++) { bCachedUniformBufferStructDeclarations[Platform] = false; } // This will trigger if an IMPLEMENT_SHADER_TYPE was in a module not loaded before InitializeShaderTypes // Shader types need to be implemented in modules that are loaded before that checkf(!bInitializedSerializationHistory, TEXT("Shader type was loaded after engine init, use ELoadingPhase::PostConfigInit on your module to cause it to load earlier.")); //make sure the name is shorter than the maximum serializable length check(FCString::Strlen(InName) < NAME_SIZE); // register this shader type GlobalListLink.Link(GetTypeList()); GetNameToTypeMap().Add(FName(InName), this); // Assign the shader type the next unassigned hash index. static uint32 NextHashIndex = 0; HashIndex = NextHashIndex++; }
FShaderPipelineType::FShaderPipelineType( const TCHAR* InName, const FShaderType* InVertexShader, const FShaderType* InHullShader, const FShaderType* InDomainShader, const FShaderType* InGeometryShader, const FShaderType* InPixelShader, bool bInShouldOptimizeUnusedOutputs) : Name(InName), TypeName(Name), GlobalListLink(this), bShouldOptimizeUnusedOutputs(bInShouldOptimizeUnusedOutputs) { checkf(Name && *Name, TEXT("Shader Pipeline Type requires a valid Name!")); checkf(InVertexShader, TEXT("A Shader Pipeline always requires a Vertex Shader")); checkf((InHullShader == nullptr && InDomainShader == nullptr) || (InHullShader != nullptr && InDomainShader != nullptr), TEXT("Both Hull & Domain shaders are needed for tessellation on Pipeline %s"), Name); //make sure the name is shorter than the maximum serializable length check(FCString::Strlen(InName) < NAME_SIZE); FMemory::Memzero(AllStages); if (InPixelShader) { Stages.Add(InPixelShader); AllStages[SF_Pixel] = InPixelShader; } if (InGeometryShader) { Stages.Add(InGeometryShader); AllStages[SF_Geometry] = InGeometryShader; } if (InDomainShader) { Stages.Add(InDomainShader); AllStages[SF_Domain] = InDomainShader; Stages.Add(InHullShader); AllStages[SF_Hull] = InHullShader; } Stages.Add(InVertexShader); AllStages[SF_Vertex] = InVertexShader; static uint32 TypeHashCounter = 0; ++TypeHashCounter; HashIndex = TypeHashCounter; GlobalListLink.LinkHead(GetTypeList()); GetNameToTypeMap().Add(FName(InName), this); // This will trigger if an IMPLEMENT_SHADER_TYPE was in a module not loaded before InitializeShaderTypes // Shader types need to be implemented in modules that are loaded before that checkf(!bInitialized, TEXT("Shader Pipeline was loaded after Engine init, use ELoadingPhase::PostConfigInit on your module to cause it to load earlier.")); }
FShaderType::~FShaderType() { GlobalListLink.Unlink(); GetNameToTypeMap().Remove(FName(Name)); }