Update Wddm23 interface

Change-Id: I8c1484875f28dd7f2591db810c64b117f49f70e3
This commit is contained in:
Dunajski, Bartosz 2018-09-12 12:43:15 +02:00 committed by sys_ocldev
parent bcceab5629
commit 53c4d2946e
4 changed files with 28 additions and 34 deletions

View File

@ -20,17 +20,20 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/memory_manager/memory_constants.h"
#include "runtime/os_interface/windows/gdi_interface.h"
#include "runtime/os_interface/windows/wddm/wddm_interface.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/os_context_win.h"
bool OCLRT::WddmInterface20::createHwQueue(PreemptionMode preemptionMode, OsContextWin &osContext) {
using namespace OCLRT;
bool WddmInterface20::createHwQueue(PreemptionMode preemptionMode, OsContextWin &osContext) {
return false;
}
void OCLRT::WddmInterface20::destroyHwQueue(D3DKMT_HANDLE hwQueue) {}
void WddmInterface20::destroyHwQueue(D3DKMT_HANDLE hwQueue) {}
bool OCLRT::WddmInterface20::createMonitoredFence(OsContextWin &osContext) {
bool WddmInterface::createMonitoredFence(OsContextWin &osContext) {
NTSTATUS Status;
D3DKMT_CREATESYNCHRONIZATIONOBJECT2 CreateSynchronizationObject = {0};
CreateSynchronizationObject.hDevice = wddm.getDevice();
@ -48,11 +51,11 @@ bool OCLRT::WddmInterface20::createMonitoredFence(OsContextWin &osContext) {
return Status == STATUS_SUCCESS;
}
const bool OCLRT::WddmInterface20::hwQueuesSupported() {
const bool WddmInterface20::hwQueuesSupported() {
return false;
}
bool OCLRT::WddmInterface20::submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) {
bool WddmInterface20::submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) {
D3DKMT_SUBMITCOMMAND SubmitCommand = {0};
NTSTATUS status = STATUS_SUCCESS;
@ -77,7 +80,7 @@ bool OCLRT::WddmInterface20::submit(uint64_t commandBuffer, size_t size, void *c
return STATUS_SUCCESS == status;
}
bool OCLRT::WddmInterface23::createHwQueue(PreemptionMode preemptionMode, OsContextWin &osContext) {
bool WddmInterface23::createHwQueue(PreemptionMode preemptionMode, OsContextWin &osContext) {
D3DKMT_CREATEHWQUEUE createHwQueue = {};
if (!wddm.getGdi()->setupHwQueueProcAddresses()) {
@ -93,14 +96,10 @@ bool OCLRT::WddmInterface23::createHwQueue(PreemptionMode preemptionMode, OsCont
UNRECOVERABLE_IF(status != STATUS_SUCCESS);
osContext.setHwQueue(createHwQueue.hHwQueue);
osContext.resetMonitoredFenceParams(createHwQueue.hHwQueueProgressFence,
reinterpret_cast<uint64_t *>(createHwQueue.HwQueueProgressFenceCPUVirtualAddress),
createHwQueue.HwQueueProgressFenceGPUVirtualAddress);
return status == STATUS_SUCCESS;
}
void OCLRT::WddmInterface23::destroyHwQueue(D3DKMT_HANDLE hwQueue) {
void WddmInterface23::destroyHwQueue(D3DKMT_HANDLE hwQueue) {
if (hwQueue) {
D3DKMT_DESTROYHWQUEUE destroyHwQueue = {};
destroyHwQueue.hHwQueue = hwQueue;
@ -110,15 +109,11 @@ void OCLRT::WddmInterface23::destroyHwQueue(D3DKMT_HANDLE hwQueue) {
}
}
bool OCLRT::WddmInterface23::createMonitoredFence(OsContextWin &osContext) {
const bool WddmInterface23::hwQueuesSupported() {
return true;
}
const bool OCLRT::WddmInterface23::hwQueuesSupported() {
return true;
}
bool OCLRT::WddmInterface23::submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) {
bool WddmInterface23::submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) {
auto monitoredFence = osContext.getMonitoredFence();
D3DKMT_SUBMITCOMMANDTOHWQUEUE submitCommand = {};
@ -132,7 +127,7 @@ bool OCLRT::WddmInterface23::submit(uint64_t commandBuffer, size_t size, void *c
pHeader->MonitorFenceValue = monitoredFence.currentFenceValue;
submitCommand.pPrivateDriverData = commandHeader;
submitCommand.PrivateDriverDataSize = sizeof(COMMAND_BUFFER_HEADER);
submitCommand.PrivateDriverDataSize = MemoryConstants::pageSize;
auto status = wddm.getGdi()->submitCommandToHwQueue(&submitCommand);
UNRECOVERABLE_IF(status != STATUS_SUCCESS);

View File

@ -39,7 +39,7 @@ class WddmInterface {
WddmInterface() = delete;
virtual bool createHwQueue(PreemptionMode preemptionMode, OsContextWin &osContext) = 0;
virtual void destroyHwQueue(D3DKMT_HANDLE hwQueue) = 0;
virtual bool createMonitoredFence(OsContextWin &osContext) = 0;
bool createMonitoredFence(OsContextWin &osContext);
virtual const bool hwQueuesSupported() = 0;
virtual bool submit(uint64_t commandBuffer, size_t size, void *commandHeader, OsContextWin &osContext) = 0;
Wddm &wddm;
@ -50,7 +50,6 @@ class WddmInterface20 : public WddmInterface {
using WddmInterface::WddmInterface;
bool createHwQueue(PreemptionMode preemptionMode, 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;
};
@ -60,7 +59,6 @@ class WddmInterface23 : public WddmInterface {
using WddmInterface::WddmInterface;
bool createHwQueue(PreemptionMode preemptionMode, 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;
};

View File

@ -389,6 +389,8 @@ NTSTATUS __stdcall D3DKMTCreateSynchronizationObject2(IN OUT D3DKMT_CREATESYNCHR
}
synchObject->Info.MonitoredFence.FenceValueCPUVirtualAddress = &cpuFence;
synchObject->Info.MonitoredFence.FenceValueGPUVirtualAddress = 3;
synchObject->hSyncObject = 4;
return STATUS_SUCCESS;
}

View File

@ -20,6 +20,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/memory_manager/memory_constants.h"
#include "runtime/os_interface/windows/gdi_interface.h"
#include "unit_tests/fixtures/gmm_environment_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
@ -78,18 +79,6 @@ TEST_F(Wddm23Tests, whenCreateContextIsCalledThenEnableHwQueues) {
EXPECT_EQ(1u, getCreateContextDataFcn()->Flags.HwQueueSupported);
}
TEST_F(Wddm23Tests, whenCreateHwQueueIsCalledThenSetAllRequiredFieldsAndMonitoredFence) {
EXPECT_EQ(osContextWin->getContext(), getCreateHwQueueDataFcn()->hHwContext);
EXPECT_EQ(0u, getCreateHwQueueDataFcn()->PrivateDriverDataSize);
EXPECT_EQ(nullptr, getCreateHwQueueDataFcn()->pPrivateDriverData);
EXPECT_TRUE(nullptr != osContextWin->getMonitoredFence().cpuAddress);
EXPECT_EQ(1u, osContextWin->getMonitoredFence().currentFenceValue);
EXPECT_NE(static_cast<D3DKMT_HANDLE>(0), osContextWin->getMonitoredFence().fenceHandle);
EXPECT_NE(static_cast<D3DGPU_VIRTUAL_ADDRESS>(0), osContextWin->getMonitoredFence().gpuAddress);
EXPECT_EQ(0u, osContextWin->getMonitoredFence().lastSubmittedFence);
}
TEST_F(Wddm23Tests, givenPreemptionModeWhenCreateHwQueueCalledThenSetGpuTimeoutIfEnabled) {
wddm->setPreemptionMode(PreemptionMode::Disabled);
wddm->wddmInterface->createHwQueue(wddm->preemptionMode, *osContextWin);
@ -135,7 +124,7 @@ TEST_F(Wddm23Tests, givenCmdBufferWhenSubmitCalledThenSetAllRequiredFiledsAndUpd
EXPECT_EQ(hwQueue, getSubmitCommandToHwQueueDataFcn()->hHwQueue);
EXPECT_EQ(osContextWin->getMonitoredFence().fenceHandle, getSubmitCommandToHwQueueDataFcn()->HwQueueProgressFenceId);
EXPECT_EQ(&cmdBufferHeader, getSubmitCommandToHwQueueDataFcn()->pPrivateDriverData);
EXPECT_EQ(static_cast<UINT>(sizeof(COMMAND_BUFFER_HEADER)), getSubmitCommandToHwQueueDataFcn()->PrivateDriverDataSize);
EXPECT_EQ(static_cast<UINT>(MemoryConstants::pageSize), getSubmitCommandToHwQueueDataFcn()->PrivateDriverDataSize);
EXPECT_EQ(osContextWin->getMonitoredFence().gpuAddress, cmdBufferHeader.MonitorFenceVA);
EXPECT_EQ(osContextWin->getMonitoredFence().lastSubmittedFence, cmdBufferHeader.MonitorFenceValue);
@ -143,6 +132,16 @@ TEST_F(Wddm23Tests, givenCmdBufferWhenSubmitCalledThenSetAllRequiredFiledsAndUpd
EXPECT_EQ(1u, osContextWin->getMonitoredFence().lastSubmittedFence);
}
TEST_F(Wddm23Tests, whenMonitoredFenceIsCreatedThenSetupAllRequiredFields) {
wddm->wddmInterface->createMonitoredFence(*osContextWin);
EXPECT_NE(nullptr, osContextWin->getMonitoredFence().cpuAddress);
EXPECT_EQ(1u, osContextWin->getMonitoredFence().currentFenceValue);
EXPECT_NE(static_cast<D3DKMT_HANDLE>(0), osContextWin->getMonitoredFence().fenceHandle);
EXPECT_NE(static_cast<D3DGPU_VIRTUAL_ADDRESS>(0), osContextWin->getMonitoredFence().gpuAddress);
EXPECT_EQ(0u, osContextWin->getMonitoredFence().lastSubmittedFence);
}
TEST_F(Wddm23Tests, givenCurrentPendingFenceValueGreaterThanPendingFenceValueWhenSubmitCalledThenCallWaitOnGpu) {
uint64_t cmdBufferAddress = 123;
size_t cmdSize = 456;