1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __D3D11GpuProgram_H_
29 #define __D3D11GpuProgram_H_
30 
31 // Precompiler options
32 #include "OgreD3D11Prerequisites.h"
33 #include "OgreGpuProgram.h"
34 
35 namespace Ogre {
36 
37 	/** Direct3D implementation of a few things common to low-level vertex & fragment programs. */
38 	class D3D11GpuProgram : public GpuProgram
39 	{
40 	protected:
41 		D3D11Device & mDevice;
42 	public:
43 		D3D11GpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
44 			const String& group, bool isManual, ManualResourceLoader* loader, D3D11Device & device);
45 
46 	protected:
47 		/** @copydoc Resource::loadImpl */
48 		void loadImpl(void);
49 		/** Overridden from GpuProgram */
50 		void loadFromSource(void);
51 		/** Internal method to load from microcode, must be overridden by subclasses. */
52 		virtual void loadFromMicrocode(ID3D10Blob *  microcode) = 0;
53 
54 
55 	};
56 
57 	/** Direct3D implementation of low-level vertex programs. */
58 	class D3D11GpuVertexProgram : public D3D11GpuProgram
59 	{
60 	protected:
61 		ID3D11VertexShader * mVertexShader;
62 	public:
63 		D3D11GpuVertexProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
64 			const String& group, bool isManual, ManualResourceLoader* loader, D3D11Device & device);
65 		~D3D11GpuVertexProgram();
66 		/// Gets the vertex shader
67 		ID3D11VertexShader * getVertexShader(void) const;
68 	protected:
69 		/** @copydoc Resource::unloadImpl */
70 		void unloadImpl(void);
71 		void loadFromMicrocode(ID3D10Blob *  microcode);
72 	};
73 
74 	/** Direct3D implementation of low-level fragment programs. */
75 	class D3D11GpuFragmentProgram : public D3D11GpuProgram
76 	{
77 	protected:
78 		ID3D11PixelShader * mPixelShader;
79 	public:
80 		D3D11GpuFragmentProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
81 			const String& group, bool isManual, ManualResourceLoader* loader, D3D11Device & device);
82 		~D3D11GpuFragmentProgram();
83 		/// Gets the pixel shader
84 		ID3D11PixelShader * getPixelShader(void) const;
85 	protected:
86 		/** @copydoc Resource::unloadImpl */
87 		void unloadImpl(void);
88 		void loadFromMicrocode(ID3D10Blob *  microcode);
89 	};
90 
91 	/** Direct3D implementation of low-level vertex programs. */
92 	class D3D11GpuDomainProgram : public D3D11GpuProgram
93 	{
94 	protected:
95 		ID3D11DomainShader * mDomainShader;
96 	public:
97 		D3D11GpuDomainProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
98 			const String& group, bool isManual, ManualResourceLoader* loader, D3D11Device & device);
99 		~D3D11GpuDomainProgram();
100 		/// Gets the vertex shader
101 		ID3D11DomainShader * getDomainShader(void) const;
102 	protected:
103 		/** @copydoc Resource::unloadImpl */
104 		void unloadImpl(void);
105 		void loadFromMicrocode(ID3D10Blob *  microcode);
106 	};
107 
108 	/** Direct3D implementation of low-level vertex programs. */
109 	class D3D11GpuHullProgram : public D3D11GpuProgram
110 	{
111 	protected:
112 		ID3D11HullShader * mHullShader;
113 	public:
114 		D3D11GpuHullProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
115 			const String& group, bool isManual, ManualResourceLoader* loader, D3D11Device & device);
116 		~D3D11GpuHullProgram();
117 		/// Gets the vertex shader
118 		ID3D11HullShader * getHullShader() const;
119 	protected:
120 		/** @copydoc Resource::unloadImpl */
121 		void unloadImpl(void);
122 		void loadFromMicrocode(ID3D10Blob *  microcode);
123 	};
124 
125 
126 	/**
127 		Direct3D implementation of low-level geometry programs.
128 		Added due to need to accept geometry programs came from other profiles (nvgp4, for example)
129 	*/
130 	class D3D11GpuGeometryProgram : public D3D11GpuProgram
131 	{
132 	protected:
133 		ID3D11GeometryShader * mGeometryShader;
134 	public:
135 		D3D11GpuGeometryProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
136 			const String& group, bool isManual, ManualResourceLoader* loader, D3D11Device & device);
137 		~D3D11GpuGeometryProgram();
138 		/// Gets the geometry shader
139 		ID3D11GeometryShader * getGeometryShader(void) const;
140 	protected:
141 		/** @copydoc Resource::unloadImpl */
142 		void unloadImpl(void);
143 		void loadFromMicrocode(ID3D10Blob *  microcode);
144 	};
145 }
146 
147 
148 #endif
149