summaryrefslogtreecommitdiff
path: root/helpers
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2016-02-19 12:32:45 +0000
committerJose Fonseca <jfonseca@vmware.com>2016-02-19 12:32:45 +0000
commit614c5dac5a4984f521d1e3b295880b698ba16bcc (patch)
tree5a85e654b891f59b5a3a84c9c9c0379e53c1bf23 /helpers
parent5788323b302665e2ebe0c141b52668210ed2e18f (diff)
d3d9trace,d3d9retrace: Handle D3D9Ex system memory textures.
Diffstat (limited to 'helpers')
-rw-r--r--helpers/d3dcommonsize.hpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/helpers/d3dcommonsize.hpp b/helpers/d3dcommonsize.hpp
index 766d49e8..91c794d2 100644
--- a/helpers/d3dcommonsize.hpp
+++ b/helpers/d3dcommonsize.hpp
@@ -117,8 +117,10 @@ _shaderSize(const DWORD *pFunction)
static inline void
_getFormatSize(D3DFORMAT Format, size_t & BlockSize, UINT & BlockWidth, UINT & BlockHeight);
+#define PACKED_PITCH 0x7ffffff
+
static inline size_t
-_getLockSize(D3DFORMAT Format, bool Partial, UINT Width, UINT Height, INT RowPitch, UINT Depth = 1, INT SlicePitch = 0) {
+_getLockSize(D3DFORMAT Format, bool Partial, UINT Width, UINT Height, INT RowPitch = PACKED_PITCH, UINT Depth = 1, INT SlicePitch = 0) {
if (Width == 0 || Height == 0 || Depth == 0) {
return 0;
}
@@ -132,6 +134,11 @@ _getLockSize(D3DFORMAT Format, bool Partial, UINT Width, UINT Height, INT RowPit
if (Format == MAKEFOURCC('N','V','1','2') ||
Format == MAKEFOURCC('Y','V','1','2')) {
// Planar YUV
+
+ if (RowPitch == PACKED_PITCH) {
+ RowPitch = Width;
+ }
+
size = (Height + (Height + 1)/2) * RowPitch;
} else {
size_t BlockSize;
@@ -141,13 +148,17 @@ _getLockSize(D3DFORMAT Format, bool Partial, UINT Width, UINT Height, INT RowPit
assert(BlockHeight);
Height = (Height + BlockHeight - 1) / BlockHeight;
+ if (RowPitch == PACKED_PITCH) {
+ RowPitch = ((Width + BlockWidth - 1) / BlockWidth * BlockSize + 7) / 8;
+ }
+
size = Height * RowPitch;
if (Partial || Height == 1) {
// Must take pixel size in consideration
if (BlockWidth) {
- Width = (Width + BlockWidth - 1) / BlockWidth;
- size = (Width * BlockSize + 7)/ 8;
+ Width = (Width + BlockWidth - 1) / BlockWidth;
+ size = (Width * BlockSize + 7) / 8;
if (Height > 1) {
size += (Height - 1) * RowPitch;
}