2020-10-07 20:22:26 +08:00
|
|
|
/*
|
2023-01-21 01:45:04 +08:00
|
|
|
* Copyright (C) 2021-2023 Intel Corporation
|
2020-10-07 20:22:26 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2023-03-01 05:08:09 +08:00
|
|
|
#include "shared/source/command_container/command_encoder.h"
|
2023-01-21 01:45:04 +08:00
|
|
|
#include "shared/source/command_container/encode_surface_state.h"
|
2022-01-13 00:57:42 +08:00
|
|
|
#include "shared/source/helpers/preamble.h"
|
|
|
|
#include "shared/test/common/mocks/mock_command_stream_receiver.h"
|
|
|
|
#include "shared/test/common/mocks/mock_device.h"
|
2022-06-30 03:17:47 +08:00
|
|
|
#include "shared/test/common/test_macros/hw_test.h"
|
2020-10-07 20:22:26 +08:00
|
|
|
|
|
|
|
using namespace NEO;
|
|
|
|
|
|
|
|
using Gen12LpCommandEncodeTest = testing::Test;
|
|
|
|
GEN12LPTEST_F(Gen12LpCommandEncodeTest, givenGen12LpPlatformWhenDoBindingTablePrefetchIsCalledThenReturnsTrue) {
|
|
|
|
EXPECT_FALSE(EncodeSurfaceState<FamilyType>::doBindingTablePrefetch());
|
|
|
|
}
|
2022-01-13 00:57:42 +08:00
|
|
|
|
|
|
|
template <bool rcs>
|
|
|
|
class MyCommandStreamReceiverMock : public MockCommandStreamReceiver {
|
|
|
|
public:
|
|
|
|
MyCommandStreamReceiverMock(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex, const DeviceBitfield deviceBitfield) : MockCommandStreamReceiver(executionEnvironment, rootDeviceIndex, deviceBitfield) {}
|
|
|
|
bool isRcs() const override {
|
|
|
|
return rcs;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-09-08 22:13:07 +08:00
|
|
|
GEN12LPTEST_F(Gen12LpCommandEncodeTest, WhenDefaultEngineIsRcsAnd3DPipelineSelectWaRequiredThenAdditionalPipelineSelectSizeEqualsTwoPipelineSelectSize) {
|
2022-01-13 00:57:42 +08:00
|
|
|
MockDevice device;
|
|
|
|
auto csr = std::make_unique<MyCommandStreamReceiverMock<true>>(*device.getExecutionEnvironment(), 0, device.getDeviceBitfield());
|
|
|
|
auto oldCsr = device.getDefaultEngine().commandStreamReceiver;
|
|
|
|
device.getDefaultEngine().commandStreamReceiver = csr.get();
|
2022-09-08 22:13:07 +08:00
|
|
|
|
2023-01-23 21:20:47 +08:00
|
|
|
const auto &productHelper = device.getProductHelper();
|
2022-12-13 00:43:41 +08:00
|
|
|
if (productHelper.is3DPipelineSelectWARequired()) {
|
2023-01-26 11:58:18 +08:00
|
|
|
EXPECT_EQ(2 * PreambleHelper<FamilyType>::getCmdSizeForPipelineSelect(device.getRootDeviceEnvironment()), EncodeWA<FamilyType>::getAdditionalPipelineSelectSize(device, csr->isRcs()));
|
2022-09-08 22:13:07 +08:00
|
|
|
} else {
|
|
|
|
EXPECT_EQ(0u, EncodeWA<FamilyType>::getAdditionalPipelineSelectSize(device, csr->isRcs()));
|
|
|
|
}
|
|
|
|
|
2022-01-13 00:57:42 +08:00
|
|
|
device.getDefaultEngine().commandStreamReceiver = oldCsr;
|
|
|
|
}
|
|
|
|
|
|
|
|
GEN12LPTEST_F(Gen12LpCommandEncodeTest, givenGen12LpPlatformWhenDefaultEngineIsNotRcsThenAdditionalPipelineSelectSizeEqualZero) {
|
|
|
|
MockDevice device;
|
|
|
|
auto csr = std::make_unique<MyCommandStreamReceiverMock<false>>(*device.getExecutionEnvironment(), 0, device.getDeviceBitfield());
|
|
|
|
auto oldCsr = device.getDefaultEngine().commandStreamReceiver;
|
|
|
|
device.getDefaultEngine().commandStreamReceiver = csr.get();
|
2022-08-17 22:58:27 +08:00
|
|
|
EXPECT_EQ(0u, EncodeWA<FamilyType>::getAdditionalPipelineSelectSize(device, csr->isRcs()));
|
2022-01-13 00:57:42 +08:00
|
|
|
device.getDefaultEngine().commandStreamReceiver = oldCsr;
|
2022-08-17 22:58:27 +08:00
|
|
|
}
|