Enable new DriverProtection interface for MapGpuVa

Related-To: NEO-6096

Signed-off-by: Dominik Dabek <dominik.dabek@intel.com>
This commit is contained in:
Dominik Dabek 2021-08-06 10:46:00 +00:00 committed by Compute-Runtime-Automation
parent 63a578f5a4
commit 65e00abea6
16 changed files with 88 additions and 6 deletions

View File

@ -35,6 +35,8 @@ class MockGmmResourceInfo : public GmmResourceInfo {
size_t getRenderPitch() override { return rowPitch; }
uint64_t getDriverProtectionBits() override { return driverProtectionBits; }
uint32_t getNumSamples() override { return mockResourceCreateParams.MSAA.NumSamples; }
uint32_t getQPitch() override { return qPitch; }
@ -97,6 +99,7 @@ class MockGmmResourceInfo : public GmmResourceInfo {
using GmmResourceInfo::clientContext;
using GmmResourceInfo::createResourceInfo;
uint64_t driverProtectionBits = 0;
uint32_t getOffsetCalled = 0u;
uint32_t arrayIndexPassedToGetOffset = 0;
SurfaceFormatInfo tempSurface{};

View File

@ -387,9 +387,9 @@ TEST_F(Wddm20Tests, givenNullAllocationWhenCreateThenAllocateAndMap) {
OsAgnosticMemoryManager mm(*executionEnvironment);
WddmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 100, nullptr, MemoryPool::MemoryNull, 0u, 1u);
Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), getGmmClientContext());
auto gmm = std::unique_ptr<Gmm>(GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), getGmmClientContext()));
allocation.setDefaultGmm(gmm);
allocation.setDefaultGmm(gmm.get());
auto status = wddm->createAllocation(&allocation);
EXPECT_EQ(STATUS_SUCCESS, status);
@ -399,7 +399,6 @@ TEST_F(Wddm20Tests, givenNullAllocationWhenCreateThenAllocateAndMap) {
EXPECT_NE(0u, allocation.getGpuAddress());
EXPECT_EQ(allocation.getGpuAddress(), GmmHelper::canonize(allocation.getGpuAddress()));
delete gmm;
mm.freeSystemMemory(allocation.getUnderlyingBuffer());
}

View File

@ -319,3 +319,4 @@ OverrideKernelSizeLimitForSmallDispatch = -1
SkipFlushingEventsOnGetStatusCalls = 0
AllowUnrestrictedSize = 0
DoNotFreeResources = 0
OverrideGmmResourceUsageField = -1

View File

@ -155,6 +155,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, OverrideMaxWorkGroupCount, -1, "-1: default, >0:
DECLARE_DEBUG_VARIABLE(int32_t, OverrideCmdQueueSynchronousMode, -1, "Overrides all command queues synchronous mode: -1: do not override, 0: implicit driver behavior, 1: synchronous, 2: asynchronous")
DECLARE_DEBUG_VARIABLE(int32_t, EnableStatelessCompression, -1, "-1: default, 0: disable, 1: Enable E2EC in SBA for all stateless accesses")
DECLARE_DEBUG_VARIABLE(int32_t, EnableMultiTileCompression, -1, "-1: default, 0: disable, 1: enable, Enables compression in multi tile scenarios.")
DECLARE_DEBUG_VARIABLE(int32_t, OverrideGmmResourceUsageField, -1, "-1: default, >=0: gmm.resourceParams.Usage is set to this value")
/*LOGGING FLAGS*/
DECLARE_DEBUG_VARIABLE(int32_t, PrintDriverDiagnostics, -1, "prints driver diagnostics messages to standard output, value corresponds to hint level")

View File

