mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
Add support for DAF injection
This commit adds support for Debug Assistance Functionality (DAF) aka "Driver Aubcapture" to debug builds on Windows. Change-Id: I7e859d32af17a6fcee23868392df6cd1390e4afd
This commit is contained in:
@ -118,6 +118,13 @@ if(NOT GTPIN_HEADERS_DIR)
|
||||
endif()
|
||||
endif(NOT GTPIN_HEADERS_DIR)
|
||||
|
||||
if(NOT KMDAF_HEADERS_DIR)
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../internal/kmdaf/kmDaf.h")
|
||||
get_filename_component(KMDAF_HEADERS_DIR "../internal/kmdaf/" ABSOLUTE)
|
||||
message(STATUS "KM-DAF headers dir: ${KMDAF_HEADERS_DIR}")
|
||||
endif()
|
||||
endif(NOT KMDAF_HEADERS_DIR)
|
||||
|
||||
if(NOT LIBDRM_DIR)
|
||||
get_filename_component(LIBDRM_DIR "../libdrm/" ABSOLUTE)
|
||||
endif(NOT LIBDRM_DIR)
|
||||
|
@ -89,6 +89,10 @@ add_subdirectory(accelerators)
|
||||
add_subdirectory(api)
|
||||
add_subdirectory(aub_mem_dump)
|
||||
|
||||
if (WIN32)
|
||||
add_subdirectory(os_interface/windows)
|
||||
endif(WIN32)
|
||||
|
||||
set (RUNTIME_SRCS_BUILT_INS
|
||||
built_ins/built_ins_storage.cpp
|
||||
built_ins/built_ins.cpp
|
||||
@ -306,6 +310,7 @@ set (RUNTIME_SRCS
|
||||
${RUNTIME_SRCS_INDIRECT_HEAP}
|
||||
${RUNTIME_SRCS_INSTRUMENTATION}
|
||||
${RUNTIME_SRCS_KERNEL}
|
||||
${RUNTIME_SRCS_KMDAF}
|
||||
${RUNTIME_SRCS_MEMORY_MANAGER}
|
||||
${RUNTIME_SRCS_GMM_HELPER}
|
||||
${RUNTIME_SRCS_MEM_OBJ}
|
||||
|
@ -275,6 +275,10 @@ uint64_t Gmm::canonize(uint64_t address) {
|
||||
return ((int64_t)((address & 0xFFFFFFFFFFFF) << (64 - 48))) >> (64 - 48);
|
||||
}
|
||||
|
||||
uint64_t Gmm::decanonize(uint64_t address) {
|
||||
return (uint64_t)(address & 0xFFFFFFFFFFFF);
|
||||
}
|
||||
|
||||
uint32_t Gmm::queryQPitch(GFXCORE_FAMILY gfxFamily, GMM_RESOURCE_TYPE resType) {
|
||||
if (gfxFamily == IGFX_GEN8_CORE && resType == GMM_RESOURCE_TYPE::RESOURCE_3D) {
|
||||
return 0;
|
||||
|
@ -76,6 +76,7 @@ class Gmm {
|
||||
static bool allowTiling(const cl_image_desc &imageDesc);
|
||||
|
||||
static uint64_t canonize(uint64_t address);
|
||||
static uint64_t decanonize(uint64_t address);
|
||||
|
||||
static GMM_CUBE_FACE_ENUM getCubeFaceIndex(uint32_t target);
|
||||
static uint32_t getRenderTileMode(uint32_t tileWalk);
|
||||
|
42
runtime/os_interface/windows/CMakeLists.txt
Normal file
42
runtime/os_interface/windows/CMakeLists.txt
Normal file
@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2018, Intel Corporation
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a
|
||||
# copy of this software and associated documentation files (the "Software"),
|
||||
# to deal in the Software without restriction, including without limitation
|
||||
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
# and/or sell copies of the Software, and to permit persons to whom the
|
||||
# Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
cmake_minimum_required (VERSION 3.0)
|
||||
|
||||
if(KMDAF_HEADERS_DIR)
|
||||
set (RUNTIME_SRCS_KMDAF
|
||||
os_interface/windows/kmdaf_listener.cpp
|
||||
os_interface/windows/kmdaf_listener.h
|
||||
)
|
||||
else(KMDAF_HEADERS_DIR)
|
||||
set (RUNTIME_SRCS_KMDAF
|
||||
os_interface/windows/kmdaf_listener_stub.cpp
|
||||
os_interface/windows/kmdaf_listener.h
|
||||
)
|
||||
endif(KMDAF_HEADERS_DIR)
|
||||
|
||||
if(KMDAF_HEADERS_DIR)
|
||||
target_include_directories(${NEO_STATIC_LIB_NAME} PUBLIC
|
||||
${KMDAF_HEADERS_DIR}
|
||||
)
|
||||
endif(KMDAF_HEADERS_DIR)
|
||||
|
||||
source_group("source files\\os_interface" FILES ${RUNTIME_SRCS_KMDAF})
|
||||
|
||||
set(RUNTIME_SRCS_KMDAF "${RUNTIME_SRCS_KMDAF}" PARENT_SCOPE)
|
55
runtime/os_interface/windows/kmdaf_listener.cpp
Normal file
55
runtime/os_interface/windows/kmdaf_listener.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/kmdaf/kmdaf_listener.h"
|
||||
#include "kmdaf.h"
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
void KmDafListener::notifyLock(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE hAllocation, D3DDDICB_LOCKFLAGS *pLockFlags, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
KM_DAF_NOTIFY_LOCK(ftrKmdDaf, hAdapter, hDevice, hAllocation, pLockFlags, pfnEscape);
|
||||
}
|
||||
|
||||
void KmDafListener::notifyUnlock(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE *phAllocation, ULONG allocations, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
KM_DAF_NOTIFY_UNLOCK(ftrKmdDaf, hAdapter, hDevice, phAllocation, allocations, pfnEscape);
|
||||
}
|
||||
|
||||
void KmDafListener::notifyMapGpuVA(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE hAllocation, D3DGPU_VIRTUAL_ADDRESS GpuVirtualAddress, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
KM_DAF_NOTIFY_MAP_GPUVA(ftrKmdDaf, hAdapter, hDevice, hAllocation, GpuVirtualAddress, pfnEscape);
|
||||
}
|
||||
|
||||
void KmDafListener::notifyUnmapGpuVA(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, D3DGPU_VIRTUAL_ADDRESS GpuVirtualAddress, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
KM_DAF_NOTIFY_UNMAP_GPUVA(ftrKmdDaf, hAdapter, hDevice, GpuVirtualAddress, pfnEscape);
|
||||
}
|
||||
|
||||
void KmDafListener::notifyMakeResident(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE *phAllocation, ULONG allocations, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
KM_DAF_NOTIFY_MAKERESIDENT(ftrKmdDaf, hAdapter, hDevice, phAllocation, allocations, pfnEscape);
|
||||
}
|
||||
|
||||
void KmDafListener::notifyEvict(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE *phAllocation, ULONG allocations, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
KM_DAF_NOTIFY_EVICT(ftrKmdDaf, hAdapter, hDevice, phAllocation, allocations, pfnEscape);
|
||||
}
|
||||
|
||||
void KmDafListener::notifyWriteTarget(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE hAllocation, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
KM_DAF_NOTIFY_WRITE_TARGET(ftrKmdDaf, hAdapter, hDevice, hAllocation, pfnEscape);
|
||||
}
|
||||
}
|
45
runtime/os_interface/windows/kmdaf_listener.h
Normal file
45
runtime/os_interface/windows/kmdaf_listener.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/os_interface/windows/windows_wrapper.h"
|
||||
#include <d3dkmthk.h>
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
struct KmDafListener {
|
||||
|
||||
MOCKABLE_VIRTUAL void notifyLock(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE hAllocation, D3DDDICB_LOCKFLAGS *pLockFlags, PFND3DKMT_ESCAPE pfnEscape);
|
||||
|
||||
MOCKABLE_VIRTUAL void notifyUnlock(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE *phAllocation, ULONG allocations, PFND3DKMT_ESCAPE pfnEscape);
|
||||
|
||||
MOCKABLE_VIRTUAL void notifyMapGpuVA(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE hAllocation, D3DGPU_VIRTUAL_ADDRESS GpuVirtualAddress, PFND3DKMT_ESCAPE pfnEscape);
|
||||
|
||||
MOCKABLE_VIRTUAL void notifyUnmapGpuVA(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, D3DGPU_VIRTUAL_ADDRESS GpuVirtualAddress, PFND3DKMT_ESCAPE pfnEscape);
|
||||
|
||||
MOCKABLE_VIRTUAL void notifyMakeResident(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE *phAllocation, ULONG allocations, PFND3DKMT_ESCAPE pfnEscape);
|
||||
|
||||
MOCKABLE_VIRTUAL void notifyEvict(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE *phAllocation, ULONG allocations, PFND3DKMT_ESCAPE pfnEscape);
|
||||
|
||||
MOCKABLE_VIRTUAL void notifyWriteTarget(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE hAllocation, PFND3DKMT_ESCAPE pfnEscape);
|
||||
};
|
||||
}
|
47
runtime/os_interface/windows/kmdaf_listener_stub.cpp
Normal file
47
runtime/os_interface/windows/kmdaf_listener_stub.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "runtime/os_interface/windows/kmdaf_listener.h"
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
void KmDafListener::notifyLock(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE hAllocation, D3DDDICB_LOCKFLAGS *pLockFlags, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
}
|
||||
|
||||
void KmDafListener::notifyUnlock(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE *phAllocation, ULONG allocations, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
}
|
||||
|
||||
void KmDafListener::notifyMapGpuVA(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE hAllocation, D3DGPU_VIRTUAL_ADDRESS GpuVirtualAddress, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
}
|
||||
|
||||
void KmDafListener::notifyUnmapGpuVA(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, D3DGPU_VIRTUAL_ADDRESS GpuVirtualAddress, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
}
|
||||
|
||||
void KmDafListener::notifyMakeResident(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE *phAllocation, ULONG allocations, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
}
|
||||
|
||||
void KmDafListener::notifyEvict(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE *phAllocation, ULONG allocations, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
}
|
||||
|
||||
void KmDafListener::notifyWriteTarget(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE hAllocation, PFND3DKMT_ESCAPE pfnEscape) {
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@
|
||||
#include "runtime/helpers/aligned_memory.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "runtime/os_interface/windows/gdi_interface.h"
|
||||
#include "runtime/os_interface/windows/kmdaf_listener.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/gmm_helper/resource_info.h"
|
||||
#include "runtime/gmm_helper/page_table_mngr.h"
|
||||
@ -69,6 +70,7 @@ Wddm::Wddm(Gdi *gdi) : initialized(false),
|
||||
node = GPUNODE_3D;
|
||||
gmmMemory = std::unique_ptr<GmmMemory>(GmmMemory::create());
|
||||
minAddress = 0;
|
||||
kmDafListener = std::unique_ptr<KmDafListener>(new KmDafListener);
|
||||
}
|
||||
|
||||
Wddm::Wddm() : Wddm(new Gdi()) {
|
||||
@ -289,6 +291,8 @@ bool Wddm::evict(D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &siz
|
||||
|
||||
sizeToTrim = Evict.NumBytesToTrim;
|
||||
|
||||
kmDafListener->notifyEvict(featureTable->ftrKmdDaf, adapter, device, handleList, numOfHandles, gdi->escape);
|
||||
|
||||
return status == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@ -319,28 +323,11 @@ bool Wddm::makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFur
|
||||
UNRECOVERABLE_IF(cantTrimFurther);
|
||||
}
|
||||
|
||||
kmDafListener->notifyMakeResident(featureTable->ftrKmdDaf, adapter, device, handles, count, gdi->escape);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool Wddm::evict(OsHandleStorage &osHandles) {
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
D3DKMT_EVICT Evict = {0};
|
||||
auto sizeToTrim = 0uLL;
|
||||
|
||||
D3DKMT_HANDLE handles[max_fragments_count] = {0};
|
||||
for (uint32_t allocationId = 0; allocationId < osHandles.fragmentCount; allocationId++) {
|
||||
handles[allocationId] = osHandles.fragmentStorageData[allocationId].osHandleStorage->handle;
|
||||
sizeToTrim += osHandles.fragmentStorageData[allocationId].fragmentSize;
|
||||
}
|
||||
|
||||
Evict.AllocationList = handles;
|
||||
Evict.hDevice = device;
|
||||
Evict.NumAllocations = osHandles.fragmentCount;
|
||||
Evict.NumBytesToTrim = sizeToTrim;
|
||||
|
||||
return status == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bool Wddm::mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr, uint64_t size, bool allocation32bit, bool use64kbPages) {
|
||||
void *mapPtr = allocation->getReservedAddress() != nullptr ? allocation->getReservedAddress() : cpuPtr;
|
||||
return mapGpuVirtualAddressImpl(allocation->gmm, allocation->handle, mapPtr, size, allocation->gpuPtr, allocation32bit, use64kbPages);
|
||||
@ -403,6 +390,8 @@ bool Wddm::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr
|
||||
return updateAuxTable(gpuPtr, gmm, true);
|
||||
}
|
||||
|
||||
kmDafListener->notifyMapGpuVA(featureTable->ftrKmdDaf, adapter, device, handle, MapGPUVA.VirtualAddress, gdi->escape);
|
||||
|
||||
return status == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@ -410,11 +399,14 @@ bool Wddm::freeGpuVirtualAddres(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size) {
|
||||
NTSTATUS status = STATUS_SUCCESS;
|
||||
D3DKMT_FREEGPUVIRTUALADDRESS FreeGPUVA = {0};
|
||||
FreeGPUVA.hAdapter = adapter;
|
||||
FreeGPUVA.BaseAddress = gpuPtr;
|
||||
FreeGPUVA.BaseAddress = Gmm::decanonize(gpuPtr);
|
||||
FreeGPUVA.Size = size;
|
||||
|
||||
status = gdi->freeGpuVirtualAddress(&FreeGPUVA);
|
||||
gpuPtr = static_cast<D3DGPU_VIRTUAL_ADDRESS>(0);
|
||||
|
||||
kmDafListener->notifyUnmapGpuVA(featureTable->ftrKmdDaf, adapter, device, FreeGPUVA.BaseAddress, gdi->escape);
|
||||
|
||||
return status == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@ -462,7 +454,10 @@ NTSTATUS Wddm::createAllocation(WddmAllocation *alloc) {
|
||||
DEBUG_BREAK_IF(true);
|
||||
break;
|
||||
}
|
||||
|
||||
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, alloc->handle, gdi->escape);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -495,6 +490,8 @@ bool Wddm::createAllocation64k(WddmAllocation *alloc) {
|
||||
|
||||
alloc->handle = AllocationInfo.hAllocation;
|
||||
|
||||
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, alloc->handle, gdi->escape);
|
||||
|
||||
success = true;
|
||||
}
|
||||
return true;
|
||||
@ -556,12 +553,14 @@ bool Wddm::createAllocationsAndMapGpuVa(OsHandleStorage &osHandles) {
|
||||
osHandles.fragmentStorageData[allocationIndex].osHandleStorage->handle = AllocationInfo[i].hAllocation;
|
||||
success = mapGpuVirtualAddress(&osHandles.fragmentStorageData[allocationIndex], false, false);
|
||||
allocationIndex++;
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
DBG_LOG(PrintDebugMessages, __FUNCTION__, "mapGpuVirtualAddress: ", success);
|
||||
DEBUG_BREAK_IF(true);
|
||||
break;
|
||||
if (!success) {
|
||||
DBG_LOG(PrintDebugMessages, __FUNCTION__, "mapGpuVirtualAddress: ", success);
|
||||
DEBUG_BREAK_IF(true);
|
||||
break;
|
||||
}
|
||||
|
||||
kmDafListener->notifyWriteTarget(featureTable->ftrKmdDaf, adapter, device, AllocationInfo[i].hAllocation, gdi->escape);
|
||||
}
|
||||
|
||||
success = true;
|
||||
@ -673,6 +672,8 @@ void *Wddm::lockResource(WddmAllocation *wddmAllocation) {
|
||||
status = gdi->lock2(&lock2);
|
||||
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
|
||||
|
||||
kmDafListener->notifyLock(featureTable->ftrKmdDaf, adapter, device, wddmAllocation->handle, 0, gdi->escape);
|
||||
|
||||
return lock2.pData;
|
||||
}
|
||||
|
||||
@ -685,6 +686,8 @@ void Wddm::unlockResource(WddmAllocation *wddmAllocation) {
|
||||
|
||||
status = gdi->unlock2(&unlock2);
|
||||
DEBUG_BREAK_IF(status != STATUS_SUCCESS);
|
||||
|
||||
kmDafListener->notifyUnlock(featureTable->ftrKmdDaf, adapter, device, &wddmAllocation->handle, 1, gdi->escape);
|
||||
}
|
||||
|
||||
D3DKMT_HANDLE Wddm::createContext() {
|
||||
|
@ -46,6 +46,7 @@ class LinearStream;
|
||||
class GmmPageTableMngr;
|
||||
struct FeatureTable;
|
||||
struct WorkaroundTable;
|
||||
struct KmDafListener;
|
||||
|
||||
class Wddm {
|
||||
private:
|
||||
@ -73,14 +74,13 @@ class Wddm {
|
||||
|
||||
MOCKABLE_VIRTUAL bool evict(D3DKMT_HANDLE *handleList, uint32_t numOfHandles, uint64_t &sizeToTrim);
|
||||
MOCKABLE_VIRTUAL bool makeResident(D3DKMT_HANDLE *handles, uint32_t count, bool cantTrimFurther, uint64_t *numberOfBytesToTrim);
|
||||
MOCKABLE_VIRTUAL bool evict(OsHandleStorage &osHandles);
|
||||
bool mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr, uint64_t size, bool allocation32bit, bool use64kbPages);
|
||||
bool mapGpuVirtualAddress(AllocationStorageData *allocationStorageData, bool allocation32bit, bool use64kbPages);
|
||||
MOCKABLE_VIRTUAL D3DKMT_HANDLE createContext();
|
||||
MOCKABLE_VIRTUAL bool freeGpuVirtualAddres(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size);
|
||||
MOCKABLE_VIRTUAL NTSTATUS createAllocation(WddmAllocation *alloc);
|
||||
MOCKABLE_VIRTUAL bool createAllocation64k(WddmAllocation *alloc);
|
||||
bool createAllocationsAndMapGpuVa(OsHandleStorage &osHandles);
|
||||
MOCKABLE_VIRTUAL bool createAllocationsAndMapGpuVa(OsHandleStorage &osHandles);
|
||||
MOCKABLE_VIRTUAL bool destroyAllocations(D3DKMT_HANDLE *handles, uint32_t allocationCount, uint64_t lastFenceValue, D3DKMT_HANDLE resourceHandle);
|
||||
MOCKABLE_VIRTUAL bool openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc);
|
||||
bool openNTHandle(HANDLE handle, WddmAllocation *alloc);
|
||||
@ -239,6 +239,8 @@ class Wddm {
|
||||
|
||||
std::unique_ptr<GmmPageTableMngr> pageTableManager;
|
||||
bool pageTableManagerInitialized = false;
|
||||
|
||||
std::unique_ptr<KmDafListener> kmDafListener;
|
||||
};
|
||||
|
||||
} // namespace OCLRT
|
||||
|
@ -103,6 +103,8 @@ class SkuInfoReceiver {
|
||||
RECEIVE_FTR(DisplayEngineS3d);
|
||||
RECEIVE_FTR(VERing);
|
||||
RECEIVE_FTR(Wddm2GpuMmu);
|
||||
|
||||
RECEIVE_FTR(KmdDaf);
|
||||
#undef RECEIVE_FTR
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,8 @@ struct FeatureTableBase {
|
||||
bool ftrDisplayEngineS3d = false; // Gmmlib
|
||||
bool ftrVERing = false; // Gmmlib
|
||||
bool ftrWddm2GpuMmu = false; // Gmmlib
|
||||
|
||||
bool ftrKmdDaf = false;
|
||||
};
|
||||
|
||||
struct WorkaroundTableBase {
|
||||
|
@ -286,6 +286,16 @@ TEST_F(GmmTests, canonize) {
|
||||
EXPECT_EQ(Gmm::canonize(addr2), addrExpected2);
|
||||
}
|
||||
|
||||
TEST_F(GmmTests, decanonize) {
|
||||
uint64_t addr1 = 0x7777777777777777;
|
||||
uint64_t addrExpected1 = 0x0000777777777777;
|
||||
EXPECT_EQ(Gmm::decanonize(addr1), addrExpected1);
|
||||
|
||||
uint64_t addr2 = 0x7FFFFFFFFFFFFFFF;
|
||||
uint64_t addrExpected2 = 0x0000FFFFFFFFFFFF;
|
||||
EXPECT_EQ(Gmm::decanonize(addr2), addrExpected2);
|
||||
}
|
||||
|
||||
TEST_F(GmmTests, returnRenderAlignment) {
|
||||
uint32_t tileModes[4][2] = {{0, 2}, {1, 3}, {2, 1}, {3, 0}}; // {given, expected}
|
||||
for (uint32_t i = 0; i < 4; i++) {
|
||||
|
@ -26,6 +26,7 @@ set(IGDRCL_SRCS_tests_os_interface_windows
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/driver_info_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/gdi_interface_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_cif.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_kmdaf_listener.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_gdi_interface.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_os_time_win.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/mock_wddm_memory_manager.h"
|
||||
@ -38,6 +39,7 @@ set(IGDRCL_SRCS_tests_os_interface_windows
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/ult_dxgi_factory.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/wddm_create.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/wddm_fixture.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/wddm_kmdaf_listener_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/wddm_memory_manager_tests.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/wddm_memory_manager_tests.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/windows/wddm_tests.cpp"
|
||||
|
152
unit_tests/os_interface/windows/mock_kmdaf_listener.h
Normal file
152
unit_tests/os_interface/windows/mock_kmdaf_listener.h
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "runtime/os_interface/windows/kmdaf_listener.h"
|
||||
|
||||
namespace OCLRT {
|
||||
|
||||
struct KmDafListenerMock : public KmDafListener {
|
||||
|
||||
inline void notifyLock(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE hAllocation, D3DDDICB_LOCKFLAGS *pLockFlags, PFND3DKMT_ESCAPE pfnEscape) override {
|
||||
notifyLockParametrization.ftrKmdDaf = ftrKmdDaf;
|
||||
notifyLockParametrization.hAdapter = hAdapter;
|
||||
notifyLockParametrization.hDevice = hDevice;
|
||||
notifyLockParametrization.hAllocation = hAllocation;
|
||||
notifyLockParametrization.pLockFlags = pLockFlags;
|
||||
notifyLockParametrization.pfnEscape = pfnEscape;
|
||||
}
|
||||
|
||||
inline void notifyUnlock(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE *phAllocation, ULONG allocations, PFND3DKMT_ESCAPE pfnEscape) override {
|
||||
notifyUnlockParametrization.ftrKmdDaf = ftrKmdDaf;
|
||||
notifyUnlockParametrization.hAdapter = hAdapter;
|
||||
notifyUnlockParametrization.hDevice = hDevice;
|
||||
notifyUnlockParametrization.phAllocation = phAllocation;
|
||||
notifyUnlockParametrization.allocations = allocations;
|
||||
notifyUnlockParametrization.pfnEscape = pfnEscape;
|
||||
}
|
||||
|
||||
inline void notifyMapGpuVA(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE hAllocation, D3DGPU_VIRTUAL_ADDRESS GpuVirtualAddress, PFND3DKMT_ESCAPE pfnEscape) override {
|
||||
notifyMapGpuVAParametrization.ftrKmdDaf = ftrKmdDaf;
|
||||
notifyMapGpuVAParametrization.hAdapter = hAdapter;
|
||||
notifyMapGpuVAParametrization.hDevice = hDevice;
|
||||
notifyMapGpuVAParametrization.hAllocation = hAllocation;
|
||||
notifyMapGpuVAParametrization.GpuVirtualAddress = GpuVirtualAddress;
|
||||
notifyMapGpuVAParametrization.pfnEscape = pfnEscape;
|
||||
}
|
||||
|
||||
inline void notifyUnmapGpuVA(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, D3DGPU_VIRTUAL_ADDRESS GpuVirtualAddress, PFND3DKMT_ESCAPE pfnEscape) override {
|
||||
notifyUnmapGpuVAParametrization.ftrKmdDaf = ftrKmdDaf;
|
||||
notifyUnmapGpuVAParametrization.hAdapter = hAdapter;
|
||||
notifyUnmapGpuVAParametrization.hDevice = hDevice;
|
||||
notifyUnmapGpuVAParametrization.GpuVirtualAddress = GpuVirtualAddress;
|
||||
notifyUnmapGpuVAParametrization.pfnEscape = pfnEscape;
|
||||
}
|
||||
|
||||
inline void notifyMakeResident(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE *phAllocation, ULONG allocations, PFND3DKMT_ESCAPE pfnEscape) override {
|
||||
notifyMakeResidentParametrization.ftrKmdDaf = ftrKmdDaf;
|
||||
notifyMakeResidentParametrization.hAdapter = hAdapter;
|
||||
notifyMakeResidentParametrization.hDevice = hDevice;
|
||||
notifyMakeResidentParametrization.phAllocation = phAllocation;
|
||||
notifyMakeResidentParametrization.allocations = allocations;
|
||||
notifyMakeResidentParametrization.pfnEscape = pfnEscape;
|
||||
}
|
||||
|
||||
inline void notifyEvict(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE *phAllocation, ULONG allocations, PFND3DKMT_ESCAPE pfnEscape) override {
|
||||
notifyEvictParametrization.ftrKmdDaf = ftrKmdDaf;
|
||||
notifyEvictParametrization.hAdapter = hAdapter;
|
||||
notifyEvictParametrization.hDevice = hDevice;
|
||||
notifyEvictParametrization.phAllocation = phAllocation;
|
||||
notifyEvictParametrization.allocations = allocations;
|
||||
notifyEvictParametrization.pfnEscape = pfnEscape;
|
||||
}
|
||||
|
||||
inline void notifyWriteTarget(bool ftrKmdDaf, D3DKMT_HANDLE hAdapter, D3DKMT_HANDLE hDevice, const D3DKMT_HANDLE hAllocation, PFND3DKMT_ESCAPE pfnEscape) override {
|
||||
notifyWriteTargetParametrization.ftrKmdDaf = ftrKmdDaf;
|
||||
notifyWriteTargetParametrization.hAdapter = hAdapter;
|
||||
notifyWriteTargetParametrization.hDevice = hDevice;
|
||||
notifyWriteTargetParametrization.hAllocation = hAllocation;
|
||||
notifyWriteTargetParametrization.pfnEscape = pfnEscape;
|
||||
}
|
||||
|
||||
struct NotifyLockParametrization {
|
||||
bool ftrKmdDaf = false;
|
||||
D3DKMT_HANDLE hAdapter = 0;
|
||||
D3DKMT_HANDLE hDevice = 0;
|
||||
D3DKMT_HANDLE hAllocation = 0;
|
||||
D3DDDICB_LOCKFLAGS *pLockFlags = nullptr;
|
||||
PFND3DKMT_ESCAPE pfnEscape = nullptr;
|
||||
} notifyLockParametrization;
|
||||
|
||||
struct NotifyUnlockParametrization {
|
||||
bool ftrKmdDaf = 0;
|
||||
D3DKMT_HANDLE hAdapter = 0;
|
||||
D3DKMT_HANDLE hDevice = 0;
|
||||
const D3DKMT_HANDLE *phAllocation = nullptr;
|
||||
ULONG allocations = 0;
|
||||
PFND3DKMT_ESCAPE pfnEscape = nullptr;
|
||||
} notifyUnlockParametrization;
|
||||
|
||||
struct NotifyMapGpuVAParametrization {
|
||||
bool ftrKmdDaf = false;
|
||||
D3DKMT_HANDLE hAdapter = 0;
|
||||
D3DKMT_HANDLE hDevice = 0;
|
||||
D3DKMT_HANDLE hAllocation = 0;
|
||||
D3DGPU_VIRTUAL_ADDRESS GpuVirtualAddress = 0;
|
||||
PFND3DKMT_ESCAPE pfnEscape = nullptr;
|
||||
} notifyMapGpuVAParametrization;
|
||||
|
||||
struct NotifyUnmapGpuVAParametrization {
|
||||
bool ftrKmdDaf = false;
|
||||
D3DKMT_HANDLE hAdapter = 0;
|
||||
D3DKMT_HANDLE hDevice = 0;
|
||||
D3DGPU_VIRTUAL_ADDRESS GpuVirtualAddress = 0;
|
||||
PFND3DKMT_ESCAPE pfnEscape = nullptr;
|
||||
} notifyUnmapGpuVAParametrization;
|
||||
|
||||
struct NotifyMakeResidentParametrization {
|
||||
bool ftrKmdDaf = 0;
|
||||
D3DKMT_HANDLE hAdapter = 0;
|
||||
D3DKMT_HANDLE hDevice = 0;
|
||||
const D3DKMT_HANDLE *phAllocation = nullptr;
|
||||
ULONG allocations = 0;
|
||||
PFND3DKMT_ESCAPE pfnEscape = nullptr;
|
||||
} notifyMakeResidentParametrization;
|
||||
|
||||
struct NotifyEvictParametrization {
|
||||
bool ftrKmdDaf = 0;
|
||||
D3DKMT_HANDLE hAdapter = 0;
|
||||
D3DKMT_HANDLE hDevice = 0;
|
||||
const D3DKMT_HANDLE *phAllocation = nullptr;
|
||||
ULONG allocations = 0;
|
||||
PFND3DKMT_ESCAPE pfnEscape = nullptr;
|
||||
} notifyEvictParametrization;
|
||||
|
||||
struct NotifyWriteTargetParametrization {
|
||||
bool ftrKmdDaf = 0;
|
||||
D3DKMT_HANDLE hAdapter = 0;
|
||||
D3DKMT_HANDLE hDevice = 0;
|
||||
D3DKMT_HANDLE hAllocation = 0;
|
||||
PFND3DKMT_ESCAPE pfnEscape = nullptr;
|
||||
} notifyWriteTargetParametrization;
|
||||
};
|
||||
}
|
198
unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp
Normal file
198
unit_tests/os_interface/windows/wddm_kmdaf_listener_tests.cpp
Normal file
@ -0,0 +1,198 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "unit_tests/os_interface/windows/mock_kmdaf_listener.h"
|
||||
#include "unit_tests/os_interface/windows/wddm_tests.h"
|
||||
#include "runtime/os_interface/windows/wddm.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace OCLRT;
|
||||
|
||||
class WddmWithKmDafMock : public Wddm {
|
||||
public:
|
||||
WddmWithKmDafMock(Gdi *gdi) : Wddm(gdi) {
|
||||
kmDafListener.reset(new KmDafListenerMock);
|
||||
}
|
||||
|
||||
KmDafListenerMock &getKmDafListenerMock() {
|
||||
return static_cast<KmDafListenerMock &>(*this->kmDafListener);
|
||||
}
|
||||
|
||||
FeatureTable *getFeatureTable() {
|
||||
return featureTable.get();
|
||||
}
|
||||
|
||||
bool mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr, uint64_t size, D3DGPU_VIRTUAL_ADDRESS &gpuPtr, bool allocation32bit, bool use64kbPages) override {
|
||||
return Wddm::mapGpuVirtualAddressImpl(gmm, handle, cpuPtr, size, gpuPtr, allocation32bit, use64kbPages);
|
||||
};
|
||||
};
|
||||
|
||||
class WddmKmDafListenerTest : public ::testing::Test {
|
||||
public:
|
||||
void SetUp() {
|
||||
wddmWithKmDafMock = new WddmWithKmDafMock(&gdi);
|
||||
wddmWithKmDafMock->init<DEFAULT_TEST_FAMILY_NAME>();
|
||||
wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf = true;
|
||||
}
|
||||
void TearDown() {
|
||||
delete wddmWithKmDafMock;
|
||||
}
|
||||
|
||||
WddmWithKmDafMock *wddmWithKmDafMock;
|
||||
MockGdi gdi;
|
||||
};
|
||||
|
||||
HWTEST_F(WddmKmDafListenerTest, givenWddmWhenLockResourceIsCalledThenKmDafListenerNotifyLockIsFedWithCorrectParams) {
|
||||
WddmAllocation allocation;
|
||||
allocation.handle = ALLOCATION_HANDLE;
|
||||
|
||||
wddmWithKmDafMock->lockResource(&allocation);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAdapter);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hDevice);
|
||||
EXPECT_EQ(allocation.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.hAllocation);
|
||||
EXPECT_EQ(0, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.pLockFlags);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyLockParametrization.pfnEscape);
|
||||
}
|
||||
|
||||
HWTEST_F(WddmKmDafListenerTest, givenWddmWhenUnlockResourceIsCalledThenKmDafListenerNotifyUnlockIsFedWithCorrectParams) {
|
||||
WddmAllocation allocation;
|
||||
allocation.handle = ALLOCATION_HANDLE;
|
||||
|
||||
wddmWithKmDafMock->unlockResource(&allocation);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.hAdapter);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.hDevice);
|
||||
EXPECT_EQ(allocation.handle, *wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.phAllocation);
|
||||
EXPECT_EQ(1u, wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.allocations);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyUnlockParametrization.pfnEscape);
|
||||
}
|
||||
|
||||
HWTEST_F(WddmKmDafListenerTest, givenWddmWhenMapGpuVirtualAddressIsCalledThenKmDafListenerNotifyMapGpuVAIsFedWithCorrectParams) {
|
||||
WddmAllocation allocation((void *)0x23000, 0x1000, nullptr);
|
||||
allocation.handle = ALLOCATION_HANDLE;
|
||||
auto gmm = std::unique_ptr<Gmm>(Gmm::create(nullptr, 1, false));
|
||||
allocation.gmm = gmm.get();
|
||||
|
||||
wddmWithKmDafMock->mapGpuVirtualAddressImpl(allocation.gmm, allocation.handle, allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), allocation.gpuPtr, false, false);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAdapter);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hDevice);
|
||||
EXPECT_EQ(allocation.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAllocation);
|
||||
EXPECT_EQ(Gmm::decanonize(allocation.gpuPtr), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.GpuVirtualAddress);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.pfnEscape);
|
||||
}
|
||||
|
||||
HWTEST_F(WddmKmDafListenerTest, givenWddmWhenFreeGpuVirtualAddressIsCalledThenKmDafListenerNotifyUnmapGpuVAIsFedWithCorrectParams) {
|
||||
WddmAllocation allocation((void *)0x23000, 0x1000, nullptr);
|
||||
allocation.gpuPtr = GPUVA;
|
||||
|
||||
wddmWithKmDafMock->freeGpuVirtualAddres(allocation.gpuPtr, allocation.getUnderlyingBufferSize());
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyUnmapGpuVAParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyUnmapGpuVAParametrization.hAdapter);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyUnmapGpuVAParametrization.hDevice);
|
||||
EXPECT_EQ(GPUVA, wddmWithKmDafMock->getKmDafListenerMock().notifyUnmapGpuVAParametrization.GpuVirtualAddress);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyUnmapGpuVAParametrization.pfnEscape);
|
||||
}
|
||||
|
||||
HWTEST_F(WddmKmDafListenerTest, givenWddmWhenMakeResidentIsCalledThenKmDafListenerNotifyMakeResidentIsFedWithCorrectParams) {
|
||||
WddmAllocation allocation;
|
||||
|
||||
wddmWithKmDafMock->makeResident(&allocation.handle, 1, false, nullptr);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyMakeResidentParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyMakeResidentParametrization.hAdapter);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyMakeResidentParametrization.hDevice);
|
||||
EXPECT_EQ(allocation.handle, *wddmWithKmDafMock->getKmDafListenerMock().notifyMakeResidentParametrization.phAllocation);
|
||||
EXPECT_EQ(1u, wddmWithKmDafMock->getKmDafListenerMock().notifyMakeResidentParametrization.allocations);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyMakeResidentParametrization.pfnEscape);
|
||||
}
|
||||
|
||||
HWTEST_F(WddmKmDafListenerTest, givenWddmWhenEvictIsCalledThenKmDafListenerNotifyEvictIsFedWithCorrectParams) {
|
||||
WddmAllocation allocation;
|
||||
uint64_t sizeToTrim;
|
||||
|
||||
wddmWithKmDafMock->evict(&allocation.handle, 1, sizeToTrim);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyEvictParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyEvictParametrization.hAdapter);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyEvictParametrization.hDevice);
|
||||
EXPECT_EQ(allocation.handle, *wddmWithKmDafMock->getKmDafListenerMock().notifyEvictParametrization.phAllocation);
|
||||
EXPECT_EQ(1u, wddmWithKmDafMock->getKmDafListenerMock().notifyEvictParametrization.allocations);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyEvictParametrization.pfnEscape);
|
||||
}
|
||||
|
||||
HWTEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafListenerNotifyWriteTargetIsFedWithCorrectParams) {
|
||||
WddmAllocation allocation((void *)0x23000, 0x1000, nullptr);
|
||||
auto gmm = std::unique_ptr<Gmm>(Gmm::create(nullptr, 1, false));
|
||||
allocation.gmm = gmm.get();
|
||||
|
||||
wddmWithKmDafMock->createAllocation(&allocation);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAdapter);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hDevice);
|
||||
EXPECT_EQ(allocation.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAllocation);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.pfnEscape);
|
||||
}
|
||||
|
||||
HWTEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDafListenerNotifyWriteTargetIsFedWithCorrectParams) {
|
||||
WddmAllocation allocation((void *)0x23000, 0x1000, nullptr);
|
||||
auto gmm = std::unique_ptr<Gmm>(Gmm::create(nullptr, 1, false));
|
||||
allocation.gmm = gmm.get();
|
||||
|
||||
wddmWithKmDafMock->createAllocation64k(&allocation);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAdapter);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hDevice);
|
||||
EXPECT_EQ(allocation.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAllocation);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.pfnEscape);
|
||||
}
|
||||
|
||||
HWTEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationsAndMapGpuVaIsCalledThenKmDafListenerNotifyWriteTargetAndMapGpuVAIsFedWithCorrectParams) {
|
||||
OsHandleStorage storage;
|
||||
OsHandle osHandle = {0};
|
||||
auto gmm = std::unique_ptr<Gmm>(Gmm::create(nullptr, 1, false));
|
||||
storage.fragmentStorageData[0].osHandleStorage = &osHandle;
|
||||
storage.fragmentStorageData[0].fragmentSize = 100;
|
||||
storage.fragmentStorageData[0].osHandleStorage->gmm = gmm.get();
|
||||
|
||||
wddmWithKmDafMock->createAllocationsAndMapGpuVa(storage);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAdapter);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hDevice);
|
||||
EXPECT_EQ(osHandle.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.hAllocation);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyWriteTargetParametrization.pfnEscape);
|
||||
|
||||
EXPECT_EQ(wddmWithKmDafMock->getFeatureTable()->ftrKmdDaf, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.ftrKmdDaf);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAdapter);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getDevice(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hDevice);
|
||||
EXPECT_EQ(osHandle.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAllocation);
|
||||
EXPECT_EQ(Gmm::decanonize(osHandle.gpuPtr), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.GpuVirtualAddress);
|
||||
EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.pfnEscape);
|
||||
}
|
@ -635,10 +635,12 @@ HWTEST_F(WddmWithMockGdiTest, makeResidentMultipleHandlesWithReturnBytesToTrim)
|
||||
mm.freeSystemMemory(allocation.getUnderlyingBuffer());
|
||||
}
|
||||
|
||||
TEST_F(WddmWithMockGdiTest, makeNonResidentCallsEvict) {
|
||||
HWTEST_F(WddmWithMockGdiTest, makeNonResidentCallsEvict) {
|
||||
MockGdi gdi;
|
||||
WddmMock wddm(&gdi);
|
||||
|
||||
wddm.init<FamilyType>();
|
||||
|
||||
D3DKMT_HANDLE handle = (D3DKMT_HANDLE)0x1234;
|
||||
|
||||
gdi.getEvictArg().AllocationList = nullptr;
|
||||
|
@ -124,6 +124,8 @@ struct SkuInfoBaseReference {
|
||||
refFtrTable.ftrDisplayEngineS3d = true;
|
||||
refFtrTable.ftrVERing = true;
|
||||
refFtrTable.ftrWddm2GpuMmu = true;
|
||||
|
||||
refFtrTable.ftrKmdDaf = true;
|
||||
}
|
||||
|
||||
static void fillReferenceWaToReceive(WorkaroundTable &refWaTable) {
|
||||
|
Reference in New Issue
Block a user