public void Destroy() { m_passNameContainer = null; if (m_templateProperties != null) { m_templateProperties.Destroy(); } m_templateProperties = null; if (m_modules != null) { m_modules.Destroy(); } m_modules = null; if (m_inputDataList != null) { m_inputDataList.Clear(); } m_inputDataList = null; if (m_inputDataDict != null) { m_inputDataDict.Clear(); } m_inputDataDict = null; m_vertexFunctionData = null; m_fragmentFunctionData = null; if (m_vertexDataContainer != null) { m_vertexDataContainer.Destroy(); } m_vertexDataContainer = null; if (m_interpolatorDataContainer != null) { m_interpolatorDataContainer.Destroy(); } if (m_localVarsList != null) { m_localVarsList.Clear(); m_localVarsList = null; } m_interpolatorDataContainer = null; if (m_availableShaderGlobals != null) { m_availableShaderGlobals.Clear(); } m_availableShaderGlobals = null; }
public void FetchDataFromTemplate(TemplateModules module) { if (module.PragmaTag.IsValid) { m_additionalPragmas.MarkAsValid(); m_additionalIncludes.MarkAsValid(); m_additionalDefines.MarkAsValid(); } if (module.BlendData.DataCheck == TemplateDataCheck.Valid) { m_blendOpHelper.ConfigureFromTemplateData(module.BlendData); m_hasValidData = true; } if (module.CullModeData.DataCheck == TemplateDataCheck.Valid) { m_cullModeHelper.ConfigureFromTemplateData(module.CullModeData); m_hasValidData = true; } if (module.ColorMaskData.DataCheck == TemplateDataCheck.Valid) { m_colorMaskHelper.ConfigureFromTemplateData(module.ColorMaskData); m_hasValidData = true; } if (module.StencilData.DataCheck == TemplateDataCheck.Valid) { m_stencilBufferHelper.ConfigureFromTemplateData(module.StencilData); m_hasValidData = true; } if (module.DepthData.DataCheck == TemplateDataCheck.Valid) { m_depthOphelper.ConfigureFromTemplateData(module.DepthData); m_hasValidData = true; } if (module.TagData.DataCheck == TemplateDataCheck.Valid) { m_tagsHelper.ConfigureFromTemplateData(module.TagData); m_hasValidData = true; } if (module.ShaderModel.DataCheck == TemplateDataCheck.Valid) { m_shaderModelHelper.ConfigureFromTemplateData(module.ShaderModel); m_hasValidData = true; } }
public void Destroy() { m_LODContainer = null; m_templateProperties.Destroy(); m_templateProperties = null; m_passes.Clear(); m_passes = null; m_modules.Destroy(); m_modules = null; m_availableShaderGlobals.Clear(); m_availableShaderGlobals = null; }
public TemplatePass(int subshaderIdx, int passIdx, TemplateIdManager idManager, string uniquePrefix, int offsetIdx, TemplatePassInfo passInfo, ref Dictionary <string, TemplateShaderPropertyData> duplicatesHelper) { m_uniquePrefix = uniquePrefix; m_isMainPass = passInfo.Data.Contains(TemplatesManager.TemplateMainPassTag); if (!m_isMainPass) { m_isInvisible = passInfo.Data.Contains(TemplatesManager.TemplateExcludeFromGraphTag); } FetchPassName(offsetIdx, passInfo.Data); if (m_passNameContainer.Index > -1) { idManager.RegisterId(m_passNameContainer.Index, uniquePrefix + m_passNameContainer.Id, m_passNameContainer.Id); } else { m_passNameContainer.Data = string.Format(DefaultPassNameStr, subshaderIdx, passIdx); } m_modules = new TemplateModules(idManager, m_templateProperties, uniquePrefix + "Module", offsetIdx, passInfo.Data, false); Dictionary <string, TemplateShaderPropertyData> ownDuplicatesDict = new Dictionary <string, TemplateShaderPropertyData>(duplicatesHelper); TemplateHelperFunctions.CreateShaderGlobalsList(passInfo.Data, ref m_availableShaderGlobals, ref ownDuplicatesDict); // Vertex and Interpolator data FetchVertexAndInterpData(offsetIdx, passInfo.Data); if (m_vertexDataContainer != null) { idManager.RegisterId(m_vertexDataContainer.VertexDataStartIdx, uniquePrefix + m_vertexDataContainer.VertexDataId, m_vertexDataContainer.VertexDataId); } if (m_interpolatorDataContainer != null) { idManager.RegisterId(m_interpolatorDataContainer.InterpDataStartIdx, uniquePrefix + m_interpolatorDataContainer.InterpDataId, m_interpolatorDataContainer.InterpDataId); } //Fetch function code areas FetchCodeAreas(offsetIdx, TemplatesManager.TemplateVertexCodeBeginArea, MasterNodePortCategory.Vertex, passInfo.Data); if (m_vertexFunctionData != null) { idManager.RegisterId(m_vertexFunctionData.Position, uniquePrefix + m_vertexFunctionData.Id, m_vertexFunctionData.Id); } FetchCodeAreas(offsetIdx, TemplatesManager.TemplateFragmentCodeBeginArea, MasterNodePortCategory.Fragment, passInfo.Data); if (m_fragmentFunctionData != null) { idManager.RegisterId(m_fragmentFunctionData.Position, uniquePrefix + m_fragmentFunctionData.Id, m_fragmentFunctionData.Id); } //Fetching inputs FetchInputs(offsetIdx, MasterNodePortCategory.Fragment, passInfo.Data); FetchInputs(offsetIdx, MasterNodePortCategory.Vertex, passInfo.Data); //Fetch local variables must be done after fetching code areas as it needs them to see is variable is on vertex or fragment TemplateHelperFunctions.FetchLocalVars(passInfo.Data, ref m_localVarsList, m_vertexFunctionData, m_fragmentFunctionData); int localVarCount = m_localVarsList.Count; if (localVarCount > 0) { idManager.RegisterTag(TemplatesManager.TemplateLocalVarTag); for (int i = 0; i < localVarCount; i++) { if (m_localVarsList[i].IsSpecialVar) { idManager.RegisterTag(m_localVarsList[i].Id); } } } int inputsCount = m_inputDataList.Count; for (int i = 0; i < inputsCount; i++) { if (m_inputDataList[i] != null) { idManager.RegisterId(m_inputDataList[i].TagGlobalStartIdx, uniquePrefix + m_inputDataList[i].TagId, m_inputDataList[i].TagId); } } ownDuplicatesDict.Clear(); ownDuplicatesDict = null; }
public void Draw(ParentNode owner, TemplateModules module) { switch (module.ShaderModel.DataCheck) { case TemplateDataCheck.Valid: m_shaderModelHelper.Draw(owner); break; case TemplateDataCheck.Unreadable: m_shaderModelHelper.ShowUnreadableDataMessage(); break; } m_isDirty = m_shaderModelHelper.IsDirty; switch (module.CullModeData.DataCheck) { case TemplateDataCheck.Valid: m_cullModeHelper.Draw(owner); break; case TemplateDataCheck.Unreadable: m_cullModeHelper.ShowUnreadableDataMessage(); break; } m_isDirty = m_cullModeHelper.IsDirty; switch (module.ColorMaskData.DataCheck) { case TemplateDataCheck.Valid: m_colorMaskHelper.Draw(owner); break; case TemplateDataCheck.Unreadable: m_colorMaskHelper.ShowUnreadableDataMessage(); break; } m_isDirty = m_isDirty || m_colorMaskHelper.IsDirty; switch (module.DepthData.DataCheck) { case TemplateDataCheck.Valid: m_depthOphelper.Draw(owner, false); break; case TemplateDataCheck.Unreadable: m_depthOphelper.ShowUnreadableDataMessage(); break; } m_isDirty = m_isDirty || m_depthOphelper.IsDirty; switch (module.BlendData.DataCheck) { case TemplateDataCheck.Valid: m_blendOpHelper.Draw(owner, false); break; case TemplateDataCheck.Unreadable: m_blendOpHelper.ShowUnreadableDataMessage(); break; } m_isDirty = m_isDirty || m_blendOpHelper.IsDirty; switch (module.StencilData.DataCheck) { case TemplateDataCheck.Valid: { CullMode cullMode = (module.CullModeData.DataCheck == TemplateDataCheck.Valid) ? m_cullModeHelper.CurrentCullMode : CullMode.Back; m_stencilBufferHelper.Draw(owner, cullMode, false); } break; case TemplateDataCheck.Unreadable: { m_stencilBufferHelper.ShowUnreadableDataMessage(); } break; } m_isDirty = m_isDirty || m_stencilBufferHelper.IsDirty; switch (module.TagData.DataCheck) { case TemplateDataCheck.Valid: m_tagsHelper.Draw(owner, false); break; case TemplateDataCheck.Unreadable: m_tagsHelper.ShowUnreadableDataMessage(owner); break; } m_isDirty = m_isDirty || m_tagsHelper.IsDirty; if (module.PragmaTag.IsValid) { m_additionalDefines.Draw(owner); m_additionalIncludes.Draw(owner); m_additionalPragmas.Draw(owner); } m_isDirty = m_isDirty || m_additionalDefines.IsDirty || m_additionalIncludes.IsDirty || m_additionalPragmas.IsDirty; }
public TemplateSubShader(int subShaderIx, TemplateIdManager idManager, string uniquePrefix, TemplateSubShaderInfo subShaderData, ref Dictionary <string, TemplateShaderPropertyData> duplicatesHelper) { m_uniquePrefix = uniquePrefix; FetchLOD(subShaderData.StartIdx, subShaderData.Modules); if (m_LODContainer.Index > -1) { idManager.RegisterId(m_LODContainer.Index, uniquePrefix + "Module" + m_LODContainer.Id, m_LODContainer.Id); } m_modules = new TemplateModules(idManager, m_templateProperties, uniquePrefix + "Module", subShaderData.StartIdx, subShaderData.Modules, true); Dictionary <string, TemplateShaderPropertyData> ownDuplicatesDict = new Dictionary <string, TemplateShaderPropertyData>(duplicatesHelper); TemplateHelperFunctions.CreateShaderGlobalsList(subShaderData.Modules, ref m_availableShaderGlobals, ref ownDuplicatesDict); m_passAmount = subShaderData.Passes.Count; if (!m_modules.PassTag.IsValid) { m_modules.PassTag.StartIdx = subShaderData.Passes[0].GlobalStartIdx; m_templateProperties.AddId(subShaderData.Data, m_modules.PassTag.Id, subShaderData.Passes[0].LocalStartIdx, m_modules.PassTag.SearchIndentation); m_modules.PassTag.StartIdx -= m_templateProperties.PropertyDict[m_modules.PassTag.Id].Indentation.Length; m_templateProperties.PropertyDict[m_modules.PassTag.Id].UseIndentationAtStart = true; idManager.RegisterId(m_modules.PassTag.StartIdx, m_modules.UniquePrefix + m_modules.PassTag.Id, string.Empty); } int firstVisible = -1; for (int passIdx = 0; passIdx < m_passAmount; passIdx++) { TemplatePass newPass = new TemplatePass(subShaderIx, passIdx, idManager, uniquePrefix + "Pass" + passIdx, subShaderData.Passes[passIdx].GlobalStartIdx, subShaderData.Passes[passIdx], ref ownDuplicatesDict); if (newPass.AddToList) { if (newPass.IsMainPass && m_mainPass < 0) { m_mainPass = passIdx; } else if (!newPass.IsInvisible && firstVisible < 0) { firstVisible = passIdx; } m_passes.Add(newPass); } else { newPass.Destroy(); newPass = null; } } if (m_mainPass < 0) { // If no main pass was set then choose the first visible one m_mainPass = (firstVisible < 0) ? 0 : firstVisible; m_passes[m_mainPass].IsMainPass = true; } ownDuplicatesDict.Clear(); ownDuplicatesDict = null; }