# OgreHighLevelGpuProgram.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-2009 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 __HighLevelGpuProgram_H__
    00029 #define __HighLevelGpuProgram_H__
    00030
    00031 #include "OgrePrerequisites.h"
    00032 #include "OgreGpuProgram.h"
    00033
    00034 namespace Ogre {
    00035
    00063     class _OgreExport HighLevelGpuProgram : public GpuProgram
    00064     {
    00065     protected:
    00067         bool mHighLevelLoaded;
    00069         GpuProgramPtr mAssemblerProgram;
    00071         mutable bool mConstantDefsBuilt;
    00072
    00074         virtual void loadHighLevel(void);
    00076         virtual void unloadHighLevel(void);
    00080         virtual void loadHighLevelImpl(void);
    00083         virtual void createLowLevelImpl(void) = 0;
    00085         virtual void unloadHighLevelImpl(void) = 0;
    00087         virtual void populateParameterNames(GpuProgramParametersSharedPtr params);
    00094         virtual void buildConstantDefinitions() const = 0;
    00095
    00097         void loadImpl();
    00099         void unloadImpl();
    00100     public:
    00102         HighLevelGpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
    00103             const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
    00104         ~HighLevelGpuProgram();
    00105
    00106
    00114         GpuProgramParametersSharedPtr createParameters(void);
    00116         GpuProgram* _getBindingDelegate(void) { return mAssemblerProgram.getPointer(); }
    00117
    00122         const GpuNamedConstants& getConstantDefinitions() const;
    00123
    00125         const GpuNamedConstants& getNamedConstants() const { return getConstantDefinitions(); }
    00126
    00127
    00128
    00129
    00130
    00131     };
    00132
    00139     class _OgreExport HighLevelGpuProgramPtr : public SharedPtr<HighLevelGpuProgram>
    00140     {
    00141     public:
    00142         HighLevelGpuProgramPtr() : SharedPtr<HighLevelGpuProgram>() {}
    00143         explicit HighLevelGpuProgramPtr(HighLevelGpuProgram* rep) : SharedPtr<HighLevelGpuProgram>(rep) {}
    00144         HighLevelGpuProgramPtr(const HighLevelGpuProgramPtr& r) : SharedPtr<HighLevelGpuProgram>(r) {}
    00145         HighLevelGpuProgramPtr(const ResourcePtr& r) : SharedPtr<HighLevelGpuProgram>()
    00146         {
    00147             // lock & copy other mutex pointer
    00148             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
    00149             {
    00150                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00151                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00152                 pRep = static_cast<HighLevelGpuProgram*>(r.getPointer());
    00153                 pUseCount = r.useCountPointer();
    00154                 if (pUseCount)
    00155                 {
    00156                     ++(*pUseCount);
    00157                 }
    00158             }
    00159         }
    00160
    00162         HighLevelGpuProgramPtr& operator=(const ResourcePtr& r)
    00163         {
    00164             if (pRep == static_cast<HighLevelGpuProgram*>(r.getPointer()))
    00165                 return *this;
    00166             release();
    00167             // lock & copy other mutex pointer
    00168             OGRE_MUTEX_CONDITIONAL(r.OGRE_AUTO_MUTEX_NAME)
    00169             {
    00170                 OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
    00171                 OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
    00172                 pRep = static_cast<HighLevelGpuProgram*>(r.getPointer());
    00173                 pUseCount = r.useCountPointer();
    00174                 if (pUseCount)
    00175                 {
    00176                     ++(*pUseCount);
    00177                 }
    00178             }
    00179             else
    00180             {
    00181                 // RHS must be a null pointer
    00182                 assert(r.isNull() && "RHS must be null if it has no mutex!");
    00183                 setNull();
    00184             }
    00185             return *this;
    00186         }
    00188         HighLevelGpuProgramPtr& operator=(const GpuProgramPtr& r);
    00189     };
    00193 }
    00194 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:51