ID3D11DeviceX::CreatePlacementBuffer Method

Creates a placement buffer.

Syntax

public:
HRESULT CreatePlacementBuffer(
         const D3D11_BUFFER_DESC *pDesc,
         void *pVirtualAddress,
         ID3D11Buffer **ppBuffer
)  

Parameters

pDesc
Type: D3D11_BUFFER_DESC *

[in] The description of the buffer, as a pointer to D3D11_BUFFER_DESC.

pVirtualAddress
Type: void *

[in] The CPU virtual address, as a void pointer. pVirtualAddress needs to have been created with the following flags: MEM_LARGE_PAGES | MEM_GRAPHICS | MEM_RESERVE | MEM_COMMIT, PAGE_WRITECOMBINE | PAGE_READWRITE.

ppBuffer
Type: ID3D11Buffer **

[out, optional] The buffer, as a pointer to a pointer to ID3D11Buffer.

Return value

Type: HRESULT 

One of the Direct3D 11 return codes.

Remarks

Aliasing is supported; that is, the buffer can overlap with other ID3D11Buffer placement instances. You can allocate a set of pages and share them with multiple ID3D11Buffer instances.

You should ensure that the size of the placement buffer is a multiple of BUFFER_CACHE_LINE_SIZE (64), as in the following line of the below example code:

alignedWidth = (sizeof(MyConstantBuffer) + 63) & ~63;  

Example

D3D11_BUFFER_DESC desc = { 0 };
desc.ByteWidth = sizeof(MyConstantBuffer);
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
desc.Usage = D3D11_USAGE_DEFAULT;
alignedWidth = (sizeof(MyConstantBuffer) + 63) & ~63;
void *buffer = static_cast<BYTE*> ( VirtualAlloc( 
                    nullptr, 
                    alignedWidth * mapCount, 
                    MEM_LARGE_PAGES | MEM_GRAPHICS | MEM_RESERVE | MEM_COMMIT, 
                    PAGE_WRITECOMBINE | PAGE_READWRITE ) );
if ( !buffer )
    return E_OUTOFMEMORY;
ComPtr<ID3D11Buffer> mConstantBuffer;
hr = device->CreatePlacementBuffer( &desc, buffer, &mConstantBuffer );  

Requirements

Header: Declared in d3d11_x.h.

Library: Use d3d11_x.lib.

See also

Reference

ID3D11DeviceX Interface

ID3D11DeviceX Members