mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 05:56:36 +08:00
Add new function to Wddm mocks
Change-Id: I2a7c368475752009ae042aa9b5f07c2df9f1b5b8 Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
2330b00536
commit
9b8b49e4cd
@@ -46,6 +46,7 @@ set(NEO_CORE_OS_INTERFACE_WINDOWS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/thk_wrapper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm/wddm_defs.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_memory_manager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/wddm_memory_manager_allocate_in_device_pool.cpp
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "core/memory_manager/gfx_partition.h"
|
||||
#include "core/os_interface/os_context.h"
|
||||
#include "core/os_interface/windows/hw_device_id.h"
|
||||
#include "core/os_interface/windows/wddm/wddm_defs.h"
|
||||
#include "core/utilities/spinlock.h"
|
||||
|
||||
#include "sku_info.h"
|
||||
@@ -40,17 +41,6 @@ struct OsHandleStorage;
|
||||
|
||||
enum class HeapIndex : uint32_t;
|
||||
|
||||
struct WddmSubmitArguments {
|
||||
MonitoredFence *monitorFence;
|
||||
D3DKMT_HANDLE contextHandle;
|
||||
D3DKMT_HANDLE hwQueueHandle;
|
||||
};
|
||||
|
||||
enum class WddmVersion : uint32_t {
|
||||
WDDM_2_0 = 0,
|
||||
WDDM_2_3
|
||||
};
|
||||
|
||||
class Wddm {
|
||||
public:
|
||||
typedef HRESULT(WINAPI *CreateDXGIFactoryFcn)(REFIID riid, void **ppFactory);
|
||||
@@ -151,7 +141,7 @@ class Wddm {
|
||||
GmmMemory *getGmmMemory() const {
|
||||
return gmmMemory.get();
|
||||
}
|
||||
void waitOnPagingFenceFromCpu();
|
||||
MOCKABLE_VIRTUAL void waitOnPagingFenceFromCpu();
|
||||
|
||||
void setGmmInputArg(void *args);
|
||||
|
||||
|
||||
25
core/os_interface/windows/wddm/wddm_defs.h
Normal file
25
core/os_interface/windows/wddm/wddm_defs.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/os_interface/windows/windows_defs.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
struct WddmSubmitArguments {
|
||||
MonitoredFence *monitorFence;
|
||||
D3DKMT_HANDLE contextHandle;
|
||||
D3DKMT_HANDLE hwQueueHandle;
|
||||
};
|
||||
|
||||
enum class WddmVersion : uint32_t {
|
||||
WDDM_2_0 = 0,
|
||||
WDDM_2_3
|
||||
};
|
||||
} // namespace NEO
|
||||
@@ -48,6 +48,7 @@ HWTEST_F(CommandEncodeSemaphore, whenAddingMiSemaphoreCommandThenExpectCompareFi
|
||||
HardwareParse hwParse;
|
||||
hwParse.parseCommands<FamilyType>(stream);
|
||||
MI_SEMAPHORE_WAIT *miSemaphore = hwParse.getCommand<MI_SEMAPHORE_WAIT>();
|
||||
ASSERT_NE(nullptr, miSemaphore);
|
||||
|
||||
EXPECT_EQ(compareMode, miSemaphore->getCompareOperation());
|
||||
EXPECT_EQ(5u, miSemaphore->getSemaphoreDataDword());
|
||||
|
||||
@@ -32,8 +32,12 @@ bool WddmMock::makeResident(const D3DKMT_HANDLE *handles, uint32_t count, bool c
|
||||
for (auto i = 0u; i < count; i++) {
|
||||
makeResidentResult.handlePack.push_back(handles[i]);
|
||||
}
|
||||
|
||||
return makeResidentResult.success = Wddm::makeResident(handles, count, cantTrimFurther, numberOfBytesToTrim);
|
||||
if (callBaseMakeResident) {
|
||||
return makeResidentResult.success = Wddm::makeResident(handles, count, cantTrimFurther, numberOfBytesToTrim);
|
||||
} else {
|
||||
makeResidentResult.success = makeResidentStatus;
|
||||
return makeResidentStatus;
|
||||
}
|
||||
}
|
||||
|
||||
bool WddmMock::evict(const D3DKMT_HANDLE *handles, uint32_t num, uint64_t &sizeToTrim) {
|
||||
@@ -155,7 +159,9 @@ bool WddmMock::queryAdapterInfo() {
|
||||
bool WddmMock::submit(uint64_t commandBuffer, size_t size, void *commandHeader, WddmSubmitArguments &submitArguments) {
|
||||
submitResult.called++;
|
||||
submitResult.commandBufferSubmitted = commandBuffer;
|
||||
submitResult.size = size;
|
||||
submitResult.commandHeaderSubmitted = commandHeader;
|
||||
submitResult.submitArgs = submitArguments;
|
||||
return submitResult.success = Wddm::submit(commandBuffer, size, commandHeader, submitArguments);
|
||||
}
|
||||
|
||||
@@ -266,6 +272,11 @@ uint64_t *WddmMock::getPagingFenceAddress() {
|
||||
return &mockPagingFence;
|
||||
}
|
||||
|
||||
void WddmMock::waitOnPagingFenceFromCpu() {
|
||||
waitOnPagingFenceFromCpuResult.called++;
|
||||
Wddm::waitOnPagingFenceFromCpu();
|
||||
}
|
||||
|
||||
void *GmockWddm::virtualAllocWrapper(void *inPtr, size_t size, uint32_t flags, uint32_t type) {
|
||||
void *tmp = reinterpret_cast<void *>(virtualAllocAddress);
|
||||
size += MemoryConstants::pageSize;
|
||||
|
||||
@@ -80,6 +80,7 @@ class WddmMock : public Wddm {
|
||||
bool reserveValidAddressRange(size_t size, void *&reservedMem);
|
||||
PLATFORM *getGfxPlatform() { return gfxPlatform.get(); }
|
||||
uint64_t *getPagingFenceAddress() override;
|
||||
void waitOnPagingFenceFromCpu() override;
|
||||
|
||||
bool configureDeviceAddressSpace() {
|
||||
configureDeviceAddressSpaceResult.called++;
|
||||
@@ -101,7 +102,7 @@ class WddmMock : public Wddm {
|
||||
WddmMockHelpers::CallResult destroyAllocationResult;
|
||||
WddmMockHelpers::CallResult destroyContextResult;
|
||||
WddmMockHelpers::CallResult queryAdapterInfoResult;
|
||||
WddmMockHelpers::CallResult submitResult;
|
||||
WddmMockHelpers::SubmitResult submitResult;
|
||||
WddmMockHelpers::CallResult waitOnGPUResult;
|
||||
WddmMockHelpers::CallResult configureDeviceAddressSpaceResult;
|
||||
WddmMockHelpers::CallResult createContextResult;
|
||||
@@ -115,6 +116,7 @@ class WddmMock : public Wddm {
|
||||
WddmMockHelpers::CallResult registerTrimCallbackResult;
|
||||
WddmMockHelpers::CallResult getPagingFenceAddressResult;
|
||||
WddmMockHelpers::CallResult reserveGpuVirtualAddressResult;
|
||||
WddmMockHelpers::CallResult waitOnPagingFenceFromCpuResult;
|
||||
|
||||
NTSTATUS createAllocationStatus = STATUS_SUCCESS;
|
||||
bool mapGpuVaStatus = true;
|
||||
@@ -125,6 +127,8 @@ class WddmMock : public Wddm {
|
||||
uintptr_t virtualAllocAddress = NEO::windowsMinAddress;
|
||||
bool kmDafEnabled = false;
|
||||
uint64_t mockPagingFence = 0u;
|
||||
bool makeResidentStatus = true;
|
||||
bool callBaseMakeResident = true;
|
||||
};
|
||||
|
||||
struct GmockWddm : WddmMock {
|
||||
|
||||
@@ -20,6 +20,16 @@ class WddmMockInterface20 : public WddmInterface20 {
|
||||
WddmInterface20::destroyMonitorFence(monitorFence);
|
||||
}
|
||||
|
||||
bool createMonitoredFence(MonitoredFence &monitorFence) override {
|
||||
createMonitoredFenceCalled++;
|
||||
if (createMonitoredFenceCalledFail) {
|
||||
return false;
|
||||
}
|
||||
return WddmInterface::createMonitoredFence(monitorFence);
|
||||
}
|
||||
|
||||
uint32_t destroyMonitorFenceCalled = 0;
|
||||
uint32_t createMonitoredFenceCalled = 0;
|
||||
bool createMonitoredFenceCalledFail = false;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/memory_manager/eviction_status.h"
|
||||
#include "core/os_interface/windows/wddm/wddm_defs.h"
|
||||
#include "core/os_interface/windows/windows_defs.h"
|
||||
|
||||
#include <vector>
|
||||
@@ -19,8 +20,6 @@ struct CallResult {
|
||||
uint32_t called = 0;
|
||||
uint64_t uint64ParamPassed = -1;
|
||||
bool success = false;
|
||||
uint64_t commandBufferSubmitted = 0u;
|
||||
void *commandHeaderSubmitted = nullptr;
|
||||
void *cpuPtrPassed = nullptr;
|
||||
};
|
||||
struct MakeResidentCall : CallResult {
|
||||
@@ -39,6 +38,14 @@ struct FreeGpuVirtualAddressCall : CallResult {
|
||||
struct MemoryOperationResult : CallResult {
|
||||
MemoryOperationsStatus operationSuccess = MemoryOperationsStatus::UNSUPPORTED;
|
||||
};
|
||||
|
||||
struct SubmitResult : CallResult {
|
||||
uint64_t commandBufferSubmitted = 0ull;
|
||||
void *commandHeaderSubmitted = nullptr;
|
||||
size_t size = 0u;
|
||||
WddmSubmitArguments submitArgs = {0};
|
||||
};
|
||||
|
||||
} // namespace WddmMockHelpers
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user