将 DirectX 9 功能映射到 DirectX 11 APIMap DirectX 9 features to DirectX 11 APIs

了解 Direct3D 9 游戏使用的功能如何转换到 Direct3D 11 和通用 Windows 平台 (UWP)。Understand how the features your Direct3D 9 game uses will translate to Direct3D 11 and the Universal Windows Platform (UWP).

另请参阅 规划 DirectX 端口从 Direct3D 9 到 Direct3D 11 的重要更改Also see Plan your DirectX port, and Important changes from Direct3D 9 to Direct3D 11.

将 Direct3D 9 映射到 DirectX 11 APIMapping Direct3D 9 to DirectX 11 APIs

Direct3D 仍然是 DirectX 图形的基础,但是 API 自从 DirectX 9 起发生了更改。Direct3D is still the foundation of DirectX graphics, but the API has changed since DirectX 9:

  • Microsoft DirectX 图形基础结构 (DXGI) 用于设置图形适配器。Microsoft DirectX Graphics Infrastructure (DXGI) is used to set up graphics adapters. 使用 DXGI 来选择缓冲区格式、创建交换链、呈现帧以及创建共享资源。Use DXGI to select buffer formats, create swap chains, present frames, and create shared resources. 请参阅 DXGI 概述See DXGI Overview.
  • Direct3D 设备上下文用于设置管道状态以及生成呈现命令。A Direct3D device context is used to set pipeline state and generate rendering commands. 我们的大多数示例都使用即时上下文直接呈现到设备;Direct3D 11 还支持使用延迟上下文的多线程呈现。Most of our samples use an immediate context to render directly to the device; Direct3D 11 also supports multithreaded rendering, in which case deferred contexts are used. 请参阅 Direct3D 11 中的设备简介See Introduction to a Device in Direct3D 11.
  • 一些功能已经被弃用,最值得一提的就是固定函数管道。Some features have been deprecated, most notably the fixed function pipeline. 请参阅已弃用的功能See Deprecated Features.

有关 Direct3D 11 功能的完整列表,请参阅 Direct3D 11 功能Direct3D 11 功能For a full list of Direct3D 11 features, see Direct3D 11 Features and Direct3D 11 Features.

从 Direct2D 9 移动到 Direct2D 11Moving from Direct2D 9 to Direct2D 11

Direct2D (Windows) 仍然是 DirectX 图形和 Windows 的重要组成部分。Direct2D (Windows) is still an important part of DirectX graphics and Windows. 你仍然可以使用 Direct2D 来绘制 2D 游戏,以及在 Direct3D 上面绘制覆盖 (HUD)。You can still use Direct2D to draw 2D games, and to draw overlays (HUDs) on top of Direct3D.

Direct2D 在 Direct3D 上运行,因此可以使用任一 API 实现 2D 游戏。Direct2D runs on top of Direct3D; 2D games can be implemented using either API. 例如,使用 Direct3D 实现的 2D 游戏可以使用正交投影、设置 Z 值以控制基元的绘制顺序,以及使用像素着色器添加特殊效果。For example, a 2D game implemented using Direct3D can use orthographic projection, set Z-values to control the drawing order of primitives, and use pixel shaders to add special effects.

由于 Direct2D 是基于 Direct3D 的,因此它也使用 DXGI 和设备上下文。Since Direct2D is based on Direct3D it also uses DXGI and device contexts. 请参阅 Direct2D API 概述See Direct2D API Overview.

DirectWrite API 增加了对使用 Direct2D 设置文本格式的支持。The DirectWrite API adds support for formatted text using Direct2D. 请参阅 DirectWrite 简介See Introducing DirectWrite.

替换已弃用的帮助程序库Replace deprecated helper libraries

D3DX 和 DXUT 已弃用,并且不能由 UWP 游戏使用。D3DX and DXUT are deprecated and cannot be used by UWP games. 这些帮助程序库为诸如纹理加载和网格加载之类的任务提供了资源。These helper libraries provided resources for tasks such as texture loading and mesh loading.

将 FX 中的着色器程序移动到 HLSLMove shader programs from FX to HLSL

对于 UWP 来说,D3DX 实用工具库(D3DX 9、D3DX 10 和 D3DX 11)(包括“效果”库)已被弃用。The D3DX utility library (D3DX 9, D3DX 10, and D3DX 11), including Effects, is deprecated for UWP. UWP 的所有 DirectX 游戏都使用 HLSL(不使用“效果”库)驱动图形管道。All DirectX games for UWP drive the graphics pipeline using HLSL without Effects.

