Pass OsContextWin object during Wddm context creation
Change-Id: Iba8d801bb6af4e9d28681caddb9c487500a42c8c Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
parent
2ec68a31ba
commit
0939743874
|
@ -115,7 +115,7 @@ void signalArbSyncObject(OsContext &osContext, CL_GL_SYNC_INFO &glSyncInfo) {
|
||||||
auto wddm = osContextWin->getWddm();
|
auto wddm = osContextWin->getWddm();
|
||||||
|
|
||||||
D3DKMT_SIGNALSYNCHRONIZATIONOBJECT signalServerClientSyncInfo = {0};
|
D3DKMT_SIGNALSYNCHRONIZATIONOBJECT signalServerClientSyncInfo = {0};
|
||||||
signalServerClientSyncInfo.hContext = osContextWin->getContext();
|
signalServerClientSyncInfo.hContext = osContextWin->getWddmContextHandle();
|
||||||
signalServerClientSyncInfo.Flags.SignalAtSubmission = 0; // Wait for GPU to complete processing command buffer
|
signalServerClientSyncInfo.Flags.SignalAtSubmission = 0; // Wait for GPU to complete processing command buffer
|
||||||
signalServerClientSyncInfo.ObjectHandleArray[0] = glSyncInfo.serverSynchronizationObject;
|
signalServerClientSyncInfo.ObjectHandleArray[0] = glSyncInfo.serverSynchronizationObject;
|
||||||
signalServerClientSyncInfo.ObjectHandleArray[1] = glSyncInfo.clientSynchronizationObject;
|
signalServerClientSyncInfo.ObjectHandleArray[1] = glSyncInfo.clientSynchronizationObject;
|
||||||
|
@ -127,7 +127,7 @@ void signalArbSyncObject(OsContext &osContext, CL_GL_SYNC_INFO &glSyncInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
D3DKMT_SIGNALSYNCHRONIZATIONOBJECT signalSubmissionSyncInfo = {0};
|
D3DKMT_SIGNALSYNCHRONIZATIONOBJECT signalSubmissionSyncInfo = {0};
|
||||||
signalSubmissionSyncInfo.hContext = osContextWin->getContext();
|
signalSubmissionSyncInfo.hContext = osContextWin->getWddmContextHandle();
|
||||||
signalSubmissionSyncInfo.Flags.SignalAtSubmission = 1; // Don't wait for GPU to complete processing command buffer
|
signalSubmissionSyncInfo.Flags.SignalAtSubmission = 1; // Don't wait for GPU to complete processing command buffer
|
||||||
signalSubmissionSyncInfo.ObjectHandleArray[0] = glSyncInfo.submissionSynchronizationObject;
|
signalSubmissionSyncInfo.ObjectHandleArray[0] = glSyncInfo.submissionSynchronizationObject;
|
||||||
signalSubmissionSyncInfo.ObjectCount = 1;
|
signalSubmissionSyncInfo.ObjectCount = 1;
|
||||||
|
|
|
@ -28,7 +28,7 @@ OsContextWin::OsContextWin(Wddm &wddm, uint32_t contextId, uint32_t numDevicesSu
|
||||||
UNRECOVERABLE_IF(!wddm.isInitialized());
|
UNRECOVERABLE_IF(!wddm.isInitialized());
|
||||||
|
|
||||||
auto wddmInterface = wddm.getWddmInterface();
|
auto wddmInterface = wddm.getWddmInterface();
|
||||||
if (!wddm.createContext(context, engineType, preemptionMode)) {
|
if (!wddm.createContext(*this)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (wddmInterface->hwQueuesSupported()) {
|
if (wddmInterface->hwQueuesSupported()) {
|
||||||
|
@ -42,7 +42,7 @@ OsContextWin::OsContextWin(Wddm &wddm, uint32_t contextId, uint32_t numDevicesSu
|
||||||
|
|
||||||
OsContextWin::~OsContextWin() {
|
OsContextWin::~OsContextWin() {
|
||||||
wddm.getWddmInterface()->destroyHwQueue(hwQueueHandle);
|
wddm.getWddmInterface()->destroyHwQueue(hwQueueHandle);
|
||||||
wddm.destroyContext(context);
|
wddm.destroyContext(wddmContextHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace OCLRT
|
} // namespace OCLRT
|
||||||
|
|
|
@ -20,24 +20,17 @@ class OsContextWin : public OsContext {
|
||||||
OsContextWin(Wddm &wddm, uint32_t contextId, uint32_t numDevicesSupported,
|
OsContextWin(Wddm &wddm, uint32_t contextId, uint32_t numDevicesSupported,
|
||||||
EngineInstanceT engineType, PreemptionMode preemptionMode);
|
EngineInstanceT engineType, PreemptionMode preemptionMode);
|
||||||
|
|
||||||
D3DKMT_HANDLE getContext() const {
|
D3DKMT_HANDLE getWddmContextHandle() const { return wddmContextHandle; }
|
||||||
return context;
|
void setWddmContextHandle(D3DKMT_HANDLE wddmContextHandle) { this->wddmContextHandle = wddmContextHandle; }
|
||||||
}
|
D3DKMT_HANDLE getHwQueue() const { return hwQueueHandle; }
|
||||||
D3DKMT_HANDLE getHwQueue() const {
|
void setHwQueue(D3DKMT_HANDLE hwQueue) { hwQueueHandle = hwQueue; }
|
||||||
return hwQueueHandle;
|
bool isInitialized() const { return initialized; }
|
||||||
}
|
|
||||||
void setHwQueue(D3DKMT_HANDLE hwQueue) {
|
|
||||||
hwQueueHandle = hwQueue;
|
|
||||||
}
|
|
||||||
bool isInitialized() const {
|
|
||||||
return initialized;
|
|
||||||
}
|
|
||||||
Wddm *getWddm() const { return &wddm; }
|
Wddm *getWddm() const { return &wddm; }
|
||||||
WddmResidencyController &getResidencyController() { return residencyController; }
|
WddmResidencyController &getResidencyController() { return residencyController; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
D3DKMT_HANDLE context = 0;
|
D3DKMT_HANDLE wddmContextHandle = 0;
|
||||||
D3DKMT_HANDLE hwQueueHandle = 0;
|
D3DKMT_HANDLE hwQueueHandle = 0;
|
||||||
Wddm &wddm;
|
Wddm &wddm;
|
||||||
WddmResidencyController residencyController;
|
WddmResidencyController residencyController;
|
||||||
|
|
|
@ -677,7 +677,7 @@ void Wddm::kmDafLock(WddmAllocation *wddmAllocation) {
|
||||||
kmDafListener->notifyLock(featureTable->ftrKmdDaf, adapter, device, wddmAllocation->handle, 0, gdi->escape);
|
kmDafListener->notifyLock(featureTable->ftrKmdDaf, adapter, device, wddmAllocation->handle, 0, gdi->escape);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Wddm::createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType, PreemptionMode preemptionMode) {
|
bool Wddm::createContext(OsContextWin &osContext) {
|
||||||
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
NTSTATUS status = STATUS_UNSUCCESSFUL;
|
||||||
D3DKMT_CREATECONTEXTVIRTUAL CreateContext = {0};
|
D3DKMT_CREATECONTEXTVIRTUAL CreateContext = {0};
|
||||||
CREATECONTEXT_PVTDATA PrivateData = {{0}};
|
CREATECONTEXT_PVTDATA PrivateData = {{0}};
|
||||||
|
@ -689,24 +689,24 @@ bool Wddm::createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType, Pre
|
||||||
PrivateData.pHwContextId = &hwContextId;
|
PrivateData.pHwContextId = &hwContextId;
|
||||||
PrivateData.IsMediaUsage = false;
|
PrivateData.IsMediaUsage = false;
|
||||||
PrivateData.NoRingFlushes = DebugManager.flags.UseNoRingFlushesKmdMode.get();
|
PrivateData.NoRingFlushes = DebugManager.flags.UseNoRingFlushesKmdMode.get();
|
||||||
applyAdditionalContextFlags(PrivateData);
|
applyAdditionalContextFlags(PrivateData, osContext);
|
||||||
|
|
||||||
CreateContext.EngineAffinity = 0;
|
CreateContext.EngineAffinity = 0;
|
||||||
CreateContext.Flags.NullRendering = static_cast<UINT>(DebugManager.flags.EnableNullHardware.get());
|
CreateContext.Flags.NullRendering = static_cast<UINT>(DebugManager.flags.EnableNullHardware.get());
|
||||||
CreateContext.Flags.HwQueueSupported = wddmInterface->hwQueuesSupported();
|
CreateContext.Flags.HwQueueSupported = wddmInterface->hwQueuesSupported();
|
||||||
|
|
||||||
if (preemptionMode >= PreemptionMode::MidBatch) {
|
if (osContext.getPreemptionMode() >= PreemptionMode::MidBatch) {
|
||||||
CreateContext.Flags.DisableGpuTimeout = readEnablePreemptionRegKey();
|
CreateContext.Flags.DisableGpuTimeout = readEnablePreemptionRegKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateContext.PrivateDriverDataSize = sizeof(PrivateData);
|
CreateContext.PrivateDriverDataSize = sizeof(PrivateData);
|
||||||
CreateContext.NodeOrdinal = WddmEngineMapper::engineNodeMap(engineType.type);
|
CreateContext.NodeOrdinal = WddmEngineMapper::engineNodeMap(osContext.getEngineType().type);
|
||||||
CreateContext.pPrivateDriverData = &PrivateData;
|
CreateContext.pPrivateDriverData = &PrivateData;
|
||||||
CreateContext.ClientHint = D3DKMT_CLIENTHINT_OPENGL;
|
CreateContext.ClientHint = D3DKMT_CLIENTHINT_OPENGL;
|
||||||
CreateContext.hDevice = device;
|
CreateContext.hDevice = device;
|
||||||
|
|
||||||
status = gdi->createContext(&CreateContext);
|
status = gdi->createContext(&CreateContext);
|
||||||
context = CreateContext.hContext;
|
osContext.setWddmContextHandle(CreateContext.hContext);
|
||||||
|
|
||||||
return status == STATUS_SUCCESS;
|
return status == STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -724,7 +724,7 @@ bool Wddm::destroyContext(D3DKMT_HANDLE context) {
|
||||||
|
|
||||||
bool Wddm::submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) {
|
bool Wddm::submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) {
|
||||||
bool status = false;
|
bool status = false;
|
||||||
if (currentPagingFenceValue > *pagingFenceAddress && !waitOnGPU(osContext.getContext())) {
|
if (currentPagingFenceValue > *pagingFenceAddress && !waitOnGPU(osContext.getWddmContextHandle())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "currentFenceValue =", osContext.getResidencyController().getMonitoredFence().currentFenceValue);
|
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "currentFenceValue =", osContext.getResidencyController().getMonitoredFence().currentFenceValue);
|
||||||
|
|
|
@ -60,8 +60,8 @@ class Wddm {
|
||||||
bool mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr);
|
bool mapGpuVirtualAddress(WddmAllocation *allocation, void *cpuPtr);
|
||||||
bool mapGpuVirtualAddress(AllocationStorageData *allocationStorageData);
|
bool mapGpuVirtualAddress(AllocationStorageData *allocationStorageData);
|
||||||
D3DGPU_VIRTUAL_ADDRESS reserveGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS minimumAddress, D3DGPU_VIRTUAL_ADDRESS maximumAddress, D3DGPU_SIZE_T size);
|
D3DGPU_VIRTUAL_ADDRESS reserveGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS minimumAddress, D3DGPU_VIRTUAL_ADDRESS maximumAddress, D3DGPU_SIZE_T size);
|
||||||
MOCKABLE_VIRTUAL bool createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType, PreemptionMode preemptionMode);
|
MOCKABLE_VIRTUAL bool createContext(OsContextWin &osContext);
|
||||||
MOCKABLE_VIRTUAL void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData);
|
MOCKABLE_VIRTUAL void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData, OsContextWin &osContext);
|
||||||
MOCKABLE_VIRTUAL bool freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size);
|
MOCKABLE_VIRTUAL bool freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size);
|
||||||
MOCKABLE_VIRTUAL NTSTATUS createAllocation(WddmAllocation *alloc);
|
MOCKABLE_VIRTUAL NTSTATUS createAllocation(WddmAllocation *alloc);
|
||||||
MOCKABLE_VIRTUAL bool createAllocation64k(WddmAllocation *alloc);
|
MOCKABLE_VIRTUAL bool createAllocation64k(WddmAllocation *alloc);
|
||||||
|
|
|
@ -49,7 +49,7 @@ bool WddmInterface20::submit(uint64_t commandBuffer, size_t size, void *commandH
|
||||||
SubmitCommand.Commands = commandBuffer;
|
SubmitCommand.Commands = commandBuffer;
|
||||||
SubmitCommand.CommandLength = static_cast<UINT>(size);
|
SubmitCommand.CommandLength = static_cast<UINT>(size);
|
||||||
SubmitCommand.BroadcastContextCount = 1;
|
SubmitCommand.BroadcastContextCount = 1;
|
||||||
SubmitCommand.BroadcastContext[0] = osContext.getContext();
|
SubmitCommand.BroadcastContext[0] = osContext.getWddmContextHandle();
|
||||||
SubmitCommand.Flags.NullRendering = (UINT)DebugManager.flags.EnableNullHardware.get();
|
SubmitCommand.Flags.NullRendering = (UINT)DebugManager.flags.EnableNullHardware.get();
|
||||||
|
|
||||||
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
|
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
|
||||||
|
@ -73,7 +73,7 @@ bool WddmInterface23::createHwQueue(OsContextWin &osContext) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
createHwQueue.hHwContext = osContext.getContext();
|
createHwQueue.hHwContext = osContext.getWddmContextHandle();
|
||||||
if (osContext.getPreemptionMode() >= PreemptionMode::MidBatch) {
|
if (osContext.getPreemptionMode() >= PreemptionMode::MidBatch) {
|
||||||
createHwQueue.Flags.DisableGpuTimeout = wddm.readEnablePreemptionRegKey();
|
createHwQueue.Flags.DisableGpuTimeout = wddm.readEnablePreemptionRegKey();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2018 Intel Corporation
|
* Copyright (C) 2018-2019 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
|
@ -8,6 +8,6 @@
|
||||||
#include "runtime/os_interface/windows/wddm/wddm.h"
|
#include "runtime/os_interface/windows/wddm/wddm.h"
|
||||||
|
|
||||||
namespace OCLRT {
|
namespace OCLRT {
|
||||||
void Wddm::applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData) {
|
void Wddm::applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData, OsContextWin &osContext) {
|
||||||
}
|
}
|
||||||
} // namespace OCLRT
|
} // namespace OCLRT
|
||||||
|
|
|
@ -103,14 +103,14 @@ bool WddmMock::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WddmMock::createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType, PreemptionMode preemptionMode) {
|
bool WddmMock::createContext(OsContextWin &osContext) {
|
||||||
createContextResult.called++;
|
createContextResult.called++;
|
||||||
return createContextResult.success = Wddm::createContext(context, engineType, preemptionMode);
|
return createContextResult.success = Wddm::createContext(osContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WddmMock::applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData) {
|
void WddmMock::applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData, OsContextWin &osContext) {
|
||||||
applyAdditionalContextFlagsResult.called++;
|
applyAdditionalContextFlagsResult.called++;
|
||||||
Wddm::applyAdditionalContextFlags(privateData);
|
Wddm::applyAdditionalContextFlags(privateData, osContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WddmMock::destroyContext(D3DKMT_HANDLE context) {
|
bool WddmMock::destroyContext(D3DKMT_HANDLE context) {
|
||||||
|
|
|
@ -67,8 +67,8 @@ class WddmMock : public Wddm {
|
||||||
bool destroyAllocations(D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) override;
|
bool destroyAllocations(D3DKMT_HANDLE *handles, uint32_t allocationCount, D3DKMT_HANDLE resourceHandle) override;
|
||||||
bool destroyAllocation(WddmAllocation *alloc, OsContextWin *osContext);
|
bool destroyAllocation(WddmAllocation *alloc, OsContextWin *osContext);
|
||||||
bool openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) override;
|
bool openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) override;
|
||||||
bool createContext(D3DKMT_HANDLE &context, EngineInstanceT engineType, PreemptionMode preemptionMode) override;
|
bool createContext(OsContextWin &osContext) override;
|
||||||
void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData) override;
|
void applyAdditionalContextFlags(CREATECONTEXT_PVTDATA &privateData, OsContextWin &osContext) override;
|
||||||
bool destroyContext(D3DKMT_HANDLE context) override;
|
bool destroyContext(D3DKMT_HANDLE context) override;
|
||||||
bool queryAdapterInfo() override;
|
bool queryAdapterInfo() override;
|
||||||
bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) override;
|
bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) override;
|
||||||
|
|
|
@ -333,7 +333,7 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToSignalArbSyncObjectWhenSignalSynchroniza
|
||||||
syncInfo.clientSynchronizationObject = 0x6cU;
|
syncInfo.clientSynchronizationObject = 0x6cU;
|
||||||
|
|
||||||
gdi->signalSynchronizationObject.mFunc = FailSignalSyncObjectMock::signal;
|
gdi->signalSynchronizationObject.mFunc = FailSignalSyncObjectMock::signal;
|
||||||
FailSignalSyncObjectMock::getExpectedContextHandle() = osContext.getContext();
|
FailSignalSyncObjectMock::getExpectedContextHandle() = osContext.getWddmContextHandle();
|
||||||
FailSignalSyncObjectMock::getExpectedSynchHandle0() = syncInfo.serverSynchronizationObject;
|
FailSignalSyncObjectMock::getExpectedSynchHandle0() = syncInfo.serverSynchronizationObject;
|
||||||
FailSignalSyncObjectMock::getExpectedSynchHandle1() = syncInfo.clientSynchronizationObject;
|
FailSignalSyncObjectMock::getExpectedSynchHandle1() = syncInfo.clientSynchronizationObject;
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ TEST_F(GlArbSyncEventOsTest, GivenCallToSignalArbSyncObjectWhenSignalSynchroniza
|
||||||
syncInfo.submissionSynchronizationObject = 0x7cU;
|
syncInfo.submissionSynchronizationObject = 0x7cU;
|
||||||
|
|
||||||
gdi->signalSynchronizationObject.mFunc = FailSignalSyncObjectMock::signal;
|
gdi->signalSynchronizationObject.mFunc = FailSignalSyncObjectMock::signal;
|
||||||
FailSignalSyncObjectMock::getExpectedContextHandle() = osContext.getContext();
|
FailSignalSyncObjectMock::getExpectedContextHandle() = osContext.getWddmContextHandle();
|
||||||
FailSignalSyncObjectMock::getExpectedSynchHandle0() = syncInfo.submissionSynchronizationObject;
|
FailSignalSyncObjectMock::getExpectedSynchHandle0() = syncInfo.submissionSynchronizationObject;
|
||||||
|
|
||||||
signalArbSyncObject(osContext, syncInfo);
|
signalArbSyncObject(osContext, syncInfo);
|
||||||
|
|
|
@ -164,7 +164,7 @@ TEST(Wddm20EnumAdaptersTest, givenUnknownPlatformWhenEnumAdapterIsCalledThenFals
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Wddm20Tests, whenInitializeWddmThenContextIsCreated) {
|
TEST_F(Wddm20Tests, whenInitializeWddmThenContextIsCreated) {
|
||||||
auto context = osContext->getContext();
|
auto context = osContext->getWddmContextHandle();
|
||||||
EXPECT_TRUE(context != static_cast<D3DKMT_HANDLE>(0));
|
EXPECT_TRUE(context != static_cast<D3DKMT_HANDLE>(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue