WDDM显卡驱动
+ -

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;
        }
    }
}

0 篇笔记 写笔记

WDDM 获取配置信息
使用DxgkDdiQueryAdapterInfo获取配置信息。 InitialData.DxgkDdiQueryAdapterInfo = BddDdiQueryAdapterInfo;配置信息的类型有以下几种,如驱动的特性,内存段的分配等。这里我们只关注驱动特性......
驱动配置信息读取RtlQueryRegistryValues
为什么这里要说是“驱动配置信息读取RtlQueryRegistryValues”,那是因为自己踩了坑的。在写Windows驱动的时候,有时需要根据配置信息上来让驱动实现不同的功能。但这个配置信息放在那里合适呢?第一当然是在文件中了,但是感觉放在那里都感觉好像不合适,而且容易被删除。另外如果参数信息比......
作者信息
我爱内核
Windows驱动开发,网站开发
好好学习,天天向上。
取消
感谢您的支持,我会继续努力的!
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

您的支持,是我们前进的动力!