GteHLSLBaseBuffer.cpp
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.1 (2016/09/12)
7 
8 #include <GTEnginePCH.h>
10 using namespace gte;
11 
12 
14 {
15 }
16 
18  unsigned int numBytes, std::vector<Member> const& members)
19  :
20  HLSLResource(desc, numBytes),
21  mMembers(members)
22 {
23 }
24 
26  unsigned int index, unsigned int numBytes,
27  std::vector<Member> const& members)
28  :
29  HLSLResource(desc, index, numBytes),
30  mMembers(members)
31 {
32 }
33 
34 std::vector<HLSLBaseBuffer::Member> const& HLSLBaseBuffer::GetMembers() const
35 {
36  return mMembers;
37 }
38 
39 void HLSLBaseBuffer::Print(std::ofstream& output) const
40 {
41  int i = 0;
42  for (auto const& member : mMembers)
43  {
44  output << "Variable[" << i << "]:" << std::endl;
45  member.first.Print(output);
46  output << "Type[" << i << "]:" << std::endl;
47  member.second.Print(output, 0);
48  ++i;
49  }
50 }
51 
52 void HLSLBaseBuffer::GenerateLayout(std::vector<MemberLayout>& layout) const
53 {
54  for (auto const& m : mMembers)
55  {
56  HLSLShaderType const& parent = m.second;
57  GenerateLayout(parent, m.first.GetOffset(), parent.GetName(),
58  layout);
59  }
60 }
61 
63  unsigned int parentOffset, std::string const& parentName,
64  std::vector<MemberLayout>& layout) const
65 {
66  unsigned int const numChildren = parent.GetNumChildren();
67  if (numChildren > 0)
68  {
69  for (unsigned int i = 0; i < numChildren; ++i)
70  {
71  HLSLShaderType const& child = parent.GetChild(i);
72  GenerateLayout(child, parentOffset + child.GetOffset(),
73  parentName + "." + child.GetName(), layout);
74  }
75  }
76  else
77  {
78  MemberLayout item;
79  item.name = parentName;
80  item.offset = parentOffset;
81  item.numElements = parent.GetNumElements();
82  layout.push_back(item);
83  }
84 }
85 
unsigned int offset
virtual void Print(std::ofstream &output) const
const GLfloat * m
Definition: glext.h:6461
std::vector< Member > mMembers
HLSLShaderType & GetChild(unsigned int i)
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
unsigned int numElements
#define D3D_SHADER_INPUT_BIND_DESC
std::string const & GetName() const
unsigned int GetOffset() const
unsigned int GetNumElements() const
GLuint index
Definition: glcorearb.h:781
std::vector< Member > const & GetMembers() const
unsigned int GetNumChildren() const
HLSLBaseBuffer(D3D_SHADER_INPUT_BIND_DESC const &desc, unsigned int numBytes, std::vector< Member > const &members)
void GenerateLayout(std::vector< MemberLayout > &layout) const


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00