Skip to content

Commit 46aabab

Browse files
austinkinrossjbourdon-msftstevewhims
authored
Make most recent PIX docs publicly (#2917)
* Documenting PIX buffer-to-buffer custom visualizers. (#2603) * PIX custom visualizers bind-by-name (#2647) * Adding details about PIX custom visualizers bind-by-name. * Edit pass Edit pass: use contractions, don't use Latin, don't say "Note that" (have a !NOTE or nothing), active voice. * Fix code block formatting in markdown --------- Co-authored-by: Steven White <[email protected]> * PIX HLSL API: Root Descriptor Limitation (#2831) * PIX HLSL API: adding note about custom visualizer root descriptor binding limitation. * Update pix-custom-visualizers.md --------- Co-authored-by: Steven White <[email protected]> * Fixing link to custom-visualizers-buffer-to-buffer-example.png. --------- Co-authored-by: JS Bourdon <[email protected]> Co-authored-by: Steven White <[email protected]> Co-authored-by: JS Bourdon <[email protected]>
1 parent 7644a3f commit 46aabab

File tree

2 files changed

+82
-4
lines changed

2 files changed

+82
-4
lines changed

desktop-src/direct3dtools/pix/articles/gpu-captures/pix-custom-visualizers.md

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Custom texture/mesh visualizers in PIX
33
description: Documenting how to use custom texture/mesh visualizers with PIX
44
ms.topic: concept-article
5-
ms.date: 10/18/2024
5+
ms.date: 01/30/2025
66
---
77

88
# Custom texture/mesh visualizers in PIX
@@ -82,7 +82,7 @@ To get more information on the API, refer to the HLSL API section.
8282

8383
![Example output from the texture visualizer above](../../images/custom-visualizers-compiler-texture-example.png)
8484

85-
## Custom buffer visualizer
85+
## Custom mesh visualizer
8686

8787
Assuming you've set up paths to your visualizer shaders in the settings, you can now see your visualizers listed in the *Custom Visualization* panel, which you can open using the following buffer viewer toolbar icon: `{}`.
8888

@@ -92,7 +92,7 @@ From that panel, you can select any available custom visualizer, and see any war
9292

9393
![Example error from a buffer visualizer](../../images/custom-visualizers-buffer-error.png)
9494

95-
### Creating a custom buffer visualizer
95+
### Creating a custom mesh visualizer
9696

9797
A visualizer is a compute shader running against the selected event, and whose output will be displayed in the mesh viewer in place of the buffer viewer showing the currently selected buffer data. To be successfully recognized by PIX, your entry point must be named **main**.
9898

@@ -141,13 +141,51 @@ In the example above, we access vertices declaring `Vertices` to point to the pi
141141

142142
To get more information on the API, refer to the HLSL API section.
143143

144-
![Example output from the buffer visualizer above](../../images/custom-visualizers-buffer-example.png)
144+
![Example output from the mesh visualizer above](../../images/custom-visualizers-buffer-example.png)
145145

146146
### Visualize a buffer as a texture
147147

148148
It is also possible to select a buffer and a custom visualizer outputting to a texture. In that case,
149149
the texture viewer will be displayed in place of the regular buffer viewer to display the result.
150150

151+
## Custom buffer visualizer
152+
153+
The custom buffer visualizer works the same as the custom mesh visualizer, except instead of outputing to a pair of index and vertex buffers, it outputs to a `RWStructuredBuffer`. The buffer viewer is shown displaying the output and the buffer format applied to the viewer is automatically populated from the structured buffer template type. This kind of visualizer is useful, among other things, to reinterpret buffer data where multiple indirections might be involved or where the meaning of the data is not easily human-readable without further modification and interpretation. It can also be used to aggregate information coming from multiple resources and display the result in a specified format.
154+
155+
### Creating a custom buffer visualizer
156+
157+
To create the visualizer, there are two required steps. A type is declared as the output type using `PixExt_Declare_BufferOutput_Type`. The buffer viewer format is derived from that type. Then, data is sent to output using `PixExt_StoreBufferData` where the offset into the structured buffer and the data to store are specified.
158+
159+
To get more information on the API, refer to the HLSL API section.
160+
161+
#### Example
162+
163+
```hlsl
164+
struct OutputData
165+
{
166+
uint i;
167+
float f;
168+
};
169+
170+
PixExt_Declare_BufferOutput_Type(OutputData);
171+
172+
[numthreads(32, 1, 1)]
173+
void main(PixExt_ComputeInput input)
174+
{
175+
OutputData output;
176+
output.i = some_value;
177+
output.f = some_other_value;
178+
179+
const uint bufferElementCount = PixExt_GetBufferElementCount();
180+
if (input.dispatchThreadId.x < bufferElementCount)
181+
{
182+
PixExt_StoreBufferData(input.dispatchThreadId.x, output);
183+
}
184+
}
185+
```
186+
187+
![Example output from the buffer visualizer above](../../images/custom-visualizers-buffer-to-buffer-example.png)
188+
151189
## User constants
152190

153191
It is possible to add constants whose values can be set from the UI for every visualizer invocation. They are supported for all custom visualizer types.
@@ -260,6 +298,13 @@ uint PixExt_GetSelectedMip();
260298
uint PixExt_GetSelectedSlice();
261299
```
262300

301+
### Selected buffer information
302+
303+
```hlsl
304+
// Returns the currently selected buffer element count.
305+
uint PixExt_GetBufferElementCount();
306+
```
307+
263308
### Selected event arguments
264309

265310
```hlsl
@@ -319,6 +364,28 @@ selected event shaders.
319364
Texture2D<float4> g_texture : PixExt_BindByName;
320365
```
321366

367+
You must bind by name through SRV types (Buffer, StructuredBuffer, Texture2D, and so on).
368+
UAVs and CBVs aren't directly supported; but you can bind those resources as SRVs
369+
in your custom visualizer.
370+
371+
Assuming the following declarations in the capture shader code:
372+
373+
```hlsl
374+
ConstantBuffer<ConstantData> g_constants : register(b2, space4);
375+
RWBuffer<float4> g_buffer : register(u4, space2);
376+
```
377+
378+
You can access the data through SRV bindings in your custom visualizer.
379+
380+
```hlsl
381+
StructuredBuffer<ConstantData> g_constants : PixExt_BindByName;
382+
Buffer<float4> g_buffer : PixExt_BindByName;
383+
```
384+
385+
### Root descriptor limitation
386+
387+
A root descriptor can be bound only as a raw buffer in a custom visualizer. Structured buffer binding isn't supported.
388+
322389
### Shader outputs
323390

324391
You output data to the viewers using the following functions.
@@ -361,6 +428,17 @@ void PixExt_StoreIndex(uint offset, uint index);
361428
void PixExt_StoreVertex(uint offset, float4 vertex);
362429
```
363430

431+
#### Buffer
432+
433+
```hlsl
434+
// Stores the given data for buffer viewer display.
435+
//
436+
// offset: Offset into the output structured buffer.
437+
// data: Value to write.
438+
template<typename TypeName>
439+
void PixExt_StoreBufferData(uint offset, TypeName data);
440+
```
441+
364442
## Requirements
365443

366444
Custom visualizer shaders will be compiled using Shader Model 6.6 (namely cs_6_6) and HLSL version 2021. We plan to support newer shader models and relax the restriction on HLSL 2021 in a future release.
59.4 KB
Loading

0 commit comments

Comments
 (0)