GteDX11InputLayoutManager.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.0 (2016/06/19)
7 
8 #include <GTEnginePCH.h>
10 using namespace gte;
11 
13 {
14  if (mMap.HasElements())
15  {
16  LogWarning("Input layout map is not empty on destruction.");
17  UnbindAll();
18  }
19 }
20 
22 {
23 }
24 
26  VertexBuffer const* vbuffer, Shader const* vshader)
27 {
28  std::shared_ptr<DX11InputLayout> layout;
29  if (vshader)
30  {
31  if (vbuffer)
32  {
33  if (!mMap.Get(std::make_pair(vbuffer, vshader), layout))
34  {
35  layout = std::make_shared<DX11InputLayout>(device, vbuffer, vshader);
36  mMap.Insert(std::make_pair(vbuffer, vshader), layout);
37 
38 #if defined(GTE_GRAPHICS_USE_NAMED_OBJECTS)
39  std::string vbname = vbuffer->GetName();
40  std::string vsname = vshader->GetName();
41  if (vbname != "" || vsname != "")
42  {
43  layout->SetName(vbname + " | " + vsname);
44  }
45 #endif
46  }
47  }
48  // else: A null vertex buffer is passed when an effect wants to
49  // bypass the input assembler.
50  }
51  else
52  {
53  LogError("Vertex shader must be nonnull.");
54  }
55  return layout.get();
56 }
57 
59 {
60  if (vbuffer)
61  {
62  std::vector<VBSPair> matches;
63  mMap.GatherMatch(vbuffer, matches);
64  for (auto match : matches)
65  {
66  std::shared_ptr<DX11InputLayout> layout;
67  mMap.Remove(match, layout);
68  }
69  return true;
70  }
71  else
72  {
73  LogError("Vertex buffer must be nonnull.");
74  return false;
75  }
76 }
77 
79 {
80  if (vshader)
81  {
82  std::vector<VBSPair> matches;
83  mMap.GatherMatch(vshader, matches);
84  for (auto match : matches)
85  {
86  std::shared_ptr<DX11InputLayout> layout;
87  mMap.Remove(match, layout);
88  }
89  return true;
90  }
91  else
92  {
93  LogError("Vertex shader must be nonnull.");
94  return false;
95  }
96 }
97 
99 {
100  mMap.RemoveAll();
101 }
102 
104 {
105  return mMap.HasElements();
106 }
107 
109 {
110 }
111 
113 {
114 }
115 
117  VertexBuffer const* vbuffer, std::vector<VBSPair>& matches)
118 {
119  mMutex.lock();
120  {
121  for (auto vbs : mMap)
122  {
123  if (vbuffer == vbs.first.first)
124  {
125  matches.push_back(vbs.first);
126  }
127  }
128  }
129  mMutex.unlock();
130 }
131 
133  std::vector<VBSPair>& matches)
134 {
135  mMutex.lock();
136  {
137  for (auto vbs : mMap)
138  {
139  if (vshader == vbs.first.second)
140  {
141  matches.push_back(vbs.first);
142  }
143  }
144  }
145  mMutex.unlock();
146 }
virtual bool Unbind(VertexBuffer const *vbuffer) override
void Insert(Key key, Value value)
bool Get(Key key, Value &value) const
bool Remove(Key key, Value &value)
DX11InputLayout * Bind(ID3D11Device *device, VertexBuffer const *vbuffer, Shader const *vshader)
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
#define LogError(message)
Definition: GteLogger.h:92
virtual bool HasElements() const override
#define LogWarning(message)
Definition: GteLogger.h:95
std::string const & GetName() const
void GatherMatch(VertexBuffer const *vbuffer, std::vector< VBSPair > &matches)
bool HasElements() const


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 03:59:59