OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreD3D9HardwarePixelBuffer.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 __D3D9PIXELBUFFER_H__
29 #define __D3D9PIXELBUFFER_H__
30 
31 #include "OgreD3D9Prerequisites.h"
34 
35 namespace Ogre {
36 
37  class D3D9Texture;
38  class D3D9RenderTexture;
39 
41  {
42  protected:
44  {
46  IDirect3DSurface9* surface;
48  IDirect3DSurface9* fSAASurface;
50  IDirect3DVolume9* volume;
52  IDirect3DSurface9* tempSurface;
54  IDirect3DVolume9* tempVolume;
56  IDirect3DBaseTexture9 *mipTex;
57  };
58 
60  typedef DeviceToBufferResourcesMap::iterator DeviceToBufferResourcesIterator;
61 
64 
67  bool mHWMipmaps;
68 
71 
72  // The owner texture if exists.
74 
75  // The current lock flags of this surface.
76  DWORD mLockFlags;
77 
78  // Device access mutex.
79  OGRE_STATIC_MUTEX(msDeviceAccessMutex);
80  protected:
82  PixelBox lockImpl(const Image::Box &lockBox, LockOptions options);
83  PixelBox lockBuffer(BufferResources* bufferResources, const Image::Box &lockBox, DWORD flags);
84 
86  void unlockImpl(void);
87  void unlockBuffer(BufferResources* bufferResources);
88 
89  BufferResources* getBufferResources(IDirect3DDevice9* d3d9Device);
90  BufferResources* createBufferResources();
91 
93  void updateRenderTexture(bool writeGamma, uint fsaa, const String& srcName);
95  void destroyRenderTexture();
96 
97  void blit(IDirect3DDevice9* d3d9Device, const HardwarePixelBufferSharedPtr &src,
98  const Image::Box &srcBox, const Image::Box &dstBox,
99  BufferResources* srcBufferResources,
100  BufferResources* dstBufferResources);
101  void blitFromMemory(const PixelBox &src, const Image::Box &dstBox, BufferResources* dstBufferResources);
102 
103  void blitToMemory(const Image::Box &srcBox, const PixelBox &dst, BufferResources* srcBufferResources, IDirect3DDevice9* d3d9Device);
104 
105  public:
107  D3D9Texture* ownerTexture);
109 
111  void bind(IDirect3DDevice9 *dev, IDirect3DSurface9 *mSurface, IDirect3DSurface9* fsaaSurface,
112  bool writeGamma, uint fsaa, const String& srcName, IDirect3DBaseTexture9 *mipTex);
113  void bind(IDirect3DDevice9 *dev, IDirect3DVolume9 *mVolume, IDirect3DBaseTexture9 *mipTex);
114 
116  void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
117 
119  void blitFromMemory(const PixelBox &src, const Image::Box &dstBox);
120 
122  void blitToMemory(const Image::Box &srcBox, const PixelBox &dst);
123 
125  void _genMipmaps(IDirect3DBaseTexture9* mipTex);
126 
128  void _setMipmapping(bool doMipmapGen, bool HWMipmaps);
129 
130 
132  RenderTexture *getRenderTarget(size_t zoffset);
133 
135  IDirect3DSurface9 *getSurface(IDirect3DDevice9* d3d9Device);
136 
138  IDirect3DSurface9 *getFSAASurface(IDirect3DDevice9* d3d9Device);
139 
141  virtual void _clearSliceRTT(size_t zoffset);
142 
144  void releaseSurfaces(IDirect3DDevice9* d3d9Device);
145 
147  void destroyBufferResources(IDirect3DDevice9* d3d9Device);
148 
149  // Called when device state is changing. Access to any device should be locked.
150  // Relevant for multi thread application.
151  static void lockDeviceAccess();
152 
153  // Called when device state change completed. Access to any device is allowed.
154  // Relevant for multi thread application.
155  static void unlockDeviceAccess();
156  };
157 };
158 #endif
IDirect3DVolume9 * tempVolume
Temporary volume in main memory if direct locking of mVolume is not possible.
IDirect3DSurface9 * tempSurface
Temporary surface in main memory if direct locking of mSurface is not possible.
IDirect3DBaseTexture9 * mipTex
Mip map texture.
This class represents a RenderTarget that renders to a Texture.
IDirect3DSurface9 * surface
Surface abstracted by this buffer.
LockOptions
Locking options.
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:689
map< IDirect3DDevice9 *, BufferResources * >::type DeviceToBufferResourcesMap
#define _OgreD3D9Export
Usage
Enums describing buffer usage; not mutually exclusive.
IDirect3DSurface9 * fSAASurface
AA Surface abstracted by this buffer.
Shared pointer implementation used to share pixel buffers.
Specialisation of HardwareBuffer for a pixel buffer.
RenderTexture implementation for D3D9.
D3D9RenderTexture * mRenderTexture
Render target.
#define OGRE_STATIC_MUTEX(name)
IDirect3DVolume9 * volume
Volume abstracted by this buffer.
_StringBase String
Definition: OgreCommon.h:53
DeviceToBufferResourcesMap::iterator DeviceToBufferResourcesIterator
DeviceToBufferResourcesMap mMapDeviceToBufferResources
Map between device to buffer resources.
unsigned int uint