The Monolithic D3D11 Runtime

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.

Overview of Monolithic Direct3D

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:

The 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 and Library Files for Monolithic

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.hd3dcompiler_x.libThe 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.hd3d11shader_x.libThe 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.

Flavors of Monolithic

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
Defaultumd.dllMinimal overhead, typically for a retail release.
D3D11_CREATE_DEVICE_INSTRUMENTEDumd_i.dllProfiling support, for example for PIX captures.
D3D11_CREATE_DEVICE_VALIDATEDumd_v.dllProfiling support plus parameter validation.
D3D11_CREATE_DEVICE_DEBUGumd_d.dllProfiling 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).

Monolithic-specific methods

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.

Windows Method Fast Xbox Method
ID3D11DeviceContext::PSSetConstantBuffersID3D11DeviceContextX::PSSetFastConstantBuffer
ID3D11DeviceContext::PSSetShaderResourcesID3D11DeviceContextX::PSSetFastShaderResource
ID3D11DeviceContext::PSSetSamplersID3D11DeviceContextX::PSSetFastSampler
ID3D11DeviceContext::VSSetConstantBuffersID3D11DeviceContextX::VSSetFastConstantBuffer
ID3D11DeviceContext::VSSetShaderResourcesID3D11DeviceContextX::VSSetFastShaderResource
ID3D11DeviceContext::VSSetSamplersID3D11DeviceContextX::VSSetFastSampler
ID3D11DeviceContext::GSSetConstantBuffersID3D11DeviceContextX::GSSetFastConstantBuffer
ID3D11DeviceContext::GSSetShaderResourcesID3D11DeviceContextX::GSSetFastShaderResource
ID3D11DeviceContext::GSSetSamplersID3D11DeviceContextX::GSSetFastSampler
ID3D11DeviceContext::CSSetConstantBuffersID3D11DeviceContextX::CSSetFastConstantBuffer
ID3D11DeviceContext::CSSetShaderResourcesID3D11DeviceContextX::CSSetFastShaderResource
ID3D11DeviceContext::CSSetSamplersID3D11DeviceContextX::CSSetFastSampler
ID3D11DeviceContext::HSSetConstantBuffersID3D11DeviceContextX::HSSetFastConstantBuffer
ID3D11DeviceContext::HSSetShaderResourcesID3D11DeviceContextX::HSSetFastShaderResource
ID3D11DeviceContext::HSSetSamplersID3D11DeviceContextX::HSSetFastSampler
ID3D11DeviceContext::DSSetConstantBuffersID3D11DeviceContextX::DSSetFastConstantBuffer
ID3D11DeviceContext::DSSetShaderResourcesID3D11DeviceContextX::DSSetFastShaderResource
ID3D11DeviceContext::DSSetSamplersID3D11DeviceContextX::DSSetFastSampler
ID3D11DeviceContext::IASetVertexBuffersID3D11DeviceContextX::IASetFastVertexBuffer
ID3D11DeviceContext::IASetIndexBufferID3D11DeviceContextX::IASetFastIndexBuffer

The “Fast” methods have the following requirements or limitations:

Shader Resource Views

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.

Using Deferred Contexts with Monolithic

The following flag can be passed to improve the performance of ID3D11Device::CreateDeferredContext.

Flag Description
D3D11_CREATE_DEFERRED_CONTEXT_TITLE_MANAGED_COMMAND_LIST_OBJECT_LIFETIMESThis 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.

DXGI Formats: Monolithic Provides Additional Support for 16-bit Depth Buffers

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.

Additional Swap Chain Flags in Monolithic

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_PCThis 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_CONSOLESThis 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_FULLSetting 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_REC709Setting 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.

Monolithic Can Use Alpha Blend Without Dithering

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
0Disables alpha-to-coverage as a multisampling technique when setting a pixel to a render target.
1Uses alpha-to-coverage, with dithering enabled.
2Uses alpha-to-coverage, with dithering disabled.

The choice to enable or disable dithering is purely aesthetic.

Gamma Ramp

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::GetGammaControlYesGets the gamma control settings. Refer to Using gamma correction.
IDXGIOutput::GetGammaControlCapabilitiesYesGets a description of the gamma-control capabilities.
IDXGIOutput::SetGammaControlYesSets the gamma controls.
DXGI_GAMMA_CONTROLYesA supporting structure for the methods. Controls the settings of a gamma curve.
TakeOwnershipNot applicable to Xbox One.Returns S_OK.
ReleaseOwnershipNot applicable to Xbox One.Returns S_OK.
FindClosestMatchingMode NoReturns DXGI_ERROR_UNSUPPORTED.
GetDesc NoReturns DXGI_ERROR_UNSUPPORTED.
GetDisplayModeList NoReturns DXGI_ERROR_UNSUPPORTED.
GetDisplaySurfaceData NoReturns DXGI_ERROR_UNSUPPORTED.
GetFrameStatistics NoReturns DXGI_ERROR_UNSUPPORTED.
SetDisplaySurface NoReturns DXGI_ERROR_UNSUPPORTED.
WaitForVBlank NoReturns DXGI_ERROR_UNSUPPORTED.

Monolithic APIs and COM

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.

Resources

See the following white papers:

The full list of white papers is available at Xbox Game Developer: White Papers.

See also

DirectX