Visual Studio 仍然在后台使用 FXC 编译着色器对象。Visual Studio still uses FXC under the hood to compile shader objects. 将提前编译 UWP 游戏着色器。UWP game shaders are compiled ahead of time. 在运行时加载字节码,然后 在相应的呈现传递过程中将每个着色器资源绑定到图形管道。The bytecode is loaded at runtime, then each shader resource is bound to the graphics pipeline during the appropriate rendering pass. 应将着色器移动到它们自己的 .HLSL 文件中,且应采用 C++ 代码实现呈现技术。Shaders should be moved to their own separate .HLSL files and rendering techniques should be implemented in your C++ code.

若要快速浏览加载着色器资源,请参阅从 Direct3D 9 到 UWP 的简单移植For a quick look at loading shader resources see Simple port from Direct3D 9 to UWP.

Direct3D 11 引入了着色器模型5,它需要 Direct3D 功能级别 11 _ 0 (或更高) 。Direct3D 11 introduced Shader Model 5, which requires Direct3D feature level 11_0 (or above). 请参阅 Direct3D 11 的 HLSL 着色器模型 5 功能See HLSL Shader Model 5 Features for Direct3D 11.

替换 XNAMath 和 D3DXMathReplace XNAMath and D3DXMath

应该将使用 XNAMath(或 D3DXMath)的代码迁移到 DirectXMathCode using XNAMath (or D3DXMath) should be migrated to DirectXMath. DirectXMath 包括可以跨 x86、x64 和 ARM 进行移植的类型。DirectXMath includes types that are portable across x86, x64, and ARM. 请参阅 XNA Math 库中的代码迁移See Code Migration from the XNA Math Library.

请注意,DirectXMath 浮点类型便于与着色器配合使用。Note that DirectXMath float types are convenient for use with shaders. 例如,XMFLOAT4XMFLOAT4X4 便于对齐常量缓冲区的数据。For example XMFLOAT4 and XMFLOAT4X4 conveniently align data for constant buffers.

将 DirectSound 替换为 XAudio2(以及背景音频)Replace DirectSound with XAudio2 (and background audio)

UWP 不支持 DirectSound:DirectSound is not supported for UWP:

  • 使用 XAudio2 向游戏中添加声音效果。Use XAudio2 to add sound effects to your game.

将 DirectInput 替换为 XInput 和 Windows 运行时 ApiReplace DirectInput with XInput and Windows Runtime APIs

UWP 不支持 DirectInput:DirectInput is not supported for UWP:

  • 为鼠标、键盘和触摸输入使用 CoreWindow 输入事件回调。Use CoreWindow input event callbacks for mouse, keyboard, and touch input.
  • 使用 XInput 1.4 以获得游戏控制器支持(以及游戏控制器耳机支持)。Use XInput 1.4 for game controller support (and game controller headset support). 如果使用桌面和 UWP 的共享代码库,请参阅 XInput 版本以获取有关向后兼容的信息。If you are using a shared code base for desktop and UWP, see XInput Versions for information on backwards compatibility.
  • 如果你的游戏需要使用应用栏,请注册 EdgeGesture 事件。Register for EdgeGesture events if your game needs to use the app bar.

使用 Microsoft Media Foundation 代替 DirectShowUse Microsoft Media Foundation instead of DirectShow

DirectShow 不再是 DirectX API(或 Windows API)的一部分。DirectShow is no longer part of the DirectX API (or the Windows API). Microsoft 媒体基础使用共享图面向 Direct3D 提供视频内容。Microsoft Media Foundation provides video content to Direct3D using shared surfaces. 请参阅 Direct3D 11 视频 APISee Direct3D 11 Video APIs.

将 DirectPlay 替换为网络代码Replace DirectPlay with networking code

Microsoft DirectPlay 已被弃用。Microsoft DirectPlay has been deprecated. 如果游戏使用网络服务,则需要提供符合 UWP 要求的网络代码。If your game uses network services, you need to provide networking code that complies with UWP requirements. 使用以下 API:Use the following APIs:

以下文章将帮助你在应用包清单中添加网络功能并声明对网络的支持。The following articles help you add networking features and declare support for networking in your app's package manifest.

