1 //
2 //   Copyright 2015 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 OPENSUBDIV_EXAMPLES_D3D11_SHADER_CACHE_H
26 #define OPENSUBDIV_EXAMPLES_D3D11_SHADER_CACHE_H
27 
28 #include <string>
29 #include "./shaderCache.h"
30 
31 struct ID3D11VertexShader;
32 struct ID3D11HullShader;
33 struct ID3D11DomainShader;
34 struct ID3D11GeometryShader;
35 struct ID3D11PixelShader;
36 struct ID3D11Device;
37 struct ID3D11InputLayout;
38 struct D3D11_INPUT_ELEMENT_DESC;
39 
40 class D3D11DrawConfig {
41 public:
42     D3D11DrawConfig();
43     ~D3D11DrawConfig();
44 
45     bool CompileVertexShader(const std::string &target,
46                              const std::string &entry,
47                              const std::string &source,
48                              ID3D11InputLayout ** ppInputLayout,
49                              D3D11_INPUT_ELEMENT_DESC const *pInputElementDescs,
50                              int numInputElements,
51                              ID3D11Device * pd3dDevice);
52     bool CompileHullShader(const std::string &target,
53                            const std::string &entry,
54                            const std::string &source,
55                            ID3D11Device * pd3dDevice);
56     bool CompileDomainShader(const std::string &target,
57                              const std::string &entry,
58                              const std::string &source,
59                              ID3D11Device * pd3dDevice);
60     bool CompileGeometryShader(const std::string &target,
61                                const std::string &entry,
62                                const std::string &source,
63                                ID3D11Device * pd3dDevice);
64     bool CompilePixelShader(const std::string &target,
65                             const std::string &entry,
66                             const std::string &source,
67                             ID3D11Device * pd3dDevice);
68 
GetVertexShader()69     ID3D11VertexShader   *GetVertexShader() const { return _vertexShader; }
GetHullShader()70     ID3D11HullShader     *GetHullShader() const { return _hullShader; }
GetDomainShader()71     ID3D11DomainShader   *GetDomainShader() const { return _domainShader; }
GetGeometryShader()72     ID3D11GeometryShader *GetGeometryShader() const { return _geometryShader; }
GetPixelShader()73     ID3D11PixelShader    *GetPixelShader() const { return _pixelShader; }
74 
75 private:
76     ID3D11VertexShader   *_vertexShader;
77     ID3D11HullShader     *_hullShader;
78     ID3D11DomainShader   *_domainShader;
79     ID3D11GeometryShader *_geometryShader;
80     ID3D11PixelShader    *_pixelShader;
81 };
82 
83 // workaround for template alias
84 #if 0
85 template <typename DESC_TYPE>
86 using D3D11ShaderCache = ShaderCacheT<DESC_TYPE, D3D11DrawConfig>;
87 #else
88 template <typename DESC_TYPE>
89 class D3D11ShaderCache : public ShaderCacheT<DESC_TYPE, D3D11DrawConfig> {
90 };
91 #endif
92 
93 #endif  // OPENSUBDIV_EXAMPLES_D3D11_SHADER_CACHE_H
94