OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreD3D9HLSLProgram.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 __D3D9HLSLProgram_H__
29 #define __D3D9HLSLProgram_H__
30 
31 #include "OgreD3D9Prerequisites.h"
33 
34 namespace Ogre {
44  {
45  public:
47  class CmdEntryPoint : public ParamCommand
48  {
49  public:
50  String doGet(const void* target) const;
51  void doSet(void* target, const String& val);
52  };
54  class CmdTarget : public ParamCommand
55  {
56  public:
57  String doGet(const void* target) const;
58  void doSet(void* target, const String& val);
59  };
62  {
63  public:
64  String doGet(const void* target) const;
65  void doSet(void* target, const String& val);
66  };
69  {
70  public:
71  String doGet(const void* target) const;
72  void doSet(void* target, const String& val);
73  };
76  {
77  public:
78  String doGet(const void* target) const;
79  void doSet(void* target, const String& val);
80  };
81 
83  class CmdMicrocode : public ParamCommand
84  {
85  public:
86  String doGet(const void* target) const;
87  void doSet(void* target, const String& val);
88  };
89 
92  {
93  public:
94  String doGet(const void* target) const;
95  void doSet(void* target, const String& val);
96  };
97 
100  {
101  public:
102  String doGet(const void* target) const;
103  void doSet(void* target, const String& val);
104  };
105 
106  protected:
107 
116 
119  void loadFromSource(void);
122  void createLowLevelImpl(void);
124  void unloadHighLevelImpl(void);
126  void buildConstantDefinitions() const;
127 
128  // Recursive utility method for buildParamNameMap
129  void processParamElement(LPD3DXCONSTANTTABLE pConstTable, D3DXHANDLE parent, String prefix, unsigned int index);
130  void populateDef(D3DXCONSTANT_DESC& d3dDesc, GpuConstantDefinition& def) const;
131 
137 
138  LPD3DXBUFFER mMicroCode;
139 
142 
143  public:
144  LPD3DXBUFFER getMicroCode();
145  public:
148  {
160  OPT_3
161  };
162  protected:
164 
166  void getMicrocodeFromCache(void);
168  void compileMicrocode(void);
169  void addMicrocodeToCache();
170  public:
171  D3D9HLSLProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
172  const String& group, bool isManual, ManualResourceLoader* loader);
173  ~D3D9HLSLProgram();
174 
176  void setEntryPoint(const String& entryPoint) { mEntryPoint = entryPoint; }
178  const String& getEntryPoint(void) const { return mEntryPoint; }
180  void setTarget(const String& target);
182  const String& getTarget(void) const { return mTarget; }
184  void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
186  const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
188  void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
190  bool getColumnMajorMatrices(void) const { return mColumnMajorMatrices; }
192  void setBackwardsCompatibility(bool compat) { mBackwardsCompatibility = compat; }
194  bool getBackwardsCompatibility(void) const { return mBackwardsCompatibility; }
198  void setOptimisationLevel(OptimisationLevel opt) { mOptimisationLevel = opt; }
199 
201  OptimisationLevel getOptimisationLevel() const { return mOptimisationLevel; }
202 
204  bool isSupported(void) const;
206  GpuProgramParametersSharedPtr createParameters(void);
208  const String& getLanguage(void) const;
209  };
210 }
211 
212 #endif
static CmdAssemblerCode msCmdAssemblerCode
OptimisationLevel getOptimisationLevel() const
Gets the optimisation level to use.
Command object for setting target assembler.
static CmdTarget msCmdTarget
bool getColumnMajorMatrices(void) const
Gets whether matrix packed in column-major order.
Command object for getting/setting assembler code.
Command object for setting matrix packing in column-major order.
Interface describing a manual resource loader.
Definition: OgreResource.h:498
OptimisationLevel mOptimisationLevel
Specialisation of HighLevelGpuProgram to provide support for D3D9 High-Level Shader Language (HLSL)...
static CmdMicrocode msCmdMicrocode
const String & getPreprocessorDefines(void) const
Sets the preprocessor defines use to compile the program.
void setEntryPoint(const String &entryPoint)
Sets the entry point for this program ie the first method called.
void setColumnMajorMatrices(bool columnMajor)
Sets whether matrix packing in column-major order.
Command object for setting entry point.
static CmdOptimisation msCmdOptimisation
static CmdBackwardsCompatibility msCmdBackwardsCompatibility
#define _OgreD3D9Export
Command object for enabling backwards compatibility.
Command object for getting/setting micro code.
void setBackwardsCompatibility(bool compat)
Sets whether backwards compatibility mode should be enabled.
bool getBackwardsCompatibility(void) const
Gets whether backwards compatibility mode should be enabled.
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
const String & getEntryPoint(void) const
Gets the entry point defined for this program.
OptimisationLevel
Shader optimisation level.
static CmdEntryPoint msCmdEntryPoint
map< String, GpuConstantDefinition >::type GpuConstantDefinitionMap
Defines a generic resource handler.
Information about predefined program constants.
_StringBase String
Definition: OgreCommon.h:53
default - no optimisation in debug mode, OPT_1 in release mode
const String & getTarget(void) const
Gets the shader target to compile down to, e.g.
Command object for setting optimisation level.
Abstract base class representing a high-level program (a vertex or fragment program).
Command object for setting macro defines.
static CmdPreprocessorDefines msCmdPreprocessorDefines
void setOptimisationLevel(OptimisationLevel opt)
Sets the optimisation level to use.
GpuConstantDefinitionMap mParametersMap
Abstract class which is command object which gets/sets parameters.
static CmdColumnMajorMatrices msCmdColumnMajorMatrices
void setPreprocessorDefines(const String &defines)
Sets the preprocessor defines use to compile the program.