浏览代码

HDRenderLoop: Fix error with DestroyBuffer

/main
sebastienlagarde 8 年前
当前提交
f889bdfb
共有 2 个文件被更改,包括 34 次插入29 次删除
  1. 61
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/SinglePass/SinglePass.cs
  2. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.cs

61
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/SinglePass/SinglePass.cs


return "LIGHTLOOP_SINGLE_PASS";
}
ComputeBuffer m_punctualLightList;
ComputeBuffer m_envLightList;
ComputeBuffer m_areaLightList;
ComputeBuffer m_punctualShadowList;
// Static keyword is required here else we get a "DestroyBuffer can only be call in main thread"
static ComputeBuffer s_PunctualLightList;
static ComputeBuffer s_EnvLightList;
static ComputeBuffer s_AreaLightList;
static ComputeBuffer s_PunctualShadowList;
if (m_punctualLightList != null)
m_punctualLightList.Release();
if (s_PunctualLightList != null)
s_PunctualLightList.Release();
if (m_areaLightList != null)
m_areaLightList.Release();
if (s_AreaLightList != null)
s_AreaLightList.Release();
if (m_punctualShadowList != null)
m_punctualShadowList.Release();
if (s_PunctualShadowList != null)
s_PunctualShadowList.Release();
if (m_envLightList != null)
m_envLightList.Release();
if (s_EnvLightList != null)
s_EnvLightList.Release();
}
public void Rebuild()

m_punctualLightList = new ComputeBuffer(HDRenderLoop.k_MaxPunctualLightsOnSCreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(PunctualLightData)));
m_areaLightList = new ComputeBuffer(HDRenderLoop.k_MaxAreaLightsOnSCreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(AreaLightData)));
m_envLightList = new ComputeBuffer(HDRenderLoop.k_MaxEnvLightsOnSCreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(EnvLightData)));
m_punctualShadowList = new ComputeBuffer(HDRenderLoop.k_MaxShadowOnScreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(PunctualShadowData)));
s_PunctualLightList = new ComputeBuffer(HDRenderLoop.k_MaxPunctualLightsOnSCreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(PunctualLightData)));
s_AreaLightList = new ComputeBuffer(HDRenderLoop.k_MaxAreaLightsOnSCreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(AreaLightData)));
s_EnvLightList = new ComputeBuffer(HDRenderLoop.k_MaxEnvLightsOnSCreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(EnvLightData)));
s_PunctualShadowList = new ComputeBuffer(HDRenderLoop.k_MaxShadowOnScreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(PunctualShadowData)));
m_punctualLightList.Release();
m_areaLightList.Release();
m_envLightList.Release();
m_punctualShadowList.Release();
s_PunctualLightList.Release();
s_PunctualLightList = null;
s_AreaLightList.Release();
s_AreaLightList = null;
s_EnvLightList.Release();
s_EnvLightList = null;
s_PunctualShadowList.Release();
s_PunctualShadowList = null;
m_punctualLightList.SetData(lightList.punctualLights.ToArray());
m_areaLightList.SetData(lightList.areaLights.ToArray());
m_envLightList.SetData(lightList.envLights.ToArray());
m_punctualShadowList.SetData(lightList.punctualShadows.ToArray());
s_PunctualLightList.SetData(lightList.punctualLights.ToArray());
s_AreaLightList.SetData(lightList.areaLights.ToArray());
s_EnvLightList.SetData(lightList.envLights.ToArray());
s_PunctualShadowList.SetData(lightList.punctualShadows.ToArray());
Shader.SetGlobalBuffer("_PunctualLightList", m_punctualLightList);
Shader.SetGlobalBuffer("_PunctualLightList", s_PunctualLightList);
Shader.SetGlobalBuffer("_AreaLightList", m_areaLightList);
Shader.SetGlobalBuffer("_AreaLightList", s_AreaLightList);
Shader.SetGlobalBuffer("_PunctualShadowList", m_punctualShadowList);
Shader.SetGlobalBuffer("_EnvLightList", m_envLightList);
Shader.SetGlobalBuffer("_PunctualShadowList", s_PunctualShadowList);
Shader.SetGlobalBuffer("_EnvLightList", s_EnvLightList);
Shader.SetGlobalInt("_EnvLightCount", lightList.envLights.Count);
}
}

2
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.cs


/*
ClearComputeBuffers();
buildScreenAABBShader = Resources.Load<ComputeShader>("srcbound");
buildScreenAABBShader = Resources.Load<ComputeShader>("scrbound");
buildPerTileLightListShader = Resources.Load<ComputeShader>("lightlistbuild");
buildPerBigTileLightListShader = Resources.Load<ComputeShader>("lightlistbuild-bigtile");
buildPerVoxelLightListShader = Resources.Load<ComputeShader>("lightlistbuild-clustered");

正在加载...
取消
保存