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-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 __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
Ogre::D3D11HardwarePixelBuffer::OgreImageBoxToDx11Box
D3D11_BOX OgreImageBoxToDx11Box(const Image::Box &inBox) const
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::D3D11HardwarePixelBuffer::SliceTRT
vector< RenderTexture * >::type SliceTRT
Render targets.
Definition: OgreD3D11HardwarePixelBuffer.h:69
Ogre::D3D11HardwarePixelBuffer::_unmapstaticbuffer
void _unmapstaticbuffer()
OgreD3D11Driver.h
Ogre::D3D11HardwarePixelBuffer::_unmapstagingbuffer
void _unmapstagingbuffer(bool copyback=true)
Ogre::D3D11HardwarePixelBuffer::fromD3DLock
void fromD3DLock(PixelBox &rval, const DXGI_MAPPED_RECT &lrect)
Util functions to convert a D3D locked box to a pixel box.
Ogre::D3D11HardwarePixelBuffer::_mapstagingbuffer
void * _mapstagingbuffer(D3D11_MAP flags)
Ogre::D3D11HardwarePixelBuffer::_clearSliceRTT
virtual void _clearSliceRTT(size_t zoffset)
Notify TextureBuffer of destruction of render target.
Definition: OgreD3D11HardwarePixelBuffer.h:105
Ogre::D3D11HardwarePixelBuffer::getFace
size_t getFace() const
Ogre::HardwarePixelBuffer
Specialisation of HardwareBuffer for a pixel buffer.
Definition: OgreHardwarePixelBuffer.h:53
Ogre::D3D11HardwarePixelBuffer::getParentTexture
D3D11Texture * getParentTexture() const
OgreHardwarePixelBuffer.h
Ogre::D3D11HardwarePixelBuffer::_genMipmaps
void _genMipmaps()
Internal function to update mipmaps on update of level 0.
Ogre::D3D11HardwarePixelBuffer::blitToMemory
void blitToMemory(const Image::Box &srcBox, const PixelBox &dst)
Copies a region of this pixelbuffer to normal memory.
Ogre::D3D11HardwarePixelBuffer::blitFromMemory
void blitFromMemory(const PixelBox &src, const Image::Box &dstBox)
Copies a region from normal memory to a region of this pixelbuffer.
Ogre::int8
signed char int8
Definition: OgrePlatform.h:364
Ogre::D3D11Device
Definition: OgreD3D11Device.h:36
Ogre::D3D11HardwarePixelBuffer::mFace
size_t mFace
Definition: OgreD3D11HardwarePixelBuffer.h:57
Ogre::D3D11HardwarePixelBuffer::mLockBox
Image::Box mLockBox
Definition: OgreD3D11HardwarePixelBuffer.h:59
Ogre::D3D11HardwarePixelBuffer::mDataForStaticUsageLock
int8 * mDataForStaticUsageLock
Definition: OgreD3D11HardwarePixelBuffer.h:55
OgreD3D11Prerequisites.h
Ogre::PixelFormat
PixelFormat
The pixel format used for images, textures, and render surfaces.
Definition: OgrePixelFormat.h:43
Ogre::D3D11Texture
Definition: OgreD3D11Texture.h:42
Ogre::D3D11HardwarePixelBuffer::getRenderTarget
RenderTexture * getRenderTarget(size_t zoffset)
Get rendertarget for z slice.
Ogre::D3D11HardwarePixelBuffer::blit
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.
Ogre::D3D11HardwarePixelBuffer::createStagingBuffer
void createStagingBuffer()
Ogre::D3D11HardwarePixelBuffer::mStagingBuffer
ID3D11Resource * mStagingBuffer
Definition: OgreD3D11HardwarePixelBuffer.h:74
Ogre::D3D11HardwarePixelBuffer::D3D11HardwarePixelBuffer
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)
Ogre::HardwarePixelBuffer::lock
virtual const PixelBox & lock(const Image::Box &lockBox, LockOptions options)
Lock the buffer for (potentially) reading / writing.
Ogre::D3D11HardwarePixelBuffer::mSubresourceIndex
size_t mSubresourceIndex
Definition: OgreD3D11HardwarePixelBuffer.h:52
Ogre::D3D11HardwarePixelBuffer::mParentTexture
D3D11Texture * mParentTexture
Definition: OgreD3D11HardwarePixelBuffer.h:51
Ogre::Box
Structure used to define a box in a 3-D integer space.
Definition: OgreCommon.h:659
Ogre::D3D11HardwarePixelBuffer::getSubresourceIndex
size_t getSubresourceIndex() const
Ogre::D3D11HardwarePixelBuffer
Definition: OgreD3D11HardwarePixelBuffer.h:39
Ogre::D3D11HardwarePixelBuffer::lockImpl
PixelBox lockImpl(const Image::Box lockBox, LockOptions options)
Lock a box.
Ogre::PixelBox
A primitive describing a volume (3D), image (2D) or line (1D) of pixels in memory.
Definition: OgrePixelFormat.h:304
Ogre::HardwarePixelBufferSharedPtr
Shared pointer implementation used to share pixel buffers.
Definition: OgreHardwarePixelBuffer.h:193
Ogre::RenderTexture
This class represents a RenderTarget that renders to a Texture.
Definition: OgreRenderTexture.h:48
Ogre::HardwareBuffer::Usage
Usage
Enums describing buffer usage; not mutually exclusive.
Definition: OgreHardwareBuffer.h:79
Ogre::D3D11HardwarePixelBuffer::mDevice
D3D11Device & mDevice
D3DDevice pointer.
Definition: OgreD3D11HardwarePixelBuffer.h:49
Ogre::D3D11HardwarePixelBuffer::_map
void _map(ID3D11Resource *res, D3D11_MAP flags, PixelBox &box)
Ogre::D3D11HardwarePixelBuffer::mCurrentLock
PixelBox mCurrentLock
Definition: OgreD3D11HardwarePixelBuffer.h:60
Ogre::D3D11HardwarePixelBuffer::~D3D11HardwarePixelBuffer
~D3D11HardwarePixelBuffer()
Ogre::HardwareBuffer::LockOptions
LockOptions
Locking options.
Definition: OgreHardwareBuffer.h:121
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::D3D11HardwarePixelBuffer::_unmap
void _unmap(ID3D11Resource *res)
Ogre::D3D11HardwarePixelBuffer::mUsingStagingBuffer
bool mUsingStagingBuffer
Definition: OgreD3D11HardwarePixelBuffer.h:73
Ogre::D3D11HardwarePixelBuffer::mSliceTRT
SliceTRT mSliceTRT
Definition: OgreD3D11HardwarePixelBuffer.h:70
Ogre::D3D11HardwarePixelBuffer::mCurrentLockOptions
LockOptions mCurrentLockOptions
Definition: OgreD3D11HardwarePixelBuffer.h:61
Ogre::D3D11HardwarePixelBuffer::_mapstaticbuffer
void * _mapstaticbuffer(PixelBox lock)
Ogre::D3D11HardwarePixelBuffer::unlockImpl
void unlockImpl(void)
Unlock a box.

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Tue Apr 13 2021 08:53:15