24 #ifndef PXR_IMAGING_HD_ST_GEOMETRIC_SHADER_H
25 #define PXR_IMAGING_HD_ST_GEOMETRIC_SHADER_H
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/imaging/hd/version.h"
30 #include "pxr/imaging/hd/enums.h"
31 #include "pxr/imaging/hdSt/shaderCode.h"
32 #include "pxr/imaging/hdSt/resourceRegistry.h"
33 #include "pxr/usd/sdf/path.h"
34 #include "pxr/imaging/garch/glApi.h"
39 PXR_NAMESPACE_OPEN_SCOPE
41 using HdSt_GeometricShaderSharedPtr =
42 std::shared_ptr<class HdSt_GeometricShader>;
43 struct HdSt_ShaderKey;
62 enum class PrimitiveType {
64 PRIM_BASIS_CURVES_LINES,
65 PRIM_BASIS_CURVES_LINEAR_PATCHES,
66 PRIM_BASIS_CURVES_CUBIC_PATCHES,
67 PRIM_MESH_COARSE_TRIANGLES,
68 PRIM_MESH_REFINED_TRIANGLES,
69 PRIM_MESH_COARSE_QUADS,
70 PRIM_MESH_REFINED_QUADS,
72 PRIM_MESH_BOXSPLINETRIANGLE,
78 static inline bool IsPrimTypePoints (PrimitiveType primType) {
79 return primType == PrimitiveType::PRIM_POINTS;
82 static inline bool IsPrimTypeBasisCurves(PrimitiveType primType) {
83 return (primType == PrimitiveType::PRIM_BASIS_CURVES_LINES ||
84 primType == PrimitiveType::PRIM_BASIS_CURVES_CUBIC_PATCHES ||
85 primType == PrimitiveType::PRIM_BASIS_CURVES_LINEAR_PATCHES);
88 static inline bool IsPrimTypeMesh(PrimitiveType primType) {
89 return (primType == PrimitiveType::PRIM_MESH_COARSE_TRIANGLES ||
90 primType == PrimitiveType::PRIM_MESH_REFINED_TRIANGLES ||
91 primType == PrimitiveType::PRIM_MESH_COARSE_QUADS ||
92 primType == PrimitiveType::PRIM_MESH_REFINED_QUADS ||
93 primType == PrimitiveType::PRIM_MESH_BSPLINE ||
94 primType == PrimitiveType::PRIM_MESH_BOXSPLINETRIANGLE);
97 static inline bool IsPrimTypeTriangles(PrimitiveType primType) {
98 return (primType == PrimitiveType::PRIM_MESH_COARSE_TRIANGLES ||
99 primType == PrimitiveType::PRIM_MESH_REFINED_TRIANGLES ||
100 primType == PrimitiveType::PRIM_VOLUME);
103 static inline bool IsPrimTypeQuads(PrimitiveType primType) {
104 return (primType == PrimitiveType::PRIM_MESH_COARSE_QUADS ||
105 primType == PrimitiveType::PRIM_MESH_REFINED_QUADS);
108 static inline bool IsPrimTypeRefinedMesh(PrimitiveType primType) {
109 return (primType == PrimitiveType::PRIM_MESH_REFINED_TRIANGLES ||
110 primType == PrimitiveType::PRIM_MESH_REFINED_QUADS ||
111 primType == PrimitiveType::PRIM_MESH_BSPLINE ||
112 primType == PrimitiveType::PRIM_MESH_BOXSPLINETRIANGLE);
115 static inline bool IsPrimTypePatches(PrimitiveType primType) {
116 return primType == PrimitiveType::PRIM_MESH_BSPLINE ||
117 primType == PrimitiveType::PRIM_MESH_BOXSPLINETRIANGLE ||
118 primType == PrimitiveType::PRIM_BASIS_CURVES_CUBIC_PATCHES ||
119 primType == PrimitiveType::PRIM_BASIS_CURVES_LINEAR_PATCHES;
123 enum class FvarPatchType {
124 PATCH_COARSE_TRIANGLES,
125 PATCH_REFINED_TRIANGLES,
129 PATCH_BOXSPLINETRIANGLE,
134 HdSt_GeometricShader(std::string
const &glslfxString,
135 PrimitiveType primType,
136 HdCullStyle cullStyle,
137 bool useHardwareFaceCulling,
138 bool hasMirroredTransform,
140 HdPolygonMode polygonMode,
142 FvarPatchType fvarPatchType,
144 float lineWidth = 0);
147 ~HdSt_GeometricShader()
override;
156 HdSt_ResourceBinder
const &binder,
161 HdSt_ResourceBinder
const &binder,
164 void AddBindings(HdBindingRequestVector *customBindings)
override;
167 bool IsFrustumCullingPass()
const {
168 return _frustumCullingPass;
171 PrimitiveType GetPrimitiveType()
const {
176 inline bool IsPrimTypePoints()
const {
177 return IsPrimTypePoints(_primType);
180 inline bool IsPrimTypeBasisCurves()
const {
181 return IsPrimTypeBasisCurves(_primType);
184 inline bool IsPrimTypeMesh()
const {
185 return IsPrimTypeMesh(_primType);
188 inline bool IsPrimTypeTriangles()
const {
189 return IsPrimTypeTriangles(_primType);
192 inline bool IsPrimTypeQuads()
const {
193 return IsPrimTypeQuads(_primType);
196 inline bool IsPrimTypePatches()
const {
197 return IsPrimTypePatches(_primType);
200 FvarPatchType GetFvarPatchType()
const {
201 return _fvarPatchType;
206 GLenum GetPrimitiveMode()
const;
211 int GetPrimitiveIndexSize()
const;
216 int GetNumPatchEvalVerts()
const;
221 int GetNumPrimitiveVertsForGeometryShader()
const;
224 static HdSt_GeometricShaderSharedPtr Create(
225 HdSt_ShaderKey
const &shaderKey,
226 HdStResourceRegistrySharedPtr
const &resourceRegistry);
229 PrimitiveType _primType;
230 HdCullStyle _cullStyle;
231 bool _useHardwareFaceCulling;
232 bool _hasMirroredTransform;
234 HdPolygonMode _polygonMode;
237 std::unique_ptr<HioGlslfx> _glslfx;
238 bool _frustumCullingPass;
239 FvarPatchType _fvarPatchType;
243 HdSt_GeometricShader(
const HdSt_GeometricShader &) =
delete;
244 HdSt_GeometricShader &operator =(
const HdSt_GeometricShader &) =
delete;
248 PXR_NAMESPACE_CLOSE_SCOPE
250 #endif // PXR_IMAGING_HD_ST_GEOMETRIC_SHADER_H
virtual void BindResources(int program, HdSt_ResourceBinder const &binder, HdRenderPassState const &state)=0
Binds shader-specific resources to program XXX: this interface is meant to be used for bridging the G...
virtual void UnbindResources(int program, HdSt_ResourceBinder const &binder, HdRenderPassState const &state)=0
Unbinds shader-specific resources.
virtual std::string GetSource(TfToken const &shaderStageKey) const =0
Returns the shader source provided by this shader for shaderStageKey.
virtual void AddBindings(HdBindingRequestVector *customBindings)=0
Add custom bindings (used by codegen)
A set of rendering parameters used among render passes.
Token for efficient comparison, assignment, and hashing of known strings.
A path value used to locate objects in layers or scenegraphs.
A base class representing the implementation (code) of a shader, used in conjunction with HdRenderPas...
virtual ID ComputeHash() const =0
Returns the hash value of the shader code and configuration.