diff --git a/shared/source/command_stream/stream_properties.cpp b/shared/source/command_stream/stream_properties.cpp index e6b7815bfb..f4e8de75e2 100644 --- a/shared/source/command_stream/stream_properties.cpp +++ b/shared/source/command_stream/stream_properties.cpp @@ -349,9 +349,7 @@ void StateBaseAddressProperties::setPropertiesBindingTableSurfaceState(int64_t b DEBUG_BREAK_IF(!this->propertiesSupportLoaded); this->bindingTablePoolBaseAddress.isDirty = false; - this->bindingTablePoolSize.isDirty = false; this->surfaceStateBaseAddress.isDirty = false; - this->surfaceStateSize.isDirty = false; if (this->stateBaseAddressPropertiesSupport.bindingTablePoolBaseAddress) { this->bindingTablePoolBaseAddress.set(bindingTablePoolBaseAddress); @@ -365,7 +363,6 @@ void StateBaseAddressProperties::setPropertiesSurfaceState(int64_t surfaceStateB DEBUG_BREAK_IF(!this->propertiesSupportLoaded); this->surfaceStateBaseAddress.isDirty = false; - this->surfaceStateSize.isDirty = false; this->surfaceStateBaseAddress.set(surfaceStateBaseAddress); this->surfaceStateSize.set(surfaceStateSize); @@ -373,14 +370,12 @@ void StateBaseAddressProperties::setPropertiesSurfaceState(int64_t surfaceStateB void StateBaseAddressProperties::setPropertiesDynamicState(int64_t dynamicStateBaseAddress, size_t dynamicStateSize) { this->dynamicStateBaseAddress.isDirty = false; - this->dynamicStateSize.isDirty = false; this->dynamicStateBaseAddress.set(dynamicStateBaseAddress); this->dynamicStateSize.set(dynamicStateSize); } void StateBaseAddressProperties::setPropertiesIndirectState(int64_t indirectObjectBaseAddress, size_t indirectObjectSize) { this->indirectObjectBaseAddress.isDirty = false; - this->indirectObjectSize.isDirty = false; this->indirectObjectBaseAddress.set(indirectObjectBaseAddress); this->indirectObjectSize.set(indirectObjectSize); } @@ -457,7 +452,6 @@ void StateBaseAddressProperties::copyPropertiesStatelessMocs(const StateBaseAddr void StateBaseAddressProperties::copyPropertiesStatelessMocsIndirectState(const StateBaseAddressProperties &properties) { this->statelessMocs.isDirty = false; this->indirectObjectBaseAddress.isDirty = false; - this->indirectObjectSize.isDirty = false; this->statelessMocs.set(properties.statelessMocs.value); this->indirectObjectBaseAddress.set(properties.indirectObjectBaseAddress.value); @@ -466,21 +460,17 @@ void StateBaseAddressProperties::copyPropertiesStatelessMocsIndirectState(const bool StateBaseAddressProperties::isDirty() const { return globalAtomics.isDirty || statelessMocs.isDirty || - bindingTablePoolBaseAddress.isDirty || bindingTablePoolSize.isDirty || - surfaceStateBaseAddress.isDirty || surfaceStateSize.isDirty || - dynamicStateBaseAddress.isDirty || dynamicStateSize.isDirty || - indirectObjectBaseAddress.isDirty || indirectObjectSize.isDirty; + bindingTablePoolBaseAddress.isDirty || + surfaceStateBaseAddress.isDirty || + dynamicStateBaseAddress.isDirty || + indirectObjectBaseAddress.isDirty; } void StateBaseAddressProperties::clearIsDirty() { globalAtomics.isDirty = false; statelessMocs.isDirty = false; bindingTablePoolBaseAddress.isDirty = false; - bindingTablePoolSize.isDirty = false; surfaceStateBaseAddress.isDirty = false; - surfaceStateSize.isDirty = false; dynamicStateBaseAddress.isDirty = false; - dynamicStateSize.isDirty = false; indirectObjectBaseAddress.isDirty = false; - indirectObjectSize.isDirty = false; } diff --git a/shared/source/command_stream/stream_property.h b/shared/source/command_stream/stream_property.h index 279419e252..c8a4cd1097 100644 --- a/shared/source/command_stream/stream_property.h +++ b/shared/source/command_stream/stream_property.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -12,23 +12,29 @@ namespace NEO { -template +template struct StreamPropertyType { static constexpr Type initValue = static_cast(-1); Type value = initValue; bool isDirty = false; void set(Type newValue) { - if ((value != newValue) && (newValue != initValue)) { - value = newValue; - isDirty = true; + if constexpr (fullStateProperty) { + if ((value != newValue) && (newValue != initValue)) { + value = newValue; + isDirty = true; + } + } else { + if (newValue != initValue) { + value = newValue; + } } } }; -using StreamProperty32 = StreamPropertyType; -using StreamProperty64 = StreamPropertyType; -using StreamPropertySizeT = StreamPropertyType; +using StreamProperty32 = StreamPropertyType; +using StreamProperty64 = StreamPropertyType; +using StreamPropertySizeT = StreamPropertyType; using StreamProperty = StreamProperty32; diff --git a/shared/test/unit_test/command_stream/stream_properties_tests_common.cpp b/shared/test/unit_test/command_stream/stream_properties_tests_common.cpp index c885d2e68f..831c6ac60d 100644 --- a/shared/test/unit_test/command_stream/stream_properties_tests_common.cpp +++ b/shared/test/unit_test/command_stream/stream_properties_tests_common.cpp @@ -829,7 +829,7 @@ TEST(StreamPropertiesTests, givenStateBaseAddressSupportFlagStateWhenSettingProp EXPECT_FALSE(sbaProperties.globalAtomics.isDirty); EXPECT_FALSE(sbaProperties.statelessMocs.isDirty); EXPECT_TRUE(sbaProperties.bindingTablePoolBaseAddress.isDirty); - EXPECT_TRUE(sbaProperties.bindingTablePoolSize.isDirty); + EXPECT_FALSE(sbaProperties.bindingTablePoolSize.isDirty); EXPECT_EQ(1, sbaProperties.globalAtomics.value); EXPECT_EQ(1, sbaProperties.statelessMocs.value); @@ -849,7 +849,7 @@ TEST(StreamPropertiesTests, givenStateBaseAddressSupportFlagStateWhenSettingProp EXPECT_EQ(2u, sbaProperties.bindingTablePoolSize.value); sbaProperties.setPropertiesAll(false, 0, 3, 3, -1, -1, -1, -1, -1, -1); - EXPECT_TRUE(sbaProperties.isDirty()); + EXPECT_FALSE(sbaProperties.isDirty()); EXPECT_EQ(0, sbaProperties.globalAtomics.value); EXPECT_EQ(0, sbaProperties.statelessMocs.value); @@ -919,11 +919,11 @@ TEST(StreamPropertiesTests, givenStateBaseAddressCommonBaseAddressAndSizeWhenSet EXPECT_FALSE(sbaProperties.indirectObjectSize.isDirty); sbaProperties.setPropertiesAll(false, -1, -1, 10, 10, 20, -1, -1, -1, -1); - EXPECT_TRUE(sbaProperties.isDirty()); + EXPECT_FALSE(sbaProperties.isDirty()); EXPECT_EQ(20u, sbaProperties.surfaceStateSize.value); EXPECT_FALSE(sbaProperties.surfaceStateBaseAddress.isDirty); - EXPECT_TRUE(sbaProperties.surfaceStateSize.isDirty); + EXPECT_FALSE(sbaProperties.surfaceStateSize.isDirty); EXPECT_FALSE(sbaProperties.dynamicStateBaseAddress.isDirty); EXPECT_FALSE(sbaProperties.dynamicStateSize.isDirty); EXPECT_FALSE(sbaProperties.indirectObjectBaseAddress.isDirty); @@ -941,13 +941,13 @@ TEST(StreamPropertiesTests, givenStateBaseAddressCommonBaseAddressAndSizeWhenSet EXPECT_FALSE(sbaProperties.indirectObjectSize.isDirty); sbaProperties.setPropertiesAll(false, -1, -1, 10, 10, 20, 30, 40, -1, -1); - EXPECT_TRUE(sbaProperties.isDirty()); + EXPECT_FALSE(sbaProperties.isDirty()); EXPECT_EQ(40u, sbaProperties.dynamicStateSize.value); EXPECT_FALSE(sbaProperties.surfaceStateBaseAddress.isDirty); EXPECT_FALSE(sbaProperties.surfaceStateSize.isDirty); EXPECT_FALSE(sbaProperties.dynamicStateBaseAddress.isDirty); - EXPECT_TRUE(sbaProperties.dynamicStateSize.isDirty); + EXPECT_FALSE(sbaProperties.dynamicStateSize.isDirty); EXPECT_FALSE(sbaProperties.indirectObjectBaseAddress.isDirty); EXPECT_FALSE(sbaProperties.indirectObjectSize.isDirty); @@ -963,7 +963,7 @@ TEST(StreamPropertiesTests, givenStateBaseAddressCommonBaseAddressAndSizeWhenSet EXPECT_FALSE(sbaProperties.indirectObjectSize.isDirty); sbaProperties.setPropertiesAll(false, -1, -1, 10, 10, 20, 30, 40, 50, 60); - EXPECT_TRUE(sbaProperties.isDirty()); + EXPECT_FALSE(sbaProperties.isDirty()); EXPECT_EQ(60u, sbaProperties.indirectObjectSize.value); EXPECT_FALSE(sbaProperties.surfaceStateBaseAddress.isDirty); @@ -971,7 +971,7 @@ TEST(StreamPropertiesTests, givenStateBaseAddressCommonBaseAddressAndSizeWhenSet EXPECT_FALSE(sbaProperties.dynamicStateBaseAddress.isDirty); EXPECT_FALSE(sbaProperties.dynamicStateSize.isDirty); EXPECT_FALSE(sbaProperties.indirectObjectBaseAddress.isDirty); - EXPECT_TRUE(sbaProperties.indirectObjectSize.isDirty); + EXPECT_FALSE(sbaProperties.indirectObjectSize.isDirty); sbaProperties.setPropertiesAll(false, -1, -1, 10, 10, 20, 30, 40, 50, 60); EXPECT_FALSE(sbaProperties.isDirty()); @@ -1132,7 +1132,7 @@ TEST(StreamPropertiesTests, givenIndirectHeapAndStatelessMocsStateBaseAddressPro indirectObjectSize = 2; sbaProperties.setPropertiesIndirectState(indirectObjectBaseAddress, indirectObjectSize); sbaPropertiesCopy.copyPropertiesStatelessMocsIndirectState(sbaProperties); - EXPECT_TRUE(sbaPropertiesCopy.isDirty()); + EXPECT_FALSE(sbaPropertiesCopy.isDirty()); EXPECT_EQ(1, sbaPropertiesCopy.statelessMocs.value); EXPECT_EQ(2, sbaPropertiesCopy.indirectObjectBaseAddress.value); EXPECT_EQ(2u, sbaPropertiesCopy.indirectObjectSize.value); @@ -1200,6 +1200,24 @@ TEST(StreamPropertiesTests, givenBindingTableAndSurfaceStateBaseAddressStateBase EXPECT_EQ(1u, sbaProperties.bindingTablePoolSize.value); EXPECT_EQ(1, sbaProperties.surfaceStateBaseAddress.value); EXPECT_EQ(1u, sbaProperties.surfaceStateSize.value); + + surfaceStateSize = 2; + bindingTablePoolSize = 2; + sbaProperties.setPropertiesBindingTableSurfaceState(bindingTablePoolBaseAddress, bindingTablePoolSize, surfaceStateBaseAddress, surfaceStateSize); + EXPECT_FALSE(sbaProperties.isDirty()); + EXPECT_EQ(1, sbaProperties.bindingTablePoolBaseAddress.value); + EXPECT_EQ(2u, sbaProperties.bindingTablePoolSize.value); + EXPECT_EQ(1, sbaProperties.surfaceStateBaseAddress.value); + EXPECT_EQ(2u, sbaProperties.surfaceStateSize.value); + + bindingTablePoolBaseAddress = 2; + surfaceStateBaseAddress = 2; + sbaProperties.setPropertiesBindingTableSurfaceState(bindingTablePoolBaseAddress, bindingTablePoolSize, surfaceStateBaseAddress, surfaceStateSize); + EXPECT_TRUE(sbaProperties.isDirty()); + EXPECT_EQ(2, sbaProperties.bindingTablePoolBaseAddress.value); + EXPECT_EQ(2u, sbaProperties.bindingTablePoolSize.value); + EXPECT_EQ(2, sbaProperties.surfaceStateBaseAddress.value); + EXPECT_EQ(2u, sbaProperties.surfaceStateSize.value); } TEST(StreamPropertiesTests, givenSurfaceStateBaseAddressStateBaseAddressPropertyWhenSettingPropertyAndCheckIfSupportedThenExpectCorrectState) { @@ -1230,6 +1248,18 @@ TEST(StreamPropertiesTests, givenSurfaceStateBaseAddressStateBaseAddressProperty EXPECT_FALSE(sbaProperties.isDirty()); EXPECT_EQ(1, sbaProperties.surfaceStateBaseAddress.value); EXPECT_EQ(1u, sbaProperties.surfaceStateSize.value); + + surfaceStateSize = 2; + sbaProperties.setPropertiesSurfaceState(surfaceStateBaseAddress, surfaceStateSize); + EXPECT_FALSE(sbaProperties.isDirty()); + EXPECT_EQ(1, sbaProperties.surfaceStateBaseAddress.value); + EXPECT_EQ(2u, sbaProperties.surfaceStateSize.value); + + surfaceStateBaseAddress = 2; + sbaProperties.setPropertiesSurfaceState(surfaceStateBaseAddress, surfaceStateSize); + EXPECT_TRUE(sbaProperties.isDirty()); + EXPECT_EQ(2, sbaProperties.surfaceStateBaseAddress.value); + EXPECT_EQ(2u, sbaProperties.surfaceStateSize.value); } TEST(StreamPropertiesTests, givenDynamicStateBaseAddressStateBaseAddressPropertyWhenSettingPropertyAndCheckIfSupportedThenExpectCorrectState) { @@ -1262,7 +1292,7 @@ TEST(StreamPropertiesTests, givenDynamicStateBaseAddressStateBaseAddressProperty dynamicStateSize = 2; sbaProperties.setPropertiesDynamicState(dynamicStateBaseAddress, dynamicStateSize); - EXPECT_TRUE(sbaProperties.isDirty()); + EXPECT_FALSE(sbaProperties.isDirty()); EXPECT_EQ(1, sbaProperties.dynamicStateBaseAddress.value); EXPECT_EQ(2u, sbaProperties.dynamicStateSize.value); @@ -1303,7 +1333,7 @@ TEST(StreamPropertiesTests, givenIndirectObjectBaseAddressStateBaseAddressProper indirectObjectSize = 2; sbaProperties.setPropertiesIndirectState(indirectObjectBaseAddress, indirectObjectSize); - EXPECT_TRUE(sbaProperties.isDirty()); + EXPECT_FALSE(sbaProperties.isDirty()); EXPECT_EQ(1, sbaProperties.indirectObjectBaseAddress.value); EXPECT_EQ(2u, sbaProperties.indirectObjectSize.value); diff --git a/shared/test/unit_test/command_stream/stream_properties_tests_common.h b/shared/test/unit_test/command_stream/stream_properties_tests_common.h index 0abd170b9b..0588142cb4 100644 --- a/shared/test/unit_test/command_stream/stream_properties_tests_common.h +++ b/shared/test/unit_test/command_stream/stream_properties_tests_common.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -16,10 +16,10 @@ struct FrontEndProperties; struct PipelineSelectProperties; struct StateComputeModeProperties; -template +template struct StreamPropertyType; -using StreamProperty = StreamPropertyType; +using StreamProperty = StreamPropertyType; std::vector getAllStateComputeModeProperties(StateComputeModeProperties &properties); std::vector getAllFrontEndProperties(FrontEndProperties &properties);