Loading...
Searching...
No Matches
extCompGpuComputationResource.h
1//
2// Copyright 2017 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_HD_ST_EXT_COMP_GPU_COMPUTATION_RESOURCE_H
8#define PXR_IMAGING_HD_ST_EXT_COMP_GPU_COMPUTATION_RESOURCE_H
9
10#include "pxr/pxr.h"
11#include "pxr/imaging/hdSt/api.h"
12#include "pxr/imaging/hd/bufferSource.h"
13#include "pxr/imaging/hdSt/resourceBinder.h"
14#include "pxr/imaging/hdSt/extCompComputeShader.h"
15#include "pxr/imaging/hdSt/resourceRegistry.h"
16
17#include <vector>
18
19PXR_NAMESPACE_OPEN_SCOPE
20
21using HdStExtCompGpuComputationResourceSharedPtr =
22 std::shared_ptr<class HdStExtCompGpuComputationResource>;
23using HdStGLSLProgramSharedPtr= std::shared_ptr<class HdStGLSLProgram>;
24using HdBufferArrayRangeSharedPtrVector =
25 std::vector<HdBufferArrayRangeSharedPtr>;
26
37public:
57 HdBufferSpecVector const &outputBufferSpecs,
58 HdSt_ExtCompComputeShaderSharedPtr const &kernel,
59 HdBufferArrayRangeSharedPtrVector const &inputs,
60 HdStResourceRegistrySharedPtr const &registry
61 );
62
63 virtual ~HdStExtCompGpuComputationResource() = default;
64
67 HdBufferArrayRangeSharedPtrVector const &GetInputs() const {
68 return _inputs;
69 }
70
75 HdStGLSLProgramSharedPtr const &GetProgram() {
76 if (!_computeProgram) {
77 _Resolve();
78 }
79 return _computeProgram;
80 }
81
85 HdSt_ResourceBinder const &GetResourceBinder() {
86 if (!_computeProgram) {
87 _Resolve();
88 }
89 return _resourceBinder;
90 }
91
92private:
96 bool _Resolve();
97
98 HdBufferSpecVector _outputBufferSpecs;
99 HdSt_ExtCompComputeShaderSharedPtr _kernel;
100 HdStResourceRegistrySharedPtr _registry;
101
102 size_t _shaderSourceHash;
103 HdBufferArrayRangeSharedPtrVector _inputs;
104 HdStGLSLProgramSharedPtr _computeProgram;
105 HdSt_ResourceBinder _resourceBinder;
106
109 const HdStExtCompGpuComputationResource &) = delete;
111 const HdStExtCompGpuComputationResource &) = delete;
112};
113
114PXR_NAMESPACE_CLOSE_SCOPE
115
116#endif // PXR_IMAGING_HD_ST_EXT_COMP_GPU_COMPUTATION_RESOURCE_H
117
A resource that represents the persistent GPU resources of an ExtComputation.
HdStGLSLProgramSharedPtr const & GetProgram()
Gets the GPU HdStGLSLProgram to run to execute the computation.
HdStExtCompGpuComputationResource(HdBufferSpecVector const &outputBufferSpecs, HdSt_ExtCompComputeShaderSharedPtr const &kernel, HdBufferArrayRangeSharedPtrVector const &inputs, HdStResourceRegistrySharedPtr const &registry)
Creates a GPU computation resource that can bind resources matching the layout of the compute kernel.
HdBufferArrayRangeSharedPtrVector const & GetInputs() const
Gets the HdBufferArrayRange that inputs should be loaded into using the resource binder.
HdSt_ResourceBinder const & GetResourceBinder()
Gets the resource binder that matches the layout of the compute program.