Jump to content

ScottHerz

Verified Members
  • Posts

    25
  • Joined

  • Last visited

Posts posted by ScottHerz

  1. On 2/10/2020 at 9:37 AM, alwyuyang said:

    Is this the alternative "Sample_GetDataThread.cs", could you please add the "Sample_MainThread.cs".  I don't understand " public Action<EyeData> NewOffThreadEyeDataAction;  private EyeData EyeData = new EyeData();  ", which are different to the version before. Could you explain a little bit, thank you very much.

    This is just something I (not an HTC employee) did. I think they've updated the API since. I used Action's instead of callbacks, as I prefer them. Here's the C# documentation on them: https://docs.microsoft.com/en-us/dotnet/api/system.action-1?view=netframework-4.8

  2. FWIW, here's what I ended up doing (to avoid aborting the thread and the reach-in for EyeData on who-knows-what-thread).

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using System;
    using System.Threading;
    using System.IO;
    using ViveSR.anipal.Eye;
    
    public class ViveProEyeProducerThread : MonoBehaviour
    {
        public Action<EyeData> NewOffThreadEyeDataAction;
    
        private EyeData EyeData = new EyeData();
        private Thread Thread;
        private const int FrequencyControl = 1;
        private bool Abort = false;
    
        void Start()
        {
            Abort = false;
            Thread = new Thread(QueryEyeData);
            Thread.Start();
        }
    
        private void OnApplicationQuit()
        {
            Abort = true;
        }
    
        private void OnDisable()
        {
            Abort = true;
        }
    
        void QueryEyeData()
        {
            int PrevFrameSequence = 0, CurrFrameSequence = 0;
    
            while (Abort == false) {
                ViveSR.Error error = SRanipal_Eye.GetEyeData(ref EyeData);
                if (error == ViveSR.Error.WORK) {
                    CurrFrameSequence = EyeData.frame_sequence;
                    if (CurrFrameSequence != PrevFrameSequence) {
                        PrevFrameSequence = CurrFrameSequence;
    
                        if (Abort == false && NewOffThreadEyeDataAction != null) {
                            NewOffThreadEyeDataAction(EyeData);
                        }
                    }
                }
                Thread.Sleep(FrequencyControl);
            }
        }
    }

     

  3. In trying to build a stand along demo, I'm running into a problem where DepthWarpShader fails to compile. 

     

    The error looks like so:

    GLSL compilation failed:0(59) : error C1031: swizzle mask element not present in operand "xyERROR"0(59) : error C1048: invalid character 'E' in swizzle "xyERROR"0(59) : error C0000: syntax error, unexpected identifier, expecting ',' or ';' at token "missing"0(60) : error C1031: swizzle mask element not present in operand "xy"0(60) : error C0000: syntax error, unexpected identifier, expecting "::" at token "GetBitcastOp"0(62) : error C1031: swizzle mask element not present in operand "xyERROR"0(62) : error C1048: invalid character 'E' in swizzle "xyERROR"0(62) : error C0000: syntax error, unexpected identifier, expecting ',' or ';' at token "missing"0(80) : error C1503: undefined variable "u_xlat9"0(80) : error C0000: syntax error, unexpected identifier, expecting "::" at token "GetBitcastOp"0(82) : error C1503: undefined variable "u_xlat9"0(82) : error C0000: syntax error, unexpected identifier, expecting ',' or ';' at token "missing"

    When I look at what it's compiled down to, it does look a little strange. Specifically the inclusion of ERROR where I'd expect something like z .

     

    **** Platform OpenGL Core:Compiled code for kernel CSMain:#version 420#extension GL_ARB_shading_language_420pack : require#ifdef GL_ARB_compute_shader#extension GL_ARB_compute_shader : enable#endif#ifdef GL_ARB_gpu_shader_fp64#extension GL_ARB_gpu_shader_fp64 : enable#endif#define HLSLCC_ENABLE_UNIFORM_BUFFERS 1#if HLSLCC_ENABLE_UNIFORM_BUFFERS#define UNITY_UNIFORM#else#define UNITY_UNIFORM uniform#endif#define UNITY_SUPPORTS_UNIFORM_LOCATION 1#if UNITY_SUPPORTS_UNIFORM_LOCATION#define UNITY_LOCATION(x) layout(location = x)#define UNITY_BINDING(x) layout(binding = x, std140)#else#define UNITY_LOCATION(x)#define UNITY_BINDING(x) layout(std140)#endiflayout(std140) uniform CGlobals {	vec4 DepthParam;	int ImageWidth;};uniform  sampler2D DepthInput;writeonly layout(binding=0) uniform image2D Result;vec4 u_xlat0;ivec4 u_xlati0;uint u_xlatu0;bool u_xlatb0;vec2 u_xlat1;uvec4 u_xlatu1;bool u_xlatb1;uvec4 u_xlatu2;uvec4 u_xlatu3;float u_xlat4;float u_xlat8;int u_xlati8;uint u_xlatu8;bool u_xlatb8;bool u_xlatb12;layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;void main(){    u_xlati0.x = ImageWidth >> 1;    u_xlatu1.xy = gl_GlobalInvocationID.xy;    u_xlatu1.z = uint(0u);    u_xlatu1.w = uint(0u);    u_xlat4 = texelFetch(DepthInput, ivec2(u_xlatu1.xy), int(u_xlatu1.w)).x;    u_xlati8 = (-int(gl_GlobalInvocationID.x)) + ImageWidth;    u_xlatu8 = (-uint(u_xlati0.x)) + uint(u_xlati8);    u_xlat8 = float(u_xlatu8);    u_xlat8 = u_xlat4 * u_xlat8;    u_xlat8 = u_xlat8 / DepthParam.x;    u_xlat8 = u_xlat8 + DepthParam.y;    u_xlat8.xyERROR missing components in GetBitcastOp()(u_xlat0.zw) + uintBitsToFloat(u_xlatu2.zw);    u_xlat8.xy(-ERROR missing components in GetBitcastOp()(u_xlat8.xy)) + uintBitsToFloat(u_xlatu1.xy);    u_xlatb1 = int(u_xlatu3.x)>=0;    u_xlat8.xyERROR missing components in GetBitcastOp()(u_xlat0.zw) + vec2(dvec4(2.2252139516747411e-308, 2.2331671504539444e-308, 2.2252139516747411e-308, 2.2331671504539444e-308).xy);    u_xlatb8 = int(u_xlatu3.z)<ImageWidth;    u_xlatb8 = u_xlatb8 && u_xlatb1;    u_xlat1.xy = DepthParam.zw * vec2(100.0, 100.0);    u_xlatb12 = u_xlat1.x<u_xlat0.y;    u_xlatb8 = u_xlatb12 && u_xlatb8;    u_xlatb1 = u_xlat0.y<u_xlat1.y;    u_xlatb8 = u_xlatb8 && u_xlatb1;    if(u_xlatb8){        u_xlatu3.yw = gl_GlobalInvocationID.yy;        imageStore(Result, ivec2(u_xlatu3.xy), u_xlat0.yyyy);        imageStore(Result, ivec2(u_xlatu3.zw), u_xlat0.yyyy);    }    u_xlatu0 = (-floatBitsToUint(u_xlat0.x)) + gl_GlobalInvocationID.x;    u_xlat0.x = float(u_xlatu0);    u_xlat0.x = u_xlat0.y * u_xlat0.x;    u_xlat0.x = u_xlat0.x / DepthParam.x;    u_xlat0.x = u_xlat0.x + (-DepthParam.y);    u_xlat9.xyuintBitsToFloat(u_xlatu2.zw) + ERROR missing components in GetBitcastOp()(u_xlat9.xy);    u_xlatb0 = int(u_xlatu2.x)>=0;    u_xlat9.xyERROR missing components in GetBitcastOp()(u_xlat9.xy) + vec2(dvec4(2.2252139516747411e-308, 2.2331671504539439e-308, 2.2252139516747411e-308, 2.2331671504539439e-308).xy);    u_xlatb8 = int(u_xlatu2.z)<ImageWidth;    u_xlati0.x = u_xlatb8 ? u_xlati0.x : int(0);    u_xlati0.x = int(uint(u_xlati0.w) & uint(u_xlati0.x));    u_xlati0.x = u_xlatb1 ? u_xlati0.x : int(0);    if(u_xlati0.x != 0) {        u_xlatu2.yw = gl_GlobalInvocationID.yy;        imageStore(Result, ivec2(u_xlatu2.xy), intBitsToFloat(u_xlati0.yyyy));        imageStore(Result, ivec2(u_xlatu2.zw), intBitsToFloat(u_xlati0.yyyy));    }    return;}**** Platform Direct3D 11:Compiled code for kernel CSMain:binary blob size 1688://// Generated by Microsoft ® D3D Shader Disassembler////// Note: shader requires additional functionality://       Double-precision floating point//       Double-precision extensions for 11.1////// Input signature://// Name                 Index   Mask Register SysValue  Format   Used// -------------------- ----- ------ -------- -------- ------- ------// no Input//// Output signature://// Name                 Index   Mask Register SysValue  Format   Used// -------------------- ----- ------ -------- -------- ------- ------// no Output      cs_5_0      dcl_globalFlags refactoringAllowed | enableDoublePrecisionFloatOps | enable11_1DoubleExtensions      dcl_constantbuffer CB0[2], immediateIndexed      dcl_resource_texture2d (float,float,float,float) t0      dcl_uav_typed_texture2d (float,float,float,float) u0      dcl_input vThreadID.xy      dcl_temps 4      dcl_thread_group 8, 8, 1   0: ishr r0.x, cb0[1].x, l(1)   1: mov r1.xy, vThreadID.xyxx   2: mov r1.zw, l(0,0,0,0)   3: ld_indexable(texture2d)(float,float,float,float) r0.y, r1.xyzw, t0.yxzw   4: iadd r0.z, -vThreadID.x, cb0[1].x   5: iadd r0.z, -r0.x, r0.z   6: utof r0.z, r0.z   7: mul r0.z, r0.y, r0.z   8: div r0.z, r0.z, cb0[0].x   9: add r0.z, r0.z, cb0[0].y  10: ftod r0.zw, r0.z  11: itod r1.xy, cb0[1].x  12: ftod r1.zw, cb0[0].x  13: dmul r0.zw, r0.zwzw, r1.zwzw  14: ftod r2.xy, r0.y  15: ddiv r0.zw, r0.zwzw, r2.xyxy  16: itod r2.zw, r0.x  17: dadd r0.zw, r0.zwzw, r2.zwzw  18: dadd r0.zw, -r0.zwzw, r1.xyxy  19: dtoi r3.x, r0.zwzw  20: ige r1.x, r3.x, l(0)  21: dadd r0.zw, r0.zwzw, d(0.000000l, 0.500000l)  22: dtoi r3.z, r0.zwzw  23: ilt r0.z, r3.z, cb0[1].x  24: and r0.z, r0.z, r1.x  25: mul r1.xy, cb0[0].zwzz, l(100.000000, 100.000000, 0.000000, 0.000000)  26: lt r0.w, r1.x, r0.y  27: and r0.z, r0.w, r0.z  28: lt r1.x, r0.y, r1.y  29: and r0.z, r0.z, r1.x  30: if_nz r0.z  31:   mov r3.yw, vThreadID.yyyy  32:   store_uav_typed u0.xyzw, r3.xyyy, r0.yyyy  33:   store_uav_typed u0.xyzw, r3.zwww, r0.yyyy  34: endif   35: iadd r0.x, -r0.x, vThreadID.x  36: utof r0.x, r0.x  37: mul r0.x, r0.y, r0.x  38: div r0.x, r0.x, cb0[0].x  39: add r0.x, r0.x, -cb0[0].y  40: ftod r3.xy, r0.x  41: dmul r1.zw, r1.zwzw, r3.xyxy  42: ddiv r1.zw, r1.zwzw, r2.xyxy  43: dadd r1.zw, r2.zwzw, r1.zwzw  44: dtoi r2.x, r1.zwzw  45: ige r0.x, r2.x, l(0)  46: dadd r1.zw, r1.zwzw, d(0.000000l, 0.500000l)  47: dtoi r2.z, r1.zwzw  48: ilt r0.z, r2.z, cb0[1].x  49: and r0.x, r0.z, r0.x  50: and r0.x, r0.w, r0.x  51: and r0.x, r1.x, r0.x  52: if_nz r0.x  53:   mov r2.yw, vThreadID.yyyy  54:   store_uav_typed u0.xyzw, r2.xyyy, r0.yyyy  55:   store_uav_typed u0.xyzw, r2.zwww, r0.yyyy  56: endif   57: ret // Approximately 0 instruction slots used

       

  4. We have a Vive Pro Eye and I'm finding that the bits it uses don't play well with the SRWorks SDK. I'm seeing several "Multiple plugins with the same name" errors. For example:

     

    We use Package Manager to bring in OpenVR, but SRWorks has its own copy. If I remove the package, nothing draws, but if I remove the plugin contained within SRWorks, it won't link.

     

    SRanipal has its own version of srworks_log which collides with the version in SRWorks. 

     

    Not really your problem, but the flfw3 you bring in collides with the one Magic Leap uses...

     

    I know this is all something of a preview, but it would be nice if it played well with the SRanipal and OpenVR's move to the PackageManager.

    (     - tags added by moderator) 

  5. Hi. I'm trying to play with the SRWorks 0.8.0.2 SDK, but can't get anything to run (and not crash). I've tried making a new  project in Unity 2018.3.13f1. After commenting out Registry calls, I crash with the abbrivated backtrace:

     

    0x00007FF9410B5F34 (DualCameraInterface) dualcamera::CreateCameraQualityControlInterface0x00007FF9410B4BD5 (DualCameraInterface) dualcamera::CreateCameraQualityControlInterface0x00007FF9411A7E60 (ViveSR_API) SystemMonitor::operator=0x00007FF9411B3D8D (ViveSR_API) ViveSR_StartModule0x000000002219B5FA (Assembly-CSharp) Vive.Plugin.SR.ViveSR_Framework.ViveSR_StartModule()0x000000002219B4A3 (Assembly-CSharp) Vive.Plugin.SR.ViveSR_Framework.StartModule()0x000000002219A513 (Assembly-CSharp) Vive.Plugin.SR.ViveSR.ViveSR_StartFramework()0x000000001A1BB264 (Assembly-CSharp) <StartFrameworkCoroutine>d__27.MoveNext()0x000000001A1BA3E0 (UnityEngine.CoreModule) UnityEngine.SetupCoroutine.InvokeMoveNext()0x000000001A1BA5D0 (UnityEngine.CoreModule) <Module>.runtime_invoke_void_object_intptr()0x00007FF914BBBE7B (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke 0x00007FF914B41E32 (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:2919] do_runtime_invoke 0x00007FF914B4AE3F (mono-2.0-bdwgc) [c:\buildslave\mono\build\mono\metadata\object.c:2966] mono_runtime_invoke 0x0000000140C00F5A (Unity) scripting_method_invoke0x0000000140BF12AA (Unity) ScriptingInvocation::Invoke0x0000000140BC4815 (Unity) Coroutine::Run

    I then tried to run the Vive_SRWorks_Demo executable and crash in pretty much the same spot it looks. 

     

    Thoughts on how to get past this?

    (  tag added by moderator)

  6. Having run some experiments, I don't think any of this can be called off the main thread.

    If you start the system on the main thread, but ask for events off thread, you'll get them, but Unity will lock up if anything else tries to talk to the SRRuntime. For example, once you've called an SR call off thread, you can't hit Stop in the editor without restarting all of Unity via the Task Manager.

    If you start the system on a dedicated thread, and try to isolate your calls to that thread, you'll quickly run into some part of SR calling into FindObjectOfType, which needs to be on the main thread.

    It would be great if the Unity side of this was made thread safe so we could safely poll at 120hz.

    (     - tag added by moderator) 

  7. Howdy. I've just started playing with the SRanipal Unity SDK for the Vive Pro Eye and am trying to understand some of the data I'm getting back. 

     

    When I look at the SingleEyeData for the left eye, there's a field for gaze_origin_mm. First off, the comments say that's in Meter Miles, which I don't think is a thing ;) Second, how would I go about converting that to a point in world space?

     

    What is the origin which gaze_origin_mm is based around? The documentation for SingleEyeData makes it look like it's the center of the lens in front of that eye. If so, what is the relationship between the center of that lens and something like the main camera?

     

    Thanks.

×
×
  • Create New...