[hwc-batching] AIDL changes for HWC command batching support.

This CL adds the new aidl/apis for HWC command batching feature.

Bug: 290685621
Test: atest VtsHalGraphicsComposer3_TargetTest
      atest PerInstance/GraphicsComposerAidlBatchedCommandTest
Change-Id: I9e8a8afefb03e04a4cd4d8db36d72e29d30e975f
This commit is contained in:
Manali Bhutiyani 2023-11-11 06:16:24 +00:00
parent 6391202a3b
commit 38565ccd51
6 changed files with 168 additions and 0 deletions

View file

@ -55,4 +55,6 @@ parcelable LayerCommand {
@nullable android.hardware.graphics.composer3.PerFrameMetadataBlob[] perFrameMetadataBlob;
@nullable android.hardware.graphics.common.Rect[] blockingRegion;
@nullable int[] bufferSlotsToClear;
android.hardware.graphics.composer3.LayerLifecycleBatchCommandType layerLifecycleBatchCommandType;
int newBufferSlotCount;
}

View file

@ -0,0 +1,40 @@
/**
* Copyright (c) 2023, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.graphics.composer3;
@Backing(type="int") @VintfStability
enum LayerLifecycleBatchCommandType {
MODIFY = 0,
CREATE = 1,
DESTROY = 2,
}

View file

@ -23,6 +23,7 @@ import android.hardware.graphics.common.Rect;
import android.hardware.graphics.composer3.Buffer;
import android.hardware.graphics.composer3.Color;
import android.hardware.graphics.composer3.LayerBrightness;
import android.hardware.graphics.composer3.LayerLifecycleBatchCommandType;
import android.hardware.graphics.composer3.ParcelableBlendMode;
import android.hardware.graphics.composer3.ParcelableComposition;
import android.hardware.graphics.composer3.ParcelableDataspace;
@ -265,4 +266,17 @@ parcelable LayerCommand {
* be freed.
*/
@nullable int[] bufferSlotsToClear;
/**
* Specifies if this layer command is on type modify, create or destroy.
* This command is replacing the older IComposerClient.createLayer and destroyLayer
* and making it more efficient with reduced aidls to the HAL.
* The HAL will report the errors by setting CommandResultPayload::CommandError.
*/
LayerLifecycleBatchCommandType layerLifecycleBatchCommandType;
/**
* Specifies the number of buffer slot to be reserved.
*/
int newBufferSlotCount;
}

View file

@ -0,0 +1,39 @@
/**
* Copyright (c) 2023, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.graphics.composer3;
/**
* Possible batch command types for a given layer.
*/
@VintfStability
@Backing(type="int")
enum LayerLifecycleBatchCommandType {
/**
* Layer attributes are being modified for already created layer.
*/
MODIFY = 0,
/**
* This indicates that the current LayerCommand should also create the layer,
* before processing the other attributes in the LayerCommand.
*/
CREATE = 1,
/**
* This indicates that the current LayerCommand should also destroyes the layer,
* after processing the other attributes in the LayerCommand.
*/
DESTROY = 2,
}

View file

