Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Anonymous's avatar
Anonymous
9 years ago

ovr_GetRenderDesc is returning old ovrEyeRenderDesc struct (SDK v1.16 instead of v1.17+)

In Oculus SDK v1.17 the ovrEyeRenderDesc struct has changed from:

typedef struct OVR_ALIGNAS(4) ovrEyeRenderDesc_
{
    ovrEyeType  Eye;                        ///< The eye index to which this instance corresponds.
    ovrFovPort  Fov;                        ///< The field of view.
    ovrRecti    DistortedViewport;          ///< Distortion viewport.
    ovrVector2f PixelsPerTanAngleAtCenter;  ///< How many display pixels will fit in tan(angle) = 1.
    ovrVector3f HmdToEyeOffset;             ///< Translation of each eye, in meters.
} ovrEyeRenderDesc;

to

typedef struct OVR_ALIGNAS(4) ovrEyeRenderDesc_ {
  ovrEyeType Eye; ///< The eye index to which this instance corresponds.
  ovrFovPort Fov; ///< The field of view.
  ovrRecti DistortedViewport; ///< Distortion viewport.
  ovrVector2f PixelsPerTanAngleAtCenter; ///< How many display pixels will fit in tan(angle) = 1.
  ovrPosef HmdToEyePose; ///< Transform of eye from the HMD center, in meters.
} ovrEyeRenderDesc;

So the HmdToEye data is now written into the following struct (instead of Vector3f):

typedef struct OVR_ALIGNAS(4) ovrPosef_ {
  ovrQuatf Orientation;
  ovrVector3f Position;
} ovrPosef;


This works fine in the Tiny Room Sample (and other samples) - there the HmdToEyePose.Orientation is set to (0,0,0,1) and HmdToEyePose.Position is set to (-0.0307..., 0, 0).

But when ovr_GetRenderDesc is called from .Net application that is using Ab3d.OculusWrap (https://github.com/ab4d/Ab3d.OculusWrap), the function still returns the data in the old format. This means that the eye position is not written to the HmdToEyePose.Position but instead into the first 3 floats in HmdToEyePose.Orientation. So HmdToEyePose.Orientation is set to (-0.0307..., 0, 0, 0) and HmdToEyePose.Position is set to (0, 0, 0).

In both application the OVR is initialized with RequestedMinorVersion set to 18 (17 has the same result).


To exclude issues with .Net marshaling I have simplified the ovrEyeRenderDesc struct to include only int and float fields and the results are still the same.

The following image shows .Net memory dump (marked with blue are the values for PixelsPerTanAngleAtCenter; then there is the eye position data):



The correct memory layout can be seen in the Oculus Tiny room sample (see that after the PixelsPerTanAngleAtCenter there are data for Quaternion and lastly the eye positition):



I am attaching a greatly simplified sample .Net project that can be used to reproduce the problem.
The sample is using the following code:

            var initializationParameters = new InitParams()
            {
                Flags = InitFlags.RequestVersion,
                RequestedMinorVersion = 18
            };

            var result = ovr_Initialize(initializationParameters);

            var sessionPtr = IntPtr.Zero;
            var graphicsLuid = new GraphicsLuid();
            result = ovr_Create(ref sessionPtr, ref graphicsLuid);

            HmdDesc hmdDesc;
            ovr_GetHmdDesc32(out hmdDesc, sessionPtr);

            var descTest = ovr_GetRenderDesc(sessionPtr, 0, hmdDesc.DefaultEyeFov[0]);

            if (descTest.HmdToEyePose_Position_X == 0)
            {
                // INVALID VALUE !!!
            }


As a workaround I have added a check if Position.X is 0 and in this case use the value from Orientation.
But I would rather get the correct Orientation and Positions values. Please advise how to get the correct struct.

2 Replies

  • Normally the LibOVR.lib shim would hide our API versioning details from you, but since you're presumably loading the LibOVRRT dll directly for .net you'll have to track those yourself (we provide the shim code in our SDK). In this case the export from the .dll is now ovr_GetRenderDesc2, calling that should get you the new eye pose.
  • Anonymous's avatar
    Anonymous
    Thank you for your information.

    I have updated the .Net wrapper and it works correctly now.