> ## 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.

# PIXSetMarker(UINT64, PCSTR, ...)

> PIXSetMarker function

# PIXSetMarker function

当特定的用户自定义事件发生时，向 PIX System Timing Capture 窗口的 CPU 时间线插入一个标记。

## 语法

```cpp theme={null}
void PIXSetMarker(  
         UINT64 color,  
         PCSTR formatString,  
         ...  
)  
```

### 参数

*color*   \
类型：UINT64

在 PIX 窗口中该事件发生时，用于时序图表的颜色。

使用 [PIX\_COLOR](https://docs.xbox.com/zh-CN/reference/tools/pix3/functions/pix_color.md) 指定颜色，使用 [PIX\_COLOR\_INDEX](https://docs.xbox.com/zh-CN/reference/tools/pix3/functions/pix_color_index.md) 指定颜色索引，或者传入一个原始 DWORD，注意其格式为 ARGB 且 alpha 通道值必须为 0xff。

*formatString*   \_In\_\
类型：PCSTR

用于描述事件的名称。该字符串可以指定零个或多个可选的字符串格式占位符，与 `sprintf` 的格式化方式非常相似。

类型：...

如果在 *formatString* 中使用了占位符，则必须提供相应数量（最多 16 个）的参数，且其类型与占位符匹配。

### 返回值

类型：void

## 备注

`PIXSetMarker` 函数会保存格式字符串和格式参数，而不是在运行时格式化字符串。格式化操作会在 PIX 中读取捕获文件时完成。使用 `PIXSetMarker` 时，请使用 16 字节对齐的字符串（首选）或 8 字节对齐的字符串以获得最佳性能。若要使用 %p 格式说明符将 char\* 或 wchar\_t\* 打印为指针，请在将其传递给 `PIXSetMarker` 时，将该指针强制转换为 void\* 或指向整数或浮点类型的指针。对 `PIXSetMarker` 的任何调用都至少保证 512 字节的空间用于保存记录数据。

该事件将显示为无持续时间，并在 **PIX System Timing Capture** 窗口中以一条竖线（单个竖条）表示。

此函数用于在 CPU 时间线中标记事件。若要在 GPU 时间线中标记事件，请调用 [PIXSetMarker 函数的第三个重载](https://docs.xbox.com/zh-CN/reference/tools/pix3/functions/pixsetmarker_3.md)或 [PIXSetMarker 函数的第四个重载](https://docs.xbox.com/zh-CN/reference/tools/pix3/functions/pixsetmarker_4.md)。

对 `PIXSetMarker` 的调用可以出现在任何位置，无需在 [PIXBeginEvent](https://docs.xbox.com/zh-CN/reference/tools/pix3/functions/pixbeginevent.md) 调用之后。

## 要求

**头文件：** pix3.h

**库：** pixevt.lib

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

## 另请参阅

[PIXSetMarker\_2](https://docs.xbox.com/zh-CN/reference/tools/pix3/functions/pixsetmarker_2.md)\
[PIXSetMarker\_3](https://docs.xbox.com/zh-CN/reference/tools/pix3/functions/pixsetmarker_3.md)\
[PIXSetMarker\_4](https://docs.xbox.com/zh-CN/reference/tools/pix3/functions/pixsetmarker_4.md)\
[PIX3](https://docs.xbox.com/zh-CN/reference/tools/pix3/pix3_members.md)\
[PIX (NDA 主题)](https://docs.xbox.com/zh-CN/tools/tools-console/pix/pix.md)


## Related topics

- [PIXSetMarker](https://docs.xbox.com/zh-CN/reference/tools/pix3/functions/pixsetmarker-overloads.md)
- [PIXSetMarker(void*, UINT64, PCSTR, ...)](https://docs.xbox.com/zh-CN/reference/tools/pix3/functions/pixsetmarker_3.md)
- [PIXSetRetailMarker(void*, UINT64, PCSTR, ...)](https://docs.xbox.com/zh-CN/reference/tools/pix3/functions/pixsetretailmarker.md)
- [PIXSetRetailMarker(void*, UINT64, PCWSTR, ...)](https://docs.xbox.com/zh-CN/reference/tools/pix3/functions/pixsetretailmarker_2.md)
- [PIXSetMarker(UINT64, PCWSTR, ...)](https://docs.xbox.com/zh-CN/reference/tools/pix3/functions/pixsetmarker_2.md)
