简体   繁体   English

为什么 Direct3D 11 中的顶点输入参数使用 DXGI 格式

[英]Why vertex input parameters in Direct3D 11 use DXGI format

I was learning Direct3D 11 sometime ago, I switched from DX9 to DX11 because it has more features.前段时间我在学习 Direct3D 11,我从 DX9 切换到 DX11,因为它有更多的功能。 But, I can't explain why input vertex layout format use DXGI formats like this但是,我无法解释为什么输入顶点布局格式使用这样的 DXGI 格式

polygonLayout.Format = DXGI_FORMAT_R32G32B32_FLOAT; //For position i don't need color

In Direct3D9 it was simpler using D3DVERTEXELEMENT9:在 Direct3D9 中,使用 D3DVERTEXELEMENT9 更简单:

D3DVERTEXELEMENT9 dwDecl3[] = 
{
    {0, 0,  D3DDECLTYPE_FLOAT3,   D3DDECLMETHOD_DEFAULT, 
                                      D3DDECLUSAGE_POSITION, 0},
    {0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, 
                                      D3DDECLUSAGE_COLOR, 0},
    {0, 16, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, 
                                      D3DDECLUSAGE_COLOR, 1},
    {1,  0, D3DDECLTYPE_FLOAT2,   D3DDECLMETHOD_DEFAULT, 
                                      D3DDECLUSAGE_TEXCOORD, 0},
    {2,  0, D3DDECLTYPE_FLOAT2,   D3DDECLMETHOD_DEFAULT, 
                                      D3DDECLUSAGE_TEXCOORD, 1},
    D3DDECL_END()
};

This isn't really a technical or programming question and more of a "why did they do that?"这不是一个真正的技术或编程问题,更多的是“他们为什么这样做?” history question.历史问题。

So...所以...

The original idea was that when Microsoft changed Direct3D 7 to Direct3D 8 to Direct3D 9, the device/adapter enumeration code was always changing even though it all did the same thing.最初的想法是,当 Microsoft 将 Direct3D 7 更改为 Direct3D 8 再更改为 Direct3D 9 时,设备/适配器枚举代码总是在更改,即使它们都做同样的事情。 Therefore, the idea of extracting out the bits of the Direct3D API that did device/adapter enumeration was hit upon and thus DirectX Graphics Infrastructure (DXGI) was created to address this need.因此,提出了提取进行设备/适配器枚举的 Direct3D API 的位的想法,因此创建了DirectX 图形基础结构(DXGI) 来满足这一需求。 Hence why enumerations like pixel formats are in DXGI_FORMAT_* enums rather than "Direct3D enums".因此,为什么像像素格式这样的枚举在DXGI_FORMAT_*枚举而不是“Direct3D 枚举”中。

The plan at the time was that DXGI wouldn't need to change and that you could just write this stuff once and it would work for Direct3D 10 and future versions of DirectX.当时的计划是 DXGI 不需要改变,你可以只写一次这些东西,它适用于 Direct3D 10 和未来版本的 DirectX。

Alas, "no plan survives contact with the enemy" and DXGI has changed almost constantly with every change of Direct3D and Windows OS.唉, “没有计划与敌人接触” ,DXGI 几乎随着 Direct3D 和 Windows 操作系统的每次变化而不断变化。

DXGI 1.0      Windows Vista and Direct3D 10

DXGI 1.1      Windows 7 and Direct3D 11
              The "you really need to use DXGICreateFactory1" release
              Included BGR formats for D3D_FEATURE_LEVEL_9_x devices
              Included BC6/BC7 formats for D3D_FEATURE_LEVEL_11_0 devices

DXGI 1.2      Windows 8 and DirectX 11.1
              Windows Store apps and the "CoreWindow" swapchain
              Introduced the DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL flip model
              Included a bunch of new formats for DirectX 11 Video APIs
              Added 16bpp (5:5:5:1, 5:6:5, and 4:4:4:4) formats

DXGI 1.3      Windows 8.1 and DirectX 11.2
              Added DXGICreateFactory2 so you could enable DXGI Debugging

DXGI 1.4      Windows 10 and DirectX 11.3 / 12.0
              Introduced the DXGI_SWAP_EFFECT_FLIP_DISCARD flip model
              DirectX 12 requires  DXGI_SWAP_EFFECT_FLIP_* flip models
              Includes a few more video formats for JPEG hardware decoding support

DXGI 1.5      Windows 10 (15086) added DuplicateOutput1
              Support for Variable refresh rate displays
              (a.k.a. DXGI_PRESENT_ALLOW_TEARING)

DXGI 1.6      Windows 10 (15063) added support for HDR displays

              Windows 10 (16299) added support for some special adapter fences

              Windows 10 (17134) added the DXGI_GPU_PREFERENCE enumeration;
              Also added HDR10+ metadata support

              Windows 10 (17763) added a way to register for an event
              for adapter changes

See DirectX Graphics Infrastructure (DXGI): Best Practices , DXGI Debug Device , and For best performance, use DXGI flip model请参阅DirectX 图形基础结构 (DXGI):最佳实践DXGI 调试设备为了获得最佳性能,请使用 DXGI 翻转 model

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM