> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GetDevice

> Gets a pointer to the device that created this interface.

Gets a pointer to the device that created this interface.

## Syntax

```cpp theme={null}
void GetDevice(
    const IID & riid,
    void** ppvDevice
)
```

### Parameters

*riid*\
Type: const IID &

The globally unique identifier (**GUID**) for the device interface.
The **REFIID**, or **GUID**, of the interface to the device can be obtained by using the \_\_uuidof() macro.
For example, \_\_uuidof([ID3D12Device](/reference/graphics/d3d12_x/interfaces/id3d12device/id3d12device)) will get the **GUID** of the interface to a device.

*ppvDevice \[out, optional]*\
Type: **void**\*\*

A pointer to a memory block that receives a pointer to the [ID3D12Device](/reference/graphics/d3d12_x/interfaces/id3d12device/id3d12device) interface for the device.

### Return value

Type: void

This method returns one of the [Direct3D 12 Return Codes](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/d3d12-graphics-reference-returnvalues).

## Remarks

Any returned interfaces have their reference count incremented by one, so be sure to call ::release() on the returned pointers before they are freed or else you will have a memory leak.

#### Examples

The [D3D12Multithreading](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/working-samples) sample uses **ID3D12DeviceChild::GetDevice** as follows:

```cpp theme={null}
// Returns required size of a buffer to be used for data upload
inline UINT64 GetRequiredIntermediateSize(
_In_ ID3D12Resource* pDestinationResource,
_In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource,
_In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources)
{
D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc();
UINT64 RequiredSize = 0;

ID3D12Device* pDevice;
pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast<void**>(&pDevice));
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, 0, nullptr, nullptr, nullptr, &RequiredSize);
pDevice->Release();

return RequiredSize;
}

```

Refer to the [Example Code in the D3D12 Reference](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/notes-on-example-code).

<div class="code" />

## Requirements

**Header:** d3d12\_xs.h or d3d12\_x.h\
**Library:** d3d12\_xs.lib or d3d12\_x.lib\
**Supported Platforms**: XBOX Series consoles and XBOX One family

## See Also

[ID3D12DeviceChild](/reference/graphics/d3d12/interfaces/id3d12devicechild/id3d12devicechild_public)


## Related topics

- [IGameInputRawDeviceReport::GetDevice](/reference/input/gameinput/interfaces/igameinputrawdevicereport/methods/igameinputrawdevicereport_getdevice.md)
- [PartyNetwork::GetDevices](/services/playfab/multiplayer/networking/reference/classes/PartyNetwork/methods/partynetwork_getdevices.md)
- [PartyEndpoint::GetDevice](/services/playfab/multiplayer/networking/reference/classes/PartyEndpoint/methods/partyendpoint_getdevice.md)
- [IGameInputReading::GetDevice](/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getdevice.md)
- [PartyChatControl::GetDevice](/services/playfab/multiplayer/networking/reference/classes/PartyChatControl/methods/partychatcontrol_getdevice.md)
