|  | @@ -17,14 +17,17 @@ namespace Core.BRG
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          private Map<string, BatchShaderBind> m_batchShaderBindMap = new Map<string, BatchShaderBind>();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        public void InitRender(BRGSamples samples, List<T> gameObjectInfos,int maxCount)
 | 
	
		
			
				|  |  | +        public int maxCount;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        public void InitRender(BRGSamples samples, List<T> gameObjectInfos, int maxCount)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              this.m_gameObjectInfos = gameObjectInfos;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +            this.maxCount = maxCount;
 | 
	
		
			
				|  |  |              for (int i = 0; i < m_gameObjectInfos.Count; i++)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  m_gameObjectInfos[i].initIndex = i;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              int maxItemSize = samples.GetAllShaderValueSize();
 | 
	
		
			
				|  |  |              Init(samples, maxCount, maxItemSize);
 | 
	
		
			
				|  |  |              UploadGpuData(gameObjectInfos.Count);
 | 
	
	
		
			
				|  | @@ -42,7 +45,11 @@ namespace Core.BRG
 | 
	
		
			
				|  |  |                  new NativeArray<MetadataValue>(m_samples.AllShaderValues.Count, Allocator.Temp,
 | 
	
		
			
				|  |  |                      NativeArrayOptions.UninitializedMemory);
 | 
	
		
			
				|  |  |              m_batchShaderBinds.Clear();
 | 
	
		
			
				|  |  | -            // int count= m_maxInstancePerWindow;
 | 
	
		
			
				|  |  | +            // BatchShaderBind transformBind = new BatchShaderBind();
 | 
	
		
			
				|  |  | +            // transformBind.shaderValue = new BRGShaderValue()
 | 
	
		
			
				|  |  | +            // {
 | 
	
		
			
				|  |  | +            //     key = "_Object2World",
 | 
	
		
			
				|  |  | +            // };
 | 
	
		
			
				|  |  |              for (int i = 0; i < m_samples.AllShaderValues.Count; i++)
 | 
	
		
			
				|  |  |              {
 | 
	
		
			
				|  |  |                  BRGShaderValue shaderValue = m_samples.AllShaderValues[i];
 | 
	
	
		
			
				|  | @@ -60,7 +67,14 @@ namespace Core.BRG
 | 
	
		
			
				|  |  |              return metadataValues;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +        public void AddBGRGameObjectInfo(T info)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            m_gameObjectInfos.Add(info);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        public void RemoveBGRGameObjectInfo(int index)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            m_gameObjectInfos.RemoveAt(index);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          public void UpdatePos()
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              if (!isUpdate)
 | 
	
	
		
			
				|  | @@ -68,6 +82,8 @@ namespace Core.BRG
 | 
	
		
			
				|  |  |                  return;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +          
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              int totalGpuBufferSize;
 | 
	
		
			
				|  |  |              int alignedWindowSize;
 | 
	
		
			
				|  |  |              NativeArray<float3x4> sysmemBuffer =
 | 
	
	
		
			
				|  | @@ -80,7 +96,7 @@ namespace Core.BRG
 | 
	
		
			
				|  |  |                  return;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            int m_itemCount = m_gameObjectInfos.Count;
 | 
	
		
			
				|  |  | +            int m_itemCount = maxCount;
 | 
	
		
			
				|  |  |              m_batchShaderBindMap.TryGetValue("_MainColor", out var baseColorBind);
 | 
	
		
			
				|  |  |              for (int i = 0; i < m_gameObjectInfos.Count; i++)
 | 
	
		
			
				|  |  |              {
 | 
	
	
		
			
				|  | @@ -107,7 +123,7 @@ namespace Core.BRG
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              // 每帧更新后重新上传数据到GPU
 | 
	
		
			
				|  |  | -            UploadGpuData(m_itemCount, m_batchShaderBinds);
 | 
	
		
			
				|  |  | +            UploadGpuData(m_gameObjectInfos.Count, m_batchShaderBinds);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |