Improving cpp compliance

Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
This commit is contained in:
Jaroslaw Chodor
2021-05-19 20:12:09 +00:00
committed by Compute-Runtime-Automation
parent d55afceb8b
commit abf0649a5b
33 changed files with 220 additions and 206 deletions

View File

@ -25,7 +25,6 @@ std::unique_ptr<PerformanceCounters> PerformanceCounters::create(Device *device)
counter->clientData.Windows.Adapter = reinterpret_cast<void *>(static_cast<UINT_PTR>(osInterface->getAdapterHandle()));
counter->clientData.Windows.Device = reinterpret_cast<void *>(static_cast<UINT_PTR>(osInterface->getDeviceHandle()));
counter->clientData.Windows.Device = reinterpret_cast<void *>(static_cast<UINT_PTR>(osInterface->getDeviceHandle()));
counter->clientData.Windows.Escape = osInterface->getEscapeHandle();
counter->clientData.Windows.KmdInstrumentationEnabled = device->getHardwareInfo().capabilityTable.instrumentationEnabled;
counter->contextData.ClientData = &counter->clientData;

View File

@ -45,7 +45,7 @@ WddmCommandStreamReceiver<GfxFamily>::WddmCommandStreamReceiver(ExecutionEnviron
notifyAubCaptureImpl = DeviceCallbacks<GfxFamily>::notifyAubCapture;
this->wddm = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface->get()->getWddm();
PreemptionMode preemptionMode = PreemptionHelper::getDefaultPreemptionMode(peekHwInfo());
PreemptionMode preemptionMode = PreemptionHelper::getDefaultPreemptionMode(this->peekHwInfo());
commandBufferHeader = new COMMAND_BUFFER_HEADER;
*commandBufferHeader = CommandBufferHeader;
@ -76,11 +76,11 @@ bool WddmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer, Resid
batchBuffer.commandBufferAllocation->updateResidencyTaskCount(this->taskCount, this->osContext->getContextId());
perfLogResidencyVariadicLog(wddm->getResidencyLogger(), "Wddm CSR processing residency set: %zu\n", allocationsForResidency.size());
this->processResidency(allocationsForResidency, 0u);
if (directSubmission.get()) {
return directSubmission->dispatchCommandBuffer(batchBuffer, *(flushStamp.get()));
if (this->directSubmission.get()) {
return this->directSubmission->dispatchCommandBuffer(batchBuffer, *(this->flushStamp.get()));
}
if (blitterDirectSubmission.get()) {
return blitterDirectSubmission->dispatchCommandBuffer(batchBuffer, *(flushStamp.get()));
if (this->blitterDirectSubmission.get()) {
return this->blitterDirectSubmission->dispatchCommandBuffer(batchBuffer, *(this->flushStamp.get()));
}
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandBufferHeader);
@ -104,26 +104,26 @@ bool WddmCommandStreamReceiver<GfxFamily>::flush(BatchBuffer &batchBuffer, Resid
this->kmDafLockAllocations(allocationsForResidency);
}
auto osContextWin = static_cast<OsContextWin *>(osContext);
auto osContextWin = static_cast<OsContextWin *>(this->osContext);
WddmSubmitArguments submitArgs = {};
submitArgs.contextHandle = osContextWin->getWddmContextHandle();
submitArgs.hwQueueHandle = osContextWin->getHwQueue().handle;
submitArgs.monitorFence = &osContextWin->getResidencyController().getMonitoredFence();
auto status = wddm->submit(commandStreamAddress, batchBuffer.usedSize - batchBuffer.startOffset, commandBufferHeader, submitArgs);
flushStamp->setStamp(submitArgs.monitorFence->lastSubmittedFence);
this->flushStamp->setStamp(submitArgs.monitorFence->lastSubmittedFence);
return status;
}
template <typename GfxFamily>
void WddmCommandStreamReceiver<GfxFamily>::processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) {
bool success = static_cast<OsContextWin *>(osContext)->getResidencyController().makeResidentResidencyAllocations(allocationsForResidency);
bool success = static_cast<OsContextWin *>(this->osContext)->getResidencyController().makeResidentResidencyAllocations(allocationsForResidency);
DEBUG_BREAK_IF(!success);
}
template <typename GfxFamily>
void WddmCommandStreamReceiver<GfxFamily>::processEviction() {
static_cast<OsContextWin *>(osContext)->getResidencyController().makeNonResidentEvictionAllocations(this->getEvictionAllocations());
static_cast<OsContextWin *>(this->osContext)->getResidencyController().makeNonResidentEvictionAllocations(this->getEvictionAllocations());
this->getEvictionAllocations().clear();
}
@ -134,7 +134,7 @@ WddmMemoryManager *WddmCommandStreamReceiver<GfxFamily>::getMemoryManager() cons
template <typename GfxFamily>
bool WddmCommandStreamReceiver<GfxFamily>::waitForFlushStamp(FlushStamp &flushStampToWait) {
return wddm->waitFromCpu(flushStampToWait, static_cast<OsContextWin *>(osContext)->getResidencyController().getMonitoredFence());
return wddm->waitFromCpu(flushStampToWait, static_cast<OsContextWin *>(this->osContext)->getResidencyController().getMonitoredFence());
}
template <typename GfxFamily>
@ -142,7 +142,7 @@ GmmPageTableMngr *WddmCommandStreamReceiver<GfxFamily>::createPageTableManager()
GMM_TRANSLATIONTABLE_CALLBACKS ttCallbacks = {};
ttCallbacks.pfWriteL3Adr = TTCallbacks<GfxFamily>::writeL3Address;
auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex].get();
auto rootDeviceEnvironment = this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex].get();
GmmPageTableMngr *gmmPageTableMngr = GmmPageTableMngr::create(rootDeviceEnvironment->getGmmClientContext(), TT_TYPE::AUXTT, &ttCallbacks);
gmmPageTableMngr->setCsrHandle(this);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -7,6 +7,7 @@
#include "shared/source/helpers/get_info.h"
#include "shared/source/os_interface/windows/os_interface.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
#include "shared/source/utilities/api_intercept.h"
#include "opencl/source/api/api.h"

View File

