Bug 1105109 - Fix unified compilation errors. r=kats
authorBotond Ballo <botond@mozilla.com>
Fri, 28 Jul 2017 20:17:19 -0400
changeset 420735 f3b7b55bfb28750d67a4de0ce541f8c5bb4d0cce
parent 420734 9de78eb067cf3ba198352d55582b4643001d4931
child 420736 54025a37b21b587993cae2d36bba8553bda601a6
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1105109
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1105109 - Fix unified compilation errors. r=kats MozReview-Commit-ID: DB3JNwlE3Dw
gfx/layers/ipc/CompositorManagerChild.cpp
gfx/layers/mlgpu/BufferCache.h
gfx/layers/mlgpu/RenderViewMLGPU.cpp
gfx/layers/mlgpu/SharedBufferMLGPU.cpp
gfx/layers/mlgpu/SharedBufferMLGPU.h
gfx/layers/wr/WebRenderBridgeParent.cpp
--- a/gfx/layers/ipc/CompositorManagerChild.cpp
+++ b/gfx/layers/ipc/CompositorManagerChild.cpp
@@ -1,26 +1,31 @@
 /* -*- 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 "mozilla/layers/CompositorManagerChild.h"
+
+#include "gfxPrefs.h"
 #include "mozilla/layers/CompositorBridgeChild.h"
 #include "mozilla/layers/CompositorManagerParent.h"
 #include "mozilla/layers/CompositorThread.h"
+#include "mozilla/gfx/gfxVars.h"
 #include "mozilla/gfx/GPUProcessManager.h"
 #include "mozilla/dom/ContentChild.h"   // for ContentChild
 #include "mozilla/dom/TabChild.h"       // for TabChild
 #include "mozilla/dom/TabGroup.h"       // for TabGroup
 #include "VsyncSource.h"
 
 namespace mozilla {
 namespace layers {
 
+using gfx::GPUProcessManager;
+
 StaticRefPtr<CompositorManagerChild> CompositorManagerChild::sInstance;
 
 /* static */ bool
 CompositorManagerChild::IsInitialized(base::ProcessId aGPUPid)
 {
   MOZ_ASSERT(NS_IsMainThread());
   return sInstance && sInstance->CanSend() && sInstance->OtherPid() == aGPUPid;
 }
@@ -260,17 +265,17 @@ CompositorManagerChild::GetSpecificMessa
 void
 CompositorManagerChild::SetReplyTimeout()
 {
 #ifndef DEBUG
   // Add a timeout for release builds to kill GPU process when it hangs.
   // Don't apply timeout when using web render as it tend to timeout frequently.
   if (XRE_IsParentProcess() &&
       GPUProcessManager::Get()->GetGPUChild() &&
-      !gfxVars::UseWebRender()) {
+      !gfx::gfxVars::UseWebRender()) {
     int32_t timeout = gfxPrefs::GPUProcessIPCReplyTimeoutMs();
     SetReplyTimeoutMs(timeout);
   }
 #endif
 }
 
 bool
 CompositorManagerChild::ShouldContinueFromReplyTimeout()
--- a/gfx/layers/mlgpu/BufferCache.h
+++ b/gfx/layers/mlgpu/BufferCache.h
@@ -2,16 +2,17 @@
 * 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 mozilla_gfx_layers_mlgpu_BufferCache_h
 #define mozilla_gfx_layers_mlgpu_BufferCache_h
 
 #include "mozilla/EnumeratedArray.h"
