performance: add debug flag to allow non zero for compressed

Signed-off-by: Michal Mrozek <michal.mrozek@intel.com>
This commit is contained in:
Michal Mrozek 2024-07-16 10:25:32 +00:00 committed by Compute-Runtime-Automation
parent fc9de71feb
commit 61e08ef4ff
4 changed files with 52 additions and 0 deletions

View File

@ -394,6 +394,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, UseLocalPreferredForCacheableBuffers, -1, "Use l
DECLARE_DEBUG_VARIABLE(int32_t, EnableCopyWithStagingBuffers, -1, "Enable copy with non-usm memory through staging buffers. -1: default, 0: disabled, 1: enabled")
DECLARE_DEBUG_VARIABLE(int32_t, StagingBufferSize, -1, "Size of single staging buffer. -1: default (2MB), >0: size in KB")
DECLARE_DEBUG_VARIABLE(int32_t, ForcePostSyncL1Flush, -1, "-1: default (do nothing), 0: L1 flush disabled in post sync, 1: L1 flush enabled in post sync")
DECLARE_DEBUG_VARIABLE(int32_t, AllowNotZeroForCompressedOnWddm, -1, "-1: default (do nothing), 0: do not set AllowNotZeroed for compressed resources, 1: set AllowNotZeroed for compressed resources");
/*DIRECT SUBMISSION FLAGS*/
DECLARE_DEBUG_VARIABLE(int32_t, EnableDirectSubmission, -1, "-1: default (disabled), 0: disable, 1:enable. Enables direct submission of command buffers bypassing KMD")

View File

@ -663,6 +663,14 @@ NTSTATUS Wddm::createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKM
createAllocation.pAllocationInfo2 = &allocationInfo;
createAllocation.hDevice = device;
bool allowNotZeroForCompressed = false;
if (NEO::debugManager.flags.AllowNotZeroForCompressedOnWddm.get() != -1) {
allowNotZeroForCompressed = !!NEO::debugManager.flags.AllowNotZeroForCompressedOnWddm.get();
}
if (allowNotZeroForCompressed && gmm->isCompressionEnabled()) {
createAllocation.Flags.AllowNotZeroed = 1;
}
status = getGdi()->createAllocation2(&createAllocation);
if (status != STATUS_SUCCESS) {
if (isReadOnlyMemory(alignedCpuPtr)) {

View File

@ -617,4 +617,5 @@ StagingBufferSize = -1
OverrideNumHighPriorityContexts = -1
ForceScratchAndMTPBufferSizeMode = -1
ForcePostSyncL1Flush = -1
AllowNotZeroForCompressedOnWddm = -1
# Please don't edit below this line

View File

@ -479,6 +479,48 @@ TEST_F(WddmTestWithMockGdiDll, givenShareableAllocationWhenCreateThenCreateResou
wddm->destroyAllocation(&allocation, nullptr);
}
TEST_F(WddmTestWithMockGdiDll, givenCompressedResourceWhenItIsCreatedThenItMayContainNonZeroContent) {
DebugManagerStateRestore restorer;
NEO::debugManager.flags.AllowNotZeroForCompressedOnWddm.set(1);
init();
WddmAllocation allocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, 0, MemoryConstants::pageSize, nullptr, MemoryPool::memoryNull, true, 1u);
auto gmm = std::unique_ptr<Gmm>(GmmHelperFunctions::getGmm(nullptr, MemoryConstants::pageSize, getGmmHelper()));
gmm->setCompressionEnabled(true);
allocation.setDefaultGmm(gmm.get());
auto status = wddm->createAllocation(&allocation);
EXPECT_EQ(STATUS_SUCCESS, status);
auto passedCreateAllocation = getMockAllocationFcn();
EXPECT_EQ(1u, passedCreateAllocation->Flags.AllowNotZeroed);
wddm->destroyAllocation(&allocation, nullptr);
}
TEST_F(WddmTestWithMockGdiDll, givenNonCompressedResourceWhenItIsCreatedThenItCannotContainNonZeroContent) {
DebugManagerStateRestore restorer;
NEO::debugManager.flags.AllowNotZeroForCompressedOnWddm.set(1);
init();
WddmAllocation allocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, 0, MemoryConstants::pageSize, nullptr, MemoryPool::memoryNull, true, 1u);
auto gmm = std::unique_ptr<Gmm>(GmmHelperFunctions::getGmm(nullptr, MemoryConstants::pageSize, getGmmHelper()));
allocation.setDefaultGmm(gmm.get());
auto status = wddm->createAllocation(&allocation);
EXPECT_EQ(STATUS_SUCCESS, status);
auto passedCreateAllocation = getMockAllocationFcn();
EXPECT_EQ(0u, passedCreateAllocation->Flags.AllowNotZeroed);
wddm->destroyAllocation(&allocation, nullptr);
}
TEST_F(WddmTestWithMockGdiDll, givenCompressedResourceWhenItIsCreatedThenItCannotContainNonZeroContent) {
init();
WddmAllocation allocation(0, 1u /*num gmms*/, AllocationType::unknown, nullptr, 0, MemoryConstants::pageSize, nullptr, MemoryPool::memoryNull, true, 1u);
auto gmm = std::unique_ptr<Gmm>(GmmHelperFunctions::getGmm(nullptr, MemoryConstants::pageSize, getGmmHelper()));
gmm->setCompressionEnabled(true);
allocation.setDefaultGmm(gmm.get());
auto status = wddm->createAllocation(&allocation);
EXPECT_EQ(STATUS_SUCCESS, status);
auto passedCreateAllocation = getMockAllocationFcn();
EXPECT_EQ(0u, passedCreateAllocation->Flags.AllowNotZeroed);
wddm->destroyAllocation(&allocation, nullptr);
}
TEST_F(WddmTestWithMockGdiDll, givenShareableAllocationWhenCreateThenSharedHandleAndResourceHandleAreSet) {
init();
struct MockWddmMemoryManager : public WddmMemoryManager {