2010-07-10 08:20:50 +00:00
|
|
|
/* ZZ Open GL graphics plugin
|
|
|
|
* Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com
|
|
|
|
* Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
|
2010-03-19 00:31:15 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-07-04 22:49:00 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
2010-03-19 00:31:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "GS.h"
|
|
|
|
#include "Mem.h"
|
|
|
|
#include "targets.h"
|
|
|
|
#include "x86.h"
|
|
|
|
|
2010-03-20 07:24:19 +00:00
|
|
|
#include "Mem_Transmit.h"
|
|
|
|
#include "Mem_Swizzle.h"
|
2010-10-30 21:42:40 +00:00
|
|
|
#ifdef ZEROGS_SSE2
|
|
|
|
#include <emmintrin.h>
|
|
|
|
#endif
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
BLOCK m_Blocks[0x40]; // do so blocks are indexable
|
|
|
|
|
2010-03-20 07:24:19 +00:00
|
|
|
PCSX2_ALIGNED16(u32 tempblock[64]);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-03-21 06:22:55 +00:00
|
|
|
// Add a bunch of local variables that used to be in the TransferHostLocal
|
2010-04-25 00:31:27 +00:00
|
|
|
// functions, in order to de-macro the TransmitHostLocal macros.
|
2010-03-21 06:22:55 +00:00
|
|
|
// May be in a class or namespace eventually.
|
|
|
|
int tempX, tempY;
|
2010-04-25 00:31:27 +00:00
|
|
|
int pitch, area, fracX;
|
2010-03-21 06:22:55 +00:00
|
|
|
int nSize;
|
|
|
|
u8* pstart;
|
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
// ------------------------
|
|
|
|
// | Y |
|
|
|
|
// ------------------------
|
|
|
|
// | block | |
|
|
|
|
// | aligned area | X |
|
|
|
|
// | | |
|
|
|
|
// ------------------------
|
|
|
|
// | Y |
|
|
|
|
// ------------------------
|
2010-03-23 12:21:46 +00:00
|
|
|
|
|
|
|
template <class T>
|
2010-04-09 04:23:27 +00:00
|
|
|
static __forceinline const T* AlignOnBlockBoundry(TransferData data, TransferFuncts fun, Point alignedPt, int& endY, const T* pbuf)
|
2010-03-23 12:21:46 +00:00
|
|
|
{
|
2010-04-25 00:31:27 +00:00
|
|
|
bool bCanAlign = ((MOD_POW2(gs.trxpos.dx, data.blockwidth) == 0) && (gs.imageX == gs.trxpos.dx) &&
|
|
|
|
(alignedPt.y > endY) && (alignedPt.x > gs.trxpos.dx));
|
|
|
|
|
|
|
|
if ((gs.imageEndX - gs.trxpos.dx) % data.widthlimit)
|
|
|
|
{
|
|
|
|
/* hack */
|
|
|
|
int testwidth = (int)nSize -
|
2010-05-01 20:33:53 +00:00
|
|
|
(gs.imageEndY - gs.imageY) * (gs.imageEndX - gs.trxpos.dx)
|
|
|
|
+ (gs.imageX - gs.trxpos.dx);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
|
|
|
if ((testwidth <= data.widthlimit) && (testwidth >= -data.widthlimit))
|
|
|
|
{
|
|
|
|
/* don't transfer */
|
2010-04-25 08:33:05 +00:00
|
|
|
/*ZZLog::Debug_Log("Bad texture %s: %d %d %d", #psm, gs.trxpos.dx, gs.imageEndX, nQWordSize);*/
|
|
|
|
//ZZLog::Error_Log("Bad texture: testwidth = %d; data.widthlimit = %d", testwidth, data.widthlimit);
|
2010-04-25 00:31:27 +00:00
|
|
|
gs.imageTransfer = -1;
|
|
|
|
}
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
bCanAlign = false;
|
|
|
|
}
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
/* first align on block boundary */
|
2010-05-01 20:33:53 +00:00
|
|
|
if (MOD_POW2(gs.imageY, data.blockheight) || !bCanAlign)
|
2010-04-25 00:31:27 +00:00
|
|
|
{
|
2010-03-23 12:21:46 +00:00
|
|
|
u32 transwidth;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-05-01 20:33:53 +00:00
|
|
|
if (!bCanAlign)
|
2010-04-25 00:31:27 +00:00
|
|
|
endY = gs.imageEndY; /* transfer the whole image */
|
|
|
|
else
|
2010-05-01 20:33:53 +00:00
|
|
|
assert(endY < gs.imageEndY); /* part of alignment condition */
|
2010-04-25 00:31:27 +00:00
|
|
|
|
|
|
|
if (((gs.imageEndX - gs.trxpos.dx) % data.widthlimit) || ((gs.imageEndX - gs.imageX) % data.widthlimit))
|
|
|
|
{
|
|
|
|
/* transmit with a width of 1 */
|
2010-04-09 04:23:27 +00:00
|
|
|
transwidth = (1 + (DSTPSM == PSMT4));
|
2010-04-25 00:31:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-03-23 12:21:46 +00:00
|
|
|
transwidth = data.widthlimit;
|
2010-04-25 00:31:27 +00:00
|
|
|
}
|
|
|
|
|
2010-07-18 03:45:28 +00:00
|
|
|
pbuf = TransmitHostLocalY<T>(data.psm, fun.wp, transwidth, endY, pbuf);
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-04-07 11:59:03 +00:00
|
|
|
if (pbuf == NULL) return NULL;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-05-01 20:33:53 +00:00
|
|
|
if (nSize == 0 || tempY == gs.imageEndY) return NULL;
|
2010-04-25 00:31:27 +00:00
|
|
|
}
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-04-07 11:59:03 +00:00
|
|
|
return pbuf;
|
2010-03-23 12:21:46 +00:00
|
|
|
}
|
2010-03-20 07:24:19 +00:00
|
|
|
|
2010-03-23 12:21:46 +00:00
|
|
|
template <class T>
|
2010-04-09 04:23:27 +00:00
|
|
|
static __forceinline const T* TransferAligningToBlocks(TransferData data, TransferFuncts fun, Point alignedPt, const T* pbuf)
|
2010-03-23 12:21:46 +00:00
|
|
|
{
|
|
|
|
bool bAligned;
|
|
|
|
const u32 TSize = sizeof(T);
|
|
|
|
_SwizzleBlock swizzle;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
|
|
|
/* can align! */
|
|
|
|
pitch = gs.imageEndX - gs.trxpos.dx;
|
|
|
|
area = pitch * data.blockheight;
|
|
|
|
fracX = gs.imageEndX - alignedPt.x;
|
|
|
|
|
|
|
|
/* on top of checking whether pbuf is aligned, make sure that the width is at least aligned to its limits (due to bugs in pcsx2) */
|
|
|
|
bAligned = !((uptr)pbuf & 0xf) && (TransPitch(pitch, data.transfersize) & 0xf) == 0;
|
|
|
|
|
2010-05-01 20:33:53 +00:00
|
|
|
if (bAligned || ((DSTPSM == PSMCT24) || (DSTPSM == PSMT8H) || (DSTPSM == PSMT4HH) || (DSTPSM == PSMT4HL)))
|
2010-04-15 22:03:23 +00:00
|
|
|
swizzle = (fun.Swizzle);
|
2010-04-25 00:31:27 +00:00
|
|
|
else
|
2010-04-15 22:03:23 +00:00
|
|
|
swizzle = (fun.Swizzle_u);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-04-15 22:03:23 +00:00
|
|
|
//Transfer aligning to blocks.
|
2010-05-01 20:33:53 +00:00
|
|
|
for (; tempY < alignedPt.y && nSize >= area; tempY += data.blockheight, nSize -= area)
|
2010-04-25 00:31:27 +00:00
|
|
|
{
|
2010-05-01 20:33:53 +00:00
|
|
|
for (int tempj = gs.trxpos.dx; tempj < alignedPt.x; tempj += data.blockwidth, pbuf += TransPitch(data.blockwidth, data.transfersize) / TSize)
|
2010-04-25 00:31:27 +00:00
|
|
|
{
|
2010-05-01 20:33:53 +00:00
|
|
|
u8 *temp = pstart + fun.gp(tempj, tempY, gs.dstbuf.bw) * data.blockbits / 8;
|
|
|
|
swizzle(temp, (u8*)pbuf, TransPitch(pitch, data.transfersize), 0xffffffff);
|
2010-04-25 00:31:27 +00:00
|
|
|
}
|
2010-10-30 21:42:40 +00:00
|
|
|
#ifdef ZEROGS_SSE2
|
|
|
|
// Note: swizzle function uses some non temporal move (mm_stream) instruction.
|
|
|
|
// store fence insures that previous store are finish before execute new one.
|
|
|
|
_mm_sfence();
|
|
|
|
|
|
|
|
#endif
|
2010-04-25 00:31:27 +00:00
|
|
|
|
|
|
|
/* transfer the rest */
|
2010-04-15 22:03:23 +00:00
|
|
|
if (alignedPt.x < gs.imageEndX)
|
2010-04-25 00:31:27 +00:00
|
|
|
{
|
2010-07-18 03:45:28 +00:00
|
|
|
pbuf = TransmitHostLocalX<T>(data.psm, fun.wp, data.widthlimit, data.blockheight, alignedPt.x, pbuf);
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-04-07 11:59:03 +00:00
|
|
|
if (pbuf == NULL) return NULL;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-05-01 20:33:53 +00:00
|
|
|
pbuf -= TransPitch((alignedPt.x - gs.trxpos.dx), data.transfersize) / TSize;
|
2010-04-25 00:31:27 +00:00
|
|
|
}
|
|
|
|
else
|
2010-03-20 07:24:19 +00:00
|
|
|
{
|
2010-05-01 20:33:53 +00:00
|
|
|
pbuf += (data.blockheight - 1) * TransPitch(pitch, data.transfersize) / TSize;
|
2010-03-20 07:24:19 +00:00
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
|
|
|
tempX = gs.trxpos.dx;
|
2010-04-15 22:03:23 +00:00
|
|
|
}
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-04-07 11:59:03 +00:00
|
|
|
return pbuf;
|
2010-03-23 12:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static __forceinline int FinishTransfer(TransferData data, int nLeftOver)
|
|
|
|
{
|
2010-05-01 20:33:53 +00:00
|
|
|
if (tempY >= gs.imageEndY)
|
2010-04-25 00:31:27 +00:00
|
|
|
{
|
2010-05-01 20:33:53 +00:00
|
|
|
assert(gs.imageTransfer == -1 || tempY == gs.imageEndY);
|
2010-04-25 00:31:27 +00:00
|
|
|
gs.imageTransfer = -1;
|
|
|
|
/*int start, end;
|
2010-10-16 11:54:46 +00:00
|
|
|
GetRectMemAddress(start, end, gs.dstbuf.psm, gs.trxpos.dx, gs.trxpos.dy, gs.imageWnew, gs.imageHnew, gs.dstbuf.bp, gs.dstbuf.bw);
|
|
|
|
g_MemTargs.ClearRange(start, end);*/
|
2010-04-25 00:31:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* update new params */
|
|
|
|
gs.imageY = tempY;
|
|
|
|
gs.imageX = tempX;
|
|
|
|
}
|
|
|
|
|
2010-05-01 20:33:53 +00:00
|
|
|
return (nSize * TransPitch(2, data.transfersize) + nLeftOver) / 2;
|
2010-03-23 12:21:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
2010-07-18 04:53:50 +00:00
|
|
|
static __forceinline int RealTransfer(u32 psm, const void* pbyMem, u32 nQWordSize)
|
2010-03-23 12:21:46 +00:00
|
|
|
{
|
2010-05-01 20:33:53 +00:00
|
|
|
assert(gs.imageTransfer == 0);
|
2010-07-18 04:53:50 +00:00
|
|
|
TransferData data = tData[psm];
|
2010-07-19 11:17:46 +00:00
|
|
|
TransferFuncts fun(psm);
|
2010-05-01 20:33:53 +00:00
|
|
|
pstart = g_pbyGSMemory + gs.dstbuf.bp * 256;
|
2010-04-25 00:31:27 +00:00
|
|
|
const T* pbuf = (const T*)pbyMem;
|
2010-03-23 12:21:46 +00:00
|
|
|
const int tp2 = TransPitch(2, data.transfersize);
|
2010-05-01 20:33:53 +00:00
|
|
|
int nLeftOver = (nQWordSize * 4 * 2) % tp2;
|
|
|
|
tempY = gs.imageY;
|
|
|
|
tempX = gs.imageX;
|
2010-03-23 12:21:46 +00:00
|
|
|
Point alignedPt;
|
2010-09-15 17:09:03 +00:00
|
|
|
|
2010-05-01 20:33:53 +00:00
|
|
|
nSize = (nQWordSize * 4 * 2) / tp2;
|
2010-04-25 00:31:27 +00:00
|
|
|
nSize = min(nSize, gs.imageWnew * gs.imageHnew);
|
|
|
|
|
|
|
|
int endY = ROUND_UPPOW2(gs.imageY, data.blockheight);
|
|
|
|
alignedPt.y = ROUND_DOWNPOW2(gs.imageEndY, data.blockheight);
|
|
|
|
alignedPt.x = ROUND_DOWNPOW2(gs.imageEndX, data.blockwidth);
|
|
|
|
|
2010-04-09 04:23:27 +00:00
|
|
|
pbuf = AlignOnBlockBoundry<T>(data, fun, alignedPt, endY, pbuf);
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-04-07 11:59:03 +00:00
|
|
|
if (pbuf == NULL) return FinishTransfer(data, nLeftOver);
|
2010-03-23 12:21:46 +00:00
|
|
|
|
2010-04-09 04:23:27 +00:00
|
|
|
pbuf = TransferAligningToBlocks<T>(data, fun, alignedPt, pbuf);
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-04-07 11:59:03 +00:00
|
|
|
if (pbuf == NULL) return FinishTransfer(data, nLeftOver);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-05-01 20:33:53 +00:00
|
|
|
if (TransPitch(nSize, data.transfersize) / 4 > 0)
|
2010-04-25 00:31:27 +00:00
|
|
|
{
|
2010-07-19 11:17:46 +00:00
|
|
|
pbuf = TransmitHostLocalY<T>(psm, fun.wp, data.widthlimit, gs.imageEndY, pbuf);
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-04-09 04:23:27 +00:00
|
|
|
if (pbuf == NULL) return FinishTransfer(data, nLeftOver);
|
2010-05-01 20:33:53 +00:00
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
/* sometimes wrong sizes are sent (tekken tag) */
|
2010-05-01 20:33:53 +00:00
|
|
|
assert(gs.imageTransfer == -1 || TransPitch(nSize, data.transfersize) / 4 <= 2);
|
2010-04-25 00:31:27 +00:00
|
|
|
}
|
|
|
|
|
2010-03-23 12:21:46 +00:00
|
|
|
return FinishTransfer(data, nLeftOver);
|
|
|
|
}
|
|
|
|
|
2010-07-18 04:53:50 +00:00
|
|
|
int TransferHostLocal32(const void* pbyMem, u32 nQWordSize) { return RealTransfer<u32>(PSMCT32, pbyMem, nQWordSize); }
|
|
|
|
int TransferHostLocal32Z(const void* pbyMem, u32 nQWordSize) { return RealTransfer<u32>(PSMT32Z, pbyMem, nQWordSize); }
|
|
|
|
int TransferHostLocal24(const void* pbyMem, u32 nQWordSize) { return RealTransfer<u8>(PSMCT24, pbyMem, nQWordSize); }
|
|
|
|
int TransferHostLocal24Z(const void* pbyMem, u32 nQWordSize) { return RealTransfer<u8>(PSMT24Z, pbyMem, nQWordSize); }
|
|
|
|
int TransferHostLocal16(const void* pbyMem, u32 nQWordSize) { return RealTransfer<u16>(PSMCT16, pbyMem, nQWordSize); }
|
|
|
|
int TransferHostLocal16S(const void* pbyMem, u32 nQWordSize) { return RealTransfer<u16>(PSMCT16S, pbyMem, nQWordSize); }
|
|
|
|
int TransferHostLocal16Z(const void* pbyMem, u32 nQWordSize) { return RealTransfer<u16>(PSMT16Z, pbyMem, nQWordSize); }
|
|
|
|
int TransferHostLocal16SZ(const void* pbyMem, u32 nQWordSize){ return RealTransfer<u16>(PSMT16SZ, pbyMem, nQWordSize); }
|
|
|
|
int TransferHostLocal8(const void* pbyMem, u32 nQWordSize) { return RealTransfer<u8>(PSMT8, pbyMem, nQWordSize); }
|
|
|
|
int TransferHostLocal4(const void* pbyMem, u32 nQWordSize) { return RealTransfer<u8>(PSMT4, pbyMem, nQWordSize); }
|
|
|
|
int TransferHostLocal8H(const void* pbyMem, u32 nQWordSize) { return RealTransfer<u8>(PSMT8H, pbyMem, nQWordSize); }
|
|
|
|
int TransferHostLocal4HL(const void* pbyMem, u32 nQWordSize) { return RealTransfer<u8>(PSMT4HL, pbyMem, nQWordSize); }
|
|
|
|
int TransferHostLocal4HH(const void* pbyMem, u32 nQWordSize) { return RealTransfer<u8>(PSMT4HH, pbyMem, nQWordSize); }
|
2010-03-23 12:21:46 +00:00
|
|
|
|
2010-07-19 11:17:46 +00:00
|
|
|
void TransferLocalHost32(void* pbyMem, u32 nQWordSize) {FUNCLOG}
|
2010-04-09 04:23:27 +00:00
|
|
|
void TransferLocalHost24(void* pbyMem, u32 nQWordSize) {FUNCLOG}
|
|
|
|
void TransferLocalHost16(void* pbyMem, u32 nQWordSize) {FUNCLOG}
|
|
|
|
void TransferLocalHost16S(void* pbyMem, u32 nQWordSize) {FUNCLOG}
|
2010-07-19 11:17:46 +00:00
|
|
|
void TransferLocalHost8(void* pbyMem, u32 nQWordSize) {FUNCLOG}
|
2010-04-09 04:23:27 +00:00
|
|
|
void TransferLocalHost4(void* pbyMem, u32 nQWordSize) {FUNCLOG}
|
|
|
|
void TransferLocalHost8H(void* pbyMem, u32 nQWordSize) {FUNCLOG}
|
|
|
|
void TransferLocalHost4HL(void* pbyMem, u32 nQWordSize) {FUNCLOG}
|
2010-07-19 11:17:46 +00:00
|
|
|
void TransferLocalHost4HH(void* pbyMem, u32 nQWordSize) {FUNCLOG}
|
2010-04-09 04:23:27 +00:00
|
|
|
void TransferLocalHost32Z(void* pbyMem, u32 nQWordSize) {FUNCLOG}
|
|
|
|
void TransferLocalHost24Z(void* pbyMem, u32 nQWordSize) {FUNCLOG}
|
|
|
|
void TransferLocalHost16Z(void* pbyMem, u32 nQWordSize) {FUNCLOG}
|
|
|
|
void TransferLocalHost16SZ(void* pbyMem, u32 nQWordSize) {FUNCLOG}
|
2010-03-19 00:31:15 +00:00
|
|
|
|
2010-09-15 17:09:03 +00:00
|
|
|
void fill_block(BLOCK b, vector<char>& vBlockData, vector<char>& vBilinearData, int floatfmt)
|
2010-03-19 00:31:15 +00:00
|
|
|
{
|
2010-09-15 17:09:03 +00:00
|
|
|
float* psrcf = (float*)&vBlockData[0] + b.ox + b.oy * BLOCK_TEXWIDTH;
|
|
|
|
u16* psrcw = NULL;
|
|
|
|
if (!floatfmt)
|
|
|
|
psrcw = (u16*)&vBlockData[0] + b.ox + b.oy * BLOCK_TEXWIDTH;
|
2010-07-19 11:17:46 +00:00
|
|
|
|
2010-09-15 17:09:03 +00:00
|
|
|
for(int i = 0; i < b.height; ++i)
|
|
|
|
{
|
|
|
|
u32 i_width = i*BLOCK_TEXWIDTH;
|
|
|
|
for(int j = 0; j < b.width; ++j)
|
|
|
|
{
|
|
|
|
/* fill the table */
|
|
|
|
u32 bt = b.blockTable[(i / b.colheight)*(b.width/b.colwidth) + (j / b.colwidth)];
|
|
|
|
u32 ct = b.columnTable[(i%b.colheight)*b.colwidth + (j%b.colwidth)];
|
|
|
|
u32 u = bt * 64 * b.mult + ct;
|
|
|
|
b.pageTable[i * b.width + j] = u;
|
|
|
|
if (floatfmt)
|
|
|
|
psrcf[i_width + j] = (float)(u) / (float)(GPU_TEXWIDTH * b.mult);
|
|
|
|
else
|
|
|
|
psrcw[i_width + j] = u;
|
2010-07-19 11:17:46 +00:00
|
|
|
|
2010-09-15 17:09:03 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-19 11:17:46 +00:00
|
|
|
|
2010-09-15 17:09:03 +00:00
|
|
|
if (floatfmt) {
|
2010-09-19 08:01:48 +00:00
|
|
|
float4* psrcv = (float4*)&vBilinearData[0] + b.ox + b.oy * BLOCK_TEXWIDTH;
|
2010-09-15 17:09:03 +00:00
|
|
|
|
|
|
|
for(int i = 0; i < b.height; ++i)
|
|
|
|
{
|
|
|
|
u32 i_width = i*BLOCK_TEXWIDTH;
|
|
|
|
u32 i_width2 = ((i+1)%b.height)*BLOCK_TEXWIDTH;
|
|
|
|
for(int j = 0; j < b.width; ++j)
|
|
|
|
{
|
|
|
|
u32 temp = ((j + 1) % b.width);
|
2010-09-19 08:01:48 +00:00
|
|
|
float4* pv = &psrcv[i_width + j];
|
2010-09-15 17:09:03 +00:00
|
|
|
pv->x = psrcf[i_width + j];
|
|
|
|
pv->y = psrcf[i_width + temp];
|
|
|
|
pv->z = psrcf[i_width2 + j];
|
|
|
|
pv->w = psrcf[i_width2 + temp];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-19 11:17:46 +00:00
|
|
|
}
|
|
|
|
|
2010-09-15 17:09:03 +00:00
|
|
|
void BLOCK::FillBlocks(vector<char>& vBlockData, vector<char>& vBilinearData, int floatfmt)
|
2010-07-19 11:17:46 +00:00
|
|
|
{
|
|
|
|
FUNCLOG
|
2010-09-15 17:09:03 +00:00
|
|
|
if (floatfmt) {
|
|
|
|
vBlockData.resize(BLOCK_TEXWIDTH * BLOCK_TEXHEIGHT * 4);
|
2010-09-19 08:01:48 +00:00
|
|
|
vBilinearData.resize(BLOCK_TEXWIDTH * BLOCK_TEXHEIGHT * sizeof(float4));
|
2010-09-15 17:09:03 +00:00
|
|
|
} else {
|
|
|
|
vBlockData.resize(BLOCK_TEXWIDTH * BLOCK_TEXHEIGHT * 2);
|
|
|
|
}
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
BLOCK b;
|
|
|
|
|
|
|
|
memset(m_Blocks, 0, sizeof(m_Blocks));
|
|
|
|
|
|
|
|
// 32
|
2010-07-19 11:17:46 +00:00
|
|
|
b.SetDim(64, 32, 0, 0, 1);
|
2010-09-15 17:09:03 +00:00
|
|
|
b.SetTable(PSMCT32);
|
|
|
|
fill_block(b, vBlockData, vBilinearData, floatfmt);
|
2010-03-19 00:31:15 +00:00
|
|
|
m_Blocks[PSMCT32] = b;
|
2010-07-18 06:59:23 +00:00
|
|
|
m_Blocks[PSMCT32].SetFun(PSMCT32);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
// 24 (same as 32 except write/readPixel are different)
|
|
|
|
m_Blocks[PSMCT24] = b;
|
2010-07-18 06:59:23 +00:00
|
|
|
m_Blocks[PSMCT24].SetFun(PSMCT24);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
// 8H (same as 32 except write/readPixel are different)
|
|
|
|
m_Blocks[PSMT8H] = b;
|
2010-07-18 06:59:23 +00:00
|
|
|
m_Blocks[PSMT8H].SetFun(PSMT8H);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
m_Blocks[PSMT4HL] = b;
|
2010-07-18 06:59:23 +00:00
|
|
|
m_Blocks[PSMT4HL].SetFun(PSMT4HL);
|
2010-09-15 17:09:03 +00:00
|
|
|
|
2010-03-19 00:31:15 +00:00
|
|
|
m_Blocks[PSMT4HH] = b;
|
2010-07-18 06:59:23 +00:00
|
|
|
m_Blocks[PSMT4HH].SetFun(PSMT4HH);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
// 32z
|
2010-07-19 11:17:46 +00:00
|
|
|
b.SetDim(64, 32, 64, 0, 1);
|
2010-09-15 17:09:03 +00:00
|
|
|
b.SetTable(PSMT32Z);
|
|
|
|
fill_block(b, vBlockData, vBilinearData, floatfmt);
|
2010-03-19 00:31:15 +00:00
|
|
|
m_Blocks[PSMT32Z] = b;
|
2010-07-18 06:59:23 +00:00
|
|
|
m_Blocks[PSMT32Z].SetFun(PSMT32Z);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
// 24Z (same as 32Z except write/readPixel are different)
|
|
|
|
m_Blocks[PSMT24Z] = b;
|
2010-07-18 06:59:23 +00:00
|
|
|
m_Blocks[PSMT24Z].SetFun(PSMT24Z);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
// 16
|
2010-07-19 11:17:46 +00:00
|
|
|
b.SetDim(64, 64, 0, 32, 2);
|
2010-09-15 17:09:03 +00:00
|
|
|
b.SetTable(PSMCT16);
|
|
|
|
fill_block(b, vBlockData, vBilinearData, floatfmt);
|
2010-03-19 00:31:15 +00:00
|
|
|
m_Blocks[PSMCT16] = b;
|
2010-07-18 06:59:23 +00:00
|
|
|
m_Blocks[PSMCT16].SetFun(PSMCT16);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
// 16s
|
2010-07-19 11:17:46 +00:00
|
|
|
b.SetDim(64, 64, 64, 32, 2);
|
2010-09-15 17:09:03 +00:00
|
|
|
b.SetTable(PSMCT16S);
|
|
|
|
fill_block(b, vBlockData, vBilinearData, floatfmt);
|
2010-03-19 00:31:15 +00:00
|
|
|
m_Blocks[PSMCT16S] = b;
|
2010-07-18 06:59:23 +00:00
|
|
|
m_Blocks[PSMCT16S].SetFun(PSMCT16S);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
// 16z
|
2010-07-19 11:17:46 +00:00
|
|
|
b.SetDim(64, 64, 0, 96, 2);
|
2010-09-15 17:09:03 +00:00
|
|
|
b.SetTable(PSMT16Z);
|
|
|
|
fill_block(b, vBlockData, vBilinearData, floatfmt);
|
2010-03-19 00:31:15 +00:00
|
|
|
m_Blocks[PSMT16Z] = b;
|
2010-07-18 06:59:23 +00:00
|
|
|
m_Blocks[PSMT16Z].SetFun(PSMT16Z);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
// 16sz
|
2010-07-19 11:17:46 +00:00
|
|
|
b.SetDim(64, 64, 64, 96, 2);
|
2010-09-15 17:09:03 +00:00
|
|
|
b.SetTable(PSMT16SZ);
|
|
|
|
fill_block(b, vBlockData, vBilinearData, floatfmt);
|
2010-03-19 00:31:15 +00:00
|
|
|
m_Blocks[PSMT16SZ] = b;
|
2010-07-18 06:59:23 +00:00
|
|
|
m_Blocks[PSMT16SZ].SetFun(PSMT16SZ);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
// 8
|
2010-07-19 11:17:46 +00:00
|
|
|
b.SetDim(128, 64, 0, 160, 4);
|
2010-09-15 17:09:03 +00:00
|
|
|
b.SetTable(PSMT8);
|
|
|
|
fill_block(b, vBlockData, vBilinearData, floatfmt);
|
2010-03-19 00:31:15 +00:00
|
|
|
m_Blocks[PSMT8] = b;
|
2010-07-18 06:59:23 +00:00
|
|
|
m_Blocks[PSMT8].SetFun(PSMT8);
|
2010-03-19 00:31:15 +00:00
|
|
|
|
|
|
|
// 4
|
2010-07-19 11:17:46 +00:00
|
|
|
b.SetDim(128, 128, 0, 224, 8);
|
2010-09-15 17:09:03 +00:00
|
|
|
b.SetTable(PSMT4);
|
|
|
|
fill_block(b, vBlockData, vBilinearData, floatfmt);
|
2010-03-19 00:31:15 +00:00
|
|
|
m_Blocks[PSMT4] = b;
|
2010-07-18 06:59:23 +00:00
|
|
|
m_Blocks[PSMT4].SetFun(PSMT4);
|
2010-03-19 00:31:15 +00:00
|
|
|
}
|