mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-22 10:17:01 +08:00
refactor: improve creating 48b resources
Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
5535ef3049
commit
d7b6f11ced
@@ -176,6 +176,8 @@ class GfxCoreHelper {
|
||||
virtual bool areSecondaryContextsSupported() const = 0;
|
||||
virtual uint32_t getContextGroupContextsCount() const = 0;
|
||||
|
||||
virtual bool is48ResourceNeededForCmdBuffer() const = 0;
|
||||
|
||||
virtual ~GfxCoreHelper() = default;
|
||||
|
||||
protected:
|
||||
@@ -390,6 +392,8 @@ class GfxCoreHelperHw : public GfxCoreHelper {
|
||||
bool areSecondaryContextsSupported() const override;
|
||||
uint32_t getContextGroupContextsCount() const override;
|
||||
|
||||
bool is48ResourceNeededForCmdBuffer() const override;
|
||||
|
||||
~GfxCoreHelperHw() override = default;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -730,4 +730,9 @@ uint32_t GfxCoreHelperHw<GfxFamily>::getContextGroupContextsCount() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
bool GfxCoreHelperHw<GfxFamily>::is48ResourceNeededForCmdBuffer() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -476,8 +476,11 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
||||
}
|
||||
|
||||
switch (properties.allocationType) {
|
||||
case AllocationType::deferredTasksList:
|
||||
case AllocationType::commandBuffer:
|
||||
case AllocationType::ringBuffer:
|
||||
allocationData.flags.resource48Bit = helper.is48ResourceNeededForCmdBuffer();
|
||||
break;
|
||||
case AllocationType::deferredTasksList:
|
||||
case AllocationType::image:
|
||||
case AllocationType::indirectObjectHeap:
|
||||
case AllocationType::instructionHeap:
|
||||
@@ -495,7 +498,6 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
||||
case AllocationType::timestampPacketTagBuffer:
|
||||
case AllocationType::debugModuleArea:
|
||||
case AllocationType::gpuTimestampDeviceBuffer:
|
||||
case AllocationType::ringBuffer:
|
||||
case AllocationType::semaphoreBuffer:
|
||||
allocationData.flags.resource48Bit = true;
|
||||
break;
|
||||
|
||||
@@ -1610,3 +1610,7 @@ TEST_F(GfxCoreHelperTest, givenContextGroupEnabledWithDebugKeyWhenContextGroupCo
|
||||
EXPECT_EQ(2u, gfxCoreHelper.getContextGroupContextsCount());
|
||||
EXPECT_TRUE(gfxCoreHelper.areSecondaryContextsSupported());
|
||||
}
|
||||
|
||||
HWTEST_F(GfxCoreHelperTest, whenAskingIf48bResourceNeededForCmdBufferThenReturnTrue) {
|
||||
EXPECT_TRUE(getHelper<GfxCoreHelper>().is48ResourceNeededForCmdBuffer());
|
||||
}
|
||||
|
||||
@@ -1034,6 +1034,27 @@ TEST_P(MemoryManagerGetAlloctionDataHaveToBeForcedTo48BitTest, givenAllocationTy
|
||||
EXPECT_TRUE(allocationData.flags.resource48Bit);
|
||||
}
|
||||
|
||||
using MemoryManagerGetAlloctionDataOptionallyForcedTo48BitTest = testing::TestWithParam<std::tuple<AllocationType, bool>>;
|
||||
|
||||
TEST_P(MemoryManagerGetAlloctionDataOptionallyForcedTo48BitTest, givenAllocationTypesOptionalFor48BitThenAllocationDataResource48BitIsSet) {
|
||||
MockExecutionEnvironment mockExecutionEnvironment{};
|
||||
auto &gfxCoreHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper<GfxCoreHelper>();
|
||||
|
||||
AllocationType allocationType;
|
||||
bool propertiesFlag48Bit;
|
||||
|
||||
std::tie(allocationType, propertiesFlag48Bit) = GetParam();
|
||||
|
||||
AllocationProperties properties(mockRootDeviceIndex, 0, allocationType, mockDeviceBitfield);
|
||||
properties.flags.resource48Bit = propertiesFlag48Bit;
|
||||
|
||||
AllocationData allocationData;
|
||||
MockMemoryManager mockMemoryManager;
|
||||
mockMemoryManager.getAllocationData(allocationData, properties, nullptr, mockMemoryManager.createStorageInfoFromProperties(properties));
|
||||
|
||||
EXPECT_EQ(gfxCoreHelper.is48ResourceNeededForCmdBuffer(), allocationData.flags.resource48Bit);
|
||||
}
|
||||
|
||||
using MemoryManagerGetAlloctionDataHaveNotToBeForcedTo48BitTest = testing::TestWithParam<std::tuple<AllocationType, bool>>;
|
||||
|
||||
TEST_P(MemoryManagerGetAlloctionDataHaveNotToBeForcedTo48BitTest, givenAllocationTypesHaveNotToBeForcedTo48BitThenAllocationDataResource48BitIsSetProperly) {
|
||||
@@ -1052,7 +1073,6 @@ TEST_P(MemoryManagerGetAlloctionDataHaveNotToBeForcedTo48BitTest, givenAllocatio
|
||||
}
|
||||
|
||||
static const AllocationType allocationHaveToBeForcedTo48Bit[] = {
|
||||
AllocationType::commandBuffer,
|
||||
AllocationType::image,
|
||||
AllocationType::indirectObjectHeap,
|
||||
AllocationType::instructionHeap,
|
||||
@@ -1066,11 +1086,15 @@ static const AllocationType allocationHaveToBeForcedTo48Bit[] = {
|
||||
AllocationType::sharedResourceCopy,
|
||||
AllocationType::surfaceStateHeap,
|
||||
AllocationType::timestampPacketTagBuffer,
|
||||
AllocationType::ringBuffer,
|
||||
AllocationType::semaphoreBuffer,
|
||||
AllocationType::deferredTasksList,
|
||||
};
|
||||
|
||||
static const AllocationType allocationsOptionallyForcedTo48Bit[] = {
|
||||
AllocationType::commandBuffer,
|
||||
AllocationType::ringBuffer,
|
||||
};
|
||||
|
||||
static const AllocationType allocationHaveNotToBeForcedTo48Bit[] = {
|
||||
AllocationType::buffer,
|
||||
AllocationType::bufferHostMemory,
|
||||
@@ -1105,3 +1129,9 @@ INSTANTIATE_TEST_CASE_P(NotForceTo48Bit,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(allocationHaveNotToBeForcedTo48Bit),
|
||||
::testing::Bool()));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(OptionallyForceTo48Bit,
|
||||
MemoryManagerGetAlloctionDataOptionallyForcedTo48BitTest,
|
||||
::testing::Combine(
|
||||
::testing::ValuesIn(allocationsOptionallyForcedTo48Bit),
|
||||
::testing::Bool()));
|
||||
|
||||
Reference in New Issue
Block a user