请注意,所有 UWP 应用(包括游戏)都使用特定类型的后台任务,以便在应用暂停时保持连接。Note that all UWP apps (including games) use specific types of background tasks to maintain connectivity while the app is suspended. 如果你的游戏需要在暂停时保持连接状态,请参阅网络基础知识If your game needs to maintain connection state while suspended see Networking basics.

功能映射Function mapping

使用下表可帮助你将 Direct3D 9 中的代码转换到 Direct3D 11。Use the following table to help convert code from Direct3D 9 to Direct3D 11. 该表还有助于区分设备和设备上下文。This can also help distinguish between the device and device context.

Direct3D9Direct3D9 Direct3D 11 等效内容Direct3D 11 Equivalent

IDirect3DDevice9IDirect3DDevice9

ID3D11Device2ID3D11Device2

ID3D11DeviceContext2ID3D11DeviceContext2

图形管道中描述了各个图形管道阶段。The graphics pipeline stages are described in Graphics Pipeline.

IDirect3D9IDirect3D9

IDXGIFactory2IDXGIFactory2

IDXGIAdapter2IDXGIAdapter2

IDXGIDevice3IDXGIDevice3

IDirect3DDevice9::PresentIDirect3DDevice9::Present

IDXGISwapChain1::Present1IDXGISwapChain1::Present1

IDirect3DDevice9::TestCooperativeLevelIDirect3DDevice9::TestCooperativeLevel

调用设置了 DXGI_PRESENT_TEST 标志的 IDXGISwapChain1::Present1Call IDXGISwapChain1::Present1 with the DXGI_PRESENT_TEST flag set.

IDirect3DBaseTexture9IDirect3DBaseTexture9

IDirect3DTexture9IDirect3DTexture9

IDirect3DCubeTexture9IDirect3DCubeTexture9

IDirect3DVolumeTexture9IDirect3DVolumeTexture9

IDirect3DIndexBuffer9IDirect3DIndexBuffer9

IDirect3DVertexBuffer9IDirect3DVertexBuffer9

ID3D11BufferID3D11Buffer

ID3D11Texture1DID3D11Texture1D

ID3D11Texture2DID3D11Texture2D

ID3D11Texture3DID3D11Texture3D

ID3D11ShaderResourceViewID3D11ShaderResourceView

ID3D11RenderTargetViewID3D11RenderTargetView

ID3D11DepthStencilViewID3D11DepthStencilView

IDirect3DVertexShader9IDirect3DVertexShader9

IDirect3DPixelShader9IDirect3DPixelShader9

ID3D11VertexShaderID3D11VertexShader

ID3D11PixelShaderID3D11PixelShader

IDirect3DVertexDeclaration9IDirect3DVertexDeclaration9

ID3D11InputLayoutID3D11InputLayout

IDirect3DDevice9::SetRenderStateIDirect3DDevice9::SetRenderState

IDirect3DDevice9::SetSamplerStateIDirect3DDevice9::SetSamplerState

ID3D11BlendState1ID3D11BlendState1

ID3D11DepthStencilStateID3D11DepthStencilState

ID3D11RasterizerState1ID3D11RasterizerState1

ID3D11SamplerStateID3D11SamplerState

IDirect3DDevice9::DrawIndexedPrimitiveIDirect3DDevice9::DrawIndexedPrimitive

IDirect3DDevice9::DrawPrimitiveIDirect3DDevice9::DrawPrimitive

ID3D11DeviceContext::DrawID3D11DeviceContext::Draw

ID3D11DeviceContext::DrawIndexedID3D11DeviceContext::DrawIndexed

ID3D11DeviceContext::DrawIndexedInstancedID3D11DeviceContext::DrawIndexedInstanced

ID3D11DeviceContext::DrawInstancedID3D11DeviceContext::DrawInstanced

ID3D11DeviceContext::IASetPrimitiveTopologyID3D11DeviceContext::IASetPrimitiveTopology

ID3D11DeviceContext::DrawAutoID3D11DeviceContext::DrawAuto

IDirect3DDevice9::BeginSceneIDirect3DDevice9::BeginScene

IDirect3DDevice9::EndSceneIDirect3DDevice9::EndScene

IDirect3DDevice9::DrawPrimitiveUPIDirect3DDevice9::DrawPrimitiveUP

IDirect3DDevice9::DrawIndexedPrimitiveUPIDirect3DDevice9::DrawIndexedPrimitiveUP

无直接等效项No direct equivalent

IDirect3DDevice9::ShowCursorIDirect3DDevice9::ShowCursor

