/* * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/os_interface/windows/device_time_wddm.h" #include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/os_interface/os_interface.h" #include "shared/source/os_interface/product_helper.h" #include "shared/source/os_interface/windows/wddm/wddm.h" #include "shared/source/os_interface/windows/windows_wrapper.h" #include #undef WIN32_NO_STATUS namespace NEO { bool DeviceTimeWddm::runEscape(Wddm *wddm, TimeStampDataHeader &escapeInfo) { if (wddm) { D3DKMT_ESCAPE escapeCommand = {}; GetGpuCpuTimestampsIn in{}; uint32_t outSize = sizeof(GetGpuCpuTimestampsOut); escapeInfo.header.EscapeCode = static_cast(GFX_ESCAPE_IGPA_INSTRUMENTATION_CONTROL); escapeInfo.header.Size = outSize; escapeInfo.data.in = in; escapeCommand.Flags.Value = 0; escapeCommand.hAdapter = 0; escapeCommand.hContext = 0; escapeCommand.hDevice = static_cast(wddm->getDeviceHandle()); escapeCommand.pPrivateDriverData = &escapeInfo; escapeCommand.PrivateDriverDataSize = sizeof(escapeInfo); escapeCommand.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; auto status = wddm->escape(escapeCommand); if (status == STATUS_SUCCESS) { return true; } } return false; } DeviceTimeWddm::DeviceTimeWddm(Wddm *wddm) { this->wddm = wddm; } double DeviceTimeWddm::getDynamicDeviceTimerResolution(HardwareInfo const &hwInfo) const { double retVal = 0u; if (wddm) { retVal = 1000000000.0 / static_cast(wddm->getTimestampFrequency()); } return retVal; } uint64_t DeviceTimeWddm::getDynamicDeviceTimerClock(HardwareInfo const &hwInfo) const { uint64_t retVal = 0u; if (wddm) { retVal = static_cast(wddm->getTimestampFrequency()); } return retVal; } void DeviceTimeWddm::convertTimestampsFromOaToCsDomain(const GfxCoreHelper &gfxCoreHelper, uint64_t ×tampData, uint64_t freqOA, uint64_t freqCS) { if (gfxCoreHelper.isTimestampShiftRequired() && freqCS > 0 && freqOA > 0) { auto freqRatio = static_cast(freqOA) / static_cast(freqCS); timestampData = static_cast(timestampData / freqRatio); } }; } // namespace NEO