OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreD3D11GpuProgram.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-2013 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 __D3D11GpuProgram_H_
29 #define __D3D11GpuProgram_H_
30 
31 // Precompiler options
32 #include "OgreD3D11Prerequisites.h"
33 #include "OgreGpuProgram.h"
34 
35 namespace Ogre {
36 
38  class D3D11GpuProgram : public GpuProgram
39  {
40  protected:
42  public:
43  D3D11GpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
44  const String& group, bool isManual, ManualResourceLoader* loader, D3D11Device & device);
45 
46  protected:
48  void loadImpl(void);
50  void loadFromSource(void);
52  virtual void loadFromMicrocode(ID3D10Blob * microcode) = 0;
53 
54 
55  };
56 
59  {
60  protected:
61  ID3D11VertexShader * mVertexShader;
62  public:
63  D3D11GpuVertexProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
64  const String& group, bool isManual, ManualResourceLoader* loader, D3D11Device & device);
67  ID3D11VertexShader * getVertexShader(void) const;
68  protected:
70  void unloadImpl(void);
71  void loadFromMicrocode(ID3D10Blob * microcode);
72  };
73 
76  {
77  protected:
78  ID3D11PixelShader * mPixelShader;
79  public:
80  D3D11GpuFragmentProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
81  const String& group, bool isManual, ManualResourceLoader* loader, D3D11Device & device);
84  ID3D11PixelShader * getPixelShader(void) const;
85  protected:
87  void unloadImpl(void);
88  void loadFromMicrocode(ID3D10Blob * microcode);
89  };
96  class _OgreExport D3D11GpuProgramPtr : public SharedPtr<D3D11GpuProgram>
97  {
98  public:
103  {
104  // lock & copy other mutex pointer
105  OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
106  OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
107  pRep = static_cast<D3D11GpuProgram*>(r.getPointer());
108  pUseCount = r.useCountPointer();
109  if (pUseCount)
110  {
111  ++(*pUseCount);
112  }
113  }
114 
117  {
118  if (pRep == static_cast<D3D11GpuProgram*>(r.getPointer()))
119  return *this;
120  release();
121  // lock & copy other mutex pointer
122  OGRE_LOCK_MUTEX(*r.OGRE_AUTO_MUTEX_NAME)
123  OGRE_COPY_AUTO_SHARED_MUTEX(r.OGRE_AUTO_MUTEX_NAME)
124  pRep = static_cast<D3D11GpuProgram*>(r.getPointer());
125  pUseCount = r.useCountPointer();
126  if (pUseCount)
127  {
128  ++(*pUseCount);
129  }
130  return *this;
131  }
132  };
133 
134 }
135 
136 
137 #endif
D3D11GpuProgramPtr(const D3D11GpuProgramPtr &r)
ID3D11PixelShader * getPixelShader(void) const
Gets the pixel shader.
void loadImpl(void)
Internal implementation of the meat of the 'load' action, only called if this resource is not being l...
T * getPointer() const
virtual void loadFromMicrocode(ID3D10Blob *microcode)=0
Internal method to load from microcode, must be overridden by subclasses.
#define _OgreExport
Definition: OgrePlatform.h:233
void loadFromMicrocode(ID3D10Blob *microcode)
Internal method to load from microcode, must be overridden by subclasses.
D3D11GpuProgram(ResourceManager *creator, const String &name, ResourceHandle handle, const String &group, bool isManual, ManualResourceLoader *loader, D3D11Device &device)
Defines a program which runs on the GPU such as a vertex or fragment program.
Interface describing a manual resource loader.
Definition: OgreResource.h:513
void unloadImpl(void)
Internal implementation of the 'unload' action; called regardless of whether this resource is being l...
D3D11GpuFragmentProgram(ResourceManager *creator, const String &name, ResourceHandle handle, const String &group, bool isManual, ManualResourceLoader *loader, D3D11Device &device)
void unloadImpl(void)
Internal implementation of the 'unload' action; called regardless of whether this resource is being l...
Direct3D implementation of low-level fragment programs.
ID3D11VertexShader * mVertexShader
void loadFromMicrocode(ID3D10Blob *microcode)
Internal method to load from microcode, must be overridden by subclasses.
ID3D11VertexShader * getVertexShader(void) const
Gets the vertex shader.
void loadFromSource(void)
Overridden from GpuProgram.
unsigned long long int ResourceHandle
Definition: OgreResource.h:40
#define OGRE_LOCK_MUTEX(name)
Direct3D implementation of low-level vertex programs.
Defines a generic resource handler.
unsigned int * useCountPointer() const
Specialisation of SharedPtr to allow SharedPtr to be assigned to D3D11GpuProgramPtr.
Reference-counted shared pointer, used for objects where implicit destruction is required.
Definition: OgreSharedPtr.h:60
D3D11GpuVertexProgram(ResourceManager *creator, const String &name, ResourceHandle handle, const String &group, bool isManual, ManualResourceLoader *loader, D3D11Device &device)
D3D11GpuProgramPtr & operator=(const ResourcePtr &r)
Operator used to convert a ResourcePtr to a D3D11GpuProgramPtr.
_StringBase String
D3D11GpuProgramPtr(const ResourcePtr &r)
D3D11GpuProgramPtr(D3D11GpuProgram *rep)
Direct3D implementation of a few things common to low-level vertex & fragment programs.
#define OGRE_COPY_AUTO_SHARED_MUTEX(from)