+#if DIRECT3D_VERSION >= 0x0900
+
+
+static inline void
+_getLockInfo(IDirect3DVertexBuffer9 *pBuffer, UINT OffsetToLock, UINT SizeToLock, void ** ppbData,
+ void * & pLockedData, size_t & LockedSize) {
+ pLockedData = *ppbData;
+ LockedSize = 0;
+
+ if (SizeToLock == 0) {
+ D3DVERTEXBUFFER_DESC Desc;
+ HRESULT hr = pBuffer->GetDesc(&Desc);
+ if (FAILED(hr)) {
+ return;
+ }
+ LockedSize = Desc.Size;
+ } else {
+ LockedSize = SizeToLock;
+ }
+}
+
+
+static inline void
+_getLockInfo(IDirect3DIndexBuffer9 *pBuffer, UINT OffsetToLock, UINT SizeToLock, void ** ppbData,
+ void * & pLockedData, size_t & LockedSize) {
+ pLockedData = *ppbData;
+ LockedSize = 0;
+
+ if (SizeToLock == 0) {
+ D3DINDEXBUFFER_DESC Desc;
+ HRESULT hr = pBuffer->GetDesc(&Desc);
+ if (FAILED(hr)) {
+ return;
+ }
+ LockedSize = Desc.Size;
+ } else {
+ LockedSize = SizeToLock;
+ }
+}
+
+
+static inline void
+_getLockInfo(IDirect3DSurface9 *pSurface, const D3DLOCKED_RECT *pLockedRect, const RECT *pRect,
+ void * & pLockedData, size_t & LockedSize) {
+ pLockedData = pLockedRect->pBits;
+ LockedSize = 0;
+
+ HRESULT hr;
+
+ D3DSURFACE_DESC Desc;
+ hr = pSurface->GetDesc(&Desc);
+ if (FAILED(hr)) {
+ return;
+ }
+
+ UINT Width;
+ UINT Height;
+ if (pRect) {
+ Width = pRect->right - pRect->left;
+ Height = pRect->bottom - pRect->top;
+ } else {
+ Width = Desc.Width;
+ Height = Desc.Height;
+ }
+
+ LockedSize = _getLockSize(Desc.Format, Width, Height, pLockedRect->Pitch);
+}
+
+
+static inline void
+_getLockInfo(IDirect3DTexture9 *pTexture, UINT Level, const D3DLOCKED_RECT *pLockedRect, const RECT *pRect,
+ void * & pLockedData, size_t & LockedSize) {
+ pLockedData = pLockedRect->pBits;
+ LockedSize = 0;
+
+ HRESULT hr;
+
+ D3DSURFACE_DESC Desc;
+ hr = pTexture->GetLevelDesc(Level, &Desc);
+ if (FAILED(hr)) {
+ return;
+ }
+
+ UINT Width;
+ UINT Height;
+ if (pRect) {
+ Width = pRect->right - pRect->left;
+ Height = pRect->bottom - pRect->top;
+ } else {
+ Width = Desc.Width;
+ Height = Desc.Height;
+ }
+
+ LockedSize = _getLockSize(Desc.Format, Width, Height, pLockedRect->Pitch);
+}
+
+
+static inline void
+_getLockInfo(IDirect3DCubeTexture9 *pTexture, D3DCUBEMAP_FACES FaceType, UINT Level, const D3DLOCKED_RECT *pLockedRect, const RECT *pRect,
+ void * & pLockedData, size_t & LockedSize) {
+ pLockedData = pLockedRect->pBits;
+ LockedSize = 0;
+
+ HRESULT hr;
+
+ (void)FaceType;
+
+ D3DSURFACE_DESC Desc;
+ hr = pTexture->GetLevelDesc(Level, &Desc);
+ if (FAILED(hr)) {
+ return;
+ }
+
+ UINT Width;
+ UINT Height;
+ if (pRect) {
+ Width = pRect->right - pRect->left;
+ Height = pRect->bottom - pRect->top;
+ } else {
+ Width = Desc.Width;
+ Height = Desc.Height;
+ }
+
+ LockedSize = _getLockSize(Desc.Format, Width, Height, pLockedRect->Pitch);
+}
+
+
+static inline void
+_getLockInfo(IDirect3DVolume9 *pVolume, const D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox,
+ void * & pLockedData, size_t & LockedSize) {
+ pLockedData = pLockedVolume->pBits;
+ LockedSize = 0;
+
+ HRESULT hr;
+
+ D3DVOLUME_DESC Desc;
+ hr = pVolume->GetDesc(&Desc);
+ if (FAILED(hr)) {
+ return;
+ }
+
+ UINT Width;
+ UINT Height;
+ UINT Depth;
+ if (pBox) {
+ Width = pBox->Right - pBox->Left;
+ Height = pBox->Bottom - pBox->Top;
+ Depth = pBox->Back - pBox->Front;
+ } else {
+ Width = Desc.Width;
+ Height = Desc.Height;
+ Depth = Desc.Depth;
+ }
+
+ LockedSize = _getLockSize(Desc.Format, Width, Height, pLockedVolume->RowPitch, Depth, pLockedVolume->SlicePitch);
+}
+
+
+static inline void
+_getLockInfo(IDirect3DVolumeTexture9 *pTexture, UINT Level, const D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox,
+ void * & pLockedData, size_t & LockedSize) {
+ pLockedData = pLockedVolume->pBits;
+ LockedSize = 0;
+
+ HRESULT hr;
+
+ D3DVOLUME_DESC Desc;
+ hr = pTexture->GetLevelDesc(Level, &Desc);
+ if (FAILED(hr)) {
+ return;
+ }
+
+ UINT Width;
+ UINT Height;
+ UINT Depth;
+ if (pBox) {
+ Width = pBox->Right - pBox->Left;
+ Height = pBox->Bottom - pBox->Top;
+ Depth = pBox->Back - pBox->Front;
+ } else {
+ Width = Desc.Width;
+ Height = Desc.Height;
+ Depth = Desc.Depth;
+ }
+
+ LockedSize = _getLockSize(Desc.Format, Width, Height, pLockedVolume->RowPitch, Depth, pLockedVolume->SlicePitch);
+}
+
+
+#endif /* DIRECT3D_VERSION >= 0x0900 */
+
+