IDirect3DDevice9::SetCursorPositionIDirect3DDevice9::SetCursorPosition

IDirect3DDevice9::SetCursorPropertiesIDirect3DDevice9::SetCursorProperties

使用标准光标 API。Use standard cursor APIs.

IDirect3DDevice9::ResetIDirect3DDevice9::Reset

LOST 设备和 POOL_MANAGED 不再存在。LOST device and POOL_MANAGED no longer exist. IDXGISwapChain1::Present1 可能失败,并带有 DXGI_ERROR_DEVICE_REMOVED 返回值。IDXGISwapChain1::Present1 can fail with a DXGI_ERROR_DEVICE_REMOVED return value.

IDirect3DDevice9:DrawRectPatchIDirect3DDevice9:DrawRectPatch

IDirect3DDevice9:DrawTriPatchIDirect3DDevice9:DrawTriPatch

IDirect3DDevice9:LightEnableIDirect3DDevice9:LightEnable

IDirect3DDevice9:MultiplyTransformIDirect3DDevice9:MultiplyTransform

IDirect3DDevice9:SetLightIDirect3DDevice9:SetLight

IDirect3DDevice9:SetMaterialIDirect3DDevice9:SetMaterial

IDirect3DDevice9:SetNPatchModeIDirect3DDevice9:SetNPatchMode

IDirect3DDevice9:SetTransformIDirect3DDevice9:SetTransform

IDirect3DDevice9:SetFVFIDirect3DDevice9:SetFVF

IDirect3DDevice9:SetTextureStageStateIDirect3DDevice9:SetTextureStageState

固定函数管道已被弃用。The fixed-function pipeline has been deprecated.

IDirect3DDevice9:CheckDepthStencilMatchIDirect3DDevice9:CheckDepthStencilMatch

IDirect3DDevice9:CheckDeviceFormatIDirect3DDevice9:CheckDeviceFormat

IDirect3DDevice9:GetDeviceCapsIDirect3DDevice9:GetDeviceCaps

IDirect3DDevice9:ValidateDeviceIDirect3DDevice9:ValidateDevice

功能位替换为功能级别。Capability bits are replaced by feature levels. 对于任何给定的功能级别,只有几个格式和功能用例是可选的。Only a few format and feature usage cases are optional for any given feature level. 这些可以使用 ID3D11Device::CheckFeatureSupportID3D11Device::CheckFormatSupport 进行检查。These can be checked with ID3D11Device::CheckFeatureSupport and ID3D11Device::CheckFormatSupport.

图面格式映射Surface format mapping

使用下表将 Direct3D 9 格式转换为 DXGI 格式。Use the following table to convert Direct3D 9 formats into DXGI formats.

Direct3D 9 格式Direct3D 9 Format Direct3D 11 格式Direct3D 11 Format

D3DFMT_UNKNOWND3DFMT_UNKNOWN

DXGI_FORMAT_UNKNOWNDXGI_FORMAT_UNKNOWN

D3DFMT_R8G8B8D3DFMT_R8G8B8

不可用Not available

D3DFMT_A8R8G8B8D3DFMT_A8R8G8B8

DXGI_FORMAT_B8G8R8A8_UNORMDXGI_FORMAT_B8G8R8A8_UNORM

DXGI_FORMAT_B8G8R8A8_UNORM_SRGBDXGI_FORMAT_B8G8R8A8_UNORM_SRGB

D3DFMT_X8R8G8B8D3DFMT_X8R8G8B8

DXGI_FORMAT_B8G8R8X8_UNORMDXGI_FORMAT_B8G8R8X8_UNORM

DXGI_FORMAT_B8G8R8X8_UNORM_SRGBDXGI_FORMAT_B8G8R8X8_UNORM_SRGB

D3DFMT_R5G6B5D3DFMT_R5G6B5

DXGI_FORMAT_B5G6R5_UNORMDXGI_FORMAT_B5G6R5_UNORM

D3DFMT_X1R5G5B5D3DFMT_X1R5G5B5

不可用Not available

D3DFMT_A1R5G5B5D3DFMT_A1R5G5B5

DXGI_FORMAT_B5G5R5A1_UNORMDXGI_FORMAT_B5G5R5A1_UNORM

D3DFMT_A4R4G4B4D3DFMT_A4R4G4B4

DXGI_FORMAT_B4G4R4A4_UNORMDXGI_FORMAT_B4G4R4A4_UNORM

