diff --git a/PSVRFramework.sln b/PSVRFramework.sln index 1563fc8..a603f89 100644 --- a/PSVRFramework.sln +++ b/PSVRFramework.sln @@ -65,21 +65,17 @@ Global {168EDAE3-110E-419E-9013-A26FE4F2B6EB}.Release|x86.ActiveCfg = Release|Any CPU {168EDAE3-110E-419E-9013-A26FE4F2B6EB}.Release|x86.Build.0 = Release|Any CPU {16FCBDA3-0C18-4F11-AF62-510B051FDBFB}.Debug|Any CPU.ActiveCfg = Debug|x64 - {16FCBDA3-0C18-4F11-AF62-510B051FDBFB}.Debug|Any CPU.Build.0 = Debug|x64 {16FCBDA3-0C18-4F11-AF62-510B051FDBFB}.Debug|x64.ActiveCfg = Debug|x64 {16FCBDA3-0C18-4F11-AF62-510B051FDBFB}.Debug|x64.Build.0 = Debug|x64 {16FCBDA3-0C18-4F11-AF62-510B051FDBFB}.Debug|x86.ActiveCfg = Debug|x64 - {16FCBDA3-0C18-4F11-AF62-510B051FDBFB}.Debug|x86.Build.0 = Debug|x64 {16FCBDA3-0C18-4F11-AF62-510B051FDBFB}.Release|Any CPU.ActiveCfg = Release|x64 {16FCBDA3-0C18-4F11-AF62-510B051FDBFB}.Release|x64.ActiveCfg = Release|x64 {16FCBDA3-0C18-4F11-AF62-510B051FDBFB}.Release|x64.Build.0 = Release|x64 {16FCBDA3-0C18-4F11-AF62-510B051FDBFB}.Release|x86.ActiveCfg = Release|x64 {9B40E68F-7090-4FFC-AAC7-2E357CEF34C7}.Debug|Any CPU.ActiveCfg = Debug|x64 - {9B40E68F-7090-4FFC-AAC7-2E357CEF34C7}.Debug|Any CPU.Build.0 = Debug|x64 {9B40E68F-7090-4FFC-AAC7-2E357CEF34C7}.Debug|x64.ActiveCfg = Debug|x64 {9B40E68F-7090-4FFC-AAC7-2E357CEF34C7}.Debug|x64.Build.0 = Debug|x64 {9B40E68F-7090-4FFC-AAC7-2E357CEF34C7}.Debug|x86.ActiveCfg = Debug|x64 - {9B40E68F-7090-4FFC-AAC7-2E357CEF34C7}.Debug|x86.Build.0 = Debug|x64 {9B40E68F-7090-4FFC-AAC7-2E357CEF34C7}.Release|Any CPU.ActiveCfg = Release|x64 {9B40E68F-7090-4FFC-AAC7-2E357CEF34C7}.Release|x64.ActiveCfg = Release|x64 {9B40E68F-7090-4FFC-AAC7-2E357CEF34C7}.Release|x64.Build.0 = Release|x64 diff --git a/PSVRFramework.sln.startup.json b/PSVRFramework.sln.startup.json new file mode 100644 index 0000000..15cceba --- /dev/null +++ b/PSVRFramework.sln.startup.json @@ -0,0 +1,34 @@ +/* + This is a configuration file for the SwitchStartupProject Visual Studio Extension + See https://bitbucket.org/thirteen/switchstartupproject/src/tip/Configuration.md +*/ +{ + /* Configuration File Version */ + "Version": 3, + + /* Create an item in the dropdown list for each project in the solution? */ + "ListAllProjects": true, + + /* + Dictionary of named startup project configurations with one or multiple + startup projects and optional command line arguments. + Example: + + "MultiProjectConfigurations": { + "A + B": { + "Projects": { + "MyProjectA": {}, + "MyProjectB": { + "CommandLineArguments": "1234" + } + } + }, + "D": { + "Projects": { + "MyProjectD": {} + } + } + }, + */ + "MultiProjectConfigurations": {} +} diff --git a/PSVRFramework/PSVR.cs b/PSVRFramework/PSVR.cs index 915acca..7770075 100644 --- a/PSVRFramework/PSVR.cs +++ b/PSVRFramework/PSVR.cs @@ -9,32 +9,46 @@ namespace PSVRFramework { - public struct PSVRSensor + public class PSVRSensor { //To be analyzed... + public HeadsetButtons Buttons; + public int Volume; + public bool Worn; + public bool DisplayActive; + public bool Muted; + public bool EarphonesConnected; - public int volume; - public bool isWorn; - public bool isDisplayActive; - public bool isMute; - public bool isEarphoneConnected; + public int GroupSequence1; + + public int GyroYaw1; + public int GyroPitch1; + public int GyroRoll1; public int MotionX1; public int MotionY1; public int MotionZ1; + public int GroupSequence2; + + public int GyroYaw2; + public int GyroPitch2; + public int GyroRoll2; + public int MotionX2; public int MotionY2; public int MotionZ2; - public int GyroYaw1; - public int GyroPitch1; - public int GyroRoll1; + public int IRSensor; //1023 = near, 0 = far - public int GyroYaw2; - public int GyroPitch2; - public int GyroRoll2; + public int CalStatus; //Calibration status? 255 = boot, 0-3 calibrating? 4 = calibrated, maybe a bit mask with sensor status? (0 bad, 1 good)? + public int Ready; //0 = not ready, 1 = ready -> uint ushort or byte? + + public int PacketSequence; + + public int VoltageReference; //Not sure at all, starts in 0 and suddenly jumps to 3 + public int VoltageValue; //Not sure at all, starts on 0, ranges very fast to 255, when switched from VR to Cinematic and back varies between 255 and 254 //DEBUG public int A; @@ -45,24 +59,24 @@ public struct PSVRSensor public int F; public int G; public int H; - public int I; - public int J; - public int K; - public int L; - public int M; - public int N; - public int O; + //For future use, will hold a Quaternion with the head orientation + public float[] Orientation; + } + [Flags] + public enum HeadsetButtons + { + VolUp = 2, + VolDown = 4, + Mute = 8 } public struct PSVRState { public PSVRSensor sensor; } - - - + public class PSVR : IDisposable { UsbEndpointWriter writer; @@ -74,40 +88,81 @@ public class PSVR : IDisposable public event EventHandler Removed; Timer aliveTimer; - - public PSVR() + + public PSVR(bool UseLibUSB) { - var ndev = UsbDevice.AllWinUsbDevices.Where(d => d.Vid == 0x54C && d.Name == "PS VR Control (Interface 5)").FirstOrDefault(); - if (ndev == null) - throw new InvalidOperationException("No Control device found"); + if (!UseLibUSB) + { - if (!ndev.Open(out controlDevice)) - throw new InvalidOperationException("Device in use"); + var ndev = UsbDevice.AllWinUsbDevices.Where(d => d.Vid == 0x54C && d.Name == "PS VR Control (Interface 5)").FirstOrDefault(); + + if (ndev == null) + throw new InvalidOperationException("No Control device found"); + + if (!ndev.Open(out controlDevice)) + throw new InvalidOperationException("Device in use"); + + ndev = UsbDevice.AllWinUsbDevices.Where(d => d.Vid == 0x54C && d.Name == "PS VR Sensor (Interface 4)").FirstOrDefault(); + + if (ndev == null) + { + controlDevice.Close(); + throw new InvalidOperationException("No Sensor device found"); + } + if (!ndev.Open(out sensorDevice)) + { + controlDevice.Close(); + throw new InvalidOperationException("Device in use"); + } + + writer = controlDevice.OpenEndpointWriter(LibUsbDotNet.Main.WriteEndpointID.Ep04); + + reader = sensorDevice.OpenEndpointReader(LibUsbDotNet.Main.ReadEndpointID.Ep03, 64); + reader.DataReceived += Reader_DataReceived; + reader.DataReceivedEnabled = true; + + aliveTimer = new Timer(is_alive); + aliveTimer.Change(2000, 2000); - ndev = UsbDevice.AllWinUsbDevices.Where(d => d.Vid == 0x54C && d.Name == "PS VR Sensor (Interface 4)").FirstOrDefault(); - if (ndev == null) - { - controlDevice.Close(); - throw new InvalidOperationException("No Sensor device found"); } - if (!ndev.Open(out sensorDevice)) + else { - controlDevice.Close(); - throw new InvalidOperationException("Device in use"); - } + LibUsbDotNet.Main.UsbDeviceFinder find = new LibUsbDotNet.Main.UsbDeviceFinder(0x054C, 0x09AF); + controlDevice = LibUsbDotNet.UsbDevice.OpenUsbDevice(find); + + if (controlDevice == null) + throw new InvalidOperationException("No device found"); + + var dev = (IUsbDevice)controlDevice; + + for (int ifa = 0; ifa < controlDevice.Configs[0].InterfaceInfoList.Count; ifa++) + { + var iface = controlDevice.Configs[0].InterfaceInfoList[ifa]; - writer = controlDevice.OpenEndpointWriter(LibUsbDotNet.Main.WriteEndpointID.Ep04); + if (iface.Descriptor.InterfaceID == 5) + { + dev.SetConfiguration(1); - reader = sensorDevice.OpenEndpointReader(LibUsbDotNet.Main.ReadEndpointID.Ep03, 64); - reader.DataReceived += Reader_DataReceived; - reader.DataReceivedEnabled = true; + var res = dev.ClaimInterface(5); + res = dev.ClaimInterface(4); - aliveTimer = new Timer(is_alive); - aliveTimer.Change(2000, 2000); + writer = dev.OpenEndpointWriter(LibUsbDotNet.Main.WriteEndpointID.Ep04); + reader = dev.OpenEndpointReader(LibUsbDotNet.Main.ReadEndpointID.Ep03, 64); + reader.DataReceived += Reader_DataReceived; + reader.DataReceivedEnabled = true; + + aliveTimer = new Timer(is_alive); + aliveTimer.Change(2000, 2000); + return; + } + } + + throw new InvalidOperationException("Device does not match descriptor"); + } } void is_alive(object state) @@ -156,77 +211,54 @@ public static PSVRSensor parseSensor(byte[] data) return sensor; } + sensor.Buttons = (HeadsetButtons)data[0]; + sensor.Volume = data[2]; - /* - * sample data - 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 - 00-00-00-19-00-0A-04-20-00-06-1D-01-FF-7F-00-00-42-AB-D7-69-00-FE-FF-F4-FF-16-00-E1-CF-1F-E0-E1-E9-9F-D9-69-00-FC-FF-EF-FF-24-00-C1-CF-1F-E0-B1-E9-1D-01-00-00-00-03-FF-82-00-00-00-00-00-BC-01-6D - 00-00-00-19-00-0A-04-20-00-06-1D-01-FF-7F-00-00-42-93-DB-69-00-FF-FF-FA-FF-13-00-D1-CF-2F-E0-81-E9-88-DD-69-00-FC-FF-0A-00-FC-FF-11-D0-FF-DF-D1-E9-1D-01-00-00-00-03-FF-82-00-00-00-00-00-7D-01-6E - 00-00-00-19-00-0A-04-20-00-06-1D-01-FF-7F-00-00-42-7B-DF-69-00-08-00-0E-00-EE-FF-F1-CF-EF-DF-01-EA-70-E1-69-00-04-00-09-00-F9-FF-E1-CF-1F-E0-B1-E9-1D-01-00-00-00-03-FF-82-00-00-00-00-00-84-01-6F - - [byte 3] - Volume (0~50) - [byte 9] - 0000 0001 Worn (Mounted on Player) - 0000 0010 Display is On - 0000 0100 ?? - 0000 1000 Mute - 0001 0000 Earphone - 0010 0000 - 0100 0000 - 1000 0000 - reference: - https://github.com/hrl7/node-psvr/blob/master/lib/psvr.js - */ - - - sensor.volume = data[2]; - - sensor.isWorn = (data[8] & 0x1) == 0x1 ? true : false;//confirmed - sensor.isDisplayActive = (data[8] & 0x2) == 0x2 ? false : true; - sensor.isMute = (data[8] & 0x8) == 0x8 ? true : false;//confirmed - - sensor.isEarphoneConnected = (data[8] & 0x10) == 0x10 ? true : false;//confirmed - + sensor.Worn = (data[8] & 0x1) == 0x1 ? true : false;//confirmed + sensor.DisplayActive = (data[8] & 0x2) == 0x2 ? false : true; + sensor.Muted = (data[8] & 0x8) == 0x8 ? true : false;//confirmed - sensor.MotionX1 = getIntFromInt16(data, 26); - sensor.MotionY1 = getIntFromInt16(data, 28); - sensor.MotionZ1 = getIntFromInt16(data, 30); + sensor.EarphonesConnected = (data[8] & 0x10) == 0x10 ? true : false;//confirmed - sensor.MotionX2 = getIntFromInt16(data, 42); - sensor.MotionY2 = getIntFromInt16(data, 44); - sensor.MotionZ2 = getIntFromInt16(data, 46); + sensor.GroupSequence1 = getIntFromInt16(data, 18); sensor.GyroYaw1 = getIntFromInt16(data, 20); sensor.GyroPitch1 = getIntFromInt16(data, 22); sensor.GyroRoll1 = getIntFromInt16(data, 24); + sensor.MotionX1 = getAccelShort(data, 26) ; + sensor.MotionY1 = getAccelShort(data, 28); + sensor.MotionZ1 = getAccelShort(data, 30); + + sensor.GroupSequence2 = getIntFromInt16(data, 34); + sensor.GyroYaw2 = getIntFromInt16(data, 36); sensor.GyroPitch2 = getIntFromInt16(data, 38); sensor.GyroRoll2 = getIntFromInt16(data, 40); + sensor.MotionX2 = getAccelShort(data, 42); + sensor.MotionY2 = getAccelShort(data, 44); + sensor.MotionZ2 = getAccelShort(data, 46); + + sensor.CalStatus = data[48]; + sensor.Ready = data[49]; - sensor.A = convert(data[18], data[19]); - sensor.B = convert(data[20], data[21]); - sensor.C = convert(data[22], data[23]); - - sensor.D = convert(data[24], data[25]); - sensor.E = convert(data[26], data[27]);//下方向加速度 - sensor.F = convert(data[28], data[29]);//左方向加速度 - - sensor.G = convert(data[30], data[31]);//後ろ方向加速度 - sensor.H = convert(data[32], data[33]); - sensor.I = convert(data[34], data[37]); - - sensor.J = convert(data[36], data[37]); - sensor.K = convert(data[38], data[39]); - sensor.L = convert(data[40], data[41]); + sensor.A = data[50]; + sensor.B = data[51]; + sensor.C = data[52]; - sensor.M = convert(data[42], data[43]);//下方向加速度 - sensor.N = convert(data[44], data[45]);//左方向加速度 - sensor.O = convert(data[46], data[47]);//後ろ方向加速度 + sensor.VoltageValue = data[53]; + sensor.VoltageReference = data[54]; + sensor.IRSensor = getIntFromInt16(data, 55); + sensor.D = data[58]; + sensor.E = data[59]; + sensor.F = data[60]; + sensor.G = data[61]; + sensor.H = data[62]; + sensor.PacketSequence = data[63]; + return sensor; } @@ -242,6 +274,18 @@ private static int getIntFromInt16(byte[] data, byte offset) return (short)data[offset] | (short)(data[offset + 1] << 8); } + private static short getAccelShort(byte[] data, byte offset) + { + + return (short)(((short)data[offset] | (short)(data[offset + 1] << 8)) >> 4); + } + + private static int getIntFromUInt16(byte[] data, byte offset) + { + + return (ushort)data[offset] | (ushort)(data[offset + 1] << 8); + } + public void Dispose() { aliveTimer.Change(Timeout.Infinite, Timeout.Infinite); diff --git a/PSVRToolbox/Classes/BMI055Fusion.cs b/PSVRToolbox/Classes/BMI055Fusion.cs new file mode 100644 index 0000000..9077f7f --- /dev/null +++ b/PSVRToolbox/Classes/BMI055Fusion.cs @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using PSVRFramework; + +namespace PSVRToolbox +{ + public class BMI055Fusion : IDisposable + { + float fRad2Deg = 57.295779513f; //将弧度转为角度的乘数 + const int MPU = 0x68; //MPU-6050的I2C地址 + const int nValCnt = 6; //一次读取寄存器的数量 + + const int nCalibTimes = 100; //校准时读数的次数 + short[] calibData = new short[nValCnt]; //校准数据 + float[] tempCal = new float[nValCnt]; + + float fLastRoll = 0.0f; //上一次滤波得到的Roll角 + float fLastPitch = 0.0f; //上一次滤波得到的Pitch角 + KalmanFilter kalmanRoll = new KalmanFilter(); //Roll角滤波器 + KalmanFilter kalmanPitch = new KalmanFilter(); //Pitch角滤波器 + + int calLeft = nCalibTimes; + + bool first = true; + Stopwatch lapseCounter; + + short[] readouts = new short[nValCnt]; + float[] realVals = new float[nValCnt]; + + public float RollRate { get; private set; } + public float PitchRate { get; private set; } + + public float Roll { get { return fLastRoll; } } + public float Pitch { get { return fLastPitch; } } + + + float maxX = 0; + + public void Feed(PSVRSensor SensorData) + { + if (calLeft > 0) + { + calLeft--; + FeedCalibration(SensorData); + return; + } + + float dt = 0; + + if (first) + { + kalmanRoll.Angle = 1; + kalmanPitch.Angle = 0.08f; + lapseCounter = new Stopwatch(); + lapseCounter.Start(); + first = false; + } + else + dt = ((float)lapseCounter.ElapsedTicks / (float)Stopwatch.Frequency); + + lapseCounter.Restart(); + + readouts[0] = (short)SensorData.MotionX1; + readouts[1] = (short)SensorData.MotionY1; + readouts[2] = (short)SensorData.MotionZ1; + + readouts[3] = (short)SensorData.GyroYaw1; + readouts[4] = (short)SensorData.GyroPitch1; + readouts[5] = (short)SensorData.GyroRoll1; + + Rectify(readouts, realVals); + + float fNorm = (float)Math.Sqrt(realVals[0] * realVals[0] + realVals[1] * realVals[1] + realVals[2] * realVals[2]); + float fRoll = GetRoll(realVals, fNorm); //计算Roll角 + if (realVals[1] > 0) + { + fRoll = -fRoll; + } + float fPitch = GetPitch(realVals, fNorm); //计算Pitch角 + if (realVals[0] < 0) + { + fPitch = -fPitch; + } + + float fNewRoll = kalmanRoll.GetAngle(fRoll, realVals[3], dt); + float fNewPitch = kalmanPitch.GetAngle(fPitch, realVals[4], dt); + + RollRate = (fNewRoll - fLastRoll) / dt; + PitchRate = (fNewPitch - fLastPitch) / dt; + + //更新Roll角和Pitch角 + fLastRoll = fNewRoll; + fLastPitch = fNewPitch; + } + + void FeedCalibration(PSVRSensor SensorData) + { + tempCal[0] += SensorData.MotionX1; + tempCal[1] += SensorData.MotionY1; + tempCal[2] += SensorData.MotionZ1; + + tempCal[3] += SensorData.GyroYaw1; + tempCal[4] += SensorData.GyroPitch1; + tempCal[5] += SensorData.GyroRoll1; + + if(calLeft == 0) + { + for (int buc = 0; buc < nValCnt; buc++) + calibData[buc] = (short)(tempCal[buc] / (float)nCalibTimes); + + calibData[0] -= 1024; + } + + + } + + float GetRoll(float[] pRealVals, float fNorm) + { + float fNormXZ = (float)Math.Sqrt(pRealVals[0] * pRealVals[0] + pRealVals[2] * pRealVals[2]); + float fCos = fNormXZ / fNorm; + return (float)Math.Sqrt(fCos); + } + + //算得Pitch角。算法见文档。 + float GetPitch(float[] pRealVals, float fNorm) + { + float fNormYZ = (float)Math.Sqrt(pRealVals[1] * pRealVals[1] + pRealVals[2] * pRealVals[2]); + float fCos = fNormYZ / fNorm; + return (float)Math.Sqrt(fCos); + } + + //对读数进行纠正,消除偏移,并转换为物理量。公式见文档。 + void Rectify(short[] pReadout, float[] pRealVals) + { + for (int i = 0; i < 3; ++i) + { + //pRealVals[i] = (float)(pReadout[i] - calibData[i]) / 16384.0f; + pRealVals[i] = ((float)(pReadout[i] - calibData[i])) / 1024.0f; + } + // pRealVals[3] = pReadout[3] / 340.0f + 36.53; + for (int i = 3; i < 6; ++i) + { + pRealVals[i] = (float)(pReadout[i] - calibData[i]) / 131.2f; + + } + } + + public void Dispose() + { + if (lapseCounter != null) + { + lapseCounter.Stop(); + lapseCounter = null; + } + } + } +} diff --git a/PSVRToolbox/Classes/KalmanFilter.cs b/PSVRToolbox/Classes/KalmanFilter.cs new file mode 100644 index 0000000..9ae3504 --- /dev/null +++ b/PSVRToolbox/Classes/KalmanFilter.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PSVRToolbox +{ + public class KalmanFilter + { + float Q_angle; // Process noise variance for the accelerometer + float Q_bias; // Process noise variance for the gyro bias + float R_measure; // Measurement noise variance - this is actually the variance of the measurement noise + + float angle; // The angle calculated by the Kalman filter - part of the 2x1 state vector + float bias; // The gyro bias calculated by the Kalman filter - part of the 2x1 state vector + float rate; // Unbiased rate calculated from the rate and the calculated bias - you have to call getAngle to update the rate + + public float Angle { get { return angle; } set { angle = value; } } + public float QAngle { get { return Q_angle; } set { Q_angle = value; } } + public float QBias { get { return Q_bias; } set { Q_bias = value; } } + public float RMeasure { get { return R_measure; } set { R_measure = value; } } + + + float[][] P = new float[2][]; // Error covariance matrix - This is a 2x2 matrix + + public KalmanFilter() + { + Q_angle = 0.001f; + Q_bias = 0.003f; + R_measure = 0.03f; + + angle = 0.0f; // Reset the angle + bias = 0.0f; // Reset bias + + P[0] = new float[2]; + P[1] = new float[2]; + + P[0][0] = 0.0f; // Since we assume that the bias is 0 and we know the starting angle (use setAngle), the error covariance matrix is set like so - see: http://en.wikipedia.org/wiki/Kalman_filter#Example_application.2C_technical + P[0][1] = 0.0f; + P[1][0] = 0.0f; + P[1][1] = 0.0f; + } + + public float GetAngle(float newAngle, float newRate, float dt) + { + // KasBot V2 - Kalman filter module - http://www.x-firm.com/?page_id=145 + // Modified by Kristian Lauszus + // See my blog post for more information: http://blog.tkjelectronics.dk/2012/09/a-practical-approach-to-kalman-filter-and-how-to-implement-it + + // Discrete Kalman filter time update equations - Time Update ("Predict") + // Update xhat - Project the state ahead + /* Step 1 */ + rate = newRate - bias; + angle += dt * rate; + + // Update estimation error covariance - Project the error covariance ahead + /* Step 2 */ + P[0][0] += dt * (dt * P[1][1] - P[0][1] - P[1][0] + Q_angle); + P[0][1] -= dt * P[1][1]; + P[1][0] -= dt * P[1][1]; + P[1][1] += Q_bias * dt; + + // Discrete Kalman filter measurement update equations - Measurement Update ("Correct") + // Calculate Kalman gain - Compute the Kalman gain + /* Step 4 */ + float S = P[0][0] + R_measure; // Estimate error + /* Step 5 */ + float[] K = new float[2]; // Kalman gain - This is a 2x1 vector + K[0] = P[0][0] / S; + K[1] = P[1][0] / S; + + // Calculate angle and bias - Update estimate with measurement zk (newAngle) + /* Step 3 */ + float y = newAngle - angle; // Angle difference + /* Step 6 */ + angle += K[0] * y; + bias += K[1] * y; + + // Calculate estimation error covariance - Update the error covariance + /* Step 7 */ + float P00_temp = P[0][0]; + float P01_temp = P[0][1]; + + P[0][0] -= K[0] * P00_temp; + P[0][1] -= K[0] * P01_temp; + P[1][0] -= K[1] * P00_temp; + P[1][1] -= K[1] * P01_temp; + + return angle; + } + } +} diff --git a/PSVRToolbox/Classes/MadgwickAHRS.cs b/PSVRToolbox/Classes/MadgwickAHRS.cs new file mode 100644 index 0000000..5eb161d --- /dev/null +++ b/PSVRToolbox/Classes/MadgwickAHRS.cs @@ -0,0 +1,397 @@ + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using PSVRFramework; + +namespace AHRS +{ + /// + /// MadgwickAHRS class. Implementation of Madgwick's IMU and AHRS algorithms. + /// + /// + /// See: http://www.x-io.co.uk/node/8#open_source_ahrs_and_imu_algorithms + /// + public class MadgwickAHRS + { + /// + /// Gets or sets the sample period. + /// + public float SamplePeriod { get; set; } + + /// + /// Gets or sets the algorithm gain beta. + /// + public float Beta { get; set; } + + /// + /// Gets or sets the Quaternion output. + /// + public float[] Quaternion { get; set; } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Sample period. + /// + public MadgwickAHRS(float samplePeriod) + : this(samplePeriod, 1f) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// + /// Sample period. + /// + /// + /// Algorithm gain beta. + /// + public MadgwickAHRS(float samplePeriod, float beta) + { + SamplePeriod = samplePeriod; + Beta = beta; + Quaternion = new float[] { 1f, 0f, 0f, 0f }; + sw.Start(); + } + + float[] drift = new float[6]; + + int samples = 0; + + public void Update(PSVRSensor Data) + { + + if (samples < 1000) + { + drift[0] += ParseAccelerometerData((short)Data.MotionY1); + drift[1] += ParseAccelerometerData((short)Data.MotionX1); + drift[2] += ParseAccelerometerData((short)Data.MotionZ1); + + drift[3] += ParseAccelerometerData((short)Data.GyroPitch1); + drift[4] += ParseAccelerometerData((short)Data.GyroYaw1); + drift[5] += ParseAccelerometerData((short)Data.GyroRoll1); + samples++; + return; + } + else if (samples == 1000) + { + samples++; + + for (int buc = 0; buc < 6; buc++) + drift[buc] = Math.Abs(drift[buc] / 1000.0f); + + drift[1] -= 1; + } + + SamplePeriod = 1 / (sw.ElapsedTicks / (float)Stopwatch.Frequency); + sw.Restart(); + + float accelX = ParseAccelerometerData((short)Data.MotionY1); + float accelY = ParseAccelerometerData((short)Data.MotionX1); + float accelZ = ParseAccelerometerData((short)Data.MotionZ1); + + //float gyroX = ParseGyroscopeData((short)Data.GyroPitch1); + //float gyroY = ParseGyroscopeData((short)Data.GyroRoll1); + //float gyroZ = ParseGyroscopeData((short)Data.GyroYaw1); + + //float gyroX = ParseGyroscopeData((short)Data.GyroPitch1); + //float gyroY = ParseGyroscopeData((short)Data.GyroYaw1); + //float gyroZ = ParseGyroscopeData((short)Data.GyroRoll1); + + //float gyroX = ParseGyroscopeData((short)Data.GyroRoll1); + //float gyroY = ParseGyroscopeData((short)Data.GyroPitch1); + //float gyroZ = ParseGyroscopeData((short)Data.GyroYaw1); + + //float gyroX = ParseGyroscopeData((short)Data.GyroRoll1); + //float gyroY = ParseGyroscopeData((short)Data.GyroYaw1); + //float gyroZ = ParseGyroscopeData((short)Data.GyroPitch1); + + + //float gyroX = ParseGyroscopeData((short)Data.GyroYaw1); + //float gyroY = ParseGyroscopeData((short)Data.GyroPitch1); + //float gyroZ = ParseGyroscopeData((short)Data.GyroRoll1); + + float gyroX = ParseGyroscopeData((short)Data.GyroPitch1); + float gyroY = ParseGyroscopeData((short)Data.GyroYaw1); + float gyroZ = ParseGyroscopeData((short)Data.GyroRoll1); + + + + + + accelX = Math.Sign(accelX) * (Math.Abs(accelX) - drift[0]); + accelX = Math.Sign(accelY) * (Math.Abs(accelY) - drift[1]); + accelX = Math.Sign(accelZ) * (Math.Abs(accelZ) - drift[2]); + accelX = Math.Sign(gyroX) * (Math.Abs(gyroX) - drift[3]); + accelX = Math.Sign(gyroY) * (Math.Abs(gyroY) - drift[4]); + accelX = Math.Sign(gyroZ) * (Math.Abs(gyroZ) - drift[5]); + + Update(gyroX, gyroY, gyroZ, accelX, accelY, accelZ); + + //accelX = ParseAccelerometerData((short)Data.MotionY2); + //accelY = ParseAccelerometerData((short)Data.MotionX2); + //accelZ = ParseAccelerometerData((short)Data.MotionZ2); + + //gyroX = ParseGyroscopeData((short)Data.GyroYaw2); + //gyroY = ParseGyroscopeData((short)Data.GyroRoll2); + //gyroZ = ParseGyroscopeData((short)Data.GyroPitch2); + + //Update(gyroX, gyroY, gyroZ, accelX, accelY, accelZ); + } + Stopwatch sw = new Stopwatch(); + /// + /// Algorithm AHRS update method. Requires only gyroscope and accelerometer data. + /// + /// + /// Gyroscope x axis measurement in radians/s. + /// + /// + /// Gyroscope y axis measurement in radians/s. + /// + /// + /// Gyroscope z axis measurement in radians/s. + /// + /// + /// Accelerometer x axis measurement in any calibrated units. + /// + /// + /// Accelerometer y axis measurement in any calibrated units. + /// + /// + /// Accelerometer z axis measurement in any calibrated units. + /// + /// + /// Magnetometer x axis measurement in any calibrated units. + /// + /// + /// Magnetometer y axis measurement in any calibrated units. + /// + /// + /// Magnetometer z axis measurement in any calibrated units. + /// + /// + /// Optimised for minimal arithmetic. + /// Total ±: 160 + /// Total *: 172 + /// Total /: 5 + /// Total sqrt: 5 + /// + public void Update(float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz) + { + float q1 = Quaternion[0], q2 = Quaternion[1], q3 = Quaternion[2], q4 = Quaternion[3]; // short name local variable for readability + float norm; + float hx, hy, _2bx, _2bz; + float s1, s2, s3, s4; + float qDot1, qDot2, qDot3, qDot4; + + // Auxiliary variables to avoid repeated arithmetic + float _2q1mx; + float _2q1my; + float _2q1mz; + float _2q2mx; + float _4bx; + float _4bz; + float _2q1 = 2f * q1; + float _2q2 = 2f * q2; + float _2q3 = 2f * q3; + float _2q4 = 2f * q4; + float _2q1q3 = 2f * q1 * q3; + float _2q3q4 = 2f * q3 * q4; + float q1q1 = q1 * q1; + float q1q2 = q1 * q2; + float q1q3 = q1 * q3; + float q1q4 = q1 * q4; + float q2q2 = q2 * q2; + float q2q3 = q2 * q3; + float q2q4 = q2 * q4; + float q3q3 = q3 * q3; + float q3q4 = q3 * q4; + float q4q4 = q4 * q4; + + // Normalise accelerometer measurement + norm = (float)Math.Sqrt(ax * ax + ay * ay + az * az); + if (norm == 0f) return; // handle NaN + norm = 1 / norm; // use reciprocal for division + ax *= norm; + ay *= norm; + az *= norm; + + // Normalise magnetometer measurement + norm = (float)Math.Sqrt(mx * mx + my * my + mz * mz); + if (norm == 0f) return; // handle NaN + norm = 1 / norm; // use reciprocal for division + mx *= norm; + my *= norm; + mz *= norm; + + // Reference direction of Earth's magnetic field + _2q1mx = 2f * q1 * mx; + _2q1my = 2f * q1 * my; + _2q1mz = 2f * q1 * mz; + _2q2mx = 2f * q2 * mx; + hx = mx * q1q1 - _2q1my * q4 + _2q1mz * q3 + mx * q2q2 + _2q2 * my * q3 + _2q2 * mz * q4 - mx * q3q3 - mx * q4q4; + hy = _2q1mx * q4 + my * q1q1 - _2q1mz * q2 + _2q2mx * q3 - my * q2q2 + my * q3q3 + _2q3 * mz * q4 - my * q4q4; + _2bx = (float)Math.Sqrt(hx * hx + hy * hy); + _2bz = -_2q1mx * q3 + _2q1my * q2 + mz * q1q1 + _2q2mx * q4 - mz * q2q2 + _2q3 * my * q4 - mz * q3q3 + mz * q4q4; + _4bx = 2f * _2bx; + _4bz = 2f * _2bz; + + // Gradient decent algorithm corrective step + s1 = -_2q3 * (2f * q2q4 - _2q1q3 - ax) + _2q2 * (2f * q1q2 + _2q3q4 - ay) - _2bz * q3 * (_2bx * (0.5f - q3q3 - q4q4) + _2bz * (q2q4 - q1q3) - mx) + (-_2bx * q4 + _2bz * q2) * (_2bx * (q2q3 - q1q4) + _2bz * (q1q2 + q3q4) - my) + _2bx * q3 * (_2bx * (q1q3 + q2q4) + _2bz * (0.5f - q2q2 - q3q3) - mz); + s2 = _2q4 * (2f * q2q4 - _2q1q3 - ax) + _2q1 * (2f * q1q2 + _2q3q4 - ay) - 4f * q2 * (1 - 2f * q2q2 - 2f * q3q3 - az) + _2bz * q4 * (_2bx * (0.5f - q3q3 - q4q4) + _2bz * (q2q4 - q1q3) - mx) + (_2bx * q3 + _2bz * q1) * (_2bx * (q2q3 - q1q4) + _2bz * (q1q2 + q3q4) - my) + (_2bx * q4 - _4bz * q2) * (_2bx * (q1q3 + q2q4) + _2bz * (0.5f - q2q2 - q3q3) - mz); + s3 = -_2q1 * (2f * q2q4 - _2q1q3 - ax) + _2q4 * (2f * q1q2 + _2q3q4 - ay) - 4f * q3 * (1 - 2f * q2q2 - 2f * q3q3 - az) + (-_4bx * q3 - _2bz * q1) * (_2bx * (0.5f - q3q3 - q4q4) + _2bz * (q2q4 - q1q3) - mx) + (_2bx * q2 + _2bz * q4) * (_2bx * (q2q3 - q1q4) + _2bz * (q1q2 + q3q4) - my) + (_2bx * q1 - _4bz * q3) * (_2bx * (q1q3 + q2q4) + _2bz * (0.5f - q2q2 - q3q3) - mz); + s4 = _2q2 * (2f * q2q4 - _2q1q3 - ax) + _2q3 * (2f * q1q2 + _2q3q4 - ay) + (-_4bx * q4 + _2bz * q2) * (_2bx * (0.5f - q3q3 - q4q4) + _2bz * (q2q4 - q1q3) - mx) + (-_2bx * q1 + _2bz * q3) * (_2bx * (q2q3 - q1q4) + _2bz * (q1q2 + q3q4) - my) + _2bx * q2 * (_2bx * (q1q3 + q2q4) + _2bz * (0.5f - q2q2 - q3q3) - mz); + norm = 1f / (float)Math.Sqrt(s1 * s1 + s2 * s2 + s3 * s3 + s4 * s4); // normalise step magnitude + s1 *= norm; + s2 *= norm; + s3 *= norm; + s4 *= norm; + + // Compute rate of change of quaternion + qDot1 = 0.5f * (-q2 * gx - q3 * gy - q4 * gz) - Beta * s1; + qDot2 = 0.5f * (q1 * gx + q3 * gz - q4 * gy) - Beta * s2; + qDot3 = 0.5f * (q1 * gy - q2 * gz + q4 * gx) - Beta * s3; + qDot4 = 0.5f * (q1 * gz + q2 * gy - q3 * gx) - Beta * s4; + + // Integrate to yield quaternion + q1 += qDot1 * SamplePeriod; + q2 += qDot2 * SamplePeriod; + q3 += qDot3 * SamplePeriod; + q4 += qDot4 * SamplePeriod; + norm = 1f / (float)Math.Sqrt(q1 * q1 + q2 * q2 + q3 * q3 + q4 * q4); // normalise quaternion + Quaternion[0] = q1 * norm; + Quaternion[1] = q2 * norm; + Quaternion[2] = q3 * norm; + Quaternion[3] = q4 * norm; + } + + float ParseAccelerometerData(short data) + { + return data / 1024.0f; //((float)data / 32768) * 16.0f; + } + + float ParseGyroscopeData(short data) + { + return data / (262.4f * 2); //((float)data / 32768) * 2000 * ((float)Math.PI / 180); + } + unsafe float invSqrt(float x) + { + float halfx = 0.5f * x; + float y = x; + long i = *(long*)&y; + i = 0x5f3759df - (i >> 1); + y = *(float*)&i; + y = y * (1.5f - (halfx * y * y)); + return y; + } + + /// + /// Algorithm IMU update method. Requires only gyroscope and accelerometer data. + /// + /// + /// Gyroscope x axis measurement in radians/s. + /// + /// + /// Gyroscope y axis measurement in radians/s. + /// + /// + /// Gyroscope z axis measurement in radians/s. + /// + /// + /// Accelerometer x axis measurement in any calibrated units. + /// + /// + /// Accelerometer y axis measurement in any calibrated units. + /// + /// + /// Accelerometer z axis measurement in any calibrated units. + /// + /// + /// Optimised for minimal arithmetic. + /// Total ±: 45 + /// Total *: 85 + /// Total /: 3 + /// Total sqrt: 3 + /// + public void Update(float gx, float gy, float gz, float ax, float ay, float az) + { + float q0 = Quaternion[0], q1 = Quaternion[1], q2 = Quaternion[2], q3 = Quaternion[3]; + float recipNorm; + float s0, s1, s2, s3; + float qDot1, qDot2, qDot3, qDot4; + float _2q0, _2q1, _2q2, _2q3, _4q0, _4q1, _4q2, _8q1, _8q2, q0q0, q1q1, q2q2, q3q3; + + // Rate of change of quaternion from gyroscope + qDot1 = 0.5f * (-q1 * gx - q2 * gy - q3 * gz); + qDot2 = 0.5f * (q0 * gx + q2 * gz - q3 * gy); + qDot3 = 0.5f * (q0 * gy - q1 * gz + q3 * gx); + qDot4 = 0.5f * (q0 * gz + q1 * gy - q2 * gx); + + // Compute feedback only if accelerometer measurement valid (avoids NaN in accelerometer normalisation) + if (!((ax == 0.0f) && (ay == 0.0f) && (az == 0.0f))) + { + + // Normalise accelerometer measurement + recipNorm = invSqrt(ax * ax + ay * ay + az * az); + ax *= recipNorm; + ay *= recipNorm; + az *= recipNorm; + + // Auxiliary variables to avoid repeated arithmetic + _2q0 = 2.0f * q0; + _2q1 = 2.0f * q1; + _2q2 = 2.0f * q2; + _2q3 = 2.0f * q3; + _4q0 = 4.0f * q0; + _4q1 = 4.0f * q1; + _4q2 = 4.0f * q2; + _8q1 = 8.0f * q1; + _8q2 = 8.0f * q2; + q0q0 = q0 * q0; + q1q1 = q1 * q1; + q2q2 = q2 * q2; + q3q3 = q3 * q3; + + // Gradient decent algorithm corrective step + s0 = _4q0 * q2q2 + _2q2 * ax + _4q0 * q1q1 - _2q1 * ay; + s1 = _4q1 * q3q3 - _2q3 * ax + 4.0f * q0q0 * q1 - _2q0 * ay - _4q1 + _8q1 * q1q1 + _8q1 * q2q2 + _4q1 * az; + s2 = 4.0f * q0q0 * q2 + _2q0 * ax + _4q2 * q3q3 - _2q3 * ay - _4q2 + _8q2 * q1q1 + _8q2 * q2q2 + _4q2 * az; + s3 = 4.0f * q1q1 * q3 - _2q1 * ax + 4.0f * q2q2 * q3 - _2q2 * ay; + recipNorm = invSqrt(s0 * s0 + s1 * s1 + s2 * s2 + s3 * s3); // normalise step magnitude + s0 *= recipNorm; + s1 *= recipNorm; + s2 *= recipNorm; + s3 *= recipNorm; + + // Apply feedback step + qDot1 -= Beta * s0; + qDot2 -= Beta * s1; + qDot3 -= Beta * s2; + qDot4 -= Beta * s3; + } + + // Integrate rate of change of quaternion to yield quaternion + q0 += qDot1 * (1.0f / SamplePeriod); + q1 += qDot2 * (1.0f / SamplePeriod); + q2 += qDot3 * (1.0f / SamplePeriod); + q3 += qDot4 * (1.0f / SamplePeriod); + + // Normalise quaternion + recipNorm = invSqrt(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3); + q0 *= recipNorm; + q1 *= recipNorm; + q2 *= recipNorm; + q3 *= recipNorm; + + Quaternion[0] = q0; + Quaternion[1] = q1; + Quaternion[2] = q2; + Quaternion[3] = q3; + } + } +} \ No newline at end of file diff --git a/PSVRToolbox/Classes/Settings.cs b/PSVRToolbox/Classes/Settings.cs index f8a2804..adf5a2e 100644 --- a/PSVRToolbox/Classes/Settings.cs +++ b/PSVRToolbox/Classes/Settings.cs @@ -70,6 +70,7 @@ public static void SaveSettings() public byte ScreenDistance { get; set; } = 0x32; public byte Brightness { get; set; } = 0x20; public byte MicVol { get; set; } = 0; + public bool UseLibUSB { get; set; } } } diff --git a/PSVRToolbox/Classes/Utils.cs b/PSVRToolbox/Classes/Utils.cs index cffdcf0..9639d94 100644 --- a/PSVRToolbox/Classes/Utils.cs +++ b/PSVRToolbox/Classes/Utils.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.Win32; @@ -63,4 +64,25 @@ public static bool DisableStartup() #endregion } + + public static class HiResDateTime + { + private static long lastTimeStamp = DateTime.UtcNow.Ticks; + public static long UtcNowTicks + { + get + { + long orig, newval; + do + { + orig = lastTimeStamp; + long now = DateTime.UtcNow.Ticks; + newval = Math.Max(now, orig + 1); + } while (Interlocked.CompareExchange + (ref lastTimeStamp, newval, orig) != orig); + + return newval; + } + } + } } diff --git a/PSVRToolbox/Forms/MainForm.cs b/PSVRToolbox/Forms/MainForm.cs index 2389ec3..334b830 100644 --- a/PSVRToolbox/Forms/MainForm.cs +++ b/PSVRToolbox/Forms/MainForm.cs @@ -4,6 +4,8 @@ using System.Data; using System.Drawing; using System.Linq; +using System.Numerics; +using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -21,17 +23,17 @@ public partial class MainForm : Form IKeyboardMouseEvents hookedEvents; PSVR vrSet; SensorBroadcaster broadcaster; - OpenTrackSender sender; + object locker = new object(); public MainForm() { InitializeComponent(); - + hookedEvents = Hook.GlobalEvents(); hookedEvents.KeyDown += HookedEvents_KeyDown; } - + #region Button handlers private void button1_Click(object sender, EventArgs e) @@ -269,7 +271,7 @@ private void detectTimer_Tick(object sender, EventArgs e) try { detectTimer.Enabled = false; - vrSet = new PSVR(); + vrSet = new PSVR(Settings.Instance.UseLibUSB); vrSet.SensorDataUpdate += VrSet_SensorDataUpdate; vrSet.Removed += VrSet_Removed; vrSet.SendCommand(PSVRCommand.GetHeadsetOn()); @@ -300,9 +302,10 @@ private void VrSet_Removed(object sender, EventArgs e) detectTimer.Enabled = true; })); } - + private void VrSet_SensorDataUpdate(object sender, PSVRSensorEventArgs e) { + lock (locker) { if (broadcaster != null) @@ -310,8 +313,7 @@ private void VrSet_SensorDataUpdate(object sender, PSVRSensorEventArgs e) } } - #endregion - + #endregion } } diff --git a/PSVRToolbox/Forms/SettingsForm.Designer.cs b/PSVRToolbox/Forms/SettingsForm.Designer.cs index 29d7da4..abfa839 100644 --- a/PSVRToolbox/Forms/SettingsForm.Designer.cs +++ b/PSVRToolbox/Forms/SettingsForm.Designer.cs @@ -59,13 +59,11 @@ private void InitializeComponent() this.chkStartup = new System.Windows.Forms.CheckBox(); this.button1 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); - this.groupBox4 = new System.Windows.Forms.GroupBox(); - this.txtOTPort = new System.Windows.Forms.TextBox(); - this.chkOpenTrack = new System.Windows.Forms.CheckBox(); + this.label11 = new System.Windows.Forms.Label(); + this.cbDriver = new System.Windows.Forms.ComboBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); - this.groupBox4.SuspendLayout(); this.SuspendLayout(); // // groupBox1 @@ -320,11 +318,13 @@ private void InitializeComponent() // // groupBox3 // + this.groupBox3.Controls.Add(this.cbDriver); + this.groupBox3.Controls.Add(this.label11); this.groupBox3.Controls.Add(this.chkMinimized); this.groupBox3.Controls.Add(this.chkStartup); - this.groupBox3.Location = new System.Drawing.Point(254, 168); + this.groupBox3.Location = new System.Drawing.Point(254, 124); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Size = new System.Drawing.Size(216, 44); + this.groupBox3.Size = new System.Drawing.Size(216, 100); this.groupBox3.TabIndex = 3; this.groupBox3.TabStop = false; this.groupBox3.Text = "Miscellaneous settings"; @@ -369,40 +369,32 @@ private void InitializeComponent() this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // - // groupBox4 + // label11 // - this.groupBox4.Controls.Add(this.txtOTPort); - this.groupBox4.Controls.Add(this.chkOpenTrack); - this.groupBox4.Location = new System.Drawing.Point(254, 124); - this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(216, 38); - this.groupBox4.TabIndex = 6; - this.groupBox4.TabStop = false; - this.groupBox4.Text = "OpenTrack sender"; + this.label11.AutoSize = true; + this.label11.Location = new System.Drawing.Point(6, 47); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(58, 13); + this.label11.TabIndex = 4; + this.label11.Text = "Driver type"; // - // txtOTPort + // cbDriver // - this.txtOTPort.Location = new System.Drawing.Point(141, 18); - this.txtOTPort.Name = "txtOTPort"; - this.txtOTPort.Size = new System.Drawing.Size(64, 20); - this.txtOTPort.TabIndex = 6; - // - // chkOpenTrack - // - this.chkOpenTrack.AutoSize = true; - this.chkOpenTrack.Location = new System.Drawing.Point(6, 18); - this.chkOpenTrack.Name = "chkOpenTrack"; - this.chkOpenTrack.Size = new System.Drawing.Size(116, 17); - this.chkOpenTrack.TabIndex = 1; - this.chkOpenTrack.Text = "Enable OpenTrack"; - this.chkOpenTrack.UseVisualStyleBackColor = true; + this.cbDriver.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cbDriver.FormattingEnabled = true; + this.cbDriver.Items.AddRange(new object[] { + "WinUSB", + "LibUSB"}); + this.cbDriver.Location = new System.Drawing.Point(6, 66); + this.cbDriver.Name = "cbDriver"; + this.cbDriver.Size = new System.Drawing.Size(201, 21); + this.cbDriver.TabIndex = 5; // // SettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(485, 263); - this.Controls.Add(this.groupBox4); this.Controls.Add(this.button2); this.Controls.Add(this.button1); this.Controls.Add(this.groupBox3); @@ -422,8 +414,6 @@ private void InitializeComponent() this.groupBox2.PerformLayout(); this.groupBox3.ResumeLayout(false); this.groupBox3.PerformLayout(); - this.groupBox4.ResumeLayout(false); - this.groupBox4.PerformLayout(); this.ResumeLayout(false); } @@ -460,8 +450,7 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox cbHeadsetOff; private System.Windows.Forms.TextBox txtBroadcastPort; private System.Windows.Forms.Label label10; - private System.Windows.Forms.GroupBox groupBox4; - private System.Windows.Forms.TextBox txtOTPort; - private System.Windows.Forms.CheckBox chkOpenTrack; + private System.Windows.Forms.ComboBox cbDriver; + private System.Windows.Forms.Label label11; } } \ No newline at end of file diff --git a/PSVRToolbox/Forms/SettingsForm.cs b/PSVRToolbox/Forms/SettingsForm.cs index 4fe21ac..3304260 100644 --- a/PSVRToolbox/Forms/SettingsForm.cs +++ b/PSVRToolbox/Forms/SettingsForm.cs @@ -29,11 +29,9 @@ private void SettingsForm_Load(object sender, EventArgs e) chkMinimized.Checked = set.StartMinimized; chkShift.Checked = set.ShiftModifier; chkStartup.Checked = Utils.IsStartupEnabled(); - chkOpenTrack.Checked = set.EnableOpenTrackSender; txtBroadcastAddress.Text = set.UDPBroadcastAddress; txtBroadcastPort.Text = set.UDPBroadcastPort.ToString(); - txtOTPort.Text = set.OpenTrackPort.ToString(); string[] keyNames = Enum.GetNames(typeof(Keys)).OrderBy(s => s).ToArray(); @@ -52,7 +50,7 @@ private void SettingsForm_Load(object sender, EventArgs e) cbTheater.SelectedItem = set.EnableTheater.ToString(); cbTracking.SelectedItem = set.EnableVRAndTracking.ToString(); cbVR.SelectedItem = set.EnableVR.ToString(); - + cbDriver.SelectedIndex = set.UseLibUSB ? 1 : 0; } private void button2_Click(object sender, EventArgs e) @@ -80,18 +78,10 @@ private void button2_Click(object sender, EventArgs e) } int portOT; - - if (!int.TryParse(txtOTPort.Text, out portOT)) - { - MessageBox.Show("Invalid OpenTrack port"); - return; - } - + var set = new Settings(); set.UDPBroadcastPort = port; - set.OpenTrackPort = portOT; - set.EnableOpenTrackSender = chkOpenTrack.Checked; set.AltModifier = chkAlt.Checked; set.EnableUDPBroadcast = chkBroadcast.Checked; set.ControlModifier = chkControl.Checked; @@ -112,6 +102,7 @@ private void button2_Click(object sender, EventArgs e) set.EnableVRAndTracking = (Keys)Enum.Parse(typeof(Keys), cbTracking.SelectedItem.ToString()); set.EnableVR = (Keys)Enum.Parse(typeof(Keys), cbVR.SelectedItem.ToString()); + set.UseLibUSB = cbDriver.SelectedIndex == 1; Settings.Instance = set; Settings.SaveSettings(); diff --git a/PSVRToolbox/PSVRToolbox.csproj b/PSVRToolbox/PSVRToolbox.csproj index f8c2f27..6852431 100644 --- a/PSVRToolbox/PSVRToolbox.csproj +++ b/PSVRToolbox/PSVRToolbox.csproj @@ -22,6 +22,8 @@ DEBUG;TRACE prompt 4 + true + false AnyCPU @@ -50,6 +52,10 @@ + + ..\packages\System.Numerics.Vectors.4.1.1\lib\portable-net45+win8+wp8+wpa81\System.Numerics.Vectors.dll + True + @@ -61,6 +67,8 @@ + + Form diff --git a/PSVRToolbox/packages.config b/PSVRToolbox/packages.config index cf3adf8..1ba315f 100644 --- a/PSVRToolbox/packages.config +++ b/PSVRToolbox/packages.config @@ -3,4 +3,5 @@ + \ No newline at end of file diff --git a/VRVideoPlayer/VRPlayer.h b/VRVideoPlayer/VRPlayer.h index 268e667..2d75835 100644 --- a/VRVideoPlayer/VRPlayer.h +++ b/VRVideoPlayer/VRPlayer.h @@ -46,6 +46,11 @@ namespace VRVideoPlayer { return true; } + void RotateMesh(float quat[]) + { + extRotate(quat); + } + property String^ FileName { String^ get() diff --git a/VRVideoPlayer/VRVideoPlayer.vcxproj b/VRVideoPlayer/VRVideoPlayer.vcxproj index b98f33a..51d2f33 100644 --- a/VRVideoPlayer/VRVideoPlayer.vcxproj +++ b/VRVideoPlayer/VRVideoPlayer.vcxproj @@ -164,268 +164,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -462,123 +200,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false false @@ -661,714 +282,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/VRVideoPlayer/VRVideoPlayer.vcxproj.filters b/VRVideoPlayer/VRVideoPlayer.vcxproj.filters index e73545f..825f7f4 100644 --- a/VRVideoPlayer/VRVideoPlayer.vcxproj.filters +++ b/VRVideoPlayer/VRVideoPlayer.vcxproj.filters @@ -51,2150 +51,37 @@ Archivos de código fuente\vlc - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente\ogl - - - Archivos de código fuente\ogl - - - Archivos de código fuente\ogl - - - Archivos de código fuente\ogl - - - Archivos de código fuente\ogl - - - Archivos de código fuente\ogl - - - Archivos de código fuente\ogl - - - Archivos de código fuente\vlc - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - - Archivos de código fuente - - + + + Archivos de código fuente - + Archivos de código fuente - - Archivos de código fuente + + Archivos de código fuente\ogl - - Archivos de código fuente + + Archivos de código fuente\ogl - - Archivos de código fuente + + Archivos de código fuente\ogl - - Archivos de código fuente + + Archivos de código fuente\ogl - - Archivos de código fuente + + Archivos de código fuente\ogl - - Archivos de código fuente + + Archivos de código fuente\ogl - - Archivos de código fuente + + Archivos de código fuente\ogl - - Archivos de código fuente + + Archivos de código fuente\vlc - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - Archivos de encabezado - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/VRVideoPlayer/external/glm/glm/detail/dummy.cpp b/VRVideoPlayer/external/glm/glm/detail/dummy.cpp index a519a6d..f9d198c 100644 --- a/VRVideoPlayer/external/glm/glm/detail/dummy.cpp +++ b/VRVideoPlayer/external/glm/glm/detail/dummy.cpp @@ -3,7 +3,7 @@ /// /// GLM is a header only library. There is nothing to compile. /// dummy.cpp exist only a wordaround for CMake file. - +#include "stdafx.h" /* #define GLM_MESSAGES #include diff --git a/VRVideoPlayer/external/glm/glm/detail/glm.cpp b/VRVideoPlayer/external/glm/glm/detail/glm.cpp index da3be4e..4915b44 100644 --- a/VRVideoPlayer/external/glm/glm/detail/glm.cpp +++ b/VRVideoPlayer/external/glm/glm/detail/glm.cpp @@ -1,6 +1,6 @@ /// @ref core /// @file glm/glm.cpp - +#include "stdafx.h" #include #include #include diff --git a/VRVideoPlayer/external/glm/test/CMakeLists.txt b/VRVideoPlayer/external/glm/test/CMakeLists.txt deleted file mode 100644 index 2d216c8..0000000 --- a/VRVideoPlayer/external/glm/test/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -function(glmCreateTestGTC NAME) - if(GLM_TEST_ENABLE) - set(SAMPLE_NAME test-${NAME}) - add_executable(${SAMPLE_NAME} ${NAME}.cpp) - - add_test( - NAME ${SAMPLE_NAME} - COMMAND $ ) - endif(GLM_TEST_ENABLE) -endfunction() - -add_subdirectory(bug) -add_subdirectory(core) -add_subdirectory(gtc) -add_subdirectory(gtx) - - diff --git a/VRVideoPlayer/external/glm/test/bug/CMakeLists.txt b/VRVideoPlayer/external/glm/test/bug/CMakeLists.txt deleted file mode 100644 index 26e8569..0000000 --- a/VRVideoPlayer/external/glm/test/bug/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -glmCreateTestGTC(bug_ms_vec_static) diff --git a/VRVideoPlayer/external/glm/test/bug/bug_ms_vec_static.cpp b/VRVideoPlayer/external/glm/test/bug/bug_ms_vec_static.cpp deleted file mode 100644 index 812d97b..0000000 --- a/VRVideoPlayer/external/glm/test/bug/bug_ms_vec_static.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#define GLM_FORCE_SWIZZLE -#include - -struct Foo -{ - static glm::vec2 Bar; -}; - -glm::vec2 Foo::Bar = glm::vec2(1.f, 1.f); - -int main() -{ - return 0; -} diff --git a/VRVideoPlayer/external/glm/test/core/CMakeLists.txt b/VRVideoPlayer/external/glm/test/core/CMakeLists.txt deleted file mode 100644 index 71ab6e2..0000000 --- a/VRVideoPlayer/external/glm/test/core/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -glmCreateTestGTC(core_force_pure) -glmCreateTestGTC(core_type_aligned) -glmCreateTestGTC(core_type_cast) -glmCreateTestGTC(core_type_ctor) -glmCreateTestGTC(core_type_float) -glmCreateTestGTC(core_type_int) -glmCreateTestGTC(core_type_length) -glmCreateTestGTC(core_type_mat2x2) -glmCreateTestGTC(core_type_mat2x3) -glmCreateTestGTC(core_type_mat2x4) -glmCreateTestGTC(core_type_mat3x2) -glmCreateTestGTC(core_type_mat3x3) -glmCreateTestGTC(core_type_mat3x4) -glmCreateTestGTC(core_type_mat4x2) -glmCreateTestGTC(core_type_mat4x3) -glmCreateTestGTC(core_type_mat4x4) -glmCreateTestGTC(core_type_vec1) -glmCreateTestGTC(core_type_vec2) -glmCreateTestGTC(core_type_vec3) -glmCreateTestGTC(core_type_vec4) -glmCreateTestGTC(core_func_common) -glmCreateTestGTC(core_func_exponential) -glmCreateTestGTC(core_func_geometric) -glmCreateTestGTC(core_func_integer) -glmCreateTestGTC(core_func_integer_bit_count) -glmCreateTestGTC(core_func_integer_find_lsb) -glmCreateTestGTC(core_func_integer_find_msb) -glmCreateTestGTC(core_func_matrix) -glmCreateTestGTC(core_func_noise) -glmCreateTestGTC(core_func_packing) -glmCreateTestGTC(core_func_trigonometric) -glmCreateTestGTC(core_func_vector_relational) -glmCreateTestGTC(core_func_swizzle) -glmCreateTestGTC(core_setup_force_cxx98) -glmCreateTestGTC(core_setup_message) -glmCreateTestGTC(core_setup_precision) - - - diff --git a/VRVideoPlayer/external/glm/test/core/core_force_pure.cpp b/VRVideoPlayer/external/glm/test/core/core_force_pure.cpp deleted file mode 100644 index 68f8211..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_force_pure.cpp +++ /dev/null @@ -1,421 +0,0 @@ -#define GLM_FORCE_PURE -#define GLM_FORCE_ALIGNED -#define GLM_FORCE_SWIZZLE -#include -#include -#include -#include -#include -#include -#include - -int test_vec4_ctor() -{ - int Error = 0; - - { - glm::ivec4 A(1, 2, 3, 4); - glm::ivec4 B(A); - Error += glm::all(glm::equal(A, B)) ? 0 : 1; - } - -# if GLM_HAS_TRIVIAL_QUERIES - // Error += std::is_trivially_default_constructible::value ? 0 : 1; - // Error += std::is_trivially_copy_assignable::value ? 0 : 1; - Error += std::is_trivially_copyable::value ? 0 : 1; - Error += std::is_trivially_copyable::value ? 0 : 1; - Error += std::is_trivially_copyable::value ? 0 : 1; - Error += std::is_trivially_copyable::value ? 0 : 1; - - Error += std::is_copy_constructible::value ? 0 : 1; -# endif - -#if GLM_HAS_INITIALIZER_LISTS - { - glm::vec4 a{ 0, 1, 2, 3 }; - std::vector v = { - {0, 1, 2, 3}, - {4, 5, 6, 7}, - {8, 9, 0, 1}}; - } - - { - glm::dvec4 a{ 0, 1, 2, 3 }; - std::vector v = { - {0, 1, 2, 3}, - {4, 5, 6, 7}, - {8, 9, 0, 1}}; - } -#endif - -#if GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_FORCE_SWIZZLE) - { - glm::vec4 A = glm::vec4(1.0f, 2.0f, 3.0f, 4.0f); - glm::vec4 B = A.xyzw; - glm::vec4 C(A.xyzw); - glm::vec4 D(A.xyzw()); - glm::vec4 E(A.x, A.yzw); - glm::vec4 F(A.x, A.yzw()); - glm::vec4 G(A.xyz, A.w); - glm::vec4 H(A.xyz(), A.w); - glm::vec4 I(A.xy, A.zw); - glm::vec4 J(A.xy(), A.zw()); - glm::vec4 K(A.x, A.y, A.zw); - glm::vec4 L(A.x, A.yz, A.w); - glm::vec4 M(A.xy, A.z, A.w); - - Error += glm::all(glm::equal(A, B)) ? 0 : 1; - Error += glm::all(glm::equal(A, C)) ? 0 : 1; - Error += glm::all(glm::equal(A, D)) ? 0 : 1; - Error += glm::all(glm::equal(A, E)) ? 0 : 1; - Error += glm::all(glm::equal(A, F)) ? 0 : 1; - Error += glm::all(glm::equal(A, G)) ? 0 : 1; - Error += glm::all(glm::equal(A, H)) ? 0 : 1; - Error += glm::all(glm::equal(A, I)) ? 0 : 1; - Error += glm::all(glm::equal(A, J)) ? 0 : 1; - Error += glm::all(glm::equal(A, K)) ? 0 : 1; - Error += glm::all(glm::equal(A, L)) ? 0 : 1; - Error += glm::all(glm::equal(A, M)) ? 0 : 1; - } -#endif// GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_FORCE_SWIZZLE) - - { - glm::vec4 A(1); - glm::vec4 B(1, 1, 1, 1); - - Error += A == B ? 0 : 1; - } - - { - std::vector Tests; - Tests.push_back(glm::vec4(glm::vec2(1, 2), 3, 4)); - Tests.push_back(glm::vec4(1, glm::vec2(2, 3), 4)); - Tests.push_back(glm::vec4(1, 2, glm::vec2(3, 4))); - Tests.push_back(glm::vec4(glm::vec3(1, 2, 3), 4)); - Tests.push_back(glm::vec4(1, glm::vec3(2, 3, 4))); - Tests.push_back(glm::vec4(glm::vec2(1, 2), glm::vec2(3, 4))); - Tests.push_back(glm::vec4(1, 2, 3, 4)); - Tests.push_back(glm::vec4(glm::vec4(1, 2, 3, 4))); - - for(std::size_t i = 0; i < Tests.size(); ++i) - Error += Tests[i] == glm::vec4(1, 2, 3, 4) ? 0 : 1; - } - - return Error; -} - -int test_bvec4_ctor() -{ - int Error = 0; - - glm::bvec4 const A(true); - glm::bvec4 const B(true); - glm::bvec4 const C(false); - glm::bvec4 const D = A && B; - glm::bvec4 const E = A && C; - glm::bvec4 const F = A || C; - bool const G = A == C; - bool const H = A != C; - - Error += D == glm::bvec4(true) ? 0 : 1; - Error += E == glm::bvec4(false) ? 0 : 1; - Error += F == glm::bvec4(true) ? 0 : 1; - - return Error; -} - -int test_vec4_operators() -{ - int Error = 0; - - { - glm::vec4 A(1.0f); - glm::vec4 B(1.0f); - bool R = A != B; - bool S = A == B; - - Error += (S && !R) ? 0 : 1; - } - - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f); - - glm::vec4 C = A + B; - Error += C == glm::vec4(5, 7, 9, 11) ? 0 : 1; - - glm::vec4 D = B - A; - Error += D == glm::vec4(3, 3, 3, 3) ? 0 : 1; - - glm::vec4 E = A * B; - Error += E == glm::vec4(4, 10, 18, 28) ? 0 : 1; - - glm::vec4 F = B / A; - Error += F == glm::vec4(4, 2.5, 2, 7.0f / 4.0f) ? 0 : 1; - - glm::vec4 G = A + 1.0f; - Error += G == glm::vec4(2, 3, 4, 5) ? 0 : 1; - - glm::vec4 H = B - 1.0f; - Error += H == glm::vec4(3, 4, 5, 6) ? 0 : 1; - - glm::vec4 I = A * 2.0f; - Error += I == glm::vec4(2, 4, 6, 8) ? 0 : 1; - - glm::vec4 J = B / 2.0f; - Error += J == glm::vec4(2, 2.5, 3, 3.5) ? 0 : 1; - - glm::vec4 K = 1.0f + A; - Error += K == glm::vec4(2, 3, 4, 5) ? 0 : 1; - - glm::vec4 L = 1.0f - B; - Error += L == glm::vec4(-3, -4, -5, -6) ? 0 : 1; - - glm::vec4 M = 2.0f * A; - Error += M == glm::vec4(2, 4, 6, 8) ? 0 : 1; - - glm::vec4 N = 2.0f / B; - Error += N == glm::vec4(0.5, 2.0 / 5.0, 2.0 / 6.0, 2.0 / 7.0) ? 0 : 1; - } - - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f); - - A += B; - Error += A == glm::vec4(5, 7, 9, 11) ? 0 : 1; - - A += 1.0f; - Error += A == glm::vec4(6, 8, 10, 12) ? 0 : 1; - } - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f); - - B -= A; - Error += B == glm::vec4(3, 3, 3, 3) ? 0 : 1; - - B -= 1.0f; - Error += B == glm::vec4(2, 2, 2, 2) ? 0 : 1; - } - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f); - - A *= B; - Error += A == glm::vec4(4, 10, 18, 28) ? 0 : 1; - - A *= 2.0f; - Error += A == glm::vec4(8, 20, 36, 56) ? 0 : 1; - } - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::vec4 B(4.0f, 5.0f, 6.0f, 7.0f); - - B /= A; - Error += B == glm::vec4(4, 2.5, 2, 7.0f / 4.0f) ? 0 : 1; - - B /= 2.0f; - Error += B == glm::vec4(2, 1.25, 1, 7.0f / 4.0f / 2.0f) ? 0 : 1; - } - { - glm::vec4 B(2.0f); - - B /= B.y; - Error += B == glm::vec4(1.0f) ? 0 : 1; - } - - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::vec4 B = -A; - Error += B == glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f) ? 0 : 1; - } - - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::vec4 B = --A; - Error += B == glm::vec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1; - } - - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::vec4 B = A--; - Error += B == glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) ? 0 : 1; - Error += A == glm::vec4(0.0f, 1.0f, 2.0f, 3.0f) ? 0 : 1; - } - - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::vec4 B = ++A; - Error += B == glm::vec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1; - } - - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::vec4 B = A++; - Error += B == glm::vec4(1.0f, 2.0f, 3.0f, 4.0f) ? 0 : 1; - Error += A == glm::vec4(2.0f, 3.0f, 4.0f, 5.0f) ? 0 : 1; - } - - return Error; -} - -int test_vec4_equal() -{ - int Error = 0; - - { - glm::vec4 const A(1, 2, 3, 4); - glm::vec4 const B(1, 2, 3, 4); - Error += A == B ? 0 : 1; - Error += A != B ? 1 : 0; - } - - { - glm::ivec4 const A(1, 2, 3, 4); - glm::ivec4 const B(1, 2, 3, 4); - Error += A == B ? 0 : 1; - Error += A != B ? 1 : 0; - } - - return Error; -} - -int test_vec4_size() -{ - int Error = 0; - - Error += sizeof(glm::vec4) == sizeof(glm::lowp_vec4) ? 0 : 1; - Error += sizeof(glm::vec4) == sizeof(glm::mediump_vec4) ? 0 : 1; - Error += sizeof(glm::vec4) == sizeof(glm::highp_vec4) ? 0 : 1; - Error += 16 == sizeof(glm::mediump_vec4) ? 0 : 1; - Error += sizeof(glm::dvec4) == sizeof(glm::lowp_dvec4) ? 0 : 1; - Error += sizeof(glm::dvec4) == sizeof(glm::mediump_dvec4) ? 0 : 1; - Error += sizeof(glm::dvec4) == sizeof(glm::highp_dvec4) ? 0 : 1; - Error += 32 == sizeof(glm::highp_dvec4) ? 0 : 1; - Error += glm::vec4().length() == 4 ? 0 : 1; - Error += glm::dvec4().length() == 4 ? 0 : 1; - - return Error; -} - -int test_vec4_swizzle_partial() -{ - int Error = 0; - - glm::vec4 A(1, 2, 3, 4); - -# if GLM_HAS_UNRESTRICTED_UNIONS && defined(GLM_SWIZZLE_RELAX) - { - glm::vec4 B(A.xy, A.zw); - Error += A == B ? 0 : 1; - } - { - glm::vec4 B(A.xy, 3.0f, 4.0f); - Error += A == B ? 0 : 1; - } - { - glm::vec4 B(1.0f, A.yz, 4.0f); - Error += A == B ? 0 : 1; - } - { - glm::vec4 B(1.0f, 2.0f, A.zw); - Error += A == B ? 0 : 1; - } - - { - glm::vec4 B(A.xyz, 4.0f); - Error += A == B ? 0 : 1; - } - { - glm::vec4 B(1.0f, A.yzw); - Error += A == B ? 0 : 1; - } -# endif - - return Error; -} - -int test_operator_increment() -{ - int Error(0); - - glm::ivec4 v0(1); - glm::ivec4 v1(v0); - glm::ivec4 v2(v0); - glm::ivec4 v3 = ++v1; - glm::ivec4 v4 = v2++; - - Error += glm::all(glm::equal(v0, v4)) ? 0 : 1; - Error += glm::all(glm::equal(v1, v2)) ? 0 : 1; - Error += glm::all(glm::equal(v1, v3)) ? 0 : 1; - - int i0(1); - int i1(i0); - int i2(i0); - int i3 = ++i1; - int i4 = i2++; - - Error += i0 == i4 ? 0 : 1; - Error += i1 == i2 ? 0 : 1; - Error += i1 == i3 ? 0 : 1; - - return Error; -} - -namespace heap -{ - class A - { - float f; - }; - - class B : public A - { - float g; - glm::vec4 v; - }; - - int test() - { - int Error(0); - - A* p = new B; - delete p; - - return Error; - } -}//namespace heap - -int test_vec4_simd() -{ - int Error = 0; - - glm::vec4 const a(std::clock(), std::clock(), std::clock(), std::clock()); - glm::vec4 const b(std::clock(), std::clock(), std::clock(), std::clock()); - - glm::vec4 const c(b * a); - glm::vec4 const d(a + c); - - Error += glm::all(glm::greaterThanEqual(d, glm::vec4(0))) ? 0 : 1; - - return Error; -} - -int main() -{ - int Error(0); - - Error += test_vec4_ctor(); - Error += test_bvec4_ctor(); - Error += test_vec4_size(); - Error += test_vec4_operators(); - Error += test_vec4_equal(); - Error += test_vec4_swizzle_partial(); - Error += test_vec4_simd(); - Error += test_operator_increment(); - Error += heap::test(); - - return Error; -} - diff --git a/VRVideoPlayer/external/glm/test/core/core_func_common.cpp b/VRVideoPlayer/external/glm/test/core/core_func_common.cpp deleted file mode 100644 index 6ff3c39..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_func_common.cpp +++ /dev/null @@ -1,1272 +0,0 @@ -#define GLM_FORCE_EXPLICIT_CTOR -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace floor_ -{ - int test() - { - int Error(0); - - { - float A(1.1f); - float B = glm::floor(A); - } - - { - double A(1.1f); - double B = glm::floor(A); - } - - { - glm::vec1 A(1.1f); - glm::vec1 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::vec1(1.0), 0.0001f)) ? 0 : 1; - } - - { - glm::dvec1 A(1.1f); - glm::dvec1 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::dvec1(1.0), 0.0001)) ? 0 : 1; - } - - { - glm::vec2 A(1.1f); - glm::vec2 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::vec2(1.0), 0.0001f)) ? 0 : 1; - } - - { - glm::dvec2 A(1.1f); - glm::dvec2 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::dvec2(1.0), 0.0001)) ? 0 : 1; - } - - { - glm::vec3 A(1.1f); - glm::vec3 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::vec3(1.0), 0.0001f)) ? 0 : 1; - } - - { - glm::dvec3 A(1.1f); - glm::dvec3 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::dvec3(1.0), 0.0001)) ? 0 : 1; - } - - { - glm::vec4 A(1.1f); - glm::vec4 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::vec4(1.0), 0.0001f)) ? 0 : 1; - } - - { - glm::dvec4 A(1.1f); - glm::dvec4 B = glm::floor(A); - - Error += glm::all(glm::epsilonEqual(B, glm::dvec4(1.0), 0.0001)) ? 0 : 1; - } - - return Error; - } -}//namespace floor - -namespace modf_ -{ - int test() - { - int Error(0); - - { - float X(1.5f); - float I(0.0f); - float A = glm::modf(X, I); - - Error += I == 1.0f ? 0 : 1; - Error += A == 0.5f ? 0 : 1; - } - - { - glm::vec4 X(1.1f, 1.2f, 1.5f, 1.7f); - glm::vec4 I(0.0f); - glm::vec4 A = glm::modf(X, I); - - Error += I == glm::vec4(1.0f) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(A, glm::vec4(0.1f, 0.2f, 0.5f, 0.7f), 0.00001f)) ? 0 : 1; - } - - { - glm::dvec4 X(1.1, 1.2, 1.5, 1.7); - glm::dvec4 I(0.0); - glm::dvec4 A = glm::modf(X, I); - - Error += I == glm::dvec4(1.0) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(A, glm::dvec4(0.1, 0.2, 0.5, 0.7), 0.000000001)) ? 0 : 1; - } - - { - double X(1.5); - double I(0.0); - double A = glm::modf(X, I); - - Error += I == 1.0 ? 0 : 1; - Error += A == 0.5 ? 0 : 1; - } - - return Error; - } -}//namespace modf - -namespace mod_ -{ - int test() - { - int Error(0); - - { - float A(1.5f); - float B(1.0f); - float C = glm::mod(A, B); - - Error += glm::abs(C - 0.5f) < 0.00001f ? 0 : 1; - } - - { - float A(-0.2f); - float B(1.0f); - float C = glm::mod(A, B); - - Error += glm::abs(C - 0.8f) < 0.00001f ? 0 : 1; - } - - { - float A(3.0); - float B(2.0f); - float C = glm::mod(A, B); - - Error += glm::abs(C - 1.0f) < 0.00001f ? 0 : 1; - } - - { - glm::vec4 A(3.0); - float B(2.0f); - glm::vec4 C = glm::mod(A, B); - - Error += glm::all(glm::epsilonEqual(C, glm::vec4(1.0f), 0.00001f)) ? 0 : 1; - } - - { - glm::vec4 A(3.0); - glm::vec4 B(2.0f); - glm::vec4 C = glm::mod(A, B); - - Error += glm::all(glm::epsilonEqual(C, glm::vec4(1.0f), 0.00001f)) ? 0 : 1; - } - - return Error; - } -}//namespace mod_ - -namespace floatBitsToInt -{ - int test() - { - int Error = 0; - - { - float A = 1.0f; - int B = glm::floatBitsToInt(A); - float C = glm::intBitsToFloat(B); - int D = *(int*)&A; - Error += B == D ? 0 : 1; - Error += A == C ? 0 : 1; - } - - { - glm::vec2 A(1.0f, 2.0f); - glm::ivec2 B = glm::floatBitsToInt(A); - glm::vec2 C = glm::intBitsToFloat(B); - Error += B.x == *(int*)&(A.x) ? 0 : 1; - Error += B.y == *(int*)&(A.y) ? 0 : 1; - Error += A == C? 0 : 1; - } - - { - glm::vec3 A(1.0f, 2.0f, 3.0f); - glm::ivec3 B = glm::floatBitsToInt(A); - glm::vec3 C = glm::intBitsToFloat(B); - Error += B.x == *(int*)&(A.x) ? 0 : 1; - Error += B.y == *(int*)&(A.y) ? 0 : 1; - Error += B.z == *(int*)&(A.z) ? 0 : 1; - Error += A == C? 0 : 1; - } - - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::ivec4 B = glm::floatBitsToInt(A); - glm::vec4 C = glm::intBitsToFloat(B); - Error += B.x == *(int*)&(A.x) ? 0 : 1; - Error += B.y == *(int*)&(A.y) ? 0 : 1; - Error += B.z == *(int*)&(A.z) ? 0 : 1; - Error += B.w == *(int*)&(A.w) ? 0 : 1; - Error += A == C? 0 : 1; - } - - return Error; - } -}//namespace floatBitsToInt - -namespace floatBitsToUint -{ - int test() - { - int Error = 0; - - { - float A = 1.0f; - glm::uint B = glm::floatBitsToUint(A); - float C = glm::intBitsToFloat(B); - Error += B == *(glm::uint*)&A ? 0 : 1; - Error += A == C? 0 : 1; - } - - { - glm::vec2 A(1.0f, 2.0f); - glm::uvec2 B = glm::floatBitsToUint(A); - glm::vec2 C = glm::uintBitsToFloat(B); - Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1; - Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1; - Error += A == C ? 0 : 1; - } - - { - glm::vec3 A(1.0f, 2.0f, 3.0f); - glm::uvec3 B = glm::floatBitsToUint(A); - glm::vec3 C = glm::uintBitsToFloat(B); - Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1; - Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1; - Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1; - Error += A == C? 0 : 1; - } - - { - glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f); - glm::uvec4 B = glm::floatBitsToUint(A); - glm::vec4 C = glm::uintBitsToFloat(B); - Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1; - Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1; - Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1; - Error += B.w == *(glm::uint*)&(A.w) ? 0 : 1; - Error += A == C? 0 : 1; - } - - return Error; - } -}//namespace floatBitsToUint - -namespace min_ -{ - int test() - { - int Error = 0; - - glm::vec1 A0 = glm::min(glm::vec1(1), glm::vec1(1)); - - glm::vec2 B0 = glm::min(glm::vec2(1), glm::vec2(1)); - glm::vec2 B1 = glm::min(glm::vec2(1), 1.0f); - bool B2 = glm::all(glm::equal(B0, B1)); - Error += B2 ? 0 : 1; - - glm::vec3 C0 = glm::min(glm::vec3(1), glm::vec3(1)); - glm::vec3 C1 = glm::min(glm::vec3(1), 1.0f); - bool C2 = glm::all(glm::equal(C0, C1)); - Error += C2 ? 0 : 1; - - glm::vec4 D0 = glm::min(glm::vec4(1), glm::vec4(1)); - glm::vec4 D1 = glm::min(glm::vec4(1), 1.0f); - bool D2 = glm::all(glm::equal(D0, D1)); - Error += D2 ? 0 : 1; - - return Error; - } -}//namespace min_ - -namespace max_ -{ - int test() - { - int Error = 0; - - glm::vec1 A0 = glm::max(glm::vec1(1), glm::vec1(1)); - - glm::vec2 B0 = glm::max(glm::vec2(1), glm::vec2(1)); - glm::vec2 B1 = glm::max(glm::vec2(1), 1.0f); - bool B2 = glm::all(glm::equal(B0, B1)); - Error += B2 ? 0 : 1; - - glm::vec3 C0 = glm::max(glm::vec3(1), glm::vec3(1)); - glm::vec3 C1 = glm::max(glm::vec3(1), 1.0f); - bool C2 = glm::all(glm::equal(C0, C1)); - Error += C2 ? 0 : 1; - - glm::vec4 D0 = glm::max(glm::vec4(1), glm::vec4(1)); - glm::vec4 D1 = glm::max(glm::vec4(1), 1.0f); - bool D2 = glm::all(glm::equal(D0, D1)); - Error += D2 ? 0 : 1; - - return Error; - } -}//namespace max_ - -namespace clamp_ -{ - int test() - { - int Error = 0; - - return Error; - } -}//namespace clamp_ - -namespace mix_ -{ - template - struct entry - { - T x; - T y; - B a; - T Result; - }; - - entry TestBool[] = - { - {0.0f, 1.0f, false, 0.0f}, - {0.0f, 1.0f, true, 1.0f}, - {-1.0f, 1.0f, false, -1.0f}, - {-1.0f, 1.0f, true, 1.0f} - }; - - entry TestFloat[] = - { - {0.0f, 1.0f, 0.0f, 0.0f}, - {0.0f, 1.0f, 1.0f, 1.0f}, - {-1.0f, 1.0f, 0.0f, -1.0f}, - {-1.0f, 1.0f, 1.0f, 1.0f} - }; - - entry TestVec2Bool[] = - { - {glm::vec2(0.0f), glm::vec2(1.0f), false, glm::vec2(0.0f)}, - {glm::vec2(0.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)}, - {glm::vec2(-1.0f), glm::vec2(1.0f), false, glm::vec2(-1.0f)}, - {glm::vec2(-1.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)} - }; - - entry TestBVec2[] = - { - {glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(false), glm::vec2(0.0f)}, - {glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(true), glm::vec2(1.0f)}, - {glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(false), glm::vec2(-1.0f)}, - {glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(true), glm::vec2(1.0f)}, - {glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(true, false), glm::vec2(1.0f, -1.0f)} - }; - - entry TestVec3Bool[] = - { - {glm::vec3(0.0f), glm::vec3(1.0f), false, glm::vec3(0.0f)}, - {glm::vec3(0.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)}, - {glm::vec3(-1.0f), glm::vec3(1.0f), false, glm::vec3(-1.0f)}, - {glm::vec3(-1.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)} - }; - - entry TestBVec3[] = - { - {glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(false), glm::vec3(0.0f)}, - {glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(true), glm::vec3(1.0f)}, - {glm::vec3(-1.0f), glm::vec3(1.0f), glm::bvec3(false), glm::vec3(-1.0f)}, - {glm::vec3(-1.0f), glm::vec3(1.0f), glm::bvec3(true), glm::vec3(1.0f)}, - {glm::vec3(1.0f, 2.0f, 3.0f), glm::vec3(4.0f, 5.0f, 6.0f), glm::bvec3(true, false, true), glm::vec3(4.0f, 2.0f, 6.0f)} - }; - - entry TestVec4Bool[] = - { - {glm::vec4(0.0f), glm::vec4(1.0f), false, glm::vec4(0.0f)}, - {glm::vec4(0.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)}, - {glm::vec4(-1.0f), glm::vec4(1.0f), false, glm::vec4(-1.0f)}, - {glm::vec4(-1.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)} - }; - - entry TestBVec4[] = - { - {glm::vec4(0.0f, 0.0f, 1.0f, 1.0f), glm::vec4(2.0f, 2.0f, 3.0f, 3.0f), glm::bvec4(false, true, false, true), glm::vec4(0.0f, 2.0f, 1.0f, 3.0f)}, - {glm::vec4(0.0f), glm::vec4(1.0f), glm::bvec4(true), glm::vec4(1.0f)}, - {glm::vec4(-1.0f), glm::vec4(1.0f), glm::bvec4(false), glm::vec4(-1.0f)}, - {glm::vec4(-1.0f), glm::vec4(1.0f), glm::bvec4(true), glm::vec4(1.0f)}, - {glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(5.0f, 6.0f, 7.0f, 8.0f), glm::bvec4(true, false, true, false), glm::vec4(5.0f, 2.0f, 7.0f, 4.0f)} - }; - - int test() - { - int Error = 0; - - // Float with bool - { - for(std::size_t i = 0; i < sizeof(TestBool) / sizeof(entry); ++i) - { - float Result = glm::mix(TestBool[i].x, TestBool[i].y, TestBool[i].a); - Error += glm::epsilonEqual(Result, TestBool[i].Result, glm::epsilon()) ? 0 : 1; - } - } - - // Float with float - { - for(std::size_t i = 0; i < sizeof(TestFloat) / sizeof(entry); ++i) - { - float Result = glm::mix(TestFloat[i].x, TestFloat[i].y, TestFloat[i].a); - Error += glm::epsilonEqual(Result, TestFloat[i].Result, glm::epsilon()) ? 0 : 1; - } - } - - // vec2 with bool - { - for(std::size_t i = 0; i < sizeof(TestVec2Bool) / sizeof(entry); ++i) - { - glm::vec2 Result = glm::mix(TestVec2Bool[i].x, TestVec2Bool[i].y, TestVec2Bool[i].a); - Error += glm::epsilonEqual(Result.x, TestVec2Bool[i].Result.x, glm::epsilon()) ? 0 : 1; - Error += glm::epsilonEqual(Result.y, TestVec2Bool[i].Result.y, glm::epsilon()) ? 0 : 1; - } - } - - // vec2 with bvec2 - { - for(std::size_t i = 0; i < sizeof(TestBVec2) / sizeof(entry); ++i) - { - glm::vec2 Result = glm::mix(TestBVec2[i].x, TestBVec2[i].y, TestBVec2[i].a); - Error += glm::epsilonEqual(Result.x, TestBVec2[i].Result.x, glm::epsilon()) ? 0 : 1; - Error += glm::epsilonEqual(Result.y, TestBVec2[i].Result.y, glm::epsilon()) ? 0 : 1; - } - } - - // vec3 with bool - { - for(std::size_t i = 0; i < sizeof(TestVec3Bool) / sizeof(entry); ++i) - { - glm::vec3 Result = glm::mix(TestVec3Bool[i].x, TestVec3Bool[i].y, TestVec3Bool[i].a); - Error += glm::epsilonEqual(Result.x, TestVec3Bool[i].Result.x, glm::epsilon()) ? 0 : 1; - Error += glm::epsilonEqual(Result.y, TestVec3Bool[i].Result.y, glm::epsilon()) ? 0 : 1; - Error += glm::epsilonEqual(Result.z, TestVec3Bool[i].Result.z, glm::epsilon()) ? 0 : 1; - } - } - - // vec3 with bvec3 - { - for(std::size_t i = 0; i < sizeof(TestBVec3) / sizeof(entry); ++i) - { - glm::vec3 Result = glm::mix(TestBVec3[i].x, TestBVec3[i].y, TestBVec3[i].a); - Error += glm::epsilonEqual(Result.x, TestBVec3[i].Result.x, glm::epsilon()) ? 0 : 1; - Error += glm::epsilonEqual(Result.y, TestBVec3[i].Result.y, glm::epsilon()) ? 0 : 1; - Error += glm::epsilonEqual(Result.z, TestBVec3[i].Result.z, glm::epsilon()) ? 0 : 1; - } - } - - // vec4 with bool - { - for(std::size_t i = 0; i < sizeof(TestVec4Bool) / sizeof(entry); ++i) - { - glm::vec4 Result = glm::mix(TestVec4Bool[i].x, TestVec4Bool[i].y, TestVec4Bool[i].a); - Error += glm::epsilonEqual(Result.x, TestVec4Bool[i].Result.x, glm::epsilon()) ? 0 : 1; - Error += glm::epsilonEqual(Result.y, TestVec4Bool[i].Result.y, glm::epsilon()) ? 0 : 1; - Error += glm::epsilonEqual(Result.z, TestVec4Bool[i].Result.z, glm::epsilon()) ? 0 : 1; - Error += glm::epsilonEqual(Result.w, TestVec4Bool[i].Result.w, glm::epsilon()) ? 0 : 1; - } - } - - // vec4 with bvec4 - { - for(std::size_t i = 0; i < sizeof(TestBVec4) / sizeof(entry); ++i) - { - glm::vec4 Result = glm::mix(TestBVec4[i].x, TestBVec4[i].y, TestBVec4[i].a); - Error += glm::epsilonEqual(Result.x, TestBVec4[i].Result.x, glm::epsilon()) ? 0 : 1; - Error += glm::epsilonEqual(Result.y, TestBVec4[i].Result.y, glm::epsilon()) ? 0 : 1; - Error += glm::epsilonEqual(Result.z, TestBVec4[i].Result.z, glm::epsilon()) ? 0 : 1; - Error += glm::epsilonEqual(Result.w, TestBVec4[i].Result.w, glm::epsilon()) ? 0 : 1; - } - } - - return Error; - } -}//namespace mix_ - -namespace step_ -{ - template - struct entry - { - EDGE edge; - VEC x; - VEC result; - }; - - entry TestVec4Scalar [] = - { - { 1.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) }, - { 0.0f, glm::vec4(1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) }, - { 0.0f, glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(0.0f) } - }; - - entry TestVec4Vector [] = - { - { glm::vec4(-1.0f, -2.0f, -3.0f, -4.0f), glm::vec4(-2.0f, -3.0f, -4.0f, -5.0f), glm::vec4(0.0f) }, - { glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4( 1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(1.0f) }, - { glm::vec4( 2.0f, 3.0f, 4.0f, 5.0f), glm::vec4( 1.0f, 2.0f, 3.0f, 4.0f), glm::vec4(0.0f) }, - { glm::vec4( 0.0f, 1.0f, 2.0f, 3.0f), glm::vec4(-1.0f,-2.0f,-3.0f,-4.0f), glm::vec4(0.0f) } - }; - - int test() - { - int Error = 0; - - // vec4 and float - { - for (std::size_t i = 0; i < sizeof(TestVec4Scalar) / sizeof(entry); ++i) - { - glm::vec4 Result = glm::step(TestVec4Scalar[i].edge, TestVec4Scalar[i].x); - Error += glm::all(glm::epsilonEqual(Result, TestVec4Scalar[i].result, glm::epsilon())) ? 0 : 1; - } - } - - // vec4 and vec4 - { - for (std::size_t i = 0; i < sizeof(TestVec4Vector) / sizeof(entry); ++i) - { - glm::vec4 Result = glm::step(TestVec4Vector[i].edge, TestVec4Vector[i].x); - Error += glm::all(glm::epsilonEqual(Result, TestVec4Vector[i].result, glm::epsilon())) ? 0 : 1; - } - } - - return Error; - } -}//namespace step_ - -namespace round_ -{ - int test() - { - int Error = 0; - - { - float A = glm::round(0.0f); - Error += A == 0.0f ? 0 : 1; - float B = glm::round(0.5f); - Error += B == 1.0f ? 0 : 1; - float C = glm::round(1.0f); - Error += C == 1.0f ? 0 : 1; - float D = glm::round(0.1f); - Error += D == 0.0f ? 0 : 1; - float E = glm::round(0.9f); - Error += E == 1.0f ? 0 : 1; - float F = glm::round(1.5f); - Error += F == 2.0f ? 0 : 1; - float G = glm::round(1.9f); - Error += G == 2.0f ? 0 : 1; - } - - { - float A = glm::round(-0.0f); - Error += A == 0.0f ? 0 : 1; - float B = glm::round(-0.5f); - Error += B == -1.0f ? 0 : 1; - float C = glm::round(-1.0f); - Error += C == -1.0f ? 0 : 1; - float D = glm::round(-0.1f); - Error += D == 0.0f ? 0 : 1; - float E = glm::round(-0.9f); - Error += E == -1.0f ? 0 : 1; - float F = glm::round(-1.5f); - Error += F == -2.0f ? 0 : 1; - float G = glm::round(-1.9f); - Error += G == -2.0f ? 0 : 1; - } - - return Error; - } -}//namespace round_ - -namespace roundEven -{ - int test() - { - int Error = 0; - - { - float A1 = glm::roundEven(-1.5f); - Error += glm::epsilonEqual(A1, -2.0f, 0.0001f) ? 0 : 1; - - float A2 = glm::roundEven(1.5f); - Error += glm::epsilonEqual(A2, 2.0f, 0.0001f) ? 0 : 1; - - float A5 = glm::roundEven(-2.5f); - Error += glm::epsilonEqual(A5, -2.0f, 0.0001f) ? 0 : 1; - - float A6 = glm::roundEven(2.5f); - Error += glm::epsilonEqual(A6, 2.0f, 0.0001f) ? 0 : 1; - - float A3 = glm::roundEven(-3.5f); - Error += glm::epsilonEqual(A3, -4.0f, 0.0001f) ? 0 : 1; - - float A4 = glm::roundEven(3.5f); - Error += glm::epsilonEqual(A4, 4.0f, 0.0001f) ? 0 : 1; - - float C7 = glm::roundEven(-4.5f); - Error += glm::epsilonEqual(C7, -4.0f, 0.0001f) ? 0 : 1; - - float C8 = glm::roundEven(4.5f); - Error += glm::epsilonEqual(C8, 4.0f, 0.0001f) ? 0 : 1; - - float C1 = glm::roundEven(-5.5f); - Error += glm::epsilonEqual(C1, -6.0f, 0.0001f) ? 0 : 1; - - float C2 = glm::roundEven(5.5f); - Error += glm::epsilonEqual(C2, 6.0f, 0.0001f) ? 0 : 1; - - float C3 = glm::roundEven(-6.5f); - Error += glm::epsilonEqual(C3, -6.0f, 0.0001f) ? 0 : 1; - - float C4 = glm::roundEven(6.5f); - Error += glm::epsilonEqual(C4, 6.0f, 0.0001f) ? 0 : 1; - - float C5 = glm::roundEven(-7.5f); - Error += glm::epsilonEqual(C5, -8.0f, 0.0001f) ? 0 : 1; - - float C6 = glm::roundEven(7.5f); - Error += glm::epsilonEqual(C6, 8.0f, 0.0001f) ? 0 : 1; - - Error += 0; - } - - { - float A7 = glm::roundEven(-2.4f); - Error += glm::epsilonEqual(A7, -2.0f, 0.0001f) ? 0 : 1; - - float A8 = glm::roundEven(2.4f); - Error += glm::epsilonEqual(A8, 2.0f, 0.0001f) ? 0 : 1; - - float B1 = glm::roundEven(-2.6f); - Error += glm::epsilonEqual(B1, -3.0f, 0.0001f) ? 0 : 1; - - float B2 = glm::roundEven(2.6f); - Error += glm::epsilonEqual(B2, 3.0f, 0.0001f) ? 0 : 1; - - float B3 = glm::roundEven(-2.0f); - Error += glm::epsilonEqual(B3, -2.0f, 0.0001f) ? 0 : 1; - - float B4 = glm::roundEven(2.0f); - Error += glm::epsilonEqual(B4, 2.0f, 0.0001f) ? 0 : 1; - - Error += 0; - } - - { - float A = glm::roundEven(0.0f); - Error += A == 0.0f ? 0 : 1; - float B = glm::roundEven(0.5f); - Error += B == 0.0f ? 0 : 1; - float C = glm::roundEven(1.0f); - Error += C == 1.0f ? 0 : 1; - float D = glm::roundEven(0.1f); - Error += D == 0.0f ? 0 : 1; - float E = glm::roundEven(0.9f); - Error += E == 1.0f ? 0 : 1; - float F = glm::roundEven(1.5f); - Error += F == 2.0f ? 0 : 1; - float G = glm::roundEven(1.9f); - Error += G == 2.0f ? 0 : 1; - } - - { - float A = glm::roundEven(-0.0f); - Error += A == 0.0f ? 0 : 1; - float B = glm::roundEven(-0.5f); - Error += B == -0.0f ? 0 : 1; - float C = glm::roundEven(-1.0f); - Error += C == -1.0f ? 0 : 1; - float D = glm::roundEven(-0.1f); - Error += D == 0.0f ? 0 : 1; - float E = glm::roundEven(-0.9f); - Error += E == -1.0f ? 0 : 1; - float F = glm::roundEven(-1.5f); - Error += F == -2.0f ? 0 : 1; - float G = glm::roundEven(-1.9f); - Error += G == -2.0f ? 0 : 1; - } - - { - float A = glm::roundEven(1.5f); - Error += A == 2.0f ? 0 : 1; - float B = glm::roundEven(2.5f); - Error += B == 2.0f ? 0 : 1; - float C = glm::roundEven(3.5f); - Error += C == 4.0f ? 0 : 1; - float D = glm::roundEven(4.5f); - Error += D == 4.0f ? 0 : 1; - float E = glm::roundEven(5.5f); - Error += E == 6.0f ? 0 : 1; - float F = glm::roundEven(6.5f); - Error += F == 6.0f ? 0 : 1; - float G = glm::roundEven(7.5f); - Error += G == 8.0f ? 0 : 1; - } - - { - float A = glm::roundEven(-1.5f); - Error += A == -2.0f ? 0 : 1; - float B = glm::roundEven(-2.5f); - Error += B == -2.0f ? 0 : 1; - float C = glm::roundEven(-3.5f); - Error += C == -4.0f ? 0 : 1; - float D = glm::roundEven(-4.5f); - Error += D == -4.0f ? 0 : 1; - float E = glm::roundEven(-5.5f); - Error += E == -6.0f ? 0 : 1; - float F = glm::roundEven(-6.5f); - Error += F == -6.0f ? 0 : 1; - float G = glm::roundEven(-7.5f); - Error += G == -8.0f ? 0 : 1; - } - - return Error; - } -}//namespace roundEven - -namespace isnan_ -{ - int test() - { - int Error = 0; - - float Zero_f = 0.0; - double Zero_d = 0.0; - - { - Error += true == glm::isnan(0.0/Zero_d) ? 0 : 1; - Error += true == glm::any(glm::isnan(glm::dvec2(0.0 / Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isnan(glm::dvec3(0.0 / Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isnan(glm::dvec4(0.0 / Zero_d))) ? 0 : 1; - } - - { - Error += true == glm::isnan(0.0f/Zero_f) ? 0 : 1; - Error += true == glm::any(glm::isnan(glm::vec2(0.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isnan(glm::vec3(0.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isnan(glm::vec4(0.0f/Zero_f))) ? 0 : 1; - } - - return Error; - } -}//namespace isnan_ - -namespace isinf_ -{ - int test() - { - int Error = 0; - - float Zero_f = 0.0; - double Zero_d = 0.0; - - { - Error += true == glm::isinf( 1.0/Zero_d) ? 0 : 1; - Error += true == glm::isinf(-1.0/Zero_d) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::dvec2( 1.0/Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::dvec2(-1.0/Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::dvec3( 1.0/Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::dvec3(-1.0/Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::dvec4( 1.0/Zero_d))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::dvec4(-1.0/Zero_d))) ? 0 : 1; - } - - { - Error += true == glm::isinf( 1.0f/Zero_f) ? 0 : 1; - Error += true == glm::isinf(-1.0f/Zero_f) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::vec2( 1.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::vec2(-1.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::vec3( 1.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::vec3(-1.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::vec4( 1.0f/Zero_f))) ? 0 : 1; - Error += true == glm::any(glm::isinf(glm::vec4(-1.0f/Zero_f))) ? 0 : 1; - } - - return Error; - } -}//namespace isinf_ - -namespace sign -{ - template - GLM_FUNC_QUALIFIER genFIType sign_if(genFIType x) - { - GLM_STATIC_ASSERT( - std::numeric_limits::is_iec559 || - (std::numeric_limits::is_signed && std::numeric_limits::is_integer), "'sign' only accept signed inputs"); - - genFIType result; - if(x > genFIType(0)) - result = genFIType(1); - else if(x < genFIType(0)) - result = genFIType(-1); - else - result = genFIType(0); - return result; - } - - template - GLM_FUNC_QUALIFIER genFIType sign_alu1(genFIType x) - { - GLM_STATIC_ASSERT( - std::numeric_limits::is_signed && std::numeric_limits::is_integer, - "'sign' only accept integer inputs"); - - return (x >> 31) | ((unsigned)-x >> 31); - } - - template - GLM_FUNC_QUALIFIER genFIType sign_alu2(genFIType x) - { - GLM_STATIC_ASSERT( - std::numeric_limits::is_signed && std::numeric_limits::is_integer, - "'sign' only accept integer inputs"); - - return -((unsigned)x >> 31) | (-(unsigned)x >> 31); - } - - template - GLM_FUNC_QUALIFIER genFIType sign_sub(genFIType x) - { - GLM_STATIC_ASSERT( - std::numeric_limits::is_signed && std::numeric_limits::is_integer, - "'sign' only accept integer inputs"); - - return ((unsigned)-x >> 31) - ((unsigned)x >> 31); - } - - template - GLM_FUNC_QUALIFIER genFIType sign_cmp(genFIType x) - { - GLM_STATIC_ASSERT( - std::numeric_limits::is_signed && std::numeric_limits::is_integer, - "'sign' only accept integer inputs"); - - return (x > 0) - (x < 0); - } - - template - struct type - { - genType Value; - genType Return; - }; - - int test_int32() - { - type const Data[] = - { - { std::numeric_limits::max(), 1}, - { std::numeric_limits::min(), -1}, - { 0, 0}, - { 1, 1}, - { 2, 1}, - { 3, 1}, - {-1,-1}, - {-2,-1}, - {-3,-1} - }; - - int Error = 0; - - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - glm::int32 Result = glm::sign(Data[i].Value); - Error += Data[i].Return == Result ? 0 : 1; - } - - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - glm::int32 Result = sign_cmp(Data[i].Value); - Error += Data[i].Return == Result ? 0 : 1; - } - - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - glm::int32 Result = sign_if(Data[i].Value); - Error += Data[i].Return == Result ? 0 : 1; - } - - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - glm::int32 Result = sign_alu1(Data[i].Value); - Error += Data[i].Return == Result ? 0 : 1; - } - - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - glm::int32 Result = sign_alu2(Data[i].Value); - Error += Data[i].Return == Result ? 0 : 1; - } - - return Error; - } - - int test_i32vec4() - { - type const Data[] = - { - {glm::i32vec4( 1), glm::i32vec4( 1)}, - {glm::i32vec4( 0), glm::i32vec4( 0)}, - {glm::i32vec4( 2), glm::i32vec4( 1)}, - {glm::i32vec4( 3), glm::i32vec4( 1)}, - {glm::i32vec4(-1), glm::i32vec4(-1)}, - {glm::i32vec4(-2), glm::i32vec4(-1)}, - {glm::i32vec4(-3), glm::i32vec4(-1)} - }; - - int Error = 0; - - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - glm::i32vec4 Result = glm::sign(Data[i].Value); - Error += glm::all(glm::equal(Data[i].Return, Result)) ? 0 : 1; - } - - return Error; - } - - int test_f32vec4() - { - type const Data[] = - { - {glm::vec4( 1), glm::vec4( 1)}, - {glm::vec4( 0), glm::vec4( 0)}, - {glm::vec4( 2), glm::vec4( 1)}, - {glm::vec4( 3), glm::vec4( 1)}, - {glm::vec4(-1), glm::vec4(-1)}, - {glm::vec4(-2), glm::vec4(-1)}, - {glm::vec4(-3), glm::vec4(-1)} - }; - - int Error = 0; - - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - glm::vec4 Result = glm::sign(Data[i].Value); - Error += glm::all(glm::equal(Data[i].Return, Result)) ? 0 : 1; - } - - return Error; - } - - int test() - { - int Error = 0; - - Error += test_int32(); - Error += test_i32vec4(); - Error += test_f32vec4(); - - return Error; - } - - int perf_rand(std::size_t Samples) - { - int Error = 0; - - std::size_t const Count = Samples; - std::vector Input, Output; - Input.resize(Count); - Output.resize(Count); - for(std::size_t i = 0; i < Count; ++i) - Input[i] = static_cast(glm::linearRand(-65536.f, 65536.f)); - - std::clock_t Timestamp0 = std::clock(); - - for(std::size_t i = 0; i < Count; ++i) - Output[i] = sign_cmp(Input[i]); - - std::clock_t Timestamp1 = std::clock(); - - for(std::size_t i = 0; i < Count; ++i) - Output[i] = sign_if(Input[i]); - - std::clock_t Timestamp2 = std::clock(); - - for(std::size_t i = 0; i < Count; ++i) - Output[i] = sign_alu1(Input[i]); - - std::clock_t Timestamp3 = std::clock(); - - for(std::size_t i = 0; i < Count; ++i) - Output[i] = sign_alu2(Input[i]); - - std::clock_t Timestamp4 = std::clock(); - - for(std::size_t i = 0; i < Count; ++i) - Output[i] = sign_sub(Input[i]); - - std::clock_t Timestamp5 = std::clock(); - - for(std::size_t i = 0; i < Count; ++i) - Output[i] = glm::sign(Input[i]); - - std::clock_t Timestamp6 = std::clock(); - - std::printf("sign_cmp(rand) Time %d clocks\n", static_cast(Timestamp1 - Timestamp0)); - std::printf("sign_if(rand) Time %d clocks\n", static_cast(Timestamp2 - Timestamp1)); - std::printf("sign_alu1(rand) Time %d clocks\n", static_cast(Timestamp3 - Timestamp2)); - std::printf("sign_alu2(rand) Time %d clocks\n", static_cast(Timestamp4 - Timestamp3)); - std::printf("sign_sub(rand) Time %d clocks\n", static_cast(Timestamp5 - Timestamp4)); - std::printf("glm::sign(rand) Time %d clocks\n", static_cast(Timestamp6 - Timestamp5)); - - return Error; - } - - int perf_linear(std::size_t Samples) - { - int Error = 0; - - std::size_t const Count = Samples; - std::vector Input, Output; - Input.resize(Count); - Output.resize(Count); - for(std::size_t i = 0; i < Count; ++i) - Input[i] = static_cast(i); - - std::clock_t Timestamp0 = std::clock(); - - for(std::size_t i = 0; i < Count; ++i) - Output[i] = sign_cmp(Input[i]); - - std::clock_t Timestamp1 = std::clock(); - - for(std::size_t i = 0; i < Count; ++i) - Output[i] = sign_if(Input[i]); - - std::clock_t Timestamp2 = std::clock(); - - for(std::size_t i = 0; i < Count; ++i) - Output[i] = sign_alu1(Input[i]); - - std::clock_t Timestamp3 = std::clock(); - - for(std::size_t i = 0; i < Count; ++i) - Output[i] = sign_alu2(Input[i]); - - std::clock_t Timestamp4 = std::clock(); - - for(std::size_t i = 0; i < Count; ++i) - Output[i] = sign_sub(Input[i]); - - std::clock_t Timestamp5 = std::clock(); - - std::printf("sign_cmp(linear) Time %d clocks\n", static_cast(Timestamp1 - Timestamp0)); - std::printf("sign_if(linear) Time %d clocks\n", static_cast(Timestamp2 - Timestamp1)); - std::printf("sign_alu1(linear) Time %d clocks\n", static_cast(Timestamp3 - Timestamp2)); - std::printf("sign_alu2(linear) Time %d clocks\n", static_cast(Timestamp4 - Timestamp3)); - std::printf("sign_sub(linear) Time %d clocks\n", static_cast(Timestamp5 - Timestamp4)); - - return Error; - } - - int perf_linear_cal(std::size_t Samples) - { - int Error = 0; - - glm::int32 const Count = static_cast(Samples); - - std::clock_t Timestamp0 = std::clock(); - glm::int32 Sum = 0; - - for(glm::int32 i = 1; i < Count; ++i) - Sum += sign_cmp(i); - - std::clock_t Timestamp1 = std::clock(); - - for(glm::int32 i = 1; i < Count; ++i) - Sum += sign_if(i); - - std::clock_t Timestamp2 = std::clock(); - - for(glm::int32 i = 1; i < Count; ++i) - Sum += sign_alu1(i); - - std::clock_t Timestamp3 = std::clock(); - - for(glm::int32 i = 1; i < Count; ++i) - Sum += sign_alu2(i); - - std::clock_t Timestamp4 = std::clock(); - - for(glm::int32 i = 1; i < Count; ++i) - Sum += sign_sub(i); - - std::clock_t Timestamp5 = std::clock(); - - std::printf("Sum %d\n", static_cast(Sum)); - - std::printf("sign_cmp(linear_cal) Time %d clocks\n", static_cast(Timestamp1 - Timestamp0)); - std::printf("sign_if(linear_cal) Time %d clocks\n", static_cast(Timestamp2 - Timestamp1)); - std::printf("sign_alu1(linear_cal) Time %d clocks\n", static_cast(Timestamp3 - Timestamp2)); - std::printf("sign_alu2(linear_cal) Time %d clocks\n", static_cast(Timestamp4 - Timestamp3)); - std::printf("sign_sub(linear_cal) Time %d clocks\n", static_cast(Timestamp5 - Timestamp4)); - - return Error; - } - - int perf(std::size_t Samples) - { - int Error(0); - - Error += perf_linear_cal(Samples); - Error += perf_linear(Samples); - Error += perf_rand(Samples); - - return Error; - } -}//namespace sign - -namespace frexp_ -{ - int test() - { - int Error(0); - - { - glm::vec1 x(1024); - glm::ivec1 exp; - glm::vec1 A = glm::frexp(x, exp); - Error += glm::all(glm::epsilonEqual(A, glm::vec1(0.5), 0.00001f)) ? 0 : 1; - Error += glm::all(glm::equal(exp, glm::ivec1(11))) ? 0 : 1; - } - - { - glm::vec2 x(1024, 0.24); - glm::ivec2 exp; - glm::vec2 A = glm::frexp(x, exp); - Error += glm::all(glm::epsilonEqual(A, glm::vec2(0.5, 0.96), 0.00001f)) ? 0 : 1; - Error += glm::all(glm::equal(exp, glm::ivec2(11, -2))) ? 0 : 1; - } - - { - glm::vec3 x(1024, 0.24, 0); - glm::ivec3 exp; - glm::vec3 A = glm::frexp(x, exp); - Error += glm::all(glm::epsilonEqual(A, glm::vec3(0.5, 0.96, 0.0), 0.00001f)) ? 0 : 1; - Error += glm::all(glm::equal(exp, glm::ivec3(11, -2, 0))) ? 0 : 1; - } - - { - glm::vec4 x(1024, 0.24, 0, -1.33); - glm::ivec4 exp; - glm::vec4 A = glm::frexp(x, exp); - Error += glm::all(glm::epsilonEqual(A, glm::vec4(0.5, 0.96, 0.0, -0.665), 0.00001f)) ? 0 : 1; - Error += glm::all(glm::equal(exp, glm::ivec4(11, -2, 0, 1))) ? 0 : 1; - } - - return Error; - } -}//namespace frexp_ - -namespace ldexp_ -{ - int test() - { - int Error(0); - - { - glm::vec1 A = glm::vec1(0.5); - glm::ivec1 exp = glm::ivec1(11); - glm::vec1 x = glm::ldexp(A, exp); - Error += glm::all(glm::epsilonEqual(x, glm::vec1(1024),0.00001f)) ? 0 : 1; - } - - { - glm::vec2 A = glm::vec2(0.5, 0.96); - glm::ivec2 exp = glm::ivec2(11, -2); - glm::vec2 x = glm::ldexp(A, exp); - Error += glm::all(glm::epsilonEqual(x, glm::vec2(1024, .24),0.00001f)) ? 0 : 1; - } - - { - glm::vec3 A = glm::vec3(0.5, 0.96, 0.0); - glm::ivec3 exp = glm::ivec3(11, -2, 0); - glm::vec3 x = glm::ldexp(A, exp); - Error += glm::all(glm::epsilonEqual(x, glm::vec3(1024, .24, 0),0.00001f)) ? 0 : 1; - } - - { - glm::vec4 A = glm::vec4(0.5, 0.96, 0.0, -0.665); - glm::ivec4 exp = glm::ivec4(11, -2, 0, 1); - glm::vec4 x = glm::ldexp(A, exp); - Error += glm::all(glm::epsilonEqual(x, glm::vec4(1024, .24, 0, -1.33),0.00001f)) ? 0 : 1; - } - - return Error; - } -}//namespace ldexp_ - -int main() -{ - int Error = 0; - - glm::ivec4 const a(1); - glm::ivec4 const b = ~a; - - glm::int32 const c(1); - glm::int32 const d = ~c; - -# if GLM_ARCH & GLM_ARCH_AVX_BIT && GLM_HAS_UNRESTRICTED_UNIONS - glm_vec4 const A = _mm_set_ps(4, 3, 2, 1); - glm_vec4 const B = glm_vec4_swizzle_xyzw(A); - glm_vec4 const C = _mm_permute_ps(A, _MM_SHUFFLE(3, 2, 1, 0)); - glm_vec4 const D = _mm_permute_ps(A, _MM_SHUFFLE(0, 1, 2, 3)); - glm_vec4 const E = _mm_shuffle_ps(A, A, _MM_SHUFFLE(0, 1, 2, 3)); -# endif - - Error += sign::test(); - Error += floor_::test(); - Error += mod_::test(); - Error += modf_::test(); - Error += floatBitsToInt::test(); - Error += floatBitsToUint::test(); - Error += mix_::test(); - Error += step_::test(); - Error += max_::test(); - Error += min_::test(); - Error += round_::test(); - Error += roundEven::test(); - Error += isnan_::test(); - Error += isinf_::test(); - Error += frexp_::test(); - Error += ldexp_::test(); - -# ifdef NDEBUG - std::size_t Samples = 1000; - Error += sign::perf(Samples); -# endif - - return Error; -} - diff --git a/VRVideoPlayer/external/glm/test/core/core_func_exponential.cpp b/VRVideoPlayer/external/glm/test/core/core_func_exponential.cpp deleted file mode 100644 index 665d8df..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_func_exponential.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include -#include -#include -#include - -int test_pow() -{ - int Error(0); - - float A = glm::pow(10.f, 10.f); - glm::vec1 B = glm::pow(glm::vec1(10.f), glm::vec1(10.f)); - glm::vec2 C = glm::pow(glm::vec2(10.f), glm::vec2(10.f)); - glm::vec3 D = glm::pow(glm::vec3(10.f), glm::vec3(10.f)); - glm::vec4 E = glm::pow(glm::vec4(10.f), glm::vec4(10.f)); - - return Error; -} - -int test_exp() -{ - int Error(0); - - float A = glm::exp(10.f); - glm::vec1 B = glm::exp(glm::vec1(10.f)); - glm::vec2 C = glm::exp(glm::vec2(10.f)); - glm::vec3 D = glm::exp(glm::vec3(10.f)); - glm::vec4 E = glm::exp(glm::vec4(10.f)); - - return Error; -} - -int test_log() -{ - int Error(0); - - float A = glm::log(10.f); - glm::vec1 B = glm::log(glm::vec1(10.f)); - glm::vec2 C = glm::log(glm::vec2(10.f)); - glm::vec3 D = glm::log(glm::vec3(10.f)); - glm::vec4 E = glm::log(glm::vec4(10.f)); - - return Error; -} - -int test_exp2() -{ - int Error(0); - - float A = glm::exp2(10.f); - glm::vec1 B = glm::exp2(glm::vec1(10.f)); - glm::vec2 C = glm::exp2(glm::vec2(10.f)); - glm::vec3 D = glm::exp2(glm::vec3(10.f)); - glm::vec4 E = glm::exp2(glm::vec4(10.f)); - - return Error; -} - -int test_log2() -{ - int Error(0); - - float A = glm::log2(10.f); - glm::vec1 B = glm::log2(glm::vec1(10.f)); - glm::vec2 C = glm::log2(glm::vec2(10.f)); - glm::vec3 D = glm::log2(glm::vec3(10.f)); - glm::vec4 E = glm::log2(glm::vec4(10.f)); - - return Error; -} - -int test_sqrt() -{ - int Error(0); - -# if GLM_ARCH & GLM_ARCH_SSE2_BIT - for(float f = 0.1f; f < 30.0f; f += 0.1f) - { - float r = _mm_cvtss_f32(_mm_sqrt_ps(_mm_set1_ps(f))); - float s = std::sqrt(f); - Error += glm::abs(r - s) < 0.01f ? 0 : 1; - assert(!Error); - } -# endif//GLM_ARCH & GLM_ARCH_SSE2_BIT - - float A = glm::sqrt(10.f); - glm::vec1 B = glm::sqrt(glm::vec1(10.f)); - glm::vec2 C = glm::sqrt(glm::vec2(10.f)); - glm::vec3 D = glm::sqrt(glm::vec3(10.f)); - glm::vec4 E = glm::sqrt(glm::vec4(10.f)); - - return Error; -} - -int test_inversesqrt() -{ - int Error(0); - - glm::uint ulp(0); - float diff(0.0f); - - for(float f = 0.001f; f < 10.f; f *= 1.001f) - { - glm::lowp_fvec1 u(f); - glm::lowp_fvec1 lowp_v = glm::inversesqrt(u); - float defaultp_v = glm::inversesqrt(f); - - ulp = glm::max(glm::float_distance(lowp_v.x, defaultp_v), ulp); - diff = glm::abs(lowp_v.x - defaultp_v); - } - - return Error; -} - -int main() -{ - int Error(0); - - Error += test_pow(); - Error += test_exp(); - Error += test_log(); - Error += test_exp2(); - Error += test_log2(); - Error += test_sqrt(); - Error += test_inversesqrt(); - - return Error; -} - diff --git a/VRVideoPlayer/external/glm/test/core/core_func_geometric.cpp b/VRVideoPlayer/external/glm/test/core/core_func_geometric.cpp deleted file mode 100644 index 5c3379c..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_func_geometric.cpp +++ /dev/null @@ -1,193 +0,0 @@ -#include -#include -#include -#include -#include - -namespace length -{ - int test() - { - float Length1 = glm::length(glm::vec1(1)); - float Length2 = glm::length(glm::vec2(1, 0)); - float Length3 = glm::length(glm::vec3(1, 0, 0)); - float Length4 = glm::length(glm::vec4(1, 0, 0, 0)); - - int Error = 0; - - Error += glm::abs(Length1 - 1.0f) < std::numeric_limits::epsilon() ? 0 : 1; - Error += glm::abs(Length2 - 1.0f) < std::numeric_limits::epsilon() ? 0 : 1; - Error += glm::abs(Length3 - 1.0f) < std::numeric_limits::epsilon() ? 0 : 1; - Error += glm::abs(Length4 - 1.0f) < std::numeric_limits::epsilon() ? 0 : 1; - - return Error; - } -}//namespace length - -namespace distance -{ - int test() - { - float Distance1 = glm::distance(glm::vec1(1), glm::vec1(1)); - float Distance2 = glm::distance(glm::vec2(1, 0), glm::vec2(1, 0)); - float Distance3 = glm::distance(glm::vec3(1, 0, 0), glm::vec3(1, 0, 0)); - float Distance4 = glm::distance(glm::vec4(1, 0, 0, 0), glm::vec4(1, 0, 0, 0)); - - int Error = 0; - - Error += glm::abs(Distance1) < std::numeric_limits::epsilon() ? 0 : 1; - Error += glm::abs(Distance2) < std::numeric_limits::epsilon() ? 0 : 1; - Error += glm::abs(Distance3) < std::numeric_limits::epsilon() ? 0 : 1; - Error += glm::abs(Distance4) < std::numeric_limits::epsilon() ? 0 : 1; - - return Error; - } -}//namespace distance - -namespace dot -{ - int test() - { - float Dot1 = glm::dot(glm::vec1(1), glm::vec1(1)); - float Dot2 = glm::dot(glm::vec2(1), glm::vec2(1)); - float Dot3 = glm::dot(glm::vec3(1), glm::vec3(1)); - float Dot4 = glm::dot(glm::vec4(1), glm::vec4(1)); - - int Error = 0; - - Error += glm::abs(Dot1 - 1.0f) < std::numeric_limits::epsilon() ? 0 : 1; - Error += glm::abs(Dot2 - 2.0f) < std::numeric_limits::epsilon() ? 0 : 1; - Error += glm::abs(Dot3 - 3.0f) < std::numeric_limits::epsilon() ? 0 : 1; - Error += glm::abs(Dot4 - 4.0f) < std::numeric_limits::epsilon() ? 0 : 1; - - return Error; - } -}//namespace dot - -namespace cross -{ - int test() - { - glm::vec3 Cross1 = glm::cross(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0)); - glm::vec3 Cross2 = glm::cross(glm::vec3(0, 1, 0), glm::vec3(1, 0, 0)); - - int Error = 0; - - Error += glm::all(glm::lessThan(glm::abs(Cross1 - glm::vec3(0, 0, 1)), glm::vec3(std::numeric_limits::epsilon()))) ? 0 : 1; - Error += glm::all(glm::lessThan(glm::abs(Cross2 - glm::vec3(0, 0,-1)), glm::vec3(std::numeric_limits::epsilon()))) ? 0 : 1; - - return Error; - } -}//namespace cross - -namespace normalize -{ - int test() - { - glm::vec3 Normalize1 = glm::normalize(glm::vec3(1, 0, 0)); - glm::vec3 Normalize2 = glm::normalize(glm::vec3(2, 0, 0)); - - glm::vec3 Normalize3 = glm::normalize(glm::vec3(-0.6, 0.7, -0.5)); - - glm::vec3 ro = glm::vec3(glm::cos(5.f) * 3.f, 2.f, glm::sin(5.f) * 3.f); - glm::vec3 w = glm::normalize(glm::vec3(0, -0.2f, 0) - ro); - glm::vec3 u = glm::normalize(glm::cross(w, glm::vec3(0, 1, 0))); - glm::vec3 v = glm::cross(u, w); - - int Error = 0; - - Error += glm::all(glm::lessThan(glm::abs(Normalize1 - glm::vec3(1, 0, 0)), glm::vec3(std::numeric_limits::epsilon()))) ? 0 : 1; - Error += glm::all(glm::lessThan(glm::abs(Normalize2 - glm::vec3(1, 0, 0)), glm::vec3(std::numeric_limits::epsilon()))) ? 0 : 1; - - return Error; - } -}//namespace normalize - -namespace faceforward -{ - int test() - { - int Error = 0; - - { - glm::vec3 N(0.0f, 0.0f, 1.0f); - glm::vec3 I(1.0f, 0.0f, 1.0f); - glm::vec3 Nref(0.0f, 0.0f, 1.0f); - glm::vec3 F = glm::faceforward(N, I, Nref); - } - - return Error; - } -}//namespace faceforward - -namespace reflect -{ - int test() - { - int Error = 0; - - { - glm::vec2 A(1.0f,-1.0f); - glm::vec2 B(0.0f, 1.0f); - glm::vec2 C = glm::reflect(A, B); - Error += C == glm::vec2(1.0, 1.0) ? 0 : 1; - } - - { - glm::dvec2 A(1.0f,-1.0f); - glm::dvec2 B(0.0f, 1.0f); - glm::dvec2 C = glm::reflect(A, B); - Error += C == glm::dvec2(1.0, 1.0) ? 0 : 1; - } - - return Error; - } -}//namespace reflect - -namespace refract -{ - int test() - { - int Error = 0; - - { - float A(-1.0f); - float B(1.0f); - float C = glm::refract(A, B, 0.5f); - Error += C == -1.0f ? 0 : 1; - } - - { - glm::vec2 A(0.0f,-1.0f); - glm::vec2 B(0.0f, 1.0f); - glm::vec2 C = glm::refract(A, B, 0.5f); - Error += glm::all(glm::epsilonEqual(C, glm::vec2(0.0, -1.0), 0.0001f)) ? 0 : 1; - } - - { - glm::dvec2 A(0.0f,-1.0f); - glm::dvec2 B(0.0f, 1.0f); - glm::dvec2 C = glm::refract(A, B, 0.5); - Error += C == glm::dvec2(0.0, -1.0) ? 0 : 1; - } - - return Error; - } -}//namespace refract - -int main() -{ - int Error(0); - - Error += length::test(); - Error += distance::test(); - Error += dot::test(); - Error += cross::test(); - Error += normalize::test(); - Error += faceforward::test(); - Error += reflect::test(); - Error += refract::test(); - - return Error; -} - diff --git a/VRVideoPlayer/external/glm/test/core/core_func_integer.cpp b/VRVideoPlayer/external/glm/test/core/core_func_integer.cpp deleted file mode 100644 index c44153d..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_func_integer.cpp +++ /dev/null @@ -1,1554 +0,0 @@ -#include -#include -#include -#include -#include -#include - -enum result -{ - SUCCESS, - FAIL, - ASSERT, - STATIC_ASSERT -}; - -namespace bitfieldInsert -{ - template - struct type - { - genType Base; - genType Insert; - sizeType Offset; - sizeType Bits; - genType Return; - }; - - typedef type typeU32; - - typeU32 const Data32[] = - { - {0x00000000, 0xffffffff, 0, 32, 0xffffffff}, - {0x00000000, 0xffffffff, 0, 31, 0x7fffffff}, - {0x00000000, 0xffffffff, 0, 0, 0x00000000}, - {0xff000000, 0x0000ff00, 8, 8, 0xff00ff00}, - {0xffff0000, 0x0000ffff, 16, 16, 0x00000000}, - {0x0000ffff, 0xffff0000, 16, 16, 0xffffffff} - }; - - int test() - { - int Error = 0; - glm::uint count = sizeof(Data32) / sizeof(typeU32); - - for(glm::uint i = 0; i < count; ++i) - { - glm::uint Return = glm::bitfieldInsert( - Data32[i].Base, - Data32[i].Insert, - Data32[i].Offset, - Data32[i].Bits); - - Error += Data32[i].Return == Return ? 0 : 1; - } - - return Error; - } -}//bitfieldInsert - -namespace bitfieldExtract -{ - template - struct type - { - genType Value; - sizeType Offset; - sizeType Bits; - genType Return; - result Result; - }; - - typedef type typeU32; - - typeU32 const Data32[] = - { - {0xffffffff, 0,32, 0xffffffff, SUCCESS}, - {0xffffffff, 8, 0, 0x00000000, SUCCESS}, - {0x00000000, 0,32, 0x00000000, SUCCESS}, - {0x0f0f0f0f, 0,32, 0x0f0f0f0f, SUCCESS}, - {0x00000000, 8, 0, 0x00000000, SUCCESS}, - {0x80000000,31, 1, 0x00000001, SUCCESS}, - {0x7fffffff,31, 1, 0x00000000, SUCCESS}, - {0x00000300, 8, 8, 0x00000003, SUCCESS}, - {0x0000ff00, 8, 8, 0x000000ff, SUCCESS}, - {0xfffffff0, 0, 5, 0x00000010, SUCCESS}, - {0x000000ff, 1, 3, 0x00000007, SUCCESS}, - {0x000000ff, 0, 3, 0x00000007, SUCCESS}, - {0x00000000, 0, 2, 0x00000000, SUCCESS}, - {0xffffffff, 0, 8, 0x000000ff, SUCCESS}, - {0xffff0000,16,16, 0x0000ffff, SUCCESS}, - {0xfffffff0, 0, 8, 0x00000000, FAIL}, - {0xffffffff,16,16, 0x00000000, FAIL}, - //{0xffffffff,32, 1, 0x00000000, ASSERT}, // Throw an assert - //{0xffffffff, 0,33, 0x00000000, ASSERT}, // Throw an assert - //{0xffffffff,16,16, 0x00000000, ASSERT}, // Throw an assert - }; - - int test() - { - int Error = 0; - - glm::uint count = sizeof(Data32) / sizeof(typeU32); - - for(glm::uint i = 0; i < count; ++i) - { - glm::uint Return = glm::bitfieldExtract( - Data32[i].Value, - Data32[i].Offset, - Data32[i].Bits); - - bool Compare = Data32[i].Return == Return; - - if(Data32[i].Result == SUCCESS && Compare) - continue; - else if(Data32[i].Result == FAIL && !Compare) - continue; - - Error += 1; - } - - return Error; - } -}//extractField - -namespace bitfieldReverse -{ -/* - GLM_FUNC_QUALIFIER unsigned int bitfieldReverseLoop(unsigned int v) - { - unsigned int Result(0); - unsigned int const BitSize = static_cast(sizeof(unsigned int) * 8); - for(unsigned int i = 0; i < BitSize; ++i) - { - unsigned int const BitSet(v & (static_cast(1) << i)); - unsigned int const BitFirst(BitSet >> i); - Result |= BitFirst << (BitSize - 1 - i); - } - return Result; - } - - GLM_FUNC_QUALIFIER glm::uint64_t bitfieldReverseLoop(glm::uint64_t v) - { - glm::uint64_t Result(0); - glm::uint64_t const BitSize = static_cast(sizeof(unsigned int) * 8); - for(glm::uint64_t i = 0; i < BitSize; ++i) - { - glm::uint64_t const BitSet(v & (static_cast(1) << i)); - glm::uint64_t const BitFirst(BitSet >> i); - Result |= BitFirst << (BitSize - 1 - i); - } - return Result; - } -*/ - template class vecType> - GLM_FUNC_QUALIFIER vecType bitfieldReverseLoop(vecType const & v) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldReverse' only accept integer values"); - - vecType Result(0); - T const BitSize = static_cast(sizeof(T) * 8); - for(T i = 0; i < BitSize; ++i) - { - vecType const BitSet(v & (static_cast(1) << i)); - vecType const BitFirst(BitSet >> i); - Result |= BitFirst << (BitSize - 1 - i); - } - return Result; - } - - template - GLM_FUNC_QUALIFIER T bitfieldReverseLoop(T v) - { - return bitfieldReverseLoop(glm::tvec1(v)).x; - } - - GLM_FUNC_QUALIFIER glm::uint32_t bitfieldReverseUint32(glm::uint32_t x) - { - x = (x & 0x55555555) << 1 | (x & 0xAAAAAAAA) >> 1; - x = (x & 0x33333333) << 2 | (x & 0xCCCCCCCC) >> 2; - x = (x & 0x0F0F0F0F) << 4 | (x & 0xF0F0F0F0) >> 4; - x = (x & 0x00FF00FF) << 8 | (x & 0xFF00FF00) >> 8; - x = (x & 0x0000FFFF) << 16 | (x & 0xFFFF0000) >> 16; - return x; - } - - GLM_FUNC_QUALIFIER glm::uint64_t bitfieldReverseUint64(glm::uint64_t x) - { - x = (x & 0x5555555555555555) << 1 | (x & 0xAAAAAAAAAAAAAAAA) >> 1; - x = (x & 0x3333333333333333) << 2 | (x & 0xCCCCCCCCCCCCCCCC) >> 2; - x = (x & 0x0F0F0F0F0F0F0F0F) << 4 | (x & 0xF0F0F0F0F0F0F0F0) >> 4; - x = (x & 0x00FF00FF00FF00FF) << 8 | (x & 0xFF00FF00FF00FF00) >> 8; - x = (x & 0x0000FFFF0000FFFF) << 16 | (x & 0xFFFF0000FFFF0000) >> 16; - x = (x & 0x00000000FFFFFFFF) << 32 | (x & 0xFFFFFFFF00000000) >> 32; - return x; - } - - template - struct compute_bitfieldReverseStep - { - template class vecType> - GLM_FUNC_QUALIFIER static vecType call(vecType const & v, T, T) - { - return v; - } - }; - - template <> - struct compute_bitfieldReverseStep - { - template class vecType> - GLM_FUNC_QUALIFIER static vecType call(vecType const & v, T Mask, T Shift) - { - return (v & Mask) << Shift | (v & (~Mask)) >> Shift; - } - }; - - template class vecType> - GLM_FUNC_QUALIFIER vecType bitfieldReverseOps(vecType const & v) - { - vecType x(v); - x = compute_bitfieldReverseStep= 2>::call(x, T(0x5555555555555555ull), static_cast( 1)); - x = compute_bitfieldReverseStep= 4>::call(x, T(0x3333333333333333ull), static_cast( 2)); - x = compute_bitfieldReverseStep= 8>::call(x, T(0x0F0F0F0F0F0F0F0Full), static_cast( 4)); - x = compute_bitfieldReverseStep= 16>::call(x, T(0x00FF00FF00FF00FFull), static_cast( 8)); - x = compute_bitfieldReverseStep= 32>::call(x, T(0x0000FFFF0000FFFFull), static_cast(16)); - x = compute_bitfieldReverseStep= 64>::call(x, T(0x00000000FFFFFFFFull), static_cast(32)); - return x; - } - - template - GLM_FUNC_QUALIFIER genType bitfieldReverseOps(genType x) - { - return bitfieldReverseOps(glm::tvec1(x)).x; - } - - template - struct type - { - genType Value; - genType Return; - result Result; - }; - - typedef type typeU32; - - typeU32 const Data32[] = - { - {0x00000001, 0x80000000, SUCCESS}, - {0x0000000f, 0xf0000000, SUCCESS}, - {0x000000ff, 0xff000000, SUCCESS}, - {0xf0000000, 0x0000000f, SUCCESS}, - {0xff000000, 0x000000ff, SUCCESS}, - {0xffffffff, 0xffffffff, SUCCESS}, - {0x00000000, 0x00000000, SUCCESS} - }; - - typedef type typeU64; - -#if(((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC) && (GLM_COMPILER < GLM_COMPILER_GCC44)) - typeU64 const Data64[] = - { - {0xf000000000000000LLU, 0x000000000000000fLLU, SUCCESS}, - {0xffffffffffffffffLLU, 0xffffffffffffffffLLU, SUCCESS}, - {0x0000000000000000LLU, 0x0000000000000000LLU, SUCCESS} - }; -#else - typeU64 const Data64[] = - { - {0x00000000000000ff, 0xff00000000000000, SUCCESS}, - {0x000000000000000f, 0xf000000000000000, SUCCESS}, - {0xf000000000000000, 0x000000000000000f, SUCCESS}, - {0xffffffffffffffff, 0xffffffffffffffff, SUCCESS}, - {0x0000000000000000, 0x0000000000000000, SUCCESS} - }; -#endif - - int test32_bitfieldReverse() - { - int Error = 0; - std::size_t const Count = sizeof(Data32) / sizeof(typeU32); - - for(std::size_t i = 0; i < Count; ++i) - { - glm::uint Return = glm::bitfieldReverse(Data32[i].Value); - - bool Compare = Data32[i].Return == Return; - - if(Data32[i].Result == SUCCESS) - Error += Compare ? 0 : 1; - else - Error += Compare ? 1 : 0; - } - - return Error; - } - - int test32_bitfieldReverseLoop() - { - int Error = 0; - std::size_t const Count = sizeof(Data32) / sizeof(typeU32); - - for(std::size_t i = 0; i < Count; ++i) - { - glm::uint Return = bitfieldReverseLoop(Data32[i].Value); - - bool Compare = Data32[i].Return == Return; - - if(Data32[i].Result == SUCCESS) - Error += Compare ? 0 : 1; - else - Error += Compare ? 1 : 0; - } - - return Error; - } - - int test32_bitfieldReverseUint32() - { - int Error = 0; - std::size_t const Count = sizeof(Data32) / sizeof(typeU32); - - for(std::size_t i = 0; i < Count; ++i) - { - glm::uint Return = bitfieldReverseUint32(Data32[i].Value); - - bool Compare = Data32[i].Return == Return; - - if(Data32[i].Result == SUCCESS) - Error += Compare ? 0 : 1; - else - Error += Compare ? 1 : 0; - } - - return Error; - } - - int test32_bitfieldReverseOps() - { - int Error = 0; - std::size_t const Count = sizeof(Data32) / sizeof(typeU32); - - for(std::size_t i = 0; i < Count; ++i) - { - glm::uint Return = bitfieldReverseOps(Data32[i].Value); - - bool Compare = Data32[i].Return == Return; - - if(Data32[i].Result == SUCCESS) - Error += Compare ? 0 : 1; - else - Error += Compare ? 1 : 0; - } - - return Error; - } - - int test64_bitfieldReverse() - { - int Error = 0; - std::size_t const Count = sizeof(Data64) / sizeof(typeU64); - - for(std::size_t i = 0; i < Count; ++i) - { - glm::uint64 Return = glm::bitfieldReverse(Data64[i].Value); - - bool Compare = Data64[i].Return == Return; - - if(Data64[i].Result == SUCCESS) - Error += Compare ? 0 : 1; - else - Error += Compare ? 1 : 0; - } - - return Error; - } - - int test64_bitfieldReverseLoop() - { - int Error = 0; - std::size_t const Count = sizeof(Data64) / sizeof(typeU64); - - for(std::size_t i = 0; i < Count; ++i) - { - glm::uint64 Return = bitfieldReverseLoop(Data64[i].Value); - - bool Compare = Data64[i].Return == Return; - - if(Data32[i].Result == SUCCESS) - Error += Compare ? 0 : 1; - else - Error += Compare ? 1 : 0; - } - - return Error; - } - - int test64_bitfieldReverseUint64() - { - int Error = 0; - std::size_t const Count = sizeof(Data64) / sizeof(typeU64); - - for(std::size_t i = 0; i < Count; ++i) - { - glm::uint64 Return = bitfieldReverseUint64(Data64[i].Value); - - bool Compare = Data64[i].Return == Return; - - if(Data64[i].Result == SUCCESS) - Error += Compare ? 0 : 1; - else - Error += Compare ? 1 : 0; - } - - return Error; - } - - int test64_bitfieldReverseOps() - { - int Error = 0; - std::size_t const Count = sizeof(Data64) / sizeof(typeU64); - - for(std::size_t i = 0; i < Count; ++i) - { - glm::uint64 Return = bitfieldReverseOps(Data64[i].Value); - - bool Compare = Data64[i].Return == Return; - - if(Data64[i].Result == SUCCESS) - Error += Compare ? 0 : 1; - else - Error += Compare ? 1 : 0; - } - - return Error; - } - - int test() - { - int Error = 0; - - Error += test32_bitfieldReverse(); - Error += test32_bitfieldReverseLoop(); - Error += test32_bitfieldReverseUint32(); - Error += test32_bitfieldReverseOps(); - - Error += test64_bitfieldReverse(); - Error += test64_bitfieldReverseLoop(); - Error += test64_bitfieldReverseUint64(); - Error += test64_bitfieldReverseOps(); - - return Error; - } - - int perf32(glm::uint32 Count) - { - int Error = 0; - - std::vector Data; - Data.resize(static_cast(Count)); - - std::clock_t Timestamps0 = std::clock(); - - for(glm::uint32 k = 0; k < Count; ++k) - Data[k] = glm::bitfieldReverse(k); - - std::clock_t Timestamps1 = std::clock(); - - for(glm::uint32 k = 0; k < Count; ++k) - Data[k] = bitfieldReverseLoop(k); - - std::clock_t Timestamps2 = std::clock(); - - for(glm::uint32 k = 0; k < Count; ++k) - Data[k] = bitfieldReverseUint32(k); - - std::clock_t Timestamps3 = std::clock(); - - for(glm::uint32 k = 0; k < Count; ++k) - Data[k] = bitfieldReverseOps(k); - - std::clock_t Timestamps4 = std::clock(); - - std::printf("glm::bitfieldReverse: %d clocks\n", static_cast(Timestamps1 - Timestamps0)); - std::printf("bitfieldReverseLoop: %d clocks\n", static_cast(Timestamps2 - Timestamps1)); - std::printf("bitfieldReverseUint32: %d clocks\n", static_cast(Timestamps3 - Timestamps2)); - std::printf("bitfieldReverseOps: %d clocks\n", static_cast(Timestamps4 - Timestamps3)); - - return Error; - } - - int perf64(glm::uint64 Count) - { - int Error = 0; - - std::vector Data; - Data.resize(static_cast(Count)); - - std::clock_t Timestamps0 = std::clock(); - - for(glm::uint32 k = 0; k < Count; ++k) - Data[k] = glm::bitfieldReverse(k); - - std::clock_t Timestamps1 = std::clock(); - - for(glm::uint64 k = 0; k < Count; ++k) - Data[k] = bitfieldReverseLoop(k); - - std::clock_t Timestamps2 = std::clock(); - - for(glm::uint64 k = 0; k < Count; ++k) - Data[k] = bitfieldReverseUint64(k); - - std::clock_t Timestamps3 = std::clock(); - - for(glm::uint64 k = 0; k < Count; ++k) - Data[k] = bitfieldReverseOps(k); - - std::clock_t Timestamps4 = std::clock(); - - std::printf("glm::bitfieldReverse - 64: %d clocks\n", static_cast(Timestamps1 - Timestamps0)); - std::printf("bitfieldReverseLoop - 64: %d clocks\n", static_cast(Timestamps2 - Timestamps1)); - std::printf("bitfieldReverseUint - 64: %d clocks\n", static_cast(Timestamps3 - Timestamps2)); - std::printf("bitfieldReverseOps - 64: %d clocks\n", static_cast(Timestamps4 - Timestamps3)); - - return Error; - } - - int perf(std::size_t Samples) - { - int Error = 0; - - Error += perf32(static_cast(Samples)); - Error += perf64(static_cast(Samples)); - - return Error; - } -}//bitfieldReverse - -namespace findMSB -{ - template - struct type - { - genType Value; - retType Return; - }; - -# if GLM_HAS_BITSCAN_WINDOWS - template - GLM_FUNC_QUALIFIER int findMSB_intrinsic(genIUType Value) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); - - if(Value == 0) - return -1; - - unsigned long Result(0); - _BitScanReverse(&Result, Value); - return int(Result); - } -# endif//GLM_HAS_BITSCAN_WINDOWS - -# if GLM_ARCH & GLM_ARCH_AVX && GLM_COMPILER & GLM_COMPILER_VC - template - GLM_FUNC_QUALIFIER int findMSB_avx(genIUType Value) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); - - if(Value == 0) - return -1; - - return int(_tzcnt_u32(Value)); - } -# endif//GLM_ARCH & GLM_ARCH_AVX && GLM_PLATFORM & GLM_PLATFORM_WINDOWS - - template - GLM_FUNC_QUALIFIER int findMSB_095(genIUType Value) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); - - if(Value == genIUType(0) || Value == genIUType(-1)) - return -1; - else if(Value > 0) - { - genIUType Bit = genIUType(-1); - for(genIUType tmp = Value; tmp > 0; tmp >>= 1, ++Bit){} - return Bit; - } - else //if(Value < 0) - { - int const BitCount(sizeof(genIUType) * 8); - int MostSignificantBit(-1); - for(int BitIndex(0); BitIndex < BitCount; ++BitIndex) - MostSignificantBit = (Value & (1 << BitIndex)) ? MostSignificantBit : BitIndex; - assert(MostSignificantBit >= 0); - return MostSignificantBit; - } - } - - template - GLM_FUNC_QUALIFIER int findMSB_nlz1(genIUType x) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findMSB' only accept integer values"); - - if (x == 0) - return -1; - - int n = 0; - if (x <= 0x0000FFFF) {n = n +16; x = x <<16;} - if (x <= 0x00FFFFFF) {n = n + 8; x = x << 8;} - if (x <= 0x0FFFFFFF) {n = n + 4; x = x << 4;} - if (x <= 0x3FFFFFFF) {n = n + 2; x = x << 2;} - if (x <= 0x7FFFFFFF) {n = n + 1;} - return 31 - n; - } - - int findMSB_nlz2(unsigned int x) - { - unsigned y; - int n; - - n = 32; - y = x >>16; if (y != 0) {n = n -16; x = y;} - y = x >> 8; if (y != 0) {n = n - 8; x = y;} - y = x >> 4; if (y != 0) {n = n - 4; x = y;} - y = x >> 2; if (y != 0) {n = n - 2; x = y;} - y = x >> 1; if (y != 0) return n - 2; - return 32 - (n - x); - } - - int findMSB_pop(unsigned int x) - { - x = x | (x >> 1); - x = x | (x >> 2); - x = x | (x >> 4); - x = x | (x >> 8); - x = x | (x >>16); - return 31 - glm::bitCount(~x); - } - - int perf_int(std::size_t Count) - { - type const Data[] = - { - {0x00000000, -1}, - {0x00000001, 0}, - {0x00000002, 1}, - {0x00000003, 1}, - {0x00000004, 2}, - {0x00000005, 2}, - {0x00000007, 2}, - {0x00000008, 3}, - {0x00000010, 4}, - {0x00000020, 5}, - {0x00000040, 6}, - {0x00000080, 7}, - {0x00000100, 8}, - {0x00000200, 9}, - {0x00000400, 10}, - {0x00000800, 11}, - {0x00001000, 12}, - {0x00002000, 13}, - {0x00004000, 14}, - {0x00008000, 15}, - {0x00010000, 16}, - {0x00020000, 17}, - {0x00040000, 18}, - {0x00080000, 19}, - {0x00100000, 20}, - {0x00200000, 21}, - {0x00400000, 22}, - {0x00800000, 23}, - {0x01000000, 24}, - {0x02000000, 25}, - {0x04000000, 26}, - {0x08000000, 27}, - {0x10000000, 28}, - {0x20000000, 29}, - {0x40000000, 30} - }; - - int Error(0); - - std::clock_t Timestamps0 = std::clock(); - - for(std::size_t k = 0; k < Count; ++k) - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - int Result = glm::findMSB(Data[i].Value); - Error += Data[i].Return == Result ? 0 : 1; - } - - std::clock_t Timestamps1 = std::clock(); - - for(std::size_t k = 0; k < Count; ++k) - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - int Result = findMSB_nlz1(Data[i].Value); - Error += Data[i].Return == Result ? 0 : 1; - } - - std::clock_t Timestamps2 = std::clock(); - - for(std::size_t k = 0; k < Count; ++k) - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - int Result = findMSB_nlz2(Data[i].Value); - Error += Data[i].Return == Result ? 0 : 1; - } - - std::clock_t Timestamps3 = std::clock(); - - for(std::size_t k = 0; k < Count; ++k) - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - int Result = findMSB_095(Data[i].Value); - Error += Data[i].Return == Result ? 0 : 1; - } - - std::clock_t Timestamps4 = std::clock(); - -# if GLM_HAS_BITSCAN_WINDOWS - for(std::size_t k = 0; k < Count; ++k) - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - int Result = findMSB_intrinsic(Data[i].Value); - Error += Data[i].Return == Result ? 0 : 1; - } -# endif//GLM_HAS_BITSCAN_WINDOWS - - std::clock_t Timestamps5 = std::clock(); - - for(std::size_t k = 0; k < Count; ++k) - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - int Result = findMSB_pop(Data[i].Value); - Error += Data[i].Return == Result ? 0 : 1; - } - - std::clock_t Timestamps6 = std::clock(); - -# if GLM_ARCH & GLM_ARCH_AVX && GLM_COMPILER & GLM_COMPILER_VC - for(std::size_t k = 0; k < Count; ++k) - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - int Result = findMSB_avx(Data[i].Value); - Error += Data[i].Return == Result ? 0 : 1; - } -# endif - - std::clock_t Timestamps7 = std::clock(); - - std::printf("glm::findMSB: %d clocks\n", static_cast(Timestamps1 - Timestamps0)); - std::printf("findMSB - nlz1: %d clocks\n", static_cast(Timestamps2 - Timestamps1)); - std::printf("findMSB - nlz2: %d clocks\n", static_cast(Timestamps3 - Timestamps2)); - std::printf("findMSB - 0.9.5: %d clocks\n", static_cast(Timestamps4 - Timestamps3)); - -# if GLM_HAS_BITSCAN_WINDOWS - std::printf("findMSB - intrinsics: %d clocks\n", static_cast(Timestamps5 - Timestamps4)); -# endif//GLM_HAS_BITSCAN_WINDOWS - std::printf("findMSB - pop: %d clocks\n", static_cast(Timestamps6 - Timestamps5)); - -# if GLM_ARCH & GLM_ARCH_AVX && GLM_COMPILER & GLM_COMPILER_VC - std::printf("findMSB - avx tzcnt: %d clocks\n", static_cast(Timestamps7 - Timestamps6)); -# endif//GLM_ARCH & GLM_ARCH_AVX && GLM_PLATFORM & GLM_PLATFORM_WINDOWS - - return Error; - } - - int test_ivec4() - { - type const Data[] = - { - {glm::ivec4(0x00000000), glm::ivec4(-1)}, - {glm::ivec4(0x00000001), glm::ivec4( 0)}, - {glm::ivec4(0x00000002), glm::ivec4( 1)}, - {glm::ivec4(0x00000003), glm::ivec4( 1)}, - {glm::ivec4(0x00000004), glm::ivec4( 2)}, - {glm::ivec4(0x00000005), glm::ivec4( 2)}, - {glm::ivec4(0x00000007), glm::ivec4( 2)}, - {glm::ivec4(0x00000008), glm::ivec4( 3)}, - {glm::ivec4(0x00000010), glm::ivec4( 4)}, - {glm::ivec4(0x00000020), glm::ivec4( 5)}, - {glm::ivec4(0x00000040), glm::ivec4( 6)}, - {glm::ivec4(0x00000080), glm::ivec4( 7)}, - {glm::ivec4(0x00000100), glm::ivec4( 8)}, - {glm::ivec4(0x00000200), glm::ivec4( 9)}, - {glm::ivec4(0x00000400), glm::ivec4(10)}, - {glm::ivec4(0x00000800), glm::ivec4(11)}, - {glm::ivec4(0x00001000), glm::ivec4(12)}, - {glm::ivec4(0x00002000), glm::ivec4(13)}, - {glm::ivec4(0x00004000), glm::ivec4(14)}, - {glm::ivec4(0x00008000), glm::ivec4(15)}, - {glm::ivec4(0x00010000), glm::ivec4(16)}, - {glm::ivec4(0x00020000), glm::ivec4(17)}, - {glm::ivec4(0x00040000), glm::ivec4(18)}, - {glm::ivec4(0x00080000), glm::ivec4(19)}, - {glm::ivec4(0x00100000), glm::ivec4(20)}, - {glm::ivec4(0x00200000), glm::ivec4(21)}, - {glm::ivec4(0x00400000), glm::ivec4(22)}, - {glm::ivec4(0x00800000), glm::ivec4(23)}, - {glm::ivec4(0x01000000), glm::ivec4(24)}, - {glm::ivec4(0x02000000), glm::ivec4(25)}, - {glm::ivec4(0x04000000), glm::ivec4(26)}, - {glm::ivec4(0x08000000), glm::ivec4(27)}, - {glm::ivec4(0x10000000), glm::ivec4(28)}, - {glm::ivec4(0x20000000), glm::ivec4(29)}, - {glm::ivec4(0x40000000), glm::ivec4(30)} - }; - - int Error(0); - - for(std::size_t i = 0; i < sizeof(Data) / sizeof(type); ++i) - { - glm::ivec4 Result0 = glm::findMSB(Data[i].Value); - Error += glm::all(glm::equal(Data[i].Return, Result0)) ? 0 : 1; - } - - return Error; - } - - int test_int() - { - typedef type entry; - - entry const Data[] = - { - {0x00000000, -1}, - {0x00000001, 0}, - {0x00000002, 1}, - {0x00000003, 1}, - {0x00000004, 2}, - {0x00000005, 2}, - {0x00000007, 2}, - {0x00000008, 3}, - {0x00000010, 4}, - {0x00000020, 5}, - {0x00000040, 6}, - {0x00000080, 7}, - {0x00000100, 8}, - {0x00000200, 9}, - {0x00000400, 10}, - {0x00000800, 11}, - {0x00001000, 12}, - {0x00002000, 13}, - {0x00004000, 14}, - {0x00008000, 15}, - {0x00010000, 16}, - {0x00020000, 17}, - {0x00040000, 18}, - {0x00080000, 19}, - {0x00100000, 20}, - {0x00200000, 21}, - {0x00400000, 22}, - {0x00800000, 23}, - {0x01000000, 24}, - {0x02000000, 25}, - {0x04000000, 26}, - {0x08000000, 27}, - {0x10000000, 28}, - {0x20000000, 29}, - {0x40000000, 30} - }; - - int Error(0); - - for(std::size_t i = 0; i < sizeof(Data) / sizeof(entry); ++i) - { - int Result0 = glm::findMSB(Data[i].Value); - Error += Data[i].Return == Result0 ? 0 : 1; - } - - for(std::size_t i = 0; i < sizeof(Data) / sizeof(entry); ++i) - { - int Result0 = findMSB_nlz1(Data[i].Value); - Error += Data[i].Return == Result0 ? 0 : 1; - } -/* - for(std::size_t i = 0; i < sizeof(Data) / sizeof(entry); ++i) - { - int Result0 = findMSB_nlz2(Data[i].Value); - Error += Data[i].Return == Result0 ? 0 : 1; - } -*/ - for(std::size_t i = 0; i < sizeof(Data) / sizeof(entry); ++i) - { - int Result0 = findMSB_095(Data[i].Value); - Error += Data[i].Return == Result0 ? 0 : 1; - } - -# if GLM_HAS_BITSCAN_WINDOWS - for(std::size_t i = 0; i < sizeof(Data) / sizeof(entry); ++i) - { - int Result0 = findMSB_intrinsic(Data[i].Value); - Error += Data[i].Return == Result0 ? 0 : 1; - } -# endif//GLM_HAS_BITSCAN_WINDOWS - - for(std::size_t i = 0; i < sizeof(Data) / sizeof(entry); ++i) - { - int Result0 = findMSB_pop(Data[i].Value); - Error += Data[i].Return == Result0 ? 0 : 1; - } - - return Error; - } - - int test() - { - int Error(0); - - Error += test_ivec4(); - Error += test_int(); - - return Error; - } - - int perf(std::size_t Samples) - { - int Error(0); - - Error += perf_int(Samples); - - return Error; - } -}//findMSB - -namespace findLSB -{ - template - struct type - { - genType Value; - retType Return; - }; - - typedef type entry; - - entry const DataI32[] = - { - {0x00000001, 0}, - {0x00000003, 0}, - {0x00000002, 1}, - // {0x80000000, 31}, // Clang generates an error with this - {0x00010000, 16}, - {0x7FFF0000, 16}, - {0x7F000000, 24}, - {0x7F00FF00, 8}, - {0x00000000, -1} - }; - -# if GLM_HAS_BITSCAN_WINDOWS - template - GLM_FUNC_QUALIFIER int findLSB_intrinsic(genIUType Value) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findLSB' only accept integer values"); - - if(Value == 0) - return -1; - - unsigned long Result(0); - _BitScanForward(&Result, Value); - return int(Result); - } -# endif - - template - GLM_FUNC_QUALIFIER int findLSB_095(genIUType Value) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'findLSB' only accept integer values"); - if(Value == 0) - return -1; - - genIUType Bit; - for(Bit = genIUType(0); !(Value & (1 << Bit)); ++Bit){} - return Bit; - } - - template - GLM_FUNC_QUALIFIER int findLSB_ntz2(genIUType x) - { - if(x == 0) - return -1; - - return glm::bitCount(~x & (x - static_cast(1))); - } - - template - GLM_FUNC_QUALIFIER int findLSB_branchfree(genIUType x) - { - bool IsNull(x == 0); - int const Keep(!IsNull); - int const Discard(IsNull); - - return static_cast(glm::bitCount(~x & (x - static_cast(1)))) * Keep + Discard * -1; - } - - int test_int() - { - int Error(0); - - for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i) - { - int Result = glm::findLSB(DataI32[i].Value); - Error += DataI32[i].Return == Result ? 0 : 1; - } - - for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i) - { - int Result = findLSB_095(DataI32[i].Value); - Error += DataI32[i].Return == Result ? 0 : 1; - } - -# if GLM_HAS_BITSCAN_WINDOWS - for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i) - { - int Result = findLSB_intrinsic(DataI32[i].Value); - Error += DataI32[i].Return == Result ? 0 : 1; - } -# endif - - for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i) - { - int Result = findLSB_ntz2(DataI32[i].Value); - Error += DataI32[i].Return == Result ? 0 : 1; - } - - for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i) - { - int Result = findLSB_branchfree(DataI32[i].Value); - Error += DataI32[i].Return == Result ? 0 : 1; - } - - return Error; - } - - int test() - { - int Error(0); - - Error += test_int(); - - return Error; - } - - int perf_int(std::size_t Count) - { - int Error(0); - - std::clock_t Timestamps0 = std::clock(); - - for(std::size_t k = 0; k < Count; ++k) - for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i) - { - int Result = glm::findLSB(DataI32[i].Value); - Error += DataI32[i].Return == Result ? 0 : 1; - } - - std::clock_t Timestamps1 = std::clock(); - - for(std::size_t k = 0; k < Count; ++k) - for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i) - { - int Result = findLSB_095(DataI32[i].Value); - Error += DataI32[i].Return == Result ? 0 : 1; - } - - std::clock_t Timestamps2 = std::clock(); - -# if GLM_HAS_BITSCAN_WINDOWS - for(std::size_t k = 0; k < Count; ++k) - for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i) - { - int Result = findLSB_intrinsic(DataI32[i].Value); - Error += DataI32[i].Return == Result ? 0 : 1; - } -# endif - - std::clock_t Timestamps3 = std::clock(); - - for(std::size_t k = 0; k < Count; ++k) - for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i) - { - int Result = findLSB_ntz2(DataI32[i].Value); - Error += DataI32[i].Return == Result ? 0 : 1; - } - - std::clock_t Timestamps4 = std::clock(); - - for(std::size_t k = 0; k < Count; ++k) - for(std::size_t i = 0; i < sizeof(DataI32) / sizeof(entry); ++i) - { - int Result = findLSB_branchfree(DataI32[i].Value); - Error += DataI32[i].Return == Result ? 0 : 1; - } - - std::clock_t Timestamps5 = std::clock(); - - std::printf("glm::findLSB: %d clocks\n", static_cast(Timestamps1 - Timestamps0)); - std::printf("findLSB - 0.9.5: %d clocks\n", static_cast(Timestamps2 - Timestamps1)); - -# if GLM_HAS_BITSCAN_WINDOWS - std::printf("findLSB - intrinsics: %d clocks\n", static_cast(Timestamps3 - Timestamps2)); -# endif - - std::printf("findLSB - ntz2: %d clocks\n", static_cast(Timestamps4 - Timestamps3)); - std::printf("findLSB - branchfree: %d clocks\n", static_cast(Timestamps5 - Timestamps4)); - - return Error; - } - - int perf(std::size_t Samples) - { - int Error(0); - - Error += perf_int(Samples); - - return Error; - } -}//findLSB - -namespace uaddCarry -{ - int test() - { - int Error(0); - - { - glm::uint x = std::numeric_limits::max(); - glm::uint y = 0; - glm::uint Carry = 0; - glm::uint Result = glm::uaddCarry(x, y, Carry); - - Error += Carry == 0 ? 0 : 1; - Error += Result == std::numeric_limits::max() ? 0 : 1; - } - - { - glm::uint x = std::numeric_limits::max(); - glm::uint y = 1; - glm::uint Carry = 0; - glm::uint Result = glm::uaddCarry(x, y, Carry); - - Error += Carry == 1 ? 0 : 1; - Error += Result == 0 ? 0 : 1; - } - - { - glm::uvec1 x(std::numeric_limits::max()); - glm::uvec1 y(0); - glm::uvec1 Carry(0); - glm::uvec1 Result(glm::uaddCarry(x, y, Carry)); - - Error += glm::all(glm::equal(Carry, glm::uvec1(0))) ? 0 : 1; - Error += glm::all(glm::equal(Result, glm::uvec1(std::numeric_limits::max()))) ? 0 : 1; - } - - { - glm::uvec1 x(std::numeric_limits::max()); - glm::uvec1 y(1); - glm::uvec1 Carry(0); - glm::uvec1 Result(glm::uaddCarry(x, y, Carry)); - - Error += glm::all(glm::equal(Carry, glm::uvec1(1))) ? 0 : 1; - Error += glm::all(glm::equal(Result, glm::uvec1(0))) ? 0 : 1; - } - - return Error; - } -}//namespace uaddCarry - -namespace usubBorrow -{ - int test() - { - int Error(0); - - { - glm::uint x = 16; - glm::uint y = 17; - glm::uint Borrow = 0; - glm::uint Result = glm::usubBorrow(x, y, Borrow); - - Error += Borrow == 1 ? 0 : 1; - Error += Result == 1 ? 0 : 1; - } - - { - glm::uvec1 x(16); - glm::uvec1 y(17); - glm::uvec1 Borrow(0); - glm::uvec1 Result(glm::usubBorrow(x, y, Borrow)); - - Error += glm::all(glm::equal(Borrow, glm::uvec1(1))) ? 0 : 1; - Error += glm::all(glm::equal(Result, glm::uvec1(1))) ? 0 : 1; - } - - { - glm::uvec2 x(16); - glm::uvec2 y(17); - glm::uvec2 Borrow(0); - glm::uvec2 Result(glm::usubBorrow(x, y, Borrow)); - - Error += glm::all(glm::equal(Borrow, glm::uvec2(1))) ? 0 : 1; - Error += glm::all(glm::equal(Result, glm::uvec2(1))) ? 0 : 1; - } - - { - glm::uvec3 x(16); - glm::uvec3 y(17); - glm::uvec3 Borrow(0); - glm::uvec3 Result(glm::usubBorrow(x, y, Borrow)); - - Error += glm::all(glm::equal(Borrow, glm::uvec3(1))) ? 0 : 1; - Error += glm::all(glm::equal(Result, glm::uvec3(1))) ? 0 : 1; - } - - { - glm::uvec4 x(16); - glm::uvec4 y(17); - glm::uvec4 Borrow(0); - glm::uvec4 Result(glm::usubBorrow(x, y, Borrow)); - - Error += glm::all(glm::equal(Borrow, glm::uvec4(1))) ? 0 : 1; - Error += glm::all(glm::equal(Result, glm::uvec4(1))) ? 0 : 1; - } - - return Error; - } -}//namespace usubBorrow - -namespace umulExtended -{ - int test() - { - int Error(0); - - { - glm::uint x = 2; - glm::uint y = 3; - glm::uint msb = 0; - glm::uint lsb = 0; - glm::umulExtended(x, y, msb, lsb); - - Error += msb == 0 ? 0 : 1; - Error += lsb == 6 ? 0 : 1; - } - - { - glm::uvec1 x(2); - glm::uvec1 y(3); - glm::uvec1 msb(0); - glm::uvec1 lsb(0); - glm::umulExtended(x, y, msb, lsb); - - Error += glm::all(glm::equal(msb, glm::uvec1(0))) ? 0 : 1; - Error += glm::all(glm::equal(lsb, glm::uvec1(6))) ? 0 : 1; - } - - { - glm::uvec2 x(2); - glm::uvec2 y(3); - glm::uvec2 msb(0); - glm::uvec2 lsb(0); - glm::umulExtended(x, y, msb, lsb); - - Error += glm::all(glm::equal(msb, glm::uvec2(0))) ? 0 : 1; - Error += glm::all(glm::equal(lsb, glm::uvec2(6))) ? 0 : 1; - } - - { - glm::uvec3 x(2); - glm::uvec3 y(3); - glm::uvec3 msb(0); - glm::uvec3 lsb(0); - glm::umulExtended(x, y, msb, lsb); - - Error += glm::all(glm::equal(msb, glm::uvec3(0))) ? 0 : 1; - Error += glm::all(glm::equal(lsb, glm::uvec3(6))) ? 0 : 1; - } - - { - glm::uvec4 x(2); - glm::uvec4 y(3); - glm::uvec4 msb(0); - glm::uvec4 lsb(0); - glm::umulExtended(x, y, msb, lsb); - - Error += glm::all(glm::equal(msb, glm::uvec4(0))) ? 0 : 1; - Error += glm::all(glm::equal(lsb, glm::uvec4(6))) ? 0 : 1; - } - - return Error; - } -}//namespace umulExtended - -namespace imulExtended -{ - int test() - { - int Error(0); - - { - int x = 2; - int y = 3; - int msb = 0; - int lsb = 0; - glm::imulExtended(x, y, msb, lsb); - - Error += msb == 0 ? 0 : 1; - Error += lsb == 6 ? 0 : 1; - } - - { - glm::ivec1 x(2); - glm::ivec1 y(3); - glm::ivec1 msb(0); - glm::ivec1 lsb(0); - glm::imulExtended(x, y, msb, lsb); - - Error += glm::all(glm::equal(msb, glm::ivec1(0))) ? 0 : 1; - Error += glm::all(glm::equal(lsb, glm::ivec1(6))) ? 0 : 1; - } - - { - glm::ivec2 x(2); - glm::ivec2 y(3); - glm::ivec2 msb(0); - glm::ivec2 lsb(0); - glm::imulExtended(x, y, msb, lsb); - - Error += glm::all(glm::equal(msb, glm::ivec2(0))) ? 0 : 1; - Error += glm::all(glm::equal(lsb, glm::ivec2(6))) ? 0 : 1; - } - - { - glm::ivec3 x(2); - glm::ivec3 y(3); - glm::ivec3 msb(0); - glm::ivec3 lsb(0); - glm::imulExtended(x, y, msb, lsb); - - Error += glm::all(glm::equal(msb, glm::ivec3(0))) ? 0 : 1; - Error += glm::all(glm::equal(lsb, glm::ivec3(6))) ? 0 : 1; - } - - { - glm::ivec4 x(2); - glm::ivec4 y(3); - glm::ivec4 msb(0); - glm::ivec4 lsb(0); - glm::imulExtended(x, y, msb, lsb); - - Error += glm::all(glm::equal(msb, glm::ivec4(0))) ? 0 : 1; - Error += glm::all(glm::equal(lsb, glm::ivec4(6))) ? 0 : 1; - } - - return Error; - } -}//namespace imulExtended - -namespace bitCount -{ - template - struct type - { - genType Value; - genType Return; - }; - - type const DataI32[] = - { - {0x00000001, 1}, - {0x00000003, 2}, - {0x00000002, 1}, - {0x7fffffff, 31}, - {0x00000000, 0} - }; - - template - inline int bitCount_if(T v) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitCount' only accept integer values"); - - int Count(0); - for(T i = 0, n = static_cast(sizeof(T) * 8); i < n; ++i) - { - if(v & static_cast(1 << i)) - ++Count; - } - return Count; - } - - template - inline int bitCount_vec(T v) - { - GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitCount' only accept integer values"); - - int Count(0); - for(T i = 0, n = static_cast(sizeof(T) * 8); i < n; ++i) - { - Count += static_cast((v >> i) & static_cast(1)); - } - return Count; - } - - template - struct compute_bitfieldBitCountStep - { - template class vecType> - GLM_FUNC_QUALIFIER static vecType call(vecType const & v, T, T) - { - return v; - } - }; - - template <> - struct compute_bitfieldBitCountStep - { - template class vecType> - GLM_FUNC_QUALIFIER static vecType call(vecType const & v, T Mask, T Shift) - { - return (v & Mask) + ((v >> Shift) & Mask); - } - }; - - template class vecType> - GLM_FUNC_QUALIFIER vecType bitCount_bitfield(vecType const & v) - { - vecType::type, P> x(*reinterpret_cast::type, P> const *>(&v)); - x = compute_bitfieldBitCountStep= 2>::call(x, typename glm::detail::make_unsigned::type(0x5555555555555555ull), typename glm::detail::make_unsigned::type( 1)); - x = compute_bitfieldBitCountStep= 4>::call(x, typename glm::detail::make_unsigned::type(0x3333333333333333ull), typename glm::detail::make_unsigned::type( 2)); - x = compute_bitfieldBitCountStep= 8>::call(x, typename glm::detail::make_unsigned::type(0x0F0F0F0F0F0F0F0Full), typename glm::detail::make_unsigned::type( 4)); - x = compute_bitfieldBitCountStep= 16>::call(x, typename glm::detail::make_unsigned::type(0x00FF00FF00FF00FFull), typename glm::detail::make_unsigned::type( 8)); - x = compute_bitfieldBitCountStep= 32>::call(x, typename glm::detail::make_unsigned::type(0x0000FFFF0000FFFFull), typename glm::detail::make_unsigned::type(16)); - x = compute_bitfieldBitCountStep= 64>::call(x, typename glm::detail::make_unsigned::type(0x00000000FFFFFFFFull), typename glm::detail::make_unsigned::type(32)); - return vecType(x); - } - - template - GLM_FUNC_QUALIFIER int bitCount_bitfield(genType x) - { - return bitCount_bitfield(glm::tvec1(x)).x; - } - - int perf(std::size_t Size) - { - int Error(0); - - std::vector v; - v.resize(Size); - - std::vector w; - w.resize(Size); - - - std::clock_t TimestampsA = std::clock(); - - // bitCount - TimeIf - { - for(std::size_t i = 0, n = v.size(); i < n; ++i) - v[i] = bitCount_if(static_cast(i)); - } - - std::clock_t TimestampsB = std::clock(); - - // bitCount - TimeVec - { - for(std::size_t i = 0, n = v.size(); i < n; ++i) - v[i] = bitCount_vec(i); - } - - std::clock_t TimestampsC = std::clock(); - - // bitCount - TimeDefault - { - for(std::size_t i = 0, n = v.size(); i < n; ++i) - v[i] = glm::bitCount(i); - } - - std::clock_t TimestampsD = std::clock(); - - // bitCount - TimeVec4 - { - for(std::size_t i = 0, n = v.size(); i < n; ++i) - w[i] = glm::bitCount(glm::ivec4(static_cast(i))); - } - - std::clock_t TimestampsE = std::clock(); - - { - for(std::size_t i = 0, n = v.size(); i < n; ++i) - v[i] = bitCount_bitfield(static_cast(i)); - } - - std::clock_t TimestampsF = std::clock(); - - std::printf("bitCount - TimeIf %d\n", static_cast(TimestampsB - TimestampsA)); - std::printf("bitCount - TimeVec %d\n", static_cast(TimestampsC - TimestampsB)); - std::printf("bitCount - TimeDefault %d\n", static_cast(TimestampsD - TimestampsC)); - std::printf("bitCount - TimeVec4 %d\n", static_cast(TimestampsE - TimestampsD)); - std::printf("bitCount - bitfield %d\n", static_cast(TimestampsF - TimestampsE)); - - return Error; - } - - int test() - { - int Error(0); - - for(std::size_t i = 0, n = sizeof(DataI32) / sizeof(type); i < n; ++i) - { - int ResultA = glm::bitCount(DataI32[i].Value); - int ResultB = bitCount_if(DataI32[i].Value); - int ResultC = bitCount_vec(DataI32[i].Value); - int ResultE = bitCount_bitfield(DataI32[i].Value); - - Error += DataI32[i].Return == ResultA ? 0 : 1; - Error += DataI32[i].Return == ResultB ? 0 : 1; - Error += DataI32[i].Return == ResultC ? 0 : 1; - Error += DataI32[i].Return == ResultE ? 0 : 1; - - assert(!Error); - } - - return Error; - } -}//bitCount - -int main() -{ - int Error = 0; - - Error += ::bitCount::test(); - Error += ::bitfieldReverse::test(); - Error += ::findMSB::test(); - Error += ::findLSB::test(); - Error += ::umulExtended::test(); - Error += ::imulExtended::test(); - Error += ::uaddCarry::test(); - Error += ::usubBorrow::test(); - Error += ::bitfieldInsert::test(); - Error += ::bitfieldExtract::test(); - -# ifdef NDEBUG - std::size_t const Samples = 1000; - ::bitCount::perf(Samples); - ::bitfieldReverse::perf(Samples); - ::findMSB::perf(Samples); - ::findLSB::perf(Samples); -# endif - - return Error; -} diff --git a/VRVideoPlayer/external/glm/test/core/core_func_integer_bit_count.cpp b/VRVideoPlayer/external/glm/test/core/core_func_integer_bit_count.cpp deleted file mode 100644 index f8cba2c..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_func_integer_bit_count.cpp +++ /dev/null @@ -1,291 +0,0 @@ -// This has the programs for computing the number of 1-bits -// in a word, or byte, etc. -// Max line length is 57, to fit in hacker.book. -#include -#include //To define "exit", req'd by XLC. -#include - -unsigned rotatel(unsigned x, int n) -{ - if ((unsigned)n > 63) {printf("rotatel, n out of range.\n"); exit(1);} - return (x << n) | (x >> (32 - n)); -} - -int pop0(unsigned x) -{ - x = (x & 0x55555555) + ((x >> 1) & 0x55555555); - x = (x & 0x33333333) + ((x >> 2) & 0x33333333); - x = (x & 0x0F0F0F0F) + ((x >> 4) & 0x0F0F0F0F); - x = (x & 0x00FF00FF) + ((x >> 8) & 0x00FF00FF); - x = (x & 0x0000FFFF) + ((x >>16) & 0x0000FFFF); - return x; -} - -int pop1(unsigned x) -{ - x = x - ((x >> 1) & 0x55555555); - x = (x & 0x33333333) + ((x >> 2) & 0x33333333); - x = (x + (x >> 4)) & 0x0F0F0F0F; - x = x + (x >> 8); - x = x + (x >> 16); - return x & 0x0000003F; -} -/* Note: an alternative to the last three executable lines above is: - return x*0x01010101 >> 24; -if your machine has a fast multiplier (suggested by Jari Kirma). */ - -int pop2(unsigned x) -{ - unsigned n; - - n = (x >> 1) & 033333333333; // Count bits in - x = x - n; // each 3-bit - n = (n >> 1) & 033333333333; // field. - x = x - n; - x = (x + (x >> 3)) & 030707070707; // 6-bit sums. - return x%63; // Add 6-bit sums. -} - -/* An alternative to the "return" statement above is: - return ((x * 0404040404) >> 26) + // Add 6-bit sums. - (x >> 30); -which runs faster on most machines (suggested by Norbert Juffa). */ - -int pop3(unsigned x) -{ - unsigned n; - - n = (x >> 1) & 0x77777777; // Count bits in - x = x - n; // each 4-bit - n = (n >> 1) & 0x77777777; // field. - x = x - n; - n = (n >> 1) & 0x77777777; - x = x - n; - x = (x + (x >> 4)) & 0x0F0F0F0F; // Get byte sums. - x = x*0x01010101; // Add the bytes. - return x >> 24; -} - -int pop4(unsigned x) -{ - int n; - - n = 0; - while (x != 0) { - n = n + 1; - x = x & (x - 1); - } - return n; -} - -int pop5(unsigned x) -{ - int i, sum; - - // Rotate and sum method // Shift right & subtract - - sum = x; // sum = x; - for (i = 1; i <= 31; i++) { // while (x != 0) { - x = rotatel(x, 1); // x = x >> 1; - sum = sum + x; // sum = sum - x; - } // } - return -sum; // return sum; -} - -int pop5a(unsigned x) -{ - int sum; - - // Shift right & subtract - - sum = x; - while (x != 0) { - x = x >> 1; - sum = sum - x; - } - return sum; -} - -int pop6(unsigned x) -{ // Table lookup. - static char table[256] = { - 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8}; - - return table[x & 0xFF] + - table[(x >> 8) & 0xFF] + - table[(x >> 16) & 0xFF] + - table[(x >> 24)]; -} - -// The following works only for 8-bit quantities. -int pop7(unsigned x) -{ - x = x*0x08040201; // Make 4 copies. - x = x >> 3; // So next step hits proper bits. - x = x & 0x11111111; // Every 4th bit. - x = x*0x11111111; // Sum the digits (each 0 or 1). - x = x >> 28; // Position the result. - return x; -} - -// The following works only for 7-bit quantities. -int pop8(unsigned x) -{ - x = x*0x02040810; // Make 4 copies, left-adjusted. - x = x & 0x11111111; // Every 4th bit. - x = x*0x11111111; // Sum the digits (each 0 or 1). - x = x >> 28; // Position the result. - return x; -} - -// The following works only for 15-bit quantities. -int pop9(unsigned x) -{ - unsigned long long y; - y = x * 0x0002000400080010ULL; - y = y & 0x1111111111111111ULL; - y = y * 0x1111111111111111ULL; - y = y >> 60; - return y; -} - -int errors; -void error(int x, int y) -{ - errors = errors + 1; - printf("Error for x = %08x, got %08x\n", x, y); -} - -int main() -{ -# ifdef NDEBUG - - int i, n; - static unsigned test[] = {0,0, 1,1, 2,1, 3,2, 4,1, 5,2, 6,2, 7,3, - 8,1, 9,2, 10,2, 11,3, 12,2, 13,3, 14,3, 15,4, 16,1, 17,2, - 0x3F,6, 0x40,1, 0x41,2, 0x7f,7, 0x80,1, 0x81,2, 0xfe,7, 0xff,8, - 0x4000,1, 0x4001,2, 0x7000,3, 0x7fff,15, - 0x55555555,16, 0xAAAAAAAA, 16, 0xFF000000,8, 0xC0C0C0C0,8, - 0x0FFFFFF0,24, 0x80000000,1, 0xFFFFFFFF,32}; - - std::size_t const Count = 1000000; - - n = sizeof(test)/4; - - std::clock_t TimestampBeg = 0; - std::clock_t TimestampEnd = 0; - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (pop0(test[i]) != test[i+1]) error(test[i], pop0(test[i]));} - TimestampEnd = std::clock(); - - printf("pop0: %ld clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (pop1(test[i]) != test[i+1]) error(test[i], pop1(test[i]));} - TimestampEnd = std::clock(); - - printf("pop1: %ld clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (pop2(test[i]) != test[i+1]) error(test[i], pop2(test[i]));} - TimestampEnd = std::clock(); - - printf("pop2: %ld clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (pop3(test[i]) != test[i+1]) error(test[i], pop3(test[i]));} - TimestampEnd = std::clock(); - - printf("pop3: %ld clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (pop4(test[i]) != test[i+1]) error(test[i], pop4(test[i]));} - TimestampEnd = std::clock(); - - printf("pop4: %ld clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (pop5(test[i]) != test[i+1]) error(test[i], pop5(test[i]));} - TimestampEnd = std::clock(); - - printf("pop5: %ld clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (pop5a(test[i]) != test[i+1]) error(test[i], pop5a(test[i]));} - TimestampEnd = std::clock(); - - printf("pop5a: %ld clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (pop6(test[i]) != test[i+1]) error(test[i], pop6(test[i]));} - TimestampEnd = std::clock(); - - printf("pop6: %ld clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if ((test[i] & 0xffffff00) == 0) - if (pop7(test[i]) != test[i+1]) error(test[i], pop7(test[i]));} - TimestampEnd = std::clock(); - - printf("pop7: %ld clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if ((test[i] & 0xffffff80) == 0) - if (pop8(test[i]) != test[i+1]) error(test[i], pop8(test[i]));} - TimestampEnd = std::clock(); - - printf("pop8: %ld clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if ((test[i] & 0xffff8000) == 0) - if (pop9(test[i]) != test[i+1]) error(test[i], pop9(test[i]));} - TimestampEnd = std::clock(); - - printf("pop9: %ld clocks\n", TimestampEnd - TimestampBeg); - - if (errors == 0) - printf("Passed all %d cases.\n", sizeof(test)/8); - -# endif//NDEBUG -} diff --git a/VRVideoPlayer/external/glm/test/core/core_func_integer_find_lsb.cpp b/VRVideoPlayer/external/glm/test/core/core_func_integer_find_lsb.cpp deleted file mode 100644 index 69eb27c..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_func_integer_find_lsb.cpp +++ /dev/null @@ -1,400 +0,0 @@ -// This has the programs for computing the number of trailing zeros -// in a word. -// Max line length is 57, to fit in hacker.book. -#include -#include //To define "exit", req'd by XLC. -#include - -int nlz(unsigned x) { - int pop(unsigned x); - - x = x | (x >> 1); - x = x | (x >> 2); - x = x | (x >> 4); - x = x | (x >> 8); - x = x | (x >>16); - return pop(~x); -} - -int pop(unsigned x) { - x = x - ((x >> 1) & 0x55555555); - x = (x & 0x33333333) + ((x >> 2) & 0x33333333); - x = (x + (x >> 4)) & 0x0F0F0F0F; - x = x + (x << 8); - x = x + (x << 16); - return x >> 24; -} - -int ntz1(unsigned x) { - return 32 - nlz(~x & (x-1)); -} - -int ntz2(unsigned x) { - return pop(~x & (x - 1)); -} - -int ntz3(unsigned x) { - int n; - - if (x == 0) return(32); - n = 1; - if ((x & 0x0000FFFF) == 0) {n = n +16; x = x >>16;} - if ((x & 0x000000FF) == 0) {n = n + 8; x = x >> 8;} - if ((x & 0x0000000F) == 0) {n = n + 4; x = x >> 4;} - if ((x & 0x00000003) == 0) {n = n + 2; x = x >> 2;} - return n - (x & 1); -} - -int ntz4(unsigned x) { - unsigned y; - int n; - - if (x == 0) return 32; - n = 31; - y = x <<16; if (y != 0) {n = n -16; x = y;} - y = x << 8; if (y != 0) {n = n - 8; x = y;} - y = x << 4; if (y != 0) {n = n - 4; x = y;} - y = x << 2; if (y != 0) {n = n - 2; x = y;} - y = x << 1; if (y != 0) {n = n - 1;} - return n; -} - -int ntz4a(unsigned x) { - unsigned y; - int n; - - if (x == 0) return 32; - n = 31; - y = x <<16; if (y != 0) {n = n -16; x = y;} - y = x << 8; if (y != 0) {n = n - 8; x = y;} - y = x << 4; if (y != 0) {n = n - 4; x = y;} - y = x << 2; if (y != 0) {n = n - 2; x = y;} - n = n - ((x << 1) >> 31); - return n; -} - -int ntz5(char x) -{ - if (x & 15) { - if (x & 3) { - if (x & 1) return 0; - else return 1; - } - else if (x & 4) return 2; - else return 3; - } - else if (x & 0x30) { - if (x & 0x10) return 4; - else return 5; - } - else if (x & 0x40) return 6; - else if (x) return 7; - else return 8; -} - -int ntz6(unsigned x) { - int n; - - x = ~x & (x - 1); - n = 0; // n = 32; - while(x != 0) { // while (x != 0) { - n = n + 1; // n = n - 1; - x = x >> 1; // x = x + x; - } // } - return n; // return n; -} - -int ntz6a(unsigned x) -{ - int n = 32; - - while (x != 0) { - n = n - 1; - x = x + x; - } - return n; -} - -/* Dean Gaudet's algorithm. To be most useful there must be a good way -to evaluate the C "conditional expression" (a?b:c construction) without -branching. The result of a?b:c is b if a is true (nonzero), and c if a -is false (0). - For example, a compare to zero op that sets a target GPR to 1 if the -operand is 0, and to 0 if the operand is nonzero, will do it. With this -instruction, the algorithm is entirely branch-free. But the most -interesting thing about it is the high degree of parallelism. All six -lines with conditional expressions can be executed in parallel (on a -machine with sufficient computational units). - Although the instruction count is 30 measured statically, it could -execute in only 10 cycles on a machine with sufficient parallelism. - The first two uses of y can instead be x, which would increase the -useful parallelism on most machines (the assignments to y, bz, and b4 -could then all run in parallel). */ - -int ntz7(unsigned x) -{ - unsigned y, bz, b4, b3, b2, b1, b0; - - y = x & -x; // Isolate rightmost 1-bit. - bz = y ? 0 : 1; // 1 if y = 0. - b4 = (y & 0x0000FFFF) ? 0 : 16; - b3 = (y & 0x00FF00FF) ? 0 : 8; - b2 = (y & 0x0F0F0F0F) ? 0 : 4; - b1 = (y & 0x33333333) ? 0 : 2; - b0 = (y & 0x55555555) ? 0 : 1; - return bz + b4 + b3 + b2 + b1 + b0; -} - -int ntz7_christophe(unsigned x) -{ - unsigned y, bz, b4, b3, b2, b1, b0; - - y = x & -x; // Isolate rightmost 1-bit. - bz = unsigned(!bool(y)); // 1 if y = 0. - b4 = unsigned(!bool(y & 0x0000FFFF)) * 16; - b3 = unsigned(!bool(y & 0x00FF00FF)) * 8; - b2 = unsigned(!bool(y & 0x0F0F0F0F)) * 4; - b1 = unsigned(!bool(y & 0x33333333)) * 2; - b0 = unsigned(!bool(y & 0x55555555)) * 1; - return bz + b4 + b3 + b2 + b1 + b0; -} - -/* Below is David Seal's algorithm, found at -http://www.ciphersbyritter.com/NEWS4/BITCT.HTM Table -entries marked "u" are unused. 6 ops including a -multiply, plus an indexed load. */ - -#define u 99 -int ntz8(unsigned x) -{ - static char table[64] = - {32, 0, 1,12, 2, 6, u,13, 3, u, 7, u, u, u, u,14, - 10, 4, u, u, 8, u, u,25, u, u, u, u, u,21,27,15, - 31,11, 5, u, u, u, u, u, 9, u, u,24, u, u,20,26, - 30, u, u, u, u,23, u,19, 29, u,22,18,28,17,16, u}; - - x = (x & -x)*0x0450FBAF; - return table[x >> 26]; -} - -/* Seal's algorithm with multiply expanded. -9 elementary ops plus an indexed load. */ - -int ntz8a(unsigned x) -{ - static char table[64] = - {32, 0, 1,12, 2, 6, u,13, 3, u, 7, u, u, u, u,14, - 10, 4, u, u, 8, u, u,25, u, u, u, u, u,21,27,15, - 31,11, 5, u, u, u, u, u, 9, u, u,24, u, u,20,26, - 30, u, u, u, u,23, u,19, 29, u,22,18,28,17,16, u}; - - x = (x & -x); - x = (x << 4) + x; // x = x*17. - x = (x << 6) + x; // x = x*65. - x = (x << 16) - x; // x = x*65535. - return table[x >> 26]; -} - -/* Reiser's algorithm. Three ops including a "remainder," -plus an indexed load. */ - -int ntz9(unsigned x) { - - static char table[37] = {32, 0, 1, 26, 2, 23, 27, - u, 3, 16, 24, 30, 28, 11, u, 13, 4, - 7, 17, u, 25, 22, 31, 15, 29, 10, 12, - 6, u, 21, 14, 9, 5, 20, 8, 19, 18}; - - x = (x & -x)%37; - return table[x]; -} - -/* Using a de Bruijn sequence. This is a table lookup with a 32-entry -table. The de Bruijn sequence used here is - 0000 0100 1101 0111 0110 0101 0001 1111, -obtained from Danny Dube's October 3, 1997, posting in -comp.compression.research. Thanks to Norbert Juffa for this reference. */ - -int ntz10(unsigned x) { - - static char table[32] = - { 0, 1, 2,24, 3,19, 6,25, 22, 4,20,10,16, 7,12,26, - 31,23,18, 5,21, 9,15,11, 30,17, 8,14,29,13,28,27}; - - if (x == 0) return 32; - x = (x & -x)*0x04D7651F; - return table[x >> 27]; -} - -/* Norbert Juffa's code, answer to exercise 1 of Chapter 5 (2nd ed). */ - -#define SLOW_MUL -int ntz11 (unsigned int n) { - - static unsigned char tab[32] = - { 0, 1, 2, 24, 3, 19, 6, 25, - 22, 4, 20, 10, 16, 7, 12, 26, - 31, 23, 18, 5, 21, 9, 15, 11, - 30, 17, 8, 14, 29, 13, 28, 27 - }; - unsigned int k; - n = n & (-n); /* isolate lsb */ - printf("n = %d\n", n); -#if defined(SLOW_MUL) - k = (n << 11) - n; - k = (k << 2) + k; - k = (k << 8) + n; - k = (k << 5) - k; -#else - k = n * 0x4d7651f; -#endif - return n ? tab[k>>27] : 32; -} - -int errors; -void error(int x, int y) { - errors = errors + 1; - printf("Error for x = %08x, got %d\n", x, y); -} - -/* ------------------------------ main ------------------------------ */ - -int main() -{ -# ifdef NDEBUG - - int i, m, n; - static unsigned test[] = {0,32, 1,0, 2,1, 3,0, 4,2, 5,0, 6,1, 7,0, - 8,3, 9,0, 16,4, 32,5, 64,6, 128,7, 255,0, 256,8, 512,9, 1024,10, - 2048,11, 4096,12, 8192,13, 16384,14, 32768,15, 65536,16, - 0x20000,17, 0x40000,18, 0x80000,19, 0x100000,20, 0x200000,21, - 0x400000,22, 0x800000,23, 0x1000000,24, 0x2000000,25, - 0x4000000,26, 0x8000000,27, 0x10000000,28, 0x20000000,29, - 0x40000000,30, 0x80000000,31, 0xFFFFFFF0,4, 0x3000FF00,8, - 0xC0000000,30, 0x60000000,29, 0x00011000, 12}; - - std::size_t const Count = 1000; - - n = sizeof(test)/4; - - std::clock_t TimestampBeg = 0; - std::clock_t TimestampEnd = 0; - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (ntz1(test[i]) != test[i+1]) error(test[i], ntz1(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz1: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (ntz2(test[i]) != test[i+1]) error(test[i], ntz2(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz2: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (ntz3(test[i]) != test[i+1]) error(test[i], ntz3(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz3: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (ntz4(test[i]) != test[i+1]) error(test[i], ntz4(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz4: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (ntz4a(test[i]) != test[i+1]) error(test[i], ntz4a(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz4a: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - m = test[i+1]; if (m > 8) m = 8; - if (ntz5(test[i]) != m) error(test[i], ntz5(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz5: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (ntz6(test[i]) != test[i+1]) error(test[i], ntz6(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz6: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (ntz6a(test[i]) != test[i+1]) error(test[i], ntz6a(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz6a: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (ntz7(test[i]) != test[i+1]) error(test[i], ntz7(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz7: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (ntz7_christophe(test[i]) != test[i+1]) error(test[i], ntz7(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz7_christophe: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (ntz8(test[i]) != test[i+1]) error(test[i], ntz8(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz8: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (ntz8a(test[i]) != test[i+1]) error(test[i], ntz8a(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz8a: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (ntz9(test[i]) != test[i+1]) error(test[i], ntz9(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz9: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (ntz10(test[i]) != test[i+1]) error(test[i], ntz10(test[i]));} - TimestampEnd = std::clock(); - - printf("ntz10: %d clocks\n", TimestampEnd - TimestampBeg); - - if (errors == 0) - printf("Passed all %d cases.\n", sizeof(test)/8); - -# endif//NDEBUG -} diff --git a/VRVideoPlayer/external/glm/test/core/core_func_integer_find_msb.cpp b/VRVideoPlayer/external/glm/test/core/core_func_integer_find_msb.cpp deleted file mode 100644 index 00268c8..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_func_integer_find_msb.cpp +++ /dev/null @@ -1,438 +0,0 @@ -// This has the programs for computing the number of leading zeros -// in a word. -// Max line length is 57, to fit in hacker.book. -// Compile with g++, not gcc. -#include -#include // To define "exit", req'd by XLC. -#include - -#define LE 1 // 1 for little-endian, 0 for big-endian. - -int pop(unsigned x) { - x = x - ((x >> 1) & 0x55555555); - x = (x & 0x33333333) + ((x >> 2) & 0x33333333); - x = (x + (x >> 4)) & 0x0F0F0F0F; - x = x + (x << 8); - x = x + (x << 16); - return x >> 24; -} - -int nlz1(unsigned x) { - int n; - - if (x == 0) return(32); - n = 0; - if (x <= 0x0000FFFF) {n = n +16; x = x <<16;} - if (x <= 0x00FFFFFF) {n = n + 8; x = x << 8;} - if (x <= 0x0FFFFFFF) {n = n + 4; x = x << 4;} - if (x <= 0x3FFFFFFF) {n = n + 2; x = x << 2;} - if (x <= 0x7FFFFFFF) {n = n + 1;} - return n; -} - -int nlz1a(unsigned x) { - int n; - -/* if (x == 0) return(32); */ - if ((int)x <= 0) return (~x >> 26) & 32; - n = 1; - if ((x >> 16) == 0) {n = n +16; x = x <<16;} - if ((x >> 24) == 0) {n = n + 8; x = x << 8;} - if ((x >> 28) == 0) {n = n + 4; x = x << 4;} - if ((x >> 30) == 0) {n = n + 2; x = x << 2;} - n = n - (x >> 31); - return n; -} -// On basic Risc, 12 to 20 instructions. - -int nlz2(unsigned x) { - unsigned y; - int n; - - n = 32; - y = x >>16; if (y != 0) {n = n -16; x = y;} - y = x >> 8; if (y != 0) {n = n - 8; x = y;} - y = x >> 4; if (y != 0) {n = n - 4; x = y;} - y = x >> 2; if (y != 0) {n = n - 2; x = y;} - y = x >> 1; if (y != 0) return n - 2; - return n - x; -} - -// As above but coded as a loop for compactness: -// 23 to 33 basic Risc instructions. -int nlz2a(unsigned x) { - unsigned y; - int n, c; - - n = 32; - c = 16; - do { - y = x >> c; if (y != 0) {n = n - c; x = y;} - c = c >> 1; - } while (c != 0); - return n - x; -} - -int nlz3(int x) { - int y, n; - - n = 0; - y = x; -L: if (x < 0) return n; - if (y == 0) return 32 - n; - n = n + 1; - x = x << 1; - y = y >> 1; - goto L; -} - -int nlz4(unsigned x) { - int y, m, n; - - y = -(x >> 16); // If left half of x is 0, - m = (y >> 16) & 16; // set n = 16. If left half - n = 16 - m; // is nonzero, set n = 0 and - x = x >> m; // shift x right 16. - // Now x is of the form 0000xxxx. - y = x - 0x100; // If positions 8-15 are 0, - m = (y >> 16) & 8; // add 8 to n and shift x left 8. - n = n + m; - x = x << m; - - y = x - 0x1000; // If positions 12-15 are 0, - m = (y >> 16) & 4; // add 4 to n and shift x left 4. - n = n + m; - x = x << m; - - y = x - 0x4000; // If positions 14-15 are 0, - m = (y >> 16) & 2; // add 2 to n and shift x left 2. - n = n + m; - x = x << m; - - y = x >> 14; // Set y = 0, 1, 2, or 3. - m = y & ~(y >> 1); // Set m = 0, 1, 2, or 2 resp. - return n + 2 - m; -} - -int nlz5(unsigned x) { - int pop(unsigned x); - - x = x | (x >> 1); - x = x | (x >> 2); - x = x | (x >> 4); - x = x | (x >> 8); - x = x | (x >>16); - return pop(~x); -} - -/* The four programs below are not valid ANSI C programs. This is -because they refer to the same storage locations as two different types. -However, they work with xlc/AIX, gcc/AIX, and gcc/NT. If you try to -code them more compactly by declaring a variable xx to be "double," and -then using - - n = 1054 - (*((unsigned *)&xx + LE) >> 20); - -then you are violating not only the rule above, but also the ANSI C -rule that pointer arithmetic can be performed only on pointers to -array elements. - When coded with the above statement, the program fails with xlc, -gcc/AIX, and gcc/NT, at some optimization levels. - BTW, these programs use the "anonymous union" feature of C++, not -available in C. */ - -int nlz6(unsigned k) { - union { - unsigned asInt[2]; - double asDouble; - }; - int n; - - asDouble = (double)k + 0.5; - n = 1054 - (asInt[LE] >> 20); - return n; -} - -int nlz7(unsigned k) { - union { - unsigned asInt[2]; - double asDouble; - }; - int n; - - asDouble = (double)k; - n = 1054 - (asInt[LE] >> 20); - n = (n & 31) + (n >> 9); - return n; -} - - /* In single precision, round-to-nearest mode, the basic method fails for: - k = 0, k = 01FFFFFF, 03FFFFFE <= k <= 03FFFFFF, - 07FFFFFC <= k <= 07FFFFFF, - 0FFFFFF8 <= k <= 0FFFFFFF, - ... - 7FFFFFC0 <= k <= 7FFFFFFF. - FFFFFF80 <= k <= FFFFFFFF. - For k = 0 it gives 158, and for the other values it is too low by 1. */ - -int nlz8(unsigned k) { - union { - unsigned asInt; - float asFloat; - }; - int n; - - k = k & ~(k >> 1); /* Fix problem with rounding. */ - asFloat = (float)k + 0.5f; - n = 158 - (asInt >> 23); - return n; -} - -/* The example below shows how to make a macro for nlz. It uses an -extension to the C and C++ languages that is provided by the GNU C/C++ -compiler, namely, that of allowing statements and declarations in -expressions (see "Using and Porting GNU CC", by Richard M. Stallman -(1998). The underscores are necessary to protect against the -possibility that the macro argument will conflict with one of its local -variables, e.g., NLZ(k). */ - -int nlz9(unsigned k) { - union { - unsigned asInt; - float asFloat; - }; - int n; - - k = k & ~(k >> 1); /* Fix problem with rounding. */ - asFloat = (float)k; - n = 158 - (asInt >> 23); - n = (n & 31) + (n >> 6); /* Fix problem with k = 0. */ - return n; -} - -/* Below are three nearly equivalent programs for computing the number -of leading zeros in a word. This material is not in HD, but may be in a -future edition. - Immediately below is Robert Harley's algorithm, found at the -comp.arch newsgroup entry dated 7/12/96, pointed out to me by Norbert -Juffa. - Table entries marked "u" are unused. 14 ops including a multiply, -plus an indexed load. - The smallest multiplier that works is 0x045BCED1 = 17*65*129*513 (all -of form 2**k + 1). There are no multipliers of three terms of the form -2**k +- 1 that work, with a table size of 64 or 128. There are some, -with a table size of 64, if you precede the multiplication with x = x - -(x >> 1), but that seems less elegant. There are also some if you use a -table size of 256, the smallest is 0x01033CBF = 65*255*1025 (this would -save two instructions in the form of this algorithm with the -multiplication expanded into shifts and adds, but the table size is -getting a bit large). */ - -#define u 99 -int nlz10(unsigned x) { - - static char table[64] = - {32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u, - u, u,12,14,21, u,19, u, u,28, u,25, u, 9, 1, u, - 17, u, 4, u, u, u,11, u, 13,22,20, u,26, u, u,18, - 5, u, u,23, u,27, u, 6, u,24, 7, u, 8, u, 0, u}; - - x = x | (x >> 1); // Propagate leftmost - x = x | (x >> 2); // 1-bit to the right. - x = x | (x >> 4); - x = x | (x >> 8); - x = x | (x >>16); - x = x*0x06EB14F9; // Multiplier is 7*255**3. - return table[x >> 26]; -} - -/* Harley's algorithm with multiply expanded. -19 elementary ops plus an indexed load. */ - -int nlz10a(unsigned x) { - - static char table[64] = - {32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u, - u, u,12,14,21, u,19, u, u,28, u,25, u, 9, 1, u, - 17, u, 4, u, u, u,11, u, 13,22,20, u,26, u, u,18, - 5, u, u,23, u,27, u, 6, u,24, 7, u, 8, u, 0, u}; - - x = x | (x >> 1); // Propagate leftmost - x = x | (x >> 2); // 1-bit to the right. - x = x | (x >> 4); - x = x | (x >> 8); - x = x | (x >> 16); - x = (x << 3) - x; // Multiply by 7. - x = (x << 8) - x; // Multiply by 255. - x = (x << 8) - x; // Again. - x = (x << 8) - x; // Again. - return table[x >> 26]; -} - -/* Julius Goryavsky's version of Harley's algorithm. -17 elementary ops plus an indexed load, if the machine -has "and not." */ - -int nlz10b(unsigned x) { - - static char table[64] = - {32,20,19, u, u,18, u, 7, 10,17, u, u,14, u, 6, u, - u, 9, u,16, u, u, 1,26, u,13, u, u,24, 5, u, u, - u,21, u, 8,11, u,15, u, u, u, u, 2,27, 0,25, u, - 22, u,12, u, u, 3,28, u, 23, u, 4,29, u, u,30,31}; - - x = x | (x >> 1); // Propagate leftmost - x = x | (x >> 2); // 1-bit to the right. - x = x | (x >> 4); - x = x | (x >> 8); - x = x & ~(x >> 16); - x = x*0xFD7049FF; // Activate this line or the following 3. -// x = (x << 9) - x; // Multiply by 511. -// x = (x << 11) - x; // Multiply by 2047. -// x = (x << 14) - x; // Multiply by 16383. - return table[x >> 26]; -} - -int errors; -void error(int x, int y) { - errors = errors + 1; - printf("Error for x = %08x, got %d\n", x, y); -} - -int main() -{ -# ifdef NDEBUG - - int i, n; - static unsigned test[] = {0,32, 1,31, 2,30, 3,30, 4,29, 5,29, 6,29, - 7,29, 8,28, 9,28, 16,27, 32,26, 64,25, 128,24, 255,24, 256,23, - 512,22, 1024,21, 2048,20, 4096,19, 8192,18, 16384,17, 32768,16, - 65536,15, 0x20000,14, 0x40000,13, 0x80000,12, 0x100000,11, - 0x200000,10, 0x400000,9, 0x800000,8, 0x1000000,7, 0x2000000,6, - 0x4000000,5, 0x8000000,4, 0x0FFFFFFF,4, 0x10000000,3, - 0x3000FFFF,2, 0x50003333,1, 0x7FFFFFFF,1, 0x80000000,0, - 0xFFFFFFFF,0}; - std::size_t const Count = 1000; - - n = sizeof(test)/4; - - std::clock_t TimestampBeg = 0; - std::clock_t TimestampEnd = 0; - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz1(test[i]) != test[i+1]) error(test[i], nlz1(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz1: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz1a(test[i]) != test[i+1]) error(test[i], nlz1a(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz1a: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz2(test[i]) != test[i+1]) error(test[i], nlz2(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz2: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz2a(test[i]) != test[i+1]) error(test[i], nlz2a(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz2a: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz3(test[i]) != test[i+1]) error(test[i], nlz3(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz3: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz4(test[i]) != test[i+1]) error(test[i], nlz4(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz4: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz5(test[i]) != test[i+1]) error(test[i], nlz5(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz5: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz6(test[i]) != test[i+1]) error(test[i], nlz6(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz6: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz7(test[i]) != test[i+1]) error(test[i], nlz7(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz7: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz8(test[i]) != test[i+1]) error(test[i], nlz8(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz8: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz9(test[i]) != test[i+1]) error(test[i], nlz9(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz9: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz10(test[i]) != test[i+1]) error(test[i], nlz10(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz10: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz10a(test[i]) != test[i+1]) error(test[i], nlz10a(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz10a: %d clocks\n", TimestampEnd - TimestampBeg); - - TimestampBeg = std::clock(); - for (std::size_t k = 0; k < Count; ++k) - for (i = 0; i < n; i += 2) { - if (nlz10b(test[i]) != test[i+1]) error(test[i], nlz10b(test[i]));} - TimestampEnd = std::clock(); - - printf("nlz10b: %d clocks\n", TimestampEnd - TimestampBeg); - - if (errors == 0) - printf("Passed all %d cases.\n", sizeof(test)/8); - -# endif//NDEBUG -} diff --git a/VRVideoPlayer/external/glm/test/core/core_func_matrix.cpp b/VRVideoPlayer/external/glm/test/core/core_func_matrix.cpp deleted file mode 100644 index 8037deb..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_func_matrix.cpp +++ /dev/null @@ -1,277 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -using namespace glm; - -int test_matrixCompMult() -{ - int Error(0); - - { - mat2 m(0, 1, 2, 3); - mat2 n = matrixCompMult(m, m); - Error += n == mat2(0, 1, 4, 9) ? 0 : 1; - } - - { - mat2x3 m(0, 1, 2, 3, 4, 5); - mat2x3 n = matrixCompMult(m, m); - Error += n == mat2x3(0, 1, 4, 9, 16, 25) ? 0 : 1; - } - - { - mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7); - mat2x4 n = matrixCompMult(m, m); - Error += n == mat2x4(0, 1, 4, 9, 16, 25, 36, 49) ? 0 : 1; - } - - { - mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8); - mat3 n = matrixCompMult(m, m); - Error += n == mat3(0, 1, 4, 9, 16, 25, 36, 49, 64) ? 0 : 1; - } - - { - mat3x2 m(0, 1, 2, 3, 4, 5); - mat3x2 n = matrixCompMult(m, m); - Error += n == mat3x2(0, 1, 4, 9, 16, 25) ? 0 : 1; - } - - { - mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); - mat3x4 n = matrixCompMult(m, m); - Error += n == mat3x4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121) ? 0 : 1; - } - - { - mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); - mat4 n = matrixCompMult(m, m); - Error += n == mat4(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225) ? 0 : 1; - } - - { - mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7); - mat4x2 n = matrixCompMult(m, m); - Error += n == mat4x2(0, 1, 4, 9, 16, 25, 36, 49) ? 0 : 1; - } - - { - mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); - mat4x3 n = matrixCompMult(m, m); - Error += n == mat4x3(0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121) ? 0 : 1; - } - - return Error; -} - -int test_outerProduct() -{ - { glm::mat2 m = glm::outerProduct(glm::vec2(1.0f), glm::vec2(1.0f)); } - { glm::mat3 m = glm::outerProduct(glm::vec3(1.0f), glm::vec3(1.0f)); } - { glm::mat4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec4(1.0f)); } - - { glm::mat2x3 m = glm::outerProduct(glm::vec3(1.0f), glm::vec2(1.0f)); } - { glm::mat2x4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec2(1.0f)); } - - { glm::mat3x2 m = glm::outerProduct(glm::vec2(1.0f), glm::vec3(1.0f)); } - { glm::mat3x4 m = glm::outerProduct(glm::vec4(1.0f), glm::vec3(1.0f)); } - - { glm::mat4x2 m = glm::outerProduct(glm::vec2(1.0f), glm::vec4(1.0f)); } - { glm::mat4x3 m = glm::outerProduct(glm::vec3(1.0f), glm::vec4(1.0f)); } - - return 0; -} - -int test_transpose() -{ - int Error(0); - - { - mat2 m(0, 1, 2, 3); - mat2 t = transpose(m); - Error += t == mat2(0, 2, 1, 3) ? 0 : 1; - } - - { - mat2x3 m(0, 1, 2, 3, 4, 5); - mat3x2 t = transpose(m); - Error += t == mat3x2(0, 3, 1, 4, 2, 5) ? 0 : 1; - } - - { - mat2x4 m(0, 1, 2, 3, 4, 5, 6, 7); - mat4x2 t = transpose(m); - Error += t == mat4x2(0, 4, 1, 5, 2, 6, 3, 7) ? 0 : 1; - } - - { - mat3 m(0, 1, 2, 3, 4, 5, 6, 7, 8); - mat3 t = transpose(m); - Error += t == mat3(0, 3, 6, 1, 4, 7, 2, 5, 8) ? 0 : 1; - } - - { - mat3x2 m(0, 1, 2, 3, 4, 5); - mat2x3 t = transpose(m); - Error += t == mat2x3(0, 2, 4, 1, 3, 5) ? 0 : 1; - } - - { - mat3x4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); - mat4x3 t = transpose(m); - Error += t == mat4x3(0, 4, 8, 1, 5, 9, 2, 6, 10, 3, 7, 11) ? 0 : 1; - } - - { - mat4 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); - mat4 t = transpose(m); - Error += t == mat4(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15) ? 0 : 1; - } - - { - mat4x2 m(0, 1, 2, 3, 4, 5, 6, 7); - mat2x4 t = transpose(m); - Error += t == mat2x4(0, 2, 4, 6, 1, 3, 5, 7) ? 0 : 1; - } - - { - mat4x3 m(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); - mat3x4 t = transpose(m); - Error += t == mat3x4(0, 3, 6, 9, 1, 4, 7, 10, 2, 5, 8, 11) ? 0 : 1; - } - - return Error; -} - -int test_determinant() -{ - - - return 0; -} - -int test_inverse() -{ - int Failed(0); - - glm::mat4x4 A4x4( - glm::vec4(1, 0, 1, 0), - glm::vec4(0, 1, 0, 0), - glm::vec4(0, 0, 1, 0), - glm::vec4(0, 0, 0, 1)); - glm::mat4x4 B4x4 = inverse(A4x4); - glm::mat4x4 I4x4 = A4x4 * B4x4; - Failed += I4x4 == glm::mat4x4(1) ? 0 : 1; - - glm::mat3x3 A3x3( - glm::vec3(1, 0, 1), - glm::vec3(0, 1, 0), - glm::vec3(0, 0, 1)); - glm::mat3x3 B3x3 = glm::inverse(A3x3); - glm::mat3x3 I3x3 = A3x3 * B3x3; - Failed += I3x3 == glm::mat3x3(1) ? 0 : 1; - - glm::mat2x2 A2x2( - glm::vec2(1, 1), - glm::vec2(0, 1)); - glm::mat2x2 B2x2 = glm::inverse(A2x2); - glm::mat2x2 I2x2 = A2x2 * B2x2; - Failed += I2x2 == glm::mat2x2(1) ? 0 : 1; - - return Failed; -} - -int test_inverse_simd() -{ - int Error = 0; - - glm::mat4x4 const Identity(1); - - glm::mat4x4 const A4x4( - glm::vec4(1, 0, 1, 0), - glm::vec4(0, 1, 0, 0), - glm::vec4(0, 0, 1, 0), - glm::vec4(0, 0, 0, 1)); - glm::mat4x4 const B4x4 = glm::inverse(A4x4); - glm::mat4x4 const I4x4 = A4x4 * B4x4; - - Error += glm::all(glm::epsilonEqual(I4x4[0], Identity[0], 0.001f)) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(I4x4[1], Identity[1], 0.001f)) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(I4x4[2], Identity[2], 0.001f)) ? 0 : 1; - Error += glm::all(glm::epsilonEqual(I4x4[3], Identity[3], 0.001f)) ? 0 : 1; - - return Error; -} - -template -int test_inverse_perf(std::size_t Count, std::size_t Instance, char const * Message) -{ - std::vector TestInputs; - TestInputs.resize(Count); - std::vector TestOutputs; - TestOutputs.resize(TestInputs.size()); - - VEC3 Axis(glm::normalize(VEC3(1.0f, 2.0f, 3.0f))); - - for(std::size_t i = 0; i < TestInputs.size(); ++i) - { - typename MAT4::value_type f = static_cast(i + Instance) * typename MAT4::value_type(0.1) + typename MAT4::value_type(0.1); - TestInputs[i] = glm::rotate(glm::translate(MAT4(1), Axis * f), f, Axis); - //TestInputs[i] = glm::translate(MAT4(1), Axis * f); - } - - std::clock_t StartTime = std::clock(); - - for(std::size_t i = 0; i < TestInputs.size(); ++i) - TestOutputs[i] = glm::inverse(TestInputs[i]); - - std::clock_t EndTime = std::clock(); - - for(std::size_t i = 0; i < TestInputs.size(); ++i) - TestOutputs[i] = TestOutputs[i] * TestInputs[i]; - - typename MAT4::value_type Diff(0); - for(std::size_t Entry = 0; Entry < TestOutputs.size(); ++Entry) - { - MAT4 i(1.0); - MAT4 m(TestOutputs[Entry]); - for(glm::length_t y = 0; y < m.length(); ++y) - for(glm::length_t x = 0; x < m[y].length(); ++x) - Diff = glm::max(m[y][x], i[y][x]); - } - - //glm::uint Ulp = 0; - //Ulp = glm::max(glm::float_distance(*Dst, *Src), Ulp); - - printf("inverse<%s>(%f): %lu\n", Message, Diff, EndTime - StartTime); - - return 0; -} - -int main() -{ - int Error(0); - Error += test_matrixCompMult(); - Error += test_outerProduct(); - Error += test_transpose(); - Error += test_determinant(); - Error += test_inverse(); - Error += test_inverse_simd(); - -# ifdef NDEBUG - std::size_t const Samples(1000); - for(std::size_t i = 0; i < 1; ++i) - { - Error += test_inverse_perf(Samples, i, "mat4"); - Error += test_inverse_perf(Samples, i, "dmat4"); - } -# endif//NDEBUG - - return Error; -} - diff --git a/VRVideoPlayer/external/glm/test/core/core_func_noise.cpp b/VRVideoPlayer/external/glm/test/core/core_func_noise.cpp deleted file mode 100644 index 41db681..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_func_noise.cpp +++ /dev/null @@ -1,7 +0,0 @@ -int main() -{ - int Failed = 0; - - return Failed; -} - diff --git a/VRVideoPlayer/external/glm/test/core/core_func_packing.cpp b/VRVideoPlayer/external/glm/test/core/core_func_packing.cpp deleted file mode 100644 index c3cd14a..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_func_packing.cpp +++ /dev/null @@ -1,156 +0,0 @@ -#include -#include -#include -#include -#include - -int test_packUnorm2x16() -{ - int Error = 0; - - std::vector A; - A.push_back(glm::vec2(1.0f, 0.0f)); - A.push_back(glm::vec2(0.5f, 0.7f)); - A.push_back(glm::vec2(0.1f, 0.2f)); - - for(std::size_t i = 0; i < A.size(); ++i) - { - glm::vec2 B(A[i]); - glm::uint32 C = glm::packUnorm2x16(B); - glm::vec2 D = glm::unpackUnorm2x16(C); - Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 65535.f)) ? 0 : 1; - assert(!Error); - } - - return Error; -} - -int test_packSnorm2x16() -{ - int Error = 0; - - std::vector A; - A.push_back(glm::vec2( 1.0f, 0.0f)); - A.push_back(glm::vec2(-0.5f,-0.7f)); - A.push_back(glm::vec2(-0.1f, 0.1f)); - - for(std::size_t i = 0; i < A.size(); ++i) - { - glm::vec2 B(A[i]); - glm::uint32 C = glm::packSnorm2x16(B); - glm::vec2 D = glm::unpackSnorm2x16(C); - Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1; - assert(!Error); - } - - return Error; -} - -int test_packUnorm4x8() -{ - int Error = 0; - - glm::uint32 Packed = glm::packUnorm4x8(glm::vec4(1.0f, 0.5f, 0.0f, 1.0f)); - glm::u8vec4 Vec(255, 128, 0, 255); - glm::uint32 & Ref = *reinterpret_cast(&Vec[0]); - - Error += Packed == Ref ? 0 : 1; - - std::vector A; - A.push_back(glm::vec4(1.0f, 0.7f, 0.3f, 0.0f)); - A.push_back(glm::vec4(0.5f, 0.1f, 0.2f, 0.3f)); - - for(std::size_t i = 0; i < A.size(); ++i) - { - glm::vec4 B(A[i]); - glm::uint32 C = glm::packUnorm4x8(B); - glm::vec4 D = glm::unpackUnorm4x8(C); - Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1; - assert(!Error); - } - - return Error; -} - -int test_packSnorm4x8() -{ - int Error = 0; - - std::vector A; - A.push_back(glm::vec4( 1.0f, 0.0f,-0.5f,-1.0f)); - A.push_back(glm::vec4(-0.7f,-0.1f, 0.1f, 0.7f)); - - for(std::size_t i = 0; i < A.size(); ++i) - { - glm::vec4 B(A[i]); - glm::uint32 C = glm::packSnorm4x8(B); - glm::vec4 D = glm::unpackSnorm4x8(C); - Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1; - assert(!Error); - } - - return Error; -} - -int test_packHalf2x16() -{ - int Error = 0; -/* - std::vector A; - A.push_back(glm::hvec2(glm::half( 1.0f), glm::half( 2.0f))); - A.push_back(glm::hvec2(glm::half(-1.0f), glm::half(-2.0f))); - A.push_back(glm::hvec2(glm::half(-1.1f), glm::half( 1.1f))); -*/ - std::vector A; - A.push_back(glm::vec2( 1.0f, 2.0f)); - A.push_back(glm::vec2(-1.0f,-2.0f)); - A.push_back(glm::vec2(-1.1f, 1.1f)); - - for(std::size_t i = 0; i < A.size(); ++i) - { - glm::vec2 B(A[i]); - glm::uint C = glm::packHalf2x16(B); - glm::vec2 D = glm::unpackHalf2x16(C); - //Error += B == D ? 0 : 1; - Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 127.f)) ? 0 : 1; - assert(!Error); - } - - return Error; -} - -int test_packDouble2x32() -{ - int Error = 0; - - std::vector A; - A.push_back(glm::uvec2( 1, 2)); - A.push_back(glm::uvec2(-1,-2)); - A.push_back(glm::uvec2(-1000, 1100)); - - for(std::size_t i = 0; i < A.size(); ++i) - { - glm::uvec2 B(A[i]); - double C = glm::packDouble2x32(B); - glm::uvec2 D = glm::unpackDouble2x32(C); - Error += B == D ? 0 : 1; - assert(!Error); - } - - return Error; -} - -int main() -{ - int Error = 0; - - Error += test_packSnorm4x8(); - Error += test_packUnorm4x8(); - Error += test_packSnorm2x16(); - Error += test_packUnorm2x16(); - Error += test_packHalf2x16(); - Error += test_packDouble2x32(); - - return Error; -} - diff --git a/VRVideoPlayer/external/glm/test/core/core_func_swizzle.cpp b/VRVideoPlayer/external/glm/test/core/core_func_swizzle.cpp deleted file mode 100644 index dfd6c8a..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_func_swizzle.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#define GLM_FORCE_MESSAGES -#define GLM_FORCE_SWIZZLE -#include - -int test_ivec2_swizzle() -{ - int Error = 0; - - glm::ivec2 A(1, 2); - glm::ivec2 B = A.yx(); - glm::ivec2 C = B.yx(); - - Error += A != B ? 0 : 1; - Error += A == C ? 0 : 1; - - return Error; -} - -int test_ivec3_swizzle() -{ - int Error = 0; - - glm::ivec3 A(1, 2, 3); - glm::ivec3 B = A.zyx(); - glm::ivec3 C = B.zyx(); - - Error += A != B ? 0 : 1; - Error += A == C ? 0 : 1; - - return Error; -} - -int test_ivec4_swizzle() -{ - int Error = 0; - - glm::ivec4 A(1, 2, 3, 4); - glm::ivec4 B = A.wzyx(); - glm::ivec4 C = B.wzyx(); - - Error += A != B ? 0 : 1; - Error += A == C ? 0 : 1; - - return Error; -} - -int test_vec4_swizzle() -{ - int Error = 0; - - glm::vec4 A(1, 2, 3, 4); - glm::vec4 B = A.wzyx(); - glm::vec4 C = B.wzyx(); - - Error += A != B ? 0 : 1; - Error += A == C ? 0 : 1; - - float f = glm::dot(C.wzyx(), C.xyzw()); - Error += glm::abs(f - 20.f) < 0.01f ? 0 : 1; - - return Error; -} - -int main() -{ - int Error = 0; - - Error += test_ivec2_swizzle(); - Error += test_ivec3_swizzle(); - Error += test_ivec4_swizzle(); - - Error += test_vec4_swizzle(); - - return Error; -} - - - diff --git a/VRVideoPlayer/external/glm/test/core/core_func_trigonometric.cpp b/VRVideoPlayer/external/glm/test/core/core_func_trigonometric.cpp deleted file mode 100644 index 3172340..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_func_trigonometric.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include - -int main() -{ - int Error = 0; - - - return Error; -} - diff --git a/VRVideoPlayer/external/glm/test/core/core_func_vector_relational.cpp b/VRVideoPlayer/external/glm/test/core/core_func_vector_relational.cpp deleted file mode 100644 index c98f789..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_func_vector_relational.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include -#include -#include -#include -#include - -int test_not() -{ - int Error(0); - - { - glm::bvec1 v(false); - Error += glm::all(glm::not_(v)) ? 0 : 1; - } - - { - glm::bvec2 v(false); - Error += glm::all(glm::not_(v)) ? 0 : 1; - } - - { - glm::bvec3 v(false); - Error += glm::all(glm::not_(v)) ? 0 : 1; - } - - { - glm::bvec4 v(false); - Error += glm::all(glm::not_(v)) ? 0 : 1; - } - - return Error; -} - -int main() -{ - int Error(0); - - Error += test_not(); - - return Error; -} - diff --git a/VRVideoPlayer/external/glm/test/core/core_setup_force_cxx98.cpp b/VRVideoPlayer/external/glm/test/core/core_setup_force_cxx98.cpp deleted file mode 100644 index 4b59501..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_setup_force_cxx98.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#define GLM_FORCE_CXX98 -#include -#include - -int main() -{ - int Error = 0; - - return Error; -} diff --git a/VRVideoPlayer/external/glm/test/core/core_setup_message.cpp b/VRVideoPlayer/external/glm/test/core/core_setup_message.cpp deleted file mode 100644 index 7eaf702..0000000 --- a/VRVideoPlayer/external/glm/test/core/core_setup_message.cpp +++ /dev/null @@ -1,263 +0,0 @@ -#define GLM_FORCE_MESSAGES -#include -#include - -int test_compiler() -{ - int Error(0); - - if(GLM_COMPILER & GLM_COMPILER_VC) - { - switch(GLM_COMPILER) - { - case GLM_COMPILER_VC2010: - std::printf("GLM_COMPILER_VC2010\n"); - break; - case GLM_COMPILER_VC2012: - std::printf("GLM_COMPILER_VC2012\n"); - break; - case GLM_COMPILER_VC2013: - std::printf("GLM_COMPILER_VC2013\n"); - break; - case GLM_COMPILER_VC2015: - std::printf("GLM_COMPILER_VC2015\n"); - break; - default: - std::printf("Visual C++ version not detected\n"); - Error += 1; - break; - } - } - else if(GLM_COMPILER & GLM_COMPILER_GCC) - { - switch(GLM_COMPILER) - { - case GLM_COMPILER_GCC44: - std::printf("GLM_COMPILER_GCC44\n"); - break; - case GLM_COMPILER_GCC45: - std::printf("GLM_COMPILER_GCC45\n"); - break; - case GLM_COMPILER_GCC46: - std::printf("GLM_COMPILER_GCC46\n"); - break; - case GLM_COMPILER_GCC47: - std::printf("GLM_COMPILER_GCC47\n"); - break; - case GLM_COMPILER_GCC48: - std::printf("GLM_COMPILER_GCC48\n"); - break; - case GLM_COMPILER_GCC49: - std::printf("GLM_COMPILER_GCC49\n"); - break; - case GLM_COMPILER_GCC50: - std::printf("GLM_COMPILER_GCC50\n"); - break; - case GLM_COMPILER_GCC51: - std::printf("GLM_COMPILER_GCC51\n"); - break; - case GLM_COMPILER_GCC52: - std::printf("GLM_COMPILER_GCC52\n"); - break; - case GLM_COMPILER_GCC53: - std::printf("GLM_COMPILER_GCC53\n"); - break; - case GLM_COMPILER_GCC54: - std::printf("GLM_COMPILER_GCC54\n"); - break; - case GLM_COMPILER_GCC60: - std::printf("GLM_COMPILER_GCC60\n"); - break; - case GLM_COMPILER_GCC61: - std::printf("GLM_COMPILER_GCC61\n"); - break; - case GLM_COMPILER_GCC62: - std::printf("GLM_COMPILER_GCC62\n"); - break; - case GLM_COMPILER_GCC70: - std::printf("GLM_COMPILER_GCC70\n"); - break; - case GLM_COMPILER_GCC71: - std::printf("GLM_COMPILER_GCC71\n"); - break; - case GLM_COMPILER_GCC72: - std::printf("GLM_COMPILER_GCC72\n"); - break; - case GLM_COMPILER_GCC80: - std::printf("GLM_COMPILER_GCC80\n"); - break; - default: - std::printf("GCC version not detected\n"); - Error += 1; - break; - } - } - else if(GLM_COMPILER & GLM_COMPILER_CUDA) - { - std::printf("GLM_COMPILER_CUDA\n"); - } - else if(GLM_COMPILER & GLM_COMPILER_CLANG) - { - switch(GLM_COMPILER) - { - case GLM_COMPILER_CLANG32: - std::printf("GLM_COMPILER_CLANG32\n"); - break; - case GLM_COMPILER_CLANG33: - std::printf("GLM_COMPILER_CLANG33\n"); - break; - case GLM_COMPILER_CLANG34: - std::printf("GLM_COMPILER_CLANG34\n"); - break; - case GLM_COMPILER_CLANG35: - std::printf("GLM_COMPILER_CLANG35\n"); - break; - case GLM_COMPILER_CLANG36: - std::printf("GLM_COMPILER_CLANG36\n"); - break; - case GLM_COMPILER_CLANG37: - std::printf("GLM_COMPILER_CLANG37\n"); - break; - case GLM_COMPILER_CLANG38: - std::printf("GLM_COMPILER_CLANG38\n"); - break; - case GLM_COMPILER_CLANG39: - std::printf("GLM_COMPILER_CLANG39\n"); - break; - default: - std::printf("LLVM version not detected\n"); - break; - } - } - else if(GLM_COMPILER & GLM_COMPILER_INTEL) - { - switch(GLM_COMPILER) - { - case GLM_COMPILER_INTEL12: - std::printf("GLM_COMPILER_INTEL12\n"); - break; - case GLM_COMPILER_INTEL12_1: - std::printf("GLM_COMPILER_INTEL12_1\n"); - break; - case GLM_COMPILER_INTEL13: - std::printf("GLM_COMPILER_INTEL13\n"); - break; - case GLM_COMPILER_INTEL14: - std::printf("GLM_COMPILER_INTEL14\n"); - break; - case GLM_COMPILER_INTEL15: - std::printf("GLM_COMPILER_INTEL15\n"); - break; - case GLM_COMPILER_INTEL16: - std::printf("GLM_COMPILER_INTEL16\n"); - break; - default: - std::printf("Intel compiler version not detected\n"); - Error += 1; - break; - } - } - else - { - std::printf("Undetected compiler\n"); - Error += 1; - } - - return Error; -} - -int test_model() -{ - int Error = 0; - - Error += ((sizeof(void*) == 4) && (GLM_MODEL == GLM_MODEL_32)) || ((sizeof(void*) == 8) && (GLM_MODEL == GLM_MODEL_64)) ? 0 : 1; - - if(GLM_MODEL == GLM_MODEL_32) - std::printf("GLM_MODEL_32\n"); - else if(GLM_MODEL == GLM_MODEL_64) - std::printf("GLM_MODEL_64\n"); - - return Error; -} - -int test_instruction_set() -{ - int Error = 0; - - std::printf("GLM_ARCH: "); - - if(GLM_ARCH == GLM_ARCH_PURE) - std::printf("GLM_ARCH_PURE "); - if(GLM_ARCH & GLM_ARCH_ARM_BIT) - std::printf("ARM "); - if(GLM_ARCH & GLM_ARCH_NEON_BIT) - std::printf("NEON "); - if(GLM_ARCH & GLM_ARCH_AVX2) - std::printf("AVX2 "); - if(GLM_ARCH & GLM_ARCH_AVX) - std::printf("AVX "); - if(GLM_ARCH & GLM_ARCH_SSE42_BIT) - std::printf("SSE4.2 "); - if(GLM_ARCH & GLM_ARCH_SSE41_BIT) - std::printf("SSE4.1 "); - if(GLM_ARCH & GLM_ARCH_SSSE3_BIT) - std::printf("SSSE3 "); - if(GLM_ARCH & GLM_ARCH_SSE3_BIT) - std::printf("SSE3 "); - if(GLM_ARCH & GLM_ARCH_SSE2_BIT) - std::printf("SSE2 "); - - std::printf("\n"); - - return Error; -} - -int test_cpp_version() -{ - std::printf("__cplusplus: %lld\n", __cplusplus); - - return 0; -} - -int test_operators() -{ - glm::vec3 A(1.0f); - glm::vec3 B(1.0f); - bool R = A != B; - bool S = A == B; - - return (S && !R) ? 0 : 1; -} - -template -struct vec -{ - -}; - -template