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/hdSt/shaderCode.h"
30#include "pxr/imaging/hd/version.h"
31#include "pxr/imaging/hd/enums.h"
32#include "pxr/imaging/hgi/enums.h"
33#include "pxr/usd/sdf/path.h"
37PXR_NAMESPACE_OPEN_SCOPE
39using HdSt_GeometricShaderSharedPtr =
40 std::shared_ptr<class HdSt_GeometricShader>;
41using HdStResourceRegistrySharedPtr =
42 std::shared_ptr<class HdStResourceRegistry>;
63 enum class PrimitiveType {
65 PRIM_BASIS_CURVES_LINES,
66 PRIM_BASIS_CURVES_LINEAR_PATCHES,
67 PRIM_BASIS_CURVES_CUBIC_PATCHES,
68 PRIM_MESH_COARSE_TRIANGLES,
69 PRIM_MESH_REFINED_TRIANGLES,
70 PRIM_MESH_COARSE_QUADS,
71 PRIM_MESH_REFINED_QUADS,
72 PRIM_MESH_COARSE_TRIQUADS,
73 PRIM_MESH_REFINED_TRIQUADS,
75 PRIM_MESH_BOXSPLINETRIANGLE,
81 static inline bool IsPrimTypePoints (PrimitiveType primType) {
82 return primType == PrimitiveType::PRIM_POINTS;
85 static inline bool IsPrimTypeBasisCurves(PrimitiveType primType) {
86 return (primType == PrimitiveType::PRIM_BASIS_CURVES_LINES ||
87 primType == PrimitiveType::PRIM_BASIS_CURVES_CUBIC_PATCHES ||
88 primType == PrimitiveType::PRIM_BASIS_CURVES_LINEAR_PATCHES);
91 static inline bool IsPrimTypeMesh(PrimitiveType primType) {
92 return (primType == PrimitiveType::PRIM_MESH_COARSE_TRIANGLES ||
93 primType == PrimitiveType::PRIM_MESH_REFINED_TRIANGLES ||
94 primType == PrimitiveType::PRIM_MESH_COARSE_QUADS ||
95 primType == PrimitiveType::PRIM_MESH_REFINED_QUADS ||
96 primType == PrimitiveType::PRIM_MESH_COARSE_TRIQUADS ||
97 primType == PrimitiveType::PRIM_MESH_REFINED_TRIQUADS ||
98 primType == PrimitiveType::PRIM_MESH_BSPLINE ||
99 primType == PrimitiveType::PRIM_MESH_BOXSPLINETRIANGLE);
102 static inline bool IsPrimTypeTriangles(PrimitiveType primType) {
103 return (primType == PrimitiveType::PRIM_MESH_COARSE_TRIANGLES ||
104 primType == PrimitiveType::PRIM_MESH_REFINED_TRIANGLES ||
105 primType == PrimitiveType::PRIM_VOLUME);
108 static inline bool IsPrimTypeQuads(PrimitiveType primType) {
109 return (primType == PrimitiveType::PRIM_MESH_COARSE_QUADS ||
110 primType == PrimitiveType::PRIM_MESH_REFINED_QUADS);
113 static inline bool IsPrimTypeTriQuads(PrimitiveType primType) {
114 return (primType == PrimitiveType::PRIM_MESH_COARSE_TRIQUADS ||
115 primType == PrimitiveType::PRIM_MESH_REFINED_TRIQUADS);
118 static inline bool IsPrimTypeRefinedMesh(PrimitiveType primType) {
119 return (primType == PrimitiveType::PRIM_MESH_REFINED_TRIANGLES ||
120 primType == PrimitiveType::PRIM_MESH_REFINED_QUADS ||
121 primType == PrimitiveType::PRIM_MESH_REFINED_TRIQUADS ||
122 primType == PrimitiveType::PRIM_MESH_BSPLINE ||
123 primType == PrimitiveType::PRIM_MESH_BOXSPLINETRIANGLE);
126 static inline bool IsPrimTypePatches(PrimitiveType primType) {
127 return primType == PrimitiveType::PRIM_MESH_BSPLINE ||
128 primType == PrimitiveType::PRIM_MESH_BOXSPLINETRIANGLE ||
129 primType == PrimitiveType::PRIM_BASIS_CURVES_CUBIC_PATCHES ||
130 primType == PrimitiveType::PRIM_BASIS_CURVES_LINEAR_PATCHES;
133 static inline bool IsPrimTypeCompute(PrimitiveType primType) {
134 return primType == PrimitiveType::PRIM_COMPUTE;
138 enum class FvarPatchType {
139 PATCH_COARSE_TRIANGLES,
140 PATCH_REFINED_TRIANGLES,
144 PATCH_BOXSPLINETRIANGLE,
149 HdSt_GeometricShader(std::string
const &glslfxString,
150 PrimitiveType primType,
151 HdCullStyle cullStyle,
152 bool useHardwareFaceCulling,
153 bool hasMirroredTransform,
155 bool useMetalTessellation,
156 HdPolygonMode polygonMode,
158 FvarPatchType fvarPatchType,
160 float lineWidth = 0);
163 ~HdSt_GeometricShader()
override;
172 HdSt_ResourceBinder
const &binder)
override;
176 HdSt_ResourceBinder
const &binder)
override;
178 void AddBindings(HdStBindingRequestVector *customBindings)
override;
181 bool IsFrustumCullingPass()
const {
182 return _frustumCullingPass;
185 PrimitiveType GetPrimitiveType()
const {
189 bool GetUseMetalTessellation()
const {
190 return _useMetalTessellation;
193 float GetLineWidth()
const {
197 HdPolygonMode GetPolygonMode()
const {
202 bool IsPrimTypePoints()
const {
203 return IsPrimTypePoints(_primType);
206 bool IsPrimTypeBasisCurves()
const {
207 return IsPrimTypeBasisCurves(_primType);
210 bool IsPrimTypeMesh()
const {
211 return IsPrimTypeMesh(_primType);
214 bool IsPrimTypeTriangles()
const {
215 return IsPrimTypeTriangles(_primType);
218 bool IsPrimTypeQuads()
const {
219 return IsPrimTypeQuads(_primType);
222 bool IsPrimTypeTriQuads()
const {
223 return IsPrimTypeTriQuads(_primType);
226 bool IsPrimTypeRefinedMesh()
const {
227 return IsPrimTypeRefinedMesh(_primType);
230 bool IsPrimTypePatches()
const {
231 return IsPrimTypePatches(_primType);
234 bool IsPrimTypeCompute()
const {
235 return IsPrimTypeCompute(_primType);
238 FvarPatchType GetFvarPatchType()
const {
239 return _fvarPatchType;
245 int GetPrimitiveIndexSize()
const;
250 int GetNumPatchEvalVerts()
const;
255 int GetNumPrimitiveVertsForGeometryShader()
const;
259 HgiPrimitiveType GetHgiPrimitiveType()
const;
263 HgiCullMode ResolveCullMode(HdCullStyle
const renderStateCullStyle)
const;
266 static HdSt_GeometricShaderSharedPtr Create(
267 HdSt_ShaderKey
const &shaderKey,
268 HdStResourceRegistrySharedPtr
const &resourceRegistry);
271 PrimitiveType _primType;
272 HdCullStyle _cullStyle;
273 bool _useHardwareFaceCulling;
274 bool _hasMirroredTransform;
276 bool _useMetalTessellation;
277 HdPolygonMode _polygonMode;
280 std::unique_ptr<HioGlslfx> _glslfx;
281 bool _frustumCullingPass;
282 FvarPatchType _fvarPatchType;
286 HdSt_GeometricShader(
const HdSt_GeometricShader &) =
delete;
287 HdSt_GeometricShader &operator =(
const HdSt_GeometricShader &) =
delete;
289 HioGlslfx const * _GetGlslfx()
const override;
293PXR_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.