D3DFMT_R3G3B2D3DFMT_R3G3B2

不可用Not available

D3DFMT_A8D3DFMT_A8

DXGI_FORMAT_A8_UNORMDXGI_FORMAT_A8_UNORM

D3DFMT_A8R3G3B2D3DFMT_A8R3G3B2

不可用Not available

D3DFMT_X4R4G4B4D3DFMT_X4R4G4B4

不可用Not available

D3DFMT_A2B10G10R10D3DFMT_A2B10G10R10

DXGI_FORMAT_R10G10B10A2DXGI_FORMAT_R10G10B10A2

D3DFMT_A8B8G8R8D3DFMT_A8B8G8R8

DXGI_FORMAT_R8G8B8A8_UNORMDXGI_FORMAT_R8G8B8A8_UNORM

DXGI_FORMAT_R8G8B8A8_UNORM_SRGBDXGI_FORMAT_R8G8B8A8_UNORM_SRGB

D3DFMT_X8B8G8R8D3DFMT_X8B8G8R8

不可用Not available

D3DFMT_G16R16D3DFMT_G16R16

DXGI_FORMAT_R16G16_UNORMDXGI_FORMAT_R16G16_UNORM

D3DFMT_A2R10G10B10D3DFMT_A2R10G10B10

不可用Not available

D3DFMT_A16B16G16R16D3DFMT_A16B16G16R16

DXGI_FORMAT_R16G16B16A16_UNORMDXGI_FORMAT_R16G16B16A16_UNORM

D3DFMT_A8P8D3DFMT_A8P8

不可用Not available

D3DFMT_P8D3DFMT_P8

不可用Not available

D3DFMT_L8D3DFMT_L8

DXGI_FORMAT_R8_UNORMDXGI_FORMAT_R8_UNORM

注意   使用 swizzle 在着色器中将红色复制到其他组件,以获取 Direct3D 9 行为。 Note   Use .r swizzle in shader to duplicate red to other components to get Direct3D 9 behavior.
 

D3DFMT_A8L8D3DFMT_A8L8

DXGI_FORMAT_R8G8_UNORMDXGI_FORMAT_R8G8_UNORM

注意   在着色器中使用 rrrg 重复红色,并将绿色移动到 alpha 组件以获取 Direct3D 9 行为。 Note   Use swizzle .rrrg in shader to duplicate red and move green to the alpha components to get Direct3D 9 behavior.
 

D3DFMT_A4L4D3DFMT_A4L4

不可用Not available

D3DFMT_V8U8D3DFMT_V8U8

DXGI_FORMAT_R8G8_SNORMDXGI_FORMAT_R8G8_SNORM

D3DFMT_L6V5U5D3DFMT_L6V5U5

不可用Not available

D3DFMT_X8L8V8U8D3DFMT_X8L8V8U8

不可用Not available

D3DFMT_Q8W8V8U8D3DFMT_Q8W8V8U8

DXGI_FORMAT_R8G8B8A8_SNORMDXGI_FORMAT_R8G8B8A8_SNORM

D3DFMT_V16U16D3DFMT_V16U16

DXGI_FORMAT_R16G16_SNORMDXGI_FORMAT_R16G16_SNORM

D3DFMT_W11V11U10D3DFMT_W11V11U10

不可用Not available

D3DFMT_A2W10V10U10D3DFMT_A2W10V10U10

不可用Not available

D3DFMT_UYVYD3DFMT_UYVY

不可用Not available

D3DFMT_R8G8_B8G8D3DFMT_R8G8_B8G8

DXGI_FORMAT_G8R8_G8B8_UNORMDXGI_FORMAT_G8R8_G8B8_UNORM

注意   在 Direct3D 9 中,数据由 255.0 f 扩展,但这可以在着色器中进行处理。 Note   In Direct3D 9 the data was scaled up by 255.0f, but this can be handled in the shader.
 

D3DFMT_YUY2D3DFMT_YUY2

不可用Not available

D3DFMT_G8R8_G8B8D3DFMT_G8R8_G8B8

DXGI_FORMAT_R8G8_B8G8_UNORMDXGI_FORMAT_R8G8_B8G8_UNORM

注意   在 Direct3D 9 中,数据由 255.0 f 扩展,但这可以在着色器中进行处理。 Note   In Direct3D 9 the data was scaled up by 255.0f, but this can be handled in the shader.
 

