[Lut HAL] add Lut VTS enforcement

Bug: 362319189
Bug: 358422255
Test: VtsHalGraphicsComposer3_TargetTest

Change-Id: I41b279d362715c32a2d0ee6021c0f1f94b612d64
This commit is contained in:
Sally Qi
2024-10-15 12:53:51 -07:00
parent 432d3f552a
commit 2d94f52b18
3 changed files with 61 additions and 3 deletions

View File

@@ -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.

View File

@@ -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;
}

View File

@@ -28,6 +28,7 @@
#include <android/hardware/graphics/composer3/ComposerClientReader.h>
#include <android/hardware/graphics/composer3/ComposerClientWriter.h>
#include <binder/ProcessState.h>
#include <cutils/ashmem.h>
#include <gtest/gtest.h>
#include <ui/Fence.h>
#include <ui/GraphicBuffer.h>
@@ -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_t>(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<float> 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) {