d3d11_status.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef MEDIA_GPU_WINDOWS_D3D11_STATUS_H_
  5. #define MEDIA_GPU_WINDOWS_D3D11_STATUS_H_
  6. #include <wrl/client.h>
  7. #include "base/logging.h"
  8. #include "base/strings/string_util.h"
  9. #include "media/base/status.h"
  10. namespace media {
  11. enum class D3D11StatusCode : StatusCodeType {
  12. kOk = 0,
  13. kFailedToGetAngleDevice = 1,
  14. kUnsupportedFeatureLevel = 2,
  15. kFailedToGetVideoDevice = 3,
  16. kFailedToGetDeviceContext = 4,
  17. kFailedToInitializeGPUProcess = 5,
  18. kDecoderFailedDecode = 6,
  19. kDecoderUnsupportedProfile = 7,
  20. kDecoderUnsupportedCodec = 8,
  21. kDecoderUnsupportedConfig = 9,
  22. kDecoderCreationFailed = 10,
  23. kMakeContextCurrentFailed = 11,
  24. kCreateTextureSelectorFailed = 12,
  25. kQueryID3D11MultithreadFailed = 13,
  26. kGetDecoderConfigCountFailed = 14,
  27. kGetDecoderConfigFailed = 15,
  28. kProcessTextureFailed = 16,
  29. kUnsupportedTextureFormatForBind = 17,
  30. kCreateDecoderOutputViewFailed = 18,
  31. kAllocateTextureForCopyingWrapperFailed = 19,
  32. kCreateDecoderOutputTextureFailed = 20,
  33. kCreateVideoProcessorInputViewFailed = 21,
  34. kVideoProcessorBltFailed = 22,
  35. kCreateVideoProcessorOutputViewFailed = 23,
  36. kCreateVideoProcessorFailed = 24,
  37. kQueryVideoContextFailed = 25,
  38. kAcceleratorFlushFailed = 26,
  39. kTryAgainNotSupported = 27,
  40. kCryptoConfigFailed = 28,
  41. kDecoderBeginFrameFailed = 29,
  42. kGetPicParamBufferFailed = 30,
  43. kReleasePicParamBufferFailed = 31,
  44. kGetBitstreamBufferFailed = 32,
  45. kReleaseBitstreamBufferFailed = 33,
  46. kGetSliceControlBufferFailed = 34,
  47. kReleaseSliceControlBufferFailed = 35,
  48. kDecoderEndFrameFailed = 36,
  49. kSubmitDecoderBuffersFailed = 37,
  50. kGetQuantBufferFailed = 38,
  51. kReleaseQuantBufferFailed = 39,
  52. kBitstreamBufferSliceTooBig = 40,
  53. kCreateSharedImageFailed = 41,
  54. kGetKeyedMutexFailed = 42,
  55. kAcquireKeyedMutexFailed = 43,
  56. kReleaseKeyedMutexFailed = 44,
  57. kCreateSharedHandleFailed = 45,
  58. };
  59. struct D3D11StatusTraits {
  60. using Codes = D3D11StatusCode;
  61. static constexpr StatusGroupType Group() { return "D3D11Status"; }
  62. static constexpr D3D11StatusCode DefaultEnumValue() {
  63. return D3D11StatusCode::kOk;
  64. }
  65. static void OnCreateFrom(TypedStatus<D3D11StatusTraits>* s, HRESULT hresult) {
  66. // Store it as a string for easy human consumption.
  67. std::stringstream hresult_str_repr;
  68. hresult_str_repr << std::hex << hresult;
  69. s->WithData("hresult", hresult_str_repr.str());
  70. // Store it as an integer for easy machine consumption.
  71. s->WithData("hresult_raw", static_cast<int32_t>(hresult));
  72. // Store the system error that might have been generated, if it's an
  73. // allowable string.
  74. std::string sys_err = logging::SystemErrorCodeToString(hresult);
  75. if (base::IsStringUTF8AllowingNoncharacters(sys_err))
  76. s->WithData("hresult_msg", sys_err);
  77. }
  78. };
  79. using D3D11Status = TypedStatus<D3D11StatusTraits>;
  80. } // namespace media
  81. #endif // MEDIA_GPU_WINDOWS_D3D11_STATUS_H_