D3DFMT_DXT1D3DFMT_DXT1

DXGI_FORMAT_BC1_UNORM & DXGI_FORMAT_BC1_UNORM_SRGBDXGI_FORMAT_BC1_UNORM & DXGI_FORMAT_BC1_UNORM_SRGB

D3DFMT_DXT2D3DFMT_DXT2

DXGI_FORMAT_BC1_UNORM & DXGI_FORMAT_BC1_UNORM_SRGBDXGI_FORMAT_BC1_UNORM & DXGI_FORMAT_BC1_UNORM_SRGB

注意   DXT1 和 DXT2 与 API/硬件的透视是相同的。 Note   DXT1 and DXT2 are the same from an API/hardware perspective. 唯一的差别是是否使用了预乘 alpha,这可以通过应用程序来跟踪,并且不需要单独的格式。The only difference is whether premultiplied alpha is used, which can be tracked by an application and doesn't need a separate format.
 

D3DFMT_DXT3D3DFMT_DXT3

DXGI_FORMAT_BC2_UNORM & DXGI_FORMAT_BC2_UNORM_SRGBDXGI_FORMAT_BC2_UNORM & DXGI_FORMAT_BC2_UNORM_SRGB

D3DFMT_DXT4D3DFMT_DXT4

DXGI_FORMAT_BC2_UNORM & DXGI_FORMAT_BC2_UNORM_SRGBDXGI_FORMAT_BC2_UNORM & DXGI_FORMAT_BC2_UNORM_SRGB

注意   DXT3 和 DXT4 与 API/硬件的透视是相同的。 Note   DXT3 and DXT4 are the same from an API/hardware perspective. 唯一的差别是是否使用了预乘 alpha,这可以通过应用程序来跟踪,并且不需要单独的格式。The only difference is whether premultiplied alpha is used, which can be tracked by an application and doesn't need a separate format.
 

D3DFMT_DXT5D3DFMT_DXT5

DXGI_FORMAT_BC3_UNORM & DXGI_FORMAT_BC3_UNORM_SRGBDXGI_FORMAT_BC3_UNORM & DXGI_FORMAT_BC3_UNORM_SRGB

D3DFMT_D16 & D3DFMT_D16_LOCKABLED3DFMT_D16 & D3DFMT_D16_LOCKABLE

DXGI_FORMAT_D16_UNORMDXGI_FORMAT_D16_UNORM

D3DFMT_D32D3DFMT_D32

不可用Not available

D3DFMT_D15S1D3DFMT_D15S1

不可用Not available

D3DFMT_D24S8D3DFMT_D24S8

不可用Not available

D3DFMT_D24X8D3DFMT_D24X8

不可用Not available

D3DFMT_D24X4S4D3DFMT_D24X4S4

不可用Not available

D3DFMT_D16D3DFMT_D16

DXGI_FORMAT_D16_UNORMDXGI_FORMAT_D16_UNORM

D3DFMT_D32F_LOCKABLED3DFMT_D32F_LOCKABLE

DXGI_FORMAT_D32_FLOATDXGI_FORMAT_D32_FLOAT

D3DFMT_D24FS8D3DFMT_D24FS8

不可用Not available

D3DFMT_S1D15D3DFMT_S1D15

不可用Not available

D3DFMT_S8D24D3DFMT_S8D24

DXGI_FORMAT_D24_UNORM_S8_UINTDXGI_FORMAT_D24_UNORM_S8_UINT

D3DFMT_X8D24D3DFMT_X8D24

不可用Not available

D3DFMT_X4S4D24D3DFMT_X4S4D24

不可用Not available

D3DFMT_L16D3DFMT_L16

DXGI_FORMAT_R16_UNORMDXGI_FORMAT_R16_UNORM

注意   使用 swizzle 在着色器中将红色复制到其他组件,以获取 D3D9 行为。 Note   Use .r swizzle in shader to duplicate red to other components to get D3D9 behavior.
 

D3DFMT_INDEX16D3DFMT_INDEX16

DXGI_FORMAT_R16_UINTDXGI_FORMAT_R16_UINT

D3DFMT_INDEX32D3DFMT_INDEX32

DXGI_FORMAT_R32_UINTDXGI_FORMAT_R32_UINT

D3DFMT_Q16W16V16U16D3DFMT_Q16W16V16U16

DXGI_FORMAT_R16G16B16A16_SNORMDXGI_FORMAT_R16G16B16A16_SNORM

