From 49e32eb178a7b6ed5c598182329bf4f21e51157d Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Tue, 12 Dec 2023 14:19:36 -0500 Subject: [graphite] Add Caps::supportsAHardwareBufferImages Change-Id: Ib9ad8086d54aa6dd58c7bb9bcefc864a27f7c8e8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/789157 Commit-Queue: Robert Phillips Reviewed-by: Nicolette Prevost --- src/gpu/graphite/Caps.h | 7 +++++++ src/gpu/graphite/vk/VulkanCaps.cpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/gpu/graphite/Caps.h b/src/gpu/graphite/Caps.h index 0f6bc2904c..0175594892 100644 --- a/src/gpu/graphite/Caps.h +++ b/src/gpu/graphite/Caps.h @@ -212,6 +212,12 @@ public: // Returns whether compute shaders are supported. bool computeSupport() const { return fComputeSupport; } + /** + * Returns true if the given backend supports importing AHardwareBuffers. This will only + * ever be supported on Android devices with API level >= 26. + */ + bool supportsAHardwareBufferImages() const { return fSupportsAHardwareBufferImages; } + // Returns the skgpu::Swizzle to use when sampling or reading back from a texture with the // passed in SkColorType and TextureInfo. skgpu::Swizzle getReadSwizzle(SkColorType, const TextureInfo&) const; @@ -308,6 +314,7 @@ protected: bool fMSAARenderToSingleSampledSupport = false; bool fComputeSupport = false; + bool fSupportsAHardwareBufferImages = false; ResourceBindingRequirements fResourceBindingReqs; diff --git a/src/gpu/graphite/vk/VulkanCaps.cpp b/src/gpu/graphite/vk/VulkanCaps.cpp index e4f7c5adcd..95e900da83 100644 --- a/src/gpu/graphite/vk/VulkanCaps.cpp +++ b/src/gpu/graphite/vk/VulkanCaps.cpp @@ -128,6 +128,13 @@ void VulkanCaps::init(const ContextOptions& contextOptions, } fMaxUniformBufferRange = physDevProperties.limits.maxUniformBufferRange; +#ifdef SK_BUILD_FOR_ANDROID + if (extensions->hasExtension( + VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME, 2)) { + fSupportsAHardwareBufferImages = true; + } +#endif + // Determine whether the client enabled certain physical device features. if (features) { auto ycbcrFeatures = -- cgit v1.2.3