@ -6,6 +6,7 @@
set(NEO_CORE_GMM_HELPER
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/resource_info_${DRIVER_MODEL}.cpp
${CMAKE_CURRENT_SOURCE_DIR}/client_context/gmm_client_context.cpp
${CMAKE_CURRENT_SOURCE_DIR}/client_context/gmm_client_context.h
${CMAKE_CURRENT_SOURCE_DIR}/gmm.cpp

View File

@ -61,12 +61,14 @@ Gmm::Gmm(GmmClientContext *clientContext, const void *alignedPtr, size_t aligned
applyAuxFlagsForBuffer(preferRenderCompressed);
applyMemoryFlags(systemMemoryPool, storageInfo);
applyAppResource(storageInfo);
applyDebugOverrides();
gmmResourceInfo.reset(GmmResourceInfo::create(clientContext, &resourceParams));
}
Gmm::Gmm(GmmClientContext *clientContext, GMM_RESOURCE_INFO *inputGmm) : clientContext(clientContext) {
gmmResourceInfo.reset(GmmResourceInfo::create(clientContext, inputGmm));
applyDebugOverrides();
}
Gmm::~Gmm() = default;
@ -76,6 +78,7 @@ Gmm::Gmm(GmmClientContext *clientContext, ImageInfo &inputOutputImgInfo, Storage
setupImageResourceParams(inputOutputImgInfo);
applyMemoryFlags(!inputOutputImgInfo.useLocalMemory, storageInfo);
applyAppResource(storageInfo);
applyDebugOverrides();
this->gmmResourceInfo.reset(GmmResourceInfo::create(clientContext, &this->resourceParams));
UNRECOVERABLE_IF(this->gmmResourceInfo == nullptr);
@ -121,6 +124,7 @@ void Gmm::setupImageResourceParams(ImageInfo &imgInfo) {
resourceParams.NoGfxMemory = 1; // dont allocate, only query for params
resourceParams.Usage = GMM_RESOURCE_USAGE_TYPE::GMM_RESOURCE_USAGE_OCL_IMAGE;
resourceParams.Format = imgInfo.surfaceFormat->GMMSurfaceFormat;
resourceParams.Flags.Gpu.Texture = 1;
resourceParams.BaseWidth64 = imageWidth;
@ -374,4 +378,10 @@ void Gmm::applyMemoryFlags(bool systemMemoryPool, StorageInfo &storageInfo) {
}
}
}
void Gmm::applyDebugOverrides() {
if (-1 != DebugManager.flags.OverrideGmmResourceUsageField.get()) {
resourceParams.Usage = static_cast<GMM_RESOURCE_USAGE_TYPE>(DebugManager.flags.OverrideGmmResourceUsageField.get());
}
}
} // namespace NEO

View File

@ -58,6 +58,7 @@ class Gmm {
void setupImageResourceParams(ImageInfo &imgInfo);
bool extraMemoryFlagsRequired();
void applyExtraMemoryFlags(const StorageInfo &storageInfo);
void applyDebugOverrides();
GmmClientContext *clientContext = nullptr;
};
} // namespace NEO

View File

