From 2d94f52b18f6539b69d2c3c4d2012b79a06f5369 Mon Sep 17 00:00:00 2001 From: Sally Qi Date: Tue, 15 Oct 2024 12:53:51 -0700 Subject: [PATCH] [Lut HAL] add Lut VTS enforcement Bug: 362319189 Bug: 358422255 Test: VtsHalGraphicsComposer3_TargetTest Change-Id: I41b279d362715c32a2d0ee6021c0f1f94b612d64 --- .../graphics/composer3/LutProperties.aidl | 4 +- .../hardware/graphics/composer3/Luts.aidl | 6 ++- .../VtsHalGraphicsComposer3_TargetTest.cpp | 54 +++++++++++++++++++ 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/LutProperties.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/LutProperties.aidl index 1c6fd18b69..d3dd30e03f 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/LutProperties.aidl +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/LutProperties.aidl @@ -36,8 +36,8 @@ parcelable LutProperties { /** * SamplingKey is about how a Lut can be sampled. - * A Lut can be sampled in more than one way, - * but only one sampling method is used at one time. + * A Lut can be sampled in more than one key, + * but only one sampling key is used at one time. * * The implementations should use a sampling strategy * at least as good as linear sampling. diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/Luts.aidl b/graphics/composer/aidl/android/hardware/graphics/composer3/Luts.aidl index 5f55f1c38c..592ac50091 100644 --- a/graphics/composer/aidl/android/hardware/graphics/composer3/Luts.aidl +++ b/graphics/composer/aidl/android/hardware/graphics/composer3/Luts.aidl @@ -40,13 +40,15 @@ parcelable Luts { * For data precision, 32-bit float is used to specify a Lut by both the HWC and * the platform. * - * * For unflattening/flattening 3D Lut(s), the algorithm below should be observed * by both the HWC and the platform. * Assuming that we have a 3D array `ORIGINAL[WIDTH, HEIGHT, DEPTH]`, we would turn it into * `FLAT[WIDTH * HEIGHT * DEPTH]` by * * `FLAT[z + DEPTH * (y + HEIGHT * x)] = ORIGINAL[x, y, z]` + * + * Noted that 1D Lut(s) should be gain curve ones + * and 3D Lut(s) should be pure color lookup ones. */ @nullable ParcelFileDescriptor pfd; @@ -60,6 +62,8 @@ parcelable Luts { /** * The properties list of the Luts. + * + * The number of sampling key inside should only be one. */ LutProperties[] lutProperties; } diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp index 106941e27e..800652357c 100644 --- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp +++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -3324,6 +3325,54 @@ TEST_P(GraphicsComposerAidlCommandV3Test, setLayerPictureProfileId_failsWithTooM } } +class GraphicsComposerAidlCommandV4Test : public GraphicsComposerAidlCommandTest { + protected: + void SetUp() override { + GraphicsComposerAidlTest::SetUp(); + if (getInterfaceVersion() <= 3) { + GTEST_SKIP() << "Device interface version is expected to be >= 4"; + } + } +}; + +TEST_P(GraphicsComposerAidlCommandV4Test, SetUnsupportedLayerLuts) { + auto& writer = getWriter(getPrimaryDisplayId()); + const auto& [layerStatus, layer] = + mComposerClient->createLayer(getPrimaryDisplayId(), kBufferSlotCount, &writer); + EXPECT_TRUE(layerStatus.isOk()); + const auto& [status, properties] = mComposerClient->getOverlaySupport(); + if (!status.isOk() && status.getExceptionCode() == EX_SERVICE_SPECIFIC && + status.getServiceSpecificError() == IComposerClient::EX_UNSUPPORTED) { + GTEST_SUCCEED() << "getOverlaySupport is not supported"; + return; + } + ASSERT_TRUE(status.isOk()); + + // TODO (b/362319189): add Lut VTS enforcement + if (!properties.lutProperties) { + int32_t size = 7; + size_t bufferSize = static_cast(size) * sizeof(float); + int32_t fd = ashmem_create_region("lut_shared_mem", bufferSize); + void* ptr = mmap(nullptr, bufferSize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + std::vector buffers = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}; + memcpy(ptr, buffers.data(), bufferSize); + munmap(ptr, bufferSize); + Luts luts; + luts.offsets = {0}; + luts.lutProperties = { + {LutProperties::Dimension::ONE_D, size, {LutProperties::SamplingKey::RGB}}}; + luts.pfd = ndk::ScopedFileDescriptor(fd); + + writer.setLayerLuts(getPrimaryDisplayId(), layer, luts); + writer.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp, + VtsComposerClient::kNoFrameIntervalNs); + execute(); + // change to client composition + ASSERT_FALSE(mReader.takeChangedCompositionTypes(getPrimaryDisplayId()).empty()); + ASSERT_TRUE(mReader.takeErrors().empty()); + } +} + GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsComposerAidlCommandTest); INSTANTIATE_TEST_SUITE_P( PerInstance, GraphicsComposerAidlCommandTest, @@ -3354,6 +3403,11 @@ INSTANTIATE_TEST_SUITE_P( PerInstance, GraphicsComposerAidlCommandV3Test, testing::ValuesIn(::android::getAidlHalInstanceNames(IComposer::descriptor)), ::android::PrintInstanceNameToString); +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsComposerAidlCommandV4Test); +INSTANTIATE_TEST_SUITE_P( + PerInstance, GraphicsComposerAidlCommandV4Test, + testing::ValuesIn(::android::getAidlHalInstanceNames(IComposer::descriptor)), + ::android::PrintInstanceNameToString); } // namespace aidl::android::hardware::graphics::composer3::vts int main(int argc, char** argv) {