OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreD3D11HardwarePixelBuffer.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 __D3D11PIXELBUFFER_H__
29 #define __D3D11PIXELBUFFER_H__
30 
31 #include "OgreD3D11Prerequisites.h"
33 #include "OgreD3D11Driver.h"
34 
35 struct ID3D11Resource;
36 
37 namespace Ogre {
38 
40  {
41  protected:
43  PixelBox lockImpl(const Image::Box lockBox, LockOptions options);
44 
46  void unlockImpl(void);
47 
50 
53 
54  // if the usage is static - alloc at lock then use device UpdateSubresource when unlock and free memory
56 
57  size_t mFace;
58 
62 
63  D3D11_BOX OgreImageBoxToDx11Box(const Image::Box &inBox) const;
64 
66  void fromD3DLock(PixelBox &rval, const DXGI_MAPPED_RECT &lrect);
67 
71 
72  void createStagingBuffer();
74  ID3D11Resource *mStagingBuffer;
75 
76  void _map(ID3D11Resource *res, D3D11_MAP flags, PixelBox & box);
77  void *_mapstagingbuffer(D3D11_MAP flags);
79  void _unmap(ID3D11Resource *res);
80  void _unmapstagingbuffer(bool copyback = true);
81  void _unmapstaticbuffer();
82  public:
83  D3D11HardwarePixelBuffer(D3D11Texture * parentTexture, D3D11Device & device, size_t subresourceIndex,
84  size_t width, size_t height, size_t depth, size_t face, PixelFormat format, HardwareBuffer::Usage usage);
85 
87  void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox);
88 
90  void blitFromMemory(const PixelBox &src, const Image::Box &dstBox);
91 
93  void blitToMemory(const Image::Box &srcBox, const PixelBox &dst);
94 
96  void _genMipmaps();
97 
98 
100 
102  RenderTexture *getRenderTarget(size_t zoffset);
103 
105  virtual void _clearSliceRTT(size_t zoffset)
106  {
107  if (mSliceTRT.size() > zoffset)
108  {
109  mSliceTRT[zoffset] = 0;
110  }
111  }
112 
113  D3D11Texture * getParentTexture() const;
114  size_t getSubresourceIndex() const;
115  size_t getFace() const;
116  };
117 };
118 #endif
D3D11_BOX OgreImageBoxToDx11Box(const Image::Box &inBox) const
This class represents a RenderTarget that renders to a Texture.
vector< RenderTexture * >::type SliceTRT
Render targets.
void unlockImpl(void)
Unlock a box.
void fromD3DLock(PixelBox &rval, const DXGI_MAPPED_RECT &lrect)
Util functions to convert a D3D locked box to a pixel box.
void * _mapstagingbuffer(D3D11_MAP flags)
void _unmap(ID3D11Resource *res)
void _genMipmaps()
Internal function to update mipmaps on update of level 0.
void * _mapstaticbuffer(PixelBox lock)
void blit(const HardwarePixelBufferSharedPtr &src, const Image::Box &srcBox, const Image::Box &dstBox)
Copies a box from another PixelBuffer to a region of the this PixelBuffer.
PixelBox lockImpl(const Image::Box lockBox, LockOptions options)
Lock a box.
LockOptions
Locking options.
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:659
PixelFormat
The pixel format used for images, textures, and render surfaces.
void blitFromMemory(const PixelBox &src, const Image::Box &dstBox)
Copies a region from normal memory to a region of this pixelbuffer.
void _map(ID3D11Resource *res, D3D11_MAP flags, PixelBox &box)
Usage
Enums describing buffer usage; not mutually exclusive.
D3D11Texture * getParentTexture() const
Shared pointer implementation used to share pixel buffers.
Specialisation of HardwareBuffer for a pixel buffer.
void blitToMemory(const Image::Box &srcBox, const PixelBox &dst)
Copies a region of this pixelbuffer to normal memory.
virtual void _clearSliceRTT(size_t zoffset)
Notify TextureBuffer of destruction of render target.
signed char int8
Definition: OgrePlatform.h:349
void _unmapstagingbuffer(bool copyback=true)
D3D11Device & mDevice
D3DDevice pointer.
virtual const PixelBox & lock(const Image::Box &lockBox, LockOptions options)
Lock the buffer for (potentially) reading / writing.
RenderTexture * getRenderTarget(size_t zoffset)
Get rendertarget for z slice.
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
size_t getSubresourceIndex() const
D3D11HardwarePixelBuffer(D3D11Texture *parentTexture, D3D11Device &device, size_t subresourceIndex, size_t width, size_t height, size_t depth, size_t face, PixelFormat format, HardwareBuffer::Usage usage)