Loading...
Searching...
No Matches
unitTestHelper.h
1//
2// Copyright 2023 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_IMAGING_HGI_UNIT_TEST_HELPER_H
8#define PXR_IMAGING_HGI_UNIT_TEST_HELPER_H
9
10#include "pxr/pxr.h"
11
12#include "pxr/imaging/hgi/hgi.h"
13
14PXR_NAMESPACE_OPEN_SCOPE
15
16using HgiUniquePtr = std::unique_ptr<class Hgi>;
17
18class HgiInitializationTestDriver
19{
20public:
21 HGI_API
22 HgiInitializationTestDriver();
23
24 HGI_API
25 ~HgiInitializationTestDriver();
26
27 HGI_API
28 Hgi* GetHgi() { return _hgi.get(); }
29
30private:
31 HgiUniquePtr _hgi;
32};
33
34class HgiPipelineCreationTestDriver
35{
36public:
37 HGI_API
38 HgiPipelineCreationTestDriver();
39
40 HGI_API
41 ~HgiPipelineCreationTestDriver();
42
43 HGI_API
44 bool CreateTestPipeline();
45
46 HGI_API
47 Hgi* GetHgi() { return _hgi.get(); }
48
49protected:
50 bool _CreateShaderProgram();
51 void _DestroyShaderProgram();
52 void _CreateVertexBufferDescriptor();
53 bool _CreatePipeline();
54 void _PrintCompileErrors();
55
56 HgiUniquePtr _hgi;
57 HgiShaderProgramHandle _shaderProgram;
59 HgiVertexBufferDesc _vboDesc;
60 HgiAttachmentDesc _colorAtt;
61 HgiAttachmentDesc _depthAtt;
62};
63
64class HgiGfxCmdBfrExecutionTestDriver : public HgiPipelineCreationTestDriver
65{
66public:
67 HGI_API
68 HgiGfxCmdBfrExecutionTestDriver();
69
70 HGI_API
71 ~HgiGfxCmdBfrExecutionTestDriver();
72
73 HGI_API
74 bool ExecuteTestGfxCmdBfr();
75
76 HGI_API
77 bool WriteToFile(const std::string& filePath);
78
79private:
80 GfVec3i _renderDim;
81
82 bool _CreateResourceBuffers();
83 bool _CreateRenderTargets();
84
85 HgiBufferHandle _indexBuffer;
86 HgiBufferHandle _vertexBuffer;
87
88 HgiTextureHandle _colorTarget;
89 HgiTextureViewHandle _colorTargetView;
90
91 HgiTextureHandle _depthTarget;
92 HgiTextureViewHandle _depthTargetView;
93};
94
95PXR_NAMESPACE_CLOSE_SCOPE
96
97#endif // PXR_IMAGING_HGI_UNIT_TEST_HELPER_H
Basic type for a vector of 3 int components.
Definition: vec3i.h:44
Hydra Graphics Interface.
Definition: hgi.h:95
Describes the properties of a framebuffer attachment.
Describes the attributes of a vertex buffer.