D3DFMT_MULTI2_ARGB8D3DFMT_MULTI2_ARGB8

不可用Not available

D3DFMT_R16FD3DFMT_R16F

DXGI_FORMAT_R16_FLOATDXGI_FORMAT_R16_FLOAT

D3DFMT_G16R16FD3DFMT_G16R16F

DXGI_FORMAT_R16G16_FLOATDXGI_FORMAT_R16G16_FLOAT

D3DFMT_A16B16G16R16FD3DFMT_A16B16G16R16F

DXGI_FORMAT_R16G16B16A16_FLOATDXGI_FORMAT_R16G16B16A16_FLOAT

D3DFMT_R32FD3DFMT_R32F

DXGI_FORMAT_R32_FLOATDXGI_FORMAT_R32_FLOAT

D3DFMT_G32R32FD3DFMT_G32R32F

DXGI_FORMAT_R32G32_FLOATDXGI_FORMAT_R32G32_FLOAT

D3DFMT_A32B32G32R32FD3DFMT_A32B32G32R32F

DXGI_FORMAT_R32G32B32A32_FLOATDXGI_FORMAT_R32G32B32A32_FLOAT

D3DFMT_CxV8U8D3DFMT_CxV8U8

不可用Not available

D3DDECLTYPE_FLOAT1D3DDECLTYPE_FLOAT1

DXGI_FORMAT_R32_FLOATDXGI_FORMAT_R32_FLOAT

D3DDECLTYPE_FLOAT2D3DDECLTYPE_FLOAT2

DXGI_FORMAT_R32G32_FLOATDXGI_FORMAT_R32G32_FLOAT

D3DDECLTYPE_FLOAT3D3DDECLTYPE_FLOAT3

DXGI_FORMAT_R32G32B32_FLOATDXGI_FORMAT_R32G32B32_FLOAT

D3DDECLTYPE_FLOAT4D3DDECLTYPE_FLOAT4

DXGI_FORMAT_R32G32B32A32_FLOATDXGI_FORMAT_R32G32B32A32_FLOAT

D3DDECLTYPED3DCOLORD3DDECLTYPED3DCOLOR

不可用Not available

D3DDECLTYPE_UBYTE4D3DDECLTYPE_UBYTE4

DXGI_FORMAT_R8G8B8A8_UINTDXGI_FORMAT_R8G8B8A8_UINT

注意   着色器获取 UINT 值,但如果需要 (0.0 f,1.0 f,则需要 Direct3D 9 样式整数浮点) ,UINT 只能在着色器中转换为 float32。 Note   The shader gets UINT values, but if Direct3D 9 style integral floats are needed (0.0f, 1.0f... 255.f), UINT can just be converted to float32 in the shader.
 

D3DDECLTYPE_SHORT2D3DDECLTYPE_SHORT2

DXGI_FORMAT_R16G16_SINTDXGI_FORMAT_R16G16_SINT

注意   着色器获取圣数值,但如果需要 Direct3D 9 样式整数浮点值,则可以只在着色器中将圣马丁转换为 float32。 Note   The shader gets SINT values, but if Direct3D 9 style integral floats are needed, SINT can just be converted to float32 in the shader.
 

D3DDECLTYPE_SHORT4D3DDECLTYPE_SHORT4

DXGI_FORMAT_R16G16B16A16_SINTDXGI_FORMAT_R16G16B16A16_SINT

注意   着色器获取圣数值,但如果需要 Direct3D 9 样式整数浮点值,则可以只在着色器中将圣马丁转换为 float32。 Note   The shader gets SINT values, but if Direct3D 9 style integral floats are needed, SINT can just be converted to float32 in the shader.
 

D3DDECLTYPE_UBYTE4ND3DDECLTYPE_UBYTE4N

DXGI_FORMAT_R8G8B8A8_UNORMDXGI_FORMAT_R8G8B8A8_UNORM

D3DDECLTYPE_SHORT2ND3DDECLTYPE_SHORT2N

DXGI_FORMAT_R16G16_SNORMDXGI_FORMAT_R16G16_SNORM

D3DDECLTYPE_SHORT4ND3DDECLTYPE_SHORT4N

DXGI_FORMAT_R16G16B16A16_SNORMDXGI_FORMAT_R16G16B16A16_SNORM

D3DDECLTYPE_USHORT2ND3DDECLTYPE_USHORT2N

