WDDM 获取配置信息
2021-06-30
471
1
使用DxgkDdiQueryAdapterInfo获取配置信息。
InitialData.DxgkDdiQueryAdapterInfo = BddDdiQueryAdapterInfo;
配置信息的类型有以下几种,如驱动的特性,内存段的分配等。这里我们只关注驱动特性。
每一种的类型,都对应一个大大的结构体,获取的信息之多之复杂。
typedef enum _DXGK_QUERYADAPTERINFOTYPE {
DXGKQAITYPE_UMDRIVERPRIVATE = 0,
DXGKQAITYPE_DRIVERCAPS = 1,
DXGKQAITYPE_QUERYSEGMENT = 2,
#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WIN7)
DXGKQAITYPE_ALLOCATIONGROUP = 3,
DXGKQAITYPE_QUERYSEGMENT2 = 4,
#endif
#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WIN8)
DXGKQAITYPE_QUERYSEGMENT3 = 5,
DXGKQAITYPE_NUMPOWERCOMPONENTS = 6,
DXGKQAITYPE_POWERCOMPONENTINFO = 7,
DXGKQAITYPE_PREFERREDGPUNODE = 8,
#endif
#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WDDM1_3)
DXGKQAITYPE_POWERCOMPONENTPSTATEINFO = 9,
DXGKQAITYPE_HISTORYBUFFERPRECISION = 10,
#endif
#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WDDM2_0)
DXGKQAITYPE_QUERYSEGMENT4 = 11,
DXGKQAITYPE_SEGMENTMEMORYSTATE = 12,
DXGKQAITYPE_GPUMMUCAPS = 13,
DXGKQAITYPE_PAGETABLELEVELDESC = 14,
DXGKQAITYPE_PHYSICALADAPTERCAPS = 15,
DXGKQAITYPE_DISPLAY_DRIVERCAPS_EXTENSION = 16,
#endif
#if (DXGKDDI_INTERFACE_VERSION >= DXGKDDI_INTERFACE_VERSION_WDDM2_2)
DXGKQAITYPE_INTEGRATED_DISPLAY_DESCRIPTOR = 17,
DXGKQAITYPE_UEFIFRAMEBUFFERRANGES = 18,
DXGKQAITYPE_QUERYCOLORIMETRYOVERRIDES = 19
} DXGK_QUERYADAPTERINFOTYPE;
对于DXGKQAITYPE_DRIVERCAPS时,对应的返回参数的结构体为DXGK_DRIVERCAPS,这里将大部分参数都置为0,只使用了少数的参数;
- 第一个参数WDDMVersion设置WDDM的版本,这里为1.2.
- 高端物理内存地址HighestAcceptableAddress,置为-1即0xfffffffffffffff.
- SupportNonVGA置为TRUE,支持使用DxgkDdiStopDeviceAndReleasePostDisplayOwnership函数重置显示设备并释放当前开机自检(POST)设备的所有权。
- SupportSmoothRotation :支持使用dxgkdidUpdateActivevidpnPresentPath函数更新适配器上的路径旋转,而不需要创建和设置新的VidPN。
代码如下:
NTSTATUS BASIC_DISPLAY_DRIVER::QueryAdapterInfo(_In_ CONST DXGKARG_QUERYADAPTERINFO* pQueryAdapterInfo)
{
PAGED_CODE();
BDD_ASSERT(pQueryAdapterInfo != NULL);
switch (pQueryAdapterInfo->Type)
{
case DXGKQAITYPE_DRIVERCAPS:
{
if (pQueryAdapterInfo->OutputDataSize < sizeof(DXGK_DRIVERCAPS))
{
BDD_LOG_ERROR2("pQueryAdapterInfo->OutputDataSize (0x%I64x) is smaller than sizeof(DXGK_DRIVERCAPS) (0x%I64x)", pQueryAdapterInfo->OutputDataSize, sizeof(DXGK_DRIVERCAPS));
return STATUS_BUFFER_TOO_SMALL;
}
DXGK_DRIVERCAPS* pDriverCaps = (DXGK_DRIVERCAPS*)pQueryAdapterInfo->pOutputData;
// Nearly all fields must be initialized to zero, so zero out to start and then change those that are non-zero.
// Fields are zero since BDD is Display-Only and therefore does not support any of the render related fields.
// It also doesn't support hardware interrupts, gamma ramps, etc.
RtlZeroMemory(pDriverCaps, sizeof(DXGK_DRIVERCAPS));
pDriverCaps->WDDMVersion = DXGKDDI_WDDMv1_2;
pDriverCaps->HighestAcceptableAddress.QuadPart = -1;
pDriverCaps->SupportNonVGA = TRUE;
pDriverCaps->SupportSmoothRotation = TRUE;
return STATUS_SUCCESS;
}
default:
{
// BDD does not need to support any other adapter information types
BDD_LOG_WARNING1("Unknown QueryAdapterInfo Type (0x%I64x) requested", pQueryAdapterInfo->Type);
return STATUS_NOT_SUPPORTED;
}
}
}