All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shaderKey.h
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_IMAGING_HD_ST_SHADER_KEY_H
25 #define PXR_IMAGING_HD_ST_SHADER_KEY_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdSt/api.h"
29 #include "pxr/imaging/hdSt/geometricShader.h" // XXX: for PrimitiveType
30 #include "pxr/imaging/hd/version.h"
31 #include "pxr/imaging/hd/enums.h"
32 #include "pxr/base/tf/token.h"
33 
34 PXR_NAMESPACE_OPEN_SCOPE
35 
36 
37 // Abstract interface for geometric shader keys that may be used to
38 // construct a geometric shader.
39 struct HdSt_ShaderKey {
40  typedef size_t ID;
41 
42  HDST_API
43  virtual ~HdSt_ShaderKey();
44 
45  // The hash computed identifies each geometric shader instance, and is used
46  // for deduplication in the resource registry.
47  HDST_API
48  ID ComputeHash() const;
49 
50  // Stitches the glslfx filename and the shader stage mixin names into
51  // a string for consumption by HioGlslfx.
52  HDST_API
53  std::string GetGlslfxString() const;
54 
55  // -------------------------------------------------------------------------
56  // Virtual interface
57  // -------------------------------------------------------------------------
58 
59  // Return the name of the glslfx file that houses the entry point mixins
60  // that define the main() function for the relevant shader stages.
61  // The expectation is that this file includes the glslfx files that
62  // define any functions it uses.
63  virtual TfToken const &GetGlslfxFilename() const = 0;
64 
65  // Each shader stage specifies the various mixins to stitch together
66  // via their token names. The Get* flavor of methods return the first
67  // token in the array.
68  HDST_API
69  virtual TfToken const *GetVS() const;
70  HDST_API
71  virtual TfToken const *GetTCS() const;
72  HDST_API
73  virtual TfToken const *GetTES() const;
74  HDST_API
75  virtual TfToken const *GetGS() const;
76  HDST_API
77  virtual TfToken const *GetFS() const;
78 
79  // An implementation detail of code gen, which generates slightly
80  // different code for the VS stage for the frustum culling pass.
81  HDST_API
82  virtual bool IsFrustumCullingPass() const;
83 
84  // Returns the geometric shader primitive type that is used in code gen
85  // and to figure out the primitive mode during draw submission.
86  virtual HdSt_GeometricShader::PrimitiveType GetPrimitiveType() const = 0;
87 
88  // Implementation details of the geometric shader that sets hardware
89  // pipeline state (polygon mode, line width) or queues upload of data
90  // (cullstyle) to the GPU.
91  HDST_API
92  virtual HdCullStyle GetCullStyle() const;
93  HDST_API
94  virtual HdPolygonMode GetPolygonMode() const;
95  HDST_API
96  virtual float GetLineWidth() const;
97 };
98 
99 
100 PXR_NAMESPACE_CLOSE_SCOPE
101 
102 #endif // PXR_IMAGING_HD_ST_SHADER_KEY_H
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87