DXGI_FORMAT_R16G16_UNORMDXGI_FORMAT_R16G16_UNORM

D3DDECLTYPE_USHORT4ND3DDECLTYPE_USHORT4N

DXGI_FORMAT_R16G16B16A16_UNORMDXGI_FORMAT_R16G16B16A16_UNORM

D3DDECLTYPE_UDEC3D3DDECLTYPE_UDEC3

不可用Not available

D3DDECLTYPE_DEC3ND3DDECLTYPE_DEC3N

不可用Not available

D3DDECLTYPE_FLOAT16_2D3DDECLTYPE_FLOAT16_2

DXGI_FORMAT_R16G16_FLOATDXGI_FORMAT_R16G16_FLOAT

D3DDECLTYPE_FLOAT16_4D3DDECLTYPE_FLOAT16_4

DXGI_FORMAT_R16G16B16A16_FLOATDXGI_FORMAT_R16G16B16A16_FLOAT

FourCC 'ATI1'FourCC 'ATI1'

DXGI_FORMAT_BC4_UNORMDXGI_FORMAT_BC4_UNORM

注意   需要功能级别10.0 或更高版本 Note   Requires Feature Level 10.0 or later
 

FourCC 'ATI2'FourCC 'ATI2'

DXGI_FORMAT_BC5_UNORMDXGI_FORMAT_BC5_UNORM

注意   需要功能级别10.0 或更高版本 Note   Requires Feature Level 10.0 or later
 

其他映射信息Additional mapping info

控制视频卡的硬件伽玛坡道到 IDirect3DDevice9:: SetGammaRamp 被替换为 IDXGIOutput:: SetGammaControlControl of the video card's hardware gamma ramp through IDirect3DDevice9::SetGammaRamp is replaced by IDXGIOutput::SetGammaControl. 请参阅 使用伽玛更正See Using gamma correction.

IDirect3DDevice9::P rocessvertices 替换为几何图形着色器的流输出功能。IDirect3DDevice9::ProcessVertices is replaced by the Stream-Output functionality of Geometry Shaders. 请参阅 流输出阶段入门。See Getting started with the Stream-Output Stage.

用于设置用户剪辑的方法 IDirect3DDevice9:: SetClipPlane 已由 HLSL SV_ClipDistance 顶点着色器输出语义 (参阅 语义) 、VS_4_0 和向上提供,或 new HLSL clipplanes function 特性 (参阅 功能级别9硬件) 上的用户剪辑平面The method IDirect3DDevice9::SetClipPlane to set user clip-planes was replaced by either the HLSL SV_ClipDistance vertex shader output semantic (see Semantics), available in VS_4_0 and up, or the new HLSL clipplanes function attribute (see User clip planes on feature level 9 hardware).

IDirect3DDevice9:: SetPaletteEntriesIDirect3DDevice9:: SetCurrentTexturePalette 已弃用。IDirect3DDevice9::SetPaletteEntries and IDirect3DDevice9::SetCurrentTexturePalette are deprecated. 将它们替换为在 256x1 R8G8B8A8 纹理中查找颜色的像素着色器。Replace these with a pixel shader that looks up colors in a 256x1 R8G8B8A8 texture instead.

已不推荐使用固定函数镶嵌函数,例如 DrawRectPatchDrawTriPatchSetNPatchModeDeletePatchFixed-function tessellation functions like DrawRectPatch, DrawTriPatch, SetNPatchMode, and DeletePatch are deprecated. 将它们替换为可编程管道 SM 5.0 分割着色器 (如果硬件支持镶嵌着色器) 。Replace these with programmable-pipeline SM5.0 Tessellation shaders (if hardware supports tessellation shaders).

不再支持IDirect3DDevice9:: SetFVF和 FVF 代码。IDirect3DDevice9::SetFVF, and FVF codes, are no longer supported. 在移植到 D3D11 输入布局之前,应从 D3D8/D3D9 FVF 代码移植到 D3D9 顶点声明。You should port from D3D8/D3D9 FVF codes to D3D9 Vertex Declarations before porting to D3D11 Input Layouts.

不直接支持的所有 D3DDECLTYPE 类型都可以通过在 VS_4_0 和向上的顶点着色器开头的少量按位运算来非常高效地模拟。All of the D3DDECLTYPE types that are not directly supported can be emulated fairly efficiently with a small number of bitwise operations at the beginning of a vertex shader in VS_4_0 and up.