+#include "mozilla/RefPtr.h"
 #include <deque>
 #include <vector>
 
 namespace mozilla {
 namespace layers {
 
 class MLGBuffer;
 class MLGDevice;
--- a/gfx/layers/mlgpu/RenderViewMLGPU.cpp
+++ b/gfx/layers/mlgpu/RenderViewMLGPU.cpp
@@ -7,16 +7,18 @@
 #include "ContainerLayerMLGPU.h"
 #include "FrameBuilder.h"
 #include "gfxPrefs.h"
 #include "LayersHelpers.h"
 #include "LayersLogging.h"
 #include "MLGDevice.h"
 #include "RenderPassMLGPU.h"
 #include "ShaderDefinitionsMLGPU.h"
+#include "Units.h"
+#include "UnitTransforms.h"
 #include "UtilityMLGPU.h"
 
 namespace mozilla {
 namespace layers {
 
 using namespace gfx;
 
 RenderViewMLGPU::RenderViewMLGPU(FrameBuilder* aBuilder,
--- a/gfx/layers/mlgpu/SharedBufferMLGPU.cpp
+++ b/gfx/layers/mlgpu/SharedBufferMLGPU.cpp
@@ -153,28 +153,138 @@ SharedBufferMLGPU::Unmap()
 
   mBytesUsedThisFrame += mCurrentPosition;
 
   mDevice->Unmap(mBuffer);
   mMap = MLGMappedResource();
   mMapped = false;
 }
 
+uint8_t*
+SharedBufferMLGPU::GetBufferPointer(size_t aBytes, ptrdiff_t* aOutOffset, RefPtr<MLGBuffer>* aOutBuffer)
+{
+  if (!EnsureMappedBuffer(aBytes)) {
+    return nullptr;
+  }
+
+  ptrdiff_t newPos = mCurrentPosition + aBytes;
+  MOZ_ASSERT(size_t(newPos) <= mMaxSize);
+
+  *aOutOffset = mCurrentPosition;
+  *aOutBuffer = mBuffer;
+
+  uint8_t* ptr = reinterpret_cast<uint8_t*>(mMap.mData) + mCurrentPosition;
+  mCurrentPosition = newPos;
+  return ptr;
+}
+
+VertexBufferSection::VertexBufferSection()
+ : mOffset(-1),
+   mNumVertices(0),
+   mStride(0)
+{}
+
+void
+VertexBufferSection::Init(MLGBuffer* aBuffer, ptrdiff_t aOffset, size_t aNumVertices, size_t aStride)
+{
+  mBuffer = aBuffer;
+  mOffset = aOffset;
+  mNumVertices = aNumVertices;
+  mStride = aStride;
+}
+
+ConstantBufferSection::ConstantBufferSection()
+ : mOffset(-1)
+{}
+
+void
+ConstantBufferSection::Init(MLGBuffer* aBuffer, ptrdiff_t aOffset, size_t aBytes, size_t aNumItems)
+{
+  mBuffer = aBuffer;
+  mOffset = aOffset;
+  mNumBytes = aBytes;
+  mNumItems = aNumItems;
+}
+
 SharedVertexBuffer::SharedVertexBuffer(MLGDevice* aDevice, size_t aDefaultSize)
  : SharedBufferMLGPU(aDevice, MLGBufferType::Vertex, aDefaultSize)
 {
 }
 
+bool
+SharedVertexBuffer::Allocate(VertexBufferSection* aHolder,
+                             size_t aNumItems,
+                             size_t aSizeOfItem,
+                             const void* aData)
+{
+  RefPtr<MLGBuffer> buffer;
+  ptrdiff_t offset;
+  size_t bytes = aSizeOfItem * aNumItems;
+  uint8_t* ptr = GetBufferPointer(bytes, &offset, &buffer);
+  if (!ptr) {
+    return false;
+  }
+
+  memcpy(ptr, aData, bytes);
+  aHolder->Init(buffer, offset, aNumItems, aSizeOfItem);
+  return true;
+}
+
+AutoBufferUploadBase::AutoBufferUploadBase()
+  : mPtr(nullptr)
+{
+}
+
+AutoBufferUploadBase::~AutoBufferUploadBase()
+{
+  if (mBuffer) {
+    UnmapBuffer();
+  }
+}
+
+void
+AutoBufferUploadBase::Init(void* aPtr, MLGDevice* aDevice, MLGBuffer* aBuffer)
+{
+  MOZ_ASSERT(!mPtr && aPtr);
+  mPtr = aPtr;
+  mDevice = aDevice;
+  mBuffer = aBuffer;
+}
+
 SharedConstantBuffer::SharedConstantBuffer(MLGDevice* aDevice, size_t aDefaultSize)
  : SharedBufferMLGPU(aDevice, MLGBufferType::Constant, aDefaultSize)
 {
   mMaxConstantBufferBindSize = aDevice->GetMaxConstantBufferBindSize();
   mCanUseOffsetAllocation = aDevice->CanUseConstantBufferOffsetBinding();
 }
 
+bool
+SharedConstantBuffer::Allocate(ConstantBufferSection* aHolder,
+                               AutoBufferUploadBase* aPtr,
+                               size_t aNumItems,
+                               size_t aSizeOfItem)
+{
+  MOZ_ASSERT(aSizeOfItem % 16 == 0, "Items must be padded to 16 bytes");
+
+  size_t bytes = aNumItems * aSizeOfItem;
+  if (bytes > mMaxConstantBufferBindSize) {
+    gfxWarning() << "Attempted to allocate too many bytes into a constant buffer";
+    return false;
+  }
+
+  RefPtr<MLGBuffer> buffer;
+  ptrdiff_t offset;
+  if (!GetBufferPointer(aPtr, bytes, &offset, &buffer)) {
+    return false;
+  }
+
+  aHolder->Init(buffer, offset, bytes, aNumItems);
+  return true;
+}
+
 uint8_t*
 SharedConstantBuffer::AllocateNewBuffer(size_t aBytes, ptrdiff_t* aOutOffset, RefPtr<MLGBuffer>* aOutBuffer)
 {
   RefPtr<MLGBuffer> buffer;
   if (BufferCache* cache = mDevice->GetConstantBufferCache()) {
     buffer = cache->GetOrCreateBuffer(aBytes);
   } else {
     buffer = mDevice->CreateBuffer(MLGBufferType::Constant, aBytes, MLGUsage::Dynamic);
--- a/gfx/layers/mlgpu/SharedBufferMLGPU.h
+++ b/gfx/layers/mlgpu/SharedBufferMLGPU.h
@@ -33,31 +33,17 @@ protected:
   SharedBufferMLGPU(MLGDevice* aDevice, MLGBufferType aType, size_t aDefaultSize);
 
   bool EnsureMappedBuffer(size_t aBytes);
   bool GrowBuffer(size_t aBytes);
   void ForgetBuffer();
   bool Map();
   void Unmap();
 
-  uint8_t* GetBufferPointer(size_t aBytes, ptrdiff_t* aOutOffset, RefPtr<MLGBuffer>* aOutBuffer) {
-    if (!EnsureMappedBuffer(aBytes)) {
-      return nullptr;
-    }
-
-    ptrdiff_t newPos = mCurrentPosition + aBytes;
-    MOZ_ASSERT(size_t(newPos) <= mMaxSize);
-
-    *aOutOffset = mCurrentPosition;
-    *aOutBuffer = mBuffer;
-
-    uint8_t* ptr = reinterpret_cast<uint8_t*>(mMap.mData) + mCurrentPosition;
-    mCurrentPosition = newPos;
-    return ptr;
-  }
+  uint8_t* GetBufferPointer(size_t aBytes, ptrdiff_t* aOutOffset, RefPtr<MLGBuffer>* aOutBuffer);
 
 protected:
   // Note: RefPtr here would cause a cycle. Only MLGDevice should own
   // SharedBufferMLGPU objects for now.
   MLGDevice* mDevice;
   MLGBufferType mType;
   size_t mDefaultSize;
   bool mCanUseOffsetAllocation;
@@ -76,21 +62,17 @@ protected:
   size_t mBytesUsedThisFrame;
   size_t mNumSmallFrames;
 };
 
 class VertexBufferSection final
 {
   friend class SharedVertexBuffer;
 public:
-  VertexBufferSection()
-   : mOffset(-1),
-     mNumVertices(0),
-     mStride(0)
-  {}
+  VertexBufferSection();
 
   uint32_t Stride() const {
     return mStride;
   }
   MLGBuffer* GetBuffer() const {
     return mBuffer;
   }
   ptrdiff_t Offset() const {
@@ -100,38 +82,31 @@ public:
   size_t NumVertices() const {
     return mNumVertices;
   }
   bool IsValid() const {
     return !!mBuffer;
   }
 
 protected:
-  void Init(MLGBuffer* aBuffer, ptrdiff_t aOffset, size_t aNumVertices, size_t aStride) {
-    mBuffer = aBuffer;
-    mOffset = aOffset;
-    mNumVertices = aNumVertices;
-    mStride = aStride;
-  }
+  void Init(MLGBuffer* aBuffer, ptrdiff_t aOffset, size_t aNumVertices, size_t aStride);
 
 protected:
   RefPtr<MLGBuffer> mBuffer;
   ptrdiff_t mOffset;
   size_t mNumVertices;
   size_t mStride;
 };
 
 class ConstantBufferSection final
 {
   friend class SharedConstantBuffer;
 
 public:
-  ConstantBufferSection()
-   : mOffset(-1)
-  {}
+  ConstantBufferSection();
 
   uint32_t NumConstants() const {
     return NumConstantsForBytes(mNumBytes);
   }
   size_t NumItems() const {
     return mNumItems;
   }
   uint32_t Offset() const {
@@ -148,22 +123,17 @@ public:
     return mOffset != -1;
   }
 
 protected:
   static constexpr size_t NumConstantsForBytes(size_t aBytes) {
     return (aBytes + ((256 - (aBytes % 256)) % 256)) / 16;
   }
 
-  void Init(MLGBuffer* aBuffer, ptrdiff_t aOffset, size_t aBytes, size_t aNumItems) {
-    mBuffer = aBuffer;
-    mOffset = aOffset;
-    mNumBytes = aBytes;
-    mNumItems = aNumItems;
-  }
+  void Init(MLGBuffer* aBuffer, ptrdiff_t aOffset, size_t aBytes, size_t aNumItems);
 
 protected:
   RefPtr<MLGBuffer> mBuffer;
   ptrdiff_t mOffset;
   size_t mNumBytes;
   size_t mNumItems;
 };
 
@@ -184,62 +154,40 @@ public:
   }
 
   // Allocate a buffer that can be uploaded immediately. This is the
   // direct access version, for cases where a StagingBuffer is not
   // needed.
   bool Allocate(VertexBufferSection* aHolder,
                 size_t aNumItems,
                 size_t aSizeOfItem,
-                const void* aData)
-  {
-    RefPtr<MLGBuffer> buffer;
-    ptrdiff_t offset;
-    size_t bytes = aSizeOfItem * aNumItems;
-    uint8_t* ptr = GetBufferPointer(bytes, &offset, &buffer);
-    if (!ptr) {
-      return false;
-    }
-
-    memcpy(ptr, aData, bytes);
-    aHolder->Init(buffer, offset, aNumItems, aSizeOfItem);
-    return true;
-  }
+                const void* aData);
 
   template <typename T>
   bool Allocate(VertexBufferSection* aHolder, const T& aItem) {
     return Allocate(aHolder, 1, sizeof(T), &aItem);
   }
 };
 
 // To support older Direct3D versions, we need to support one-off MLGBuffers,
 // where data is uploaded immediately rather than at the end of all batch
 // preparation. We achieve this through a small helper class.
 //
 // Note: the unmap is not inline sincce we don't include MLGDevice.h.
 class MOZ_STACK_CLASS AutoBufferUploadBase
 {
 public:
-  AutoBufferUploadBase() : mPtr(nullptr) {}
-  ~AutoBufferUploadBase() {
-    if (mBuffer) {
-      UnmapBuffer();
-    }
-  }
+  AutoBufferUploadBase();
+  ~AutoBufferUploadBase();
 
   void Init(void* aPtr) {
     MOZ_ASSERT(!mPtr && aPtr);
     mPtr = aPtr;
   }
-  void Init(void* aPtr, MLGDevice* aDevice, MLGBuffer* aBuffer) {
-    MOZ_ASSERT(!mPtr && aPtr);
-    mPtr = aPtr;
-    mDevice = aDevice;
-    mBuffer = aBuffer;
-  }
+  void Init(void* aPtr, MLGDevice* aDevice, MLGBuffer* aBuffer);
   void* get() {
     return const_cast<void*>(mPtr);
   }
 
 private:
   void UnmapBuffer();
 
 protected:
@@ -307,36 +255,17 @@ private:
     }
     memcpy(ptr.get(), aData, aNumItems * aSizeOfItem);
     return true;
   }
 
   bool Allocate(ConstantBufferSection* aHolder,
                 AutoBufferUploadBase* aPtr,
                 size_t aNumItems,
-                size_t aSizeOfItem)
-  {
-    MOZ_ASSERT(aSizeOfItem % 16 == 0, "Items must be padded to 16 bytes");
-
-    size_t bytes = aNumItems * aSizeOfItem;
-    if (bytes > mMaxConstantBufferBindSize) {
-      gfxWarning() << "Attempted to allocate too many bytes into a constant buffer";
-      return false;
-    }
-
-
-    RefPtr<MLGBuffer> buffer;
-    ptrdiff_t offset;
-    if (!GetBufferPointer(aPtr, bytes, &offset, &buffer)) {
-      return false;
-    }
-
-    aHolder->Init(buffer, offset, bytes, aNumItems);
-    return true;
-  }
+                size_t aSizeOfItem);
 
   bool GetBufferPointer(AutoBufferUploadBase* aPtr,
                         size_t aBytes,
                         ptrdiff_t* aOutOffset,
                         RefPtr<MLGBuffer>* aOutBuffer)
   {
     if (!mCanUseOffsetAllocation) {
       uint8_t* ptr = AllocateNewBuffer(aBytes, aOutOffset, aOutBuffer);
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -3,16 +3,17 @@
 /* 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 "mozilla/layers/WebRenderBridgeParent.h"
 
 #include "apz/src/AsyncPanZoomController.h"
 #include "CompositableHost.h"
+#include "gfxEnv.h"
 #include "gfxPrefs.h"
 #include "gfxEnv.h"
 #include "GeckoProfiler.h"
 #include "GLContext.h"
 #include "GLContextProvider.h"
 #include "mozilla/Range.h"
 #include "mozilla/layers/AnimationHelper.h"
 #include "mozilla/layers/APZCTreeManager.h"