diff --git a/dom/vr/VRDevice.cpp b/dom/vr/VRDevice.cpp index ec13baf47f90..a04a17766bab 100644 --- a/dom/vr/VRDevice.cpp +++ b/dom/vr/VRDevice.cpp @@ -214,9 +214,21 @@ public: : HMDVRDevice(aParent, aHMD) { // XXX TODO use real names/IDs - mHWID.AppendPrintf("HMDInfo-0x%llx", aHMD); - mDeviceId.AssignLiteral("somedevid"); - mDeviceName.AssignLiteral("HMD Device"); + uint64_t hmdid = reinterpret_cast(aHMD); + + mHWID.Truncate(); + mHWID.AppendPrintf("HMDInfo-0x%llx", hmdid); + + mDeviceId.Truncate(); + mDeviceId.AppendPrintf("HMDInfo-dev-0x%llx", hmdid); + + if (aHMD->GetType() == VRHMDType::Oculus) { + mDeviceName.AssignLiteral("VR HMD Device (oculus)"); + } else if (aHMD->GetType() == VRHMDType::Cardboard) { + mDeviceName.AssignLiteral("VR HMD Device (cardboard)"); + } else { + mDeviceName.AssignLiteral("VR HMD Device (unknown)"); + } mValid = true; } @@ -270,9 +282,21 @@ public: , mTracking(false) { // XXX TODO use real names/IDs - mHWID.AppendPrintf("HMDInfo-0x%llx", aHMD); - mDeviceId.AssignLiteral("somedevid"); - mDeviceName.AssignLiteral("HMD Position Device"); + uint64_t hmdid = reinterpret_cast(aHMD); + + mHWID.Truncate(); + mHWID.AppendPrintf("HMDInfo-0x%llx", hmdid); + + mDeviceId.Truncate(); + mDeviceId.AppendPrintf("HMDInfo-dev-0x%llx", hmdid); + + if (aHMD->GetType() == VRHMDType::Oculus) { + mDeviceName.AssignLiteral("VR Position Device (oculus)"); + } else if (aHMD->GetType() == VRHMDType::Cardboard) { + mDeviceName.AssignLiteral("VR Position Device (cardboard)"); + } else { + mDeviceName.AssignLiteral("VR Position Device (unknown)"); + } mValid = true; } diff --git a/gfx/layers/d3d11/CompositorD3D11.cpp b/gfx/layers/d3d11/CompositorD3D11.cpp index eafd44bff7f5..5832ba87564d 100644 --- a/gfx/layers/d3d11/CompositorD3D11.cpp +++ b/gfx/layers/d3d11/CompositorD3D11.cpp @@ -73,17 +73,19 @@ struct DeviceAttachmentsD3D11 // // VR pieces // - RefPtr mVRDistortionInputLayout; - RefPtr mVRDistortionConstants; - + typedef EnumeratedArray> + VRDistortionInputLayoutArray; typedef EnumeratedArray> VRVertexShaderArray; typedef EnumeratedArray> VRPixelShaderArray; + VRDistortionInputLayoutArray mVRDistortionInputLayout; VRVertexShaderArray mVRDistortionVS; VRPixelShaderArray mVRDistortionPS; + RefPtr mVRDistortionConstants; + // These will be created/filled in as needed during rendering whenever the configuration // changes. VRHMDConfiguration mVRConfiguration; @@ -334,7 +336,12 @@ CompositorD3D11::Initialize() sizeof(vrlayout) / sizeof(D3D11_INPUT_ELEMENT_DESC), OculusVRDistortionVS, sizeof(OculusVRDistortionVS), - byRef(mAttachments->mVRDistortionInputLayout)); + byRef(mAttachments->mVRDistortionInputLayout[VRHMDType::Oculus])); + + // XXX shared for now, rename + mAttachments->mVRDistortionInputLayout[VRHMDType::Cardboard] = + mAttachments->mVRDistortionInputLayout[VRHMDType::Oculus]; + cBufferDesc.ByteWidth = sizeof(gfx::VRDistortionConstants); hr = mDevice->CreateBuffer(&cBufferDesc, nullptr, byRef(mAttachments->mVRDistortionConstants)); if (FAILED(hr)) { @@ -661,6 +668,7 @@ CompositorD3D11::DrawVRDistortion(const gfx::Rect& aRect, gfx::IntSize size = vrEffect->mRenderTarget->GetSize(); // XXX source->GetSize() VRHMDInfo* hmdInfo = vrEffect->mHMD; + VRHMDType hmdType = hmdInfo->GetType(); VRDistortionConstants shaderConstants; // do we need to recreate the VR buffers, since the config has changed? @@ -709,20 +717,17 @@ CompositorD3D11::DrawVRDistortion(const gfx::Rect& aRect, // Triangle lists and same layout for both eyes mContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); - mContext->IASetInputLayout(mAttachments->mVRDistortionInputLayout); - - // Shaders for this HMD - mContext->VSSetShader(mAttachments->mVRDistortionVS[mAttachments->mVRConfiguration.hmdType], nullptr, 0); - mContext->PSSetShader(mAttachments->mVRDistortionPS[mAttachments->mVRConfiguration.hmdType], nullptr, 0); + mContext->IASetInputLayout(mAttachments->mVRDistortionInputLayout[hmdType]); + mContext->VSSetShader(mAttachments->mVRDistortionVS[hmdType], nullptr, 0); + mContext->PSSetShader(mAttachments->mVRDistortionPS[hmdType], nullptr, 0); // This is the source texture SRV for the pixel shader - // XXX, um should we cache this SRV? + // XXX, um should we cache this SRV on the source? RefPtr view; mDevice->CreateShaderResourceView(source->GetD3D11Texture(), nullptr, byRef(view)); ID3D11ShaderResourceView* srView = view; mContext->PSSetShaderResources(0, 1, &srView); - gfx::IntSize vpSizeInt = mCurrentRT->GetSize(); gfx::Size vpSize(vpSizeInt.width, vpSizeInt.height); ID3D11Buffer* vbuffer; @@ -1343,6 +1348,11 @@ CompositorD3D11::CreateShaders() return false; } + // These are shared + // XXX rename Oculus shaders to something more generic + mAttachments->mVRDistortionVS[VRHMDType::Cardboard] = mAttachments->mVRDistortionVS[VRHMDType::Oculus]; + mAttachments->mVRDistortionPS[VRHMDType::Cardboard] = mAttachments->mVRDistortionPS[VRHMDType::Oculus]; + return true; } diff --git a/gfx/layers/d3d11/CompositorD3D11Shaders.h b/gfx/layers/d3d11/CompositorD3D11Shaders.h index f6379c7f4ccb..18b99663296b 100644 --- a/gfx/layers/d3d11/CompositorD3D11Shaders.h +++ b/gfx/layers/d3d11/CompositorD3D11Shaders.h @@ -1,9 +1,8 @@ #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -104,10 +103,10 @@ ret const BYTE LayerQuadVS[] = { - 68, 88, 66, 67, 67, 61, - 27, 151, 57, 33, 48, 19, - 55, 6, 95, 77, 254, 163, - 118, 237, 1, 0, 0, 0, + 68, 88, 66, 67, 200, 251, + 64, 251, 166, 240, 101, 137, + 191, 140, 75, 217, 9, 168, + 61, 163, 1, 0, 0, 0, 180, 6, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 152, 1, 0, 0, 160, 3, @@ -262,7 +261,7 @@ const BYTE LayerQuadVS[] = 65, 84, 116, 0, 0, 0, 13, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 6, 0, + 3, 0, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, @@ -272,7 +271,7 @@ const BYTE LayerQuadVS[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -363,10 +362,10 @@ const BYTE LayerQuadVS[] = 41, 32, 72, 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, - 105, 108, 101, 114, 32, 57, - 46, 51, 48, 46, 57, 50, - 48, 48, 46, 50, 48, 53, - 52, 54, 0, 171, 73, 83, + 105, 108, 101, 114, 32, 54, + 46, 51, 46, 57, 54, 48, + 48, 46, 49, 54, 51, 56, + 52, 0, 171, 171, 73, 83, 71, 78, 44, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, @@ -393,10 +392,9 @@ const BYTE LayerQuadVS[] = }; #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -460,10 +458,10 @@ ret const BYTE SolidColorShader[] = { - 68, 88, 66, 67, 182, 98, - 102, 100, 187, 218, 19, 40, - 99, 74, 29, 228, 47, 107, - 160, 122, 1, 0, 0, 0, + 68, 88, 66, 67, 30, 148, + 104, 202, 165, 39, 58, 182, + 100, 205, 95, 195, 52, 137, + 197, 241, 1, 0, 0, 0, 224, 3, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 132, 0, 0, 0, 204, 0, @@ -508,7 +506,7 @@ const BYTE SolidColorShader[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -599,9 +597,9 @@ const BYTE SolidColorShader[] = 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, - 114, 32, 57, 46, 51, 48, - 46, 57, 50, 48, 48, 46, - 50, 48, 53, 52, 54, 0, + 114, 32, 54, 46, 51, 46, + 57, 54, 48, 48, 46, 49, + 54, 51, 56, 52, 0, 171, 73, 83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0, @@ -629,10 +627,9 @@ const BYTE SolidColorShader[] = }; #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -716,10 +713,10 @@ ret const BYTE RGBShader[] = { - 68, 88, 66, 67, 195, 54, - 227, 44, 79, 159, 121, 69, - 60, 252, 145, 90, 151, 241, - 175, 162, 1, 0, 0, 0, + 68, 88, 66, 67, 239, 198, + 87, 206, 69, 92, 245, 30, + 125, 195, 239, 77, 37, 241, + 175, 187, 1, 0, 0, 0, 232, 4, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 204, 0, 0, 0, 136, 1, @@ -795,7 +792,7 @@ const BYTE RGBShader[] = 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 2, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -899,9 +896,9 @@ const BYTE RGBShader[] = 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, - 114, 32, 57, 46, 51, 48, - 46, 57, 50, 48, 48, 46, - 50, 48, 53, 52, 54, 0, + 114, 32, 54, 46, 51, 46, + 57, 54, 48, 48, 46, 49, + 54, 51, 56, 52, 0, 171, 73, 83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0, @@ -929,10 +926,9 @@ const BYTE RGBShader[] = }; #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -1014,10 +1010,10 @@ ret const BYTE RGBAShader[] = { - 68, 88, 66, 67, 124, 18, - 8, 218, 34, 168, 20, 218, - 144, 232, 183, 104, 152, 211, - 5, 26, 1, 0, 0, 0, + 68, 88, 66, 67, 230, 59, + 90, 23, 60, 77, 18, 113, + 14, 129, 183, 152, 233, 55, + 111, 42, 1, 0, 0, 0, 196, 4, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 192, 0, 0, 0, 100, 1, @@ -1087,7 +1083,7 @@ const BYTE RGBAShader[] = 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1191,9 +1187,9 @@ const BYTE RGBAShader[] = 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, - 114, 32, 57, 46, 51, 48, - 46, 57, 50, 48, 48, 46, - 50, 48, 53, 52, 54, 0, + 114, 32, 54, 46, 51, 46, + 57, 54, 48, 48, 46, 49, + 54, 51, 56, 52, 0, 171, 73, 83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0, @@ -1221,10 +1217,9 @@ const BYTE RGBAShader[] = }; #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -1324,10 +1319,10 @@ ret const BYTE ComponentAlphaShader[] = { - 68, 88, 66, 67, 152, 37, - 117, 77, 87, 153, 20, 62, - 92, 142, 77, 134, 246, 203, - 174, 59, 1, 0, 0, 0, + 68, 88, 66, 67, 186, 162, + 72, 42, 69, 36, 160, 68, + 108, 121, 216, 238, 108, 37, + 6, 145, 1, 0, 0, 0, 68, 6, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 64, 1, 0, 0, 160, 2, @@ -1450,7 +1445,7 @@ const BYTE ComponentAlphaShader[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1561,9 +1556,9 @@ const BYTE ComponentAlphaShader[] = 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, - 114, 32, 57, 46, 51, 48, - 46, 57, 50, 48, 48, 46, - 50, 48, 53, 52, 54, 0, + 114, 32, 54, 46, 51, 46, + 57, 54, 48, 48, 46, 49, + 54, 51, 56, 52, 0, 171, 73, 83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0, @@ -1595,10 +1590,9 @@ const BYTE ComponentAlphaShader[] = }; #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -1714,10 +1708,10 @@ ret const BYTE YCbCrShader[] = { - 68, 88, 66, 67, 26, 187, - 43, 127, 28, 135, 212, 40, - 57, 230, 160, 198, 151, 242, - 106, 110, 1, 0, 0, 0, + 68, 88, 66, 67, 181, 118, + 100, 53, 248, 120, 136, 92, + 59, 190, 18, 201, 139, 224, + 32, 141, 1, 0, 0, 0, 212, 7, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 220, 1, 0, 0, 44, 4, @@ -1896,7 +1890,7 @@ const BYTE YCbCrShader[] = 0, 0, 15, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, - 6, 0, 0, 0, 0, 0, + 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1906,7 +1900,7 @@ const BYTE YCbCrShader[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -2022,9 +2016,9 @@ const BYTE YCbCrShader[] = 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, 114, 32, - 57, 46, 51, 48, 46, 57, - 50, 48, 48, 46, 50, 48, - 53, 52, 54, 0, 73, 83, + 54, 46, 51, 46, 57, 54, + 48, 48, 46, 49, 54, 51, + 56, 52, 0, 171, 73, 83, 71, 78, 80, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 56, 0, 0, 0, @@ -2051,10 +2045,9 @@ const BYTE YCbCrShader[] = }; #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -2165,10 +2158,10 @@ ret const BYTE LayerQuadMaskVS[] = { - 68, 88, 66, 67, 229, 18, - 238, 182, 176, 120, 118, 84, - 74, 135, 103, 188, 146, 51, - 229, 207, 1, 0, 0, 0, + 68, 88, 66, 67, 223, 251, + 10, 17, 13, 90, 47, 25, + 119, 198, 20, 157, 124, 193, + 251, 234, 1, 0, 0, 0, 120, 7, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 224, 1, 0, 0, 76, 4, @@ -2352,7 +2345,7 @@ const BYTE LayerQuadMaskVS[] = 116, 0, 0, 0, 16, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 4, 0, - 0, 0, 8, 0, 0, 0, + 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -2362,7 +2355,7 @@ const BYTE LayerQuadMaskVS[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 2, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -2453,10 +2446,10 @@ const BYTE LayerQuadMaskVS[] = 72, 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, - 101, 114, 32, 57, 46, 51, - 48, 46, 57, 50, 48, 48, - 46, 50, 48, 53, 52, 54, - 0, 171, 73, 83, 71, 78, + 101, 114, 32, 54, 46, 51, + 46, 57, 54, 48, 48, 46, + 49, 54, 51, 56, 52, 0, + 171, 171, 73, 83, 71, 78, 44, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, @@ -2487,10 +2480,9 @@ const BYTE LayerQuadMaskVS[] = }; #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -2605,10 +2597,10 @@ ret const BYTE LayerQuadMask3DVS[] = { - 68, 88, 66, 67, 81, 198, - 45, 88, 207, 133, 27, 66, - 4, 235, 107, 238, 69, 93, - 43, 232, 1, 0, 0, 0, + 68, 88, 66, 67, 151, 141, + 11, 11, 111, 244, 17, 242, + 119, 116, 248, 53, 235, 192, + 38, 193, 1, 0, 0, 0, 204, 7, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 24, 2, 0, 0, 160, 4, @@ -2806,7 +2798,7 @@ const BYTE LayerQuadMask3DVS[] = 116, 0, 0, 0, 17, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, - 0, 0, 9, 0, 0, 0, + 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -2816,7 +2808,7 @@ const BYTE LayerQuadMask3DVS[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -2907,10 +2899,10 @@ const BYTE LayerQuadMask3DVS[] = 72, 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, - 101, 114, 32, 57, 46, 51, - 48, 46, 57, 50, 48, 48, - 46, 50, 48, 53, 52, 54, - 0, 171, 73, 83, 71, 78, + 101, 114, 32, 54, 46, 51, + 46, 57, 54, 48, 48, 46, + 49, 54, 51, 56, 52, 0, + 171, 171, 73, 83, 71, 78, 44, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 0, 0, @@ -2941,10 +2933,9 @@ const BYTE LayerQuadMask3DVS[] = }; #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -3028,10 +3019,10 @@ ret const BYTE SolidColorShaderMask[] = { - 68, 88, 66, 67, 110, 173, - 179, 170, 121, 56, 16, 38, - 131, 202, 191, 200, 149, 158, - 191, 136, 1, 0, 0, 0, + 68, 88, 66, 67, 236, 109, + 19, 151, 23, 187, 157, 205, + 112, 188, 91, 187, 108, 106, + 138, 14, 1, 0, 0, 0, 232, 4, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 204, 0, 0, 0, 112, 1, @@ -3103,7 +3094,7 @@ const BYTE SolidColorShaderMask[] = 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -3207,9 +3198,9 @@ const BYTE SolidColorShaderMask[] = 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, - 114, 32, 57, 46, 51, 48, - 46, 57, 50, 48, 48, 46, - 50, 48, 53, 52, 54, 0, + 114, 32, 54, 46, 51, 46, + 57, 54, 48, 48, 46, 49, + 54, 51, 56, 52, 0, 171, 73, 83, 71, 78, 104, 0, 0, 0, 3, 0, 0, 0, 8, 0, 0, 0, 80, 0, @@ -3241,10 +3232,9 @@ const BYTE SolidColorShaderMask[] = }; #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -3339,10 +3329,10 @@ ret const BYTE RGBShaderMask[] = { - 68, 88, 66, 67, 90, 156, - 108, 215, 2, 184, 95, 225, - 139, 102, 23, 57, 234, 197, - 48, 52, 1, 0, 0, 0, + 68, 88, 66, 67, 30, 30, + 87, 58, 114, 156, 251, 151, + 29, 94, 34, 100, 228, 250, + 37, 251, 1, 0, 0, 0, 192, 5, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 8, 1, 0, 0, 32, 2, @@ -3443,7 +3433,7 @@ const BYTE RGBShaderMask[] = 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -3554,9 +3544,9 @@ const BYTE RGBShaderMask[] = 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, - 114, 32, 57, 46, 51, 48, - 46, 57, 50, 48, 48, 46, - 50, 48, 53, 52, 54, 0, + 114, 32, 54, 46, 51, 46, + 57, 54, 48, 48, 46, 49, + 54, 51, 56, 52, 0, 171, 73, 83, 71, 78, 104, 0, 0, 0, 3, 0, 0, 0, 8, 0, 0, 0, 80, 0, @@ -3588,10 +3578,9 @@ const BYTE RGBShaderMask[] = }; #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -3684,10 +3673,10 @@ ret const BYTE RGBAShaderMask[] = { - 68, 88, 66, 67, 106, 15, - 51, 47, 230, 18, 55, 40, - 97, 21, 143, 67, 32, 99, - 176, 32, 1, 0, 0, 0, + 68, 88, 66, 67, 188, 13, + 191, 168, 231, 201, 42, 209, + 88, 243, 29, 35, 226, 31, + 145, 20, 1, 0, 0, 0, 156, 5, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 252, 0, 0, 0, 252, 1, @@ -3782,7 +3771,7 @@ const BYTE RGBAShaderMask[] = 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -3893,9 +3882,9 @@ const BYTE RGBAShaderMask[] = 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, - 114, 32, 57, 46, 51, 48, - 46, 57, 50, 48, 48, 46, - 50, 48, 53, 52, 54, 0, + 114, 32, 54, 46, 51, 46, + 57, 54, 48, 48, 46, 49, + 54, 51, 56, 52, 0, 171, 73, 83, 71, 78, 104, 0, 0, 0, 3, 0, 0, 0, 8, 0, 0, 0, 80, 0, @@ -3927,10 +3916,9 @@ const BYTE RGBAShaderMask[] = }; #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -4028,10 +4016,10 @@ ret const BYTE RGBAShaderMask3D[] = { - 68, 88, 66, 67, 176, 186, - 72, 64, 199, 228, 205, 219, - 97, 152, 199, 132, 157, 124, - 226, 212, 1, 0, 0, 0, + 68, 88, 66, 67, 113, 141, + 78, 23, 128, 223, 235, 10, + 0, 97, 49, 111, 47, 53, + 229, 55, 1, 0, 0, 0, 24, 6, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 24, 1, 0, 0, 64, 2, @@ -4138,7 +4126,7 @@ const BYTE RGBAShaderMask3D[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -4258,9 +4246,9 @@ const BYTE RGBAShaderMask3D[] = 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, 114, 32, - 57, 46, 51, 48, 46, 57, - 50, 48, 48, 46, 50, 48, - 53, 52, 54, 0, 73, 83, + 54, 46, 51, 46, 57, 54, + 48, 48, 46, 49, 54, 51, + 56, 52, 0, 171, 73, 83, 71, 78, 104, 0, 0, 0, 3, 0, 0, 0, 8, 0, 0, 0, 80, 0, 0, 0, @@ -4291,10 +4279,9 @@ const BYTE RGBAShaderMask3D[] = }; #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -4421,10 +4408,10 @@ ret const BYTE YCbCrShaderMask[] = { - 68, 88, 66, 67, 115, 10, - 33, 43, 108, 217, 72, 92, - 140, 65, 97, 68, 194, 221, - 95, 25, 1, 0, 0, 0, + 68, 88, 66, 67, 103, 162, + 223, 236, 236, 142, 143, 151, + 73, 154, 187, 112, 81, 114, + 229, 251, 1, 0, 0, 0, 168, 8, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 24, 2, 0, 0, 196, 4, @@ -4628,7 +4615,7 @@ const BYTE YCbCrShaderMask[] = 116, 0, 0, 0, 17, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 7, 0, 0, 0, + 0, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -4638,7 +4625,7 @@ const BYTE YCbCrShaderMask[] = 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 2, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -4760,9 +4747,9 @@ const BYTE YCbCrShaderMask[] = 76, 83, 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, - 114, 32, 57, 46, 51, 48, - 46, 57, 50, 48, 48, 46, - 50, 48, 53, 52, 54, 0, + 114, 32, 54, 46, 51, 46, + 57, 54, 48, 48, 46, 49, + 54, 51, 56, 52, 0, 171, 73, 83, 71, 78, 104, 0, 0, 0, 3, 0, 0, 0, 8, 0, 0, 0, 80, 0, @@ -4794,10 +4781,9 @@ const BYTE YCbCrShaderMask[] = }; #if 0 // -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 // // -/// // Buffer Definitions: // // cbuffer $Globals @@ -4908,10 +4894,10 @@ ret const BYTE ComponentAlphaShaderMask[] = { - 68, 88, 66, 67, 66, 175, - 106, 103, 136, 76, 200, 80, - 95, 179, 74, 140, 138, 144, - 12, 21, 1, 0, 0, 0, + 68, 88, 66, 67, 245, 71, + 211, 223, 156, 101, 223, 204, + 145, 138, 53, 12, 16, 220, + 106, 83, 1, 0, 0, 0, 20, 7, 0, 0, 6, 0, 0, 0, 56, 0, 0, 0, 124, 1, 0, 0, 52, 3, @@ -5058,7 +5044,7 @@ const BYTE ComponentAlphaShaderMask[] = 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -5176,9 +5162,9 @@ const BYTE ComponentAlphaShaderMask[] = 76, 32, 83, 104, 97, 100, 101, 114, 32, 67, 111, 109, 112, 105, 108, 101, 114, 32, - 57, 46, 51, 48, 46, 57, - 50, 48, 48, 46, 50, 48, - 53, 52, 54, 0, 73, 83, + 54, 46, 51, 46, 57, 54, + 48, 48, 46, 49, 54, 51, + 56, 52, 0, 171, 73, 83, 71, 78, 104, 0, 0, 0, 3, 0, 0, 0, 8, 0, 0, 0, 80, 0, 0, 0, diff --git a/gfx/layers/d3d11/CompositorD3D11ShadersVR.h b/gfx/layers/d3d11/CompositorD3D11ShadersVR.h index ade0666127cf..f4ed05e4a27c 100644 --- a/gfx/layers/d3d11/CompositorD3D11ShadersVR.h +++ b/gfx/layers/d3d11/CompositorD3D11ShadersVR.h @@ -1,638 +1,636 @@ -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 -// -// -/// -// Buffer Definitions: -// -// cbuffer $Globals -// { -// -// float4 VREyeToSource; // Offset: 0 Size: 16 -// float4 VRDestinationScaleAndOffset;// Offset: 16 Size: 16 -// -// } -// -// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// $Globals cbuffer NA NA 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// POSITION 0 xy 0 NONE float xy -// TEXCOORD 0 xy 1 NONE float xy -// TEXCOORD 1 xy 2 NONE float xy -// TEXCOORD 2 xy 3 NONE float xy -// COLOR 0 xyzw 4 NONE float xyzw -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_Position 0 xyzw 0 POS float xyzw -// TEXCOORD 0 xyz 1 NONE float xyz -// TEXCOORD 1 xyz 2 NONE float xyz -// TEXCOORD 2 xyz 3 NONE float xyz -// COLOR 0 xyzw 4 NONE float xyzw -// -// -// Constant buffer to DX9 shader constant mappings: -// -// Target Reg Buffer Start Reg # of Regs Data Conversion -// ---------- ------- --------- --------- ---------------------- -// c1 cb0 0 2 ( FLT, FLT, FLT, FLT) -// -// -// Runtime generated constant mappings: -// -// Target Reg Constant Description -// ---------- -------------------------------------------------- -// c0 Vertex Shader position offset -// -// -// Level9 shader bytecode: -// - vs_2_x - def c3, 0.5, 1, 0, 0 - dcl_texcoord v0 - dcl_texcoord1 v1 - dcl_texcoord2 v2 - dcl_texcoord3 v3 - dcl_texcoord4 v4 - mad oT0.xy, c1, v1, c1.zwzw - mad oT1.xy, c1, v2, c1.zwzw - mad oT2.xy, c1, v3, c1.zwzw - mad r0.xy, v0, c2.zwzw, c2 - add oPos.xy, r0, c0 - mov oPos.zw, c3.xyxy - mov oT0.z, c3.y - mov oT1.z, c3.y - mov oT2.z, c3.y - mov oT3, v4 - -// approximately 10 instruction slots used -vs_4_0 -dcl_constantbuffer cb0[2], immediateIndexed -dcl_input v0.xy -dcl_input v1.xy -dcl_input v2.xy -dcl_input v3.xy -dcl_input v4.xyzw -dcl_output_siv o0.xyzw, position -dcl_output o1.xyz -dcl_output o2.xyz -dcl_output o3.xyz -dcl_output o4.xyzw -mad o0.xy, v0.xyxx, cb0[1].zwzz, cb0[1].xyxx -mov o0.zw, l(0,0,0.500000,1.000000) -mad o1.xy, cb0[0].xyxx, v1.xyxx, cb0[0].zwzz -mov o1.z, l(1.000000) -mad o2.xy, cb0[0].xyxx, v2.xyxx, cb0[0].zwzz -mov o2.z, l(1.000000) -mad o3.xy, cb0[0].xyxx, v3.xyxx, cb0[0].zwzz -mov o3.z, l(1.000000) -mov o4.xyzw, v4.xyzw -ret -// Approximately 10 instruction slots used -#endif - -const BYTE OculusVRDistortionVS[] = -{ - 68, 88, 66, 67, 146, 215, - 61, 238, 94, 6, 58, 25, - 65, 203, 120, 251, 26, 22, - 109, 4, 1, 0, 0, 0, - 244, 5, 0, 0, 6, 0, - 0, 0, 56, 0, 0, 0, - 108, 1, 0, 0, 44, 3, - 0, 0, 168, 3, 0, 0, - 176, 4, 0, 0, 80, 5, - 0, 0, 65, 111, 110, 57, - 44, 1, 0, 0, 44, 1, - 0, 0, 0, 2, 254, 255, - 248, 0, 0, 0, 52, 0, - 0, 0, 1, 0, 36, 0, - 0, 0, 48, 0, 0, 0, - 48, 0, 0, 0, 36, 0, - 1, 0, 48, 0, 0, 0, - 0, 0, 2, 0, 1, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 2, 254, 255, - 81, 0, 0, 5, 3, 0, - 15, 160, 0, 0, 0, 63, - 0, 0, 128, 63, 0, 0, - 0, 0, 0, 0, 0, 0, - 31, 0, 0, 2, 5, 0, - 0, 128, 0, 0, 15, 144, - 31, 0, 0, 2, 5, 0, - 1, 128, 1, 0, 15, 144, - 31, 0, 0, 2, 5, 0, - 2, 128, 2, 0, 15, 144, - 31, 0, 0, 2, 5, 0, - 3, 128, 3, 0, 15, 144, - 31, 0, 0, 2, 5, 0, - 4, 128, 4, 0, 15, 144, - 4, 0, 0, 4, 0, 0, - 3, 224, 1, 0, 228, 160, - 1, 0, 228, 144, 1, 0, - 238, 160, 4, 0, 0, 4, - 1, 0, 3, 224, 1, 0, - 228, 160, 2, 0, 228, 144, - 1, 0, 238, 160, 4, 0, - 0, 4, 2, 0, 3, 224, - 1, 0, 228, 160, 3, 0, - 228, 144, 1, 0, 238, 160, - 4, 0, 0, 4, 0, 0, - 3, 128, 0, 0, 228, 144, - 2, 0, 238, 160, 2, 0, - 228, 160, 2, 0, 0, 3, - 0, 0, 3, 192, 0, 0, - 228, 128, 0, 0, 228, 160, - 1, 0, 0, 2, 0, 0, - 12, 192, 3, 0, 68, 160, - 1, 0, 0, 2, 0, 0, - 4, 224, 3, 0, 85, 160, - 1, 0, 0, 2, 1, 0, - 4, 224, 3, 0, 85, 160, - 1, 0, 0, 2, 2, 0, - 4, 224, 3, 0, 85, 160, - 1, 0, 0, 2, 3, 0, - 15, 224, 4, 0, 228, 144, - 255, 255, 0, 0, 83, 72, - 68, 82, 184, 1, 0, 0, - 64, 0, 1, 0, 110, 0, - 0, 0, 89, 0, 0, 4, - 70, 142, 32, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 95, 0, 0, 3, 50, 16, - 16, 0, 0, 0, 0, 0, - 95, 0, 0, 3, 50, 16, - 16, 0, 1, 0, 0, 0, - 95, 0, 0, 3, 50, 16, - 16, 0, 2, 0, 0, 0, - 95, 0, 0, 3, 50, 16, - 16, 0, 3, 0, 0, 0, - 95, 0, 0, 3, 242, 16, - 16, 0, 4, 0, 0, 0, - 103, 0, 0, 4, 242, 32, - 16, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 101, 0, - 0, 3, 114, 32, 16, 0, - 1, 0, 0, 0, 101, 0, - 0, 3, 114, 32, 16, 0, - 2, 0, 0, 0, 101, 0, - 0, 3, 114, 32, 16, 0, - 3, 0, 0, 0, 101, 0, - 0, 3, 242, 32, 16, 0, - 4, 0, 0, 0, 50, 0, - 0, 11, 50, 32, 16, 0, - 0, 0, 0, 0, 70, 16, - 16, 0, 0, 0, 0, 0, - 230, 138, 32, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 70, 128, 32, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 54, 0, 0, 8, 194, 32, - 16, 0, 0, 0, 0, 0, - 2, 64, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 63, 0, 0, - 128, 63, 50, 0, 0, 11, - 50, 32, 16, 0, 1, 0, - 0, 0, 70, 128, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 70, 16, 16, 0, - 1, 0, 0, 0, 230, 138, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 54, 0, - 0, 5, 66, 32, 16, 0, - 1, 0, 0, 0, 1, 64, - 0, 0, 0, 0, 128, 63, - 50, 0, 0, 11, 50, 32, - 16, 0, 2, 0, 0, 0, - 70, 128, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 70, 16, 16, 0, 2, 0, - 0, 0, 230, 138, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 54, 0, 0, 5, - 66, 32, 16, 0, 2, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 50, 0, - 0, 11, 50, 32, 16, 0, - 3, 0, 0, 0, 70, 128, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 70, 16, - 16, 0, 3, 0, 0, 0, - 230, 138, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 54, 0, 0, 5, 66, 32, - 16, 0, 3, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 54, 0, 0, 5, - 242, 32, 16, 0, 4, 0, - 0, 0, 70, 30, 16, 0, - 4, 0, 0, 0, 62, 0, - 0, 1, 83, 84, 65, 84, - 116, 0, 0, 0, 10, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 10, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 6, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 82, 68, 69, 70, 0, 1, - 0, 0, 1, 0, 0, 0, - 72, 0, 0, 0, 1, 0, - 0, 0, 28, 0, 0, 0, - 0, 4, 254, 255, 0, 1, - 0, 0, 204, 0, 0, 0, - 60, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 36, 71, 108, 111, - 98, 97, 108, 115, 0, 171, - 171, 171, 60, 0, 0, 0, - 2, 0, 0, 0, 96, 0, - 0, 0, 32, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 144, 0, 0, 0, - 0, 0, 0, 0, 16, 0, - 0, 0, 2, 0, 0, 0, - 160, 0, 0, 0, 0, 0, - 0, 0, 176, 0, 0, 0, - 16, 0, 0, 0, 16, 0, - 0, 0, 2, 0, 0, 0, - 160, 0, 0, 0, 0, 0, - 0, 0, 86, 82, 69, 121, - 101, 84, 111, 83, 111, 117, - 114, 99, 101, 0, 171, 171, - 1, 0, 3, 0, 1, 0, - 4, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 86, 82, - 68, 101, 115, 116, 105, 110, - 97, 116, 105, 111, 110, 83, - 99, 97, 108, 101, 65, 110, - 100, 79, 102, 102, 115, 101, - 116, 0, 77, 105, 99, 114, - 111, 115, 111, 102, 116, 32, - 40, 82, 41, 32, 72, 76, - 83, 76, 32, 83, 104, 97, - 100, 101, 114, 32, 67, 111, - 109, 112, 105, 108, 101, 114, - 32, 57, 46, 51, 48, 46, - 57, 50, 48, 48, 46, 50, - 48, 53, 52, 54, 0, 171, - 73, 83, 71, 78, 152, 0, - 0, 0, 5, 0, 0, 0, - 8, 0, 0, 0, 128, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 3, 3, 0, 0, 137, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 3, 3, 0, 0, 137, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 2, 0, 0, 0, - 3, 3, 0, 0, 137, 0, - 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 3, 0, 0, 0, - 3, 3, 0, 0, 146, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 4, 0, 0, 0, - 15, 15, 0, 0, 80, 79, - 83, 73, 84, 73, 79, 78, - 0, 84, 69, 88, 67, 79, - 79, 82, 68, 0, 67, 79, - 76, 79, 82, 0, 79, 83, - 71, 78, 156, 0, 0, 0, - 5, 0, 0, 0, 8, 0, - 0, 0, 128, 0, 0, 0, - 0, 0, 0, 0, 1, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 15, 0, - 0, 0, 140, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 7, 8, - 0, 0, 140, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 2, 0, 0, 0, 7, 8, - 0, 0, 140, 0, 0, 0, - 2, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 3, 0, 0, 0, 7, 8, - 0, 0, 149, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 4, 0, 0, 0, 15, 0, - 0, 0, 83, 86, 95, 80, - 111, 115, 105, 116, 105, 111, - 110, 0, 84, 69, 88, 67, - 79, 79, 82, 68, 0, 67, - 79, 76, 79, 82, 0, 171 -}; -#if 0 -// -// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 -// -// -/// -// Resource Bindings: -// -// Name Type Format Dim Slot Elements -// ------------------------------ ---------- ------- ----------- ---- -------- -// Linear sampler NA NA 0 1 -// Texture texture float4 2d 0 1 -// -// -// -// Input signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_Position 0 xyzw 0 POS float -// TEXCOORD 0 xyz 1 NONE float xy -// TEXCOORD 1 xyz 2 NONE float xy -// TEXCOORD 2 xyz 3 NONE float xy -// COLOR 0 xyzw 4 NONE float x -// -// -// Output signature: -// -// Name Index Mask Register SysValue Format Used -// -------------------- ----- ------ -------- -------- ------- ------ -// SV_Target 0 xyzw 0 TARGET float xyzw -// -// -// Sampler/Resource to DX9 shader sampler mappings: -// -// Target Sampler Source Sampler Source Resource -// -------------- --------------- ---------------- -// s0 s0 t0 -// -// -// Level9 shader bytecode: -// - ps_2_x - def c0, 1, 0, 0, 0 - dcl t0.xyz - dcl t1.xyz - dcl t2.xyz - dcl t3 - dcl_2d s0 - texld r0, t1, s0 - texld r1, t0, s0 - mul r1.x, r1.x, t3.x - mul r1.y, r0.y, t3.x - texld r0, t2, s0 - mul r1.z, r0.z, t3.x - mov r1.w, c0.x - mov oC0, r1 - -// approximately 8 instruction slots used (3 texture, 5 arithmetic) -ps_4_0 -dcl_sampler s0, mode_default -dcl_resource_texture2d (float,float,float,float) t0 -dcl_input_ps linear v1.xy -dcl_input_ps linear v2.xy -dcl_input_ps linear v3.xy -dcl_input_ps linear v4.x -dcl_output o0.xyzw -dcl_temps 1 -sample r0.xyzw, v1.xyxx, t0.xyzw, s0 -mul o0.x, r0.x, v4.x -sample r0.xyzw, v2.xyxx, t0.xyzw, s0 -mul o0.y, r0.y, v4.x -sample r0.xyzw, v3.xyxx, t0.xyzw, s0 -mul o0.z, r0.z, v4.x -mov o0.w, l(1.000000) -ret -// Approximately 8 instruction slots used -#endif - -const BYTE OculusVRDistortionPS[] = -{ - 68, 88, 66, 67, 150, 176, - 84, 101, 196, 27, 87, 110, - 226, 144, 161, 15, 69, 81, - 48, 158, 1, 0, 0, 0, - 128, 4, 0, 0, 6, 0, - 0, 0, 56, 0, 0, 0, - 60, 1, 0, 0, 132, 2, - 0, 0, 0, 3, 0, 0, - 168, 3, 0, 0, 76, 4, - 0, 0, 65, 111, 110, 57, - 252, 0, 0, 0, 252, 0, - 0, 0, 0, 2, 255, 255, - 212, 0, 0, 0, 40, 0, - 0, 0, 0, 0, 40, 0, - 0, 0, 40, 0, 0, 0, - 40, 0, 1, 0, 36, 0, - 0, 0, 40, 0, 0, 0, - 0, 0, 1, 2, 255, 255, - 81, 0, 0, 5, 0, 0, - 15, 160, 0, 0, 128, 63, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 31, 0, 0, 2, 0, 0, - 0, 128, 0, 0, 7, 176, - 31, 0, 0, 2, 0, 0, - 0, 128, 1, 0, 7, 176, - 31, 0, 0, 2, 0, 0, - 0, 128, 2, 0, 7, 176, - 31, 0, 0, 2, 0, 0, - 0, 128, 3, 0, 15, 176, - 31, 0, 0, 2, 0, 0, - 0, 144, 0, 8, 15, 160, - 66, 0, 0, 3, 0, 0, - 15, 128, 1, 0, 228, 176, - 0, 8, 228, 160, 66, 0, - 0, 3, 1, 0, 15, 128, - 0, 0, 228, 176, 0, 8, - 228, 160, 5, 0, 0, 3, - 1, 0, 1, 128, 1, 0, - 0, 128, 3, 0, 0, 176, - 5, 0, 0, 3, 1, 0, - 2, 128, 0, 0, 85, 128, - 3, 0, 0, 176, 66, 0, - 0, 3, 0, 0, 15, 128, - 2, 0, 228, 176, 0, 8, - 228, 160, 5, 0, 0, 3, - 1, 0, 4, 128, 0, 0, - 170, 128, 3, 0, 0, 176, - 1, 0, 0, 2, 1, 0, - 8, 128, 0, 0, 0, 160, - 1, 0, 0, 2, 0, 8, - 15, 128, 1, 0, 228, 128, - 255, 255, 0, 0, 83, 72, - 68, 82, 64, 1, 0, 0, - 64, 0, 0, 0, 80, 0, - 0, 0, 90, 0, 0, 3, - 0, 96, 16, 0, 0, 0, - 0, 0, 88, 24, 0, 4, - 0, 112, 16, 0, 0, 0, - 0, 0, 85, 85, 0, 0, - 98, 16, 0, 3, 50, 16, - 16, 0, 1, 0, 0, 0, - 98, 16, 0, 3, 50, 16, - 16, 0, 2, 0, 0, 0, - 98, 16, 0, 3, 50, 16, - 16, 0, 3, 0, 0, 0, - 98, 16, 0, 3, 18, 16, - 16, 0, 4, 0, 0, 0, - 101, 0, 0, 3, 242, 32, - 16, 0, 0, 0, 0, 0, - 104, 0, 0, 2, 1, 0, - 0, 0, 69, 0, 0, 9, - 242, 0, 16, 0, 0, 0, - 0, 0, 70, 16, 16, 0, - 1, 0, 0, 0, 70, 126, - 16, 0, 0, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 56, 0, 0, 7, - 18, 32, 16, 0, 0, 0, - 0, 0, 10, 0, 16, 0, - 0, 0, 0, 0, 10, 16, - 16, 0, 4, 0, 0, 0, - 69, 0, 0, 9, 242, 0, - 16, 0, 0, 0, 0, 0, - 70, 16, 16, 0, 2, 0, - 0, 0, 70, 126, 16, 0, - 0, 0, 0, 0, 0, 96, - 16, 0, 0, 0, 0, 0, - 56, 0, 0, 7, 34, 32, - 16, 0, 0, 0, 0, 0, - 26, 0, 16, 0, 0, 0, - 0, 0, 10, 16, 16, 0, - 4, 0, 0, 0, 69, 0, - 0, 9, 242, 0, 16, 0, - 0, 0, 0, 0, 70, 16, - 16, 0, 3, 0, 0, 0, - 70, 126, 16, 0, 0, 0, - 0, 0, 0, 96, 16, 0, - 0, 0, 0, 0, 56, 0, - 0, 7, 66, 32, 16, 0, - 0, 0, 0, 0, 42, 0, - 16, 0, 0, 0, 0, 0, - 10, 16, 16, 0, 4, 0, - 0, 0, 54, 0, 0, 5, - 130, 32, 16, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 128, 63, 62, 0, - 0, 1, 83, 84, 65, 84, - 116, 0, 0, 0, 8, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 5, 0, - 0, 0, 3, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 82, 68, 69, 70, 160, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 2, 0, - 0, 0, 28, 0, 0, 0, - 0, 4, 255, 255, 0, 1, - 0, 0, 107, 0, 0, 0, - 92, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, - 0, 0, 99, 0, 0, 0, - 2, 0, 0, 0, 5, 0, - 0, 0, 4, 0, 0, 0, - 255, 255, 255, 255, 0, 0, - 0, 0, 1, 0, 0, 0, - 13, 0, 0, 0, 76, 105, - 110, 101, 97, 114, 0, 84, - 101, 120, 116, 117, 114, 101, - 0, 77, 105, 99, 114, 111, - 115, 111, 102, 116, 32, 40, - 82, 41, 32, 72, 76, 83, - 76, 32, 83, 104, 97, 100, - 101, 114, 32, 67, 111, 109, - 112, 105, 108, 101, 114, 32, - 57, 46, 51, 48, 46, 57, - 50, 48, 48, 46, 50, 48, - 53, 52, 54, 0, 171, 171, - 73, 83, 71, 78, 156, 0, - 0, 0, 5, 0, 0, 0, - 8, 0, 0, 0, 128, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, - 15, 0, 0, 0, 140, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 1, 0, 0, 0, - 7, 3, 0, 0, 140, 0, - 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 2, 0, 0, 0, - 7, 3, 0, 0, 140, 0, - 0, 0, 2, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 3, 0, 0, 0, - 7, 3, 0, 0, 149, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 3, 0, - 0, 0, 4, 0, 0, 0, - 15, 1, 0, 0, 83, 86, - 95, 80, 111, 115, 105, 116, - 105, 111, 110, 0, 84, 69, - 88, 67, 79, 79, 82, 68, - 0, 67, 79, 76, 79, 82, - 0, 171, 79, 83, 71, 78, - 44, 0, 0, 0, 1, 0, - 0, 0, 8, 0, 0, 0, - 32, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 0, 0, - 0, 0, 15, 0, 0, 0, - 83, 86, 95, 84, 97, 114, - 103, 101, 116, 0, 171, 171 -}; +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Buffer Definitions: +// +// cbuffer $Globals +// { +// +// float4 VREyeToSource; // Offset: 0 Size: 16 +// float4 VRDestinationScaleAndOffset;// Offset: 16 Size: 16 +// +// } +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// $Globals cbuffer NA NA 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// POSITION 0 xy 0 NONE float xy +// TEXCOORD 0 xy 1 NONE float xy +// TEXCOORD 1 xy 2 NONE float xy +// TEXCOORD 2 xy 3 NONE float xy +// COLOR 0 xyzw 4 NONE float xyzw +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 POS float xyzw +// TEXCOORD 0 xyz 1 NONE float xyz +// TEXCOORD 1 xyz 2 NONE float xyz +// TEXCOORD 2 xyz 3 NONE float xyz +// COLOR 0 xyzw 4 NONE float xyzw +// +// +// Constant buffer to DX9 shader constant mappings: +// +// Target Reg Buffer Start Reg # of Regs Data Conversion +// ---------- ------- --------- --------- ---------------------- +// c1 cb0 0 2 ( FLT, FLT, FLT, FLT) +// +// +// Runtime generated constant mappings: +// +// Target Reg Constant Description +// ---------- -------------------------------------------------- +// c0 Vertex Shader position offset +// +// +// Level9 shader bytecode: +// + vs_2_x + def c3, 0.5, 1, 0, 0 + dcl_texcoord v0 + dcl_texcoord1 v1 + dcl_texcoord2 v2 + dcl_texcoord3 v3 + dcl_texcoord4 v4 + mad oT0.xy, v1, c1.zwzw, c1 + mad oT1.xy, v2, c1.zwzw, c1 + mad oT2.xy, v3, c1.zwzw, c1 + mad r0.xy, v0, c2.zwzw, c2 + add oPos.xy, r0, c0 + mov oPos.zw, c3.xyxy + mov oT0.z, c3.y + mov oT1.z, c3.y + mov oT2.z, c3.y + mov oT3, v4 + +// approximately 10 instruction slots used +vs_4_0 +dcl_constantbuffer cb0[2], immediateIndexed +dcl_input v0.xy +dcl_input v1.xy +dcl_input v2.xy +dcl_input v3.xy +dcl_input v4.xyzw +dcl_output_siv o0.xyzw, position +dcl_output o1.xyz +dcl_output o2.xyz +dcl_output o3.xyz +dcl_output o4.xyzw +mad o0.xy, v0.xyxx, cb0[1].zwzz, cb0[1].xyxx +mov o0.zw, l(0,0,0.500000,1.000000) +mad o1.xy, v1.xyxx, cb0[0].zwzz, cb0[0].xyxx +mov o1.z, l(1.000000) +mad o2.xy, v2.xyxx, cb0[0].zwzz, cb0[0].xyxx +mov o2.z, l(1.000000) +mad o3.xy, v3.xyxx, cb0[0].zwzz, cb0[0].xyxx +mov o3.z, l(1.000000) +mov o4.xyzw, v4.xyzw +ret +// Approximately 10 instruction slots used +#endif + +const BYTE OculusVRDistortionVS[] = +{ + 68, 88, 66, 67, 3, 61, + 196, 122, 10, 53, 44, 234, + 18, 242, 195, 238, 42, 90, + 72, 193, 1, 0, 0, 0, + 244, 5, 0, 0, 6, 0, + 0, 0, 56, 0, 0, 0, + 108, 1, 0, 0, 44, 3, + 0, 0, 168, 3, 0, 0, + 176, 4, 0, 0, 80, 5, + 0, 0, 65, 111, 110, 57, + 44, 1, 0, 0, 44, 1, + 0, 0, 0, 2, 254, 255, + 248, 0, 0, 0, 52, 0, + 0, 0, 1, 0, 36, 0, + 0, 0, 48, 0, 0, 0, + 48, 0, 0, 0, 36, 0, + 1, 0, 48, 0, 0, 0, + 0, 0, 2, 0, 1, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 2, 254, 255, + 81, 0, 0, 5, 3, 0, + 15, 160, 0, 0, 0, 63, + 0, 0, 128, 63, 0, 0, + 0, 0, 0, 0, 0, 0, + 31, 0, 0, 2, 5, 0, + 0, 128, 0, 0, 15, 144, + 31, 0, 0, 2, 5, 0, + 1, 128, 1, 0, 15, 144, + 31, 0, 0, 2, 5, 0, + 2, 128, 2, 0, 15, 144, + 31, 0, 0, 2, 5, 0, + 3, 128, 3, 0, 15, 144, + 31, 0, 0, 2, 5, 0, + 4, 128, 4, 0, 15, 144, + 4, 0, 0, 4, 0, 0, + 3, 224, 1, 0, 228, 144, + 1, 0, 238, 160, 1, 0, + 228, 160, 4, 0, 0, 4, + 1, 0, 3, 224, 2, 0, + 228, 144, 1, 0, 238, 160, + 1, 0, 228, 160, 4, 0, + 0, 4, 2, 0, 3, 224, + 3, 0, 228, 144, 1, 0, + 238, 160, 1, 0, 228, 160, + 4, 0, 0, 4, 0, 0, + 3, 128, 0, 0, 228, 144, + 2, 0, 238, 160, 2, 0, + 228, 160, 2, 0, 0, 3, + 0, 0, 3, 192, 0, 0, + 228, 128, 0, 0, 228, 160, + 1, 0, 0, 2, 0, 0, + 12, 192, 3, 0, 68, 160, + 1, 0, 0, 2, 0, 0, + 4, 224, 3, 0, 85, 160, + 1, 0, 0, 2, 1, 0, + 4, 224, 3, 0, 85, 160, + 1, 0, 0, 2, 2, 0, + 4, 224, 3, 0, 85, 160, + 1, 0, 0, 2, 3, 0, + 15, 224, 4, 0, 228, 144, + 255, 255, 0, 0, 83, 72, + 68, 82, 184, 1, 0, 0, + 64, 0, 1, 0, 110, 0, + 0, 0, 89, 0, 0, 4, + 70, 142, 32, 0, 0, 0, + 0, 0, 2, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 0, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 1, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 95, 0, 0, 3, 50, 16, + 16, 0, 3, 0, 0, 0, + 95, 0, 0, 3, 242, 16, + 16, 0, 4, 0, 0, 0, + 103, 0, 0, 4, 242, 32, + 16, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 1, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 2, 0, 0, 0, 101, 0, + 0, 3, 114, 32, 16, 0, + 3, 0, 0, 0, 101, 0, + 0, 3, 242, 32, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 11, 50, 32, 16, 0, + 0, 0, 0, 0, 70, 16, + 16, 0, 0, 0, 0, 0, + 230, 138, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 70, 128, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 54, 0, 0, 8, 194, 32, + 16, 0, 0, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 63, 0, 0, + 128, 63, 50, 0, 0, 11, + 50, 32, 16, 0, 1, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 230, 138, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 70, 128, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 54, 0, + 0, 5, 66, 32, 16, 0, + 1, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 63, + 50, 0, 0, 11, 50, 32, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 230, 138, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 70, 128, 32, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 54, 0, 0, 5, + 66, 32, 16, 0, 2, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 50, 0, + 0, 11, 50, 32, 16, 0, + 3, 0, 0, 0, 70, 16, + 16, 0, 3, 0, 0, 0, + 230, 138, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 70, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 54, 0, 0, 5, 66, 32, + 16, 0, 3, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 63, 54, 0, 0, 5, + 242, 32, 16, 0, 4, 0, + 0, 0, 70, 30, 16, 0, + 4, 0, 0, 0, 62, 0, + 0, 1, 83, 84, 65, 84, + 116, 0, 0, 0, 10, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 10, 0, + 0, 0, 4, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 82, 68, 69, 70, 0, 1, + 0, 0, 1, 0, 0, 0, + 72, 0, 0, 0, 1, 0, + 0, 0, 28, 0, 0, 0, + 0, 4, 254, 255, 0, 1, + 0, 0, 204, 0, 0, 0, + 60, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 36, 71, 108, 111, + 98, 97, 108, 115, 0, 171, + 171, 171, 60, 0, 0, 0, + 2, 0, 0, 0, 96, 0, + 0, 0, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 144, 0, 0, 0, + 0, 0, 0, 0, 16, 0, + 0, 0, 2, 0, 0, 0, + 160, 0, 0, 0, 0, 0, + 0, 0, 176, 0, 0, 0, + 16, 0, 0, 0, 16, 0, + 0, 0, 2, 0, 0, 0, + 160, 0, 0, 0, 0, 0, + 0, 0, 86, 82, 69, 121, + 101, 84, 111, 83, 111, 117, + 114, 99, 101, 0, 171, 171, + 1, 0, 3, 0, 1, 0, + 4, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 86, 82, + 68, 101, 115, 116, 105, 110, + 97, 116, 105, 111, 110, 83, + 99, 97, 108, 101, 65, 110, + 100, 79, 102, 102, 115, 101, + 116, 0, 77, 105, 99, 114, + 111, 115, 111, 102, 116, 32, + 40, 82, 41, 32, 72, 76, + 83, 76, 32, 83, 104, 97, + 100, 101, 114, 32, 67, 111, + 109, 112, 105, 108, 101, 114, + 32, 54, 46, 51, 46, 57, + 54, 48, 48, 46, 49, 54, + 51, 56, 52, 0, 171, 171, + 73, 83, 71, 78, 152, 0, + 0, 0, 5, 0, 0, 0, + 8, 0, 0, 0, 128, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 3, 3, 0, 0, 137, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 3, 3, 0, 0, 137, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 3, 3, 0, 0, 137, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 3, 3, 0, 0, 146, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 15, 15, 0, 0, 80, 79, + 83, 73, 84, 73, 79, 78, + 0, 84, 69, 88, 67, 79, + 79, 82, 68, 0, 67, 79, + 76, 79, 82, 0, 79, 83, + 71, 78, 156, 0, 0, 0, + 5, 0, 0, 0, 8, 0, + 0, 0, 128, 0, 0, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 15, 0, + 0, 0, 140, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 1, 0, 0, 0, 7, 8, + 0, 0, 140, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 2, 0, 0, 0, 7, 8, + 0, 0, 140, 0, 0, 0, + 2, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 3, 0, 0, 0, 7, 8, + 0, 0, 149, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 0, 0, + 4, 0, 0, 0, 15, 0, + 0, 0, 83, 86, 95, 80, + 111, 115, 105, 116, 105, 111, + 110, 0, 84, 69, 88, 67, + 79, 79, 82, 68, 0, 67, + 79, 76, 79, 82, 0, 171 +}; +#if 0 +// +// Generated by Microsoft (R) HLSL Shader Compiler 6.3.9600.16384 +// +// +// Resource Bindings: +// +// Name Type Format Dim Slot Elements +// ------------------------------ ---------- ------- ----------- ---- -------- +// Linear sampler NA NA 0 1 +// Texture texture float4 2d 0 1 +// +// +// +// Input signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Position 0 xyzw 0 POS float +// TEXCOORD 0 xyz 1 NONE float xy +// TEXCOORD 1 xyz 2 NONE float xy +// TEXCOORD 2 xyz 3 NONE float xy +// COLOR 0 xyzw 4 NONE float x +// +// +// Output signature: +// +// Name Index Mask Register SysValue Format Used +// -------------------- ----- ------ -------- -------- ------- ------ +// SV_Target 0 xyzw 0 TARGET float xyzw +// +// +// Sampler/Resource to DX9 shader sampler mappings: +// +// Target Sampler Source Sampler Source Resource +// -------------- --------------- ---------------- +// s0 s0 t0 +// +// +// Level9 shader bytecode: +// + ps_2_x + def c0, 1, 0, 0, 0 + dcl t0.xyz + dcl t1.xyz + dcl t2.xyz + dcl t3 + dcl_2d s0 + texld r0, t1, s0 + texld r1, t0, s0 + mul r1.x, r1.x, t3.x + mul r1.y, r0.y, t3.x + texld r0, t2, s0 + mul r1.z, r0.z, t3.x + mov r1.w, c0.x + mov oC0, r1 + +// approximately 8 instruction slots used (3 texture, 5 arithmetic) +ps_4_0 +dcl_sampler s0, mode_default +dcl_resource_texture2d (float,float,float,float) t0 +dcl_input_ps linear v1.xy +dcl_input_ps linear v2.xy +dcl_input_ps linear v3.xy +dcl_input_ps linear v4.x +dcl_output o0.xyzw +dcl_temps 1 +sample r0.xyzw, v1.xyxx, t0.xyzw, s0 +mul o0.x, r0.x, v4.x +sample r0.xyzw, v2.xyxx, t0.xyzw, s0 +mul o0.y, r0.y, v4.x +sample r0.xyzw, v3.xyxx, t0.xyzw, s0 +mul o0.z, r0.z, v4.x +mov o0.w, l(1.000000) +ret +// Approximately 8 instruction slots used +#endif + +const BYTE OculusVRDistortionPS[] = +{ + 68, 88, 66, 67, 108, 219, + 61, 216, 27, 0, 27, 222, + 242, 132, 183, 21, 166, 141, + 130, 39, 1, 0, 0, 0, + 128, 4, 0, 0, 6, 0, + 0, 0, 56, 0, 0, 0, + 60, 1, 0, 0, 132, 2, + 0, 0, 0, 3, 0, 0, + 168, 3, 0, 0, 76, 4, + 0, 0, 65, 111, 110, 57, + 252, 0, 0, 0, 252, 0, + 0, 0, 0, 2, 255, 255, + 212, 0, 0, 0, 40, 0, + 0, 0, 0, 0, 40, 0, + 0, 0, 40, 0, 0, 0, + 40, 0, 1, 0, 36, 0, + 0, 0, 40, 0, 0, 0, + 0, 0, 1, 2, 255, 255, + 81, 0, 0, 5, 0, 0, + 15, 160, 0, 0, 128, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 31, 0, 0, 2, 0, 0, + 0, 128, 0, 0, 7, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 1, 0, 7, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 2, 0, 7, 176, + 31, 0, 0, 2, 0, 0, + 0, 128, 3, 0, 15, 176, + 31, 0, 0, 2, 0, 0, + 0, 144, 0, 8, 15, 160, + 66, 0, 0, 3, 0, 0, + 15, 128, 1, 0, 228, 176, + 0, 8, 228, 160, 66, 0, + 0, 3, 1, 0, 15, 128, + 0, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 1, 0, 1, 128, 1, 0, + 0, 128, 3, 0, 0, 176, + 5, 0, 0, 3, 1, 0, + 2, 128, 0, 0, 85, 128, + 3, 0, 0, 176, 66, 0, + 0, 3, 0, 0, 15, 128, + 2, 0, 228, 176, 0, 8, + 228, 160, 5, 0, 0, 3, + 1, 0, 4, 128, 0, 0, + 170, 128, 3, 0, 0, 176, + 1, 0, 0, 2, 1, 0, + 8, 128, 0, 0, 0, 160, + 1, 0, 0, 2, 0, 8, + 15, 128, 1, 0, 228, 128, + 255, 255, 0, 0, 83, 72, + 68, 82, 64, 1, 0, 0, + 64, 0, 0, 0, 80, 0, + 0, 0, 90, 0, 0, 3, + 0, 96, 16, 0, 0, 0, + 0, 0, 88, 24, 0, 4, + 0, 112, 16, 0, 0, 0, + 0, 0, 85, 85, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 1, 0, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 2, 0, 0, 0, + 98, 16, 0, 3, 50, 16, + 16, 0, 3, 0, 0, 0, + 98, 16, 0, 3, 18, 16, + 16, 0, 4, 0, 0, 0, + 101, 0, 0, 3, 242, 32, + 16, 0, 0, 0, 0, 0, + 104, 0, 0, 2, 1, 0, + 0, 0, 69, 0, 0, 9, + 242, 0, 16, 0, 0, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 56, 0, 0, 7, + 18, 32, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 10, 16, + 16, 0, 4, 0, 0, 0, + 69, 0, 0, 9, 242, 0, + 16, 0, 0, 0, 0, 0, + 70, 16, 16, 0, 2, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 34, 32, + 16, 0, 0, 0, 0, 0, + 26, 0, 16, 0, 0, 0, + 0, 0, 10, 16, 16, 0, + 4, 0, 0, 0, 69, 0, + 0, 9, 242, 0, 16, 0, + 0, 0, 0, 0, 70, 16, + 16, 0, 3, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 56, 0, + 0, 7, 66, 32, 16, 0, + 0, 0, 0, 0, 42, 0, + 16, 0, 0, 0, 0, 0, + 10, 16, 16, 0, 4, 0, + 0, 0, 54, 0, 0, 5, + 130, 32, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 63, 62, 0, + 0, 1, 83, 84, 65, 84, + 116, 0, 0, 0, 8, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 82, 68, 69, 70, 160, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, + 0, 0, 28, 0, 0, 0, + 0, 4, 255, 255, 0, 1, + 0, 0, 107, 0, 0, 0, + 92, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, + 0, 0, 99, 0, 0, 0, + 2, 0, 0, 0, 5, 0, + 0, 0, 4, 0, 0, 0, + 255, 255, 255, 255, 0, 0, + 0, 0, 1, 0, 0, 0, + 13, 0, 0, 0, 76, 105, + 110, 101, 97, 114, 0, 84, + 101, 120, 116, 117, 114, 101, + 0, 77, 105, 99, 114, 111, + 115, 111, 102, 116, 32, 40, + 82, 41, 32, 72, 76, 83, + 76, 32, 83, 104, 97, 100, + 101, 114, 32, 67, 111, 109, + 112, 105, 108, 101, 114, 32, + 54, 46, 51, 46, 57, 54, + 48, 48, 46, 49, 54, 51, + 56, 52, 0, 171, 171, 171, + 73, 83, 71, 78, 156, 0, + 0, 0, 5, 0, 0, 0, + 8, 0, 0, 0, 128, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, + 15, 0, 0, 0, 140, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 1, 0, 0, 0, + 7, 3, 0, 0, 140, 0, + 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 2, 0, 0, 0, + 7, 3, 0, 0, 140, 0, + 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 3, 0, 0, 0, + 7, 3, 0, 0, 149, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 4, 0, 0, 0, + 15, 1, 0, 0, 83, 86, + 95, 80, 111, 115, 105, 116, + 105, 111, 110, 0, 84, 69, + 88, 67, 79, 79, 82, 68, + 0, 67, 79, 76, 79, 82, + 0, 171, 79, 83, 71, 78, + 44, 0, 0, 0, 1, 0, + 0, 0, 8, 0, 0, 0, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, + 0, 0, 15, 0, 0, 0, + 83, 86, 95, 84, 97, 114, + 103, 101, 116, 0, 171, 171 +}; diff --git a/gfx/layers/d3d11/CompositorD3D11VR.hlsl b/gfx/layers/d3d11/CompositorD3D11VR.hlsl index 9a129ebc5517..6df71241bf23 100644 --- a/gfx/layers/d3d11/CompositorD3D11VR.hlsl +++ b/gfx/layers/d3d11/CompositorD3D11VR.hlsl @@ -37,13 +37,16 @@ SamplerState Linear AddressV = Clamp; }; +/* + * Oculus basic distortion, with chroma aberration correction + */ VS_VR_OUTPUT OculusVRDistortionVS(const VS_VR_INPUT aVertex) { VS_VR_OUTPUT res; - float2 tc0 = VREyeToSource.xy * aVertex.vTexCoord0 + VREyeToSource.zw; - float2 tc1 = VREyeToSource.xy * aVertex.vTexCoord1 + VREyeToSource.zw; - float2 tc2 = VREyeToSource.xy * aVertex.vTexCoord2 + VREyeToSource.zw; + float2 tc0 = aVertex.vTexCoord0 * VREyeToSource.zw + VREyeToSource.xy; + float2 tc1 = aVertex.vTexCoord1 * VREyeToSource.zw + VREyeToSource.xy; + float2 tc2 = aVertex.vTexCoord2 * VREyeToSource.zw + VREyeToSource.xy; //res.vPosition.xy = aVertex.vPosition.xy; res.vPosition.xy = aVertex.vPosition.xy * VRDestinationScaleAndOffset.zw + VRDestinationScaleAndOffset.xy; diff --git a/gfx/vr/gfxVR.cpp b/gfx/vr/gfxVR.cpp index 367605b8c600..c14d0052a5ff 100644 --- a/gfx/vr/gfxVR.cpp +++ b/gfx/vr/gfxVR.cpp @@ -13,6 +13,7 @@ #include "gfxPrefs.h" #include "gfxVR.h" #include "gfxVROculus.h" +#include "gfxVRCardboard.h" #include "nsServiceManagerUtils.h" #include "nsIScreenManager.h" @@ -85,6 +86,10 @@ VRHMDManager::ManagerInit() mgr = new VRHMDManagerOculus(); if (mgr->PlatformInit()) sManagers->AppendElement(mgr); + + mgr = new VRHMDManagerCardboard(); + if (mgr->PlatformInit()) + sManagers->AppendElement(mgr); } /* static */ void diff --git a/gfx/vr/gfxVR.h b/gfx/vr/gfxVR.h index 005f98b7a0be..05514bd17059 100644 --- a/gfx/vr/gfxVR.h +++ b/gfx/vr/gfxVR.h @@ -19,6 +19,7 @@ namespace gfx { enum class VRHMDType : uint16_t { Oculus, + Cardboard, NumHMDTypes }; @@ -217,6 +218,7 @@ public: protected: VRHMDManager() { } + virtual ~VRHMDManager() { } }; } // namespace gfx diff --git a/gfx/vr/gfxVRCardboard.cpp b/gfx/vr/gfxVRCardboard.cpp new file mode 100644 index 000000000000..4b5b5f864b2e --- /dev/null +++ b/gfx/vr/gfxVRCardboard.cpp @@ -0,0 +1,382 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include + +#include "prlink.h" +#include "prmem.h" +#include "prenv.h" +#include "gfxPrefs.h" +#include "nsString.h" +#include "mozilla/dom/ScreenOrientation.h" +#include "mozilla/Preferences.h" +#include "mozilla/Hal.h" + +#include "gfxVRCardboard.h" + +#include "nsServiceManagerUtils.h" +#include "nsIScreenManager.h" + +#ifdef ANDROID +#include +#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoVR" , ## args) +#else +#define LOG(...) do { } while(0) +#endif + +#ifndef M_PI +# define M_PI 3.14159265358979323846 +#endif + +// 1/sqrt(2) (aka sqrt(2)/2) +#ifndef M_SQRT1_2 +# define M_SQRT1_2 0.70710678118654752440 +#endif + +using namespace mozilla::dom; +using namespace mozilla::gfx; +using namespace mozilla::gfx::impl; + +namespace { +// some utility functions + +// This remaps axes in the given matrix to a new configuration based on the +// screen orientation. Similar to what Android SensorManager.remapCoordinateSystem +// does, except only for a fixed number of transforms that we need. +Matrix4x4 +RemapMatrixForOrientation(ScreenOrientation screenConfig, const Matrix4x4& aMatrix) +{ + Matrix4x4 out; + const float *in = &aMatrix._11; + float *o = &out._11; + + if (screenConfig == eScreenOrientation_LandscapePrimary) { + // remap X,Y -> Y,-X + o[0] = -in[1]; o[1] = in[0]; o[2] = in[2]; + o[4] = -in[5]; o[5] = in[4]; o[6] = in[6]; + o[8] = -in[9]; o[9] = in[8]; o[10] = in[10]; + } else if (screenConfig == eScreenOrientation_LandscapeSecondary) { + // remap X,Y -> -Y,X + o[0] = in[1]; o[1] = -in[0]; o[2] = in[2]; + o[4] = in[5]; o[5] = -in[4]; o[6] = in[6]; + o[8] = in[9]; o[9] = -in[8]; o[10] = in[10]; + } else if (screenConfig == eScreenOrientation_PortraitPrimary || + screenConfig == eScreenOrientation_PortraitSecondary) + { + // remap X,Y -> X,-Z + o[0] = in[0]; o[1] = in[2]; o[2] = -in[1]; + o[4] = in[4]; o[5] = in[6]; o[6] = -in[5]; + o[8] = in[8]; o[9] = in[10]; o[10] = -in[9]; + } else { + MOZ_ASSERT(0, "gfxVRCardboard::RemapMatrixForOrientation invalid screenConfig"); + } + + return out; +} + +} + +HMDInfoCardboard::HMDInfoCardboard() + : VRHMDInfo(VRHMDType::Cardboard) + , mStartCount(0) + , mOrient(eScreenOrientation_PortraitPrimary) +{ + MOZ_ASSERT(sizeof(HMDInfoCardboard::DistortionVertex) == sizeof(VRDistortionVertex), + "HMDInfoCardboard::DistortionVertex must match the size of VRDistortionVertex"); + + mSupportedSensorBits = State_Orientation; + + mRecommendedEyeFOV[Eye_Left] = VRFieldOfView(45.0, 45.0, 45.0, 45.0); + mRecommendedEyeFOV[Eye_Right] = VRFieldOfView(45.0, 45.0, 45.0, 45.0); + + mMaximumEyeFOV[Eye_Left] = VRFieldOfView(45.0, 45.0, 45.0, 45.0); + mMaximumEyeFOV[Eye_Right] = VRFieldOfView(45.0, 45.0, 45.0, 45.0); + + SetFOV(mRecommendedEyeFOV[Eye_Left], mRecommendedEyeFOV[Eye_Right], 0.01, 10000.0); +} + +bool +HMDInfoCardboard::StartSensorTracking() +{ + LOG("HMDInfoCardboard::StartSensorTracking %d\n", mStartCount); + if (mStartCount == 0) { + // it's never been started before; initialize observers and + // initial state. + + mozilla::hal::ScreenConfiguration sconfig; + mozilla::hal::GetCurrentScreenConfiguration(&sconfig); + this->Notify(sconfig); + + mozilla::hal::RegisterSensorObserver(mozilla::hal::SENSOR_GAME_ROTATION_VECTOR, this); + mozilla::hal::RegisterScreenConfigurationObserver(this); + + mLastSensorState.Clear(); + } + + mStartCount++; + return true; +} + +void +HMDInfoCardboard::Notify(const mozilla::hal::ScreenConfiguration& config) +{ + mOrient = config.orientation(); + + if (mOrient == eScreenOrientation_LandscapePrimary) { + mScreenTransform = Quaternion(0.f, 0.f, M_SQRT1_2, M_SQRT1_2); + } else if (mOrient == eScreenOrientation_LandscapeSecondary) { + mScreenTransform = Quaternion(0.f, 0.f, -M_SQRT1_2, M_SQRT1_2); + } else if (mOrient == eScreenOrientation_PortraitPrimary) { + mScreenTransform = Quaternion(); + } else if (mOrient == eScreenOrientation_PortraitSecondary) { + mScreenTransform = Quaternion(0.f, 0.f, 1.f, 0.f); + } +} + +void +HMDInfoCardboard::Notify(const mozilla::hal::SensorData& data) +{ + if (data.sensor() != mozilla::hal::SENSOR_GAME_ROTATION_VECTOR) + return; + + const nsTArray& sensorValues = data.values(); + + // This is super chatty + //LOG("HMDInfoCardboard::Notify %f %f %f %f\n", sensorValues[0], sensorValues[1], sensorValues[2], sensorValues[3]); + + mSavedLastSensor.Set(sensorValues[0], sensorValues[1], sensorValues[2], sensorValues[3]); + mSavedLastSensorTime = data.timestamp(); + mNeedsSensorCompute = true; +} + +void +HMDInfoCardboard::ComputeStateFromLastSensor() +{ + if (!mNeedsSensorCompute) + return; + + // apply the zero orientation + Quaternion q = mSensorZeroInverse * mSavedLastSensor; + + // make a matrix from the quat + Matrix4x4 qm; + qm.SetRotationFromQuaternion(q); + + // remap the coordinate space, based on the orientation + Matrix4x4 qmRemapped = RemapMatrixForOrientation(mOrient, qm); + + // turn it back into a quat + q.SetFromRotationMatrix(qmRemapped); + + // apply adjustment based on what's been done to the screen and the original zero + // position of the base coordinate space + q = mScreenTransform * q; + + VRHMDSensorState& state = mLastSensorState; + + state.flags |= State_Orientation; + state.orientation[0] = q.x; + state.orientation[1] = q.y; + state.orientation[2] = q.z; + state.orientation[3] = q.w; + + state.timestamp = mSavedLastSensorTime / 1000000.0; + + mNeedsSensorCompute = false; +} + +VRHMDSensorState +HMDInfoCardboard::GetSensorState(double timeOffset) +{ + ComputeStateFromLastSensor(); + return mLastSensorState; +} + +void +HMDInfoCardboard::StopSensorTracking() +{ + LOG("HMDInfoCardboard::StopSensorTracking, count %d\n", mStartCount); + if (--mStartCount == 0) { + mozilla::hal::UnregisterScreenConfigurationObserver(this); + mozilla::hal::UnregisterSensorObserver(mozilla::hal::SENSOR_GAME_ROTATION_VECTOR, this); + } +} + +void +HMDInfoCardboard::ZeroSensor() +{ + mSensorZeroInverse = mSavedLastSensor; + mSensorZeroInverse.Invert(); +} + +static Matrix4x4 +ConstructProjectionMatrix(const VRFieldOfView& fov, bool rightHanded, double zNear, double zFar) +{ + float upTan = tan(fov.upDegrees * M_PI / 180.0); + float downTan = tan(fov.downDegrees * M_PI / 180.0); + float leftTan = tan(fov.leftDegrees * M_PI / 180.0); + float rightTan = tan(fov.rightDegrees * M_PI / 180.0); + + float handednessScale = rightHanded ? -1.0 : 1.0; + + float pxscale = 2.0f / (leftTan + rightTan); + float pxoffset = (leftTan - rightTan) * pxscale * 0.5; + float pyscale = 2.0f / (upTan + downTan); + float pyoffset = (upTan - downTan) * pyscale * 0.5; + + Matrix4x4 mobj; + float *m = &mobj._11; + + m[0*4+0] = pxscale; + m[0*4+2] = pxoffset * handednessScale; + + m[1*4+1] = pyscale; + m[1*4+2] = -pyoffset * handednessScale; + + m[2*4+2] = zFar / (zNear - zFar) * -handednessScale; + m[2*4+3] = (zFar * zNear) / (zNear - zFar); + + m[3*4+2] = handednessScale; + + return mobj; +} + +bool +HMDInfoCardboard::SetFOV(const VRFieldOfView& aFOVLeft, + const VRFieldOfView& aFOVRight, + double zNear, double zFar) +{ + const float standardIPD = 0.064f; + + for (uint32_t eye = 0; eye < NumEyes; eye++) { + mEyeFOV[eye] = eye == Eye_Left ? aFOVLeft : aFOVRight; + mEyeTranslation[eye] = Point3D(standardIPD * (eye == Eye_Left ? -1.0 : 1.0), 0.0, 0.0); + mEyeProjectionMatrix[eye] = ConstructProjectionMatrix(mEyeFOV[eye], true, zNear, zFar); + + mDistortionMesh[eye].mVertices.SetLength(4); + mDistortionMesh[eye].mIndices.SetLength(6); + + HMDInfoCardboard::DistortionVertex *destv = reinterpret_cast(mDistortionMesh[eye].mVertices.Elements()); + float xoffs = eye == Eye_Left ? 0.0f : 1.0f; + float txoffs = eye == Eye_Left ? 0.0f : 0.5f; + destv[0].pos[0] = -1.0 + xoffs; + destv[0].pos[1] = -1.0; + destv[0].texR[0] = destv[0].texG[0] = destv[0].texB[0] = 0.0 + txoffs; + destv[0].texR[1] = destv[0].texG[1] = destv[0].texB[1] = 1.0; + destv[0].padding[0] = 1.0; // vignette factor + + destv[1].pos[0] = 0.0 + xoffs; + destv[1].pos[1] = -1.0; + destv[1].texR[0] = destv[1].texG[0] = destv[1].texB[0] = 0.5 + txoffs; + destv[1].texR[1] = destv[1].texG[1] = destv[1].texB[1] = 1.0; + destv[1].padding[0] = 1.0; // vignette factor + + destv[2].pos[0] = 0.0 + xoffs; + destv[2].pos[1] = 1.0; + destv[2].texR[0] = destv[2].texG[0] = destv[2].texB[0] = 0.5 + txoffs; + destv[2].texR[1] = destv[2].texG[1] = destv[2].texB[1] = 0.0; + destv[2].padding[0] = 1.0; // vignette factor + + destv[3].pos[0] = -1.0 + xoffs; + destv[3].pos[1] = 1.0; + destv[3].texR[0] = destv[3].texG[0] = destv[3].texB[0] = 0.0 + txoffs; + destv[3].texR[1] = destv[3].texG[1] = destv[3].texB[1] = 0.0; + destv[3].padding[0] = 1.0; // vignette factor + + uint16_t *iv = mDistortionMesh[eye].mIndices.Elements(); + iv[0] = 0; iv[1] = 1; iv[2] = 2; + iv[3] = 2; iv[4] = 3; iv[5] = 0; + } + + // XXX find out the default screen size and use that + mEyeResolution.width = 1920 / 2; + mEyeResolution.height = 1080; + + mConfiguration.hmdType = mType; + mConfiguration.value = 0; + mConfiguration.fov[0] = aFOVLeft; + mConfiguration.fov[1] = aFOVRight; + + return true; +} + +void +HMDInfoCardboard::FillDistortionConstants(uint32_t whichEye, + const IntSize& textureSize, const IntRect& eyeViewport, + const Size& destViewport, const Rect& destRect, + VRDistortionConstants& values) +{ + // these modify the texture coordinates; texcoord * zw + xy + values.eyeToSourceScaleAndOffset[0] = 0.0; + values.eyeToSourceScaleAndOffset[1] = 0.0; + values.eyeToSourceScaleAndOffset[2] = 1.0; + values.eyeToSourceScaleAndOffset[3] = 1.0; + + // Our mesh positions are in the [-1..1] clip space; we give appropriate offset + // and scaling for the right viewport. (In the 0..2 space for sanity) + + // this is the destRect in clip space + float x0 = destRect.x / destViewport.width * 2.0 - 1.0; + float x1 = (destRect.x + destRect.width) / destViewport.width * 2.0 - 1.0; + + float y0 = destRect.y / destViewport.height * 2.0 - 1.0; + float y1 = (destRect.y + destRect.height) / destViewport.height * 2.0 - 1.0; + + // offset + values.destinationScaleAndOffset[0] = (x0+x1) / 2.0; + values.destinationScaleAndOffset[1] = (y0+y1) / 2.0; + // scale + values.destinationScaleAndOffset[2] = destRect.width / destViewport.width; + values.destinationScaleAndOffset[3] = destRect.height / destViewport.height; +} + +void +HMDInfoCardboard::Destroy() +{ +} + + + +bool +VRHMDManagerCardboard::PlatformInit() +{ + return true; +} + +bool +VRHMDManagerCardboard::Init() +{ + if (mCardboardInitialized) + return true; + + nsRefPtr hmd = new HMDInfoCardboard(); + mCardboardHMDs.AppendElement(hmd); + + mCardboardInitialized = true; + return true; +} + +void +VRHMDManagerCardboard::Destroy() +{ + if (!mCardboardInitialized) + return; + + for (size_t i = 0; i < mCardboardHMDs.Length(); ++i) { + mCardboardHMDs[i]->Destroy(); + } + + mCardboardHMDs.Clear(); + mCardboardInitialized = false; +} + +void +VRHMDManagerCardboard::GetHMDs(nsTArray>& aHMDResult) +{ + Init(); + for (size_t i = 0; i < mCardboardHMDs.Length(); ++i) { + aHMDResult.AppendElement(mCardboardHMDs[i]); + } +} diff --git a/gfx/vr/gfxVRCardboard.h b/gfx/vr/gfxVRCardboard.h new file mode 100644 index 000000000000..fd6ecd98ac0f --- /dev/null +++ b/gfx/vr/gfxVRCardboard.h @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef GFX_VR_CARDBOARD_H +#define GFX_VR_CARDBOARD_H + +#include "mozilla/gfx/2D.h" +#include "mozilla/gfx/Quaternion.h" +#include "mozilla/EnumeratedArray.h" +#include "mozilla/HalSensor.h" +#include "mozilla/HalScreenConfiguration.h" + +#include "gfxVR.h" + +namespace mozilla { +namespace gfx { +namespace impl { + +class HMDInfoCardboard : + public VRHMDInfo, + public hal::ISensorObserver, + public hal::ScreenConfigurationObserver +{ +public: + explicit HMDInfoCardboard(); + + bool SetFOV(const VRFieldOfView& aFOVLeft, const VRFieldOfView& aFOVRight, + double zNear, double zFar) override; + + bool StartSensorTracking() override; + VRHMDSensorState GetSensorState(double timeOffset) override; + void StopSensorTracking() override; + void ZeroSensor() override; + + void FillDistortionConstants(uint32_t whichEye, + const IntSize& textureSize, const IntRect& eyeViewport, + const Size& destViewport, const Rect& destRect, + VRDistortionConstants& values) override; + + void Destroy(); + + // ISensorObserver interface + void Notify(const hal::SensorData& SensorData) override; + // ScreenConfigurationObserver interface + void Notify(const hal::ScreenConfiguration& ScreenConfiguration) override; + +protected: + // must match the size of VRDistortionVertex + struct DistortionVertex { + float pos[2]; + float texR[2]; + float texG[2]; + float texB[2]; + float padding[4]; + }; + + virtual ~HMDInfoCardboard() { + Destroy(); + } + + void ComputeStateFromLastSensor(); + + uint32_t mStartCount; + VRHMDSensorState mLastSensorState; + uint32_t mOrient; + Quaternion mScreenTransform; + Quaternion mSensorZeroInverse; + + Quaternion mSavedLastSensor; + double mSavedLastSensorTime; + bool mNeedsSensorCompute; // if we need to compute the state from mSavedLastSensor +}; + +} // namespace impl + +class VRHMDManagerCardboard : public VRHMDManager +{ +public: + VRHMDManagerCardboard() + : mCardboardInitialized(false) + { } + + virtual bool PlatformInit() override; + virtual bool Init() override; + virtual void Destroy() override; + virtual void GetHMDs(nsTArray >& aHMDResult) override; +protected: + nsTArray> mCardboardHMDs; + bool mCardboardInitialized; +}; + +} // namespace gfx +} // namespace mozilla + +#endif /* GFX_VR_CARDBOARD_H */ diff --git a/gfx/vr/gfxVROculus.cpp b/gfx/vr/gfxVROculus.cpp index ab22e3565234..7f85bd9c4290 100644 --- a/gfx/vr/gfxVROculus.cpp +++ b/gfx/vr/gfxVROculus.cpp @@ -331,10 +331,10 @@ HMDInfoOculus::FillDistortionConstants(uint32_t whichEye, ovrHmd_GetRenderScaleAndOffset(mFOVPort[whichEye], texSize, eyePort, scaleOut); - values.eyeToSourceScaleAndOffset[0] = scaleOut[0].x; - values.eyeToSourceScaleAndOffset[1] = scaleOut[0].y; - values.eyeToSourceScaleAndOffset[2] = scaleOut[1].x; - values.eyeToSourceScaleAndOffset[3] = scaleOut[1].y; + values.eyeToSourceScaleAndOffset[0] = scaleOut[1].x; + values.eyeToSourceScaleAndOffset[1] = scaleOut[1].y; + values.eyeToSourceScaleAndOffset[2] = scaleOut[0].x; + values.eyeToSourceScaleAndOffset[3] = scaleOut[0].y; // These values are in clip space [-1..1] range, but we're providing // scaling in the 0..2 space for sanity. diff --git a/gfx/vr/moz.build b/gfx/vr/moz.build index a0c3acacf52b..ad8e65357f07 100644 --- a/gfx/vr/moz.build +++ b/gfx/vr/moz.build @@ -14,6 +14,7 @@ LOCAL_INCLUDES += [ UNIFIED_SOURCES += [ 'gfxVR.cpp', + 'gfxVRCardboard.cpp', 'gfxVROculus.cpp', ]