GteHLSLShaderVariable.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>
9 #include <LowLevel/GteWrapper.h>
11 #include <iomanip>
12 using namespace gte;
13 
14 
16 {
17 }
18 
20  D3D_SHADER_VARIABLE_DESC const& desc)
21 {
22  mDesc.name = std::string(desc.Name ? desc.Name : "");
23  mDesc.offset = desc.StartOffset;
24  mDesc.numBytes = desc.Size;
25  mDesc.flags = desc.uFlags;
26  mDesc.textureStart = desc.StartTexture;
27  mDesc.textureNumSlots = desc.TextureSize;
28  mDesc.samplerStart = desc.StartSampler;
29  mDesc.samplerNumSlots = desc.SamplerSize;
30  if (desc.DefaultValue && desc.Size > 0)
31  {
32  mDesc.defaultValue.resize(desc.Size);
33  Memcpy(&mDesc.defaultValue[0], desc.DefaultValue, desc.Size);
34  }
35 }
36 
38 {
39  return mDesc.name;
40 }
41 
42 unsigned int HLSLShaderVariable::GetOffset() const
43 {
44  return mDesc.offset;
45 }
46 
47 unsigned int HLSLShaderVariable::GetNumBytes() const
48 {
49  return mDesc.numBytes;
50 }
51 
52 unsigned int HLSLShaderVariable::GetFlags() const
53 {
54  return mDesc.flags;
55 }
56 
58 {
59  return mDesc.textureStart;
60 }
61 
63 {
64  return mDesc.textureNumSlots;
65 }
66 
68 {
69  return mDesc.samplerStart;
70 }
71 
73 {
74  return mDesc.samplerNumSlots;
75 }
76 
77 std::vector<unsigned char> const& HLSLShaderVariable::GetDefaultValue() const
78 {
79  return mDesc.defaultValue;
80 }
81 
82 void HLSLShaderVariable::Print(std::ofstream& output) const
83 {
84  output << "name = " << mDesc.name << std::endl;
85  output << "offset = " << mDesc.offset << std::endl;
86  output << "numBytes = " << mDesc.numBytes << std::endl;
87  output << "flags = " << mDesc.flags << std::endl;
88 
89  if (mDesc.textureStart == 0xFFFFFFFF)
90  {
91  output << "textureStart = -1" << std::endl;
92  }
93  else
94  {
95  output << "textureStart = " << mDesc.textureStart << std::endl;
96  }
97  output << "textureNumSlots = " << mDesc.textureNumSlots << std::endl;
98 
99  if (mDesc.samplerStart == 0xFFFFFFFF)
100  {
101  output << "samplerStart = -1" << std::endl;
102  }
103  else
104  {
105  output << "samplerStart = " << mDesc.samplerStart << std::endl;
106  }
107  output << "textureNumSlots = " << mDesc.samplerNumSlots << std::endl;
108 
109  output << "default value = ";
110  size_t size = mDesc.defaultValue.size();
111  if (size > 0)
112  {
113  output << std::hex << std::endl;
114  size_t j = 0;
115  for (auto c : mDesc.defaultValue)
116  {
117  unsigned int hc = static_cast<unsigned int>(c);
118  output << "0x" << std::setw(2) << std::setfill('0') << hc;
119  if ((++j % 16) == 0)
120  {
121  if (j != size)
122  {
123  output << std::endl;
124  }
125  }
126  else
127  {
128  output << ' ';
129  }
130  }
131  output << std::dec;
132  }
133  else
134  {
135  output << "none";
136  }
137  output << std::endl;
138 }
139 
std::vector< unsigned char > const & GetDefaultValue() const
unsigned int GetTextureStart() const
unsigned int GetFlags() const
#define D3D_SHADER_VARIABLE_DESC
GLsizeiptr size
Definition: glcorearb.h:659
const GLubyte * c
Definition: glext.h:11671
unsigned int GetSamplerStart() const
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
unsigned int GetSamplerNumSlots() const
unsigned int GetNumBytes() const
void SetDescription(D3D_SHADER_VARIABLE_DESC const &desc)
std::string const & GetName() const
void Print(std::ofstream &output) const
unsigned int GetTextureNumSlots() const
void Memcpy(void *target, void const *source, size_t count)
Definition: GteWrapper.cpp:16
unsigned int GetOffset() const
std::vector< unsigned char > defaultValue


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