@ -29,6 +29,7 @@
#include <aidl/android/hardware/graphics/composer3/Composition.h>
#include <aidl/android/hardware/graphics/composer3/DisplayBrightness.h>
#include <aidl/android/hardware/graphics/composer3/LayerBrightness.h>
#include <aidl/android/hardware/graphics/composer3/LayerLifecycleBatchCommandType.h>
#include <aidl/android/hardware/graphics/composer3/PerFrameMetadata.h>
#include <aidl/android/hardware/graphics/composer3/PerFrameMetadataBlob.h>
@ -99,6 +100,15 @@ class ComposerClientWriter final {
getBufferCommand(slot, buffer, releaseFence));
}
void setLayerLifecycleBatchCommandType(int64_t display, int64_t layer,
LayerLifecycleBatchCommandType cmd) {
getLayerCommand(display, layer).layerLifecycleBatchCommandType = cmd;
}
void setNewBufferSlotCount(int64_t display, int64_t layer, int32_t newBufferSlotToCount) {
getLayerCommand(display, layer).newBufferSlotCount = newBufferSlotToCount;
}
void validateDisplay(int64_t display,
std::optional<ClockMonotonicTimestamp> expectedPresentTime,
int32_t frameIntervalNs) {

View file

@ -2913,6 +2913,69 @@ TEST_P(GraphicsComposerAidlCommandTest, MultiThreadedPresent) {
}
}
class GraphicsComposerAidlBatchedCommandTest : public GraphicsComposerAidlCommandTest {
protected:
void SetUp() override {
GraphicsComposerAidlCommandTest::SetUp();
if (getInterfaceVersion() <= 2) {
GTEST_SKIP() << "Device interface version is expected to be >= 3";
}
}
void TearDown() override {
const auto errors = mReader.takeErrors();
ASSERT_TRUE(mReader.takeErrors().empty());
ASSERT_NO_FATAL_FAILURE(GraphicsComposerAidlTest::TearDown());
}
};
TEST_P(GraphicsComposerAidlBatchedCommandTest, CreateBatchedCommand) {
auto& writer = getWriter(getPrimaryDisplayId());
int64_t layer = 5;
writer.setLayerLifecycleBatchCommandType(getPrimaryDisplayId(), layer,
LayerLifecycleBatchCommandType::CREATE);
writer.setNewBufferSlotCount(getPrimaryDisplayId(), layer, 1);
writer.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
VtsComposerClient::kNoFrameIntervalNs);
execute();
ASSERT_TRUE(mReader.takeErrors().empty());
}
TEST_P(GraphicsComposerAidlBatchedCommandTest, DestroyBatchedCommand) {
auto& writer = getWriter(getPrimaryDisplayId());
int64_t layer = 5;
writer.setLayerLifecycleBatchCommandType(getPrimaryDisplayId(), layer,
LayerLifecycleBatchCommandType::CREATE);
writer.setNewBufferSlotCount(getPrimaryDisplayId(), layer, 1);
writer.validateDisplay(getPrimaryDisplayId(), ComposerClientWriter::kNoTimestamp,
VtsComposerClient::kNoFrameIntervalNs);
execute();
ASSERT_TRUE(mReader.takeErrors().empty());
writer.setLayerLifecycleBatchCommandType(getPrimaryDisplayId(), layer,
LayerLifecycleBatchCommandType::DESTROY);
layer++;
writer.setLayerLifecycleBatchCommandType(getPrimaryDisplayId(), layer,
LayerLifecycleBatchCommandType::CREATE);
writer.setNewBufferSlotCount(getPrimaryDisplayId(), layer, 1);
execute();
ASSERT_TRUE(mReader.takeErrors().empty());
}
TEST_P(GraphicsComposerAidlBatchedCommandTest, NoCreateDestroyBatchedCommandIncorrectLayer) {
auto& writer = getWriter(getPrimaryDisplayId());
int64_t layer = 5;
writer.setLayerLifecycleBatchCommandType(getPrimaryDisplayId(), layer,
LayerLifecycleBatchCommandType::DESTROY);
execute();
const auto errors = mReader.takeErrors();
ASSERT_TRUE(errors.size() == 1 && errors[0].errorCode == IComposerClient::EX_BAD_LAYER);
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsComposerAidlBatchedCommandTest);
INSTANTIATE_TEST_SUITE_P(
PerInstance, GraphicsComposerAidlBatchedCommandTest,
testing::ValuesIn(::android::getAidlHalInstanceNames(IComposer::descriptor)),
::android::PrintInstanceNameToString);
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsComposerAidlCommandTest);
INSTANTIATE_TEST_SUITE_P(
PerInstance, GraphicsComposerAidlCommandTest,