mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Wddm 2.3 improvements
- Dont create synchronization object manually - take it from HW queue - Construct MonitoredFence from HwQueue object - D3DKMT_SUBMITCOMMANDTOHWQUEUE should get currentFenceValue instead of its handle - Dont pass MonitoredFenceVa/Value in cmd buffer header Change-Id: I4717119379cef2f0e641ce9f4ef614089491a85d Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com> Related-To: NEO-3728
This commit is contained in:

committed by
sys_ocldev

parent
49e17d734e
commit
c0c6a46ece
@ -34,12 +34,12 @@ OsContextWin::OsContextWin(Wddm &wddm, uint32_t contextId, DeviceBitfield device
|
||||
return;
|
||||
}
|
||||
}
|
||||
initialized = wddmInterface->createMonitoredFence(residencyController);
|
||||
initialized = wddmInterface->createMonitoredFence(*this);
|
||||
residencyController.registerCallback();
|
||||
};
|
||||
|
||||
OsContextWin::~OsContextWin() {
|
||||
wddm.getWddmInterface()->destroyHwQueue(hwQueueHandle);
|
||||
wddm.getWddmInterface()->destroyHwQueue(hardwareQueue.handle);
|
||||
wddm.destroyContext(wddmContextHandle);
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,14 @@
|
||||
namespace NEO {
|
||||
|
||||
class Wddm;
|
||||
|
||||
struct HardwareQueue {
|
||||
D3DKMT_HANDLE handle = 0;
|
||||
D3DKMT_HANDLE progressFenceHandle = 0;
|
||||
VOID *progressFenceCpuVA = nullptr;
|
||||
D3DGPU_VIRTUAL_ADDRESS progressFenceGpuVA = 0;
|
||||
};
|
||||
|
||||
class OsContextWin : public OsContext {
|
||||
public:
|
||||
OsContextWin() = delete;
|
||||
@ -22,16 +30,16 @@ class OsContextWin : public OsContext {
|
||||
|
||||
D3DKMT_HANDLE getWddmContextHandle() const { return wddmContextHandle; }
|
||||
void setWddmContextHandle(D3DKMT_HANDLE wddmContextHandle) { this->wddmContextHandle = wddmContextHandle; }
|
||||
D3DKMT_HANDLE getHwQueue() const { return hwQueueHandle; }
|
||||
void setHwQueue(D3DKMT_HANDLE hwQueue) { hwQueueHandle = hwQueue; }
|
||||
HardwareQueue getHwQueue() const { return hardwareQueue; }
|
||||
void setHwQueue(HardwareQueue hardwareQueue) { this->hardwareQueue = hardwareQueue; }
|
||||
bool isInitialized() const { return initialized; }
|
||||
Wddm *getWddm() const { return &wddm; }
|
||||
WddmResidencyController &getResidencyController() { return residencyController; }
|
||||
MOCKABLE_VIRTUAL WddmResidencyController &getResidencyController() { return residencyController; }
|
||||
|
||||
protected:
|
||||
bool initialized = false;
|
||||
D3DKMT_HANDLE wddmContextHandle = 0;
|
||||
D3DKMT_HANDLE hwQueueHandle = 0;
|
||||
HardwareQueue hardwareQueue;
|
||||
Wddm &wddm;
|
||||
WddmResidencyController residencyController;
|
||||
};
|
||||
|
@ -19,7 +19,8 @@ bool WddmInterface20::createHwQueue(OsContextWin &osContext) {
|
||||
}
|
||||
void WddmInterface20::destroyHwQueue(D3DKMT_HANDLE hwQueue) {}
|
||||
|
||||
bool WddmInterface::createMonitoredFence(WddmResidencyController &residencyController) {
|
||||
bool WddmInterface20::createMonitoredFence(OsContextWin &osContext) {
|
||||
auto &residencyController = osContext.getResidencyController();
|
||||
NTSTATUS Status;
|
||||
D3DKMT_CREATESYNCHRONIZATIONOBJECT2 CreateSynchronizationObject = {0};
|
||||
CreateSynchronizationObject.hDevice = wddm.getDevice();
|
||||
@ -80,11 +81,21 @@ bool WddmInterface23::createHwQueue(OsContextWin &osContext) {
|
||||
|
||||
auto status = wddm.getGdi()->createHwQueue(&createHwQueue);
|
||||
UNRECOVERABLE_IF(status != STATUS_SUCCESS);
|
||||
osContext.setHwQueue(createHwQueue.hHwQueue);
|
||||
osContext.setHwQueue({createHwQueue.hHwQueue, createHwQueue.hHwQueueProgressFence, createHwQueue.HwQueueProgressFenceCPUVirtualAddress,
|
||||
createHwQueue.HwQueueProgressFenceGPUVirtualAddress});
|
||||
|
||||
return status == STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bool WddmInterface23::createMonitoredFence(OsContextWin &osContext) {
|
||||
auto &residencyController = osContext.getResidencyController();
|
||||
auto hwQueue = osContext.getHwQueue();
|
||||
residencyController.resetMonitoredFenceParams(hwQueue.progressFenceHandle,
|
||||
reinterpret_cast<uint64_t *>(hwQueue.progressFenceCpuVA),
|
||||
hwQueue.progressFenceGpuVA);
|
||||
return true;
|
||||
}
|
||||
|
||||
void WddmInterface23::destroyHwQueue(D3DKMT_HANDLE hwQueue) {
|
||||
if (hwQueue) {
|
||||
D3DKMT_DESTROYHWQUEUE destroyHwQueue = {};
|
||||
@ -103,15 +114,11 @@ bool WddmInterface23::submit(uint64_t commandBuffer, size_t size, void *commandH
|
||||
auto monitoredFence = osContext.getResidencyController().getMonitoredFence();
|
||||
|
||||
D3DKMT_SUBMITCOMMANDTOHWQUEUE submitCommand = {};
|
||||
submitCommand.hHwQueue = osContext.getHwQueue();
|
||||
submitCommand.HwQueueProgressFenceId = monitoredFence.fenceHandle;
|
||||
submitCommand.hHwQueue = osContext.getHwQueue().handle;
|
||||
submitCommand.HwQueueProgressFenceId = monitoredFence.currentFenceValue;
|
||||
submitCommand.CommandBuffer = commandBuffer;
|
||||
submitCommand.CommandLength = static_cast<UINT>(size);
|
||||
|
||||
COMMAND_BUFFER_HEADER *pHeader = reinterpret_cast<COMMAND_BUFFER_HEADER *>(commandHeader);
|
||||
pHeader->MonitorFenceVA = monitoredFence.gpuAddress;
|
||||
pHeader->MonitorFenceValue = monitoredFence.currentFenceValue;
|
||||
|
||||
submitCommand.pPrivateDriverData = commandHeader;
|
||||
submitCommand.PrivateDriverDataSize = MemoryConstants::pageSize;
|
||||
|
||||
|
@ -27,7 +27,7 @@ class WddmInterface {
|
||||
WddmInterface() = delete;
|
||||
virtual bool createHwQueue(OsContextWin &osContext) = 0;
|
||||
virtual void destroyHwQueue(D3DKMT_HANDLE hwQueue) = 0;
|
||||
bool createMonitoredFence(WddmResidencyController &residencyController);
|
||||
virtual bool createMonitoredFence(OsContextWin &osContext) = 0;
|
||||
virtual const bool hwQueuesSupported() = 0;
|
||||
virtual bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) = 0;
|
||||
Wddm &wddm;
|
||||
@ -38,6 +38,7 @@ class WddmInterface20 : public WddmInterface {
|
||||
using WddmInterface::WddmInterface;
|
||||
bool createHwQueue(OsContextWin &osContext) override;
|
||||
void destroyHwQueue(D3DKMT_HANDLE hwQueue) override;
|
||||
bool createMonitoredFence(OsContextWin &osContext) override;
|
||||
const bool hwQueuesSupported() override;
|
||||
bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) override;
|
||||
};
|
||||
@ -47,6 +48,7 @@ class WddmInterface23 : public WddmInterface {
|
||||
using WddmInterface::WddmInterface;
|
||||
bool createHwQueue(OsContextWin &osContext) override;
|
||||
void destroyHwQueue(D3DKMT_HANDLE hwQueue) override;
|
||||
bool createMonitoredFence(OsContextWin &osContext) override;
|
||||
const bool hwQueuesSupported() override;
|
||||
bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) override;
|
||||
};
|
||||
|
Reference in New Issue
Block a user