public void SetGroupTable(CGroupTable gt) { if (null == gt) { return; } m_sGroupName = gt.m_sFileName; m_pIntBuffer = new ComputeBuffer((gt.m_iM + gt.m_iN - 1) * (gt.m_iM + gt.m_iN - 1) + gt.m_IG.Length, 4); m_pFloatBuffer = new ComputeBuffer(gt.m_iM, 4); uint[] intData = new uint[(gt.m_iM + gt.m_iN - 1) * (gt.m_iM + gt.m_iN - 1) + gt.m_IG.Length]; for (int i = 0; i < gt.m_iM + gt.m_iN - 1; ++i) { for (int j = 0; j < gt.m_iM + gt.m_iN - 1; ++j) { intData[i * (gt.m_iM + gt.m_iN - 1) + j] = (uint)gt.m_MI[i, j]; } } for (int i = 0; i < gt.m_IG.Length; ++i) { intData[(gt.m_iM + gt.m_iN - 1) * (gt.m_iM + gt.m_iN - 1) + i] = (uint)gt.m_IG[i]; } m_pIntBuffer.SetData(intData); float[] floatData = new float[gt.m_iM]; for (int i = 0; i < gt.m_iM; ++i) { floatData[i] = gt.m_EI[i]; } m_pFloatBuffer.SetData(floatData); CmpShader.SetInt("iM", gt.m_iM); CmpShader.SetInt("iN", gt.m_iN); CmpShader.SetInt("iIG", gt.m_IG.Length); //Debug.Log(string.Format("im = {0}, in = {1}, ig = {2}", gt.m_iM, gt.m_iN, gt.m_IG.Length)); int[] iMTTextureSize = CUtility.GetUpperTwoExp(gt.m_iM + gt.m_iN - 1); int[] iEITextureSize = CUtility.GetUpperTwoExp(gt.m_iM); int[] iIGTextureSize = CUtility.GetUpperTwoExp(gt.m_IG.Length); m_pMT = new RenderTexture(iMTTextureSize[1], iMTTextureSize[1], 1, RenderTextureFormat.RInt); m_pMT.enableRandomWrite = true; m_pMT.Create(); m_pEI = new RenderTexture(iEITextureSize[1], 1, 1, RenderTextureFormat.RFloat); m_pEI.enableRandomWrite = true; m_pEI.Create(); m_pIG = new RenderTexture(iIGTextureSize[1], 1, 1, RenderTextureFormat.RInt); m_pIG.enableRandomWrite = true; m_pIG.Create(); CmpShader.SetTexture(m_iKernelSetGroupData, "MT", m_pMT); CmpShader.SetTexture(m_iKernelSetGroupData, "EI", m_pEI); CmpShader.SetTexture(m_iKernelSetGroupData, "IG", m_pIG); CmpShader.SetTexture(m_iKernelCalcUsing, "MT", m_pMT); CmpShader.SetTexture(m_iKernelCalcUsing, "EI", m_pEI); CmpShader.SetTexture(m_iKernelCalcUsing, "IG", m_pIG); CmpShader.SetTexture(m_iKernelEnergyUsing, "MT", m_pMT); CmpShader.SetTexture(m_iKernelEnergyUsing, "EI", m_pEI); CmpShader.SetBuffer(m_iKernelSetGroupData, "IntDataBuffer", m_pIntBuffer); CmpShader.SetBuffer(m_iKernelSetGroupData, "FloatDataBuffer", m_pFloatBuffer); CmpShader.Dispatch(m_iKernelSetGroupData, 4, 4, 1); CmpShader.Dispatch(m_iKernelGenerateConstants, 1, 1, 1); m_pIntBuffer.Release(); m_pIntBuffer = null; m_pFloatBuffer.Release(); m_pFloatBuffer = null; //Group table reset, need to reset configuration SetWhiteConfigure(); }