-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored the access to Mask Volume instanced to be able to feed a DOTS version to the system.
- Loading branch information
1 parent
1a29f12
commit b2b6502
Showing
8 changed files
with
261 additions
and
118 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
com.unity.render-pipelines.high-definition/Runtime/Material/MaskVolume/IMaskVolumeList.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace UnityEngine.Rendering.HighDefinition | ||
{ | ||
interface IMaskVolumeList | ||
{ | ||
void ReleaseRemovedVolumesFromAtlas(); | ||
int GetVolumeCount(); | ||
|
||
bool IsDataAssigned(int i); | ||
bool IsDataUpdated(int i); | ||
Vector3Int GetResolution(int i); | ||
|
||
Vector3 GetPosition(int i); | ||
Quaternion GetRotation(int i); | ||
|
||
ref MaskVolumeArtistParameters GetParameters(int i); | ||
|
||
int GetAtlasID(int i); | ||
|
||
int GetDataSHL0Length(int i); | ||
void SetDataSHL0(int i, ComputeBuffer buffer); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...nity.render-pipelines.high-definition/Runtime/Material/MaskVolume/IMaskVolumeList.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
com.unity.render-pipelines.high-definition/Runtime/Material/MaskVolume/MaskVolumeHandle.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
namespace UnityEngine.Rendering.HighDefinition | ||
{ | ||
struct MaskVolumeHandle | ||
{ | ||
IMaskVolumeList m_List; | ||
int m_Index; | ||
|
||
public MaskVolumeHandle(IMaskVolumeList list, int index) | ||
{ | ||
m_List = list; | ||
m_Index = index; | ||
} | ||
|
||
public bool IsDataAssigned() => m_List.IsDataAssigned(m_Index); | ||
public bool IsDataUpdated() => m_List.IsDataUpdated(m_Index); | ||
public Vector3Int GetResolution() => m_List.GetResolution(m_Index); | ||
|
||
public Vector3 position => m_List.GetPosition(m_Index); | ||
public Quaternion rotation => m_List.GetRotation(m_Index); | ||
|
||
public ref MaskVolumeArtistParameters parameters => ref m_List.GetParameters(m_Index); | ||
|
||
public int GetAtlasID() => m_List.GetAtlasID(m_Index); | ||
|
||
public int DataSHL0Length => m_List.GetDataSHL0Length(m_Index); | ||
public void SetDataSHL0(ComputeBuffer buffer) => m_List.SetDataSHL0(m_Index, buffer); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ity.render-pipelines.high-definition/Runtime/Material/MaskVolume/MaskVolumeHandle.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
99 changes: 99 additions & 0 deletions
99
com.unity.render-pipelines.high-definition/Runtime/Material/MaskVolume/MaskVolumeManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace UnityEngine.Rendering.HighDefinition | ||
{ | ||
internal class MaskVolumeManager : IMaskVolumeList | ||
{ | ||
static private MaskVolumeManager _instance = null; | ||
|
||
internal static MaskVolumeManager manager | ||
{ | ||
get | ||
{ | ||
if (_instance == null) | ||
{ | ||
_instance = new MaskVolumeManager(); | ||
} | ||
return _instance; | ||
} | ||
} | ||
|
||
List<MaskVolume> m_Volumes = new List<MaskVolume>(); | ||
|
||
List<IMaskVolumeList> m_AdditionalMaskLists = new List<IMaskVolumeList>(); | ||
List<MaskVolumeHandle> m_VolumeHandles = new List<MaskVolumeHandle>(); | ||
|
||
internal List<MaskVolumeHandle> CollectVolumesToRender() | ||
{ | ||
m_VolumeHandles.Clear(); | ||
var count = m_Volumes.Count; | ||
for (int i = 0; i < count; i++) | ||
m_VolumeHandles.Add(new MaskVolumeHandle(this, i)); | ||
foreach (var list in m_AdditionalMaskLists) | ||
{ | ||
list.ReleaseRemovedVolumesFromAtlas(); | ||
count = list.GetVolumeCount(); | ||
for (int i = 0; i < count; i++) | ||
m_VolumeHandles.Add(new MaskVolumeHandle(list, i)); | ||
} | ||
return m_VolumeHandles; | ||
} | ||
|
||
internal void RegisterVolume(MaskVolume volume) | ||
{ | ||
if (m_Volumes.Contains(volume)) | ||
return; | ||
|
||
m_Volumes.Add(volume); | ||
} | ||
|
||
internal void DeRegisterVolume(MaskVolume volume) | ||
{ | ||
var index = m_Volumes.IndexOf(volume); | ||
if (index == -1) | ||
return; | ||
|
||
ReleaseVolumeFromAtlas(new MaskVolumeHandle(this, index)); | ||
m_Volumes.RemoveAt(index); | ||
} | ||
|
||
public void ReleaseVolumeFromAtlas(MaskVolume volume) | ||
{ | ||
var index = m_Volumes.IndexOf(volume); | ||
if (index == -1) | ||
return; | ||
|
||
ReleaseVolumeFromAtlas(new MaskVolumeHandle(this, index)); | ||
} | ||
|
||
public void ReleaseVolumeFromAtlas(MaskVolumeHandle volume) | ||
{ | ||
if (RenderPipelineManager.currentPipeline is HDRenderPipeline hdrp) | ||
hdrp.ReleaseMaskVolumeFromAtlas(volume); | ||
} | ||
|
||
public void AddMaskList(IMaskVolumeList list) | ||
{ | ||
m_AdditionalMaskLists.Add(list); | ||
} | ||
|
||
public void RemoveMaskList(IMaskVolumeList list) | ||
{ | ||
m_AdditionalMaskLists.Remove(list); | ||
} | ||
|
||
void IMaskVolumeList.ReleaseRemovedVolumesFromAtlas() { } | ||
int IMaskVolumeList.GetVolumeCount() => m_Volumes.Count; | ||
bool IMaskVolumeList.IsDataAssigned(int i) => m_Volumes[i].IsDataAssigned(); | ||
bool IMaskVolumeList.IsDataUpdated(int i) => m_Volumes[i].dataUpdated; | ||
Vector3Int IMaskVolumeList.GetResolution(int i) => m_Volumes[i].GetResolution(); | ||
|
||
Vector3 IMaskVolumeList.GetPosition(int i) => m_Volumes[i].transform.position; | ||
Quaternion IMaskVolumeList.GetRotation(int i) => m_Volumes[i].transform.rotation; | ||
ref MaskVolumeArtistParameters IMaskVolumeList.GetParameters(int i) => ref m_Volumes[i].parameters; | ||
int IMaskVolumeList.GetAtlasID(int i) => m_Volumes[i].GetAtlasID(); | ||
|
||
int IMaskVolumeList.GetDataSHL0Length(int i) => m_Volumes[i].GetPayload().dataSHL0.Length; | ||
void IMaskVolumeList.SetDataSHL0(int i, ComputeBuffer buffer) => buffer.SetData(m_Volumes[i].GetPayload().dataSHL0); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ty.render-pipelines.high-definition/Runtime/Material/MaskVolume/MaskVolumeManager.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.