@ -20,6 +20,7 @@ BOOL WINAPI ULTVirtualFree(LPVOID ptr, SIZE_T size, DWORD flags) {
LPVOID WINAPI ULTVirtualAlloc(LPVOID inPtr, SIZE_T size, DWORD flags, DWORD type) {
return reinterpret_cast<LPVOID>(virtualAllocAddress);
}
Wddm::CreateDXGIFactoryFcn getCreateDxgiFactory() {
return ULTCreateDXGIFactory;
}

View File

@ -20,7 +20,6 @@
#include "shared/source/helpers/string.h"
#include "shared/source/os_interface/os_library.h"
#include "opencl/source/helpers/validators.h"
#include "opencl/source/os_interface/os_inc_base.h"
#include "opencl/source/platform/extensions.h"
@ -51,6 +50,16 @@
namespace NEO {
template <typename T = void>
bool areNotNullptr() {
return true;
}
template <typename T, typename... RT>
bool areNotNullptr(T t, RT... rt) {
return (t != nullptr) && areNotNullptr<RT...>(rt...);
}
CIF::CIFMain *createMainNoSanitize(CIF::CreateCIFMainFunc_t createFunc);
std::string convertToPascalCase(const std::string &inString) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -45,11 +45,11 @@ WddmDirectSubmission<GfxFamily, Dispatcher>::WddmDirectSubmission(Device &device
template <typename GfxFamily, typename Dispatcher>
WddmDirectSubmission<GfxFamily, Dispatcher>::~WddmDirectSubmission() {
perfLogResidencyVariadicLog(wddm->getResidencyLogger(), "Stopping Wddm ULLS\n");
if (ringStart) {
stopRingBuffer();
if (this->ringStart) {
this->stopRingBuffer();
WddmDirectSubmission<GfxFamily, Dispatcher>::handleCompletionRingBuffer(ringFence.lastSubmittedFence, ringFence);
}
deallocateResources();
this->deallocateResources();
wddm->getWddmInterface()->destroyMonitorFence(ringFence);
}
@ -93,10 +93,10 @@ bool WddmDirectSubmission<GfxFamily, Dispatcher>::handleResidency() {
template <typename GfxFamily, typename Dispatcher>
void WddmDirectSubmission<GfxFamily, Dispatcher>::handleSwitchRingBuffers() {
if (ringStart) {
if (completionRingBuffers[currentRingBuffer] != 0) {
if (this->ringStart) {
if (this->completionRingBuffers[this->currentRingBuffer] != 0) {
MonitoredFence &currentFence = osContextWin->getResidencyController().getMonitoredFence();
handleCompletionRingBuffer(completionRingBuffers[currentRingBuffer], currentFence);
handleCompletionRingBuffer(this->completionRingBuffers[this->currentRingBuffer], currentFence);
}
}
}
@ -107,7 +107,7 @@ uint64_t WddmDirectSubmission<GfxFamily, Dispatcher>::updateTagValue() {
currentFence.lastSubmittedFence = currentFence.currentFenceValue;
currentFence.currentFenceValue++;
completionRingBuffers[currentRingBuffer] = currentFence.lastSubmittedFence;
this->completionRingBuffers[this->currentRingBuffer] = currentFence.lastSubmittedFence;
return currentFence.lastSubmittedFence;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*

View File

@ -113,13 +113,11 @@ set(NEO_CORE_HELPERS
)
set_property(GLOBAL PROPERTY NEO_CORE_HELPERS ${NEO_CORE_HELPERS})
if(WIN32)
set(NEO_CORE_SRCS_HELPERS_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.cpp
${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.h
${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.inl
)
set_property(GLOBAL PROPERTY NEO_CORE_SRCS_HELPERS_WINDOWS ${NEO_CORE_SRCS_HELPERS_WINDOWS})
endif()
set(NEO_CORE_SRCS_HELPERS_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.cpp
${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.h
${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.inl
)
set_property(GLOBAL PROPERTY NEO_CORE_SRCS_HELPERS_WINDOWS ${NEO_CORE_SRCS_HELPERS_WINDOWS})
add_subdirectories()

View File

@ -5,7 +5,8 @@
*
*/
#pragma once
#include "shared/source/os_interface/windows/windows_wrapper.h"
#include <cstdint>
namespace NEO {

View File

@ -6,6 +6,8 @@
*/
#pragma once
#include "shared/source/os_interface/windows/windows_wrapper.h"
#include <cstdint>
namespace NEO {

View File

@ -6,6 +6,7 @@
*/
#pragma once
#include <cstdint>
#include <utility>
#include <vector>

View File

@ -26,6 +26,7 @@ namespace NEO {
bool OSInterface::osEnabled64kbPages = false;
bool OSInterface::newResourceImplicitFlush = true;
bool OSInterface::gpuIdleImplicitFlush = true;
bool OSInterface::requiresSupportForWddmTrimNotification = false;
OSInterface::OSInterfaceImpl::OSInterfaceImpl() = default;
OSInterface::OSInterfaceImpl::~OSInterfaceImpl() = default;

View File

@ -33,6 +33,7 @@ class OSInterface {
static bool are64kbPagesEnabled();
static bool newResourceImplicitFlush;
static bool gpuIdleImplicitFlush;
static bool requiresSupportForWddmTrimNotification;
uint32_t getDeviceHandle() const;
void setGmmInputArgs(void *args);
static std::vector<std::unique_ptr<HwDeviceId>> discoverDevices(ExecutionEnvironment &executionEnvironment);

View File

@ -76,6 +76,5 @@ set(NEO_CORE_OS_INTERFACE_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/windows_wrapper.h
)
if(WIN32)
set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_WINDOWS ${NEO_CORE_OS_INTERFACE_WINDOWS})
endif()
set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_WINDOWS ${NEO_CORE_OS_INTERFACE_WINDOWS})

View File

@ -49,6 +49,8 @@ DriverInfo *DriverInfo::create(const HardwareInfo *hwInfo, OSInterface *osInterf
DriverInfoWindows::DriverInfoWindows(std::string &&fullPath) : path(DriverInfoWindows::trimRegistryKey(fullPath)),
registryReader(createRegistryReaderFunc(path)) {}
DriverInfoWindows::~DriverInfoWindows() = default;
std::string DriverInfoWindows::trimRegistryKey(std::string path) {
std::string prefix("\\REGISTRY\\MACHINE\\");
auto pos = prefix.find(prefix);
@ -77,6 +79,11 @@ bool DriverInfoWindows::isCompatibleDriverStore() const {
return currentLibraryPath.find(driverStorePath.c_str()) == 0u;
}
bool isCompatibleDriverStore(std::string &&deviceRegistryPath) {
DriverInfoWindows driverInfo(std::move(deviceRegistryPath));
return driverInfo.isCompatibleDriverStore();
}
decltype(DriverInfoWindows::createRegistryReaderFunc) DriverInfoWindows::createRegistryReaderFunc = [](const std::string &registryPath) -> std::unique_ptr<SettingsReader> {
return std::make_unique<RegistryReader>(false, registryPath);
};

View File

@ -20,6 +20,7 @@ class SettingsReader;
class DriverInfoWindows : public DriverInfo {
public:
DriverInfoWindows(std::string &&path);
~DriverInfoWindows();
std::string getDeviceName(std::string defaultName) override;
std::string getVersion(std::string defaultVersion) override;
bool isCompatibleDriverStore() const;

View File

@ -8,6 +8,7 @@
#include "shared/source/os_interface/windows/gdi_interface.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/os_interface/os_interface.h"
namespace NEO {
@ -19,16 +20,16 @@ inline const std::string getGdiName() {
}
}
Gdi::Gdi() : gdiDll(getGdiName(), nullptr) {
if (gdiDll.isLoaded()) {
Gdi::Gdi() : gdiDll(NEO::OsLibrary::load(getGdiName(), nullptr)) {
if (gdiDll) {
initialized = Gdi::getAllProcAddresses();
}
}
bool Gdi::setupHwQueueProcAddresses() {
createHwQueue = reinterpret_cast<PFND3DKMT_CREATEHWQUEUE>(gdiDll.getProcAddress("D3DKMTCreateHwQueue"));
destroyHwQueue = reinterpret_cast<PFND3DKMT_DESTROYHWQUEUE>(gdiDll.getProcAddress("D3DKMTDestroyHwQueue"));
submitCommandToHwQueue = reinterpret_cast<PFND3DKMT_SUBMITCOMMANDTOHWQUEUE>(gdiDll.getProcAddress("D3DKMTSubmitCommandToHwQueue"));
createHwQueue = gdiDll->getProcAddress("D3DKMTCreateHwQueue");
destroyHwQueue = gdiDll->getProcAddress("D3DKMTDestroyHwQueue");
submitCommandToHwQueue = gdiDll->getProcAddress("D3DKMTSubmitCommandToHwQueue");
if (!createHwQueue || !destroyHwQueue || !submitCommandToHwQueue) {
return false;
@ -37,58 +38,53 @@ bool Gdi::setupHwQueueProcAddresses() {
}
bool Gdi::getAllProcAddresses() {
openAdapterFromHdc = reinterpret_cast<PFND3DKMT_OPENADAPTERFROMHDC>(gdiDll.getProcAddress("D3DKMTOpenAdapterFromHdc"));
openAdapterFromLuid = reinterpret_cast<PFND3DKMT_OPENADAPTERFROMLUID>(gdiDll.getProcAddress("D3DKMTOpenAdapterFromLuid"));
createAllocation_ = reinterpret_cast<PFND3DKMT_CREATEALLOCATION>(gdiDll.getProcAddress("D3DKMTCreateAllocation"));
createAllocation2 = reinterpret_cast<PFND3DKMT_CREATEALLOCATION>(gdiDll.getProcAddress("D3DKMTCreateAllocation2"));
destroyAllocation = reinterpret_cast<PFND3DKMT_DESTROYALLOCATION>(gdiDll.getProcAddress("D3DKMTDestroyAllocation"));
destroyAllocation2 = reinterpret_cast<PFND3DKMT_DESTROYALLOCATION2>(gdiDll.getProcAddress("D3DKMTDestroyAllocation2"));
queryAdapterInfo = reinterpret_cast<PFND3DKMT_QUERYADAPTERINFO>(gdiDll.getProcAddress("D3DKMTQueryAdapterInfo"));
closeAdapter = reinterpret_cast<PFND3DKMT_CLOSEADAPTER>(gdiDll.getProcAddress("D3DKMTCloseAdapter"));
createDevice = reinterpret_cast<PFND3DKMT_CREATEDEVICE>(gdiDll.getProcAddress("D3DKMTCreateDevice"));
destroyDevice = reinterpret_cast<PFND3DKMT_DESTROYDEVICE>(gdiDll.getProcAddress("D3DKMTDestroyDevice"));
escape = reinterpret_cast<PFND3DKMT_ESCAPE>(gdiDll.getProcAddress("D3DKMTEscape"));
createContext = reinterpret_cast<PFND3DKMT_CREATECONTEXTVIRTUAL>(gdiDll.getProcAddress("D3DKMTCreateContextVirtual"));
destroyContext = reinterpret_cast<PFND3DKMT_DESTROYCONTEXT>(gdiDll.getProcAddress("D3DKMTDestroyContext"));
openResource = reinterpret_cast<PFND3DKMT_OPENRESOURCE>(gdiDll.getProcAddress("D3DKMTOpenResource"));
openResourceFromNtHandle = reinterpret_cast<PFND3DKMT_OPENRESOURCEFROMNTHANDLE>(gdiDll.getProcAddress("D3DKMTOpenResourceFromNtHandle"));
queryResourceInfo = reinterpret_cast<PFND3DKMT_QUERYRESOURCEINFO>(gdiDll.getProcAddress("D3DKMTQueryResourceInfo"));
queryResourceInfoFromNtHandle = reinterpret_cast<PFND3DKMT_QUERYRESOURCEINFOFROMNTHANDLE>(gdiDll.getProcAddress("D3DKMTQueryResourceInfoFromNtHandle"));
lock = reinterpret_cast<PFND3DKMT_LOCK>(gdiDll.getProcAddress("D3DKMTLock"));
unlock = reinterpret_cast<PFND3DKMT_UNLOCK>(gdiDll.getProcAddress("D3DKMTUnlock"));
render = reinterpret_cast<PFND3DKMT_RENDER>(gdiDll.getProcAddress("D3DKMTRender"));
createSynchronizationObject = reinterpret_cast<PFND3DKMT_CREATESYNCHRONIZATIONOBJECT>(gdiDll.getProcAddress("D3DKMTCreateSynchronizationObject"));
createSynchronizationObject2 = reinterpret_cast<PFND3DKMT_CREATESYNCHRONIZATIONOBJECT2>(gdiDll.getProcAddress("D3DKMTCreateSynchronizationObject2"));
destroySynchronizationObject = reinterpret_cast<PFND3DKMT_DESTROYSYNCHRONIZATIONOBJECT>(gdiDll.getProcAddress("D3DKMTDestroySynchronizationObject"));
signalSynchronizationObject = reinterpret_cast<PFND3DKMT_SIGNALSYNCHRONIZATIONOBJECT>(gdiDll.getProcAddress("D3DKMTSignalSynchronizationObject"));
waitForSynchronizationObject = reinterpret_cast<PFND3DKMT_WAITFORSYNCHRONIZATIONOBJECT>(gdiDll.getProcAddress("D3DKMTWaitForSynchronizationObject"));
waitForSynchronizationObjectFromCpu = reinterpret_cast<PFND3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU>(gdiDll.getProcAddress("D3DKMTWaitForSynchronizationObjectFromCpu"));
signalSynchronizationObjectFromCpu = reinterpret_cast<PFND3DKMT_SIGNALSYNCHRONIZATIONOBJECTFROMCPU>(gdiDll.getProcAddress("D3DKMTSignalSynchronizationObjectFromCpu"));
waitForSynchronizationObjectFromGpu = reinterpret_cast<PFND3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMGPU>(gdiDll.getProcAddress("D3DKMTWaitForSynchronizationObjectFromGpu"));
signalSynchronizationObjectFromGpu = reinterpret_cast<PFND3DKMT_SIGNALSYNCHRONIZATIONOBJECTFROMGPU>(gdiDll.getProcAddress("D3DKMTSignalSynchronizationObjectFromGpu"));
createPagingQueue = reinterpret_cast<PFND3DKMT_CREATEPAGINGQUEUE>(gdiDll.getProcAddress("D3DKMTCreatePagingQueue"));
destroyPagingQueue = reinterpret_cast<PFND3DKMT_DESTROYPAGINGQUEUE>(gdiDll.getProcAddress("D3DKMTDestroyPagingQueue"));
lock2 = reinterpret_cast<PFND3DKMT_LOCK2>(gdiDll.getProcAddress("D3DKMTLock2"));
unlock2 = reinterpret_cast<PFND3DKMT_UNLOCK2>(gdiDll.getProcAddress("D3DKMTUnlock2"));
mapGpuVirtualAddress = reinterpret_cast<PFND3DKMT_MAPGPUVIRTUALADDRESS>(gdiDll.getProcAddress("D3DKMTMapGpuVirtualAddress"));
reserveGpuVirtualAddress = reinterpret_cast<PFND3DKMT_RESERVEGPUVIRTUALADDRESS>(gdiDll.getProcAddress("D3DKMTReserveGpuVirtualAddress"));
freeGpuVirtualAddress = reinterpret_cast<PFND3DKMT_FREEGPUVIRTUALADDRESS>(gdiDll.getProcAddress("D3DKMTFreeGpuVirtualAddress"));
updateGpuVirtualAddress = reinterpret_cast<PFND3DKMT_UPDATEGPUVIRTUALADDRESS>(gdiDll.getProcAddress("D3DKMTUpdateGpuVirtualAddress"));
submitCommand = reinterpret_cast<PFND3DKMT_SUBMITCOMMAND>(gdiDll.getProcAddress("D3DKMTSubmitCommand"));
makeResident = reinterpret_cast<PFND3DKMT_MAKERESIDENT>(gdiDll.getProcAddress("D3DKMTMakeResident"));
evict = reinterpret_cast<PFND3DKMT_EVICT>(gdiDll.getProcAddress("D3DKMTEvict"));
registerTrimNotification = reinterpret_cast<PFND3DKMT_REGISTERTRIMNOTIFICATION>(gdiDll.getProcAddress("D3DKMTRegisterTrimNotification"));
unregisterTrimNotification = reinterpret_cast<PFND3DKMT_UNREGISTERTRIMNOTIFICATION>(gdiDll.getProcAddress("D3DKMTUnregisterTrimNotification"));
setAllocationPriority = reinterpret_cast<PFND3DKMT_SETALLOCATIONPRIORITY>(gdiDll.getProcAddress("D3DKMTSetAllocationPriority"));
openAdapterFromLuid = gdiDll->getProcAddress("D3DKMTOpenAdapterFromLuid");
createAllocation_ = gdiDll->getProcAddress("D3DKMTCreateAllocation");
createAllocation2 = gdiDll->getProcAddress("D3DKMTCreateAllocation2");
destroyAllocation2 = gdiDll->getProcAddress("D3DKMTDestroyAllocation2");
queryAdapterInfo = gdiDll->getProcAddress("D3DKMTQueryAdapterInfo");
closeAdapter = gdiDll->getProcAddress("D3DKMTCloseAdapter");
createDevice = gdiDll->getProcAddress("D3DKMTCreateDevice");
destroyDevice = gdiDll->getProcAddress("D3DKMTDestroyDevice");
escape = gdiDll->getProcAddress("D3DKMTEscape");
createContext = gdiDll->getProcAddress("D3DKMTCreateContextVirtual");
destroyContext = gdiDll->getProcAddress("D3DKMTDestroyContext");
openResource = gdiDll->getProcAddress("D3DKMTOpenResource");
openResourceFromNtHandle = gdiDll->getProcAddress("D3DKMTOpenResourceFromNtHandle");
queryResourceInfo = gdiDll->getProcAddress("D3DKMTQueryResourceInfo");
queryResourceInfoFromNtHandle = gdiDll->getProcAddress("D3DKMTQueryResourceInfoFromNtHandle");
createSynchronizationObject = gdiDll->getProcAddress("D3DKMTCreateSynchronizationObject");
createSynchronizationObject2 = gdiDll->getProcAddress("D3DKMTCreateSynchronizationObject2");
destroySynchronizationObject = gdiDll->getProcAddress("D3DKMTDestroySynchronizationObject");
signalSynchronizationObject = gdiDll->getProcAddress("D3DKMTSignalSynchronizationObject");
waitForSynchronizationObject = gdiDll->getProcAddress("D3DKMTWaitForSynchronizationObject");
waitForSynchronizationObjectFromCpu = gdiDll->getProcAddress("D3DKMTWaitForSynchronizationObjectFromCpu");
signalSynchronizationObjectFromCpu = gdiDll->getProcAddress("D3DKMTSignalSynchronizationObjectFromCpu");
waitForSynchronizationObjectFromGpu = gdiDll->getProcAddress("D3DKMTWaitForSynchronizationObjectFromGpu");
signalSynchronizationObjectFromGpu = gdiDll->getProcAddress("D3DKMTSignalSynchronizationObjectFromGpu");
createPagingQueue = gdiDll->getProcAddress("D3DKMTCreatePagingQueue");
destroyPagingQueue = gdiDll->getProcAddress("D3DKMTDestroyPagingQueue");
lock2 = gdiDll->getProcAddress("D3DKMTLock2");
unlock2 = gdiDll->getProcAddress("D3DKMTUnlock2");
mapGpuVirtualAddress = gdiDll->getProcAddress("D3DKMTMapGpuVirtualAddress");
reserveGpuVirtualAddress = gdiDll->getProcAddress("D3DKMTReserveGpuVirtualAddress");
freeGpuVirtualAddress = gdiDll->getProcAddress("D3DKMTFreeGpuVirtualAddress");
updateGpuVirtualAddress = gdiDll->getProcAddress("D3DKMTUpdateGpuVirtualAddress");
submitCommand = gdiDll->getProcAddress("D3DKMTSubmitCommand");
makeResident = gdiDll->getProcAddress("D3DKMTMakeResident");
evict = gdiDll->getProcAddress("D3DKMTEvict");
registerTrimNotification = gdiDll->getProcAddress("D3DKMTRegisterTrimNotification");
unregisterTrimNotification = gdiDll->getProcAddress("D3DKMTUnregisterTrimNotification");
setAllocationPriority = gdiDll->getProcAddress("D3DKMTSetAllocationPriority");
// For debug purposes
getDeviceState = reinterpret_cast<PFND3DKMT_GETDEVICESTATE>(gdiDll.getProcAddress("D3DKMTGetDeviceState"));
getDeviceState = gdiDll->getProcAddress("D3DKMTGetDeviceState");
// clang-format off
if (openAdapterFromHdc && openAdapterFromLuid && createAllocation2 && destroyAllocation
if (openAdapterFromLuid && createAllocation2
&& destroyAllocation2 && queryAdapterInfo && closeAdapter && createDevice
&& destroyDevice && escape && createContext && destroyContext
&& openResource && queryResourceInfo && lock && unlock && render
&& openResource && queryResourceInfo
&& createSynchronizationObject && createSynchronizationObject2
&& destroySynchronizationObject && signalSynchronizationObject
&& waitForSynchronizationObject && waitForSynchronizationObjectFromCpu
@ -96,8 +92,14 @@ bool Gdi::getAllProcAddresses() {
&& signalSynchronizationObjectFromGpu && createPagingQueue && destroyPagingQueue
&& lock2 && unlock2 && mapGpuVirtualAddress && reserveGpuVirtualAddress
&& freeGpuVirtualAddress && updateGpuVirtualAddress &&submitCommand
&& makeResident && evict && registerTrimNotification && unregisterTrimNotification){
return true;
&& makeResident && evict){
if (NEO::OSInterface::requiresSupportForWddmTrimNotification) {
if(registerTrimNotification && unregisterTrimNotification){
return true;
}
}else{
return true;
}
}
// clang-format on
return false;

View File

@ -6,14 +6,16 @@
*/
#pragma once
#include "shared/source/os_interface/os_library.h"
#include "shared/source/os_interface/windows/os_inc.h"
#include "shared/source/os_interface/windows/os_library_win.h"
#include "shared/source/os_interface/windows/thk_wrapper.h"
#include "shared/source/os_interface/windows/windows_wrapper.h"
#include <d3d9types.h>
#include <d3dkmthk.h>
#include <memory>
#include <string>
namespace NEO {
@ -23,7 +25,6 @@ class Gdi {
Gdi();
~Gdi(){};
ThkWrapper<IN OUT D3DKMT_OPENADAPTERFROMHDC *> openAdapterFromHdc{};
ThkWrapper<IN OUT D3DKMT_OPENADAPTERFROMLUID *> openAdapterFromLuid{};
ThkWrapper<IN OUT D3DKMT_CREATEALLOCATION *> createAllocation_{};
ThkWrapper<IN OUT D3DKMT_CREATEALLOCATION *> createAllocation2{};
@ -40,9 +41,6 @@ class Gdi {
ThkWrapper<IN OUT D3DKMT_OPENRESOURCEFROMNTHANDLE *> openResourceFromNtHandle{};
ThkWrapper<IN OUT D3DKMT_QUERYRESOURCEINFO *> queryResourceInfo{};
ThkWrapper<IN OUT D3DKMT_QUERYRESOURCEINFOFROMNTHANDLE *> queryResourceInfoFromNtHandle{};
ThkWrapper<IN OUT D3DKMT_LOCK *> lock{};
ThkWrapper<IN CONST D3DKMT_UNLOCK *> unlock{};
ThkWrapper<IN OUT D3DKMT_RENDER *> render{};
ThkWrapper<IN OUT D3DKMT_CREATESYNCHRONIZATIONOBJECT *> createSynchronizationObject{};
ThkWrapper<IN OUT D3DKMT_CREATESYNCHRONIZATIONOBJECT2 *> createSynchronizationObject2{};
ThkWrapper<IN CONST D3DKMT_DESTROYSYNCHRONIZATIONOBJECT *> destroySynchronizationObject{};
@ -84,6 +82,6 @@ class Gdi {
protected:
MOCKABLE_VIRTUAL bool getAllProcAddresses();
bool initialized = false;
NEO::Windows::OsLibrary gdiDll;
std::unique_ptr<NEO::OsLibrary> gdiDll;
};
} // namespace NEO

View File

@ -17,6 +17,7 @@ namespace NEO {
bool OSInterface::osEnabled64kbPages = true;
bool OSInterface::newResourceImplicitFlush = false;
bool OSInterface::gpuIdleImplicitFlush = false;
bool OSInterface::requiresSupportForWddmTrimNotification = true;
OSInterface::OSInterface() {
osInterfaceImpl = new OSInterfaceImpl();

View File

@ -9,7 +9,7 @@
#include "shared/source/os_interface/os_library.h"
#define UMDF_USING_NTSTATUS
#include "shared/source/os_interface/windows/windows_wrapper.h"
#include <Windows.h>
namespace NEO {
namespace Windows {

View File

@ -7,11 +7,72 @@
#pragma once
#include "shared/source/helpers/options.h"
#include "shared/source/os_interface/windows/windows_wrapper.h"
#include "shared/source/utilities/api_intercept.h"
#include <d3dkmthk.h>
namespace NEO {
// Default template for GetID( ) for Thk function, causing compilation error !!
// Returns ID for specific ThkWrapper type
template <class Param>
constexpr unsigned int getThkWrapperId() {
static_assert(sizeof(Param) > sizeof(Param) + 1, "Template specialization for GetID is required for each new THKWrapper");
return 0;
}
// Template specializations of GetID(), required for every new Thk function
#define GET_ID(TYPE, VALUE) \
template <> \
constexpr unsigned int getThkWrapperId<TYPE>() { \
return 0; \
}
GET_ID(D3DKMT_OPENADAPTERFROMLUID *, SYSTIMER_ID_OPENADAPTERFROMLUID)
GET_ID(CONST D3DKMT_CLOSEADAPTER *, SYSTIMER_ID_CLOSEADAPTER)
GET_ID(CONST D3DKMT_QUERYADAPTERINFO *, SYSTIMER_ID_QUERYADAPTERINFO)
GET_ID(CONST D3DKMT_ESCAPE *, SYSTIMER_ID_ESCAPE)
GET_ID(D3DKMT_CREATEDEVICE *, SYSTIMER_ID_CREATEDEVICE)
GET_ID(CONST D3DKMT_DESTROYDEVICE *, SYSTIMER_ID_DESTROYDEVICE)
GET_ID(D3DKMT_CREATECONTEXT *, SYSTIMER_ID_CREATECONTEXT)
GET_ID(CONST D3DKMT_DESTROYCONTEXT *, SYSTIMER_ID_DESTROYCONTEXT)
GET_ID(D3DKMT_CREATEALLOCATION *, SYSTIMER_ID_CREATEALLOCATION)
GET_ID(D3DKMT_OPENRESOURCE *, SYSTIMER_ID_OPENRESOURCE)
GET_ID(D3DKMT_QUERYRESOURCEINFO *, SYSTIMER_ID_QUERYRESOURCEINFO)
GET_ID(D3DKMT_CREATESYNCHRONIZATIONOBJECT *, SYSTIMER_ID_CREATESYNCHRONIZATIONOBJECT)
GET_ID(CONST D3DKMT_DESTROYSYNCHRONIZATIONOBJECT *, SYSTIMER_ID_DESTROYSYNCHRONIZATIONOBJECT)
GET_ID(CONST D3DKMT_SIGNALSYNCHRONIZATIONOBJECT *, SYSTIMER_ID_SIGNALSYNCHRONIZATIONOBJECT)
GET_ID(CONST_FROM_WDK_10_0_18328_0 D3DKMT_WAITFORSYNCHRONIZATIONOBJECT *, SYSTIMER_ID_WAITFORSYNCHRONIZATIONOBJECT)
GET_ID(D3DKMT_CREATESYNCHRONIZATIONOBJECT2 *, SYSTIMER_ID_CREATESYNCHRONIZATIONOBJECT2)
GET_ID(D3DKMT_GETDEVICESTATE *, SYSTIMER_ID_GETDEVICESTATE)
GET_ID(D3DDDI_MAKERESIDENT *, SYSTIMER_ID_MAKERESIDENT)
GET_ID(D3DKMT_EVICT *, SYSTIMER_ID_EVICT)
GET_ID(CONST D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU *, SYSTIMER_ID_WAITFORSYNCHRONIZATIONOBJECTFROMCPU)
GET_ID(CONST D3DKMT_SIGNALSYNCHRONIZATIONOBJECTFROMCPU *, SYSTIMER_ID_SIGNALSYNCHRONIZATIONOBJECTFROMCPU)
GET_ID(CONST D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMGPU *, SYSTIMER_ID_WAITFORSYNCHRONIZATIONOBJECTFROMGPU)
GET_ID(CONST D3DKMT_SIGNALSYNCHRONIZATIONOBJECTFROMGPU *, SYSTIMER_ID_SIGNALSYNCHRONIZATIONOBJECTFROMGPU)
GET_ID(D3DKMT_CREATEPAGINGQUEUE *, SYSTIMER_ID_CREATEPAGINGQUEUE)
GET_ID(D3DDDI_DESTROYPAGINGQUEUE *, SYSTIMER_ID_D3DDDI_DESTROYPAGINGQUEUE)
GET_ID(D3DKMT_LOCK2 *, SYSTIMER_ID_LOCK2)
GET_ID(CONST D3DKMT_UNLOCK2 *, SYSTIMER_ID_UNLOCK2)
GET_ID(CONST D3DKMT_INVALIDATECACHE *, SYSTIMER_ID_INVALIDATECACHE)
GET_ID(D3DDDI_MAPGPUVIRTUALADDRESS *, SYSTIMER_ID_D3DDDI_MAPGPUVIRTUALADDRESS)
GET_ID(D3DDDI_RESERVEGPUVIRTUALADDRESS *, SYSTIMER_ID_D3DDDI_RESERVEGPUVIRTUALADDRESS)
GET_ID(CONST D3DKMT_FREEGPUVIRTUALADDRESS *, SYSTIMER_ID_FREEGPUVIRTUALADDRESS)
GET_ID(CONST D3DKMT_UPDATEGPUVIRTUALADDRESS *, SYSTIMER_ID_UPDATEGPUVIRTUALADDRESS)
GET_ID(D3DKMT_CREATECONTEXTVIRTUAL *, SYSTIMER_ID_CREATECONTEXTVIRTUAL)
GET_ID(CONST D3DKMT_SUBMITCOMMAND *, SYSTIMER_ID_SUBMITCOMMAND)
GET_ID(D3DKMT_OPENSYNCOBJECTFROMNTHANDLE2 *, SYSTIMER_ID_OPENSYNCOBJECTFROMNTHANDLE2)
GET_ID(CONST D3DKMT_DESTROYALLOCATION2 *, SYSTIMER_ID_DESTROYALLOCATION2)
GET_ID(D3DKMT_REGISTERTRIMNOTIFICATION *, SYSTIMER_ID_REGISTERTRIMNOTIFICATION)
GET_ID(D3DKMT_UNREGISTERTRIMNOTIFICATION *, SYSTIMER_ID_UNREGISTERTRIMNOTIFICATION)
GET_ID(D3DKMT_OPENRESOURCEFROMNTHANDLE *, SYSTIMER_ID_OPENRESOURCEFROMNTHANDLE)
GET_ID(D3DKMT_QUERYRESOURCEINFOFROMNTHANDLE *, SYSTIMER_ID_QUERYRESOURCEINFOFROMNTHANDLE)
GET_ID(D3DKMT_CREATEHWQUEUE *, SYSTIMER_ID_CREATEHWQUEUE)
GET_ID(CONST D3DKMT_DESTROYHWQUEUE *, SYSTIMER_ID_DESTROYHWQUEUE)
GET_ID(CONST D3DKMT_SUBMITCOMMANDTOHWQUEUE *, SYSTIMER_ID_SUBMITCOMMANDTOHWQUEUE)
GET_ID(CONST D3DKMT_SETALLOCATIONPRIORITY *, SYSTIMER_ID_SETALLOCATIONPRIORITY)
template <typename Param>
class ThkWrapper {
typedef NTSTATUS(APIENTRY *Func)(Param);
@ -31,81 +92,15 @@ class ThkWrapper {
}
}
template <class T>
inline T &operator=(T func) {
return mFunc = func;
ThkWrapper &operator=(void *func) {
mFunc = reinterpret_cast<decltype(mFunc)>(func);
return *this;
}
// This operator overload is for implicit casting ThkWrapper struct to Function Pointer in GetPfn methods like GetEscapePfn() or for comparing against NULL function pointer
operator Func() const {
return mFunc;
}
private:
// Default template for GetID( ) for Thk function, causing compilation error !!
// Returns ID for specific ThkWrapper type
template <class Param>
unsigned int getId() const {
static_assert(0, "Template specialization for GetID is required for each new THKWrapper");
return 0;
}
// Template specializations of GetID(), required for every new Thk function
#define GET_ID(TYPE, VALUE) \
template <> \
unsigned int getId<TYPE>() const { \
return VALUE; \
}
GET_ID(D3DKMT_OPENADAPTERFROMHDC *, SYSTIMER_ID_OPENADAPTERFROMHDC)
GET_ID(D3DKMT_OPENADAPTERFROMLUID *, SYSTIMER_ID_OPENADAPTERFROMLUID)
GET_ID(CONST D3DKMT_CLOSEADAPTER *, SYSTIMER_ID_CLOSEADAPTER)
GET_ID(CONST D3DKMT_QUERYADAPTERINFO *, SYSTIMER_ID_QUERYADAPTERINFO)
GET_ID(CONST D3DKMT_ESCAPE *, SYSTIMER_ID_ESCAPE)
GET_ID(D3DKMT_CREATEDEVICE *, SYSTIMER_ID_CREATEDEVICE)
GET_ID(CONST D3DKMT_DESTROYDEVICE *, SYSTIMER_ID_DESTROYDEVICE)
GET_ID(D3DKMT_CREATECONTEXT *, SYSTIMER_ID_CREATECONTEXT)
GET_ID(CONST D3DKMT_DESTROYCONTEXT *, SYSTIMER_ID_DESTROYCONTEXT)
GET_ID(D3DKMT_CREATEALLOCATION *, SYSTIMER_ID_CREATEALLOCATION)
GET_ID(CONST D3DKMT_DESTROYALLOCATION *, SYSTIMER_ID_DESTROYALLOCATION)
GET_ID(D3DKMT_OPENRESOURCE *, SYSTIMER_ID_OPENRESOURCE)
GET_ID(D3DKMT_QUERYRESOURCEINFO *, SYSTIMER_ID_QUERYRESOURCEINFO)
GET_ID(D3DKMT_LOCK *, SYSTIMER_ID_LOCK)
GET_ID(CONST D3DKMT_UNLOCK *, SYSTIMER_ID_UNLOCK)
GET_ID(D3DKMT_RENDER *, SYSTIMER_ID_RENDER)
GET_ID(D3DKMT_CREATESYNCHRONIZATIONOBJECT *, SYSTIMER_ID_CREATESYNCHRONIZATIONOBJECT)
GET_ID(CONST D3DKMT_DESTROYSYNCHRONIZATIONOBJECT *, SYSTIMER_ID_DESTROYSYNCHRONIZATIONOBJECT)
GET_ID(CONST D3DKMT_SIGNALSYNCHRONIZATIONOBJECT *, SYSTIMER_ID_SIGNALSYNCHRONIZATIONOBJECT)
GET_ID(CONST_FROM_WDK_10_0_18328_0 D3DKMT_WAITFORSYNCHRONIZATIONOBJECT *, SYSTIMER_ID_WAITFORSYNCHRONIZATIONOBJECT)
GET_ID(D3DKMT_CREATESYNCHRONIZATIONOBJECT2 *, SYSTIMER_ID_CREATESYNCHRONIZATIONOBJECT2)
GET_ID(D3DKMT_GETDEVICESTATE *, SYSTIMER_ID_GETDEVICESTATE)
GET_ID(D3DDDI_MAKERESIDENT *, SYSTIMER_ID_MAKERESIDENT)
GET_ID(D3DKMT_EVICT *, SYSTIMER_ID_EVICT)
GET_ID(CONST D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU *, SYSTIMER_ID_WAITFORSYNCHRONIZATIONOBJECTFROMCPU)
GET_ID(CONST D3DKMT_SIGNALSYNCHRONIZATIONOBJECTFROMCPU *, SYSTIMER_ID_SIGNALSYNCHRONIZATIONOBJECTFROMCPU)
GET_ID(CONST D3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMGPU *, SYSTIMER_ID_WAITFORSYNCHRONIZATIONOBJECTFROMGPU)
GET_ID(CONST D3DKMT_SIGNALSYNCHRONIZATIONOBJECTFROMGPU *, SYSTIMER_ID_SIGNALSYNCHRONIZATIONOBJECTFROMGPU)
GET_ID(D3DKMT_CREATEPAGINGQUEUE *, SYSTIMER_ID_CREATEPAGINGQUEUE)
GET_ID(D3DDDI_DESTROYPAGINGQUEUE *, SYSTIMER_ID_D3DDDI_DESTROYPAGINGQUEUE)
GET_ID(D3DKMT_LOCK2 *, SYSTIMER_ID_LOCK2)
GET_ID(CONST D3DKMT_UNLOCK2 *, SYSTIMER_ID_UNLOCK2)
GET_ID(CONST D3DKMT_INVALIDATECACHE *, SYSTIMER_ID_INVALIDATECACHE)
GET_ID(D3DDDI_MAPGPUVIRTUALADDRESS *, SYSTIMER_ID_D3DDDI_MAPGPUVIRTUALADDRESS)
GET_ID(D3DDDI_RESERVEGPUVIRTUALADDRESS *, SYSTIMER_ID_D3DDDI_RESERVEGPUVIRTUALADDRESS)
GET_ID(CONST D3DKMT_FREEGPUVIRTUALADDRESS *, SYSTIMER_ID_FREEGPUVIRTUALADDRESS)
GET_ID(CONST D3DKMT_UPDATEGPUVIRTUALADDRESS *, SYSTIMER_ID_UPDATEGPUVIRTUALADDRESS)
GET_ID(D3DKMT_CREATECONTEXTVIRTUAL *, SYSTIMER_ID_CREATECONTEXTVIRTUAL)
GET_ID(CONST D3DKMT_SUBMITCOMMAND *, SYSTIMER_ID_SUBMITCOMMAND)
GET_ID(D3DKMT_OPENSYNCOBJECTFROMNTHANDLE2 *, SYSTIMER_ID_OPENSYNCOBJECTFROMNTHANDLE2)
GET_ID(D3DKMT_OPENSYNCOBJECTNTHANDLEFROMNAME *, SYSTIMER_ID_OPENSYNCOBJECTNTHANDLEFROMNAME)
GET_ID(CONST D3DKMT_DESTROYALLOCATION2 *, SYSTIMER_ID_DESTROYALLOCATION2)
GET_ID(D3DKMT_REGISTERTRIMNOTIFICATION *, SYSTIMER_ID_REGISTERTRIMNOTIFICATION)
GET_ID(D3DKMT_UNREGISTERTRIMNOTIFICATION *, SYSTIMER_ID_UNREGISTERTRIMNOTIFICATION)
GET_ID(D3DKMT_OPENRESOURCEFROMNTHANDLE *, SYSTIMER_ID_OPENRESOURCEFROMNTHANDLE)
GET_ID(D3DKMT_QUERYRESOURCEINFOFROMNTHANDLE *, SYSTIMER_ID_QUERYRESOURCEINFOFROMNTHANDLE)
GET_ID(D3DKMT_CREATEHWQUEUE *, SYSTIMER_ID_CREATEHWQUEUE)
GET_ID(CONST D3DKMT_DESTROYHWQUEUE *, SYSTIMER_ID_DESTROYHWQUEUE)
GET_ID(CONST D3DKMT_SUBMITCOMMANDTOHWQUEUE *, SYSTIMER_ID_SUBMITCOMMANDTOHWQUEUE)
GET_ID(CONST D3DKMT_SETALLOCATIONPRIORITY *, SYSTIMER_ID_SETALLOCATIONPRIORITY)
};
} // namespace NEO

View File

@ -65,12 +65,12 @@ bool isAllowedDeviceId(uint32_t deviceId) {
return (static_cast<uint32_t>(reqDeviceId) == deviceId);
}
DxCoreAdapterFactory::DxCoreAdapterFactory(DXCoreCreateAdapterFactoryFcn createAdapterFactoryFcn) : createAdapterFactoryFcn(createAdapterFactoryFcn) {
DxCoreAdapterFactory::DxCoreAdapterFactory(AdapterFactory::CreateAdapterFactoryFcn createAdapterFactoryFcn) : createAdapterFactoryFcn(createAdapterFactoryFcn) {
if (nullptr == createAdapterFactoryFcn) {
return;
}
HRESULT hr = createAdapterFactoryFcn(__uuidof(IDXCoreAdapterFactory), (void **)(&adapterFactory));
HRESULT hr = createAdapterFactoryFcn(__uuidof(adapterFactory), (void **)(&adapterFactory));
if (hr != S_OK) {
adapterFactory = nullptr;
}
@ -93,7 +93,7 @@ bool DxCoreAdapterFactory::createSnapshotOfAvailableAdapters() {
destroyCurrentSnapshot();
GUID attributes[]{DXCORE_ADAPTER_ATTRIBUTE_D3D12_CORE_COMPUTE};
HRESULT hr = adapterFactory->CreateAdapterList(1, attributes, __uuidof(IDXCoreAdapterList), (void **)(&adaptersInSnapshot));
HRESULT hr = adapterFactory->CreateAdapterList(1, attributes, __uuidof(adaptersInSnapshot), (void **)(&adaptersInSnapshot));
if ((hr != S_OK) || (adaptersInSnapshot == nullptr)) {
DEBUG_BREAK_IF(true);
destroyCurrentSnapshot();
@ -117,7 +117,7 @@ bool DxCoreAdapterFactory::getAdapterDesc(uint32_t ordinal, AdapterDesc &outAdap
}
IDXCoreAdapter *adapter = nullptr;
HRESULT hr = adaptersInSnapshot->GetAdapter(ordinal, __uuidof(IDXCoreAdapter), (void **)&adapter);
HRESULT hr = adaptersInSnapshot->GetAdapter(ordinal, __uuidof(adapter), (void **)&adapter);
if ((hr != S_OK) || (adapter == nullptr)) {
return false;
}
@ -144,7 +144,7 @@ bool DxCoreAdapterFactory::getAdapterDesc(uint32_t ordinal, AdapterDesc &outAdap
outAdapter.driverDescription = driverDescription.data();
DXCoreHardwareID hwId = {};
adapter->GetProperty(DXCoreAdapterProperty::HardwareID, sizeof(hwId), &hwId);
hr = adapter->GetProperty(DXCoreAdapterProperty::HardwareID, sizeof(hwId), &hwId);
DEBUG_BREAK_IF(S_OK != hr);
outAdapter.deviceId = hwId.deviceID;
@ -167,12 +167,12 @@ void DxCoreAdapterFactory::destroyCurrentSnapshot() {
}
}
DxgiAdapterFactory::DxgiAdapterFactory(CreateDXGIFactoryFcn createAdapterFactoryFcn) : createAdapterFactoryFcn(createAdapterFactoryFcn) {
DxgiAdapterFactory::DxgiAdapterFactory(AdapterFactory::CreateAdapterFactoryFcn createAdapterFactoryFcn) : createAdapterFactoryFcn(createAdapterFactoryFcn) {
if (nullptr == createAdapterFactoryFcn) {
return;
}
HRESULT hr = createAdapterFactoryFcn(__uuidof(IDXGIFactory), (void **)(&adapterFactory));
HRESULT hr = createAdapterFactoryFcn(__uuidof(adapterFactory), (void **)(&adapterFactory));
if (hr != S_OK) {
adapterFactory = nullptr;
}

View File

@ -31,6 +31,8 @@ bool isAllowedDeviceId(uint32_t deviceId);
class AdapterFactory {
public:
using CreateAdapterFactoryFcn = HRESULT(WINAPI *)(REFIID riid, void **ppFactory);
struct AdapterDesc {
enum class Type {
Unknown,
@ -54,8 +56,7 @@ class AdapterFactory {
class DxCoreAdapterFactory : public AdapterFactory {
public:
using DXCoreCreateAdapterFactoryFcn = HRESULT(WINAPI *)(REFIID riid, void **ppFactory);
DxCoreAdapterFactory(DXCoreCreateAdapterFactoryFcn createAdapterFactoryFcn);
DxCoreAdapterFactory(AdapterFactory::CreateAdapterFactoryFcn createAdapterFactoryFcn);
~DxCoreAdapterFactory() override;
@ -72,15 +73,14 @@ class DxCoreAdapterFactory : public AdapterFactory {
protected:
void destroyCurrentSnapshot();
DXCoreCreateAdapterFactoryFcn createAdapterFactoryFcn = nullptr;
AdapterFactory::CreateAdapterFactoryFcn createAdapterFactoryFcn = nullptr;
IDXCoreAdapterFactory *adapterFactory = nullptr;
IDXCoreAdapterList *adaptersInSnapshot = nullptr;
};
class DxgiAdapterFactory : public AdapterFactory {
public:
using CreateDXGIFactoryFcn = HRESULT(WINAPI *)(REFIID riid, void **ppFactory);
DxgiAdapterFactory(CreateDXGIFactoryFcn createAdapterFactoryFcn);
DxgiAdapterFactory(AdapterFactory::CreateAdapterFactoryFcn createAdapterFactoryFcn);
~DxgiAdapterFactory() override {
destroyCurrentSnapshot();
@ -106,15 +106,15 @@ class DxgiAdapterFactory : public AdapterFactory {
adaptersInSnapshot.clear();
}
CreateDXGIFactoryFcn createAdapterFactoryFcn = nullptr;
AdapterFactory::CreateAdapterFactoryFcn createAdapterFactoryFcn = nullptr;
IDXGIFactory1 *adapterFactory = nullptr;
std::vector<AdapterDesc> adaptersInSnapshot;
};
class WddmAdapterFactory : public AdapterFactory {
public:
WddmAdapterFactory(DxCoreAdapterFactory::DXCoreCreateAdapterFactoryFcn dxCoreCreateAdapterFactoryF,
DxgiAdapterFactory::CreateDXGIFactoryFcn dxgiCreateAdapterFactoryF) {
WddmAdapterFactory(AdapterFactory::CreateAdapterFactoryFcn dxCoreCreateAdapterFactoryF,
AdapterFactory::CreateAdapterFactoryFcn dxgiCreateAdapterFactoryF) {
underlyingFactory = std::make_unique<DxCoreAdapterFactory>(dxCoreCreateAdapterFactoryF);
if (false == underlyingFactory->isSupported()) {
underlyingFactory = std::make_unique<DxgiAdapterFactory>(dxgiCreateAdapterFactoryF);

View File

@ -7,6 +7,8 @@
#include "shared/source/os_interface/windows/wddm/um_km_data_translator.h"
#include "shared/source/helpers/string.h"
namespace NEO {
size_t UmKmDataTranslator::getSizeForAdapterInfoInternalRepresentation() {

View File

@ -71,9 +71,9 @@ struct UmKmDataTempStorageBase {
size_t requestedSize = 0U;
};
template <typename SrcT, size_t OverestimateMul = 2>
struct UmKmDataTempStorage : UmKmDataTempStorageBase<sizeof(SrcT) * OverestimateMul> {
using UmKmDataTempStorageBase::UmKmDataTempStorageBase;
template <typename SrcT, size_t OverestimateMul = 2, typename BaseT = UmKmDataTempStorageBase<sizeof(SrcT) * OverestimateMul>>
struct UmKmDataTempStorage : BaseT {
using BaseT::BaseT;
};
std::unique_ptr<UmKmDataTranslator> createUmKmDataTranslator(const Gdi &gdi, D3DKMT_HANDLE adapter);

View File

@ -17,6 +17,7 @@
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/heap_assigner.h"
#include "shared/source/helpers/interlocked_max.h"
#include "shared/source/helpers/string.h"
#include "shared/source/helpers/windows/gmm_callbacks.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/source/os_interface/windows/debug_registry_reader.h"
@ -32,6 +33,7 @@
#include "shared/source/os_interface/windows/wddm/wddm_residency_logger.h"
#include "shared/source/os_interface/windows/wddm_allocation.h"
#include "shared/source/os_interface/windows/wddm_engine_mapper.h"
#include "shared/source/os_interface/windows/wddm_memory_manager.h"
#include "shared/source/os_interface/windows/wddm_residency_allocations_container.h"
#include "shared/source/sku_info/operations/windows/sku_info_receiver.h"
#include "shared/source/utilities/stackvec.h"

View File

@ -12,7 +12,7 @@
namespace NEO {
Wddm::CreateDXGIFactoryFcn getCreateDxgiFactory() {
return DXCoreCreateAdapterFactory;
return CreateDXGIFactory;
}
Wddm::DXCoreCreateAdapterFactoryFcn getDXCoreCreateAdapterFactory() {

View File

@ -12,6 +12,7 @@
#include "shared/source/os_interface/windows/os_context_win.h"
#include "shared/source/os_interface/windows/wddm/um_km_data_translator.h"
#include "shared/source/os_interface/windows/wddm/wddm.h"
#include "shared/source/os_interface/windows/windows_wrapper.h"
using namespace NEO;
@ -58,7 +59,7 @@ void WddmInterface20::destroyMonitorFence(MonitoredFence &monitorFence) {
WddmInterface::destroyMonitorFence(monitorFence.fenceHandle);
}
const bool WddmInterface20::hwQueuesSupported() {
bool WddmInterface20::hwQueuesSupported() {
return false;
}
@ -137,7 +138,7 @@ void WddmInterface23::destroyHwQueue(D3DKMT_HANDLE hwQueue) {
}
}
const bool WddmInterface23::hwQueuesSupported() {
bool WddmInterface23::hwQueuesSupported() {
return true;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -33,7 +33,7 @@ class WddmInterface {
MOCKABLE_VIRTUAL bool createMonitoredFence(MonitoredFence &monitorFence);
void destroyMonitorFence(D3DKMT_HANDLE fenceHandle);
virtual void destroyMonitorFence(MonitoredFence &monitorFence) = 0;
virtual const bool hwQueuesSupported() = 0;
virtual bool hwQueuesSupported() = 0;
virtual bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, WddmSubmitArguments &submitArguments) = 0;
Wddm &wddm;
};
@ -45,7 +45,7 @@ class WddmInterface20 : public WddmInterface {
void destroyHwQueue(D3DKMT_HANDLE hwQueue) override;
bool createMonitoredFence(OsContextWin &osContext) override;
void destroyMonitorFence(MonitoredFence &monitorFence) override;
const bool hwQueuesSupported() override;
bool hwQueuesSupported() override;
bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, WddmSubmitArguments &submitArguments) override;
};
@ -56,7 +56,7 @@ class WddmInterface23 : public WddmInterface {
void destroyHwQueue(D3DKMT_HANDLE hwQueue) override;
bool createMonitoredFence(OsContextWin &osContext) override;
void destroyMonitorFence(MonitoredFence &monitorFence) override;
const bool hwQueuesSupported() override;
bool hwQueuesSupported() override;
bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, WddmSubmitArguments &submitArguments) override;
};
} // namespace NEO

View File

@ -7,6 +7,7 @@
#include "shared/source/os_interface/windows/wddm_memory_operations_handler.h"
#include "shared/source/helpers/string.h"
#include "shared/source/memory_manager/host_ptr_defines.h"
#include "shared/source/os_interface/windows/wddm_allocation.h"
#include "shared/source/os_interface/windows/wddm_residency_allocations_container.h"
@ -18,6 +19,8 @@ WddmMemoryOperationsHandler::WddmMemoryOperationsHandler(Wddm *wddm) : wddm(wddm
residentAllocations = std::make_unique<WddmResidentAllocationsContainer>(wddm);
}
WddmMemoryOperationsHandler::~WddmMemoryOperationsHandler() = default;
MemoryOperationsStatus WddmMemoryOperationsHandler::makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) {
uint32_t totalHandlesCount = 0;
constexpr uint32_t stackAllocations = 64;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 Intel Corporation
* Copyright (C) 2019-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -18,7 +18,7 @@ class WddmResidentAllocationsContainer;
class WddmMemoryOperationsHandler : public MemoryOperationsHandler {
public:
WddmMemoryOperationsHandler(Wddm *wddm);
~WddmMemoryOperationsHandler() override = default;
~WddmMemoryOperationsHandler() override;
MemoryOperationsStatus makeResident(Device *device, ArrayRef<GraphicsAllocation *> gfxAllocations) override;
MemoryOperationsStatus evict(Device *device, GraphicsAllocation &gfxAllocation) override;

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@ -7,7 +7,8 @@
#pragma once
#include "windows.h"
#include "shared/source/os_interface/windows/windows_wrapper.h"
#include <d3dkmthk.h>
#include <cstdint>

View File

@ -107,7 +107,6 @@ class MockGdi : public Gdi {
waitForSynchronizationObjectFromCpu = reinterpret_cast<PFND3DKMT_WAITFORSYNCHRONIZATIONOBJECTFROMCPU>(waitFromCpuMock);
queryResourceInfo = reinterpret_cast<PFND3DKMT_QUERYRESOURCEINFO>(queryResourceInfoMock);
openResource = reinterpret_cast<PFND3DKMT_OPENRESOURCE>(openResourceMock);
openAdapterFromHdc = reinterpret_cast<PFND3DKMT_OPENADAPTERFROMHDC>(MockGdi::openAdapterFromHdcMock);
return true;
}
@ -165,17 +164,6 @@ class MockGdi : public Gdi {
static D3DKMT_OPENRESOURCE openResource;
return openResource;
}
static NTSTATUS __stdcall openAdapterFromHdcMock(D3DKMT_OPENADAPTERFROMHDC *openAdapterFromHdcStruct) {
if (!openAdapterFromHdcStruct) {
return STATUS_INVALID_PARAMETER;
}
if (openAdapterFromHdcStruct->hDc == 0) {
return STATUS_INVALID_PARAMETER;
}
openAdapterFromHdcStruct->AdapterLuid = MockGdi::adapterLuidToReturn;
openAdapterFromHdcStruct->hAdapter = MockGdi::adapterHandleForHdc;
return STATUS_SUCCESS;
}
};
} // namespace NEO