2010-04-25 00:31:27 +00:00
|
|
|
/*
|
2009-02-09 21:15:56 +00:00
|
|
|
* Copyright (C) 2007-2009 Gabest
|
|
|
|
* http://www.gabest.org
|
|
|
|
*
|
|
|
|
* 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, or (at your option)
|
|
|
|
* any later version.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-02-09 21:15:56 +00:00
|
|
|
* 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.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-02-09 21:15:56 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNU Make; see the file COPYING. If not, write to
|
2012-09-09 18:16:11 +00:00
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
2009-02-09 21:15:56 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "GS.h"
|
|
|
|
#include "GSVector.h"
|
|
|
|
#include "GSTables.h"
|
|
|
|
#include "GSAlignedClass.h"
|
|
|
|
|
|
|
|
class GSLocalMemory;
|
|
|
|
|
2016-05-11 23:24:37 +00:00
|
|
|
class alignas(32) GSClut : public GSAlignedClass<32>
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2021-01-12 05:25:27 +00:00
|
|
|
static const GSVector4i m_bm;
|
|
|
|
static const GSVector4i m_gm;
|
|
|
|
static const GSVector4i m_rm;
|
2016-07-06 23:21:31 +00:00
|
|
|
|
2009-07-06 16:35:06 +00:00
|
|
|
GSLocalMemory* m_mem;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
uint32 m_CBP[2];
|
|
|
|
uint16* m_clut;
|
|
|
|
uint32* m_buff32;
|
|
|
|
uint64* m_buff64;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2016-05-11 23:24:37 +00:00
|
|
|
struct alignas(32) WriteState
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
GIFRegTEX0 TEX0;
|
|
|
|
GIFRegTEXCLUT TEXCLUT;
|
|
|
|
bool dirty;
|
|
|
|
bool IsDirty(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
|
|
|
} m_write;
|
|
|
|
|
2016-05-11 23:24:37 +00:00
|
|
|
struct alignas(32) ReadState
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
|
|
|
GIFRegTEX0 TEX0;
|
|
|
|
GIFRegTEXA TEXA;
|
|
|
|
bool dirty;
|
|
|
|
bool adirty;
|
|
|
|
int amin, amax;
|
|
|
|
bool IsDirty(const GIFRegTEX0& TEX0);
|
|
|
|
bool IsDirty(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA);
|
|
|
|
} m_read;
|
|
|
|
|
|
|
|
typedef void (GSClut::*writeCLUT)(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
|
|
|
|
|
|
|
writeCLUT m_wc[2][16][64];
|
|
|
|
|
|
|
|
void WriteCLUT32_I8_CSM1(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
|
|
|
void WriteCLUT32_I4_CSM1(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
|
|
|
void WriteCLUT16_I8_CSM1(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
|
|
|
void WriteCLUT16_I4_CSM1(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
|
|
|
void WriteCLUT16S_I8_CSM1(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
|
|
|
void WriteCLUT16S_I4_CSM1(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
|
|
|
|
2021-04-12 09:31:30 +00:00
|
|
|
template <int n>
|
|
|
|
void WriteCLUT32_CSM2(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
|
|
|
template <int n>
|
|
|
|
void WriteCLUT16_CSM2(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
|
|
|
template <int n>
|
|
|
|
void WriteCLUT16S_CSM2(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2020-10-26 17:22:07 +00:00
|
|
|
void WriteCLUT_NULL(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
static void WriteCLUT_T32_I8_CSM1(const uint32* RESTRICT src, uint16* RESTRICT clut);
|
|
|
|
static void WriteCLUT_T32_I4_CSM1(const uint32* RESTRICT src, uint16* RESTRICT clut);
|
|
|
|
static void WriteCLUT_T16_I8_CSM1(const uint16* RESTRICT src, uint16* RESTRICT clut);
|
|
|
|
static void WriteCLUT_T16_I4_CSM1(const uint16* RESTRICT src, uint16* RESTRICT clut);
|
|
|
|
static void ReadCLUT_T32_I8(const uint16* RESTRICT clut, uint32* RESTRICT dst);
|
|
|
|
static void ReadCLUT_T32_I4(const uint16* RESTRICT clut, uint32* RESTRICT dst);
|
2015-08-08 06:27:24 +00:00
|
|
|
//static void ReadCLUT_T32_I4(const uint16* RESTRICT clut, uint32* RESTRICT dst32, uint64* RESTRICT dst64);
|
|
|
|
//static void ReadCLUT_T16_I8(const uint16* RESTRICT clut, uint32* RESTRICT dst);
|
|
|
|
//static void ReadCLUT_T16_I4(const uint16* RESTRICT clut, uint32* RESTRICT dst);
|
|
|
|
//static void ReadCLUT_T16_I4(const uint16* RESTRICT clut, uint32* RESTRICT dst32, uint64* RESTRICT dst64);
|
2009-05-14 16:41:52 +00:00
|
|
|
static void ExpandCLUT64_T32_I8(const uint32* RESTRICT src, uint64* RESTRICT dst);
|
2009-02-09 21:15:56 +00:00
|
|
|
static void ExpandCLUT64_T32(const GSVector4i& hi, const GSVector4i& lo0, const GSVector4i& lo1, const GSVector4i& lo2, const GSVector4i& lo3, GSVector4i* dst);
|
|
|
|
static void ExpandCLUT64_T32(const GSVector4i& hi, const GSVector4i& lo, GSVector4i* dst);
|
2015-08-08 06:27:24 +00:00
|
|
|
//static void ExpandCLUT64_T16_I8(const uint32* RESTRICT src, uint64* RESTRICT dst);
|
2009-02-09 21:15:56 +00:00
|
|
|
static void ExpandCLUT64_T16(const GSVector4i& hi, const GSVector4i& lo0, const GSVector4i& lo1, const GSVector4i& lo2, const GSVector4i& lo3, GSVector4i* dst);
|
|
|
|
static void ExpandCLUT64_T16(const GSVector4i& hi, const GSVector4i& lo, GSVector4i* dst);
|
|
|
|
|
2009-05-14 16:41:52 +00:00
|
|
|
static void Expand16(const uint16* RESTRICT src, uint32* RESTRICT dst, int w, const GIFRegTEXA& TEXA);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
public:
|
2009-07-06 16:35:06 +00:00
|
|
|
GSClut(GSLocalMemory* mem);
|
2009-02-09 21:15:56 +00:00
|
|
|
virtual ~GSClut();
|
|
|
|
|
|
|
|
void Invalidate();
|
2016-09-02 22:11:56 +00:00
|
|
|
void Invalidate(uint32 block);
|
2009-02-09 21:15:56 +00:00
|
|
|
bool WriteTest(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
|
|
|
void Write(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT);
|
2015-08-08 06:27:24 +00:00
|
|
|
//void Read(const GIFRegTEX0& TEX0);
|
2009-02-09 21:15:56 +00:00
|
|
|
void Read32(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA);
|
2012-06-19 01:57:13 +00:00
|
|
|
void GetAlphaMinMax32(int& amin, int& amax);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2021-04-12 09:31:30 +00:00
|
|
|
uint32 operator[](size_t i) const { return m_buff32[i]; }
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2021-04-12 09:31:30 +00:00
|
|
|
operator const uint32*() const { return m_buff32; }
|
|
|
|
operator const uint64*() const { return m_buff64; }
|
2009-02-09 21:15:56 +00:00
|
|
|
};
|