Skip to content

Commit

Permalink
d3d9trace: Use smallest blobs for ATI1N/ATI2N formats.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfonseca committed Sep 2, 2016
1 parent d277370 commit 595728c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
12 changes: 4 additions & 8 deletions helpers/d3d9size.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#pragma once


#include <assert.h>

#include "d3dcommonsize.hpp"


Expand Down Expand Up @@ -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:
Expand Down
18 changes: 18 additions & 0 deletions helpers/d3dcommonsize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

#include <assert.h>

#include <algorithm>

#include "os.hpp"


Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 595728c

Please sign in to comment.