The Monolithic (or Mono) version of the D3D11 runtime provides a high-performance runtime by using streamlined, Xbox-specific versions of DirectX APIs. This version is platform-specific and has the generalized code from D3D11 removed.
Note The Stock version of the Direct3D driver has been removed from the XDK, so now, all development using the XDK is for Monolithic.
Many of the changes to Direct3D from the Windows version are because Xbox One uses a single specific hardware platform, and Game OS titles require very high graphics performance. Because the target hardware is specific rather than having to support a variety of CPUs and GPUs, a layer of abstraction has been removed to provide faster performance.
The Monolithic runtime is required for all titles. There is a single driver that combines the Direct3D runtime and user-mode driver, removing unnecessary abstraction and improving performance.
Monolithic Direct3D is encapsulated in the unified header file d3d11_x.h, which incorporates relevant definitions, types, and interfaces from the following Windows header files:
d3d11.h, d3d11_1.h, and select d3d10 headersd3dcommon.hdxgi.h, dxgi1_2.h, dxgiformat.h, and dxgitype.hThe runtime is built to d3d11_x.dll. The d3dcompiler library itself remains an independent entity. All of the samples available at Xbox One Samples use the Monolithic runtime.
| Header | Library | Description |
|---|---|---|
d3d11_x.h | d3d11_x.lib | The main Monolithic header and library for DirectX 11.x. You code directly against these APIs, though macro substition is used throughout this header. For the actual API as it will appear in your code, see the Reference documentation or use the Visual Studio features such as AutoComplete. This is the longest header file. This header covers the following areas: |
d3dcompiler_x.h | d3dcompiler_x.lib | The main header and library for the shader language. Include this if there is any shader code in your app. You don't code directly against these APIs, so they are not covered in the Reference documentation. |
d3d11shader_x.h | d3d11shader_x.lib | The structures used by the shader. This file is included when using d3dcompiler_x.h, so there is no need to include it specifically. You don't code directly against these APIs, so they are not covered in the Reference documentation. |
Under Monolithic, the graphics User Mode driver has been split into four new flavors, selected with a set of new D3D11CreateDevice flags:
| Flag | Library | Description |
|---|---|---|
| Default | umd.dll | Minimal overhead, typically for a retail release. |
| D3D11_CREATE_DEVICE_INSTRUMENTED | umd_i.dll | Profiling support, for example for PIX captures. |
| D3D11_CREATE_DEVICE_VALIDATED | umd_v.dll | Profiling support plus parameter validation. |
| D3D11_CREATE_DEVICE_DEBUG | umd_d.dll | Profiling support, parameter validation, and Debug compilation (supporting asserts, RIPs, and so on). |
In addition to these flags, there are some other creation flags that are specific to Monolithic Direct3D (described in the table in Direct3D Creation Flags and Supported Formats on Xbox One).
The Monolithic version of Direct3D also includes a number of methods that are not available in Windows DirectX to aid in maximizing performance. These methods have Fast inserted into the method name. There are a number of limitations that apply to the fast versions, described below the table.
The “Fast” methods have the following requirements or limitations:
The D3D11X_SRV_FORMAT structure is used with D3D Monolithic shader resource views. D3D11X_SRV_FORMAT allows the title to change the data format, numeric format, and component swizzle of a shader resource view after creation. The formats and swizzles are specified in their hardware form, which is enumerated in D3D11X_IMG_DATA_FORMAT, D3D11X_IMG_NUM_FORMAT, and D3D11X_SWIZZLE.
The D3D11X_SRV_FORMAT structure is output by ID3D11ShaderResourceView::GetFormatX, and is passed into ID3D11ShaderResourceView::SetFormatX.
The following flag can be passed to improve the performance of ID3D11Device::CreateDeferredContext.
| Flag | Description |
|---|---|
| D3D11_CREATE_DEFERRED_CONTEXT_TITLE_MANAGED_COMMAND_LIST_OBJECT_LIFETIMES | This flag causes the CPU overhead to be reduced both for recording Command Lists and for calling Release on Command Lists. When this flag is specified, Direct3D no longer increments reference counts on objects when the objects are recorded into the Command List, and Direct3D no longer decrements reference counts on those objects when the Command List is released. It is the title's responsibility then to ensure that it has never freed any Direct3D object used by the Command List when it calls ExecuteCommandList, otherwise CPU crashes or incorrect GPU rendering will occur when using the retail version of Direct3D. However, it is fine to have freed Direct3D objects used by the Command List before calling Release on the Command List. |
The Xbox One hardware supports 16-bit depth buffers with 8-bit stencil; in the DXGI_FORMAT enumeration, refer to the following enumeration constants:
These formats offer higher performance when a stencil is required but depth precision does not need to be very high for the scene being rendered; for example, with certain shadow maps.
The following are additional flags that are available in Monolithic Direct3D that are not in Windows DirectX, for DXGI_SWAP_CHAIN_FLAG.
| Flag | Description |
|---|---|
| DXGIX_SWAP_CHAIN_MATCH_XBOX360_AND_PC | This flag ensures that the behavior of the swap chain matches the behavior on Xbox 360. It also visually matches PC platforms viewed on PC monitors. This flag can be helpful if the title runs on the Xbox 360 or PC as well as on Xbox One, or was originally developed for them. This enumeration constant is defined as DXGIX_SWAP_CHAIN_FLAG_QUANTIZATION_RGB_FULL | DXGIX_SWAP_CHAIN_FLAG_COLORIMETRY_sRGB_TO_REC709. |
| DXGIX_SWAP_CHAIN_MATCH_OTHER_CONSOLES | This flag ensures that the behavior of the swap chain matches that of other game consoles, not the Xbox 360 or PC. This can be helpful if you are developing a title that is also to run on another console, or was originally developed for another console. The flag is identical to defining DXGIX_SWAP_CHAIN_FLAG_QUANTIZATION_RGB_FULL.This is the default behavior, if no swap chain flags are set. |
| DXGIX_SWAP_CHAIN_FLAG_QUANTIZATION_RGB_FULL | Setting this flag adjusts the display color space conversion appropriately for titles which are calibrated for RGB Full (black = 0, white = 255 for 8-bit). Titles should not use this flag when the final front buffer is calibrated for RGB Limited (black = 16, white = 235 for 8-bit). This flag indicates the calibration of the content in the title's front buffer, not the calibration of the television. |
| DXGIX_SWAP_CHAIN_FLAG_COLORIMERTY_sRGB_TO_REC709 | Setting this flag will adjust the display gamma ramp to convert from sRGB to REC709 for titles which are calibrated for sRGB. Titles should not use this flag when the final front buffer content is already calibrated for REC709. This flag indicates the calibration of the content in the title's front buffer, not the calibration of the television. Using this flag also requires setting the flag DXGIX_SWAP_CHAIN_FLAG_QUANTIZATION_RGB_FULL. HDTVs generally expect this color space so it is necessary to convert to REC709 if you want HDTV output to resemble sRGB output on a computer monitor. |
There is an option in Monolithic Direct3D to disable dithering, when alpha blend is used. When using Windows Direct3D, if alpha blend is used, dithering cannot be turned off.
When using Monolithic, to control whether dithering is enabled, in the D3D11_BLEND_DESC1 structure, for the AlphaToCoverageEnable member, specify 0, 1, or 2, as follows:
| Value | Result |
|---|---|
| 0 | Disables alpha-to-coverage as a multisampling technique when setting a pixel to a render target. |
| 1 | Uses alpha-to-coverage, with dithering enabled. |
| 2 | Uses alpha-to-coverage, with dithering disabled. |
The choice to enable or disable dithering is purely aesthetic.
There is some support for the Gamma ramp methods of the IDXGIOutput interface. An IDXGIOutput interface represents an adapter output, such as a monitor. The three supported methods work like the Windows equivalents, except that they are supported on Xbox One in either display mode (Full screen or Snapped).
| Method | Implemented | Notes |
|---|---|---|
| IDXGIOutput::GetGammaControl | Yes | Gets the gamma control settings. Refer to Using gamma correction. |
| IDXGIOutput::GetGammaControlCapabilities | Yes | Gets a description of the gamma-control capabilities. |
| IDXGIOutput::SetGammaControl | Yes | Sets the gamma controls. |
| DXGI_GAMMA_CONTROL | Yes | A supporting structure for the methods. Controls the settings of a gamma curve. |
| TakeOwnership | Not applicable to Xbox One. | Returns S_OK. |
| ReleaseOwnership | Not applicable to Xbox One. | Returns S_OK. |
| FindClosestMatchingMode | No | Returns DXGI_ERROR_UNSUPPORTED. |
| GetDesc | No | Returns DXGI_ERROR_UNSUPPORTED. |
| GetDisplayModeList | No | Returns DXGI_ERROR_UNSUPPORTED. |
| GetDisplaySurfaceData | No | Returns DXGI_ERROR_UNSUPPORTED. |
| GetFrameStatistics | No | Returns DXGI_ERROR_UNSUPPORTED. |
| SetDisplaySurface | No | Returns DXGI_ERROR_UNSUPPORTED. |
| WaitForVBlank | No | Returns DXGI_ERROR_UNSUPPORTED. |
The Monolithic APIs use a Microsoft COM-like architecture, but they do not actually use COM. Addref and Release work, but nothing beyond that is guaranteed to work. Monolithic interfaces may be wrapped in the Microsoft::WRL::ComPtr class and most functionality will work as expected. However, there is a case where calling QueryInterface on a Monolithic interface wrapped in a ComPtr class results in a compiler error. This behavior is “by design” because the Monolithic APIs do not provide a full implementation of COM.
The following code will give a compiler error (QueryInterface’ : cannot access private member declared in class):
Microsoft::WRL::ComPtr<ID3D11DeviceContextX> m_pd3dContextX;
Microsoft::WRL::ComPtr<ID3D11DeviceContext> m_pd3dContext;
// TODO: ....create context for m_pd3dContext as usual.
// Call QueryInterface to get the ID3D11DeviceContextX
m_pd3dContext->QueryInterface(__uuidof(ID3D11DeviceContextX), (VOID**)&m_pd3dContextX);
The way to get around this is to call QueryInterface on the actual context pointer and not the wrapped smart pointer. Replace the last line in the code above with:
m_pd3dContext.Get()->QueryInterface(__uuidof(ID3D11DeviceContextX), (VOID**)&m_pd3dContextX);
Note the use of the Get method on the COM pointer, which performs the operation on the underlying pointer directly.
In general, to create Monolithic D3D devices and contexts use ID3D11DeviceContextX and ID3D11DeviceX interfaces.
See the following white papers:
The full list of white papers is available at Xbox Game Developer: White Papers.