Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ID3D11Device1::CreateDeviceContextState method

Creates a context state object that holds all Microsoft Direct3D state and some Direct3D behavior.

Syntax


HRESULT CreateDeviceContextState(
  [in]   UINT Flags,
  [in]   const D3D_FEATURE_LEVEL *pFeatureLevels,
  [in]   UINT FeatureLevels,
  [in]   UINT SDKVersion,
  [in]   REFIID EmulatedInterface,
  [out]  D3D_FEATURE_LEVEL *pChosenFeatureLevel,
  [out]  ID3DDeviceContextState **ppContextState
);

Parameters

Flags [in]

A combination of D3D11_1_CREATE_DEVICE_CONTEXT_STATE_FLAG values that are combined by using a bitwise OR operation. The resulting value specifies how to create the context state object. The D3D11_1_CREATE_DEVICE_CONTEXT_STATE_SINGLETHREADED flag is currently the only defined flag. If the original device was created with D3D11_CREATE_DEVICE_SINGLETHREADED, you must create all context state objects from that device with the D3D11_1_CREATE_DEVICE_CONTEXT_STATE_SINGLETHREADED flag.

If you set the single-threaded flag for both the context state object and the device, you guarantee that you will call the whole set of context methods and device methods only from one thread. You therefore do not need to use critical sections to synchronize access to the device context, and the runtime can avoid working with those processor-intensive critical sections.

pFeatureLevels [in]

A pointer to an array of D3D_FEATURE_LEVEL values. The array can contain elements from the following list and determines the order of feature levels for which creation is attempted. Unlike D3D11CreateDevice, you can't set pFeatureLevels to NULL because there is no default feature level array.



{
    D3D_FEATURE_LEVEL_11_1,
    D3D_FEATURE_LEVEL_11_0,
    D3D_FEATURE_LEVEL_10_1,
    D3D_FEATURE_LEVEL_10_0,
    D3D_FEATURE_LEVEL_9_3,
    D3D_FEATURE_LEVEL_9_2,
    D3D_FEATURE_LEVEL_9_1,
};
          

FeatureLevels [in]

The number of elements in pFeatureLevels. Unlike D3D11CreateDevice, you must set FeatureLevels to greater than 0 because you can't set pFeatureLevels to NULL.

SDKVersion [in]

The SDK version. You must set this parameter to D3D11_SDK_VERSION.

EmulatedInterface [in]

The globally unique identifier (GUID) for the emulated interface. This value specifies the behavior of the device when the context state object is active. Valid values are obtained by using the __uuidof operator on the ID3D10Device, ID3D10Device1, ID3D11Device, and ID3D11Device1 interfaces. See Remarks.

pChosenFeatureLevel [out]

A pointer to a variable that receives a D3D_FEATURE_LEVEL value from the pFeatureLevels array. This is the first array value with which CreateDeviceContextState succeeded in creating the context state object. If the call to CreateDeviceContextState fails, the variable pointed to by pChosenFeatureLevel is set to zero.

ppContextState [out]

The address of a pointer to an ID3DDeviceContextState object that represents the state of a Direct3D device.

Return value

This method returns one of the Direct3D 11 Return Codes.

Remarks

The REFIID value of the emulated interface is a GUID obtained by use of the __uuidof operator. For example, __uuidof(ID3D11Device) gets the GUID of the interface to a Microsoft Direct3D 11 device.

Call the ID3D11DeviceContext1::SwapDeviceContextState method to activate the context state object. When the context state object is active, the device behaviors that are associated with both the context state object's feature level and its compatible interface are activated on the Direct3D device until the next call to SwapDeviceContextState.

When a context state object is active, the runtime disables certain methods on the device and context interfaces. For example, a context state object that is created with __uuidof(ID3D11Device) will cause the runtime to turn off most of the Microsoft Direct3D 10 device interfaces, and a context state object that is created with __uuidof(ID3D10Device1) or __uuidof(ID3D10Device) will cause the runtime to turn off most of the ID3D11DeviceContext methods. This behavior ensures that a user of either emulated interface cannot set device state that the other emulated interface is unable to express. This restriction helps guarantee that the ID3D10Device1 emulated interface accurately reflects the full state of the pipeline and that the emulated interface will not operate contrary to its original interface definition.

For example, suppose the tessellation stage is made active through the ID3D11DeviceContext interface when you create the device through D3D11CreateDevice or D3D11CreateDeviceAndSwapChain, instead of through the Direct3D 10 equivalents. Because the Direct3D 11 context is active, a Direct3D 10 interface is inactive when you first retrieve it via QueryInterface. This means that you cannot immediately pass a Direct3D 10 interface that you retrieved from a Direct3D 11 device to a function. You must first call SwapDeviceContextState to activate a Direct3D 10-compatible context state object.

The following table shows the methods that are active and inactive for each emulated interface.

Emulated interface Active device or immediate context interfaces Inactive device or immediate context interfaces

ID3D11Device or

ID3D11Device1

ID3D11Device

IDXGIDevice +

IDXGIDevice1 +

IDXGIDevice2

ID3D10Multithread

ID3D10Device

ID3D10Device1 or

ID3D10Device

ID3D10Device

ID3D10Device1

IDXGIDevice +

IDXGIDevice1

ID3D10Multithread

ID3D11Device

ID3D11DeviceContext (As published by the immediate context. The Direct3D 10 or Microsoft Direct3D 10.1 emulated interface has no effect on deferred contexts.)

 

