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

# XGameStreamingGetLastFrameDisplayed

> XGameStreamingGetLastFrameDisplayed

# XGameStreamingGetLastFrameDisplayed

> [!NOTE]
>
> **已弃用。** 此 API 从 2604 GDK 版本开始已弃用，将在未来的 GDK 版本中删除。没有替代 API：游戏应改用 [XGameStreamingGetStreamAddedLatency](https://docs.xbox.com/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminggetstreamaddedlatency.md) 进行延迟感知的游戏调整。

获取最近在流式处理客户端屏幕上显示的帧的帧管道令牌。

## 语法

```cpp theme={null}
HRESULT XGameStreamingGetLastFrameDisplayed(  
         XGameStreamingClientId client,  
         D3D12XBOX_FRAME_PIPELINE_TOKEN* framePipelineToken  
)  
```

### 参数

*client*   \_In\_\
类型：XGameStreamingClientId

正在查询的流式处理客户端设备的 ID。

*framePipelineToken*   \_Out\_\
类型：D3D12XBOX\_FRAME\_PIPELINE\_TOKEN\*

上次在客户端设备上显示的帧管道令牌。

### 返回值

类型：HRESULT

如果成功，则返回 **S\_OK**；否则返回错误代码。

#### 潜在错误

| 错误代码 | 错误值 | 错误原因 |
| - | - | - |
| E\_GAMESTREAMING\_NOT\_INITIALIZED | 0x89245400 | XGameStreaming 运行时尚未初始化。在调用其他 API 之前，请先调用 [XGameStreamingInitialize](https://docs.xbox.com/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminginitialize.md)。 |
| E\_GAMESTREAMING\_CLIENT\_NOT\_CONNECTED | 0x89245401 | 指定的客户端未连接。 |
| E\_GAMESTREAMING\_NO\_DATA | 0x89245402 | 请求的数据不可用。数据可能稍后可用。 |

## 备注

当玩家正在流式播放游戏时，如果游戏需要在确认特定帧显示在用户屏幕上后更改游戏行为，则可以使用 `XGameStreamingGetLastFrameDisplayed`。

游戏可能会使用此项的一些示例包括：

* 视觉计时器已过期，玩家在过期之前未采取任何操作。
* 未在适当的窗口内采取操作。
* 玩家继续超出边界的移动，并且未采取行动来恢复。

`XGameStreamingGetLastFrameDisplayed` 应在尝试确定应采取但未采取操作的时间时使用。如果游戏需要确定在玩家**执行**输入时正在显示的内容，则游戏应使用 [XGameStreamingGetAssociatedFrame](https://docs.xbox.com/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminggetassociatedframe.md)。

## 示例

```C++ theme={null}
// In this example, when processing input, the game would like to pass along the last frame 
// that was being displayed to the player so that their simulation engine can take that into account.
 

// The framePipelineToken was initially captured at the callback of WaitFrameEventX

void Game::Update(DX::StepTimer const& timer)
{
    ...

    D3D12XBOX_FRAME_PIPELINE_TOKEN framePipelineToken = D3D12XBOX_FRAME_PIPELINE_TOKEN_NULL;
    if SUCCEEDED(XGameStreamingGetLastFrameDisplayed(clientId, &framePipelineToken)
    {
        SimulateBasedOnLastFrameDisplayed(framePipelineToken);
    }
    else 
    {
        // don't have last token, potentially simulate based on current frame

        SimulateBasedOnCurrentFrame();
    }

    
      
    ...
}

```

## 要求

**标头：** xgamestreaming.h

**库：** xgameruntime.lib

**支持的平台：** Windows、XBOX One 系列主机和 XBOX Series 主机

## 概念性文档

* [游戏流式处理延迟补偿深入探究](https://docs.xbox.com/zh-CN/build/core-features/common/game-streaming/game-streaming-latency-compensation-deep-dive.md)

## 另请参阅

[XGameStreamingGetAssociatedFrame](https://docs.xbox.com/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminggetassociatedframe.md)\
[XGameStreaming](https://docs.xbox.com/zh-CN/reference/system/xgamestreaming/xgamestreaming_members.md#Latency)\
[游戏流式处理延迟补偿概述](https://docs.xbox.com/zh-CN/build/core-features/common/game-streaming/game-streaming-latency-compensation-overview.md)


## Related topics

- [XGameStreamingGetAssociatedFrame](https://docs.xbox.com/zh-CN/reference/system/xgamestreaming/functions/xgamestreaminggetassociatedframe.md)
- [游戏串流延迟补偿深入探讨](https://docs.xbox.com/zh-CN/build/core-features/common/game-streaming/game-streaming-latency-compensation-deep-dive.md)
- [XGameStreaming（API 内容）](https://docs.xbox.com/zh-CN/reference/system/xgamestreaming/xgamestreaming_members.md)
- [在 Unity 项目中使用 GDK API 的 C# 包装器](https://docs.xbox.com/zh-CN/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [GetLastXmaFrameBitPosition](https://docs.xbox.com/zh-CN/reference/audio/xma2defs/functions/getlastxmaframebitposition.md)
