7#ifndef PXR_IMAGING_HD_ST_GEOMETRIC_SHADER_H
8#define PXR_IMAGING_HD_ST_GEOMETRIC_SHADER_H
11#include "pxr/imaging/hdSt/api.h"
12#include "pxr/imaging/hdSt/shaderCode.h"
13#include "pxr/imaging/hd/version.h"
14#include "pxr/imaging/hd/enums.h"
15#include "pxr/imaging/hgi/enums.h"
16#include "pxr/usd/sdf/path.h"
20PXR_NAMESPACE_OPEN_SCOPE
22using HdSt_GeometricShaderSharedPtr =
23 std::shared_ptr<class HdSt_GeometricShader>;
24using HdStResourceRegistrySharedPtr =
25 std::shared_ptr<class HdStResourceRegistry>;
46 enum class PrimitiveType {
48 PRIM_BASIS_CURVES_LINES,
49 PRIM_BASIS_CURVES_LINEAR_PATCHES,
50 PRIM_BASIS_CURVES_CUBIC_PATCHES,
51 PRIM_MESH_COARSE_TRIANGLES,
52 PRIM_MESH_REFINED_TRIANGLES,
53 PRIM_MESH_COARSE_QUADS,
54 PRIM_MESH_REFINED_QUADS,
55 PRIM_MESH_COARSE_TRIQUADS,
56 PRIM_MESH_REFINED_TRIQUADS,
58 PRIM_MESH_BOXSPLINETRIANGLE,
64 static inline bool IsPrimTypePoints (PrimitiveType primType) {
65 return primType == PrimitiveType::PRIM_POINTS;
68 static inline bool IsPrimTypeBasisCurves(PrimitiveType primType) {
69 return (primType == PrimitiveType::PRIM_BASIS_CURVES_LINES ||
70 primType == PrimitiveType::PRIM_BASIS_CURVES_CUBIC_PATCHES ||
71 primType == PrimitiveType::PRIM_BASIS_CURVES_LINEAR_PATCHES);
74 static inline bool IsPrimTypeMesh(PrimitiveType primType) {
75 return (primType == PrimitiveType::PRIM_MESH_COARSE_TRIANGLES ||
76 primType == PrimitiveType::PRIM_MESH_REFINED_TRIANGLES ||
77 primType == PrimitiveType::PRIM_MESH_COARSE_QUADS ||
78 primType == PrimitiveType::PRIM_MESH_REFINED_QUADS ||
79 primType == PrimitiveType::PRIM_MESH_COARSE_TRIQUADS ||
80 primType == PrimitiveType::PRIM_MESH_REFINED_TRIQUADS ||
81 primType == PrimitiveType::PRIM_MESH_BSPLINE ||
82 primType == PrimitiveType::PRIM_MESH_BOXSPLINETRIANGLE);
85 static inline bool IsPrimTypeTriangles(PrimitiveType primType) {
86 return (primType == PrimitiveType::PRIM_MESH_COARSE_TRIANGLES ||
87 primType == PrimitiveType::PRIM_MESH_REFINED_TRIANGLES ||
88 primType == PrimitiveType::PRIM_VOLUME);
91 static inline bool IsPrimTypeQuads(PrimitiveType primType) {
92 return (primType == PrimitiveType::PRIM_MESH_COARSE_QUADS ||
93 primType == PrimitiveType::PRIM_MESH_REFINED_QUADS);
96 static inline bool IsPrimTypeTriQuads(PrimitiveType primType) {
97 return (primType == PrimitiveType::PRIM_MESH_COARSE_TRIQUADS ||
98 primType == PrimitiveType::PRIM_MESH_REFINED_TRIQUADS);
101 static inline bool IsPrimTypeRefinedMesh(PrimitiveType primType) {
102 return (primType == PrimitiveType::PRIM_MESH_REFINED_TRIANGLES ||
103 primType == PrimitiveType::PRIM_MESH_REFINED_QUADS ||
104 primType == PrimitiveType::PRIM_MESH_REFINED_TRIQUADS ||
105 primType == PrimitiveType::PRIM_MESH_BSPLINE ||
106 primType == PrimitiveType::PRIM_MESH_BOXSPLINETRIANGLE);
109 static inline bool IsPrimTypePatches(PrimitiveType primType) {
110 return primType == PrimitiveType::PRIM_MESH_BSPLINE ||
111 primType == PrimitiveType::PRIM_MESH_BOXSPLINETRIANGLE ||
112 primType == PrimitiveType::PRIM_BASIS_CURVES_CUBIC_PATCHES ||
113 primType == PrimitiveType::PRIM_BASIS_CURVES_LINEAR_PATCHES;
116 static inline bool IsPrimTypeCompute(PrimitiveType primType) {
117 return primType == PrimitiveType::PRIM_COMPUTE;
121 enum class FvarPatchType {
122 PATCH_COARSE_TRIANGLES,
123 PATCH_REFINED_TRIANGLES,
127 PATCH_BOXSPLINETRIANGLE,
132 HdSt_GeometricShader(std::string
const &glslfxString,
133 PrimitiveType primType,
134 HdCullStyle cullStyle,
135 bool useHardwareFaceCulling,
136 bool hasMirroredTransform,
138 bool useMetalTessellation,
139 HdPolygonMode polygonMode,
141 FvarPatchType fvarPatchType,
144 uint32_t vertexCountFallback = 0,
146 bool useHardwareClipPlanes =
true);
149 ~HdSt_GeometricShader()
override;
158 HdSt_ResourceBinder
const &binder)
override;
162 HdSt_ResourceBinder
const &binder)
override;
164 void AddBindings(HdStBindingRequestVector *customBindings)
override;
167 bool IsFrustumCullingPass()
const {
168 return _frustumCullingPass;
171 PrimitiveType GetPrimitiveType()
const {
175 bool GetUseMetalTessellation()
const {
176 return _useMetalTessellation;
179 float GetLineWidth()
const {
183 HdPolygonMode GetPolygonMode()
const {
187 uint32_t GetVertexCountFallback()
const {
188 return _vertexCountFallback;
191 const TfToken GetDepthQualifier()
const {
192 return _depthQualifier;
195 bool GetUseHardwareClipPlanes()
const {
196 return _useHardwareClipPlanes;
200 bool IsPrimTypePoints()
const {
201 return IsPrimTypePoints(_primType);
204 bool IsPrimTypeBasisCurves()
const {
205 return IsPrimTypeBasisCurves(_primType);
208 bool IsPrimTypeMesh()
const {
209 return IsPrimTypeMesh(_primType);
212 bool IsPrimTypeTriangles()
const {
213 return IsPrimTypeTriangles(_primType);
216 bool IsPrimTypeQuads()
const {
217 return IsPrimTypeQuads(_primType);
220 bool IsPrimTypeTriQuads()
const {
221 return IsPrimTypeTriQuads(_primType);
224 bool IsPrimTypeRefinedMesh()
const {
225 return IsPrimTypeRefinedMesh(_primType);
228 bool IsPrimTypePatches()
const {
229 return IsPrimTypePatches(_primType);
232 bool IsPrimTypeCompute()
const {
233 return IsPrimTypeCompute(_primType);
236 FvarPatchType GetFvarPatchType()
const {
237 return _fvarPatchType;
243 int GetPrimitiveIndexSize()
const;
248 int GetNumPatchEvalVerts()
const;
253 int GetNumPrimitiveVertsForGeometryShader()
const;
257 HgiPrimitiveType GetHgiPrimitiveType()
const;
261 HgiCullMode ResolveCullMode(HdCullStyle
const renderStateCullStyle)
const;
265 static HdSt_GeometricShaderSharedPtr Create(
266 HdSt_ShaderKey
const &shaderKey,
267 HdStResourceRegistrySharedPtr
const &resourceRegistry);
270 PrimitiveType _primType;
271 HdCullStyle _cullStyle;
272 bool _useHardwareFaceCulling;
273 bool _hasMirroredTransform;
275 bool _useMetalTessellation;
276 HdPolygonMode _polygonMode;
278 uint32_t _vertexCountFallback;
280 bool _useHardwareClipPlanes;
282 std::unique_ptr<HioGlslfx> _glslfx;
283 bool _frustumCullingPass;
284 FvarPatchType _fvarPatchType;
288 HdSt_GeometricShader(
const HdSt_GeometricShader &) =
delete;
289 HdSt_GeometricShader &operator =(
const HdSt_GeometricShader &) =
delete;
291 HioGlslfx const * _GetGlslfx()
const override;
295PXR_NAMESPACE_CLOSE_SCOPE
A base class representing the implementation (code) of a shader, used in conjunction with HdRenderPas...
virtual void BindResources(int program, HdSt_ResourceBinder const &binder)=0
Binds shader-specific resources to program XXX: this interface is meant to be used for bridging the G...
virtual void AddBindings(HdStBindingRequestVector *customBindings)=0
Add custom bindings (used by codegen)
virtual std::string GetSource(TfToken const &shaderStageKey) const =0
Returns the shader source provided by this shader for shaderStageKey.
virtual void UnbindResources(int program, HdSt_ResourceBinder const &binder)=0
Unbinds shader-specific resources.
virtual ID ComputeHash() const =0
Returns the hash value of the shader code and configuration.
A class representing the config and shader source of a glslfx file.
A path value used to locate objects in layers or scenegraphs.
Token for efficient comparison, assignment, and hashing of known strings.