Go to the documentation of this file.00001
00002
00003 #ifndef _BUFFER_H_
00004 #define _BUFFER_H_
00005
00006 #include <EngineConfig.h>
00007 #include <core/Types.h>
00008
00009 namespace resource
00010 {
00011
00013 enum BufferLocking
00014 {
00015 BL_NORMAL,
00016 BL_DISCARD,
00017 BL_READ_ONLY,
00018 BL_NO_OVERWRITE
00019 };
00020
00022 enum BufferUsage
00023 {
00024 BU_STATIC = 1,
00025 BU_DYNAMIC = 2,
00026 BU_WRITE_ONLY = 4,
00027 BU_STATIC_WRITE_ONLY = 5,
00028 BU_DYNAMIC_WRITE_ONLY = 6,
00029 BU_DISCARDABLE = 8,
00030 BU_DYNAMIC_WRITE_ONLY_DISCARDABLE = 14
00031 };
00032
00046 class ENGINE_PUBLIC_EXPORT Buffer
00047 {
00048 public:
00049
00050 Buffer(BufferUsage usage, bool systemMemory, bool useShadowBuffer);
00051
00052 virtual ~Buffer();
00058 virtual void* lock(u32 offset, u32 length, BufferLocking options);
00059
00063 void* lock(BufferLocking options);
00064
00075 virtual void unlock();
00076
00082 virtual void readData(u32 offset, u32 length, void* pDest) = 0;
00090 virtual void writeData(u32 offset, u32 length, const void* pSource, bool discardWholeBuffer = false) = 0;
00091
00101 virtual void copyData(Buffer& srcBuffer, u32 srcOffset, u32 dstOffset, u32 length, bool discardWholeBuffer = false);
00102
00104 virtual void updateFromShadow();
00105
00107 u32 getSizeInBytes() const;
00109 BufferUsage getUsage() const;
00111 bool isSystemMemory() const;
00113 bool isLocked() const;
00114
00115 protected:
00116
00117 u32 mSizeInBytes;
00118 BufferUsage mUsage;
00119 bool mIsLocked;
00120 u32 mLockStart;
00121 u32 mLockSize;
00122 bool mSystemMemory;
00123 bool mUseShadowBuffer;
00124 Buffer* mShadowBuffer;
00125 bool mShadowUpdated;
00126
00128 virtual void* lockImpl(u32 offset, u32 length, BufferLocking options) = 0;
00130 virtual void unlockImpl() = 0;
00131 };
00132
00133 }
00134
00135 #endif// _BUFFER_H_