OgreD3D9HLSLProgram.h
Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004 (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2013 Torus Knot Software Ltd
00008 
00009 Permission is hereby granted, free of charge, to any person obtaining a copy
00010 of this software and associated documentation files (the "Software"), to deal
00011 in the Software without restriction, including without limitation the rights
00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00013 copies of the Software, and to permit persons to whom the Software is
00014 furnished to do so, subject to the following conditions:
00015 
00016 The above copyright notice and this permission notice shall be included in
00017 all copies or substantial portions of the Software.
00018 
00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00025 THE SOFTWARE.
00026 -----------------------------------------------------------------------------
00027 */
00028 #ifndef __D3D9HLSLProgram_H__
00029 #define __D3D9HLSLProgram_H__
00030 
00031 #include "OgreD3D9Prerequisites.h"
00032 #include "OgreHighLevelGpuProgram.h"
00033 
00034 namespace Ogre {
00043     class _OgreD3D9Export D3D9HLSLProgram : public HighLevelGpuProgram
00044     {
00045     public:
00047         class CmdEntryPoint : public ParamCommand
00048         {
00049         public:
00050             String doGet(const void* target) const;
00051             void doSet(void* target, const String& val);
00052         };
00054         class CmdTarget : public ParamCommand
00055         {
00056         public:
00057             String doGet(const void* target) const;
00058             void doSet(void* target, const String& val);
00059         };
00061         class CmdPreprocessorDefines : public ParamCommand
00062         {
00063         public:
00064             String doGet(const void* target) const;
00065             void doSet(void* target, const String& val);
00066         };
00068         class CmdColumnMajorMatrices : public ParamCommand
00069         {
00070         public:
00071             String doGet(const void* target) const;
00072             void doSet(void* target, const String& val);
00073         };
00075         class CmdOptimisation : public ParamCommand
00076         {
00077         public:
00078             String doGet(const void* target) const;
00079             void doSet(void* target, const String& val);
00080         };
00081 
00083         class CmdMicrocode : public ParamCommand
00084         {
00085         public:
00086             String doGet(const void* target) const;
00087             void doSet(void* target, const String& val);
00088         };
00089 
00091         class CmdAssemblerCode : public ParamCommand
00092         {
00093         public:
00094             String doGet(const void* target) const;
00095             void doSet(void* target, const String& val);
00096         };
00097 
00099         class CmdBackwardsCompatibility : public ParamCommand
00100         {
00101         public:
00102             String doGet(const void* target) const;
00103             void doSet(void* target, const String& val);
00104         };
00105 
00106     protected:
00107 
00108         static CmdEntryPoint msCmdEntryPoint;
00109         static CmdTarget msCmdTarget;
00110         static CmdPreprocessorDefines msCmdPreprocessorDefines;
00111         static CmdColumnMajorMatrices msCmdColumnMajorMatrices;
00112         static CmdOptimisation msCmdOptimisation;
00113         static CmdMicrocode msCmdMicrocode;
00114         static CmdAssemblerCode msCmdAssemblerCode;
00115         static CmdBackwardsCompatibility msCmdBackwardsCompatibility;
00116 
00119         void loadFromSource(void);
00122         void createLowLevelImpl(void);
00124         void unloadHighLevelImpl(void);
00126         void buildConstantDefinitions() const;
00127 
00128         // Recursive utility method for buildParamNameMap
00129         void processParamElement(LPD3DXCONSTANTTABLE pConstTable, D3DXHANDLE parent, String prefix, unsigned int index);
00130         void populateDef(D3DXCONSTANT_DESC& d3dDesc, GpuConstantDefinition& def) const;
00131 
00132         String mTarget;
00133         String mEntryPoint;
00134         String mPreprocessorDefines;
00135         bool mColumnMajorMatrices;
00136         bool mBackwardsCompatibility;
00137 
00138         LPD3DXBUFFER mMicroCode;
00139 
00140         GpuConstantDefinitionMap mParametersMap;
00141         size_t mParametersMapSizeAsBuffer;
00142 
00143     public:
00144         LPD3DXBUFFER getMicroCode();
00145     public:
00147         enum OptimisationLevel
00148         {
00150             OPT_DEFAULT,
00152             OPT_NONE,
00154             OPT_0, 
00156             OPT_1,
00158             OPT_2, 
00160             OPT_3
00161         };
00162     protected:
00163         OptimisationLevel mOptimisationLevel;
00164 
00166         void getMicrocodeFromCache(void);
00168         void compileMicrocode(void);
00169         void addMicrocodeToCache();
00170     public:
00171         D3D9HLSLProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
00172             const String& group, bool isManual, ManualResourceLoader* loader);
00173         ~D3D9HLSLProgram();
00174 
00176         void setEntryPoint(const String& entryPoint) { mEntryPoint = entryPoint; }
00178         const String& getEntryPoint(void) const { return mEntryPoint; }
00180         void setTarget(const String& target);
00182         const String& getTarget(void) const { return mTarget; }
00184         void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
00186         const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
00188         void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
00190         bool getColumnMajorMatrices(void) const { return mColumnMajorMatrices; }
00192         void setBackwardsCompatibility(bool compat) { mBackwardsCompatibility = compat; }
00194         bool getBackwardsCompatibility(void) const { return mBackwardsCompatibility; }
00198         void setOptimisationLevel(OptimisationLevel opt) { mOptimisationLevel = opt; }
00199 
00201         OptimisationLevel getOptimisationLevel() const { return mOptimisationLevel; }
00202 
00204         bool isSupported(void) const;
00206         GpuProgramParametersSharedPtr createParameters(void);
00208         const String& getLanguage(void) const;
00209     };
00210 }
00211 
00212 #endif

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:42