Bug 1381085 - Move VR to its own D3D11Device draft
authorKearwood "Kip" Gilbert <kgilbert@mozilla.com>
Fri, 21 Jul 2017 17:30:34 -0700
changeset 665172 19de131ea505fb315097ad8e9aeb414584dd947b
parent 665171 cee863f78026e0c27530678f90a14291706ff629
child 731669 b0088a632b8fd54f88752fb6caa57cb7cfebf9a9
push id79946
push userkgilbert@mozilla.com
push dateFri, 15 Sep 2017 00:03:30 +0000
bugs1381085
milestone57.0a1
Bug 1381085 - Move VR to its own D3D11Device - WebVR is no longer dependent on PTexture, TextureParent, TextureHost, and TextureChild. It continues to use TextureClient for pooling and coordinating locks with other Gecko code. - As VR is now rendered in its own context, it no longer causes conflicts with Advanced Layers, which were due to VR frame submission updating D3D11 state without updating the mirrored state in MLGDevice. - VRManagerParent no longer descends from HostIPCAllocator or ShmemAllocator - PreserveDrawingBuffer now behaving correctly for 2d display mirroring - Refactored out Canvas layer mirror specialization, no longer needed as we are no longer implementing a TextureForwarder to submit VR frames. MozReview-Commit-ID: 2RGOulCInSu
dom/canvas/CanvasRenderingContext2D.cpp
dom/canvas/CanvasRenderingContext2D.h
dom/canvas/ImageBitmapRenderingContext.cpp
dom/canvas/ImageBitmapRenderingContext.h
dom/canvas/WebGLContext.cpp
dom/canvas/WebGLContext.h
dom/canvas/nsICanvasRenderingContextInternal.h
dom/html/HTMLCanvasElement.cpp
dom/html/HTMLCanvasElement.h
gfx/gl/SharedSurface.cpp
gfx/layers/ipc/PTexture.ipdl
gfx/vr/VRDisplayHost.cpp
gfx/vr/VRDisplayHost.h
gfx/vr/VRManager.cpp
gfx/vr/VRManager.h
gfx/vr/gfxVR.h
gfx/vr/gfxVROSVR.cpp
gfx/vr/gfxVROSVR.h
gfx/vr/gfxVROculus.cpp
gfx/vr/gfxVROculus.h
gfx/vr/gfxVROpenVR.cpp
gfx/vr/gfxVROpenVR.h
gfx/vr/gfxVRPuppet.cpp
gfx/vr/gfxVRPuppet.h
gfx/vr/ipc/PVRLayer.ipdl
gfx/vr/ipc/PVRManager.ipdl
gfx/vr/ipc/VRLayerChild.cpp
gfx/vr/ipc/VRLayerChild.h
gfx/vr/ipc/VRLayerParent.cpp
gfx/vr/ipc/VRLayerParent.h
gfx/vr/ipc/VRManagerChild.cpp
gfx/vr/ipc/VRManagerChild.h
gfx/vr/ipc/VRManagerParent.cpp
gfx/vr/ipc/VRManagerParent.h
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -6090,24 +6090,18 @@ void CanvasRenderingContext2D::RemoveDra
     delete mDrawObserver;
     mDrawObserver = nullptr;
   }
 }
 
 already_AddRefed<Layer>
 CanvasRenderingContext2D::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
                                          Layer* aOldLayer,
-                                         LayerManager* aManager,
-                                         bool aMirror /* = false */)
-{
-  if (aMirror) {
-    // Not supported for CanvasRenderingContext2D
-    return nullptr;
-  }
-
+                                         LayerManager* aManager)
+{
   if (mOpaque || mIsSkiaGL) {
     // If we're opaque then make sure we have a surface so we paint black
     // instead of transparent.
     // If we're using SkiaGL, then SkiaGLTex() below needs the target to
     // be accessible.
     EnsureTarget();
   }
 
@@ -6168,29 +6162,28 @@ CanvasRenderingContext2D::GetCanvasLayer
   // (at the latest), at which time this userData will be destroyed,
   // releasing the reference to the element.
   // The userData will receive DidTransactionCallbacks, which flush the
   // the invalidation state to indicate that the canvas is up to date.
   userData = new CanvasRenderingContext2DUserData(this);
   canvasLayer->SetUserData(&g2DContextLayerUserData, userData);
 
   CanvasRenderer* canvasRenderer = canvasLayer->CreateOrGetCanvasRenderer();
-  InitializeCanvasRenderer(aBuilder, canvasRenderer, aMirror);
+  InitializeCanvasRenderer(aBuilder, canvasRenderer);
   uint32_t flags = mOpaque ? Layer::CONTENT_OPAQUE : 0;
   canvasLayer->SetContentFlags(flags);
 
   mResetLayer = false;
 
   return canvasLayer.forget();
 }
 
 bool
 CanvasRenderingContext2D::InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
-                                                   CanvasRenderer* aRenderer,
-                                                   bool aMirror)
+                                                   CanvasRenderer* aRenderer)
 {
   CanvasInitializeData data;
   data.mSize = GetSize();
   data.mHasAlpha = !mOpaque;
   data.mPreTransCallback = CanvasRenderingContext2DUserData::PreTransactionCallback;
   data.mPreTransCallbackData = this;
   data.mDidTransCallback = CanvasRenderingContext2DUserData::DidTransactionCallback;
   data.mDidTransCallbackData = this;
--- a/dom/canvas/CanvasRenderingContext2D.h
+++ b/dom/canvas/CanvasRenderingContext2D.h
@@ -461,21 +461,19 @@ public:
     return mTarget->Snapshot();
   }
 
   virtual void SetIsOpaque(bool aIsOpaque) override;
   bool GetIsOpaque() override { return mOpaque; }
   NS_IMETHOD Reset() override;
   already_AddRefed<Layer> GetCanvasLayer(nsDisplayListBuilder* aBuilder,
                                          Layer* aOldLayer,
-                                         LayerManager* aManager,
-                                         bool aMirror = false) override;
+                                         LayerManager* aManager) override;
   bool InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
-                                CanvasRenderer* aRenderer,
-                                bool aMirror = false) override;
+                                CanvasRenderer* aRenderer) override;
   virtual bool ShouldForceInactiveLayer(LayerManager* aManager) override;
   void MarkContextClean() override;
   void MarkContextCleanForFrameCapture() override;
   bool IsContextCleanForFrameCapture() override;
   NS_IMETHOD SetIsIPC(bool aIsIPC) override;
   // this rect is in canvas device space
   void Redraw(const mozilla::gfx::Rect& aR);
   NS_IMETHOD Redraw(const gfxRect& aR) override { Redraw(ToRect(aR)); return NS_OK; }
--- a/dom/canvas/ImageBitmapRenderingContext.cpp
+++ b/dom/canvas/ImageBitmapRenderingContext.cpp
@@ -221,24 +221,18 @@ ImageBitmapRenderingContext::Reset()
   mImage = nullptr;
 
   return NS_OK;
 }
 
 already_AddRefed<Layer>
 ImageBitmapRenderingContext::GetCanvasLayer(nsDisplayListBuilder* aBuilder,
                                             Layer* aOldLayer,
-                                            LayerManager* aManager,
-                                            bool aMirror /* = false */)
+                                            LayerManager* aManager)
 {
-  if (aMirror) {
-    // Not supported for ImageBitmapRenderingContext
-    return nullptr;
-  }
-
   if (!mImage) {
     // No DidTransactionCallback will be received, so mark the context clean
     // now so future invalidations will be dispatched.
     MarkContextClean();
     return nullptr;
   }
 
   RefPtr<ImageLayer> imageLayer;
--- a/dom/canvas/ImageBitmapRenderingContext.h
+++ b/dom/canvas/ImageBitmapRenderingContext.h
@@ -66,18 +66,17 @@ public:
   virtual already_AddRefed<mozilla::gfx::SourceSurface>
   GetSurfaceSnapshot(gfxAlphaType* aOutAlphaType) override;
 
   virtual void SetIsOpaque(bool aIsOpaque) override;
   virtual bool GetIsOpaque() override;
   NS_IMETHOD Reset() override;
   virtual already_AddRefed<Layer> GetCanvasLayer(nsDisplayListBuilder* aBuilder,
                                                  Layer* aOldLayer,
-                                                 LayerManager* aManager,
-                                                 bool aMirror = false) override;
+                                                 LayerManager* aManager) override;
   virtual void MarkContextClean() override;
 
   NS_IMETHOD Redraw(const gfxRect& aDirty) override;
   NS_IMETHOD SetIsIPC(bool aIsIPC) override;
 
   virtual void DidRefresh() override;
 
   virtual void MarkContextCleanForFrameCapture() override;
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -1307,18 +1307,17 @@ public:
 
 private:
     RefPtr<HTMLCanvasElement> mCanvas;
 };
 
 already_AddRefed<layers::Layer>
 WebGLContext::GetCanvasLayer(nsDisplayListBuilder* builder,
                              Layer* oldLayer,
-                             LayerManager* manager,
-                             bool)
+                             LayerManager* manager)
 {
     if (!mResetLayer && oldLayer &&
         oldLayer->HasUserData(&gWebGLLayerUserData))
     {
         RefPtr<layers::Layer> ret = oldLayer;
         return ret.forget();
     }
 
@@ -1344,18 +1343,17 @@ WebGLContext::GetCanvasLayer(nsDisplayLi
 
     mResetLayer = false;
 
     return canvasLayer.forget();
 }
 
 bool
 WebGLContext::InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
-                                       CanvasRenderer* aRenderer,
-                                       bool)
+                                       CanvasRenderer* aRenderer)
 {
     if (IsContextLost())
         return false;
 
     CanvasInitializeData data;
     if (aBuilder->IsPaintingToWindow() && mCanvasElement) {
         // Make the layer tell us whenever a transaction finishes (including
         // the current transaction), so we can clear our invalidation state and
@@ -2322,83 +2320,37 @@ WebGLContext::GetUnpackSize(bool isFunc3
     totalBytes += usedBytesPerRow;
 
     return totalBytes;
 }
 
 already_AddRefed<layers::SharedSurfaceTextureClient>
 WebGLContext::GetVRFrame()
 {
-    VRManagerChild* vrmc = VRManagerChild::Get();
-    if (!vrmc) {
-        return nullptr;
-    }
-
-    /**
-     * Swap buffers as though composition has occurred.
-     * We will then share the resulting front buffer to be submitted to the VR
-     * compositor.
-     */
-    BeginComposition();
-    EndComposition();
-
-    gl::GLScreenBuffer* screen = gl->Screen();
-    if (!screen) {
-        return nullptr;
-    }
-
-    RefPtr<SharedSurfaceTextureClient> sharedSurface = screen->Front();
-    if (!sharedSurface) {
-        return nullptr;
-    }
-
-    if (sharedSurface && sharedSurface->GetAllocator() != vrmc) {
-        RefPtr<SharedSurfaceTextureClient> dest =
-        screen->Factory()->NewTexClient(sharedSurface->GetSize(), vrmc);
-        if (!dest) {
-            return nullptr;
-        }
-        gl::SharedSurface* destSurf = dest->Surf();
-        destSurf->ProducerAcquire();
-        SharedSurface::ProdCopy(sharedSurface->Surf(), dest->Surf(),
-                                screen->Factory());
-        destSurf->ProducerRelease();
-
-        return dest.forget();
-    }
+  /**
+   * Swap buffers as though composition has occurred.
+   * We will then share the resulting front buffer to be submitted to the VR
+   * compositor.
+   */
+  BeginComposition();
+  EndComposition();
+
+  gl::GLScreenBuffer* screen = gl->Screen();
+  if (!screen) {
+      return nullptr;
+  }
+
+  RefPtr<SharedSurfaceTextureClient> sharedSurface = screen->Front();
+  if (!sharedSurface) {
+      return nullptr;
+  }
 
     return sharedSurface.forget();
 }
 
-bool
-WebGLContext::StartVRPresentation()
-{
-    VRManagerChild* vrmc = VRManagerChild::Get();
-    if (!vrmc) {
-        return false;
-    }
-    gl::GLScreenBuffer* screen = gl->Screen();
-    if (!screen) {
-        return false;
-    }
-    gl::SurfaceCaps caps = screen->mCaps;
-
-    UniquePtr<gl::SurfaceFactory> factory =
-        gl::GLScreenBuffer::CreateFactory(gl,
-            caps,
-            vrmc,
-            vrmc->GetBackendType(),
-            TextureFlags::ORIGIN_BOTTOM_LEFT);
-
-    if (factory) {
-        screen->Morph(Move(factory));
-    }
-    return true;
-}
-
 ////////////////////////////////////////////////////////////////////////////////
 
 static inline size_t
 SizeOfViewElem(const dom::ArrayBufferView& view)
 {
     const auto& elemType = view.Type();
     if (elemType == js::Scalar::MaxTypedArrayViewType) // DataViews.
         return 1;
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -428,22 +428,20 @@ public:
         const TexTarget texTarget = TexImageTargetToTexTarget(texImgTarget);
         return ActiveBoundTextureForTarget(texTarget);
     }
 
     void InvalidateResolveCacheForTextureWithTexUnit(const GLuint);
 
     already_AddRefed<Layer>
     GetCanvasLayer(nsDisplayListBuilder* builder, Layer* oldLayer,
-                   LayerManager* manager,
-                   bool aMirror = false) override;
+                   LayerManager* manager) override;
     bool
     InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
-                             CanvasRenderer* aRenderer,
-                             bool aMirror = false) override;
+                             CanvasRenderer* aRenderer) override;
 
     // Note that 'clean' here refers to its invalidation state, not the
     // contents of the buffer.
     void MarkContextClean() override { mInvalidated = false; }
 
     void MarkContextCleanForFrameCapture() override { mCapturedFrameInvalidated = false; }
 
     bool IsContextCleanForFrameCapture() override { return !mCapturedFrameInvalidated; }