@ -33,6 +33,8 @@ class GmmResourceInfo {
MOCKABLE_VIRTUAL size_t getRenderPitch() { return static_cast<size_t>(resourceInfo->GetRenderPitch()); }
MOCKABLE_VIRTUAL uint64_t getDriverProtectionBits();
MOCKABLE_VIRTUAL uint32_t getNumSamples() { return resourceInfo->GetNumSamples(); }
MOCKABLE_VIRTUAL uint32_t getQPitch() { return resourceInfo->GetQPitch(); }

View File

@ -0,0 +1,15 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gmm_helper/resource_info.h"
namespace NEO {
uint64_t GmmResourceInfo::getDriverProtectionBits() {
return 0u;
}
} // namespace NEO

View File

@ -0,0 +1,15 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gmm_helper/resource_info.h"
namespace NEO {
uint64_t GmmResourceInfo::getDriverProtectionBits() {
return 0u;
}
} // namespace NEO

View File

@ -0,0 +1,15 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gmm_helper/resource_info.h"
namespace NEO {
uint64_t GmmResourceInfo::getDriverProtectionBits() {
return 0u;
}
} // namespace NEO

View File

@ -25,16 +25,16 @@ set(NEO_CORE_OS_INTERFACE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_memory_win.h
${CMAKE_CURRENT_SOURCE_DIR}/os_socket.h
${CMAKE_CURRENT_SOURCE_DIR}/os_time_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_time_win.h
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_thread_win.h
${CMAKE_CURRENT_SOURCE_DIR}/os_time_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_time_win.h
${CMAKE_CURRENT_SOURCE_DIR}/page_table_manager_functions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/print.cpp
${CMAKE_CURRENT_SOURCE_DIR}/trim_callback.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm/adapter_factory_create_with_fallback.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm/adapter_factory_dxgi.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm/adapter_factory_dxgi.h
${CMAKE_CURRENT_SOURCE_DIR}/wddm/adapter_factory_create_with_fallback.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm/read_preemption_regkey.cpp
${CMAKE_CURRENT_SOURCE_DIR}/windows_inc.cpp
)
@ -43,6 +43,7 @@ set(NEO_CORE_OS_INTERFACE_WDDM
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_additional_context_flags.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_allocation.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_apply_additional_map_gpu_va_fields.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_engine_mapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/d3dkmthk_wrapper.h
${CMAKE_CURRENT_SOURCE_DIR}/dxgi_wrapper.h

View File

@ -431,6 +431,7 @@ bool Wddm::mapGpuVirtualAddress(Gmm *gmm, D3DKMT_HANDLE handle, D3DGPU_VIRTUAL_A
MapGPUVA.hPagingQueue = pagingQueue;
MapGPUVA.hAllocation = handle;
MapGPUVA.Protection = protectionType;
MapGPUVA.SizeInPages = size / MemoryConstants::pageSize;
MapGPUVA.OffsetInPages = 0;
@ -438,6 +439,8 @@ bool Wddm::mapGpuVirtualAddress(Gmm *gmm, D3DKMT_HANDLE handle, D3DGPU_VIRTUAL_A
MapGPUVA.MinimumAddress = minimumAddress;
MapGPUVA.MaximumAddress = maximumAddress;
applyAdditionalMapGPUVAFields(MapGPUVA, gmm);
NTSTATUS status = getGdi()->mapGpuVirtualAddress(&MapGPUVA);
gpuPtr = GmmHelper::canonize(MapGPUVA.VirtualAddress);

View File

@ -75,6 +75,7 @@ class Wddm : public DriverModel {
MOCKABLE_VIRTUAL D3DGPU_VIRTUAL_ADDRESS reserveGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS minimumAddress, D3DGPU_VIRTUAL_ADDRESS maximumAddress, D3DGPU_SIZE_T size);
MOCKABLE_VIRTUAL bool createContext(OsContextWin &osContext);
MOCKABLE_VIRTUAL void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData, OsContextWin &osContext, const HardwareInfo &hwInfo);
MOCKABLE_VIRTUAL void applyAdditionalMapGPUVAFields(D3DDDI_MAPGPUVIRTUALADDRESS &MapGPUVA, Gmm *gmm);
MOCKABLE_VIRTUAL bool freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size);
MOCKABLE_VIRTUAL NTSTATUS createAllocation(const void *alignedCpuPtr, const Gmm *gmm, D3DKMT_HANDLE &outHandle, D3DKMT_HANDLE &outResourceHandle, D3DKMT_HANDLE *outSharedHandle);
MOCKABLE_VIRTUAL bool createAllocation(const Gmm *gmm, D3DKMT_HANDLE &outHandle);

View File

@ -10,4 +10,5 @@
namespace NEO {
void Wddm::applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData, OsContextWin &osContext, const HardwareInfo &hwInfo) {
}
} // namespace NEO

View File

@ -0,0 +1,13 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/windows/wddm/wddm.h"
namespace NEO {
void Wddm::applyAdditionalMapGPUVAFields(D3DDDI_MAPGPUVIRTUALADDRESS &mapGPUVA, Gmm *gmm) {
}
} // namespace NEO