The following table shows the immediate context methods that the runtime disables when the indicated context state objects are active.

Methods of ID3D11DeviceContext when __uuidof(ID3D10Device1) or __uuidof(ID3D10Device) is active Methods of ID3D10Device when __uuidof(ID3D11Device) is active

ClearDepthStencilView

ClearDepthStencilView

ClearRenderTargetView

ClearRenderTargetView

ClearState

ClearState

ClearUnorderedAccessViewUint

ClearUnorderedAccessViewFloat

CopyResource

CopyResource

CopyStructureCount

CopySubresourceRegion

CopySubresourceRegion

CSGetConstantBuffers

CSGetSamplers

CSGetShader

CSGetShaderResources

CSGetUnorderedAccessViews

CSSetConstantBuffers

CSSetSamplers

CSSetShader

CSSetShaderResources

CSSetUnorderedAccessViews

Dispatch

DispatchIndirect

CreateBlendState

Draw

Draw

DrawAuto

DrawAuto

DrawIndexed

DrawIndexed

DrawIndexedInstanced

DrawIndexedInstanced

DrawIndexedInstancedIndirect

DrawInstanced

DrawInstanced

DrawInstancedIndirect

DSGetConstantBuffers

DSGetSamplers

DSGetShader

DSGetShaderResources

DSSetConstantBuffers

DSSetSamplers

DSSetShader

DSSetShaderResources

ExecuteCommandList

FinishCommandList

Flush

Flush

GenerateMips

GenerateMips

GetPredication

GetPredication

GetResourceMinLOD

GetType

GetTextFilterSize

GSGetConstantBuffers

GSGetConstantBuffers

GSGetSamplers

GSGetSamplers

GSGetShader

GSGetShader

GSGetShaderResources

GSGetShaderResources

GSSetConstantBuffers

GSSetConstantBuffers

GSSetSamplers

GSSetSamplers

GSSetShader

GSSetShader

GSSetShaderResources

GSSetShaderResources

HSGetConstantBuffers

HSGetSamplers

HSGetShader

HSGetShaderResources

HSSetConstantBuffers

HSSetSamplers

HSSetShader

HSSetShaderResources

IAGetIndexBuffer

IAGetIndexBuffer

IAGetInputLayout

IAGetInputLayout

IAGetPrimitiveTopology

IAGetPrimitiveTopology

IAGetVertexBuffers

IAGetVertexBuffers

IASetIndexBuffer

IASetIndexBuffer

IASetInputLayout

IASetInputLayout

IASetPrimitiveTopology

IASetPrimitiveTopology

IASetVertexBuffers

IASetVertexBuffers

OMGetBlendState

OMGetBlendState

OMGetDepthStencilState

OMGetDepthStencilState

OMGetRenderTargets

OMGetRenderTargets

OMGetRenderTargetsAndUnorderedAccessViews

OMSetBlendState

OMSetBlendState

OMSetDepthStencilState

OMSetDepthStencilState

OMSetRenderTargets

OMSetRenderTargets

OMSetRenderTargetsAndUnorderedAccessViews

PSGetConstantBuffers

PSGetConstantBuffers

PSGetSamplers

PSGetSamplers

PSGetShader

PSGetShader

PSGetShaderResources

PSGetShaderResources

PSSetConstantBuffers

PSSetConstantBuffers

PSSetSamplers

PSSetSamplers

PSSetShader

PSSetShader

PSSetShaderResources

PSSetShaderResources

ResolveSubresource

ResolveSubresource

RSGetScissorRects

RSGetScissorRects

RSGetState

RSGetState

RSGetViewports

RSGetViewports

RSSetScissorRects

RSSetScissorRects

RSSetState

RSSetState

RSSetViewports

RSSetViewports

SetPredication

SetPredication

SetResourceMinLOD

SetTextFilterSize

SOGetTargets

SOGetTargets

SOSetTargets

SOSetTargets

UpdateSubresource

UpdateSubresource

VSGetConstantBuffers

VSGetConstantBuffers

VSGetSamplers

VSGetSamplers

VSGetShader

VSGetShader

VSGetShaderResources

VSGetShaderResources

VSSetConstantBuffers

VSSetConstantBuffers

VSSetSamplers

VSSetSamplers

VSSetShader

VSSetShader

VSSetShaderResources

VSSetShaderResources

 

The following table shows the immediate context methods that the runtime does not disable when the indicated context state objects are active.

Methods of ID3D11DeviceContext when __uuidof(ID3D10Device1) or __uuidof(ID3D10Device) is active Methods of ID3D10Device when __uuidof(ID3D11Device) is active

Begin

End

GetCreationFlags

GetPrivateData

GetContextFlags

GetData

Map

Unmap

 

The following table shows the ID3D10Device interface methods that the runtime does not disable because they are not immediate context methods.

Methods of ID3D10Device

CheckCounter

CheckCounterInfo

Create*, like CreateQuery

GetDeviceRemovedReason

GetExceptionMode

OpenSharedResource

SetExceptionMode

SetPrivateData

SetPrivateDataInterface

 

Windows Phone 8: This API is supported.

Requirements

Minimum supported client

Windows 8 and Platform Update for Windows 7 [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2012 and Platform Update for Windows Server 2008 R2 [desktop apps | Windows Store apps]

Header

D3D11_1.h

Library

D3D11.lib

See also

ID3D11Device1

 

 

Community Additions

Show:
© 2014 Microsoft