+ return _getLockSize(Desc.Format, Width, Height, pLockedRect->Pitch);
+}
+
+
+static inline size_t
+_getLockSize(IDirect3DVolume9 *pVolume, const D3DLOCKED_BOX *pLockedBox, const D3DBOX *pBox) {
+ HRESULT hr;
+
+ D3DVOLUME_DESC Desc;
+ hr = pVolume->GetDesc(&Desc);
+ if (FAILED(hr)) {
+ return 0;
+ }
+
+ 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;
+ }
+
+ return _getLockSize(Desc.Format, Width, Height, pLockedBox->RowPitch, Depth, pLockedBox->SlicePitch);
+}
+
+
+static inline size_t
+_getLockSize(IDirect3DVolumeTexture9 *pTexture, UINT Level, const D3DLOCKED_BOX *pLockedBox, const D3DBOX *pBox) {
+ HRESULT hr;
+
+ D3DVOLUME_DESC Desc;
+ hr = pTexture->GetLevelDesc(Level, &Desc);
+ if (FAILED(hr)) {
+ return 0;
+ }
+
+ 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;
+ }
+
+ return _getLockSize(Desc.Format, Width, Height, pLockedBox->RowPitch, Depth, pLockedBox->SlicePitch);