HatchitResource
ht_pipeline_resource.h
1 
26 #pragma once
27 
28 #include <ht_debug.h>
29 #include <ht_platform.h>
30 #include <ht_resource.h>
31 #include <ht_jsonhelper.h>
32 #include <ht_shadervariable.h>
33 #include <ht_math.h>
34 #include <ht_shader_resource.h>
35 
36 #include <fstream>
37 
38 namespace Hatchit {
39 
40  namespace Resource {
41 
42  class HT_API Pipeline : public FileResource<Pipeline>
43  {
44  public:
45  struct Attribute
46  {
47  std::string semanticName;
48  uint32_t semanticIndex;
49  ShaderVariable::Type type;
50  uint32_t slot;
51  };
52 
53  enum PolygonMode
54  {
55  SOLID,
56  LINE
57  };
58 
59  enum CullMode
60  {
61  NONE,
62  FRONT,
63  BACK
64  };
65 
67  {
68  bool testDepth; //True to run depth test, false to ignore depth test
69  bool writeDepth; //True to write depth buffer, false to ignore writing depth buffer
70  };
71 
72  //Describes options for the render state
73  //Some options are not available such as front face winding order
75  {
76  PolygonMode polygonMode; //How we want to render objects
77  CullMode cullMode; //How we want to cull faces
78  bool frontCounterClockwise; //Determines if a triangle is front- or back-facing.
79  bool depthClampEnable; //True to use depth clamping, false to clip primitives
80  bool discardEnable; //True to discard primitives before rasterization
81  float lineWidth; //How wide to render when using Line polygon mode
82  };
83 
84  enum SampleCount
85  {
86  SAMPLE_1_BIT,
87  SAMPLE_2_BIT,
88  SAMPLE_4_BIT,
89  SAMPLE_8_BIT,
90  SAMPLE_16_BIT,
91  SAMPLE_32_BIT,
92  SAMPLE_64_BIT
93  };
94 
95  //Describes the multisampling state of the pipeline
97  {
98  SampleCount samples; //How many bits per sample
99  float minSamples; //Min samples per fragment
100  bool perSampleShading; //Shades per sample if true, per fragment if false
101  };
102 
103  enum ShaderSlot
104  {
105  VERTEX = 0,
106  FRAGMENT,
107  GEOMETRY,
108  TESS_CONTROL,
109  TESS_EVAL,
110  COMPUTE,
111  };
112  static const int MAX_SHADERS = 6;
113 
114  Pipeline(Core::Guid ID);
115  virtual ~Pipeline() {};
116 
117  //Required function for all RefCounted classes
118  bool Initialize(const std::string& fileName);
119 
120  const std::string& GetRenderPassPath() const;
121 
122  const DepthStencilState& GetDepthStencilState() const;
123  const RasterizerState& GetRasterizationState() const;
124  const MultisampleState& GetMultisampleState() const;
125  const std::vector<Attribute>& GetVertexLayout() const;
126  const std::vector<Attribute>& GetInstanceLayout() const;
127 
128  const std::vector<ShaderVariable*>& GetShaderVariables() const;
129 
130  const std::map<ShaderSlot, std::string>& GetSPVShaderPaths() const;
131  const std::map<ShaderSlot, std::string>& GetCSOShaderPaths() const;
132 
133  const std::map<ShaderSlot, ShaderHandle>& GetSPVShaderHandles() const;
134  const std::map<ShaderSlot, ShaderHandle>& GetCSOShaderHandles() const;
135 
136  private:
137  std::string m_renderPassPath;
138 
139  DepthStencilState m_depthStencilState;
140  RasterizerState m_rasterizationState;
141  MultisampleState m_multisampleState;
142  std::vector<Attribute> m_vertexLayout;
143  std::vector<Attribute> m_instanceLayout;
144 
145  std::vector<ShaderVariable*> m_shaderVariables;
146 
147  std::map<ShaderSlot, std::string> m_spvShaderPaths;
148  std::map<ShaderSlot, std::string> m_csoShaderPaths;
149 
150  std::map<ShaderSlot, ShaderHandle> m_spvShaderHandles;
151  std::map<ShaderSlot, ShaderHandle> m_csoShaderHandles;
152  };
153 
154  using PipelineHandle = Core::Handle<const Pipeline>;
155  }
156 
157 }
Definition: ht_pipeline_resource.h:42
Definition: ht_resource.h:35
Hatchit Engine Copyright(c) 2015-2016 Third-Degree.
Definition: ht_assimp.h:31
Definition: ht_pipeline_resource.h:96
Definition: ht_pipeline_resource.h:66
Definition: ht_pipeline_resource.h:74
Definition: ht_pipeline_resource.h:45