HatchitResource
ht_rootlayout_resource.h
1 
15 #pragma once
16 
17 #include <ht_resource.h>
18 #include <ht_bitfield.h>
19 #include <ht_sampler_resource.h>
20 #include <ht_shadervariable.h>
21 
22 namespace Hatchit
23 {
24  namespace Resource
25  {
26  class HT_API RootLayout final : public FileResource<RootLayout>
27  {
28  public:
29 
30  enum class ShaderVisibility
31  {
32  UNKNOWN,
33  ALL,
34  VERTEX,
35  TESS_CONTROL,
36  TESS_EVAL,
37  GEOMETRY,
38  FRAGMENT
39  };
40  enum Flags
41  {
42  LAYOUT_FLAG_NONE = 0,
43  LAYOUT_ALLOW_INPUT_ASSEMLBER_INPUT_LAYOUT = 1 << 1,
44  LAYOUT_DENY_VERTEX_SHADER_ROOT_ACCESS = 1 << 2,
45  LAYOUT_DENY_TESS_CONTROL_SHADER_ROOT_ACCESS = 1 << 3,
46  LAYOUT_DENY_TESS_EVAL_SHADER_ROOT_ACCESS = 1 << 4,
47  LAYOUT_DENY_GEOMETRY_SHADER_ROOT_ACCESS = 1 << 5,
48  LAYOUT_DENY_FRAGMENT_SHADER_ROOT_ACCESS = 1 << 6,
49  LAYOUT_ALLOW_STREAM_OUTPUT = 1 << 7
50  };
51 
52  struct Range
53  {
54  enum class Type
55  {
56  UNKNOWN,
57  CONSTANT_BUFFER,
58  SHADER_RESOURCE,
59  UNORDERED_ACCESS,
60  SAMPLER
61  };
62 
63  Type type;
64  uint32_t numDescriptors;
65  uint32_t baseRegister;
66  uint32_t registerSpace;
67  };
68 
70  {
71  uint32_t rangeCount;
72  std::vector<Range> ranges;
73  };
74 
75  struct Constant
76  {
77  uint32_t shaderRegister;
78  uint32_t registerSpace;
79  uint32_t valueCount;
80  ShaderVariable::Type type;
81  };
82 
83  struct Descriptor
84  {
85  uint32_t shaderRegister;
86  uint32_t registerSpace;
87  };
88 
89  struct Parameter
90  {
91  struct Data
92  {
93  DescriptorTable table;
94  Constant constant;
95  Descriptor descriptor;
96  };
97 
98  enum class Type
99  {
100  UNKNOWN,
101  TABLE,
102  CONSTANTS,
103  CONSTANT_BUFFER,
104  SHADER_RESOURCE,
105  UNORDERED_ACCESS
106  };
107 
108  Type type;
109  ShaderVisibility visibility;
110  Data data;
111  };
112 
113  RootLayout(Core::Guid ID);
114 
115  bool Initialize(const std::string& fileName);
116 
117  virtual ~RootLayout() = default;
118 
119 
120  uint32_t GetParameterCount() const;
121  Core::BitField<Flags> GetDescriptorFlags() const;
122  const std::vector<Parameter>& GetParameters() const;
123  const std::vector<Sampler>& GetSamplers() const;
124 
125  private:
126  uint32_t m_parameterCount;
127  std::vector<Parameter> m_parameters;
128  std::vector<Sampler> m_samplers;
129  Core::BitField<Flags> m_flags;
130 
131 
132  Flags FlagFromString(std::string s);
133  ShaderVisibility ParameterVisibilityFromString(std::string s);
134  Parameter::Type ParameterTypeFromString(std::string s);
135  Range::Type RangeTypeFromString(std::string s);
136  };
137 
138  using RootLayoutHandle = Core::Handle<const RootLayout>;
139  }
140 }
Definition: ht_rootlayout_resource.h:52
Definition: ht_rootlayout_resource.h:26
Definition: ht_resource.h:35
Hatchit Engine Copyright(c) 2015-2016 Third-Degree.
Definition: ht_assimp.h:31
Definition: ht_rootlayout_resource.h:83
Definition: ht_rootlayout_resource.h:75
Definition: ht_rootlayout_resource.h:91
Definition: ht_rootlayout_resource.h:69
Definition: ht_rootlayout_resource.h:89