Add check in allocateGraphicsMemory64kb to not use cpuPtr
when isRenderCompressed Related-To: NEO-4532 Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
This commit is contained in:
parent
4ce7c0e5f6
commit
e060536a32
|
@ -45,8 +45,10 @@ struct GmmTests : public MockExecutionEnvironmentGmmFixtureTest {
|
|||
void SetUp() override {
|
||||
MockExecutionEnvironmentGmmFixture::SetUp();
|
||||
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
|
||||
localPlatformDevice = rootDeviceEnvironment->getMutableHardwareInfo();
|
||||
}
|
||||
RootDeviceEnvironment *rootDeviceEnvironment = nullptr;
|
||||
HardwareInfo *localPlatformDevice = nullptr;
|
||||
};
|
||||
|
||||
TEST(GmmGlTests, givenGmmWhenAskedforCubeFaceIndexThenProperValueIsReturned) {
|
||||
|
@ -811,4 +813,70 @@ TEST(GmmHelperTest, givenValidGmmFunctionsWhenCreateGmmHelperWithoutOsInterfaceT
|
|||
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType);
|
||||
}
|
||||
|
||||
using GmmCompressionTest = GmmTests;
|
||||
TEST_F(GmmCompressionTest, givenEnabledAndPreferredE2ECWhenApplyingForBuffersThenSetValidFlags) {
|
||||
std::unique_ptr<Gmm> gmm(new Gmm(getGmmClientContext(), nullptr, 1, false));
|
||||
gmm->resourceParams = {};
|
||||
|
||||
localPlatformDevice->capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
|
||||
gmm->applyAuxFlagsForBuffer(true);
|
||||
EXPECT_EQ(1u, gmm->resourceParams.Flags.Info.RenderCompressed);
|
||||
EXPECT_EQ(1u, gmm->resourceParams.Flags.Gpu.CCS);
|
||||
EXPECT_EQ(1u, gmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
|
||||
EXPECT_TRUE(gmm->isRenderCompressed);
|
||||
}
|
||||
|
||||
TEST_F(GmmCompressionTest, givenDisabledE2ECAndEnabledDebugFlagWhenApplyingForBuffersThenSetValidFlags) {
|
||||
DebugManagerStateRestore restore;
|
||||
Gmm gmm(getGmmClientContext(), nullptr, 1, false);
|
||||
gmm.resourceParams = {};
|
||||
|
||||
DebugManager.flags.RenderCompressedBuffersEnabled.set(1);
|
||||
localPlatformDevice->capabilityTable.ftrRenderCompressedBuffers = false;
|
||||
|
||||
gmm.applyAuxFlagsForBuffer(true);
|
||||
EXPECT_EQ(1u, gmm.resourceParams.Flags.Info.RenderCompressed);
|
||||
EXPECT_EQ(1u, gmm.resourceParams.Flags.Gpu.CCS);
|
||||
EXPECT_EQ(1u, gmm.resourceParams.Flags.Gpu.UnifiedAuxSurface);
|
||||
EXPECT_TRUE(gmm.isRenderCompressed);
|
||||
|
||||
gmm.resourceParams = {};
|
||||
gmm.isRenderCompressed = false;
|
||||
DebugManager.flags.RenderCompressedBuffersEnabled.set(0);
|
||||
localPlatformDevice->capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
|
||||
gmm.applyAuxFlagsForBuffer(true);
|
||||
EXPECT_EQ(0u, gmm.resourceParams.Flags.Info.RenderCompressed);
|
||||
EXPECT_EQ(0u, gmm.resourceParams.Flags.Gpu.CCS);
|
||||
EXPECT_EQ(0u, gmm.resourceParams.Flags.Gpu.UnifiedAuxSurface);
|
||||
EXPECT_FALSE(gmm.isRenderCompressed);
|
||||
}
|
||||
|
||||
TEST_F(GmmCompressionTest, givenEnabledAndNotPreferredE2ECWhenApplyingForBuffersThenDontSetValidFlags) {
|
||||
std::unique_ptr<Gmm> gmm(new Gmm(getGmmClientContext(), nullptr, 1, false));
|
||||
gmm->resourceParams = {};
|
||||
|
||||
localPlatformDevice->capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
|
||||
gmm->applyAuxFlagsForBuffer(false);
|
||||
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.RenderCompressed);
|
||||
EXPECT_EQ(0u, gmm->resourceParams.Flags.Gpu.CCS);
|
||||
EXPECT_EQ(0u, gmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
|
||||
EXPECT_FALSE(gmm->isRenderCompressed);
|
||||
}
|
||||
|
||||
TEST_F(GmmCompressionTest, givenDisabledAndPreferredE2ECWhenApplyingForBuffersThenDontSetValidFlags) {
|
||||
std::unique_ptr<Gmm> gmm(new Gmm(getGmmClientContext(), nullptr, 1, false));
|
||||
gmm->resourceParams = {};
|
||||
|
||||
localPlatformDevice->capabilityTable.ftrRenderCompressedBuffers = false;
|
||||
|
||||
gmm->applyAuxFlagsForBuffer(true);
|
||||
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.RenderCompressed);
|
||||
EXPECT_EQ(0u, gmm->resourceParams.Flags.Gpu.CCS);
|
||||
EXPECT_EQ(0u, gmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
|
||||
EXPECT_FALSE(gmm->isRenderCompressed);
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
|
|
@ -18,9 +18,7 @@ class MockWddmMemoryManager : public MemoryManagerCreate<WddmMemoryManager> {
|
|||
using BaseClass = WddmMemoryManager;
|
||||
|
||||
public:
|
||||
using BaseClass::allocateGraphicsMemory64kb;
|
||||
using BaseClass::allocateGraphicsMemoryForNonSvmHostPtr;
|
||||
using BaseClass::allocateGraphicsMemoryInDevicePool;
|
||||
using BaseClass::allocateGraphicsMemoryWithGpuVa;
|
||||
using BaseClass::allocateGraphicsMemoryWithProperties;
|
||||
using BaseClass::allocateShareableMemory;
|
||||
|
@ -33,6 +31,18 @@ class MockWddmMemoryManager : public MemoryManagerCreate<WddmMemoryManager> {
|
|||
using MemoryManagerCreate<WddmMemoryManager>::MemoryManagerCreate;
|
||||
using BaseClass::getHugeGfxMemoryChunkSize;
|
||||
|
||||
GraphicsAllocation *allocateGraphicsMemory64kb(const AllocationData &allocationData) override {
|
||||
allocationGraphicsMemory64kbCreated = true;
|
||||
return BaseClass::allocateGraphicsMemory64kb(allocationData);
|
||||
}
|
||||
GraphicsAllocation *allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) override {
|
||||
if (allocateGraphicsMemoryInNonDevicePool) {
|
||||
status = AllocationStatus::RetryInNonDevicePool;
|
||||
return nullptr;
|
||||
}
|
||||
return BaseClass::allocateGraphicsMemoryInDevicePool(allocationData, status);
|
||||
}
|
||||
|
||||
size_t hugeGfxMemoryChunkSize = BaseClass::getHugeGfxMemoryChunkSize();
|
||||
size_t getHugeGfxMemoryChunkSize() const override { return hugeGfxMemoryChunkSize; }
|
||||
|
||||
|
@ -63,5 +73,7 @@ class MockWddmMemoryManager : public MemoryManagerCreate<WddmMemoryManager> {
|
|||
}
|
||||
|
||||
uint32_t freeGraphicsMemoryImplCalled = 0u;
|
||||
bool allocationGraphicsMemory64kbCreated = false;
|
||||
bool allocateGraphicsMemoryInNonDevicePool = false;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
#include "opencl/test/unit_test/mocks/mock_platform.h"
|
||||
#include "opencl/test/unit_test/os_interface/windows/mock_wddm_allocation.h"
|
||||
|
||||
#include "mock_gmm_client_context.h"
|
||||
|
||||
using namespace NEO;
|
||||
using namespace ::testing;
|
||||
|
||||
|
@ -679,6 +681,59 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerSizeZeroWhenCreateFromShared
|
|||
memoryManager->freeGraphicsMemory(gpuAllocation);
|
||||
}
|
||||
|
||||
HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenAllocateGraphicsMemoryWithSetAllocattionPropertisWithAllocationTypeBufferCompressedIsCalledThenIsRendeCompressedTrueAndGpuMappingIsSetWithGoodAddressRange) {
|
||||
void *ptr = reinterpret_cast<void *>(0x1001);
|
||||
auto size = MemoryConstants::pageSize;
|
||||
HardwareInfo hwInfo = *defaultHwInfo;
|
||||
hwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
rootDeviceEnvironment->setHwInfo(&hwInfo);
|
||||
|
||||
auto memoryManager = std::make_unique<MockWddmMemoryManager>(true, false, *executionEnvironment);
|
||||
memoryManager->allocateGraphicsMemoryInNonDevicePool = true;
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{mockRootDeviceIndex, true, size, GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, mockDeviceBitfield}, ptr);
|
||||
|
||||
auto gfxPartition = memoryManager->getGfxPartition(mockRootDeviceIndex);
|
||||
D3DGPU_VIRTUAL_ADDRESS standard64kbRangeMinimumAddress = gfxPartition->getHeapMinimalAddress(HeapIndex::HEAP_STANDARD64KB);
|
||||
D3DGPU_VIRTUAL_ADDRESS standard64kbRangeMaximumAddress = gfxPartition->getHeapLimit(HeapIndex::HEAP_STANDARD64KB);
|
||||
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_TRUE(memoryManager->allocationGraphicsMemory64kbCreated);
|
||||
EXPECT_TRUE(allocation->getDefaultGmm()->isRenderCompressed);
|
||||
if ((is32bit || rootDeviceEnvironment->isFullRangeSvm()) &&
|
||||
allocation->getDefaultGmm()->gmmResourceInfo->is64KBPageSuitable()) {
|
||||
EXPECT_GE(GmmHelper::decanonize(allocation->getGpuAddress()), standard64kbRangeMinimumAddress);
|
||||
EXPECT_LE(GmmHelper::decanonize(allocation->getGpuAddress()), standard64kbRangeMaximumAddress);
|
||||
}
|
||||
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenAllocateGraphicsMemoryWithSetAllocattionPropertisWithAllocationTypeBufferIsCalledThenIsRendeCompressedFalseAndCorrectAddressRange) {
|
||||
void *ptr = reinterpret_cast<void *>(0x1001);
|
||||
auto size = MemoryConstants::pageSize;
|
||||
HardwareInfo hwInfo = *defaultHwInfo;
|
||||
hwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
rootDeviceEnvironment->setHwInfo(&hwInfo);
|
||||
|
||||
auto memoryManager = std::make_unique<MockWddmMemoryManager>(false, false, *executionEnvironment);
|
||||
memoryManager->allocateGraphicsMemoryInNonDevicePool = true;
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{mockRootDeviceIndex, true, size, GraphicsAllocation::AllocationType::BUFFER, mockDeviceBitfield}, ptr);
|
||||
|
||||
auto gfxPartition = memoryManager->getGfxPartition(mockRootDeviceIndex);
|
||||
D3DGPU_VIRTUAL_ADDRESS svmRangeMinimumAddress = gfxPartition->getHeapMinimalAddress(HeapIndex::HEAP_SVM);
|
||||
D3DGPU_VIRTUAL_ADDRESS svmRangeMaximumAddress = gfxPartition->getHeapLimit(HeapIndex::HEAP_SVM);
|
||||
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
EXPECT_FALSE(memoryManager->allocationGraphicsMemory64kbCreated);
|
||||
EXPECT_FALSE(allocation->getDefaultGmm()->isRenderCompressed);
|
||||
if (is32bit || rootDeviceEnvironment->isFullRangeSvm()) {
|
||||
|
||||
EXPECT_GE(GmmHelper::decanonize(allocation->getGpuAddress()), svmRangeMinimumAddress);
|
||||
EXPECT_LE(GmmHelper::decanonize(allocation->getGpuAddress()), svmRangeMaximumAddress);
|
||||
}
|
||||
memoryManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleFailsThenReturnNull) {
|
||||
auto osHandle = 1u;
|
||||
auto size = 4096u;
|
||||
|
|
|
@ -123,6 +123,18 @@ void Gmm::setupImageResourceParams(ImageInfo &imgInfo) {
|
|||
applyAuxFlagsForImage(imgInfo);
|
||||
}
|
||||
|
||||
void Gmm::applyAuxFlagsForBuffer(bool preferRenderCompression) {
|
||||
bool allowRenderCompression = HwHelper::renderCompressedBuffersSupported(*clientContext->getHardwareInfo()) &&
|
||||
preferRenderCompression;
|
||||
|
||||
if (allowRenderCompression) {
|
||||
resourceParams.Flags.Info.RenderCompressed = 1;
|
||||
resourceParams.Flags.Gpu.CCS = 1;
|
||||
resourceParams.Flags.Gpu.UnifiedAuxSurface = 1;
|
||||
isRenderCompressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Gmm::queryImageParams(ImageInfo &imgInfo) {
|
||||
auto imageCount = this->gmmResourceInfo->getArraySize();
|
||||
imgInfo.size = this->gmmResourceInfo->getSizeAllocation();
|
||||
|
|
|
@ -12,6 +12,4 @@
|
|||
using namespace NEO;
|
||||
|
||||
void Gmm::applyAuxFlagsForImage(ImageInfo &imgInfo) {}
|
||||
void Gmm::applyAuxFlagsForBuffer(bool preferRenderCompression) {}
|
||||
|
||||
void Gmm::applyMemoryFlags(bool systemMemoryPool, StorageInfo &storageInfo) { this->useSystemMemoryPool = systemMemoryPool; }
|
||||
|
|
|
@ -476,6 +476,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData &
|
|||
return allocation;
|
||||
}
|
||||
bool use32Allocator = heapAssigner.use32BitHeap(allocationData.type);
|
||||
|
||||
if (use32Allocator ||
|
||||
(force32bitAllocations && allocationData.flags.allow32Bit && is64bit)) {
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
|
||||
|
|
|
@ -115,13 +115,11 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(const Allocati
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
auto cpuPtr = lockResource(wddmAllocation.get());
|
||||
auto cpuPtr = gmm->isRenderCompressed ? nullptr : lockResource(wddmAllocation.get());
|
||||
|
||||
// 64kb map is not needed
|
||||
auto status = mapGpuVirtualAddress(wddmAllocation.get(), cpuPtr);
|
||||
DEBUG_BREAK_IF(!status);
|
||||
wddmAllocation->setCpuAddress(cpuPtr);
|
||||
|
||||
return wddmAllocation.release();
|
||||
}
|
||||
|
||||
|
@ -204,7 +202,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithAlignment(const
|
|||
maxOsContextCount);
|
||||
wddmAllocation->setDriverAllocatedCpuPtr(pSysMem);
|
||||
|
||||
gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), pSysMem, sizeAligned, allocationData.flags.uncacheable);
|
||||
gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), pSysMem, sizeAligned, allocationData.flags.uncacheable, allocationData.flags.preferRenderCompressed, true, allocationData.storageInfo);
|
||||
|
||||
wddmAllocation->setDefaultGmm(gmm);
|
||||
void *mapPtr = wddmAllocation->getAlignedCpuPtr();
|
||||
|
|
Loading…
Reference in New Issue