Skip to content

Commit 3dd72f5

Browse files
Sean Lu(呂祥榮)Sean Lu(呂祥榮)
authored andcommitted
version 2.4.0
1 parent 7f2a459 commit 3dd72f5

File tree

162 files changed

+31547
-35069
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+31547
-35069
lines changed

com.htc.upm.vive.openxr/Editor/CompositionLayer/Scripts/CompositionLayerEditor.cs

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ public class CompositionLayerEditor : Editor
6767
static GUIContent Label_AngleOfArc = new GUIContent("Arc Angle", "Central angle of arc of Cylinder Layer");
6868
SerializedProperty Property_AngleOfArc;
6969

70+
static string PropertyName_isExternalSurface = "isExternalSurface";
71+
static GUIContent Label_isExternalSurface = new GUIContent("External Surface", "Specify using external surface or not.");
72+
SerializedProperty Property_isExternalSurface;
73+
74+
static string PropertyName_ExternalSurfaceWidth = "externalSurfaceWidth";
75+
static GUIContent Label_ExternalSurfaceWidth = new GUIContent("Width");
76+
SerializedProperty Property_ExternalSurfaceWidth;
77+
78+
static string PropertyName_ExternalSurfaceHeight = "externalSurfaceHeight";
79+
static GUIContent Label_ExternalSurfaceHeight = new GUIContent("Height");
80+
SerializedProperty Property_ExternalSurfaceHeight;
81+
7082
static string PropertyName_IsDynamicLayer = "isDynamicLayer";
7183
static GUIContent Label_IsDynamicLayer = new GUIContent("Dynamic Layer", "Specify whether Layer needs to be updated each frame or not.");
7284
SerializedProperty Property_IsDynamicLayer;
@@ -101,9 +113,10 @@ public class CompositionLayerEditor : Editor
101113
SerializedProperty Property_TrackingOrigin;
102114

103115
private bool showLayerParams = true, showColorScaleBiasParams = true;
104-
#pragma warning disable
116+
105117
private bool showExternalSurfaceParams = false;
106-
#pragma warning restore
118+
119+
107120
public override void OnInspectorGUI()
108121
{
109122
if (Property_LayerType == null) Property_LayerType = serializedObject.FindProperty(PropertyName_LayerType);
@@ -117,6 +130,9 @@ public override void OnInspectorGUI()
117130
if (Property_CylinderArcLength == null) Property_CylinderArcLength = serializedObject.FindProperty(PropertyName_CylinderArcLength);
118131
if (Property_CylinderRadius == null) Property_CylinderRadius = serializedObject.FindProperty(PropertyName_CylinderRadius);
119132
if (Property_AngleOfArc == null) Property_AngleOfArc = serializedObject.FindProperty(PropertyName_AngleOfArc);
133+
if (Property_isExternalSurface == null) Property_isExternalSurface = serializedObject.FindProperty(PropertyName_isExternalSurface);
134+
if (Property_ExternalSurfaceWidth == null) Property_ExternalSurfaceWidth = serializedObject.FindProperty(PropertyName_ExternalSurfaceWidth);
135+
if (Property_ExternalSurfaceHeight == null) Property_ExternalSurfaceHeight = serializedObject.FindProperty(PropertyName_ExternalSurfaceHeight);
120136
if (Property_IsDynamicLayer == null) Property_IsDynamicLayer = serializedObject.FindProperty(PropertyName_IsDynamicLayer);
121137
if (Property_ApplyColorScaleBias == null) Property_ApplyColorScaleBias = serializedObject.FindProperty(PropertyName_ApplyColorScaleBias);
122138
if (Property_SolidEffect == null) Property_SolidEffect = serializedObject.FindProperty(PropertyName_SolidEffect);
@@ -436,6 +452,25 @@ public override void OnInspectorGUI()
436452
EditorGUILayout.PropertyField(Property_IsDynamicLayer, Label_IsDynamicLayer);
437453
serializedObject.ApplyModifiedProperties();
438454

455+
//EditorGUILayout.PropertyField(Property_isExternalSurface, Label_isExternalSurface);
456+
//serializedObject.ApplyModifiedProperties();
457+
458+
//if (targetCompositionLayer.isExternalSurface)
459+
if (false)
460+
{
461+
EditorGUI.indentLevel++;
462+
showExternalSurfaceParams = EditorGUILayout.Foldout(showExternalSurfaceParams, "External Surface Parameters");
463+
if (showExternalSurfaceParams)
464+
{
465+
EditorGUILayout.PropertyField(Property_ExternalSurfaceWidth, Label_ExternalSurfaceWidth);
466+
EditorGUILayout.PropertyField(Property_ExternalSurfaceHeight, Label_ExternalSurfaceHeight);
467+
EditorGUILayout.PropertyField(Property_IsProtectedSurface, Label_IsProtectedSurface);
468+
469+
serializedObject.ApplyModifiedProperties();
470+
}
471+
EditorGUI.indentLevel--;
472+
}
473+
439474
EditorGUILayout.PropertyField(Property_ApplyColorScaleBias, Label_ApplyColorScaleBias);
440475
serializedObject.ApplyModifiedProperties();
441476

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:93cb5f5a51d9ab068989c656cadf5173ad9e2f01ea730a88b962b290c7146020
3-
size 305152
2+
oid sha256:c5bcb67b079fa79a7d0e26e07c7d8a5ebdf4620e26c02707297a9922fccef546
3+
size 349840

com.htc.upm.vive.openxr/Runtime/CompositionLayer/Scripts/CompositionLayer.cs

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ public class CompositionLayer : MonoBehaviour
9696
[SerializeField]
9797
public bool isDynamicLayer = false;
9898

99+
[SerializeField]
100+
public bool isExternalSurface = false;
101+
102+
[Tooltip("Width of external surface in pixels.")]
103+
[SerializeField]
104+
public uint externalSurfaceWidth = 1280;
105+
106+
[Tooltip("Height of external surface in pixels.")]
107+
[SerializeField]
108+
public uint externalSurfaceHeight = 720;
109+
99110
[SerializeField]
100111
public bool applyColorScaleBias = false;
101112

@@ -187,6 +198,58 @@ private bool CompositionLayerInit()
187198
return true;
188199
}
189200

