Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fecf4550 authored by Sean Callanan's avatar Sean Callanan
Browse files

mapper-passthrough: filter two usages for gralloc1

GPU_CUBE_MAP and GPU_MIPMAP_COMPLETE both do not exist in gralloc1,
so don't try to allocate buffers that have those usages.  Report an
error instead.

Bug: 66876469
Test: CTSNativeHardwareTestCases on Taimen
Change-Id: I1a6bd209faf5ffad93dbac0ab887bb1447a44aac
parent defaf3ab
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ namespace passthrough {

using V2_0::BufferDescriptor;
using V2_0::Error;
using android::hardware::graphics::common::V1_0::BufferUsage;
using android::hardware::graphics::common::V1_1::BufferUsage;

namespace detail {

@@ -72,6 +72,8 @@ class Gralloc1HalImpl : public V2_0::passthrough::detail::Gralloc1HalImpl<Hal> {

    Error createDescriptor_2_1(const IMapper::BufferDescriptorInfo& descriptorInfo,
                               BufferDescriptor* outDescriptor) override {
        if (gralloc1UsageUnsupported(descriptorInfo.usage))
             return Error::BAD_DESCRIPTOR;
        return createDescriptor(
            V2_0::IMapper::BufferDescriptorInfo{
                descriptorInfo.width, descriptorInfo.height, descriptorInfo.layerCount,
@@ -163,6 +165,16 @@ class Gralloc1HalImpl : public V2_0::passthrough::detail::Gralloc1HalImpl<Hal> {
        return consumerUsage;
    }

    static bool gralloc1UsageUnsupported(uint64_t usage) {
        // Certain newer public usage bits should not be used with gralloc1.
        // We use a blacklist instead of a whitelist here in order to avoid
        // breaking private usage flags.
        constexpr uint64_t unsupportedMask = BufferUsage::GPU_CUBE_MAP |
                                             BufferUsage::GPU_MIPMAP_COMPLETE;

        return usage & unsupportedMask;
    }

   private:
    using BaseType2_0 = V2_0::passthrough::detail::Gralloc1HalImpl<Hal>;
    using BaseType2_0::createDescriptor;