OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreD3D9GpuProgram.h
Go to the documentation of this file.
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-2014 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 __D3D9GpuProgram_H_
29 #define __D3D9GpuProgram_H_
30 
31 // Precompiler options
32 #include "OgreD3D9Prerequisites.h"
33 #include "OgreGpuProgram.h"
34 #include "OgreD3D9Resource.h"
35 
36 namespace Ogre {
37 
40  {
41  public:
44  {
45  public:
46  String doGet(const void* target) const;
47  void doSet(void* target, const String& val);
48  };
51  {
52  public:
53  String doGet(const void* target) const;
54  void doSet(void* target, const String& val);
55  };
56  protected:
59  public:
60  D3D9GpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
61  const String& group, bool isManual, ManualResourceLoader* loader);
62  ~D3D9GpuProgram();
63 
64 
66  void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
68  bool getColumnMajorMatrices(void) const { return mColumnMajorMatrices; }
69 
72  void setExternalMicrocode(const void* pMicrocode, size_t size);
77  void setExternalMicrocode(ID3DXBuffer* pMicrocode);
79  LPD3DXBUFFER getExternalMicrocode(void);
80  protected:
82  void loadImpl(void);
84  void loadImpl(IDirect3DDevice9* d3d9Device);
86  void unloadImpl(void);
88  void loadFromSource(void);
90  void loadFromSource(IDirect3DDevice9* d3d9Device);
92  virtual void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode) = 0;
93 
94 
102  virtual GpuProgramParametersSharedPtr createParameters(void);
103  protected:
105  ID3DXBuffer* mExternalMicrocode;
106 
107  void getMicrocodeFromCache( IDirect3DDevice9* d3d9Device );
108  void compileMicrocode( IDirect3DDevice9* d3d9Device );
109  };
110 
113  {
114  public:
115  D3D9GpuVertexProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
116  const String& group, bool isManual, ManualResourceLoader* loader);
118 
120  IDirect3DVertexShader9* getVertexShader(void);
121 
122  // Called immediately after the Direct3D device has been created.
123  virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
124 
125  // Called before the Direct3D device is going to be destroyed.
126  virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
127 
128  protected:
130  void unloadImpl(void);
131  void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode);
132 
133  protected:
135  typedef DeviceToVertexShaderMap::iterator DeviceToVertexShaderIterator;
136 
138  };
139 
142  {
143  public:
144  D3D9GpuFragmentProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
145  const String& group, bool isManual, ManualResourceLoader* loader);
148  IDirect3DPixelShader9* getPixelShader(void);
149 
150  // Called immediately after the Direct3D device has been created.
151  virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
152 
153  // Called before the Direct3D device is going to be destroyed.
154  virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
155 
156  protected:
158  void unloadImpl(void);
159  void loadFromMicrocode(IDirect3DDevice9* d3d9Device, ID3DXBuffer* microcode);
160 
161  protected:
163  typedef DeviceToPixelShaderMap::iterator DeviceToPixelShaderIterator;
164 
166  };
167 }
168 
169 
170 #endif
static CmdExternalMicrocode msCmdExternalMicrocode
map< IDirect3DDevice9 *, IDirect3DVertexShader9 * >::type DeviceToVertexShaderMap
Direct3D implementation of low-level vertex programs.
DeviceToVertexShaderMap mMapDeviceToVertexShader
bool getColumnMajorMatrices(void) const
Gets whether matrix packed in column-major order.
Command object for setting matrix packing in column-major order.
Defines a program which runs on the GPU such as a vertex or fragment program.
Interface describing a manual resource loader.
Definition: OgreResource.h:514
map< IDirect3DDevice9 *, IDirect3DPixelShader9 * >::type DeviceToPixelShaderMap
Direct3D implementation of a few things common to low-level vertex & fragment programs.
Direct3D implementation of low-level fragment programs.
DeviceToPixelShaderMap::iterator DeviceToPixelShaderIterator
ID3DXBuffer * mExternalMicrocode
#define _OgreD3D9Export
DeviceToPixelShaderMap mMapDeviceToPixelShader
Command object for getting/setting external micro code (void*)
void setColumnMajorMatrices(bool columnMajor)
Sets whether matrix packing in column-major order.
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
DeviceToVertexShaderMap::iterator DeviceToVertexShaderIterator
Defines a generic resource handler.
_StringBase String
Abstract class which is command object which gets/sets parameters.
static CmdColumnMajorMatrices msCmdColumnMajorMatrices
Represents a Direct3D rendering resource.