plugin_cuda_utils.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Copyright (C) 2013 Mamadou DIOP
  2. * Copyright (C) 2013 Doubango Telecom <http://www.doubango.org>
  3. *
  4. * This file is part of Open Source Doubango Framework.
  5. *
  6. * DOUBANGO is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * DOUBANGO is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with DOUBANGO.
  18. */
  19. #ifndef PLUGIN_CUDA_UTILS_H
  20. #define PLUGIN_CUDA_UTILS_H
  21. #include "plugin_cuda_config.h"
  22. #include <Windows.h>
  23. #undef CHECK_HR
  24. // In CHECK_HR(x) When (x) is a function it will be executed twice when used in "TSK_DEBUG_ERROR(x)" and "If(x)"
  25. #define CHECK_HR(x) { HRESULT __hr__ = (x); if (FAILED(__hr__)) { TSK_DEBUG_ERROR("Operation Failed (%08x)", __hr__); goto bail; } }
  26. #undef SafeRelease
  27. #define SafeRelease(ppT) \
  28. { \
  29. if (*ppT) \
  30. { \
  31. (*ppT)->Release(); \
  32. *ppT = NULL; \
  33. } \
  34. }
  35. class CudaUtils
  36. {
  37. public:
  38. static HRESULT Startup();
  39. static HRESULT Shutdown();
  40. static bool IsH264Supported();
  41. static int ConvertSMVer2Cores(int nMajor, int nMinor);
  42. static int GetMaxGflopsDeviceId();
  43. private:
  44. static bool g_bStarted;
  45. static bool g_bH264Checked;
  46. static bool g_bH264Supported;
  47. static int g_nCores;
  48. };
  49. #endif/* PLUGIN_CUDA_UTILS_H */