summaryrefslogtreecommitdiff
path: root/helpers
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2016-08-26 16:06:24 +0100
committerJose Fonseca <jfonseca@vmware.com>2016-09-02 18:38:50 +0100
commit595728c10471f3f0d3c7fe7fb46dc9a7c0e8562a (patch)
tree811566bbe97f215083151a9e3d71bdb1f82e1178 /helpers
parentd27737073f49ed989db5a1417122e0ada05e7961 (diff)
d3d9trace: Use smallest blobs for ATI1N/ATI2N formats.
Fixes #478.
Diffstat (limited to 'helpers')
-rw-r--r--helpers/d3d9size.hpp12
-rw-r--r--helpers/d3dcommonsize.hpp18
2 files changed, 22 insertions, 8 deletions
diff --git a/helpers/d3d9size.hpp b/helpers/d3d9size.hpp
index a6aca446..a86cf9c3 100644
--- a/helpers/d3d9size.hpp
+++ b/helpers/d3d9size.hpp
@@ -33,6 +33,8 @@
#pragma once
+#include <assert.h>
+
#include "d3dcommonsize.hpp"
@@ -158,16 +160,10 @@ _getFormatSize(D3DFORMAT Format, size_t & BlockSize, UINT & BlockWidth, UINT & B
case D3DFMT_NV12:
case D3DFMT_YV12:
- // Planar YUV
case D3DFMT_ATI1N:
case D3DFMT_ATI2N:
- /*
- * Because these are unsupported formats, RowPitch is not set to the
- * number of bytes between row of blocks, but instead in such way that
- * Height * RowPitch will match the expected size.
- */
- BlockWidth = 0;
- BlockSize = 0;
+ // Handled elsewhere
+ assert(0);
break;
case D3DFMT_UNKNOWN:
diff --git a/helpers/d3dcommonsize.hpp b/helpers/d3dcommonsize.hpp
index 91c794d2..a1d2a343 100644
--- a/helpers/d3dcommonsize.hpp
+++ b/helpers/d3dcommonsize.hpp
@@ -38,6 +38,8 @@
#include <assert.h>
+#include <algorithm>
+
#include "os.hpp"
@@ -140,6 +142,22 @@ _getLockSize(D3DFORMAT Format, bool Partial, UINT Width, UINT Height, INT RowPit
}
size = (Height + (Height + 1)/2) * RowPitch;
+ } else if (Format == MAKEFOURCC('A','T','I','1')) {
+ // 64 bits per 4x4 block, but limited to height*pitch
+
+ if (RowPitch == PACKED_PITCH) {
+ RowPitch = Width;
+ }
+
+ size = std::min(Height * RowPitch, ((Height + 3)/4) * ((Width + 3)/4) * (64 / 8));
+ } else if (Format == MAKEFOURCC('A','T','I','2')) {
+ // 128 bits per 4x4 block, but limited to height*pitch
+
+ if (RowPitch == PACKED_PITCH) {
+ RowPitch = Width;
+ }
+
+ size = std::min(Height * RowPitch, ((Height + 3)/4) * ((Width + 3)/4) * (128 / 8));
} else {
size_t BlockSize;
UINT BlockWidth;