201+
if (isExternalSurface)
202+
{
203+
CompositionLayerRenderThreadSyncObject SetupExternalAndroidSurfaceSyncObjects = new CompositionLayerRenderThreadSyncObject(
204+
(taskQueue) =>
205+
{
206+
lock (taskQueue)
207+
{
208+
CompositionLayerRenderThreadTask task = (CompositionLayerRenderThreadTask)taskQueue.Dequeue();
209+
210+
//Enumerate Swapchain formats
211+
compositionLayerFeature = OpenXRSettings.Instance.GetFeature<ViveCompositionLayer>();
212+
213+
uint imageCount;
214+
215+
GraphicsAPI graphicsAPI = GraphicsAPI.GLES3;
216+
217+
switch (SystemInfo.graphicsDeviceType)
218+
{
219+
case UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3:
220+
graphicsAPI = GraphicsAPI.GLES3;
221+
break;
222+
case UnityEngine.Rendering.GraphicsDeviceType.Vulkan:
223+
graphicsAPI = GraphicsAPI.Vulkan;
224+
break;
225+
default:
226+
ERROR("Unsupported Graphics API, aborting init process.");
227+
return;
228+
}
229+
230+
layerID = compositionLayerFeature.CompositionLayer_Init(externalSurfaceWidth, externalSurfaceHeight, graphicsAPI, isDynamicLayer, isProtectedSurface, out imageCount, true);
231+
232+
if (layerID != 0)
233+
{
234+
DEBUG("Init completed, ID: " + layerID);
235+
layerTextures = new LayerTextures(imageCount);
236+
InitStatus = true;
237+
}
238+
239+
taskQueue.Release(task);
240+
}
241+
});
242+
243+
CompositionLayerRenderThreadTask.IssueObtainSwapchainEvent(SetupExternalAndroidSurfaceSyncObjects);
244+
245+
texture = new Texture2D((int)externalSurfaceWidth, (int)externalSurfaceHeight, TextureFormat.RGBA32, false, isLinear);
246+
247+
248+
DEBUG("CompositionLayerInit Ext Surf");
249+
250+
return true;
251+
}
252+
190253
if (texture == null)
191254
{
192255
ERROR("CompositionLayerInit: Source Texture not found, abort init.");
@@ -262,6 +325,22 @@ private bool SetLayerTexture()
262325
{
263326
if (!isInitializationComplete || !isSynchronized) return false;
264327

328+
if (isExternalSurface)
329+
{
330+
//Set Texture Layout
331+
offset.x = 0;
332+
offset.y = (int)externalSurfaceHeight;
333+
extent.width = (int)externalSurfaceWidth;
334+
extent.height = (int)-externalSurfaceHeight;
335+
rect.offset = offset;
336+
rect.extent = extent;
337+
338+
layerTextures.textureLayout = rect;
339+
340+
return true; //No need to process texture queues
341+
}
342+
343+
265344
if (texture != null) //check for texture size change
266345
{
267346
if (TextureParamsChanged())
@@ -805,6 +884,14 @@ private void ActivatePlaceholder()
805884
}
806885
}
807886

887+
public IntPtr GetExternalSurfaceObj()
888+
{
889+
IntPtr value = compositionLayerFeature.Compositionlayer_GetExternalSurfaceObj2(layerID);
890+
//DEBUG("GetExternalSurfaceObj layerID " + layerID + " SurfaceObj " + value);
891+
892+
return value;
893+
}
894+
808895
public bool RenderAsLayer()
809896
{
810897
if (placeholderGenerated && compositionLayerPlaceholderPrefabGO != null)

0 commit comments

Comments
 (0)