VkTestContext.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright 2016 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef VkTestContext_DEFINED
  8. #define VkTestContext_DEFINED
  9. #include "tools/gpu/TestContext.h"
  10. #ifdef SK_VULKAN
  11. #include "include/gpu/vk/GrVkBackendContext.h"
  12. #include "tools/gpu/vk/GrVulkanDefines.h"
  13. class GrVkExtensions;
  14. namespace sk_gpu_test {
  15. class VkTestContext : public TestContext {
  16. public:
  17. virtual GrBackendApi backend() override { return GrBackendApi::kVulkan; }
  18. const GrVkBackendContext& getVkBackendContext() const {
  19. return fVk;
  20. }
  21. const GrVkExtensions* getVkExtensions() const {
  22. return fExtensions;
  23. }
  24. const VkPhysicalDeviceFeatures2* getVkFeatures() const {
  25. return fFeatures;
  26. }
  27. protected:
  28. VkTestContext(const GrVkBackendContext& vk, const GrVkExtensions* extensions,
  29. const VkPhysicalDeviceFeatures2* features, bool ownsContext,
  30. VkDebugReportCallbackEXT debugCallback,
  31. PFN_vkDestroyDebugReportCallbackEXT destroyCallback)
  32. : fVk(vk)
  33. , fExtensions(extensions)
  34. , fFeatures(features)
  35. , fOwnsContext(ownsContext)
  36. , fDebugCallback(debugCallback)
  37. , fDestroyDebugReportCallbackEXT(destroyCallback) {}
  38. GrVkBackendContext fVk;
  39. const GrVkExtensions* fExtensions;
  40. const VkPhysicalDeviceFeatures2* fFeatures;
  41. bool fOwnsContext;
  42. VkDebugReportCallbackEXT fDebugCallback = VK_NULL_HANDLE;
  43. PFN_vkDestroyDebugReportCallbackEXT fDestroyDebugReportCallbackEXT = nullptr;
  44. private:
  45. typedef TestContext INHERITED;
  46. };
  47. /**
  48. * Creates Vk context object bound to the native Vk library.
  49. */
  50. VkTestContext* CreatePlatformVkTestContext(VkTestContext*);
  51. } // namespace sk_gpu_test
  52. #endif
  53. #endif