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

# PIXBeginEvent function reference

> PIXBeginEvent function reference

# PIXBeginEvent function reference

Starts a user-defined event for a timing capture of CPU activity, to be displayed in the **System Timing Capture** feature of PIX.

## Syntax

```cpp theme={null}
void PIXBeginEvent(  
         UINT64 color,  
         PCWSTR formatString,  
         ...  
)  
```

### Parameters

*color*   \
Type: UINT64

The event color to use in the system timing chart. Use [PIX\_COLOR](/reference/tools/pix3/functions/pix_color) to specify a color, [PIX\_COLOR\_INDEX](/reference/tools/pix3/functions/pix_color_index) to specify a color index, or pass in a raw DWORD noting that the format is ARGB and the alpha channel value must be 0xff.

*formatString*   \_In\_\
Type: PCWSTR

The name to use to describe the event, as a pointer to a null-terminated Unicode string. The string may specify zero or more optional string format placeholders, very similar to `sprintf` formatting.

Type: ...

If placeholders are used in *formatString*, there must be a corresponding number of parameters whose types depend on the placeholders. This method supports up to a maximum of 16 format parameters.

### Return value

Type: void

## Remarks

The `PIXBeginEvent` function saves format string and format parameters instead of formatting the string at runtime. Formatting is then done when reading capture files in PIX. Use 16-byte aligned strings (preferable) or 8-byte aligned strings with PIXBeginEvent to get the best performance.

To print a char\* or wchar\_t\* as a pointer using %p format specifier, cast the pointer to void\* or a pointer to an integral or a floating point type when passing it to `PIXBeginEvent`. For the best performance, use a statically allocated string.

Calls to `PIXBeginEvent` are guaranteed at least 512 bytes of space to save the record data, which includes the full size and alignment of the format string and all variables. In general, PIX events are intended for short high-performance markers that align to your game's major components, systems, or content.

This method is used to time CPU events. For more information about timing GPU events, see the [PIX GPU Capture APIs](/reference/tools/pix3/pix3_members#pixgpucaptureapis) section of [PIX3](/reference/tools/pix3/pix3_members).

Each call to `PIXBeginEvent` must have a matching call to [PIXEndEvent](/reference/tools/pix3/functions/pixendevent). The paired calls to `PIXBeginEvent` and [PIXEndEvent](/reference/tools/pix3/functions/pixendevent) must occur on the same thread.  The timing interval is about 200ns, and there is a low overhead to using this function, so up to several hundred thousand calls to `PIXBeginEvent` can be made per second.

`PIXBeginEvent` and `PIXEndEvent` pairs can be nested to any depth.

## Requirements

**Header:** pix3.h

**Library:** pixevt.lib

**Supported platforms:** XBOX One family consoles and XBOX Series consoles

## See also

[PIXEndEvent](/reference/tools/pix3/functions/pixendevent)\
[PIXBeginEvent](/reference/tools/pix3/functions/pixbeginevent)\
[PIXBeginEvent\_3](/reference/tools/pix3/functions/pixbeginevent_3)\
[PIXBeginEvent\_4](/reference/tools/pix3/functions/pixbeginevent_4)\
[PIX3](/reference/tools/pix3/pix3_members)\
[PIX (NDA topic)](/tools/tools-console/pix/pix)


## Related topics

- [PIXBeginEvent function](/reference/tools/pix3/functions/pixbeginevent.md)
- [PIXBeginEvent reference](/reference/tools/pix3/functions/pixbeginevent_3.md)
- [PIXBeginEvent Function](/reference/tools/pix3/functions/pixbeginevent-overloads.md)
- [PIXBeginEvent overview](/reference/tools/pix3/functions/pixbeginevent_4.md)
- [PIXBeginRetailEvent function](/reference/tools/pix3/functions/pixbeginretailevent.md)
