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-2012 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     protected:
    00098
    00099         static CmdEntryPoint msCmdEntryPoint;
    00100         static CmdTarget msCmdTarget;
    00101         static CmdPreprocessorDefines msCmdPreprocessorDefines;
    00102         static CmdColumnMajorMatrices msCmdColumnMajorMatrices;
    00103         static CmdOptimisation msCmdOptimisation;
    00104         static CmdMicrocode msCmdMicrocode;
    00105         static CmdAssemblerCode msCmdAssemblerCode;
    00106
    00109         void loadFromSource(void);
    00112         void createLowLevelImpl(void);
    00114         void unloadHighLevelImpl(void);
    00116         void buildConstantDefinitions() const;
    00117
    00118         // Recursive utility method for buildParamNameMap
    00119         void processParamElement(LPD3DXCONSTANTTABLE pConstTable, D3DXHANDLE parent, String prefix, unsigned int index);
    00120         void populateDef(D3DXCONSTANT_DESC& d3dDesc, GpuConstantDefinition& def) const;
    00121
    00122         String mTarget;
    00123         String mEntryPoint;
    00124         String mPreprocessorDefines;
    00125         bool mColumnMajorMatrices;
    00126
    00127         LPD3DXBUFFER mMicroCode;
    00128
    00129         GpuConstantDefinitionMap mParametersMap;
    00130         size_t mParametersMapSizeAsBuffer;
    00131
    00132     public:
    00133         LPD3DXBUFFER getMicroCode();
    00134     public:
    00136         enum OptimisationLevel
    00137         {
    00139             OPT_DEFAULT,
    00141             OPT_NONE,
    00143             OPT_0,
    00145             OPT_1,
    00147             OPT_2,
    00149             OPT_3
    00150         };
    00151     protected:
    00152         OptimisationLevel mOptimisationLevel;
    00153
    00155         void getMicrocodeFromCache(void);
    00157         void compileMicrocode(void);
    00158         void addMicrocodeToCache();
    00159     public:
    00160         D3D9HLSLProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
    00161             const String& group, bool isManual, ManualResourceLoader* loader);
    00162         ~D3D9HLSLProgram();
    00163
    00165         void setEntryPoint(const String& entryPoint) { mEntryPoint = entryPoint; }
    00167         const String& getEntryPoint(void) const { return mEntryPoint; }
    00169         void setTarget(const String& target);
    00171         const String& getTarget(void) const { return mTarget; }
    00173         void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
    00175         const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
    00177         void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
    00179         bool getColumnMajorMatrices(void) const { return mColumnMajorMatrices; }
    00183         void setOptimisationLevel(OptimisationLevel opt) { mOptimisationLevel = opt; }
    00184
    00186         OptimisationLevel getOptimisationLevel() const { return mOptimisationLevel; }
    00187
    00189         bool isSupported(void) const;
    00191         GpuProgramParametersSharedPtr createParameters(void);
    00193         const String& getLanguage(void) const;
    00194     };
    00195 }
    00196
    00197 #endif

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:21