@@ -637,17 +635,16 @@ public:
     bool IsShader(const WebGLShader* shader);
     bool IsVertexArray(const WebGLVertexArray* vao);
     void LineWidth(GLfloat width);
     void LinkProgram(WebGLProgram& prog);
     void PixelStorei(GLenum pname, GLint param);
     void PolygonOffset(GLfloat factor, GLfloat units);
 
     already_AddRefed<layers::SharedSurfaceTextureClient> GetVRFrame();
-    bool StartVRPresentation();
 
     ////
 
     webgl::PackingInfo
     ValidImplementationColorReadPI(const webgl::FormatUsageInfo* usage) const;
 
 protected:
     bool ReadPixels_SharedPrecheck(dom::CallerType aCallerType,
--- a/dom/canvas/nsICanvasRenderingContextInternal.h
+++ b/dom/canvas/nsICanvasRenderingContextInternal.h
@@ -134,21 +134,19 @@ public:
   // Invalidate this context and release any held resources, in preperation
   // for possibly reinitializing with SetDimensions/InitializeWithSurface.
   NS_IMETHOD Reset() = 0;
 
   // Return the CanvasLayer for this context, creating
   // one for the given layer manager if not available.
   virtual already_AddRefed<Layer> GetCanvasLayer(nsDisplayListBuilder* builder,
                                                  Layer *oldLayer,
-                                                 LayerManager *manager,
-                                                 bool aMirror = false) = 0;
+                                                 LayerManager *manager) = 0;
   virtual bool InitializeCanvasRenderer(nsDisplayListBuilder* aBuilder,
-                                        CanvasRenderer* aRenderer,
-                                        bool aMirror = false) { return true; }
+                                        CanvasRenderer* aRenderer) { return true; }
 
   // Return true if the canvas should be forced to be "inactive" to ensure
   // it can be drawn to the screen even if it's too large to be blitted by
   // an accelerated CanvasLayer.
   virtual bool ShouldForceInactiveLayer(LayerManager *manager) { return false; }
 
   virtual void MarkContextClean() = 0;
 
