Skip to content

Commit 53c4d29

Browse files
Update Wddm23 interface
Change-Id: I8c1484875f28dd7f2591db810c64b117f49f70e3
1 parent bcceab5 commit 53c4d29

File tree

4 files changed

+28
-34
lines changed

4 files changed

+28
-34
lines changed

runtime/os_interface/windows/wddm/wddm_interface.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,20 @@
2020
* OTHER DEALINGS IN THE SOFTWARE.
2121
*/
2222

23+
#include "runtime/memory_manager/memory_constants.h"
2324
#include "runtime/os_interface/windows/gdi_interface.h"
2425
#include "runtime/os_interface/windows/wddm/wddm_interface.h"
2526
#include "runtime/os_interface/windows/wddm/wddm.h"
2627
#include "runtime/os_interface/windows/os_context_win.h"
2728

28-
bool OCLRT::WddmInterface20::createHwQueue(PreemptionMode preemptionMode, OsContextWin &osContext) {
29+
using namespace OCLRT;
30+
31+
bool WddmInterface20::createHwQueue(PreemptionMode preemptionMode, OsContextWin &osContext) {
2932
return false;
3033
}
31-
void OCLRT::WddmInterface20::destroyHwQueue(D3DKMT_HANDLE hwQueue) {}
34+
void WddmInterface20::destroyHwQueue(D3DKMT_HANDLE hwQueue) {}
3235

33-
bool OCLRT::WddmInterface20::createMonitoredFence(OsContextWin &osContext) {
36+
bool WddmInterface::createMonitoredFence(OsContextWin &osContext) {
3437
NTSTATUS Status;
3538
D3DKMT_CREATESYNCHRONIZATIONOBJECT2 CreateSynchronizationObject = {0};
3639
CreateSynchronizationObject.hDevice = wddm.getDevice();
@@ -48,11 +51,11 @@ bool OCLRT::WddmInterface20::createMonitoredFence(OsContextWin &osContext) {
4851
return Status == STATUS_SUCCESS;
4952
}
5053

51-
const bool OCLRT::WddmInterface20::hwQueuesSupported() {
54+
const bool WddmInterface20::hwQueuesSupported() {
5255
return false;
5356
}
5457

55-
bool OCLRT::WddmInterface20::submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) {
58+
bool WddmInterface20::submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) {
5659
D3DKMT_SUBMITCOMMAND SubmitCommand = {0};
5760
NTSTATUS status = STATUS_SUCCESS;
5861

@@ -77,7 +80,7 @@ bool OCLRT::WddmInterface20::submit(uint64_t commandBuffer, size_t size, void *c
7780
return STATUS_SUCCESS == status;
7881
}
7982

80-
bool OCLRT::WddmInterface23::createHwQueue(PreemptionMode preemptionMode, OsContextWin &osContext) {
83+
bool WddmInterface23::createHwQueue(PreemptionMode preemptionMode, OsContextWin &osContext) {
8184
D3DKMT_CREATEHWQUEUE createHwQueue = {};
8285

8386
if (!wddm.getGdi()->setupHwQueueProcAddresses()) {
@@ -93,14 +96,10 @@ bool OCLRT::WddmInterface23::createHwQueue(PreemptionMode preemptionMode, OsCont
9396
UNRECOVERABLE_IF(status != STATUS_SUCCESS);
9497
osContext.setHwQueue(createHwQueue.hHwQueue);
9598

96-
osContext.resetMonitoredFenceParams(createHwQueue.hHwQueueProgressFence,
97-
reinterpret_cast<uint64_t *>(createHwQueue.HwQueueProgressFenceCPUVirtualAddress),
98-
createHwQueue.HwQueueProgressFenceGPUVirtualAddress);
99-
10099
return status == STATUS_SUCCESS;
101100
}
102101

103-
void OCLRT::WddmInterface23::destroyHwQueue(D3DKMT_HANDLE hwQueue) {
102+
void WddmInterface23::destroyHwQueue(D3DKMT_HANDLE hwQueue) {
104103
if (hwQueue) {
105104
D3DKMT_DESTROYHWQUEUE destroyHwQueue = {};
106105
destroyHwQueue.hHwQueue = hwQueue;
@@ -110,15 +109,11 @@ void OCLRT::WddmInterface23::destroyHwQueue(D3DKMT_HANDLE hwQueue) {
110109
}
111110
}
112111

113-
bool OCLRT::WddmInterface23::createMonitoredFence(OsContextWin &osContext) {
114-
return true;
115-
}
116-
117-
const bool OCLRT::WddmInterface23::hwQueuesSupported() {
112+
const bool WddmInterface23::hwQueuesSupported() {
118113
return true;
119114
}
120115

121-
bool OCLRT::WddmInterface23::submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) {
116+
bool WddmInterface23::submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) {
122117
auto monitoredFence = osContext.getMonitoredFence();
123118

124119
D3DKMT_SUBMITCOMMANDTOHWQUEUE submitCommand = {};
@@ -132,7 +127,7 @@ bool OCLRT::WddmInterface23::submit(uint64_t commandBuffer, size_t size, void *c
132127
pHeader->MonitorFenceValue = monitoredFence.currentFenceValue;
133128

134129
submitCommand.pPrivateDriverData = commandHeader;
135-
submitCommand.PrivateDriverDataSize = sizeof(COMMAND_BUFFER_HEADER);
130+
submitCommand.PrivateDriverDataSize = MemoryConstants::pageSize;
136131

137132
auto status = wddm.getGdi()->submitCommandToHwQueue(&submitCommand);
138133
UNRECOVERABLE_IF(status != STATUS_SUCCESS);

runtime/os_interface/windows/wddm/wddm_interface.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class WddmInterface {
3939
WddmInterface() = delete;
4040
virtual bool createHwQueue(PreemptionMode preemptionMode, OsContextWin &osContext) = 0;
4141
virtual void destroyHwQueue(D3DKMT_HANDLE hwQueue) = 0;
42-
virtual bool createMonitoredFence(OsContextWin &osContext) = 0;
42+
bool createMonitoredFence(OsContextWin &osContext);
4343
virtual const bool hwQueuesSupported() = 0;
4444
virtual bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) = 0;
4545
Wddm &wddm;
@@ -50,7 +50,6 @@ class WddmInterface20 : public WddmInterface {
5050
using WddmInterface::WddmInterface;
5151
bool createHwQueue(PreemptionMode preemptionMode, OsContextWin &osContext) override;
5252
void destroyHwQueue(D3DKMT_HANDLE hwQueue) override;
53-
bool createMonitoredFence(OsContextWin &osContext) override;
5453
const bool hwQueuesSupported() override;
5554
bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) override;
5655
};
@@ -60,7 +59,6 @@ class WddmInterface23 : public WddmInterface {
6059
using WddmInterface::WddmInterface;
6160
bool createHwQueue(PreemptionMode preemptionMode, OsContextWin &osContext) override;
6261
void destroyHwQueue(D3DKMT_HANDLE hwQueue) override;
63-
bool createMonitoredFence(OsContextWin &osContext) override;
6462
const bool hwQueuesSupported() override;
6563
bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) override;
6664
};

unit_tests/mock_gdi/mock_gdi.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ NTSTATUS __stdcall D3DKMTCreateSynchronizationObject2(IN OUT D3DKMT_CREATESYNCHR
389389
}
390390

391391
synchObject->Info.MonitoredFence.FenceValueCPUVirtualAddress = &cpuFence;
392+
synchObject->Info.MonitoredFence.FenceValueGPUVirtualAddress = 3;
393+
synchObject->hSyncObject = 4;
392394
return STATUS_SUCCESS;
393395
}
394396

unit_tests/os_interface/windows/wddm23_tests.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* OTHER DEALINGS IN THE SOFTWARE.
2121
*/
2222

23+
#include "runtime/memory_manager/memory_constants.h"
2324
#include "runtime/os_interface/windows/gdi_interface.h"
2425
#include "unit_tests/fixtures/gmm_environment_fixture.h"
2526
#include "unit_tests/helpers/debug_manager_state_restore.h"
@@ -78,18 +79,6 @@ TEST_F(Wddm23Tests, whenCreateContextIsCalledThenEnableHwQueues) {
7879
EXPECT_EQ(1u, getCreateContextDataFcn()->Flags.HwQueueSupported);
7980
}
8081

81-
TEST_F(Wddm23Tests, whenCreateHwQueueIsCalledThenSetAllRequiredFieldsAndMonitoredFence) {
82-
EXPECT_EQ(osContextWin->getContext(), getCreateHwQueueDataFcn()->hHwContext);
83-
EXPECT_EQ(0u, getCreateHwQueueDataFcn()->PrivateDriverDataSize);
84-
EXPECT_EQ(nullptr, getCreateHwQueueDataFcn()->pPrivateDriverData);
85-
86-
EXPECT_TRUE(nullptr != osContextWin->getMonitoredFence().cpuAddress);
87-
EXPECT_EQ(1u, osContextWin->getMonitoredFence().currentFenceValue);
88-
EXPECT_NE(static_cast<D3DKMT_HANDLE>(0), osContextWin->getMonitoredFence().fenceHandle);
89-
EXPECT_NE(static_cast<D3DGPU_VIRTUAL_ADDRESS>(0), osContextWin->getMonitoredFence().gpuAddress);
90-
EXPECT_EQ(0u, osContextWin->getMonitoredFence().lastSubmittedFence);
91-
}
92-
9382
TEST_F(Wddm23Tests, givenPreemptionModeWhenCreateHwQueueCalledThenSetGpuTimeoutIfEnabled) {
9483
wddm->setPreemptionMode(PreemptionMode::Disabled);
9584
wddm->wddmInterface->createHwQueue(wddm->preemptionMode, *osContextWin);
@@ -135,14 +124,24 @@ TEST_F(Wddm23Tests, givenCmdBufferWhenSubmitCalledThenSetAllRequiredFiledsAndUpd
135124
EXPECT_EQ(hwQueue, getSubmitCommandToHwQueueDataFcn()->hHwQueue);
136125
EXPECT_EQ(osContextWin->getMonitoredFence().fenceHandle, getSubmitCommandToHwQueueDataFcn()->HwQueueProgressFenceId);
137126
EXPECT_EQ(&cmdBufferHeader, getSubmitCommandToHwQueueDataFcn()->pPrivateDriverData);
138-
EXPECT_EQ(static_cast<UINT>(sizeof(COMMAND_BUFFER_HEADER)), getSubmitCommandToHwQueueDataFcn()->PrivateDriverDataSize);
127+
EXPECT_EQ(static_cast<UINT>(MemoryConstants::pageSize), getSubmitCommandToHwQueueDataFcn()->PrivateDriverDataSize);
139128

140129
EXPECT_EQ(osContextWin->getMonitoredFence().gpuAddress, cmdBufferHeader.MonitorFenceVA);
141130
EXPECT_EQ(osContextWin->getMonitoredFence().lastSubmittedFence, cmdBufferHeader.MonitorFenceValue);
142131
EXPECT_EQ(2u, osContextWin->getMonitoredFence().currentFenceValue);
143132
EXPECT_EQ(1u, osContextWin->getMonitoredFence().lastSubmittedFence);
144133
}
145134

135+
TEST_F(Wddm23Tests, whenMonitoredFenceIsCreatedThenSetupAllRequiredFields) {
136+
wddm->wddmInterface->createMonitoredFence(*osContextWin);
137+
138+
EXPECT_NE(nullptr, osContextWin->getMonitoredFence().cpuAddress);
139+
EXPECT_EQ(1u, osContextWin->getMonitoredFence().currentFenceValue);
140+
EXPECT_NE(static_cast<D3DKMT_HANDLE>(0), osContextWin->getMonitoredFence().fenceHandle);
141+
EXPECT_NE(static_cast<D3DGPU_VIRTUAL_ADDRESS>(0), osContextWin->getMonitoredFence().gpuAddress);
142+
EXPECT_EQ(0u, osContextWin->getMonitoredFence().lastSubmittedFence);
143+
}
144+
146145
TEST_F(Wddm23Tests, givenCurrentPendingFenceValueGreaterThanPendingFenceValueWhenSubmitCalledThenCallWaitOnGpu) {
147146
uint64_t cmdBufferAddress = 123;
148147
size_t cmdSize = 456;

0 commit comments

Comments
 (0)