All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
d3d11DrawContext.h
Go to the documentation of this file.
1 //
2 // Copyright 2013 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 
25 #ifndef OSD_D3D11L_DRAW_CONTEXT_H
26 #define OSD_D3D11L_DRAW_CONTEXT_H
27 
28 #include "../version.h"
29 
30 #include "../far/patchTables.h"
31 #include "../osd/drawContext.h"
32 #include "../osd/vertex.h"
33 
34 #include <map>
35 
36 struct ID3D11VertexShader;
37 struct ID3D11HullShader;
38 struct ID3D11DomainShader;
39 struct ID3D11GeometryShader;
40 struct ID3D11PixelShader;
41 
42 struct ID3D11Buffer;
43 struct ID3D11ShaderResourceView;
44 struct ID3D11Device;
45 struct ID3D11DeviceContext;
46 
47 namespace OpenSubdiv {
48 namespace OPENSUBDIV_VERSION {
49 
50 namespace Osd {
51 
63 class D3D11DrawContext : public DrawContext {
64 public:
65  typedef ID3D11Buffer * VertexBufferBinding;
66 
67  virtual ~D3D11DrawContext();
68 
77  static D3D11DrawContext *Create(Far::PatchTables const *patchTables,
78  ID3D11DeviceContext *pd3d11DeviceContext,
79  int numVertexElements);
80 
87  template<class VERTEX_BUFFER>
88  void UpdateVertexTexture(VERTEX_BUFFER *vbo, ID3D11DeviceContext *pd3d11DeviceContext) {
89  if (vbo)
90  updateVertexTexture(vbo->BindD3D11Buffer(pd3d11DeviceContext),
91  pd3d11DeviceContext,
92  vbo->GetNumVertices(),
93  vbo->GetNumElements());
94  }
95 
96  ID3D11Buffer *patchIndexBuffer;
97 
98  ID3D11Buffer *ptexCoordinateBuffer;
99  ID3D11ShaderResourceView *ptexCoordinateBufferSRV;
100 
101  ID3D11Buffer *fvarDataBuffer;
102  ID3D11ShaderResourceView *fvarDataBufferSRV;
103 
104  ID3D11ShaderResourceView *vertexBufferSRV;
105  ID3D11Buffer *vertexValenceBuffer;
106  ID3D11ShaderResourceView *vertexValenceBufferSRV;
107  ID3D11Buffer *quadOffsetBuffer;
108  ID3D11ShaderResourceView *quadOffsetBufferSRV;
109 
122  bool SetFVarDataTexture(Far::PatchTables const & patchTables,
123  ID3D11DeviceContext *pd3d11DeviceContext,
124  int fvarWidth, FVarData const & fvarData);
125 
126 private:
128 
129 
130  // allocate buffers from patchTables
131  bool create(Far::PatchTables const &patchTables,
132  ID3D11DeviceContext *pd3d11DeviceContext,
133  int numVertexElements);
134 
135  void updateVertexTexture(ID3D11Buffer *vbo,
136  ID3D11DeviceContext *pd3d11DeviceContext,
137  int numVertices,
138  int numVertexElements);
139 
140  int _numVertices;
141 };
142 
143 } // end namespace Osd
144 
145 } // end namespace OPENSUBDIV_VERSION
146 using namespace OPENSUBDIV_VERSION;
147 
148 } // end namespace OpenSubdiv
149 
150 #endif /* OSD_D3D11L_DRAW_CONTEXT_H */
151 
bool SetFVarDataTexture(Far::PatchTables const &patchTables, ID3D11DeviceContext *pd3d11DeviceContext, int fvarWidth, FVarData const &fvarData)
Container for patch vertex indices tables.
Definition: patchTables.h:49
static D3D11DrawContext * Create(Far::PatchTables const *patchTables, ID3D11DeviceContext *pd3d11DeviceContext, int numVertexElements)
Create an D3D11DrawContext from Far::PatchTables.
void UpdateVertexTexture(VERTEX_BUFFER *vbo, ID3D11DeviceContext *pd3d11DeviceContext)