From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- gfx/thebes/DeviceManagerDx.h | 154 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 gfx/thebes/DeviceManagerDx.h (limited to 'gfx/thebes/DeviceManagerDx.h') diff --git a/gfx/thebes/DeviceManagerDx.h b/gfx/thebes/DeviceManagerDx.h new file mode 100644 index 000000000..ea6dd4846 --- /dev/null +++ b/gfx/thebes/DeviceManagerDx.h @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * 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_thebes_DeviceManagerDx_h +#define mozilla_gfx_thebes_DeviceManagerDx_h + +#include "gfxPlatform.h" +#include "gfxTelemetry.h" +#include "mozilla/Maybe.h" +#include "mozilla/Mutex.h" +#include "mozilla/RefPtr.h" +#include "mozilla/StaticPtr.h" +#include "mozilla/gfx/GraphicsMessages.h" +#include "nsTArray.h" +#include "nsWindowsHelpers.h" + +#include +#include + +#include + +// This header is available in the June 2010 SDK and in the Win8 SDK +#include +// Win 8.0 SDK types we'll need when building using older sdks. +#if !defined(D3D_FEATURE_LEVEL_11_1) // defined in the 8.0 SDK only +#define D3D_FEATURE_LEVEL_11_1 static_cast(0xb100) +#define D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION 2048 +#define D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION 4096 +#endif + +struct ID3D11Device; +struct IDirectDraw7; + +namespace mozilla { +class ScopedGfxFeatureReporter; + +namespace gfx { +class FeatureState; + +class DeviceManagerDx final +{ +public: + static void Init(); + static void Shutdown(); + + DeviceManagerDx(); + + static DeviceManagerDx* Get() { + return sInstance; + } + + RefPtr GetCompositorDevice(); + RefPtr GetContentDevice(); + RefPtr CreateDecoderDevice(); + IDirectDraw7* GetDirectDraw(); + + unsigned GetCompositorFeatureLevel() const; + bool TextureSharingWorks(); + bool IsWARP(); + + // Returns true if we can create a texture with + // D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX and also + // upload texture data during the CreateTexture2D + // call. This crashes on some devices, so we might + // need to avoid it. + bool CanInitializeKeyedMutexTextures(); + + bool CreateCompositorDevices(); + void CreateContentDevices(); + + void ImportDeviceInfo(const D3D11DeviceStatus& aDeviceStatus); + void ExportDeviceInfo(D3D11DeviceStatus* aOut); + + void ResetDevices(); + void InitializeDirectDraw(); + + // Reset and reacquire the devices if a reset has happened. + // Returns whether a reset occurred not whether reacquiring + // was successful. + bool MaybeResetAndReacquireDevices(); + + // Test whether we can acquire a DXGI 1.2-compatible adapter. This should + // only be called on startup before devices are initialized. + bool CheckRemotePresentSupport(); + + // Device reset helpers. + bool HasDeviceReset(DeviceResetReason* aOutReason = nullptr); + + // Note: these set the cached device reset reason, which will be picked up + // on the next frame. + void ForceDeviceReset(ForcedDeviceResetReason aReason); + void NotifyD3D9DeviceReset(); + +private: + IDXGIAdapter1 *GetDXGIAdapter(); + + void DisableD3D11AfterCrash(); + + void CreateCompositorDevice(mozilla::gfx::FeatureState& d3d11); + bool CreateCompositorDeviceHelper( + mozilla::gfx::FeatureState& aD3d11, + IDXGIAdapter1* aAdapter, + bool aAttemptVideoSupport, + RefPtr& aOutDevice); + + void CreateWARPCompositorDevice(); + + mozilla::gfx::FeatureStatus CreateContentDevice(); + + bool CreateDevice(IDXGIAdapter* aAdapter, + D3D_DRIVER_TYPE aDriverType, + UINT aFlags, + HRESULT& aResOut, + RefPtr& aOutDevice); + + bool ContentAdapterIsParentAdapter(ID3D11Device* device); + + bool LoadD3D11(); + void ReleaseD3D11(); + + // Call GetDeviceRemovedReason on each device until one returns + // a failure. + bool GetAnyDeviceRemovedReason(DeviceResetReason* aOutReason); + +private: + static StaticAutoPtr sInstance; + + // This is assigned during device creation. Afterwards, it is released if + // devices failed, and "forgotten" if devices succeeded (meaning, we leak + // the ref and unassign the module). + nsModuleHandle mD3D11Module; + + mozilla::Mutex mDeviceLock; + nsTArray mFeatureLevels; + RefPtr mAdapter; + RefPtr mCompositorDevice; + RefPtr mContentDevice; + RefPtr mDecoderDevice; + bool mCompositorDeviceSupportsVideo; + + Maybe mDeviceStatus; + + nsModuleHandle mDirectDrawDLL; + RefPtr mDirectDraw; + + Maybe mDeviceResetReason; +}; + +} // namespace gfx +} // namespace mozilla + +#endif // mozilla_gfx_thebes_DeviceManagerDx_h -- cgit v1.2.3