D3DCommon.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2019 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <d3dcompiler.h>
  5. #include <dxgiformat.h>
  6. #include <string>
  7. #include <vector>
  8. #include <wrl/client.h>
  9. #include "Common/CommonTypes.h"
  10. struct IDXGIFactory;
  11. enum class AbstractTextureFormat : u32;
  12. namespace D3DCommon
  13. {
  14. // Loading dxgi.dll and d3dcompiler.dll
  15. bool LoadLibraries();
  16. void UnloadLibraries();
  17. // Returns a list of D3D device names.
  18. std::vector<std::string> GetAdapterNames();
  19. // Helper function which creates a DXGI factory.
  20. Microsoft::WRL::ComPtr<IDXGIFactory> CreateDXGIFactory(bool debug_device);
  21. // Globally-accessible D3DCompiler function.
  22. extern pD3DCompile d3d_compile;
  23. // Helpers for texture format conversion.
  24. DXGI_FORMAT GetDXGIFormatForAbstractFormat(AbstractTextureFormat format, bool typeless);
  25. DXGI_FORMAT GetSRVFormatForAbstractFormat(AbstractTextureFormat format);
  26. DXGI_FORMAT GetRTVFormatForAbstractFormat(AbstractTextureFormat format, bool integer);
  27. DXGI_FORMAT GetDSVFormatForAbstractFormat(AbstractTextureFormat format);
  28. AbstractTextureFormat GetAbstractFormatForDXGIFormat(DXGI_FORMAT format);
  29. // This function will assign a name to the given resource.
  30. // The DirectX debug layer will make it easier to identify resources that way,
  31. // e.g. when listing up all resources who have unreleased references.
  32. void SetDebugObjectName(IUnknown* resource, std::string_view name);
  33. } // namespace D3DCommon