--- a/dom/html/HTMLCanvasElement.cpp
+++ b/dom/html/HTMLCanvasElement.cpp
@@ -373,17 +373,16 @@ HTMLCanvasElementObserver::HandleEvent(n
 
 NS_IMPL_ISUPPORTS(HTMLCanvasElementObserver, nsIObserver)
 
 // ---------------------------------------------------------------------------
 
 HTMLCanvasElement::HTMLCanvasElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
   : nsGenericHTMLElement(aNodeInfo),
     mResetLayer(true) ,
-    mVRPresentationActive(false),
     mWriteOnly(false)
 {}
 
 HTMLCanvasElement::~HTMLCanvasElement()
 {
   if (mContextObserver) {
     mContextObserver->Destroy();
     mContextObserver = nullptr;
@@ -1155,17 +1154,17 @@ HTMLCanvasElement::GetCanvasLayer(nsDisp
 {
   // The address of sOffscreenCanvasLayerUserDataDummy is used as the user
   // data key for retained LayerManagers managed by FrameLayerBuilder.
   // We don't much care about what value in it, so just assign a dummy
   // value for it.
   static uint8_t sOffscreenCanvasLayerUserDataDummy = 0;
 
   if (mCurrentContext) {
-    return mCurrentContext->GetCanvasLayer(aBuilder, aOldLayer, aManager, mVRPresentationActive);
+    return mCurrentContext->GetCanvasLayer(aBuilder, aOldLayer, aManager);
   }
 
   if (mOffscreenCanvas) {
     if (!mResetLayer &&
         aOldLayer && aOldLayer->HasUserData(&sOffscreenCanvasLayerUserDataDummy)) {
       RefPtr<Layer> ret = aOldLayer;
       return ret.forget();
     }
@@ -1498,42 +1497,16 @@ HTMLCanvasElement::InvalidateFromAsyncCa
   HTMLCanvasElement *element = aRenderer->mHTMLCanvasElement;
   if (!element) {
     return;
   }
 
   element->InvalidateCanvasContent(nullptr);
 }
 
-void
-HTMLCanvasElement::StartVRPresentation()
-{
-  if (GetCurrentContextType() != CanvasContextType::WebGL1 &&
-      GetCurrentContextType() != CanvasContextType::WebGL2) {
-    return;
-  }
-
-  WebGLContext* webgl = static_cast<WebGLContext*>(GetContextAtIndex(0));
-  if (!webgl) {
-    return;
-  }
-
-  if (!webgl->StartVRPresentation()) {
-    return;
-  }
-
-  mVRPresentationActive = true;
-}
-
-void
-HTMLCanvasElement::StopVRPresentation()
-{
-  mVRPresentationActive = false;
-}
-
 already_AddRefed<layers::SharedSurfaceTextureClient>
 HTMLCanvasElement::GetVRFrame()
 {
   if (GetCurrentContextType() != CanvasContextType::WebGL1 &&
       GetCurrentContextType() != CanvasContextType::WebGL2) {
     return nullptr;
   }
 
--- a/dom/html/HTMLCanvasElement.h
+++ b/dom/html/HTMLCanvasElement.h
@@ -336,18 +336,16 @@ public:
 
   void OnVisibilityChange();
 
   void OnMemoryPressure();
 
   static void SetAttrFromAsyncCanvasRenderer(AsyncCanvasRenderer *aRenderer);
   static void InvalidateFromAsyncCanvasRenderer(AsyncCanvasRenderer *aRenderer);
 
-  void StartVRPresentation();
-  void StopVRPresentation();
   already_AddRefed<layers::SharedSurfaceTextureClient> GetVRFrame();
 
 protected:
   virtual ~HTMLCanvasElement();
 
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   virtual nsIntSize GetWidthHeight() override;
@@ -381,17 +379,16 @@ protected:
   RefPtr<HTMLCanvasElement> mOriginalCanvas;
   RefPtr<PrintCallback> mPrintCallback;
   RefPtr<HTMLCanvasPrintState> mPrintState;
   nsTArray<WeakPtr<FrameCaptureListener>> mRequestedFrameListeners;
   RefPtr<RequestedFrameRefreshObserver> mRequestedFrameRefreshObserver;
   RefPtr<AsyncCanvasRenderer> mAsyncCanvasRenderer;
   RefPtr<OffscreenCanvas> mOffscreenCanvas;
   RefPtr<HTMLCanvasElementObserver> mContextObserver;
-  bool mVRPresentationActive;
 
 public:
   // Record whether this canvas should be write-only or not.
   // We set this when script paints an image from a different origin.
   // We also transitively set it when script paints a canvas which
   // is itself write-only.
   bool                     mWriteOnly;
 
--- a/gfx/gl/SharedSurface.cpp
+++ b/gfx/gl/SharedSurface.cpp
@@ -318,22 +318,17 @@ SurfaceFactory::~SurfaceFactory()
 already_AddRefed<layers::SharedSurfaceTextureClient>
 SurfaceFactory::NewTexClient(const gfx::IntSize& size, const layers::LayersIPCChannel* aLayersChannel)
 {
     while (!mRecycleFreePool.empty()) {
         RefPtr<layers::SharedSurfaceTextureClient> cur = mRecycleFreePool.front();
         mRecycleFreePool.pop();
 
         if (cur->Surf()->mSize == size){
-            // In the general case, textureClients transit textures through
-            // CompositorForwarder. But, the textureClient created by VRManagerChild
-            // has a different LayerIPCChannel, PVRManager. Therefore, textureClients
-            // need to be separated into different cases.
-            if ((aLayersChannel && aLayersChannel == cur->GetAllocator()) ||
-                (cur->GetAllocator() != gfx::VRManagerChild::Get())) {
+            if (aLayersChannel && aLayersChannel == cur->GetAllocator()) {
                 cur->Surf()->WaitForBufferOwnership();
                 return cur.forget();
             }
         }
 
         StopRecycling(cur);
     }
 
--- a/gfx/layers/ipc/PTexture.ipdl
+++ b/gfx/layers/ipc/PTexture.ipdl
@@ -4,32 +4,31 @@
 /* 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 LayersSurfaces;
 include protocol PLayerTransaction;
 include protocol PCompositorBridge;
 include protocol PImageBridge;
-include protocol PVRManager;
 include protocol PVideoBridge;
 include "mozilla/GfxMessageUtils.h";
 include "mozilla/layers/LayersMessageUtils.h";
 
 using struct mozilla::layers::FrameMetrics from "FrameMetrics.h";
 using mozilla::layers::TextureFlags from "mozilla/layers/CompositorTypes.h";
 
 namespace mozilla {
 namespace layers {
 
 /**
  * PTexture is the IPDL glue between a TextureClient and a TextureHost.
  */
 sync protocol PTexture {
-    manager PImageBridge or PCompositorBridge or PVRManager or PVideoBridge;
+    manager PImageBridge or PCompositorBridge or PVideoBridge;
 
 child:
     async __delete__();
 
 parent:
     /**
      * Asynchronously tell the compositor side to remove the texture.
      */
--- a/gfx/vr/VRDisplayHost.cpp
+++ b/gfx/vr/VRDisplayHost.cpp
@@ -9,16 +9,17 @@
 #include "mozilla/layers/TextureHost.h"
 #include "mozilla/dom/GamepadBinding.h" // For GamepadMappingType
 
 #if defined(XP_WIN)
 
 #include <d3d11.h>
 #include "gfxWindowsPlatform.h"
 #include "../layers/d3d11/CompositorD3D11.h"
+#include "mozilla/gfx/DeviceManagerDx.h"
 #include "mozilla/layers/TextureD3D11.h"
 
 #elif defined(XP_MACOSX)
 
 #include "mozilla/gfx/MacIOSurface.h"
 
 #endif
 
@@ -156,17 +157,18 @@ VRDisplayHost::NotifyVSync()
   if (bShouldStartFrame) {
     VRManager *vm = VRManager::Get();
     MOZ_ASSERT(vm);
     vm->NotifyVRVsync(mDisplayInfo.mDisplayID);
   }
 }
 
 void
-VRDisplayHost::SubmitFrame(VRLayerParent* aLayer, PTextureParent* aTexture,
+VRDisplayHost::SubmitFrame(VRLayerParent* aLayer,
+                           const layers::SurfaceDescriptor &aTexture,
                            uint64_t aFrameId,
                            const gfx::Rect& aLeftEyeRect,
                            const gfx::Rect& aRightEyeRect)
 {
   AutoProfilerTracing tracing("VR", "SubmitFrameAtVRDisplayHost");
 
   if ((mDisplayInfo.mGroupMask & aLayer->GetGroup()) == 0) {
     // Suppress layers hidden by the group mask
@@ -174,72 +176,90 @@ VRDisplayHost::SubmitFrame(VRLayerParent
   }
 
   // Ensure that we only accept the first SubmitFrame call per RAF cycle.
   if (!mFrameStarted || aFrameId != mDisplayInfo.mFrameId) {
     return;
   }
   mFrameStarted = false;
 
-#if defined(XP_WIN)
-
-  TextureHost* th = TextureHost::AsTextureHost(aTexture);
+  switch (aTexture.type()) {
 
-  // WebVR doesn't use the compositor to compose the frame, so use
-  // AutoLockTextureHostWithoutCompositor here.
-  AutoLockTextureHostWithoutCompositor autoLock(th);
-  if (autoLock.Failed()) {
-    NS_WARNING("Failed to lock the VR layer texture");
-    return;
-  }
+#if defined(XP_WIN)
+    case SurfaceDescriptor::TSurfaceDescriptorD3D10: {
+      const SurfaceDescriptorD3D10& surf = aTexture.get_SurfaceDescriptorD3D10();
+      ID3D11Device* device = GetDevice();
+      if (!device) {
+        return;
+      }
+      RefPtr<ID3D11Texture2D> dxTexture = nullptr;
+      HRESULT hr = GetDevice()->OpenSharedResource((HANDLE)surf.handle(),
+        __uuidof(ID3D11Texture2D),
+        (void**)(ID3D11Texture2D**)getter_AddRefs(dxTexture));
+      if (FAILED(hr)) {
+        NS_WARNING("Failed to open shared texture");
+        return;
+      }
 
-  CompositableTextureSourceRef source;
-  if (!th->BindTextureSource(source)) {
-    NS_WARNING("The TextureHost was successfully locked but can't provide a TextureSource");
-    return;
-  }
-  MOZ_ASSERT(source);
-
-  IntSize texSize = source->GetSize();
-
-  TextureSourceD3D11* sourceD3D11 = source->AsSourceD3D11();
-  if (!sourceD3D11) {
-    NS_WARNING("VRDisplayHost::SubmitFrame failed to get a TextureSourceD3D11");
-    return;
+      // Similar to LockD3DTexture in TextureD3D11.cpp
+      RefPtr<IDXGIKeyedMutex> mutex;
+      dxTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mutex));
+      if (mutex) {
+        HRESULT hr = mutex->AcquireSync(0, 10000);
+        if (hr == WAIT_TIMEOUT) {
+          gfxDevCrash(LogReason::D3DLockTimeout) << "D3D lock mutex timeout";
+        }
+        else if (hr == WAIT_ABANDONED) {
+          gfxCriticalNote << "GFX: D3D11 lock mutex abandoned";
+        }
+        if (FAILED(hr)) {
+          NS_WARNING("Failed to lock the texture");
+          return;
+        }
+      }
+      bool success = true;
+      if (!SubmitFrame(dxTexture, surf.size(), aLeftEyeRect, aRightEyeRect)) {
+        success = false;
+      }
+      if (mutex) {
+        HRESULT hr = mutex->ReleaseSync(0);
+        if (FAILED(hr)) {
+          NS_WARNING("Failed to unlock the texture");
+        }
+      }
+      if (!success) {
+        return;
+      }
+      break;
+    }
+#elif defined(XP_MACOSX)
+    case SurfaceDescriptor::TSurfaceDescriptorMacIOSurface: {
+      const SurfaceDescriptorMacIOSurface& desc = aTexture.get_SurfaceDescriptorMacIOSurface();
+      RefPtr<MacIOSurface> surf = MacIOSurface::LookupSurface(desc.surfaceId(),
+                                                              desc.scaleFactor(),
+                                                              !desc.isOpaque());
+      if (!surf) {
+        NS_WARNING("VRDisplayHost::SubmitFrame failed to get a MacIOSurface");
+        return;
+      }
+      IntSize texSize = gfx::IntSize(surf->GetDevicePixelWidth(),
+                                     surf->GetDevicePixelHeight());
+      if (!SubmitFrame(surf, texSize, aLeftEyeRect, aRightEyeRect)) {
+        return;
+      }
+      break;
+    }
+#endif
+    default: {
+      NS_WARNING("Unsupported SurfaceDescriptor type for VR layer texture");
+      return;
+    }
   }
 
-  if (!SubmitFrame(sourceD3D11, texSize, aLeftEyeRect, aRightEyeRect)) {
-    return;
-  }
-
-#elif defined(XP_MACOSX)
-
-  TextureHost* th = TextureHost::AsTextureHost(aTexture);
-
-  MacIOSurface* surf = th->GetMacIOSurface();
-  if (!surf) {
-    NS_WARNING("VRDisplayHost::SubmitFrame failed to get a MacIOSurface");
-    return;
-  }
-
-  IntSize texSize = gfx::IntSize(surf->GetDevicePixelWidth(),
-                                 surf->GetDevicePixelHeight());
-
-  if (!SubmitFrame(surf, texSize, aLeftEyeRect, aRightEyeRect)) {
-    return;
-  }
-
-#else
-
-  NS_WARNING("WebVR is not supported on this platform.");
-  return;
-#endif
-
 #if defined(XP_WIN) || defined(XP_MACOSX)
-
   /**
    * Trigger the next VSync immediately after we are successfully
    * submitting frames.  As SubmitFrame is responsible for throttling
    * the render loop, if we don't successfully call it, we shouldn't trigger
    * NotifyVRVsync immediately, as it will run unbounded.
    * If NotifyVRVsync is not called here due to SubmitFrame failing, the
    * fallback "watchdog" code in VRDisplayHost::NotifyVSync() will cause
    * frames to continue at a lower refresh rate until frame submission
@@ -256,16 +276,31 @@ VRDisplayHost::CheckClearDisplayInfoDirt
 {
   if (mDisplayInfo == mLastUpdateDisplayInfo) {
     return false;
   }
   mLastUpdateDisplayInfo = mDisplayInfo;
   return true;
 }
 
+
+#if defined(XP_WIN)
+ID3D11Device*
+VRDisplayHost::GetDevice()
+{
+  if (!mDevice) {
+    mDevice = gfx::DeviceManagerDx::Get()->GetVRDevice();
+    if (!mDevice) {
+      NS_WARNING("Failed to get a D3D11Device for VRDisplayHost");
+    }
+  }
+  return mDevice;
+}
+#endif
+
 VRControllerHost::VRControllerHost(VRDeviceType aType, dom::GamepadHand aHand,
                                    uint32_t aDisplayID)
  : mButtonPressed(0)
  , mButtonTouched(0)
  , mVibrateIndex(0)
 {
   MOZ_COUNT_CTOR(VRControllerHost);
   mControllerInfo.mType = aType;
--- a/gfx/vr/VRDisplayHost.h
+++ b/gfx/vr/VRDisplayHost.h
@@ -12,27 +12,24 @@
 #include "nsCOMPtr.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/EnumeratedArray.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/TypedEnumBits.h"
 #include "mozilla/dom/GamepadPoseState.h"
+#include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
 
-#if defined(XP_MACOSX)
+#if defined(XP_WIN)
+struct ID3D11Texture2D;
+#elif defined(XP_MACOSX)
 class MacIOSurface;
 #endif
 namespace mozilla {
-namespace layers {
-class PTextureParent;
-#if defined(XP_WIN)
-class TextureSourceD3D11;
-#endif
-} // namespace layers
 namespace gfx {
 class VRLayerParent;
 
 class VRDisplayHost {
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRDisplayHost)
 
   const VRDisplayInfo& GetDisplayInfo() const { return mDisplayInfo; }
@@ -42,17 +39,17 @@ public:
 
   virtual void ZeroSensor() = 0;
   virtual void StartPresentation() = 0;
   virtual void StopPresentation() = 0;
   virtual void NotifyVSync();
 
   void StartFrame();
   void SubmitFrame(VRLayerParent* aLayer,
-                   mozilla::layers::PTextureParent* aTexture,
+                   const layers::SurfaceDescriptor& aTexture,
                    uint64_t aFrameId,
                    const gfx::Rect& aLeftEyeRect,
                    const gfx::Rect& aRightEyeRect);
 
   bool CheckClearDisplayInfoDirty();
   void SetGroupMask(uint32_t aGroupMask);
   bool GetIsConnected();
 
@@ -60,17 +57,17 @@ protected:
   explicit VRDisplayHost(VRDeviceType aType);
   virtual ~VRDisplayHost();
 
 #if defined(XP_WIN)
   // Subclasses should override this SubmitFrame function.
   // Returns true if the SubmitFrame call will block as necessary
   // to control timing of the next frame and throttle the render loop
   // for the needed framerate.
-  virtual bool SubmitFrame(mozilla::layers::TextureSourceD3D11* aSource,
+  virtual bool SubmitFrame(ID3D11Texture2D* aSource,
                            const IntSize& aSize,
                            const gfx::Rect& aLeftEyeRect,
                            const gfx::Rect& aRightEyeRect) = 0;
 #elif defined(XP_MACOSX)
   virtual bool SubmitFrame(MacIOSurface* aMacIOSurface,
                            const IntSize& aSize,
                            const gfx::Rect& aLeftEyeRect,
                            const gfx::Rect& aRightEyeRect) = 0;
@@ -80,20 +77,28 @@ protected:
 
   nsTArray<RefPtr<VRLayerParent>> mLayers;
   // Weak reference to mLayers entries are cleared in
   // VRLayerParent destructor
 
 protected:
   virtual VRHMDSensorState GetSensorState() = 0;
 
+#if defined(XP_WIN)
+  virtual ID3D11Device* GetDevice();
+#endif
+
 private:
   VRDisplayInfo mLastUpdateDisplayInfo;
   TimeStamp mLastFrameStart;
   bool mFrameStarted;
+
+#if defined(XP_WIN)
+  RefPtr<ID3D11Device> mDevice;
+#endif
 };
 
 class VRControllerHost {
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRControllerHost)
 
   const VRControllerInfo& GetControllerInfo() const;
   void SetButtonPressed(uint64_t aBit);
--- a/gfx/vr/VRManager.cpp
+++ b/gfx/vr/VRManager.cpp
@@ -338,30 +338,16 @@ VRManager::GetDisplay(const uint32_t& aD
 {
   RefPtr<gfx::VRDisplayHost> display;
   if (mVRDisplays.Get(aDisplayID, getter_AddRefs(display))) {
     return display;
   }
   return nullptr;
 }
 
-void
-VRManager::SubmitFrame(VRLayerParent* aLayer, layers::PTextureParent* aTexture,
-                       uint64_t aFrameId,
-                       const gfx::Rect& aLeftEyeRect,
-                       const gfx::Rect& aRightEyeRect)
-{
-  TextureHost* th = TextureHost::AsTextureHost(aTexture);
-  mLastFrame = th;
-  RefPtr<VRDisplayHost> display = GetDisplay(aLayer->GetDisplayID());
-  if (display) {
-    display->SubmitFrame(aLayer, aTexture, aFrameId, aLeftEyeRect, aRightEyeRect);
-  }
-}
-
 RefPtr<gfx::VRControllerHost>
 VRManager::GetController(const uint32_t& aControllerID)
 {
   RefPtr<gfx::VRControllerHost> controller;
   if (mVRControllers.Get(aControllerID, getter_AddRefs(controller))) {
     return controller;
   }
   return nullptr;
--- a/gfx/vr/VRManager.h
+++ b/gfx/vr/VRManager.h
@@ -38,36 +38,30 @@ public:
   void NotifyVRVsync(const uint32_t& aDisplayID);
   void RefreshVRDisplays(bool aMustDispatch = false);
   void RefreshVRControllers();
   void ScanForControllers();
   void RemoveControllers();
   template<class T> void NotifyGamepadChange(uint32_t aIndex, const T& aInfo);
   RefPtr<gfx::VRDisplayHost> GetDisplay(const uint32_t& aDisplayID);
   void GetVRDisplayInfo(nsTArray<VRDisplayInfo>& aDisplayInfo);
-
-  void SubmitFrame(VRLayerParent* aLayer, layers::PTextureParent* aTexture,
-                   uint64_t aFrameId,
-                   const gfx::Rect& aLeftEyeRect,
-                   const gfx::Rect& aRightEyeRect);
   RefPtr<gfx::VRControllerHost> GetController(const uint32_t& aControllerID);
   void GetVRControllerInfo(nsTArray<VRControllerInfo>& aControllerInfo);
   void CreateVRTestSystem();
   void VibrateHaptic(uint32_t aControllerIdx, uint32_t aHapticIndex,
                      double aIntensity, double aDuration, uint32_t aPromiseID);
   void StopVibrateHaptic(uint32_t aControllerIdx);
   void NotifyVibrateHapticCompleted(uint32_t aPromiseID);
   void DispatchSubmitFrameResult(uint32_t aDisplayID, const VRSubmitFrameResultInfo& aResult);
 
 protected:
   VRManager();
   ~VRManager();
 
 private:
-  RefPtr<layers::TextureHost> mLastFrame;
 
   void Init();
   void Destroy();
   void Shutdown();
 
   void DispatchVRDisplayInfoUpdate();
 
   typedef nsTHashtable<nsRefPtrHashKey<VRManagerParent>> VRManagerParentSet;
--- a/gfx/vr/gfxVR.h
+++ b/gfx/vr/gfxVR.h
@@ -132,17 +132,17 @@ struct VRFieldOfView {
   double leftDegrees;
 };
 
 struct VRHMDSensorState {
   VRHMDSensorState()
   {
     Clear();
   }
-  int32_t inputFrameID;
+  int64_t inputFrameID;
   double timestamp;
   VRDisplayCapabilityFlags flags;
 
   // These members will only change with inputFrameID:
   float orientation[4];
   float position[3];
   float angularVelocity[3];
   float angularAcceleration[3];
@@ -194,17 +194,17 @@ struct VRDisplayInfo
   const Point3D& GetEyeTranslation(uint32_t whichEye) const { return mEyeTranslation[whichEye]; }
   const VRFieldOfView& GetEyeFOV(uint32_t whichEye) const { return mEyeFOV[whichEye]; }
   bool GetIsConnected() const { return mIsConnected; }
   bool GetIsMounted() const { return mIsMounted; }
   uint32_t GetPresentingGroups() const { return mPresentingGroups; }
   uint32_t GetGroupMask() const { return mGroupMask; }
   const Size& GetStageSize() const { return mStageSize; }
   const Matrix4x4& GetSittingToStandingTransform() const { return mSittingToStandingTransform; }
-  uint32_t GetFrameId() const { return mFrameId; }
+  uint64_t GetFrameId() const { return mFrameId; }
 
   enum Eye {
     Eye_Left,
     Eye_Right,
     NumEyes
   };
 
   uint32_t mDisplayID;
@@ -215,17 +215,17 @@ struct VRDisplayInfo
   Point3D mEyeTranslation[VRDisplayInfo::NumEyes];
   IntSize mEyeResolution;
   bool mIsConnected;
   bool mIsMounted;
   uint32_t mPresentingGroups;
   uint32_t mGroupMask;
   Size mStageSize;
   Matrix4x4 mSittingToStandingTransform;
-  uint32_t mFrameId;
+  uint64_t mFrameId;
   VRHMDSensorState mLastSensorState[kVRMaxLatencyFrames];
 
   bool operator==(const VRDisplayInfo& other) const {
     for (size_t i = 0; i < kVRMaxLatencyFrames; i++) {
       if (mLastSensorState[i] != other.mLastSensorState[i]) {
         return false;
       }
     }
--- a/gfx/vr/gfxVROSVR.cpp
+++ b/gfx/vr/gfxVROSVR.cpp
@@ -316,17 +316,17 @@ VRDisplayOSVR::GetSensorState()
   }
 
   return result;
 }
 
 #if defined(XP_WIN)
 
 bool
-VRDisplayOSVR::SubmitFrame(TextureSourceD3D11* aSource,
+VRDisplayOSVR::SubmitFrame(ID3D11Texture2D* aSource,
   const IntSize& aSize,
   const gfx::Rect& aLeftEyeRect,
   const gfx::Rect& aRightEyeRect)
 {
   // XXX Add code to submit frame
   return false;
 }
 
--- a/gfx/vr/gfxVROSVR.h
+++ b/gfx/vr/gfxVROSVR.h
@@ -31,17 +31,17 @@ public:
   void ZeroSensor() override;
 
 protected:
   VRHMDSensorState GetSensorState() override;
   virtual void StartPresentation() override;
   virtual void StopPresentation() override;
 
 #if defined(XP_WIN)
-  virtual bool SubmitFrame(mozilla::layers::TextureSourceD3D11* aSource,
+  virtual bool SubmitFrame(ID3D11Texture2D* aSource,
                            const IntSize& aSize,
                            const gfx::Rect& aLeftEyeRect,
                            const gfx::Rect& aRightEyeRect) override;
 #elif defined(XP_MACOSX)
   virtual bool SubmitFrame(MacIOSurface* aMacIOSurface,
                            const IntSize& aSize,
                            const gfx::Rect& aLeftEyeRect,
                            const gfx::Rect& aRightEyeRect) override;
--- a/gfx/vr/gfxVROculus.cpp
+++ b/gfx/vr/gfxVROculus.cpp
@@ -262,18 +262,18 @@ VROculusSession::StopPresentation()
       if (ovr_GetPerfStats(mSession, &perfStats) == ovrSuccess) {
         if (perfStats.FrameStatsCount) {
           const uint32_t droppedFramesPerSec = (perfStats.FrameStats[0].AppDroppedFrameCount -
                                                 mTelemetry.mLastDroppedFrameCount) / duration.ToSeconds();
           Telemetry::Accumulate(Telemetry::WEBVR_DROPPED_FRAMES_IN_OCULUS, droppedFramesPerSec);
         }
       }
     }
-    Refresh();
   }
+  Refresh();
 }
 
 VROculusSession::~VROculusSession()
 {
   Uninitialize(true);
 }
 
 void
@@ -292,16 +292,17 @@ VROculusSession::StopRendering()
 {
   if (!mRenderTargets.IsEmpty()) {
     mRenderTargets.Clear();
   }
   if (mTextureSet && mSession) {
     ovr_DestroyTextureSwapChain(mSession, mTextureSet);
   }
   mTextureSet = nullptr;
+  mContext = nullptr;
   mDevice = nullptr;
 }
 
 void
 VROculusSession::StopSession()
 {
   if (mSession) {
     ovr_Destroy(mSession);
@@ -407,21 +408,27 @@ VROculusSession::Initialize(ovrInitFlags
 bool
 VROculusSession::StartRendering()
 {
   if (!mPresenting) {
     // Nothing to do if we aren't presenting
     return true;
   }
   if (!mDevice) {
-    mDevice = gfx::DeviceManagerDx::Get()->GetCompositorDevice();
+    mDevice = gfx::DeviceManagerDx::Get()->GetVRDevice();
     if (!mDevice) {
       NS_WARNING("Failed to get a D3D11Device for Oculus");
       return false;
     }
+    mDevice->GetImmediateContext(getter_AddRefs(mContext));
+    if (!mContext) {
+      mDevice = nullptr;
+      NS_WARNING("Failed to get D3D11DeviceContext for Oculus");
+      return false;
+    }
   }
 
   if (!mTextureSet) {
     /**
     * The presentation format is determined by content, which describes the
     * left and right eye rectangles in the VRLayer.  The default, if no
     * coordinates are passed is to place the left and right eye textures
     * side-by-side within the buffer.
@@ -516,18 +523,17 @@ VROculusSession::StartSession()
   if (mSession != nullptr) {
     // HMD Detected and we already have a session, let's keep using it.
     return true;
   }
 
   // HMD Detected and we don't have a session yet,
   // try to create a new session
   ovrSession session;
-  ovrGraphicsLuid luid;
-  ovrResult orv = ovr_Create(&session, &luid);
+  ovrResult orv = ovr_Create(&session, &mLuid);
   if (orv == ovrSuccess) {
     orv = ovr_SetTrackingOriginType(session, ovrTrackingOrigin_FloorLevel);
     if (orv != ovrSuccess) {
       NS_WARNING("ovr_SetTrackingOriginType failed.\n");
     }
     mSession = session;
     return true;
   }
@@ -697,16 +703,30 @@ VROculusSession::GetNextRenderTarget()
 
 ovrTextureSwapChain
 VROculusSession::GetSwapChain()
 {
   MOZ_ASSERT(mTextureSet);
   return mTextureSet;
 }
 
+ID3D11Device*
+VROculusSession::GetDevice()
+{
+  MOZ_ASSERT(mDevice);
+  return mDevice;
+}
+
+ID3D11DeviceContext*
+VROculusSession::GetContext()
+{
+  MOZ_ASSERT(mContext);
+  return mContext;
+}
+
 void
 VROculusSession::UnloadOvrLib()
 {
   if (mOvrLib) {
     PR_UnloadLibrary(mOvrLib);
     mOvrLib = nullptr;
   }
 }
@@ -845,17 +865,16 @@ VRDisplayOculus::GetSensorState()
       // XXX We might need to call ovr_GetPredictedDisplayTime even if we don't use the result.
       // If we don't call it, the Oculus driver will spew out many warnings...
       predictedFrameTime = ovr_GetPredictedDisplayTime(mSession->Get(), 0);
     }
     result = GetSensorState(predictedFrameTime);
   }
   result.inputFrameID = mDisplayInfo.mFrameId;
   result.position[1] -= mEyeHeight;
-  mDisplayInfo.mLastSensorState[result.inputFrameID % kVRMaxLatencyFrames] = result;
   return result;
 }
 
 VRHMDSensorState
 VRDisplayOculus::GetSensorState(double absTime)
 {
   VRHMDSensorState result;
 
@@ -910,97 +929,86 @@ VRDisplayOculus::GetSensorState(double a
 void
 VRDisplayOculus::StartPresentation()
 {
   mSession->StartPresentation(IntSize(mDisplayInfo.mEyeResolution.width * 2, mDisplayInfo.mEyeResolution.height));
   if (!mSession->IsRenderReady()) {
     return;
   }
 
-  if (!mDevice) {
-    mDevice = gfx::DeviceManagerDx::Get()->GetCompositorDevice();
-    if (!mDevice) {
-      NS_WARNING("Failed to get a D3D11Device for Oculus");
-      return;
-    }
-  }
-
-  if (!mContext) {
-    mDevice->GetImmediateContext(getter_AddRefs(mContext));
-    if (!mContext) {
-      NS_WARNING("Failed to get immediate context for Oculus");
-      return;
-    }
+  ID3D11Device* device = mSession->GetDevice();
+  if (!device) {
+    NS_WARNING("Failed to get a D3D11Device for Oculus");
   }
 
   if (!mQuadVS) {
-    if (FAILED(mDevice->CreateVertexShader(sLayerQuadVS.mData, sLayerQuadVS.mLength, nullptr, &mQuadVS))) {
+    if (FAILED(device->CreateVertexShader(sLayerQuadVS.mData, sLayerQuadVS.mLength, nullptr, &mQuadVS))) {
       NS_WARNING("Failed to create vertex shader for Oculus");
       return;
     }
   }
 
   if (!mQuadPS) {
-    if (FAILED(mDevice->CreatePixelShader(sRGBShader.mData, sRGBShader.mLength, nullptr, &mQuadPS))) {
+    if (FAILED(device->CreatePixelShader(sRGBShader.mData, sRGBShader.mLength, nullptr, &mQuadPS))) {
       NS_WARNING("Failed to create pixel shader for Oculus");
       return;
     }
   }
 
   CD3D11_BUFFER_DESC cBufferDesc(sizeof(layers::VertexShaderConstants),
     D3D11_BIND_CONSTANT_BUFFER,
     D3D11_USAGE_DYNAMIC,
     D3D11_CPU_ACCESS_WRITE);
 
   if (!mVSConstantBuffer) {
-    if (FAILED(mDevice->CreateBuffer(&cBufferDesc, nullptr, getter_AddRefs(mVSConstantBuffer)))) {
+    if (FAILED(device->CreateBuffer(&cBufferDesc, nullptr, getter_AddRefs(mVSConstantBuffer)))) {
       NS_WARNING("Failed to vertex shader constant buffer for Oculus");
       return;
     }
   }
 
   if (!mPSConstantBuffer) {
     cBufferDesc.ByteWidth = sizeof(layers::PixelShaderConstants);
-    if (FAILED(mDevice->CreateBuffer(&cBufferDesc, nullptr, getter_AddRefs(mPSConstantBuffer)))) {
+    if (FAILED(device->CreateBuffer(&cBufferDesc, nullptr, getter_AddRefs(mPSConstantBuffer)))) {
       NS_WARNING("Failed to pixel shader constant buffer for Oculus");
       return;
     }
   }
 
   if (!mLinearSamplerState) {
     CD3D11_SAMPLER_DESC samplerDesc(D3D11_DEFAULT);
-    if (FAILED(mDevice->CreateSamplerState(&samplerDesc, getter_AddRefs(mLinearSamplerState)))) {
+    if (FAILED(device->CreateSamplerState(&samplerDesc, getter_AddRefs(mLinearSamplerState)))) {
       NS_WARNING("Failed to create sampler state for Oculus");
       return;
     }
   }
 
   if (!mInputLayout) {
     D3D11_INPUT_ELEMENT_DESC layout[] =
     {
       { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
     };
 
-    if (FAILED(mDevice->CreateInputLayout(layout,
+    if (FAILED(device->CreateInputLayout(layout,
                                               sizeof(layout) / sizeof(D3D11_INPUT_ELEMENT_DESC),
                                               sLayerQuadVS.mData,
                                               sLayerQuadVS.mLength,
                                               getter_AddRefs(mInputLayout)))) {
       NS_WARNING("Failed to create input layout for Oculus");
       return;
     }
   }
 
   if (!mVertexBuffer) {
     Vertex vertices[] = { { { 0.0, 0.0 } },{ { 1.0, 0.0 } },{ { 0.0, 1.0 } },{ { 1.0, 1.0 } } };
     CD3D11_BUFFER_DESC bufferDesc(sizeof(vertices), D3D11_BIND_VERTEX_BUFFER);
     D3D11_SUBRESOURCE_DATA data;
     data.pSysMem = (void*)vertices;
 
-    if (FAILED(mDevice->CreateBuffer(&bufferDesc, &data, getter_AddRefs(mVertexBuffer)))) {
+    if (FAILED(device->CreateBuffer(&bufferDesc, &data, getter_AddRefs(mVertexBuffer)))) {
       NS_WARNING("Failed to create vertex buffer for Oculus");
       return;
     }
   }
 
   memset(&mVSConstants, 0, sizeof(mVSConstants));
   memset(&mPSConstants, 0, sizeof(mPSConstants));
 }
@@ -1015,59 +1023,71 @@ VRDisplayOculus::StopPresentation()
 
 bool
 VRDisplayOculus::UpdateConstantBuffers()
 {
   HRESULT hr;
   D3D11_MAPPED_SUBRESOURCE resource;
   resource.pData = nullptr;
 
-  hr = mContext->Map(mVSConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &resource);
+  ID3D11DeviceContext* context = mSession->GetContext();
+  if (!context) {
+    NS_WARNING("Failed to get immediate context for Oculus");
+    return false;
+  }
+
+  hr = context->Map(mVSConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &resource);
   if (FAILED(hr) || !resource.pData) {
     return false;
   }
   *(VertexShaderConstants*)resource.pData = mVSConstants;
-  mContext->Unmap(mVSConstantBuffer, 0);
+  context->Unmap(mVSConstantBuffer, 0);
   resource.pData = nullptr;
 
-  hr = mContext->Map(mPSConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &resource);
+  hr = context->Map(mPSConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &resource);
   if (FAILED(hr) || !resource.pData) {
     return false;
   }
   *(PixelShaderConstants*)resource.pData = mPSConstants;
-  mContext->Unmap(mPSConstantBuffer, 0);
+  context->Unmap(mPSConstantBuffer, 0);
 
   ID3D11Buffer *buffer = mVSConstantBuffer;
-  mContext->VSSetConstantBuffers(0, 1, &buffer);
+  context->VSSetConstantBuffers(0, 1, &buffer);
   buffer = mPSConstantBuffer;
-  mContext->PSSetConstantBuffers(0, 1, &buffer);
+  context->PSSetConstantBuffers(0, 1, &buffer);
   return true;
 }
 
 bool
-VRDisplayOculus::SubmitFrame(TextureSourceD3D11* aSource,
-  const IntSize& aSize,
-  const gfx::Rect& aLeftEyeRect,
-  const gfx::Rect& aRightEyeRect)
+VRDisplayOculus::SubmitFrame(ID3D11Texture2D* aSource,
+                             const IntSize& aSize,
+                             const gfx::Rect& aLeftEyeRect,
+                             const gfx::Rect& aRightEyeRect)
 {
-  if (!mSession->IsRenderReady() || !mDevice || !mContext) {
+  if (!mSession->IsRenderReady()) {
     return false;
   }
   /**
     * XXX - We should resolve fail the promise returned by
     *       VRDisplay.requestPresent() when the DX11 resources fail allocation
     *       in VRDisplayOculus::StartPresentation().
     *       Bailing out here prevents the crash but content should be aware
     *       that frames are not being presented.
     *       See Bug 1299309.
     **/
 
+  ID3D11DeviceContext* context = mSession->GetContext();
+  if (!context) {
+    NS_WARNING("Failed to get immediate context for Oculus");
+    return false;
+  }
+
   RefPtr<CompositingRenderTargetD3D11> surface = mSession->GetNextRenderTarget();
 
-  surface->BindRenderTarget(mContext);
+  surface->BindRenderTarget(context);
 
   Matrix viewMatrix = Matrix::Translation(-1.0, 1.0);
   viewMatrix.PreScale(2.0f / float(aSize.width), 2.0f / float(aSize.height));
   viewMatrix.PreScale(1.0f, -1.0f);
   Matrix4x4 projection = Matrix4x4::From2D(viewMatrix);
   projection._33 = 0.0f;
 
   Matrix transform2d;
@@ -1094,41 +1114,49 @@ VRDisplayOculus::SubmitFrame(TextureSour
   mVSConstants.layerQuad = Rect(0.0f, 0.0f, aSize.width, aSize.height);
   mVSConstants.textureCoords = Rect(0.0f, 1.0f, 1.0f, -1.0f);
 
   mPSConstants.layerOpacity[0] = 1.0f;
 
   ID3D11Buffer* vbuffer = mVertexBuffer;
   UINT vsize = sizeof(Vertex);
   UINT voffset = 0;
-  mContext->IASetVertexBuffers(0, 1, &vbuffer, &vsize, &voffset);
-  mContext->IASetIndexBuffer(nullptr, DXGI_FORMAT_R16_UINT, 0);
-  mContext->IASetInputLayout(mInputLayout);
-  mContext->RSSetViewports(1, &viewport);
-  mContext->RSSetScissorRects(1, &scissor);
-  mContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
-  mContext->VSSetShader(mQuadVS, nullptr, 0);
-  mContext->PSSetShader(mQuadPS, nullptr, 0);
-  ID3D11ShaderResourceView* srView = aSource->GetShaderResourceView();
-  if (!srView) {
-    NS_WARNING("Failed to get SRV for Oculus");
+  context->IASetVertexBuffers(0, 1, &vbuffer, &vsize, &voffset);
+  context->IASetIndexBuffer(nullptr, DXGI_FORMAT_R16_UINT, 0);
+  context->IASetInputLayout(mInputLayout);
+  context->RSSetViewports(1, &viewport);
+  context->RSSetScissorRects(1, &scissor);
+  context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
+  context->VSSetShader(mQuadVS, nullptr, 0);
+  context->PSSetShader(mQuadPS, nullptr, 0);
+
+  ID3D11Device* device = mSession->GetDevice();
+  if (!device) {
     return false;
   }
-  mContext->PSSetShaderResources(0 /* 0 == TexSlot::RGB */, 1, &srView);
+
+  RefPtr<ID3D11ShaderResourceView> srView;
+  HRESULT hr = device->CreateShaderResourceView(aSource, nullptr, getter_AddRefs(srView));
+  if (FAILED(hr) || !srView) {
+    gfxWarning() << "Could not create shader resource view for Oculus: " << hexa(hr);
+    return nullptr;
+  }
+  ID3D11ShaderResourceView* viewPtr = srView.get();
+  context->PSSetShaderResources(0 /* 0 == TexSlot::RGB */, 1, &viewPtr);
   // XXX Use Constant from TexSlot in CompositorD3D11.cpp?
 
   ID3D11SamplerState *sampler = mLinearSamplerState;
-  mContext->PSSetSamplers(0, 1, &sampler);
+  context->PSSetSamplers(0, 1, &sampler);
 
   if (!UpdateConstantBuffers()) {
     NS_WARNING("Failed to update constant buffers for Oculus");
     return false;
   }
 
-  mContext->Draw(4, 0);
+  context->Draw(4, 0);
 
   ovrResult orv = ovr_CommitTextureSwapChain(mSession->Get(), mSession->GetSwapChain());
   if (orv != ovrSuccess) {
     NS_WARNING("ovr_CommitTextureSwapChain failed.\n");
     return false;
   }
 
   ovrLayerEyeFov layer;
--- a/gfx/vr/gfxVROculus.h
+++ b/gfx/vr/gfxVROculus.h
@@ -45,25 +45,29 @@ public:
   bool IsRenderReady() const;
   ovrSession Get();
   void StartPresentation(const IntSize& aSize);
   void StopPresentation();
   void StopTracking();
   bool IsQuitTimeoutActive();
   already_AddRefed<layers::CompositingRenderTargetD3D11> GetNextRenderTarget();
   ovrTextureSwapChain GetSwapChain();
+  ID3D11Device* GetDevice();
+  ID3D11DeviceContext* GetContext();
 
 private:
   PRLibrary* mOvrLib;
   ovrSession mSession;
+  ovrGraphicsLuid mLuid;
   ovrInitFlags mInitFlags;
   ovrTextureSwapChain mTextureSet;
   nsTArray<RefPtr<layers::CompositingRenderTargetD3D11>> mRenderTargets;
   IntSize mPresentationSize;
   RefPtr<ID3D11Device> mDevice;
+  RefPtr<ID3D11DeviceContext> mContext;
   // The timestamp of the last time Oculus set ShouldQuit to true.
   TimeStamp mLastShouldQuit;
   // The timestamp of the last ending presentation
   TimeStamp mLastPresentationEnd;
   VRTelemetry mTelemetry;
   bool mPresenting;
 
   ~VROculusSession();
@@ -84,17 +88,17 @@ class VRDisplayOculus : public VRDisplay
 public:
   virtual void NotifyVSync() override;
   void ZeroSensor() override;
 
 protected:
   virtual VRHMDSensorState GetSensorState() override;
   virtual void StartPresentation() override;
   virtual void StopPresentation() override;
-  virtual bool SubmitFrame(mozilla::layers::TextureSourceD3D11* aSource,
+  virtual bool SubmitFrame(ID3D11Texture2D* aSource,
                            const IntSize& aSize,
                            const gfx::Rect& aLeftEyeRect,
                            const gfx::Rect& aRightEyeRect) override;
   void UpdateStageParameters();
 
 public:
   explicit VRDisplayOculus(VROculusSession* aSession);
   void Destroy();
@@ -104,17 +108,16 @@ protected:
 
   VRHMDSensorState GetSensorState(double absTime);
 
   ovrHmdDesc mDesc;
   RefPtr<VROculusSession> mSession;
   ovrFovPort mFOVPort[2];
 
   RefPtr<ID3D11Device> mDevice;
-  RefPtr<ID3D11DeviceContext> mContext;
   ID3D11VertexShader* mQuadVS;
   ID3D11PixelShader* mQuadPS;
   RefPtr<ID3D11SamplerState> mLinearSamplerState;
   layers::VertexShaderConstants mVSConstants;
   layers::PixelShaderConstants mPSConstants;
   RefPtr<ID3D11Buffer> mVSConstantBuffer;
   RefPtr<ID3D11Buffer> mPSConstantBuffer;
   RefPtr<ID3D11Buffer> mVertexBuffer;
--- a/gfx/vr/gfxVROpenVR.cpp
+++ b/gfx/vr/gfxVROpenVR.cpp
@@ -359,22 +359,22 @@ VRDisplayOpenVR::SubmitFrame(void* aText
 
   mVRCompositor->PostPresentHandoff();
   return true;
 }
 
 #if defined(XP_WIN)
 
 bool
-VRDisplayOpenVR::SubmitFrame(TextureSourceD3D11* aSource,
+VRDisplayOpenVR::SubmitFrame(ID3D11Texture2D* aSource,
                              const IntSize& aSize,
                              const gfx::Rect& aLeftEyeRect,
                              const gfx::Rect& aRightEyeRect)
 {
-  return SubmitFrame((void *)aSource->GetD3D11Texture(),
+  return SubmitFrame((void *)aSource,
                      ::vr::ETextureType::TextureType_DirectX,
                      aSize, aLeftEyeRect, aRightEyeRect);
 }
 
 #elif defined(XP_MACOSX)
 
 bool
 VRDisplayOpenVR::SubmitFrame(MacIOSurface* aMacIOSurface,
--- a/gfx/vr/gfxVROpenVR.h
+++ b/gfx/vr/gfxVROpenVR.h
@@ -33,17 +33,17 @@ public:
   void ZeroSensor() override;
   bool GetIsHmdPresent();
 
 protected:
   virtual VRHMDSensorState GetSensorState() override;
   virtual void StartPresentation() override;
   virtual void StopPresentation() override;
 #if defined(XP_WIN)
-  virtual bool SubmitFrame(mozilla::layers::TextureSourceD3D11* aSource,
+  virtual bool SubmitFrame(ID3D11Texture2D* aSource,
                            const IntSize& aSize,
                            const gfx::Rect& aLeftEyeRect,
                            const gfx::Rect& aRightEyeRect) override;
 #elif defined(XP_MACOSX)
   virtual bool SubmitFrame(MacIOSurface* aMacIOSurface,
                            const IntSize& aSize,
                            const gfx::Rect& aLeftEyeRect,
                            const gfx::Rect& aRightEyeRect) override;
--- a/gfx/vr/gfxVRPuppet.cpp
+++ b/gfx/vr/gfxVRPuppet.cpp
@@ -161,84 +161,82 @@ void
 VRDisplayPuppet::StartPresentation()
 {
   if (mIsPresenting) {
     return;
   }
   mIsPresenting = true;
 
 #if defined(XP_WIN)
-  if (!mDevice) {
-    mDevice = gfx::DeviceManagerDx::Get()->GetCompositorDevice();
-    if (!mDevice) {
-      NS_WARNING("Failed to get a D3D11Device for Puppet");
-      return;
-    }
+  ID3D11Device* device = GetDevice();
+  if (!device) {
+    NS_WARNING("Unable to get a ID3D11Device for VRDisplayPuppet");
+    return;
   }
 
-  mDevice->GetImmediateContext(getter_AddRefs(mContext));
+  device->GetImmediateContext(getter_AddRefs(mContext));
   if (!mContext) {
     NS_WARNING("Failed to get immediate context for Puppet");
     return;
   }
 
-  if (FAILED(mDevice->CreateVertexShader(sLayerQuadVS.mData,
+  if (FAILED(device->CreateVertexShader(sLayerQuadVS.mData,
                       sLayerQuadVS.mLength, nullptr, &mQuadVS))) {
     NS_WARNING("Failed to create vertex shader for Puppet");
     return;
   }
 
-  if (FAILED(mDevice->CreatePixelShader(sRGBShader.mData,
+  if (FAILED(device->CreatePixelShader(sRGBShader.mData,
                       sRGBShader.mLength, nullptr, &mQuadPS))) {
     NS_WARNING("Failed to create pixel shader for Puppet");
     return;
   }
 
   CD3D11_BUFFER_DESC cBufferDesc(sizeof(layers::VertexShaderConstants),
                                  D3D11_BIND_CONSTANT_BUFFER,
                                  D3D11_USAGE_DYNAMIC,
                                  D3D11_CPU_ACCESS_WRITE);
 
-  if (FAILED(mDevice->CreateBuffer(&cBufferDesc, nullptr, getter_AddRefs(mVSConstantBuffer)))) {
+  if (FAILED(device->CreateBuffer(&cBufferDesc, nullptr, getter_AddRefs(mVSConstantBuffer)))) {
     NS_WARNING("Failed to vertex shader constant buffer for Puppet");
     return;
   }
 
   cBufferDesc.ByteWidth = sizeof(layers::PixelShaderConstants);
-  if (FAILED(mDevice->CreateBuffer(&cBufferDesc, nullptr, getter_AddRefs(mPSConstantBuffer)))) {
+  if (FAILED(device->CreateBuffer(&cBufferDesc, nullptr, getter_AddRefs(mPSConstantBuffer)))) {
     NS_WARNING("Failed to pixel shader constant buffer for Puppet");
     return;
   }
 
   CD3D11_SAMPLER_DESC samplerDesc(D3D11_DEFAULT);
-  if (FAILED(mDevice->CreateSamplerState(&samplerDesc, getter_AddRefs(mLinearSamplerState)))) {
+  if (FAILED(device->CreateSamplerState(&samplerDesc, getter_AddRefs(mLinearSamplerState)))) {
     NS_WARNING("Failed to create sampler state for Puppet");
     return;
   }
 
   D3D11_INPUT_ELEMENT_DESC layout[] =
   {
     { "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
   };
 
-  if (FAILED(mDevice->CreateInputLayout(layout,
-                                        sizeof(layout) / sizeof(D3D11_INPUT_ELEMENT_DESC),
-                                        sLayerQuadVS.mData,
-                                        sLayerQuadVS.mLength,
-                                        getter_AddRefs(mInputLayout)))) {
+  if (FAILED(device->CreateInputLayout(layout,
+                                       sizeof(layout) / sizeof(D3D11_INPUT_ELEMENT_DESC),
+                                       sLayerQuadVS.mData,
+                                       sLayerQuadVS.mLength,
+                                       getter_AddRefs(mInputLayout)))) {
     NS_WARNING("Failed to create input layout for Puppet");
     return;
   }
 
   Vertex vertices[] = { { { 0.0, 0.0 } },{ { 1.0, 0.0 } },{ { 0.0, 1.0 } },{ { 1.0, 1.0 } } };
   CD3D11_BUFFER_DESC bufferDesc(sizeof(vertices), D3D11_BIND_VERTEX_BUFFER);
   D3D11_SUBRESOURCE_DATA data;
   data.pSysMem = (void*)vertices;
 
-  if (FAILED(mDevice->CreateBuffer(&bufferDesc, &data, getter_AddRefs(mVertexBuffer)))) {
+  if (FAILED(device->CreateBuffer(&bufferDesc, &data, getter_AddRefs(mVertexBuffer)))) {
     NS_WARNING("Failed to create vertex buffer for Puppet");
     return;
   }
 
   memset(&mVSConstants, 0, sizeof(mVSConstants));
   memset(&mPSConstants, 0, sizeof(mPSConstants));
 #endif // XP_WIN
 }
@@ -279,45 +277,50 @@ VRDisplayPuppet::UpdateConstantBuffers()
   ID3D11Buffer *buffer = mVSConstantBuffer;
   mContext->VSSetConstantBuffers(0, 1, &buffer);
   buffer = mPSConstantBuffer;
   mContext->PSSetConstantBuffers(0, 1, &buffer);
   return true;
 }
 
 bool
-VRDisplayPuppet::SubmitFrame(TextureSourceD3D11* aSource,
+VRDisplayPuppet::SubmitFrame(ID3D11Texture2D* aSource,
                              const IntSize& aSize,
                              const gfx::Rect& aLeftEyeRect,
                              const gfx::Rect& aRightEyeRect)
 {
   if (!mIsPresenting) {
     return false;
   }
 
   VRManager *vm = VRManager::Get();
   MOZ_ASSERT(vm);
 
+  ID3D11Device* device = GetDevice();
+  if (!device) {
+    NS_WARNING("Unable to get a ID3D11Device for VRDisplayPuppet");
+    return false;
+  }
+
   switch (gfxPrefs::VRPuppetSubmitFrame()) {
     case 0:
       // The VR frame is not displayed.
       break;
     case 1:
     {
       // The frames are submitted to VR compositor are decoded
       // into a base64Image and dispatched to the DOM side.
       D3D11_TEXTURE2D_DESC desc;
-      ID3D11Texture2D* texture = aSource->GetD3D11Texture();
-      texture->GetDesc(&desc);
+      aSource->GetDesc(&desc);
       MOZ_ASSERT(desc.Format == DXGI_FORMAT_B8G8R8A8_UNORM,
                  "Only support B8G8R8A8_UNORM format.");
       // Map the staging resource
       ID3D11Texture2D* mappedTexture = nullptr;
       D3D11_MAPPED_SUBRESOURCE mapInfo;
-      HRESULT hr = mContext->Map(texture,
+      HRESULT hr = mContext->Map(aSource,
                                  0,  // Subsource
                                  D3D11_MAP_READ,
                                  0,  // MapFlags
                                  &mapInfo);
 
       if (FAILED(hr)) {
         // If we can't map this texture, copy it to a staging resource.
         if (hr == E_INVALIDARG) {
@@ -329,39 +332,39 @@ VRDisplayPuppet::SubmitFrame(TextureSour
           desc2.Format = desc.Format;
           desc2.SampleDesc = desc.SampleDesc;
           desc2.Usage = D3D11_USAGE_STAGING;
           desc2.BindFlags = 0;
           desc2.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
           desc2.MiscFlags = 0;
 
           ID3D11Texture2D* stagingTexture = nullptr;
-          hr = mDevice->CreateTexture2D(&desc2, nullptr, &stagingTexture);
+          hr = device->CreateTexture2D(&desc2, nullptr, &stagingTexture);
           if (FAILED(hr)) {
             MOZ_ASSERT(false, "Failed to create a staging texture");
             return false;
           }
           // Copy the texture to a staging resource
-          mContext->CopyResource(stagingTexture, texture);
+          mContext->CopyResource(stagingTexture, aSource);
           // Map the staging resource
           hr = mContext->Map(stagingTexture,
                              0,  // Subsource
                              D3D11_MAP_READ,
                              0,  // MapFlags
                              &mapInfo);
           if (FAILED(hr)) {
             MOZ_ASSERT(false, "Failed to map staging texture");
           }
           mappedTexture = stagingTexture;
         } else {
           MOZ_ASSERT(false, "Failed to map staging texture");
           return false;
         }
       } else {
-        mappedTexture = texture;
+        mappedTexture = aSource;
       }
       // Ideally, we should convert the srcData to a PNG image and decode it
       // to a Base64 string here, but the GPU process does not have the privilege to
       // access the image library. So, we have to convert the RAW image data
       // to a base64 string and forward it to let the content process to
       // do the image conversion.
       char* srcData = static_cast<char*>(mapInfo.pData);
       VRSubmitFrameResultInfo result;
@@ -426,22 +429,25 @@ VRDisplayPuppet::SubmitFrame(TextureSour
       mContext->IASetVertexBuffers(0, 1, &vbuffer, &vsize, &voffset);
       mContext->IASetIndexBuffer(nullptr, DXGI_FORMAT_R16_UINT, 0);
       mContext->IASetInputLayout(mInputLayout);
       mContext->RSSetViewports(1, &viewport);
       mContext->RSSetScissorRects(1, &scissor);
       mContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
       mContext->VSSetShader(mQuadVS, nullptr, 0);
       mContext->PSSetShader(mQuadPS, nullptr, 0);
-      ID3D11ShaderResourceView* srView = aSource->GetShaderResourceView();
-      if (!srView) {
-        NS_WARNING("Failed to get SRV for Puppet");
-        return false;
+
+      RefPtr<ID3D11ShaderResourceView> srView;
+      HRESULT hr = device->CreateShaderResourceView(aSource, nullptr, getter_AddRefs(srView));
+      if (FAILED(hr) || !srView) {
+        gfxWarning() << "Could not create shader resource view for Puppet: " << hexa(hr);
+        return nullptr;
       }
-      mContext->PSSetShaderResources(0 /* 0 == TexSlot::RGB */, 1, &srView);
+      ID3D11ShaderResourceView* viewPtr = srView.get();
+      mContext->PSSetShaderResources(0 /* 0 == TexSlot::RGB */, 1, &viewPtr);
       // XXX Use Constant from TexSlot in CompositorD3D11.cpp?
 
       ID3D11SamplerState *sampler = mLinearSamplerState;
       mContext->PSSetSamplers(0, 1, &sampler);
 
       if (!UpdateConstantBuffers()) {
         NS_WARNING("Failed to update constant buffers for Puppet");
         return false;
--- a/gfx/vr/gfxVRPuppet.h
+++ b/gfx/vr/gfxVRPuppet.h
@@ -27,17 +27,17 @@ public:
   void SetSensorState(const VRHMDSensorState& aSensorState);
   void ZeroSensor() override;
 
 protected:
   virtual VRHMDSensorState GetSensorState() override;
   virtual void StartPresentation() override;
   virtual void StopPresentation() override;
 #if defined(XP_WIN)
-  virtual bool SubmitFrame(mozilla::layers::TextureSourceD3D11* aSource,
+  virtual bool SubmitFrame(ID3D11Texture2D* aSource,
                            const IntSize& aSize,
                            const gfx::Rect& aLeftEyeRect,
                            const gfx::Rect& aRightEyeRect) override;
 #elif defined(XP_MACOSX)
   virtual bool SubmitFrame(MacIOSurface* aMacIOSurface,
                            const IntSize& aSize,
                            const gfx::Rect& aLeftEyeRect,
                            const gfx::Rect& aRightEyeRect) override;
@@ -51,17 +51,16 @@ protected:
   void Destroy();
 
   bool mIsPresenting;
 
 private:
 #if defined(XP_WIN)
   bool UpdateConstantBuffers();
 
-  RefPtr<ID3D11Device> mDevice;
   RefPtr<ID3D11DeviceContext> mContext;
   ID3D11VertexShader* mQuadVS;
   ID3D11PixelShader* mQuadPS;
   RefPtr<ID3D11SamplerState> mLinearSamplerState;
   layers::VertexShaderConstants mVSConstants;
   layers::PixelShaderConstants mPSConstants;
   RefPtr<ID3D11Buffer> mVSConstantBuffer;
   RefPtr<ID3D11Buffer> mPSConstantBuffer;
--- a/gfx/vr/ipc/PVRLayer.ipdl
+++ b/gfx/vr/ipc/PVRLayer.ipdl
@@ -1,27 +1,27 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * vim: sw=2 ts=8 et :
  */
 /* 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 LayersSurfaces;
 include protocol PVRManager;
-include protocol PTexture;
 
 namespace mozilla {
 namespace gfx {
 
 async protocol PVRLayer
 {
   manager PVRManager;
 
 parent:
-  async SubmitFrame(PTexture aTexture, uint64_t aFrameId);
+  async SubmitFrame(SurfaceDescriptor aTexture, uint64_t aFrameId);
   async Destroy();
 
 child:
   async __delete__();
 };
 
 } // gfx
 } // mozilla
--- a/gfx/vr/ipc/PVRManager.ipdl
+++ b/gfx/vr/ipc/PVRManager.ipdl
@@ -1,17 +1,16 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * vim: sw=2 ts=8 et :
  */
 /* 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 LayersSurfaces;
-include protocol PTexture;
 include protocol PVRLayer;
 include LayersMessages;
 include GamepadEventTypes;
 
 include "VRMessageUtils.h";
 
 using struct mozilla::gfx::VRFieldOfView from "gfxVR.h";
 using struct mozilla::gfx::VRDisplayInfo from "gfxVR.h";
@@ -28,23 +27,19 @@ namespace gfx {
 
 /**
  * The PVRManager protocol is used to enable communication of VR display
  * enumeration and sensor state between the compositor thread and
  * content threads/processes.
  */
 sync protocol PVRManager
 {
-  manages PTexture;
   manages PVRLayer;
 
 parent:
-  async PTexture(SurfaceDescriptor aSharedData, LayersBackend aBackend,
-                 TextureFlags aTextureFlags, uint64_t aSerial);
-
   async PVRLayer(uint32_t aDisplayID, float aLeftEyeX, float aLeftEyeY,
                  float aLeftEyeWidth, float aLeftEyeHeight, float aRightEyeX,
                  float aRightEyeY, float aRightEyeWidth, float aRightEyeHeight,
                  uint32_t aGroup);
 
   // (Re)Enumerate VR Displays.  An updated list of VR displays will be returned
   // asynchronously to children via UpdateDisplayInfo.
   async RefreshDisplays();
--- a/gfx/vr/ipc/VRLayerChild.cpp
+++ b/gfx/vr/ipc/VRLayerChild.cpp
@@ -6,91 +6,101 @@
 #include "VRLayerChild.h"
 #include "GLScreenBuffer.h"
 #include "mozilla/layers/TextureClientSharedSurface.h"
 #include "SharedSurface.h"                // for SharedSurface
 #include "SharedSurfaceGL.h"              // for SharedSurface
 #include "mozilla/layers/LayersMessages.h" // for TimedTexture
 #include "nsICanvasRenderingContextInternal.h"
 #include "mozilla/dom/HTMLCanvasElement.h"
+#include "mozilla/layers/SyncObject.h" // for SyncObjectClient
 
 namespace mozilla {
 namespace gfx {
 
 VRLayerChild::VRLayerChild()
   : mCanvasElement(nullptr)
-  , mShSurfClient(nullptr)
-  , mFront(nullptr)
   , mIPCOpen(false)
+  , mLastSubmittedFrameId(0)
 {
   MOZ_COUNT_CTOR(VRLayerChild);
 }
 
 VRLayerChild::~VRLayerChild()
 {
-  if (mCanvasElement) {
-    mCanvasElement->StopVRPresentation();
-  }
-
   ClearSurfaces();
 
   MOZ_COUNT_DTOR(VRLayerChild);
 }
 
 void
 VRLayerChild::Initialize(dom::HTMLCanvasElement* aCanvasElement)
 {
   MOZ_ASSERT(aCanvasElement);
   mCanvasElement = aCanvasElement;
-  mCanvasElement->StartVRPresentation();
 
   VRManagerChild *vrmc = VRManagerChild::Get();
   vrmc->RunFrameRequestCallbacks();
 }
 
 void
 VRLayerChild::SubmitFrame(uint64_t aFrameId)
 {
-  if (!mCanvasElement) {
+  // aFrameId will not increment unless the previuosly submitted
+  // frame was received by the VR thread and submitted to the VR
+  // compositor.  We early-exit here in the event that SubmitFrame
+  // was called twice for the same aFrameId.
+  if (!mCanvasElement || aFrameId == mLastSubmittedFrameId) {
     return;
   }
+  mLastSubmittedFrameId = aFrameId;
+
+  // Keep the SharedSurfaceTextureClient alive long enough for
+  // 1 extra frame, accomodating overlapped asynchronous rendering.
+  mLastFrameTexture = mThisFrameTexture;
+
+  mThisFrameTexture = mCanvasElement->GetVRFrame();
+  if (!mThisFrameTexture) {
+    return;
+  }
+  VRManagerChild* vrmc = VRManagerChild::Get();
+  mThisFrameTexture->SyncWithObject(vrmc->GetSyncObject());
+  if (!gfxPlatform::GetPlatform()->DidRenderingDeviceReset()) {
+    if (vrmc->GetSyncObject() &&
+      vrmc->GetSyncObject()->IsSyncObjectValid()) {
+      vrmc->GetSyncObject()->Synchronize();
+    }
+  }
 
-  mShSurfClient = mCanvasElement->GetVRFrame();
-  if (!mShSurfClient) {
-    return;
-  }
-
-  gl::SharedSurface* surf = mShSurfClient->Surf();
+  gl::SharedSurface* surf = mThisFrameTexture->Surf();
   if (surf->mType == gl::SharedSurfaceType::Basic) {
     gfxCriticalError() << "SharedSurfaceType::Basic not supported for WebVR";
     return;
   }
 
-  mFront = mShSurfClient;
-  mShSurfClient = nullptr;
+  layers::SurfaceDescriptor desc;
+  if (!surf->ToSurfaceDescriptor(&desc)) {
+    gfxCriticalError() << "SharedSurface::ToSurfaceDescriptor failed in VRLayerChild::SubmitFrame";
+    return;
+  }
 
-  mFront->SetAddedToCompositableClient();
-  VRManagerChild* vrmc = VRManagerChild::Get();
-  mFront->SyncWithObject(vrmc->GetSyncObject());
-  MOZ_ALWAYS_TRUE(mFront->InitIPDLActor(vrmc));
-
-  SendSubmitFrame(mFront->GetIPDLActor(), aFrameId);
+  SendSubmitFrame(desc, aFrameId);
 }
 
 bool
 VRLayerChild::IsIPCOpen()
 {
   return mIPCOpen;
 }
 
 void
 VRLayerChild::ClearSurfaces()
 {
-  mFront = nullptr;
-  mShSurfClient = nullptr;
+  mThisFrameTexture = nullptr;
+  mLastFrameTexture = nullptr;
 }
 
 void
 VRLayerChild::ActorDestroy(ActorDestroyReason aWhy)
 {
   mIPCOpen = false;
 }
 
--- a/gfx/vr/ipc/VRLayerChild.h
+++ b/gfx/vr/ipc/VRLayerChild.h
@@ -41,24 +41,27 @@ public:
 
 private:
   VRLayerChild();
   virtual ~VRLayerChild();
   void ClearSurfaces();
   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
 
   RefPtr<dom::HTMLCanvasElement> mCanvasElement;
-  RefPtr<layers::SharedSurfaceTextureClient> mShSurfClient;
-  RefPtr<layers::TextureClient> mFront;
   bool mIPCOpen;
 
   // AddIPDLReference and ReleaseIPDLReference are only to be called by CreateIPDLActor
   // and DestroyIPDLActor, respectively. We intentionally make them private to prevent misuse.
   // The purpose of these methods is to be aware of when the IPC system around this
   // actor goes down: mIPCOpen is then set to false.
   void AddIPDLReference();
   void ReleaseIPDLReference();
+
+  RefPtr<layers::SharedSurfaceTextureClient> mThisFrameTexture;
+  RefPtr<layers::SharedSurfaceTextureClient> mLastFrameTexture;
+
+  uint64_t mLastSubmittedFrameId;
 };
 
 } // namespace gfx
 } // namespace mozilla
 
 #endif
--- a/gfx/vr/ipc/VRLayerParent.cpp
+++ b/gfx/vr/ipc/VRLayerParent.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; 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 "VRLayerParent.h"
 #include "mozilla/Unused.h"
+#include "VRDisplayHost.h"
 
 namespace mozilla {
 namespace gfx {
 
 VRLayerParent::VRLayerParent(uint32_t aVRDisplayID, const Rect& aLeftEyeRect, const Rect& aRightEyeRect, const uint32_t aGroup)
   : mIPCOpen(true)
   , mVRDisplayID(aVRDisplayID)
   , mLeftEyeRect(aLeftEyeRect)
@@ -52,22 +53,26 @@ VRLayerParent::Destroy()
   }
 
   if (mIPCOpen) {
     Unused << PVRLayerParent::Send__delete__(this);
   }
 }
 
 mozilla::ipc::IPCResult
-VRLayerParent::RecvSubmitFrame(PTextureParent* texture,
+VRLayerParent::RecvSubmitFrame(const layers::SurfaceDescriptor &aTexture,
                                const uint64_t& aFrameId)
 {
   if (mVRDisplayID) {
     VRManager* vm = VRManager::Get();
-    vm->SubmitFrame(this, texture, aFrameId, mLeftEyeRect, mRightEyeRect);
+    RefPtr<VRDisplayHost> display = vm->GetDisplay(mVRDisplayID);
+    if (display) {
+      display->SubmitFrame(this, aTexture, aFrameId,
+                           mLeftEyeRect, mRightEyeRect);
+    }
   }
 
   return IPC_OK();
 }
 
 
 } // namespace gfx
 } // namespace mozilla
--- a/gfx/vr/ipc/VRLayerParent.h
+++ b/gfx/vr/ipc/VRLayerParent.h
@@ -16,31 +16,30 @@ namespace mozilla {
 namespace gfx {
 
 class VRLayerParent : public PVRLayerParent {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRLayerParent)
 
 public:
   VRLayerParent(uint32_t aVRDisplayID, const Rect& aLeftEyeRect,
                 const Rect& aRightEyeRect, const uint32_t aGroup);
-  virtual mozilla::ipc::IPCResult RecvSubmitFrame(PTextureParent* texture,
+  virtual mozilla::ipc::IPCResult RecvSubmitFrame(const layers::SurfaceDescriptor &aTexture,
                                                   const uint64_t& aFrameId) override;
   virtual mozilla::ipc::IPCResult RecvDestroy() override;
   uint32_t GetDisplayID() const { return mVRDisplayID; }
   uint32_t GetGroup() const { return mGroup; }
 protected:
   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
 
   virtual ~VRLayerParent();
   void Destroy();
 
   bool mIPCOpen;
 
   uint32_t mVRDisplayID;
-  gfx::IntSize mSize;
   gfx::Rect mLeftEyeRect;
   gfx::Rect mRightEyeRect;
   uint32_t mGroup;
 };
 
 } // namespace gfx
 } // namespace mozilla
 
--- a/gfx/vr/ipc/VRManagerChild.cpp
+++ b/gfx/vr/ipc/VRManagerChild.cpp
@@ -34,18 +34,17 @@ namespace gfx {
 static StaticRefPtr<VRManagerChild> sVRManagerChildSingleton;
 static StaticRefPtr<VRManagerParent> sVRManagerParentSingleton;
 
 void ReleaseVRManagerParentSingleton() {
   sVRManagerParentSingleton = nullptr;
 }
 
 VRManagerChild::VRManagerChild()
-  : TextureForwarder()
-  , mDisplaysInitialized(false)
+  : mDisplaysInitialized(false)
   , mMessageLoop(MessageLoop::current())
   , mFrameRequestCallbackCounter(0)
   , mBackend(layers::LayersBackend::LAYERS_NONE)
   , mPromiseID(0)
   , mVRMockDisplay(nullptr)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -162,31 +161,16 @@ VRManagerChild::Destroy()
   RefPtr<VRManagerChild> selfRef = this;
 
   // The DeferredDestroyVRManager task takes ownership of
   // the VRManagerChild and will release it when it runs.
   MessageLoop::current()->PostTask(
              NewRunnableFunction(DeferredDestroy, selfRef));
 }
 
-layers::PTextureChild*
-VRManagerChild::AllocPTextureChild(const SurfaceDescriptor&,
-                                   const LayersBackend&,
-                                   const TextureFlags&,
-                                   const uint64_t&)
-{
-  return TextureClient::CreateIPDLActor();
-}
-
-bool
-VRManagerChild::DeallocPTextureChild(PTextureChild* actor)
-{
-  return TextureClient::DestroyIPDLActor(actor);
-}
-
 PVRLayerChild*
 VRManagerChild::AllocPVRLayerChild(const uint32_t& aDisplayID,
                                    const float& aLeftEyeX,
                                    const float& aLeftEyeY,
                                    const float& aLeftEyeWidth,
                                    const float& aLeftEyeHeight,
                                    const float& aRightEyeX,
                                    const float& aRightEyeY,
@@ -337,69 +321,26 @@ VRManagerChild::RecvParentAsyncMessages(
       default:
         NS_ERROR("unknown AsyncParentMessageData type");
         return IPC_FAIL_NO_REASON(this);
     }
   }
   return IPC_OK();
 }
 
-PTextureChild*
-VRManagerChild::CreateTexture(const SurfaceDescriptor& aSharedData,
-                              LayersBackend aLayersBackend,
-                              TextureFlags aFlags,
-                              uint64_t aSerial,
-                              wr::MaybeExternalImageId& aExternalImageId,
-                              nsIEventTarget* aTarget)
-{
-  return SendPTextureConstructor(aSharedData, aLayersBackend, aFlags, aSerial);
-}
-
-void
-VRManagerChild::CancelWaitForRecycle(uint64_t aTextureId)
-{
-  RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
-  if (!client) {
-    return;
-  }
-  mTexturesWaitingRecycled.Remove(aTextureId);
-}
-
 void
 VRManagerChild::NotifyNotUsed(uint64_t aTextureId, uint64_t aFwdTransactionId)
 {
   RefPtr<TextureClient> client = mTexturesWaitingRecycled.Get(aTextureId);
   if (!client) {
     return;
   }
   mTexturesWaitingRecycled.Remove(aTextureId);
 }
 
-bool
-VRManagerChild::AllocShmem(size_t aSize,
-                           ipc::SharedMemory::SharedMemoryType aType,
-                           ipc::Shmem* aShmem)
-{
-  return PVRManagerChild::AllocShmem(aSize, aType, aShmem);
-}
-
-bool
-VRManagerChild::AllocUnsafeShmem(size_t aSize,
-                                 ipc::SharedMemory::SharedMemoryType aType,
-                                 ipc::Shmem* aShmem)
-{
-  return PVRManagerChild::AllocUnsafeShmem(aSize, aType, aShmem);
-}
-
-bool
-VRManagerChild::DeallocShmem(ipc::Shmem& aShmem)
-{
-  return PVRManagerChild::DeallocShmem(aShmem);
-}
-
 PVRLayerChild*
 VRManagerChild::CreateVRLayer(uint32_t aDisplayID,
                               const Rect& aLeftEyeRect,
                               const Rect& aRightEyeRect,
                               nsIEventTarget* aTarget,
                               uint32_t aGroup)
 {
   PVRLayerChild* vrLayerChild = AllocPVRLayerChild(aDisplayID, aLeftEyeRect.x,
--- a/gfx/vr/ipc/VRManagerChild.h
+++ b/gfx/vr/ipc/VRManagerChild.h
@@ -28,24 +28,19 @@ namespace layers {
 class SyncObjectClient;
 class TextureClient;
 }
 namespace gfx {
 class VRLayerChild;
 class VRDisplayClient;
 
 class VRManagerChild : public PVRManagerChild
-                     , public layers::TextureForwarder
-                     , public layers::KnowsCompositor
 {
 public:
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRManagerChild, override);
-
-  TextureForwarder* GetTextureForwarder() override { return this; }
-  LayersIPCActor* GetLayersIPCActor() override { return this; }
+  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRManagerChild);
 
   static VRManagerChild* Get();
 
   // Indicate that an observer wants to receive VR events.
   void AddListener(dom::VREventObserver* aObserver);
   // Indicate that an observer should no longer receive VR events.
   void RemoveListener(dom::VREventObserver* aObserver);
 
@@ -59,38 +54,26 @@ public:
   static void InitSameProcess();
   static void InitWithGPUProcess(Endpoint<PVRManagerChild>&& aEndpoint);
   static bool InitForContent(Endpoint<PVRManagerChild>&& aEndpoint);
   static bool ReinitForContent(Endpoint<PVRManagerChild>&& aEndpoint);
   static void ShutDown();
 
   static bool IsCreated();
 
-  virtual PTextureChild* CreateTexture(
-    const SurfaceDescriptor& aSharedData,
-    layers::LayersBackend aLayersBackend,
-    TextureFlags aFlags,
-    uint64_t aSerial,
-    wr::MaybeExternalImageId& aExternalImageId,
-    nsIEventTarget* aTarget = nullptr) override;
-  virtual void CancelWaitForRecycle(uint64_t aTextureId) override;
-
   PVRLayerChild* CreateVRLayer(uint32_t aDisplayID,
                                const Rect& aLeftEyeRect,
                                const Rect& aRightEyeRect,
                                nsIEventTarget* aTarget,
                                uint32_t aGroup);
 
   static void IdentifyTextureHost(const layers::TextureFactoryIdentifier& aIdentifier);
   layers::LayersBackend GetBackendType() const;
   layers::SyncObjectClient* GetSyncObject() { return mSyncObject; }
 
-  virtual MessageLoop* GetMessageLoop() const override { return mMessageLoop; }
-  virtual base::ProcessId GetParentPid() const override { return OtherPid(); }
-
   nsresult ScheduleFrameRequestCallback(mozilla::dom::FrameRequestCallback& aCallback,
     int32_t *aHandle);
   void CancelFrameRequestCallback(int32_t aHandle);
   void RunFrameRequestCallbacks();
 
   void UpdateDisplayInfo(nsTArray<VRDisplayInfo>& aDisplayUpdates);
   void FireDOMVRDisplayMountedEvent(uint32_t aDisplayID);
   void FireDOMVRDisplayUnmountedEvent(uint32_t aDisplayID);
@@ -101,22 +84,16 @@ public:
   virtual void HandleFatalError(const char* aName, const char* aMsg) const override;
 
 protected:
   explicit VRManagerChild();
   ~VRManagerChild();
   void Destroy();
   static void DeferredDestroy(RefPtr<VRManagerChild> aVRManagerChild);
 
-  virtual PTextureChild* AllocPTextureChild(const SurfaceDescriptor& aSharedData,
-                                            const layers::LayersBackend& aLayersBackend,
-                                            const TextureFlags& aFlags,
-                                            const uint64_t& aSerial) override;
-  virtual bool DeallocPTextureChild(PTextureChild* actor) override;
-
   virtual PVRLayerChild* AllocPVRLayerChild(const uint32_t& aDisplayID,
                                             const float& aLeftEyeX,
                                             const float& aLeftEyeY,
                                             const float& aLeftEyeWidth,
                                             const float& aLeftEyeHeight,
                                             const float& aRightEyeX,
                                             const float& aRightEyeY,
                                             const float& aRightEyeWidth,
@@ -133,36 +110,20 @@ protected:
   virtual mozilla::ipc::IPCResult RecvReplyGamepadVibrateHaptic(const uint32_t& aPromiseID) override;
 
   virtual mozilla::ipc::IPCResult RecvReplyCreateVRServiceTestDisplay(const nsCString& aID,
                                                                       const uint32_t& aPromiseID,
                                                                       const uint32_t& aDeviceID) override;
   virtual mozilla::ipc::IPCResult RecvReplyCreateVRServiceTestController(const nsCString& aID,
                                                                          const uint32_t& aPromiseID,
                                                                          const uint32_t& aDeviceID) override;
-
-  // ShmemAllocator
-
-  virtual bool AllocShmem(size_t aSize,
-                          ipc::SharedMemory::SharedMemoryType aType,
-                          ipc::Shmem* aShmem) override;
-
-  virtual bool AllocUnsafeShmem(size_t aSize,
-                                ipc::SharedMemory::SharedMemoryType aType,
-                                ipc::Shmem* aShmem) override;
-
-  virtual bool DeallocShmem(ipc::Shmem& aShmem) override;
-
-  virtual bool IsSameProcess() const override
+  bool IsSameProcess() const
   {
     return OtherPid() == base::GetCurrentProcId();
   }
-
-  friend class layers::CompositorBridgeChild;
-
 private:
 
   void FireDOMVRDisplayMountedEventInternal(uint32_t aDisplayID);
   void FireDOMVRDisplayUnmountedEventInternal(uint32_t aDisplayID);
   void FireDOMVRDisplayConnectEventInternal(uint32_t aDisplayID);
   void FireDOMVRDisplayDisconnectEventInternal(uint32_t aDisplayID);
   void FireDOMVRDisplayPresentChangeEventInternal(uint32_t aDisplayID);
   /**
--- a/gfx/vr/ipc/VRManagerParent.cpp
+++ b/gfx/vr/ipc/VRManagerParent.cpp
@@ -16,18 +16,17 @@
 #include "VRManager.h"
 #include "gfxVRPuppet.h"
 
 namespace mozilla {
 using namespace layers;
 namespace gfx {
 
 VRManagerParent::VRManagerParent(ProcessId aChildProcessId, bool aIsContentChild)
-  : HostIPCAllocator()
-  , mDisplayTestID(0)
+  : mDisplayTestID(0)
   , mControllerTestID(0)
   , mHaveEventListener(false)
   , mHaveControllerListener(false)
   , mIsContentChild(aIsContentChild)
 {
   MOZ_COUNT_CTOR(VRManagerParent);
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -36,31 +35,16 @@ VRManagerParent::VRManagerParent(Process
 
 VRManagerParent::~VRManagerParent()
 {
   MOZ_ASSERT(!mVRManagerHolder);
 
   MOZ_COUNT_DTOR(VRManagerParent);
 }
 
-PTextureParent*
-VRManagerParent::AllocPTextureParent(const SurfaceDescriptor& aSharedData,
-                                     const LayersBackend& aLayersBackend,
-                                     const TextureFlags& aFlags,
-                                     const uint64_t& aSerial)
-{
-  return layers::TextureHost::CreateIPDLActor(this, aSharedData, aLayersBackend, aFlags, aSerial, Nothing());
-}
-
-bool
-VRManagerParent::DeallocPTextureParent(PTextureParent* actor)
-{
-  return layers::TextureHost::DestroyIPDLActor(actor);
-}
-
 PVRLayerParent*
 VRManagerParent::AllocPVRLayerParent(const uint32_t& aDisplayID,
                                      const float& aLeftEyeX,
                                      const float& aLeftEyeY,
                                      const float& aLeftEyeWidth,
                                      const float& aLeftEyeHeight,
                                      const float& aRightEyeX,
                                      const float& aRightEyeY,
@@ -84,62 +68,22 @@ VRManagerParent::AllocPVRLayerParent(con
 bool
 VRManagerParent::DeallocPVRLayerParent(PVRLayerParent* actor)
 {
   delete actor;
   return true;
 }
 
 bool
-VRManagerParent::AllocShmem(size_t aSize,
-  ipc::SharedMemory::SharedMemoryType aType,
-  ipc::Shmem* aShmem)
-{
-  return PVRManagerParent::AllocShmem(aSize, aType, aShmem);
-}
-
-bool
-VRManagerParent::AllocUnsafeShmem(size_t aSize,
-  ipc::SharedMemory::SharedMemoryType aType,
-  ipc::Shmem* aShmem)
-{
-  return PVRManagerParent::AllocUnsafeShmem(aSize, aType, aShmem);
-}
-
-void
-VRManagerParent::DeallocShmem(ipc::Shmem& aShmem)
-{
-  PVRManagerParent::DeallocShmem(aShmem);
-}
-
-bool
 VRManagerParent::IsSameProcess() const
 {
   return OtherPid() == base::GetCurrentProcId();
 }
 
 void
-VRManagerParent::NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId)
-{
-  MOZ_ASSERT_UNREACHABLE("unexpected to be called");
-}
-
-void
-VRManagerParent::SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage)
-{
-  MOZ_ASSERT_UNREACHABLE("unexpected to be called");
-}
-
-base::ProcessId
-VRManagerParent::GetChildProcessId()
-{
-  return OtherPid();
-}
-
-void
 VRManagerParent::RegisterWithManager()
 {
   VRManager* vm = VRManager::Get();
   vm->AddVRManagerParent(this);
   mVRManagerHolder = vm;
 }
 
 void
--- a/gfx/vr/ipc/VRManagerParent.h
+++ b/gfx/vr/ipc/VRManagerParent.h
@@ -23,60 +23,34 @@ namespace gfx {
 class VRManager;
 
 namespace impl {
 class VRDisplayPuppet;
 class VRControllerPuppet;
 } // namespace impl
 
 class VRManagerParent final : public PVRManagerParent
-                            , public HostIPCAllocator
-                            , public ShmemAllocator
 {
+  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VRManagerParent);
 public:
   explicit VRManagerParent(ProcessId aChildProcessId, bool aIsContentChild);
 
   static VRManagerParent* CreateSameProcess();
   static bool CreateForGPUProcess(Endpoint<PVRManagerParent>&& aEndpoint);
   static bool CreateForContent(Endpoint<PVRManagerParent>&& aEndpoint);
 
-  virtual base::ProcessId GetChildProcessId() override;
-
-  // ShmemAllocator
-
-  virtual ShmemAllocator* AsShmemAllocator() override { return this; }
-
-  virtual bool AllocShmem(size_t aSize,
-    ipc::SharedMemory::SharedMemoryType aType,
-    ipc::Shmem* aShmem) override;
-
-  virtual bool AllocUnsafeShmem(size_t aSize,
-    ipc::SharedMemory::SharedMemoryType aType,
-    ipc::Shmem* aShmem) override;
-
-  virtual void DeallocShmem(ipc::Shmem& aShmem) override;
-
-  virtual bool IsSameProcess() const override;
+  bool IsSameProcess() const;
   bool HaveEventListener();
   bool HaveControllerListener();
-
-  virtual void NotifyNotUsed(PTextureParent* aTexture, uint64_t aTransactionId) override;
-  virtual void SendAsyncMessage(const InfallibleTArray<AsyncParentMessageData>& aMessage) override;
   bool SendGamepadUpdate(const GamepadChangeEvent& aGamepadEvent);
   bool SendReplyGamepadVibrateHaptic(const uint32_t& aPromiseID);
 
 protected:
   ~VRManagerParent();
 
-  virtual PTextureParent* AllocPTextureParent(const SurfaceDescriptor& aSharedData,
-                                              const LayersBackend& aLayersBackend,
-                                              const TextureFlags& aFlags,
-                                              const uint64_t& aSerial) override;
-  virtual bool DeallocPTextureParent(PTextureParent* actor) override;
-
   virtual PVRLayerParent* AllocPVRLayerParent(const uint32_t& aDisplayID,
                                               const float& aLeftEyeX,
                                               const float& aLeftEyeY,
                                               const float& aLeftEyeWidth,
                                               const float& aLeftEyeHeight,
                                               const float& aRightEyeX,
                                               const float& aRightEyeY,
                                               const float& aRightEyeWidth,