]> git.cworth.org Git - apitrace/blobdiff - helpers/d3dsize.hpp
Use same logic for both Lock and LockRect.
[apitrace] / helpers / d3dsize.hpp
index 97fccd3e5d99f5a176042354431d46f775df562a..92503fe8b8daca95164418d9aa7045a0a9156889 100644 (file)
@@ -160,6 +160,36 @@ _formatSize(D3DFORMAT Format, UINT Width, UINT Height, INT Pitch) {
 #if DIRECT3D_VERSION >= 0x0900
 
 
+static inline size_t
+_getLockSize(IDirect3DVertexBuffer9 *pBuffer, UINT OffsetToLock, UINT SizeToLock, void ** ppbData) {
+    if (SizeToLock == 0) {
+        D3DVERTEXBUFFER_DESC Desc;
+        HRESULT hr = pBuffer->GetDesc(&Desc);
+        if (FAILED(hr)) {
+            return 0;
+        } 
+        SizeToLock = Desc.Size;
+    }
+
+    return SizeToLock;
+}
+
+
+static inline size_t
+_getLockSize(IDirect3DIndexBuffer9 *pBuffer, UINT OffsetToLock, UINT SizeToLock, void ** ppbData) {
+    if (SizeToLock == 0) {
+        D3DINDEXBUFFER_DESC Desc;
+        HRESULT hr = pBuffer->GetDesc(&Desc);
+        if (FAILED(hr)) {
+            return 0;
+        } 
+        SizeToLock = Desc.Size;
+    }
+
+    return SizeToLock;
+}
+
+
 static inline size_t
 _getLockSize(IDirect3DSurface9 *pSurface, const D3DLOCKED_RECT *pLockedRect, const RECT *pRect) {
     HRESULT hr;