Loading...
Searching...
No Matches
visualizeAovTask.h
1
//
2
// Copyright 2021 Pixar
3
//
4
// Licensed under the terms set forth in the LICENSE.txt file available at
5
// https://openusd.org/license.
6
//
7
#ifndef HDX_VISUALIZE_AOV_TASK_H
8
#define HDX_VISUALIZE_AOV_TASK_H
9
10
#include "
pxr/pxr.h
"
11
#include "
pxr/base/gf/vec3i.h
"
12
#include "pxr/imaging/hdx/api.h"
13
#include "pxr/imaging/hdx/task.h"
14
#include "pxr/imaging/hdx/tokens.h"
15
#include "pxr/imaging/hgi/attachmentDesc.h"
16
#include "pxr/imaging/hgi/buffer.h"
17
#include "pxr/imaging/hgi/graphicsPipeline.h"
18
#include "pxr/imaging/hgi/resourceBindings.h"
19
#include "pxr/imaging/hgi/shaderProgram.h"
20
#include "pxr/imaging/hgi/texture.h"
21
#include "pxr/usd/sdf/path.h"
22
23
PXR_NAMESPACE_OPEN_SCOPE
24
25
struct
HdxVisualizeAovTaskParams
;
26
45
class
HdxVisualizeAovTask
:
public
HdxTask
46
{
47
public
:
48
using
TaskParams
=
HdxVisualizeAovTaskParams
;
49
50
HDX_API
51
HdxVisualizeAovTask
(
HdSceneDelegate
* delegate,
SdfPath
const
&
id
);
52
53
HDX_API
54
~HdxVisualizeAovTask
()
override
;
55
56
HDX_API
57
void
Prepare
(HdTaskContext* ctx,
58
HdRenderIndex
* renderIndex)
override
;
59
60
HDX_API
61
void
Execute
(HdTaskContext* ctx)
override
;
62
63
protected
:
64
HDX_API
65
void
_Sync(
HdSceneDelegate
* delegate,
66
HdTaskContext* ctx,
67
HdDirtyBits* dirtyBits)
override
;
68
69
private
:
70
// Enumeration of visualization kernels
71
enum
VizKernel {
72
VizKernelDepth = 0,
73
VizKernelId,
74
VizKernelNormal,
75
VizKernelFallback,
76
VizKernelNone
77
};
78
79
HdxVisualizeAovTask
() =
delete
;
80
HdxVisualizeAovTask
(
const
HdxVisualizeAovTask
&) =
delete
;
81
HdxVisualizeAovTask
&operator =(
const
HdxVisualizeAovTask
&) =
delete
;
82
83
// Returns true if the enum member was updated, indicating that the kernel
84
// to be used has changed.
85
bool
_UpdateVizKernel(
TfToken
const
&aovName);
86
87
// Returns a token used in sampling the texture based on the kernel used.
88
TfToken
const
& _GetTextureIdentifierForShader()
const
;
89
90
// Returns the fragment shader mixin based on the kernel used.
91
TfToken
const
& _GetFragmentMixin()
const
;
92
93
// ------------- Hgi resource creation/deletion utilities ------------------
94
// Utility function to create the GL program for color correction
95
bool
_CreateShaderResources(
HgiTextureDesc
const
& inputAovTextureDesc);
96
97
// Utility function to create buffer resources.
98
bool
_CreateBufferResources();
99
100
// Utility to create resource bindings
101
bool
_CreateResourceBindings(
HgiTextureHandle
const
& inputAovTexture);
102
103
// Utility to create a pipeline
104
bool
_CreatePipeline(
HgiTextureDesc
const
& outputTextureDesc);
105
106
// Utility to create a texture sampler
107
bool
_CreateSampler(
HgiTextureDesc
const
& inputAovTextureDesc);
108
109
// Create texture to write the colorized results into.
110
bool
_CreateOutputTexture(
GfVec3i
const
&dimensions);
111
112
// Destroy shader program and the shader functions it holds.
113
void
_DestroyShaderProgram();
114
115
// Print shader compile errors.
116
void
_PrintCompileErrors();
117
// -------------------------------------------------------------------------
118
119
// Readback the depth AOV on the CPU to update min, max values.
120
void
_UpdateMinMaxDepth(
HgiTextureHandle
const
&inputAovTexture);
121
122
// Execute the appropriate kernel and update the task context 'color' entry.
123
void
_ApplyVisualizationKernel(
HgiTextureHandle
const
& outputTexture);
124
125
// Kernel dependent resources
126
HgiTextureHandle
_outputTexture;
127
GfVec3i
_outputTextureDimensions;
128
HgiAttachmentDesc
_outputAttachmentDesc;
129
HgiShaderProgramHandle
_shaderProgram;
130
HgiResourceBindingsHandle
_resourceBindings;
131
HgiGraphicsPipelineHandle
_pipeline;
132
133
// Kernel independent resources
134
HgiBufferHandle
_indexBuffer;
135
HgiBufferHandle
_vertexBuffer;
136
HgiSamplerHandle
_sampler;
137
138
float
_screenSize[2];
139
float
_minMaxDepth[2];
140
VizKernel _vizKernel;
141
};
142
143
153
struct
HdxVisualizeAovTaskParams
154
{
155
HDX_API
156
HdxVisualizeAovTaskParams
();
157
158
TfToken
aovName;
159
};
160
161
// VtValue requirements
162
HDX_API
163
std::ostream& operator<<(std::ostream& out,
const
HdxVisualizeAovTaskParams
& pv);
164
HDX_API
165
bool
operator==(
const
HdxVisualizeAovTaskParams
& lhs,
166
const
HdxVisualizeAovTaskParams
& rhs);
167
HDX_API
168
bool
operator!=(
const
HdxVisualizeAovTaskParams
& lhs,
169
const
HdxVisualizeAovTaskParams
& rhs);
170
171
PXR_NAMESPACE_CLOSE_SCOPE
172
173
#endif
GfVec3i
Basic type for a vector of 3 int components.
Definition
vec3i.h:44
HdRenderIndex
The render index is part of the Hydra 1.0 API and is only used for emulation purposes so that HdScene...
Definition
renderIndex.h:110
HdSceneDelegate
Adapter class providing data exchange with the client scene graph.
Definition
sceneDelegate.h:404
HdxTask
Base class for (some) tasks in Hdx that provides common progressive rendering and Hgi functionality.
Definition
task.h:28
HdxVisualizeAovTask
A task for visualizing non-color AOVs such as depth, normals, primId.
Definition
visualizeAovTask.h:46
HdxVisualizeAovTask::Prepare
HDX_API void Prepare(HdTaskContext *ctx, HdRenderIndex *renderIndex) override
Prepare Phase: Resolve bindings and manage resources.
HdxVisualizeAovTask::Execute
HDX_API void Execute(HdTaskContext *ctx) override
Execute Phase: Runs the task.
HgiHandle< class HgiTexture >
SdfPath
A path value used to locate objects in layers or scenegraphs.
Definition
path.h:281
TfToken
Token for efficient comparison, assignment, and hashing of known strings.
Definition
token.h:71
pxr.h
HdxVisualizeAovTaskParams
aovName: The name of the aov to visualize.
Definition
visualizeAovTask.h:154
HgiAttachmentDesc
Describes the properties of a framebuffer attachment.
Definition
attachmentDesc.h:49
HgiTextureDesc
Describes the properties needed to create a GPU texture.
Definition
texture.h:91
vec3i.h
pxr
imaging
hdx
visualizeAovTask.h
© Copyright 2026, Pixar Animation Studios. |
Terms of Use
| Generated on Fri Jun 5 2026 12:57:27 by
1.12.0