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,
143 float lineWidth = 0);
146 ~HdSt_GeometricShader()
override;
155 HdSt_ResourceBinder
const &binder)
override;
159 HdSt_ResourceBinder
const &binder)
override;
161 void AddBindings(HdStBindingRequestVector *customBindings)
override;
164 bool IsFrustumCullingPass()
const {
165 return _frustumCullingPass;
168 PrimitiveType GetPrimitiveType()
const {
172 bool GetUseMetalTessellation()
const {
173 return _useMetalTessellation;
176 float GetLineWidth()
const {
180 HdPolygonMode GetPolygonMode()
const {
185 bool IsPrimTypePoints()
const {
186 return IsPrimTypePoints(_primType);
189 bool IsPrimTypeBasisCurves()
const {
190 return IsPrimTypeBasisCurves(_primType);
193 bool IsPrimTypeMesh()
const {
194 return IsPrimTypeMesh(_primType);
197 bool IsPrimTypeTriangles()
const {
198 return IsPrimTypeTriangles(_primType);
201 bool IsPrimTypeQuads()
const {
202 return IsPrimTypeQuads(_primType);
205 bool IsPrimTypeTriQuads()
const {
206 return IsPrimTypeTriQuads(_primType);
209 bool IsPrimTypeRefinedMesh()
const {
210 return IsPrimTypeRefinedMesh(_primType);
213 bool IsPrimTypePatches()
const {
214 return IsPrimTypePatches(_primType);
217 bool IsPrimTypeCompute()
const {
218 return IsPrimTypeCompute(_primType);
221 FvarPatchType GetFvarPatchType()
const {
222 return _fvarPatchType;
228 int GetPrimitiveIndexSize()
const;
233 int GetNumPatchEvalVerts()
const;
238 int GetNumPrimitiveVertsForGeometryShader()
const;
242 HgiPrimitiveType GetHgiPrimitiveType()
const;
246 HgiCullMode ResolveCullMode(HdCullStyle
const renderStateCullStyle)
const;
250 static HdSt_GeometricShaderSharedPtr Create(
251 HdSt_ShaderKey
const &shaderKey,
252 HdStResourceRegistrySharedPtr
const &resourceRegistry);
255 PrimitiveType _primType;
256 HdCullStyle _cullStyle;
257 bool _useHardwareFaceCulling;
258 bool _hasMirroredTransform;
260 bool _useMetalTessellation;
261 HdPolygonMode _polygonMode;
264 std::unique_ptr<HioGlslfx> _glslfx;
265 bool _frustumCullingPass;
266 FvarPatchType _fvarPatchType;
270 HdSt_GeometricShader(
const HdSt_GeometricShader &) =
delete;
271 HdSt_GeometricShader &operator =(
const HdSt_GeometricShader &) =
delete;
273 HioGlslfx const * _GetGlslfx()
const override;
277PXR_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.