added option to use XFB in GL, but XFB support still needs work. modified viewport to include scissor offset.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@879 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
70eebcb3a3
commit
bbbe898839
|
@ -32,9 +32,12 @@ namespace VideoInterface
|
||||||
// VI Internal Hardware Addresses
|
// VI Internal Hardware Addresses
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
VI_VERTICAL_TIMING = 0x0,
|
||||||
VI_CONTROL_REGISTER = 0x02,
|
VI_CONTROL_REGISTER = 0x02,
|
||||||
VI_FRAMEBUFFER_1 = 0x01C,
|
VI_FRAMEBUFFER_TOP_HI = 0x01C,
|
||||||
VI_FRAMEBUFFER_2 = 0x024,
|
VI_FRAMEBUFFER_TOP_LO = 0x01E,
|
||||||
|
VI_FRAMEBUFFER_BOTTOM_HI = 0x024,
|
||||||
|
VI_FRAMEBUFFER_BOTTOM_LO = 0x026,
|
||||||
VI_VERTICAL_BEAM_POSITION = 0x02C,
|
VI_VERTICAL_BEAM_POSITION = 0x02C,
|
||||||
VI_HORIZONTAL_BEAM_POSITION = 0x02e,
|
VI_HORIZONTAL_BEAM_POSITION = 0x02e,
|
||||||
VI_PRERETRACE = 0x030,
|
VI_PRERETRACE = 0x030,
|
||||||
|
@ -42,8 +45,22 @@ enum
|
||||||
VI_DI2 = 0x038,
|
VI_DI2 = 0x038,
|
||||||
VI_DI3 = 0x03C,
|
VI_DI3 = 0x03C,
|
||||||
VI_INTERLACE = 0x850,
|
VI_INTERLACE = 0x850,
|
||||||
VI_HSCALEW = 0x04A,
|
VI_HSCALEW = 0x048,
|
||||||
VI_HSCALER = 0x04C,
|
VI_HSCALER = 0x04A,
|
||||||
|
VI_FBWIDTH = 0x070,
|
||||||
|
};
|
||||||
|
|
||||||
|
union UVIVerticalTimingRegister
|
||||||
|
{
|
||||||
|
u16 Hex;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned EQU : 4;
|
||||||
|
unsigned ACV : 10;
|
||||||
|
unsigned : 2;
|
||||||
|
};
|
||||||
|
UVIVerticalTimingRegister(u16 _hex) { Hex = _hex;}
|
||||||
|
UVIVerticalTimingRegister() { Hex = 0;}
|
||||||
};
|
};
|
||||||
|
|
||||||
union UVIDisplayControlRegister
|
union UVIDisplayControlRegister
|
||||||
|
@ -85,16 +102,57 @@ union UVIInterruptRegister
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
union UVIHorizontalStepping
|
||||||
|
{
|
||||||
|
u16 Hex;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned FbSteps : 8;
|
||||||
|
unsigned FieldSteps : 8;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
union UVIHorizontalScaling
|
||||||
|
{
|
||||||
|
u16 Hex;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
unsigned STP : 9;
|
||||||
|
unsigned : 3;
|
||||||
|
unsigned HS_EN : 1;
|
||||||
|
unsigned : 3;
|
||||||
|
};
|
||||||
|
UVIHorizontalScaling(u16 _hex) { Hex = _hex;}
|
||||||
|
UVIHorizontalScaling() { Hex = 0;}
|
||||||
|
};
|
||||||
|
|
||||||
|
union UVIFrameBufferAddress
|
||||||
|
{
|
||||||
|
u32 Hex;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
u16 Lo;
|
||||||
|
u16 Hi;
|
||||||
|
};
|
||||||
|
UVIFrameBufferAddress(u16 _hex) { Hex = _hex;}
|
||||||
|
UVIFrameBufferAddress() { Hex = 0;}
|
||||||
|
};
|
||||||
|
|
||||||
// STATE_TO_SAVE
|
// STATE_TO_SAVE
|
||||||
|
static UVIVerticalTimingRegister m_VIVerticalTimingRegister;
|
||||||
|
|
||||||
static UVIDisplayControlRegister m_VIDisplayControlRegister;
|
static UVIDisplayControlRegister m_VIDisplayControlRegister;
|
||||||
|
|
||||||
// Framebuffers
|
// Framebuffers
|
||||||
static u32 m_FrameBuffer1; // normal framebuffer address
|
static UVIFrameBufferAddress m_FrameBufferTop; // normal framebuffer address
|
||||||
static u32 m_FrameBuffer2; // framebuffer for 3d buffer address
|
static UVIFrameBufferAddress m_FrameBufferBottom;
|
||||||
|
|
||||||
// VI Interrupt Registers
|
// VI Interrupt Registers
|
||||||
static UVIInterruptRegister m_VIInterruptRegister[4];
|
static UVIInterruptRegister m_VIInterruptRegister[4];
|
||||||
|
|
||||||
|
static UVIHorizontalStepping m_VIHorizontalStepping;
|
||||||
|
static UVIHorizontalScaling m_VIHorizontalScaling;
|
||||||
|
|
||||||
u8 m_UVIUnknownRegs[0x1000];
|
u8 m_UVIUnknownRegs[0x1000];
|
||||||
|
|
||||||
static u16 HorizontalBeamPos = 0;
|
static u16 HorizontalBeamPos = 0;
|
||||||
|
@ -102,19 +160,26 @@ static u16 VerticalBeamPos = 0;
|
||||||
|
|
||||||
static u32 TicksPerFrame = 0;
|
static u32 TicksPerFrame = 0;
|
||||||
static u32 LineCount = 0;
|
static u32 LineCount = 0;
|
||||||
|
static u32 LinesPerField = 0;
|
||||||
static u64 LastTime = 0;
|
static u64 LastTime = 0;
|
||||||
|
static u32 NextXFBRender = 0;
|
||||||
|
|
||||||
|
// only correct when scaling is enabled?
|
||||||
|
static u16 FbWidth = 0;
|
||||||
|
|
||||||
void DoState(PointerWrap &p)
|
void DoState(PointerWrap &p)
|
||||||
{
|
{
|
||||||
|
p.Do(m_VIVerticalTimingRegister);
|
||||||
p.Do(m_VIDisplayControlRegister);
|
p.Do(m_VIDisplayControlRegister);
|
||||||
p.Do(m_FrameBuffer1);
|
p.Do(m_FrameBufferTop);
|
||||||
p.Do(m_FrameBuffer2);
|
p.Do(m_FrameBufferBottom);
|
||||||
p.Do(m_VIInterruptRegister);
|
p.Do(m_VIInterruptRegister);
|
||||||
p.DoArray(m_UVIUnknownRegs, 0x1000);
|
p.DoArray(m_UVIUnknownRegs, 0x1000);
|
||||||
p.Do(HorizontalBeamPos);
|
p.Do(HorizontalBeamPos);
|
||||||
p.Do(VerticalBeamPos);
|
p.Do(VerticalBeamPos);
|
||||||
p.Do(TicksPerFrame);
|
p.Do(TicksPerFrame);
|
||||||
p.Do(LineCount);
|
p.Do(LineCount);
|
||||||
|
p.Do(LinesPerField);
|
||||||
p.Do(LastTime);
|
p.Do(LastTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,17 +191,39 @@ void Init()
|
||||||
m_VIDisplayControlRegister.Hex = 0x0000;
|
m_VIDisplayControlRegister.Hex = 0x0000;
|
||||||
m_VIDisplayControlRegister.ENB = 0;
|
m_VIDisplayControlRegister.ENB = 0;
|
||||||
m_VIDisplayControlRegister.FMT = 0;
|
m_VIDisplayControlRegister.FMT = 0;
|
||||||
|
|
||||||
|
NextXFBRender = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Read16(u16& _uReturnValue, const u32 _iAddress)
|
void Read16(u16& _uReturnValue, const u32 _iAddress)
|
||||||
{
|
{
|
||||||
switch (_iAddress & 0xFFF)
|
switch (_iAddress & 0xFFF)
|
||||||
{
|
{
|
||||||
|
case VI_VERTICAL_TIMING:
|
||||||
|
_uReturnValue = m_VIVerticalTimingRegister.Hex;
|
||||||
|
return;
|
||||||
|
|
||||||
case VI_CONTROL_REGISTER:
|
case VI_CONTROL_REGISTER:
|
||||||
LOG(VIDEOINTERFACE, "VideoInterface(r16): VI_CONTROL_REGISTER 0x%08x", m_VIDisplayControlRegister.Hex);
|
LOG(VIDEOINTERFACE, "VideoInterface(r16): VI_CONTROL_REGISTER 0x%08x", m_VIDisplayControlRegister.Hex);
|
||||||
_uReturnValue = m_VIDisplayControlRegister.Hex;
|
_uReturnValue = m_VIDisplayControlRegister.Hex;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case VI_FRAMEBUFFER_TOP_HI:
|
||||||
|
_uReturnValue = m_FrameBufferTop.Hi;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VI_FRAMEBUFFER_TOP_LO:
|
||||||
|
_uReturnValue = m_FrameBufferTop.Lo;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VI_FRAMEBUFFER_BOTTOM_HI:
|
||||||
|
_uReturnValue = m_FrameBufferBottom.Hi;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VI_FRAMEBUFFER_BOTTOM_LO:
|
||||||
|
_uReturnValue = m_FrameBufferBottom.Lo;
|
||||||
|
break;
|
||||||
|
|
||||||
case VI_VERTICAL_BEAM_POSITION:
|
case VI_VERTICAL_BEAM_POSITION:
|
||||||
_uReturnValue = VerticalBeamPos;
|
_uReturnValue = VerticalBeamPos;
|
||||||
return;
|
return;
|
||||||
|
@ -154,15 +241,27 @@ void Read16(u16& _uReturnValue, const u32 _iAddress)
|
||||||
_uReturnValue = m_VIInterruptRegister[1].Hi;
|
_uReturnValue = m_VIInterruptRegister[1].Hi;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 0x38:
|
case VI_DI2:
|
||||||
_uReturnValue = m_VIInterruptRegister[2].Hi;
|
_uReturnValue = m_VIInterruptRegister[2].Hi;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 0x3C:
|
case VI_DI3:
|
||||||
_uReturnValue = m_VIInterruptRegister[3].Hi;
|
_uReturnValue = m_VIInterruptRegister[3].Hi;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
case VI_HSCALEW:
|
||||||
|
_uReturnValue = m_VIHorizontalStepping.Hex;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VI_HSCALER:
|
||||||
|
_uReturnValue = m_VIHorizontalScaling.Hex;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VI_FBWIDTH:
|
||||||
|
_uReturnValue = FbWidth;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
_uReturnValue = *(u16*)&m_UVIUnknownRegs[_iAddress & 0xFFF];
|
_uReturnValue = *(u16*)&m_UVIUnknownRegs[_iAddress & 0xFFF];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -178,6 +277,10 @@ void Write16(const u16 _iValue, const u32 _iAddress)
|
||||||
|
|
||||||
switch (_iAddress & 0xFFF)
|
switch (_iAddress & 0xFFF)
|
||||||
{
|
{
|
||||||
|
case VI_VERTICAL_TIMING:
|
||||||
|
m_VIVerticalTimingRegister.Hex = _iValue;
|
||||||
|
break;
|
||||||
|
|
||||||
case VI_CONTROL_REGISTER:
|
case VI_CONTROL_REGISTER:
|
||||||
{
|
{
|
||||||
UVIDisplayControlRegister tmpConfig(_iValue);
|
UVIDisplayControlRegister tmpConfig(_iValue);
|
||||||
|
@ -197,6 +300,22 @@ void Write16(const u16 _iValue, const u32 _iAddress)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VI_FRAMEBUFFER_TOP_HI:
|
||||||
|
m_FrameBufferTop.Hi = _iValue;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VI_FRAMEBUFFER_TOP_LO:
|
||||||
|
m_FrameBufferTop.Lo = _iValue;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VI_FRAMEBUFFER_BOTTOM_HI:
|
||||||
|
m_FrameBufferBottom.Hi = _iValue;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VI_FRAMEBUFFER_BOTTOM_LO:
|
||||||
|
m_FrameBufferBottom.Lo = _iValue;
|
||||||
|
break;
|
||||||
|
|
||||||
case VI_VERTICAL_BEAM_POSITION:
|
case VI_VERTICAL_BEAM_POSITION:
|
||||||
_dbg_assert_(VIDEOINTERFACE,0);
|
_dbg_assert_(VIDEOINTERFACE,0);
|
||||||
break;
|
break;
|
||||||
|
@ -225,17 +344,19 @@ void Write16(const u16 _iValue, const u32 _iAddress)
|
||||||
m_VIInterruptRegister[3].Hi = _iValue;
|
m_VIInterruptRegister[3].Hi = _iValue;
|
||||||
UpdateInterrupts();
|
UpdateInterrupts();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VI_HSCALEW:
|
case VI_HSCALEW:
|
||||||
{
|
m_VIHorizontalStepping.Hex = _iValue;
|
||||||
// int width = _iValue&0x3FF;
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VI_HSCALER:
|
case VI_HSCALER:
|
||||||
{
|
m_VIHorizontalScaling.Hex = _iValue;
|
||||||
// int hsEnable = (_iValue&(1<<12)) ? true : false;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VI_FBWIDTH:
|
||||||
|
FbWidth = _iValue;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
*(u16*)&m_UVIUnknownRegs[_iAddress & 0xFFF] = _iValue;
|
*(u16*)&m_UVIUnknownRegs[_iAddress & 0xFFF] = _iValue;
|
||||||
break;
|
break;
|
||||||
|
@ -270,24 +391,12 @@ void Read32(u32& _uReturnValue, const u32 _iAddress)
|
||||||
void Write32(const u32 _iValue, const u32 _iAddress)
|
void Write32(const u32 _iValue, const u32 _iAddress)
|
||||||
{
|
{
|
||||||
LOG(VIDEOINTERFACE, "(w32): 0x%08x, 0x%08x",_iValue,_iAddress);
|
LOG(VIDEOINTERFACE, "(w32): 0x%08x, 0x%08x",_iValue,_iAddress);
|
||||||
|
|
||||||
switch(_iAddress & 0xFFF)
|
// Allow 32-bit writes to the VI: although this is officially not
|
||||||
{
|
// allowed, the hardware seems to accept it (for example, DesktopMan GC
|
||||||
case VI_FRAMEBUFFER_1:
|
// Tetris uses it).
|
||||||
m_FrameBuffer1 = _iValue;
|
Write16(_iValue >> 16, _iAddress);
|
||||||
break;
|
Write16(_iValue & 0xFFFF, _iAddress + 2);
|
||||||
case VI_FRAMEBUFFER_2:
|
|
||||||
m_FrameBuffer2 = _iValue;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// Allow 32-bit writes to the VI: although this is officially not
|
|
||||||
// allowed, the hardware seems to accept it (for example, DesktopMan GC
|
|
||||||
// Tetris uses it).
|
|
||||||
Write16(_iValue >> 16, _iAddress);
|
|
||||||
Write16(_iValue & 0xFFFF, _iAddress + 2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateInterrupts()
|
void UpdateInterrupts()
|
||||||
|
@ -327,7 +436,7 @@ void GenerateVIInterrupt(VIInterruptType _VIInterrupt)
|
||||||
|
|
||||||
u8* GetFrameBufferPointer()
|
u8* GetFrameBufferPointer()
|
||||||
{
|
{
|
||||||
return Memory::GetPointer(VideoInterface::m_FrameBuffer1);
|
return Memory::GetPointer(VideoInterface::m_FrameBufferTop.Hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreInit(bool _bNTSC)
|
void PreInit(bool _bNTSC)
|
||||||
|
@ -355,6 +464,7 @@ void PreInit(bool _bNTSC)
|
||||||
Write16(0x01ae, 0xcc002032);
|
Write16(0x01ae, 0xcc002032);
|
||||||
Write16(0x1107, 0xcc002030);
|
Write16(0x1107, 0xcc002030);
|
||||||
Write16(0x0000, 0xcc00206c);
|
Write16(0x0000, 0xcc00206c);
|
||||||
|
Write16(0x0001, 0xcc00206e); // component cable is connected
|
||||||
|
|
||||||
if (_bNTSC)
|
if (_bNTSC)
|
||||||
Write16(0x0001, 0xcc002002); // STATUS REG
|
Write16(0x0001, 0xcc002002); // STATUS REG
|
||||||
|
@ -370,11 +480,13 @@ void UpdateTiming()
|
||||||
case 2:
|
case 2:
|
||||||
TicksPerFrame = SystemTimers::GetTicksPerSecond() / 30;
|
TicksPerFrame = SystemTimers::GetTicksPerSecond() / 30;
|
||||||
LineCount = m_VIDisplayControlRegister.NIN ? 263 : 525;
|
LineCount = m_VIDisplayControlRegister.NIN ? 263 : 525;
|
||||||
|
LinesPerField = 263;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
TicksPerFrame = SystemTimers::GetTicksPerSecond() / 25;
|
TicksPerFrame = SystemTimers::GetTicksPerSecond() / 25;
|
||||||
LineCount = m_VIDisplayControlRegister.NIN ? 313 : 625;
|
LineCount = m_VIDisplayControlRegister.NIN ? 313 : 625;
|
||||||
|
LinesPerField = 313;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -395,6 +507,32 @@ void Update()
|
||||||
{
|
{
|
||||||
VerticalBeamPos = 1;
|
VerticalBeamPos = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(VerticalBeamPos == NextXFBRender)
|
||||||
|
{
|
||||||
|
|
||||||
|
u8* xfbPtr = 0;
|
||||||
|
int yOffset = 0;
|
||||||
|
|
||||||
|
if(NextXFBRender == 1)
|
||||||
|
{
|
||||||
|
NextXFBRender = LinesPerField;
|
||||||
|
xfbPtr = Memory::GetPointer(VideoInterface::m_FrameBufferTop.Hex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NextXFBRender = 1;
|
||||||
|
xfbPtr = Memory::GetPointer(VideoInterface::m_FrameBufferBottom.Hex);
|
||||||
|
yOffset = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(xfbPtr && PluginVideo::IsLoaded())
|
||||||
|
{
|
||||||
|
int fbWidth = m_VIHorizontalStepping.FieldSteps * 16;
|
||||||
|
int fbHeight = (m_VIHorizontalStepping.FbSteps / m_VIHorizontalStepping.FieldSteps) * m_VIVerticalTimingRegister.ACV;
|
||||||
|
PluginVideo::Video_UpdateXFB(xfbPtr, fbWidth, fbHeight, yOffset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check INT_PRERETRACE
|
// check INT_PRERETRACE
|
||||||
if (m_VIInterruptRegister[0].VCT == VerticalBeamPos)
|
if (m_VIInterruptRegister[0].VCT == VerticalBeamPos)
|
||||||
|
|
|
@ -39,7 +39,7 @@ typedef void (__cdecl* TVideo_Initialize)(SVideoInitialize*);
|
||||||
typedef void (__cdecl* TVideo_Prepare)();
|
typedef void (__cdecl* TVideo_Prepare)();
|
||||||
typedef void (__cdecl* TVideo_Shutdown)();
|
typedef void (__cdecl* TVideo_Shutdown)();
|
||||||
typedef void (__cdecl* TVideo_SendFifoData)(u8*);
|
typedef void (__cdecl* TVideo_SendFifoData)(u8*);
|
||||||
typedef void (__cdecl* TVideo_UpdateXFB)(u8*, u32, u32);
|
typedef void (__cdecl* TVideo_UpdateXFB)(u8*, u32, u32, s32);
|
||||||
typedef BOOL (__cdecl* TVideo_Screenshot)(TCHAR*);
|
typedef BOOL (__cdecl* TVideo_Screenshot)(TCHAR*);
|
||||||
typedef void (__cdecl* TVideo_EnterLoop)();
|
typedef void (__cdecl* TVideo_EnterLoop)();
|
||||||
typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds);
|
typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds);
|
||||||
|
|
|
@ -34,26 +34,53 @@ void yuv2rgb(int y, int u, int v, int &r, int &g, int &b)
|
||||||
r = bound((76283*(y - 16) + 104595*(v - 128))>>16);
|
r = bound((76283*(y - 16) + 104595*(v - 128))>>16);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
void rgb2yuv(int r, int g, int b, int &y, int &u, int &v)
|
||||||
|
|
||||||
void ConvertXFB(u32 *dst, const u8* _pXFB, int width, int height)
|
|
||||||
{
|
{
|
||||||
const unsigned char *src = _pXFB;
|
y = (((16843 * r) + (33030 * g) + (6423 * b)) >> 16) + 16;
|
||||||
for (int y = 0; y < height; y++)
|
v = (((28770 * r) - (24117 * g) - (4653 * b)) >> 16) + 128;
|
||||||
{
|
u = ((-(9699 * r) - (19071 * g) + (28770 * b)) >> 16) + 128;
|
||||||
for (int x = 0; x < width; x++, src += 4)
|
}
|
||||||
{
|
|
||||||
int Y1 = src[0];
|
} // namespace
|
||||||
int U = src[1];
|
|
||||||
int Y2 = src[2];
|
void ConvertFromXFB(u32 *dst, const u8* _pXFB, int width, int height)
|
||||||
int V = src[3];
|
{
|
||||||
|
const unsigned char *src = _pXFB;
|
||||||
int r, g, b;
|
|
||||||
yuv2rgb(Y1,U,V, r,g,b);
|
u32 numBlocks = (width * height) / 2;
|
||||||
*dst++ = 0xFF000000 | (r<<16) | (g<<8) | (b);
|
|
||||||
yuv2rgb(Y2,U,V, r,g,b);
|
for (u32 i = 0; i < numBlocks; i++, src += 4)
|
||||||
*dst++ = 0xFF000000 | (r<<16) | (g<<8) | (b);
|
{
|
||||||
}
|
int Y1 = src[0];
|
||||||
}
|
int U = src[1];
|
||||||
|
int Y2 = src[2];
|
||||||
|
int V = src[3];
|
||||||
|
|
||||||
|
int r, g, b;
|
||||||
|
yuv2rgb(Y1,U,V, r,g,b);
|
||||||
|
*dst++ = 0xFF000000 | (r<<16) | (g<<8) | (b);
|
||||||
|
yuv2rgb(Y2,U,V, r,g,b);
|
||||||
|
*dst++ = 0xFF000000 | (r<<16) | (g<<8) | (b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConvertToXFB(u32 *dst, const u8* _pEFB, int width, int height)
|
||||||
|
{
|
||||||
|
const unsigned char *src = _pEFB;
|
||||||
|
|
||||||
|
u32 numBlocks = (width * height) / 2;
|
||||||
|
|
||||||
|
for (u32 i = 0; i < numBlocks; i++)
|
||||||
|
{
|
||||||
|
int y1 = (((16843 * src[0]) + (33030 * src[1]) + (6423 * src[2])) >> 16) + 16;
|
||||||
|
int u1 = ((-(9699 * src[0]) - (19071 * src[1]) + (28770 * src[2])) >> 16) + 128;
|
||||||
|
src += 4;
|
||||||
|
|
||||||
|
int y2 = (((16843 * src[0]) + (33030 * src[1]) + (6423 * src[2])) >> 16) + 16;
|
||||||
|
int v2 = (((28770 * src[0]) - (24117 * src[1]) - (4653 * src[2])) >> 16) + 128;
|
||||||
|
src += 4;
|
||||||
|
|
||||||
|
*dst++ = (v2 << 24) | (y2 << 16) | (u1 << 8) | (y1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,9 @@
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
void ConvertXFB(u32 *dst, const u8* _pXFB, int width, int height);
|
void ConvertFromXFB(u32 *dst, const u8* _pXFB, int width, int height);
|
||||||
|
|
||||||
|
// converts 32-bit RGBA data to 16-bit 4:2:2 YUV data
|
||||||
|
void ConvertToXFB(u32 *dst, const u8* _pEFB, int width, int height);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -146,7 +146,7 @@ EXPORT void CALL Video_SendFifoData(u8* _uData);
|
||||||
// input: pointer to the XFB, width and height of the XFB
|
// input: pointer to the XFB, width and height of the XFB
|
||||||
// output: none
|
// output: none
|
||||||
//
|
//
|
||||||
EXPORT void CALL Video_UpdateXFB(u8* _pXFB, u32 _dwWidth, u32 _dwHeight);
|
EXPORT void CALL Video_UpdateXFB(u8* _pXFB, u32 _dwWidth, u32 _dwHeight, s32 _dwYOffset);
|
||||||
|
|
||||||
// __________________________________________________________________________________________________
|
// __________________________________________________________________________________________________
|
||||||
// Function: Video_Screenshot
|
// Function: Video_Screenshot
|
||||||
|
|
|
@ -231,7 +231,7 @@ void Video_Stop(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Video_UpdateXFB(u8* /*_pXFB*/, u32 /*_dwWidth*/, u32 /*_dwHeight*/)
|
void Video_UpdateXFB(u8* /*_pXFB*/, u32 /*_dwWidth*/, u32 /*_dwHeight*/, s32 /*_dwYOffset*/)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
ConvertXFB(tempBuffer, _pXFB, _dwWidth, _dwHeight);
|
ConvertXFB(tempBuffer, _pXFB, _dwWidth, _dwHeight);
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "TextureDecoder.h"
|
#include "TextureDecoder.h"
|
||||||
#include "VertexShaderManager.h"
|
#include "VertexShaderManager.h"
|
||||||
#include "PixelShaderManager.h"
|
#include "PixelShaderManager.h"
|
||||||
|
#include "XFB.h"
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------------
|
||||||
|
@ -592,19 +593,19 @@ bool SetScissorRect()
|
||||||
|
|
||||||
RECT rc;
|
RECT rc;
|
||||||
|
|
||||||
rc.left = bpmem.scissorTL.x + xoff - 342; // left = 0
|
rc.left = bpmem.scissorTL.x - xoff - 342; // left = 0
|
||||||
rc.left *= MValueX;
|
rc.left *= MValueX;
|
||||||
if (rc.left < 0) rc.left = 0;
|
if (rc.left < 0) rc.left = 0;
|
||||||
|
|
||||||
rc.top = bpmem.scissorTL.y + yoff - 342; // right = 0
|
rc.top = bpmem.scissorTL.y - yoff - 342; // right = 0
|
||||||
rc.top *= MValueY;
|
rc.top *= MValueY;
|
||||||
if (rc.top < 0) rc.top = 0;
|
if (rc.top < 0) rc.top = 0;
|
||||||
|
|
||||||
rc.right = bpmem.scissorBR.x + xoff - 342; // right = 640
|
rc.right = bpmem.scissorBR.x - xoff - 342; // right = 640
|
||||||
rc.right *= MValueX;
|
rc.right *= MValueX;
|
||||||
if (rc.right > 640 * MValueX) rc.right = 640 * MValueX;
|
if (rc.right > 640 * MValueX) rc.right = 640 * MValueX;
|
||||||
|
|
||||||
rc.bottom = bpmem.scissorBR.y + yoff - 342; // bottom = 480
|
rc.bottom = bpmem.scissorBR.y - yoff - 342; // bottom = 480
|
||||||
rc.bottom *= MValueY;
|
rc.bottom *= MValueY;
|
||||||
if (rc.bottom > 480 * MValueY) rc.bottom = 480 * MValueY;
|
if (rc.bottom > 480 * MValueY) rc.bottom = 480 * MValueY;
|
||||||
|
|
||||||
|
@ -684,15 +685,15 @@ void LoadBPReg(u32 value0)
|
||||||
TRectangle rc = {
|
TRectangle rc = {
|
||||||
(int)(bpmem.copyTexSrcXY.x),
|
(int)(bpmem.copyTexSrcXY.x),
|
||||||
(int)(bpmem.copyTexSrcXY.y),
|
(int)(bpmem.copyTexSrcXY.y),
|
||||||
(int)((bpmem.copyTexSrcXY.x + bpmem.copyTexSrcWH.x)),
|
(int)((bpmem.copyTexSrcXY.x + bpmem.copyTexSrcWH.x + 1)),
|
||||||
(int)((bpmem.copyTexSrcXY.y + bpmem.copyTexSrcWH.y))
|
(int)((bpmem.copyTexSrcXY.y + bpmem.copyTexSrcWH.y + 1))
|
||||||
};
|
};
|
||||||
//Need another rc here to get it to scale.
|
//Need another rc here to get it to scale.
|
||||||
TRectangle multirc = {
|
TRectangle multirc = {
|
||||||
(int)(bpmem.copyTexSrcXY.x * MValueX),
|
(int)(bpmem.copyTexSrcXY.x * MValueX),
|
||||||
(int)(bpmem.copyTexSrcXY.y * MValueY),
|
(int)(bpmem.copyTexSrcXY.y * MValueY),
|
||||||
(int)((bpmem.copyTexSrcXY.x * MValueX + bpmem.copyTexSrcWH.x * MValueX)),
|
(int)((bpmem.copyTexSrcXY.x * MValueX + (bpmem.copyTexSrcWH.x + 1) * MValueX)),
|
||||||
(int)((bpmem.copyTexSrcXY.y * MValueY + bpmem.copyTexSrcWH.y * MValueY))
|
(int)((bpmem.copyTexSrcXY.y * MValueY + (bpmem.copyTexSrcWH.y + 1) * MValueY))
|
||||||
};
|
};
|
||||||
|
|
||||||
UPE_Copy PE_copy;
|
UPE_Copy PE_copy;
|
||||||
|
@ -706,8 +707,15 @@ void LoadBPReg(u32 value0)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// EFB to XFB
|
// EFB to XFB
|
||||||
Renderer::Swap(multirc);
|
if(g_Config.bUseXFB)
|
||||||
g_VideoInitialize.pCopiedToXFB();
|
{
|
||||||
|
XFB_Write(Memory_GetPtr(bpmem.copyTexDest<<5), multirc, (bpmem.copyMipMapStrideChannels << 4), bpmem.copyTexSrcWH.y + 1, bpmem.dispcopyyscale/256.0f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Renderer::Swap(multirc);
|
||||||
|
}
|
||||||
|
g_VideoInitialize.pCopiedToXFB();
|
||||||
}
|
}
|
||||||
|
|
||||||
// clearing
|
// clearing
|
||||||
|
|
|
@ -41,6 +41,7 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
|
||||||
EVT_CHECKBOX(ID_SHADERERRORS,ConfigDialog::ShowShaderErrorsCheck)
|
EVT_CHECKBOX(ID_SHADERERRORS,ConfigDialog::ShowShaderErrorsCheck)
|
||||||
EVT_CHECKBOX(ID_TEXFMTOVERLAY,ConfigDialog::TexFmtOverlayChange)
|
EVT_CHECKBOX(ID_TEXFMTOVERLAY,ConfigDialog::TexFmtOverlayChange)
|
||||||
EVT_CHECKBOX(ID_TEXFMTCENTER,ConfigDialog::TexFmtOverlayChange)
|
EVT_CHECKBOX(ID_TEXFMTCENTER,ConfigDialog::TexFmtOverlayChange)
|
||||||
|
EVT_CHECKBOX(ID_USEXFB,ConfigDialog::UseXFBChange)
|
||||||
EVT_CHECKBOX(ID_DUMPTEXTURES,ConfigDialog::DumpTexturesChange)
|
EVT_CHECKBOX(ID_DUMPTEXTURES,ConfigDialog::DumpTexturesChange)
|
||||||
EVT_DIRPICKER_CHANGED(ID_TEXTUREPATH,ConfigDialog::TexturePathChange)
|
EVT_DIRPICKER_CHANGED(ID_TEXTUREPATH,ConfigDialog::TexturePathChange)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
@ -145,6 +146,9 @@ void ConfigDialog::CreateGUIControls()
|
||||||
m_TexFmtCenter->SetValue(g_Config.bTexFmtOverlayCenter);
|
m_TexFmtCenter->SetValue(g_Config.bTexFmtOverlayCenter);
|
||||||
m_TexFmtCenter->Enable(m_TexFmtOverlay->IsChecked());
|
m_TexFmtCenter->Enable(m_TexFmtOverlay->IsChecked());
|
||||||
|
|
||||||
|
m_UseXFB = new wxCheckBox(m_PageAdvanced, ID_USEXFB, wxT("Use XFB"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||||
|
m_UseXFB->SetValue(g_Config.bUseXFB);
|
||||||
|
|
||||||
m_DumpTextures = new wxCheckBox(m_PageAdvanced, ID_DUMPTEXTURES, wxT("Dump textures to:"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
m_DumpTextures = new wxCheckBox(m_PageAdvanced, ID_DUMPTEXTURES, wxT("Dump textures to:"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
|
||||||
m_DumpTextures->SetValue(g_Config.bDumpTextures);
|
m_DumpTextures->SetValue(g_Config.bDumpTextures);
|
||||||
m_TexturePath = new wxDirPickerCtrl(m_PageAdvanced, ID_TEXTUREPATH, wxEmptyString, wxT("Choose a directory to store texture dumps:"), wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL);
|
m_TexturePath = new wxDirPickerCtrl(m_PageAdvanced, ID_TEXTUREPATH, wxEmptyString, wxT("Choose a directory to store texture dumps:"), wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL);
|
||||||
|
@ -195,8 +199,9 @@ void ConfigDialog::CreateGUIControls()
|
||||||
sPage3->Add(m_Statistics, wxGBPosition(3, 0), wxGBSpan(1, 2), wxALL, 5);
|
sPage3->Add(m_Statistics, wxGBPosition(3, 0), wxGBSpan(1, 2), wxALL, 5);
|
||||||
sPage3->Add(m_TexFmtOverlay, wxGBPosition(4, 0), wxGBSpan(1, 1), wxALL, 5);
|
sPage3->Add(m_TexFmtOverlay, wxGBPosition(4, 0), wxGBSpan(1, 1), wxALL, 5);
|
||||||
sPage3->Add(m_TexFmtCenter, wxGBPosition(4, 1), wxGBSpan(1, 1), wxALL, 5);
|
sPage3->Add(m_TexFmtCenter, wxGBPosition(4, 1), wxGBSpan(1, 1), wxALL, 5);
|
||||||
sPage3->Add(m_DumpTextures, wxGBPosition(5, 0), wxGBSpan(1, 1), wxALL, 5);
|
sPage3->Add(m_UseXFB, wxGBPosition(5, 0), wxGBSpan(1, 1), wxALL, 5);
|
||||||
sPage3->Add(m_TexturePath, wxGBPosition(5, 1), wxGBSpan(1, 1), wxALL, 5);
|
sPage3->Add(m_DumpTextures, wxGBPosition(6, 0), wxGBSpan(1, 1), wxALL, 5);
|
||||||
|
sPage3->Add(m_TexturePath, wxGBPosition(6, 1), wxGBSpan(1, 1), wxALL, 5);
|
||||||
m_PageAdvanced->SetSizer(sPage3);
|
m_PageAdvanced->SetSizer(sPage3);
|
||||||
sPage3->Layout();
|
sPage3->Layout();
|
||||||
|
|
||||||
|
@ -318,6 +323,11 @@ void ConfigDialog::TexFmtOverlayChange(wxCommandEvent& event)
|
||||||
TextureMngr::Invalidate();
|
TextureMngr::Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigDialog::UseXFBChange(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
g_Config.bUseXFB = m_UseXFB->IsChecked();
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigDialog::DumpTexturesChange(wxCommandEvent& event)
|
void ConfigDialog::DumpTexturesChange(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
m_TexturePath->Enable(m_DumpTextures->IsChecked());
|
m_TexturePath->Enable(m_DumpTextures->IsChecked());
|
||||||
|
@ -336,4 +346,4 @@ void ConfigDialog::DllAbout(wxCommandEvent& event)
|
||||||
info.AddDeveloper(_T("zerofrog(@gmail.com)"));
|
info.AddDeveloper(_T("zerofrog(@gmail.com)"));
|
||||||
info.SetDescription(_T("Vertex/Pixel Shader 2.0 or higher, framebuffer objects, multiple render targets"));
|
info.SetDescription(_T("Vertex/Pixel Shader 2.0 or higher, framebuffer objects, multiple render targets"));
|
||||||
wxAboutBox(info);
|
wxAboutBox(info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ class ConfigDialog : public wxDialog
|
||||||
void OverlayCheck(wxCommandEvent& event);
|
void OverlayCheck(wxCommandEvent& event);
|
||||||
void ShowShaderErrorsCheck(wxCommandEvent& event);
|
void ShowShaderErrorsCheck(wxCommandEvent& event);
|
||||||
void TexFmtOverlayChange(wxCommandEvent& event);
|
void TexFmtOverlayChange(wxCommandEvent& event);
|
||||||
|
void UseXFBChange(wxCommandEvent& event);
|
||||||
void DumpTexturesChange(wxCommandEvent& event);
|
void DumpTexturesChange(wxCommandEvent& event);
|
||||||
void TexturePathChange(wxFileDirPickerEvent& event);
|
void TexturePathChange(wxFileDirPickerEvent& event);
|
||||||
void DllAbout(wxCommandEvent& event);
|
void DllAbout(wxCommandEvent& event);
|
||||||
|
@ -76,6 +77,7 @@ class ConfigDialog : public wxDialog
|
||||||
wxButton *m_OK;
|
wxButton *m_OK;
|
||||||
wxDirPickerCtrl *m_TexturePath;
|
wxDirPickerCtrl *m_TexturePath;
|
||||||
wxCheckBox *m_DumpTextures;
|
wxCheckBox *m_DumpTextures;
|
||||||
|
wxCheckBox *m_UseXFB;
|
||||||
wxCheckBox *m_TexFmtCenter;
|
wxCheckBox *m_TexFmtCenter;
|
||||||
wxCheckBox *m_TexFmtOverlay;
|
wxCheckBox *m_TexFmtOverlay;
|
||||||
wxCheckBox *m_Statistics;
|
wxCheckBox *m_Statistics;
|
||||||
|
@ -105,6 +107,7 @@ class ConfigDialog : public wxDialog
|
||||||
ID_OK,
|
ID_OK,
|
||||||
ID_TEXTUREPATH,
|
ID_TEXTUREPATH,
|
||||||
ID_SHADERERRORS,
|
ID_SHADERERRORS,
|
||||||
|
ID_USEXFB,
|
||||||
ID_TEXFMTCENTER,
|
ID_TEXFMTCENTER,
|
||||||
ID_TEXFMTOVERLAY,
|
ID_TEXFMTOVERLAY,
|
||||||
ID_SHOWFPS,
|
ID_SHOWFPS,
|
||||||
|
|
|
@ -90,6 +90,7 @@ void Config::Load()
|
||||||
|
|
||||||
iniFile.Get("Settings", "TexFmtOverlayEnable", &bTexFmtOverlayEnable, 0);
|
iniFile.Get("Settings", "TexFmtOverlayEnable", &bTexFmtOverlayEnable, 0);
|
||||||
iniFile.Get("Settings", "TexFmtOverlayCenter", &bTexFmtOverlayCenter, 0);
|
iniFile.Get("Settings", "TexFmtOverlayCenter", &bTexFmtOverlayCenter, 0);
|
||||||
|
iniFile.Get("Settings", "UseXFB", &bUseXFB, 0);
|
||||||
|
|
||||||
iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0);
|
iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0);
|
||||||
iniFile.Get("Enhancements", "ForceMaxAniso", &bForceMaxAniso, 0);
|
iniFile.Get("Enhancements", "ForceMaxAniso", &bForceMaxAniso, 0);
|
||||||
|
@ -118,6 +119,7 @@ void Config::Save()
|
||||||
iniFile.Set("Settings", "TexDumpPath", texDumpPath);
|
iniFile.Set("Settings", "TexDumpPath", texDumpPath);
|
||||||
iniFile.Set("Settings", "TexFmtOverlayEnable", bTexFmtOverlayEnable);
|
iniFile.Set("Settings", "TexFmtOverlayEnable", bTexFmtOverlayEnable);
|
||||||
iniFile.Set("Settings", "TexFmtOverlayCenter", bTexFmtOverlayCenter);
|
iniFile.Set("Settings", "TexFmtOverlayCenter", bTexFmtOverlayCenter);
|
||||||
|
iniFile.Set("Settings", "UseXFB", bUseXFB);
|
||||||
|
|
||||||
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
|
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
|
||||||
iniFile.Set("Enhancements", "ForceMaxAniso", bForceMaxAniso);
|
iniFile.Set("Enhancements", "ForceMaxAniso", bForceMaxAniso);
|
||||||
|
|
|
@ -141,6 +141,7 @@ struct Config
|
||||||
bool bTexFmtOverlayEnable;
|
bool bTexFmtOverlayEnable;
|
||||||
bool bTexFmtOverlayCenter;
|
bool bTexFmtOverlayCenter;
|
||||||
bool bOverlayStats;
|
bool bOverlayStats;
|
||||||
|
bool bUseXFB;
|
||||||
bool bDumpTextures;
|
bool bDumpTextures;
|
||||||
char texDumpPath[280];
|
char texDumpPath[280];
|
||||||
|
|
||||||
|
|
|
@ -707,7 +707,21 @@ void Renderer::Swap(const TRectangle& rc)
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||||
TextureMngr::DisableStage(0);
|
TextureMngr::DisableStage(0);
|
||||||
|
|
||||||
static int fpscount;
|
SwapBuffers();
|
||||||
|
|
||||||
|
RestoreGLState();
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
g_Config.iSaveTargetId = 0;
|
||||||
|
|
||||||
|
// for testing zbuffer targets
|
||||||
|
//Renderer::SetZBufferRender();
|
||||||
|
//SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_ZBufferTarget, GetTargetWidth(), GetTargetHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::SwapBuffers()
|
||||||
|
{
|
||||||
|
static int fpscount;
|
||||||
static int s_fps;
|
static int s_fps;
|
||||||
static unsigned long lasttime;
|
static unsigned long lasttime;
|
||||||
++fpscount;
|
++fpscount;
|
||||||
|
@ -812,15 +826,6 @@ void Renderer::Swap(const TRectangle& rc)
|
||||||
Renderer::SetRenderMode(RM_Normal); // turn off any zwrites
|
Renderer::SetRenderMode(RM_Normal); // turn off any zwrites
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RestoreGLState();
|
|
||||||
GL_REPORT_ERRORD();
|
|
||||||
|
|
||||||
g_Config.iSaveTargetId = 0;
|
|
||||||
|
|
||||||
// for testing zbuffer targets
|
|
||||||
//Renderer::SetZBufferRender();
|
|
||||||
//SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_ZBufferTarget, GetTargetWidth(), GetTargetHeight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Renderer::SaveRenderTarget(const char* filename, int jpeg)
|
bool Renderer::SaveRenderTarget(const char* filename, int jpeg)
|
||||||
|
|
|
@ -73,6 +73,8 @@ public:
|
||||||
// Finish up the current frame, print some stats
|
// Finish up the current frame, print some stats
|
||||||
static void Swap(const TRectangle& rc);
|
static void Swap(const TRectangle& rc);
|
||||||
|
|
||||||
|
static void SwapBuffers();
|
||||||
|
|
||||||
static bool SaveRenderTarget(const char* filename, int jpeg);
|
static bool SaveRenderTarget(const char* filename, int jpeg);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -344,6 +344,8 @@ void VertexShaderMngr::SetConstants(VERTEXSHADER& vs)
|
||||||
// -------------
|
// -------------
|
||||||
// rawViewport[0] = 320, rawViewport[1] = -240
|
// rawViewport[0] = 320, rawViewport[1] = -240
|
||||||
// -------------
|
// -------------
|
||||||
|
int scissorXOff = bpmem.scissorOffset.x * 2 - 342;
|
||||||
|
int scissorYOff = bpmem.scissorOffset.y * 2 - 342;
|
||||||
float fourThree = 4.0f/3.0f;
|
float fourThree = 4.0f/3.0f;
|
||||||
float ratio = AR / fourThree;
|
float ratio = AR / fourThree;
|
||||||
float hAdj; float wAdj; float actualRatiow; float actualRatioh;
|
float hAdj; float wAdj; float actualRatiow; float actualRatioh;
|
||||||
|
@ -391,16 +393,16 @@ void VertexShaderMngr::SetConstants(VERTEXSHADER& vs)
|
||||||
if(g_Config.bStretchToFit && g_Config.renderToMainframe)
|
if(g_Config.bStretchToFit && g_Config.renderToMainframe)
|
||||||
{
|
{
|
||||||
glViewport(
|
glViewport(
|
||||||
(int)(rawViewport[3]-rawViewport[0]-342) + xoffs,
|
(int)(rawViewport[3]-rawViewport[0]-342-scissorXOff) + xoffs,
|
||||||
Renderer::GetTargetHeight() - ((int)(rawViewport[4]-rawViewport[1]-342)) + yoffs,
|
Renderer::GetTargetHeight() - ((int)(rawViewport[4]-rawViewport[1]-342-scissorYOff)) + yoffs,
|
||||||
wid, // width
|
wid, // width
|
||||||
hei // height
|
hei // height
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glViewport((int)(rawViewport[3]-rawViewport[0]-342) * MValueX,
|
glViewport((int)(rawViewport[3]-rawViewport[0]-342-scissorXOff) * MValueX,
|
||||||
Renderer::GetTargetHeight()-((int)(rawViewport[4]-rawViewport[1]-342)) * MValueY,
|
Renderer::GetTargetHeight()-((int)(rawViewport[4]-rawViewport[1]-342-scissorYOff)) * MValueY,
|
||||||
abs((int)(2 * rawViewport[0])) * MValueX, abs((int)(2 * rawViewport[1])) * MValueY);
|
abs((int)(2 * rawViewport[0])) * MValueX, abs((int)(2 * rawViewport[1])) * MValueY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,10 @@
|
||||||
// Preliminary non-working code.
|
// Preliminary non-working code.
|
||||||
|
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
#include "GLInit.h"
|
||||||
#include "Render.h"
|
#include "Render.h"
|
||||||
#include "TextureMngr.h"
|
#include "TextureMngr.h"
|
||||||
|
#include "VertexShaderManager.h"
|
||||||
#include "XFBConvert.h"
|
#include "XFBConvert.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -29,39 +31,138 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
static GLuint xfb_texture;
|
static GLuint xfb_texture;
|
||||||
static u8 *xfb_buffer;
|
static u8 *xfb_buffer = 0;
|
||||||
|
static u8 *efb_buffer = 0;
|
||||||
|
static GLuint s_xfbFrameBuffer = 0;
|
||||||
|
static GLuint s_xfbRenderBuffer = 0;
|
||||||
|
|
||||||
void XFB_Init()
|
void XFB_Init()
|
||||||
{
|
{
|
||||||
|
// used to render XFB
|
||||||
xfb_buffer = new u8[XFB_WIDTH * XFB_HEIGHT * 4];
|
xfb_buffer = new u8[XFB_WIDTH * XFB_HEIGHT * 4];
|
||||||
memset(xfb_buffer, 0, XFB_WIDTH * XFB_HEIGHT * 4);
|
memset(xfb_buffer, 0, XFB_WIDTH * XFB_HEIGHT * 4);
|
||||||
glGenTextures(1, &xfb_texture);
|
glGenTextures(1, &xfb_texture);
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, xfb_texture);
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, xfb_texture);
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, XFB_WIDTH, XFB_HEIGHT, 0, GL_BGRA, GL_UNSIGNED_BYTE, xfb_buffer);
|
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, XFB_WIDTH, XFB_HEIGHT, 0, GL_BGRA, GL_UNSIGNED_BYTE, xfb_buffer);
|
||||||
|
|
||||||
|
// used to render EFB
|
||||||
|
glGenFramebuffersEXT( 1, &s_xfbFrameBuffer);
|
||||||
|
glGenRenderbuffersEXT(1, &s_xfbRenderBuffer);
|
||||||
|
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, s_xfbRenderBuffer);
|
||||||
|
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA, nBackbufferWidth, nBackbufferHeight);
|
||||||
|
|
||||||
|
efb_buffer = new u8[nBackbufferWidth * nBackbufferHeight * 4];
|
||||||
}
|
}
|
||||||
|
|
||||||
void XFB_Draw(u8 *xfb_in_ram)
|
void XFB_Write(u8 *xfb_in_ram, const TRectangle& sourceRc, u32 dstWd, u32 dstHt, float yScale)
|
||||||
{
|
{
|
||||||
|
Renderer::SetRenderMode(Renderer::RM_Normal);
|
||||||
|
|
||||||
Renderer::ResetGLState();
|
Renderer::ResetGLState();
|
||||||
ConvertXFB((u32 *)xfb_buffer, xfb_in_ram, XFB_WIDTH, XFB_HEIGHT);
|
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, xfb_texture);
|
// switch to XFB frame buffer
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, XFB_WIDTH, XFB_HEIGHT, 0, GL_BGRA, GL_UNSIGNED_BYTE, xfb_buffer);
|
Renderer::SetFramebuffer(s_xfbFrameBuffer);
|
||||||
|
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, s_xfbRenderBuffer);
|
||||||
|
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, s_xfbRenderBuffer);
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
glViewport(nXoff, nYoff, nBackbufferWidth, nBackbufferHeight);
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, Renderer::GetRenderTarget());
|
||||||
|
TextureMngr::EnableTexRECT(0);
|
||||||
|
for (int i = 1; i < 8; ++i)
|
||||||
|
TextureMngr::DisableStage(i);
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
float scaledTextureY = nBackbufferHeight - (nBackbufferHeight / yScale);
|
||||||
|
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(nBackbufferWidth, nBackbufferHeight); glVertex2f(-1,-1);
|
||||||
|
glTexCoord2f(nBackbufferWidth, scaledTextureY); glVertex2f(-1,1);
|
||||||
|
glTexCoord2f(0, scaledTextureY); glVertex2f(1,1);
|
||||||
|
glTexCoord2f(0, nBackbufferHeight); glVertex2f(1,-1);
|
||||||
|
glEnd();
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
int width = sourceRc.right - sourceRc.left;
|
||||||
|
int height = sourceRc.bottom - sourceRc.top;
|
||||||
|
glReadPixels(sourceRc.left, sourceRc.top, width, height, GL_RGBA, GL_UNSIGNED_BYTE, efb_buffer);
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
Renderer::SetFramebuffer(0);
|
||||||
|
Renderer::RestoreGLState();
|
||||||
|
VertexShaderMngr::SetViewportChanged();
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||||
|
TextureMngr::DisableStage(0);
|
||||||
|
|
||||||
|
Renderer::RestoreGLState();
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
|
// TODO - verify that XFB pixel order. probably reverse of GL pixel order
|
||||||
|
// TODO - use shader for conversion
|
||||||
|
ConvertToXFB((u32 *)xfb_in_ram, efb_buffer, dstWd, dstHt);
|
||||||
|
|
||||||
|
// old way
|
||||||
|
/*glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, Renderer::GetRenderTarget());
|
||||||
|
TextureMngr::EnableTexRECT(0);
|
||||||
|
|
||||||
|
glGetTexImage(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, GL_UNSIGNED_BYTE, efb_buffer);
|
||||||
|
|
||||||
|
static u8 *efbEndAddress = efb_buffer + ((nBackbufferWidth * nBackbufferHeight) - 1) * 4;
|
||||||
|
ConvertToXFBReverse((u32 *)xfb_in_ram, efbEndAddress, dstWd, dstHt);*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void XFB_Draw(u8 *xfb_in_ram, u32 width, u32 height, s32 yOffset)
|
||||||
|
{
|
||||||
|
if(width == 0 || height == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
OpenGL_Update(); // just updates the render window position and the backbuffer size
|
||||||
|
|
||||||
|
Renderer::SetRenderMode(Renderer::RM_Normal);
|
||||||
|
|
||||||
|
// render to the real buffer now
|
||||||
|
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); // switch to the backbuffer
|
||||||
|
glViewport(nXoff, nYoff, nBackbufferWidth, nBackbufferHeight);
|
||||||
|
|
||||||
|
Renderer::ResetGLState();
|
||||||
|
|
||||||
|
// TODO - use shader for conversion
|
||||||
|
ConvertFromXFB((u32 *)xfb_buffer, xfb_in_ram, width, height);
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, xfb_texture);
|
||||||
|
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, 4, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, xfb_buffer);
|
||||||
TextureMngr::EnableTexRECT(0);
|
TextureMngr::EnableTexRECT(0);
|
||||||
for (int i = 1; i < 8; ++i)
|
for (int i = 1; i < 8; ++i)
|
||||||
TextureMngr::DisableStage(i);
|
TextureMngr::DisableStage(i);
|
||||||
|
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0, 0); glVertex2f(-1,-1);
|
glTexCoord2f(width, height + yOffset); glVertex2f(-1,-1);
|
||||||
glTexCoord2f(0, XFB_WIDTH); glVertex2f(-1,1);
|
glTexCoord2f(width, 0 + yOffset); glVertex2f(-1,1);
|
||||||
glTexCoord2f(XFB_WIDTH, XFB_HEIGHT); glVertex2f(1,1);
|
glTexCoord2f(0, 0 + yOffset); glVertex2f(1,1);
|
||||||
glTexCoord2f(XFB_WIDTH, 0); glVertex2f(1,-1);
|
glTexCoord2f(0, height + yOffset); glVertex2f(1,-1);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0);
|
||||||
|
TextureMngr::DisableStage(0);
|
||||||
|
|
||||||
|
Renderer::SwapBuffers();
|
||||||
|
|
||||||
Renderer::RestoreGLState();
|
Renderer::RestoreGLState();
|
||||||
|
GL_REPORT_ERRORD();
|
||||||
}
|
}
|
||||||
|
|
||||||
void XFB_Shutdown()
|
void XFB_Shutdown()
|
||||||
{
|
{
|
||||||
|
glDeleteFramebuffersEXT(1, &s_xfbFrameBuffer);
|
||||||
|
|
||||||
glDeleteTextures(1, &xfb_texture);
|
glDeleteTextures(1, &xfb_texture);
|
||||||
xfb_texture = 0;
|
xfb_texture = 0;
|
||||||
delete [] xfb_buffer;
|
delete [] xfb_buffer;
|
||||||
|
|
|
@ -18,8 +18,16 @@
|
||||||
#ifndef _XFB_H
|
#ifndef _XFB_H
|
||||||
#define _XFB_H
|
#define _XFB_H
|
||||||
|
|
||||||
|
#include "TextureMngr.h"
|
||||||
|
|
||||||
void XFB_Init();
|
void XFB_Init();
|
||||||
void XFB_Draw(u8 *xfb_in_ram);
|
|
||||||
|
// write the EFB to the XFB
|
||||||
|
void XFB_Write(u8 *xfb_in_ram, const TRectangle& sourceRc, u32 dstWd, u32 dstHt, float yScale);
|
||||||
|
|
||||||
|
// draw the XFB to the screen
|
||||||
|
void XFB_Draw(u8 *xfb_in_ram, u32 width, u32 height, s32 yOffset);
|
||||||
|
|
||||||
void XFB_Shutdown();
|
void XFB_Shutdown();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
#include "VertexLoader.h"
|
#include "VertexLoader.h"
|
||||||
#include "PixelShaderManager.h"
|
#include "PixelShaderManager.h"
|
||||||
#include "VertexShaderManager.h"
|
#include "VertexShaderManager.h"
|
||||||
|
#include "XFB.h"
|
||||||
|
|
||||||
#include "VideoState.h"
|
#include "VideoState.h"
|
||||||
#include "Debugger/Debugger.h" // for the CDebugger class
|
#include "Debugger/Debugger.h" // for the CDebugger class
|
||||||
|
|
||||||
|
@ -298,8 +300,12 @@ BOOL Video_Screenshot(TCHAR* _szFilename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Video_UpdateXFB(u8* _pXFB, u32 _dwWidth, u32 _dwHeight)
|
void Video_UpdateXFB(u8* _pXFB, u32 _dwWidth, u32 _dwHeight, s32 _dwYOffset)
|
||||||
{
|
{
|
||||||
|
if(g_Config.bUseXFB)
|
||||||
|
{
|
||||||
|
XFB_Draw(_pXFB, _dwWidth, _dwHeight, _dwYOffset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Video_AddMessage(const char* pstr, u32 milliseconds)
|
void Video_AddMessage(const char* pstr, u32 milliseconds)
|
||||||
|
|
Loading…
Reference in New Issue