mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-24 06:51:17 +01:00
Some cleanup, extracted XFB convert code into VideoCommon, added non-activated support to gl plugin. + a minor bugfix with no effects seen so far in gl plugin :P
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@209 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
1aedd4891c
commit
b4d7ce0197
@ -117,62 +117,21 @@ typedef union _LARGE_INTEGER
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined (_MSC_VER) && !defined (HAVE_ALIGNED_MALLOC)
|
|
||||||
|
|
||||||
// declare linux equivalents
|
|
||||||
extern __forceinline void* gc_aligned_malloc(size_t size, size_t align)
|
|
||||||
{
|
|
||||||
char* p = (char*)malloc(size + align);
|
|
||||||
int off = 2 + align - ((s64)(p + 2) % align);
|
|
||||||
|
|
||||||
p += off;
|
|
||||||
*(u16*)(p - 2) = off;
|
|
||||||
|
|
||||||
return(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
extern __forceinline void gc_aligned_free(void* pmem)
|
|
||||||
{
|
|
||||||
if (pmem != NULL)
|
|
||||||
{
|
|
||||||
char* p = (char*)pmem;
|
|
||||||
free(p - (int)*(u16*)(p - 2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define _aligned_malloc gc_aligned_malloc
|
|
||||||
#define _aligned_free gc_aligned_free
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (_M_IX86) && defined (_WIN32)
|
#if defined (_M_IX86) && defined (_WIN32)
|
||||||
#define HWCALL __cdecl
|
#define HWCALL __cdecl
|
||||||
#else
|
#else
|
||||||
#define HWCALL
|
#define HWCALL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Hacks
|
|
||||||
#ifndef SAFE_DELETE
|
|
||||||
#define SAFE_DELETE(ptr) if (ptr){delete ptr; ptr = 0;}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Common defines
|
|
||||||
// TODO(ector,fires): turn into inline function?
|
|
||||||
#undef min
|
#undef min
|
||||||
#undef max
|
#undef max
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T min(const T& a, const T& b) {return(a > b ? b : a);}
|
inline T min(const T& a, const T& b) {return(a > b ? b : a);}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T max(const T& a, const T& b) {return(a > b ? a : b);}
|
inline T max(const T& a, const T& b) {return(a > b ? a : b);}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Byte ordering
|
// Byte ordering
|
||||||
|
|
||||||
@ -183,39 +142,25 @@ inline u8 swap8(u8 _data) {return(_data);}
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
inline u16 swap16(u16 _data) {return(_byteswap_ushort(_data));}
|
inline u16 swap16(u16 _data) {return(_byteswap_ushort(_data));}
|
||||||
|
|
||||||
|
|
||||||
inline u32 swap32(u32 _data) {return(_byteswap_ulong(_data));}
|
inline u32 swap32(u32 _data) {return(_byteswap_ulong(_data));}
|
||||||
|
|
||||||
|
|
||||||
inline u64 swap64(u64 _data) {return(_byteswap_uint64(_data));}
|
inline u64 swap64(u64 _data) {return(_byteswap_uint64(_data));}
|
||||||
|
|
||||||
|
|
||||||
#elif __linux__
|
#elif __linux__
|
||||||
}
|
}
|
||||||
#include <byteswap.h>
|
#include <byteswap.h>
|
||||||
namespace Common
|
namespace Common
|
||||||
{
|
{
|
||||||
inline u16 swap16(u16 _data) {return(bswap_16(_data));}
|
inline u16 swap16(u16 _data) {return(bswap_16(_data));}
|
||||||
|
|
||||||
|
|
||||||
inline u32 swap32(u32 _data) {return(bswap_32(_data));}
|
inline u32 swap32(u32 _data) {return(bswap_32(_data));}
|
||||||
|
|
||||||
|
|
||||||
inline u64 swap64(u64 _data) {return(bswap_64(_data));}
|
inline u64 swap64(u64 _data) {return(bswap_64(_data));}
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
inline u16 swap16(u16 data) {return((data >> 8) | (data << 8));}
|
inline u16 swap16(u16 data) {return((data >> 8) | (data << 8));}
|
||||||
|
|
||||||
|
|
||||||
inline u32 swap32(u32 data) {return((swap16(data) << 16) | swap16(data >> 16));}
|
inline u32 swap32(u32 data) {return((swap16(data) << 16) | swap16(data >> 16));}
|
||||||
|
|
||||||
|
|
||||||
inline u64 swap64(u64 data) {return(((u64)swap32(data) << 32) | swap32(data >> 32));}
|
inline u64 swap64(u64 data) {return(((u64)swap32(data) << 32) | swap32(data >> 32));}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
} // end of namespace Common
|
} // end of namespace Common
|
||||||
|
|
||||||
// Utility functions
|
// Utility functions
|
||||||
@ -231,36 +176,35 @@ extern void __Log(int logNumber, const char* text, ...);
|
|||||||
class LogTypes
|
class LogTypes
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum LOG_TYPE
|
||||||
enum LOG_TYPE
|
{
|
||||||
{
|
MASTER_LOG,
|
||||||
MASTER_LOG,
|
BOOT,
|
||||||
BOOT,
|
PIXELENGINE,
|
||||||
PIXELENGINE,
|
COMMANDPROCESSOR,
|
||||||
COMMANDPROCESSOR,
|
VIDEOINTERFACE,
|
||||||
VIDEOINTERFACE,
|
SERIALINTERFACE,
|
||||||
SERIALINTERFACE,
|
PERIPHERALINTERFACE,
|
||||||
PERIPHERALINTERFACE,
|
MEMMAP,
|
||||||
MEMMAP,
|
DSPINTERFACE,
|
||||||
DSPINTERFACE,
|
STREAMINGINTERFACE,
|
||||||
STREAMINGINTERFACE,
|
DVDINTERFACE,
|
||||||
DVDINTERFACE,
|
GPFIFO,
|
||||||
GPFIFO,
|
EXPANSIONINTERFACE,
|
||||||
EXPANSIONINTERFACE,
|
AUDIO_INTERFACE,
|
||||||
AUDIO_INTERFACE,
|
GEKKO,
|
||||||
GEKKO,
|
HLE,
|
||||||
HLE,
|
DSPHLE,
|
||||||
DSPHLE,
|
VIDEO,
|
||||||
VIDEO,
|
AUDIO,
|
||||||
AUDIO,
|
DYNA_REC,
|
||||||
DYNA_REC,
|
OSREPORT,
|
||||||
OSREPORT,
|
CONSOLE,
|
||||||
CONSOLE,
|
WII_IOB,
|
||||||
WII_IOB,
|
WII_IPC,
|
||||||
WII_IPC,
|
WII_IPC_HLE,
|
||||||
WII_IPC_HLE,
|
NUMBER_OF_LOGS
|
||||||
NUMBER_OF_LOGS
|
};
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef bool (*PanicAlertHandler)(const char* text, bool yes_no);
|
typedef bool (*PanicAlertHandler)(const char* text, bool yes_no);
|
||||||
@ -268,7 +212,6 @@ void RegisterPanicAlertHandler(PanicAlertHandler handler);
|
|||||||
|
|
||||||
void Host_UpdateLogDisplay();
|
void Host_UpdateLogDisplay();
|
||||||
|
|
||||||
|
|
||||||
// Logging macros
|
// Logging macros
|
||||||
#ifdef LOGGING
|
#ifdef LOGGING
|
||||||
|
|
||||||
@ -297,7 +240,6 @@ void Host_UpdateLogDisplay();
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
|
#define _assert_(_a_) _dbg_assert_(MASTER_LOG, _a_)
|
||||||
#define _assert_msg_(_t_, _a_, _fmt_, ...)\
|
#define _assert_msg_(_t_, _a_, _fmt_, ...)\
|
||||||
|
@ -5,6 +5,7 @@ files = ["BPMemory.cpp",
|
|||||||
"LookUpTables.cpp",
|
"LookUpTables.cpp",
|
||||||
"TextureDecoder.cpp",
|
"TextureDecoder.cpp",
|
||||||
"XFMemory.cpp",
|
"XFMemory.cpp",
|
||||||
|
"XFBConvert.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
env_common = env.Copy(CXXFLAGS = " -fPIC ")
|
env_common = env.Copy(CXXFLAGS = " -fPIC ")
|
||||||
|
59
Source/Core/VideoCommon/Src/XFBConvert.cpp
Normal file
59
Source/Core/VideoCommon/Src/XFBConvert.cpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
// Copyright (C) 2003-2008 Dolphin Project.
|
||||||
|
|
||||||
|
// 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, version 2.0.
|
||||||
|
|
||||||
|
// 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 2.0 for more details.
|
||||||
|
|
||||||
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
|
// Official SVN repository and contact information can be found at
|
||||||
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
|
#include "XFBConvert.h"
|
||||||
|
#include "Common.h"
|
||||||
|
|
||||||
|
// TODO: Convert this thing into wicked fast SSE2.
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
int bound(int i)
|
||||||
|
{
|
||||||
|
return (i>255)?255:((i<0)?0:i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void yuv2rgb(int y, int u, int v, int &r, int &g, int &b)
|
||||||
|
{
|
||||||
|
b = bound((76283*(y - 16) + 132252*(u - 128))>>16);
|
||||||
|
g = bound((76283*(y - 16) - 53281 *(v - 128) - 25624*(u - 128))>>16); //last one u?
|
||||||
|
r = bound((76283*(y - 16) + 104595*(v - 128))>>16);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void ConvertXFB(u32 *dst, const u8* _pXFB, int width, int height)
|
||||||
|
{
|
||||||
|
const unsigned char *src = _pXFB;
|
||||||
|
for (int y = 0; y < height; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < width; x++, src += 4)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
25
Source/Core/VideoCommon/Src/XFBConvert.h
Normal file
25
Source/Core/VideoCommon/Src/XFBConvert.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// Copyright (C) 2003-2008 Dolphin Project.
|
||||||
|
|
||||||
|
// 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, version 2.0.
|
||||||
|
|
||||||
|
// 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 2.0 for more details.
|
||||||
|
|
||||||
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
|
// Official SVN repository and contact information can be found at
|
||||||
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
|
#ifndef _XFB_CONVERT
|
||||||
|
#define _XFB_CONVERT
|
||||||
|
|
||||||
|
#include "Common.h"
|
||||||
|
|
||||||
|
void ConvertXFB(u32 *dst, const u8* _pXFB, int width, int height);
|
||||||
|
|
||||||
|
#endif
|
@ -413,6 +413,10 @@
|
|||||||
RelativePath=".\Src\LookUpTables.h"
|
RelativePath=".\Src\LookUpTables.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\SConscript"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\TextureDecoder.cpp"
|
RelativePath=".\Src\TextureDecoder.cpp"
|
||||||
>
|
>
|
||||||
@ -421,6 +425,14 @@
|
|||||||
RelativePath=".\Src\TextureDecoder.h"
|
RelativePath=".\Src\TextureDecoder.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\XFBConvert.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\XFBConvert.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\XFMemory.cpp"
|
RelativePath=".\Src\XFMemory.cpp"
|
||||||
>
|
>
|
||||||
|
@ -36,7 +36,7 @@ CDSPHandler::CDSPHandler()
|
|||||||
|
|
||||||
CDSPHandler::~CDSPHandler()
|
CDSPHandler::~CDSPHandler()
|
||||||
{
|
{
|
||||||
SAFE_DELETE(m_pUCode);
|
delete m_pUCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -90,13 +90,13 @@ void CDSPHandler::SendMailToDSP(u32 _uMail)
|
|||||||
|
|
||||||
IUCode* CDSPHandler::GetUCode()
|
IUCode* CDSPHandler::GetUCode()
|
||||||
{
|
{
|
||||||
return(m_pUCode);
|
return m_pUCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CDSPHandler::SetUCode(u32 _crc)
|
void CDSPHandler::SetUCode(u32 _crc)
|
||||||
{
|
{
|
||||||
SAFE_DELETE(m_pUCode);
|
delete m_pUCode;
|
||||||
|
|
||||||
m_MailHandler.Clear();
|
m_MailHandler.Clear();
|
||||||
m_pUCode = UCodeFactory(_crc, m_MailHandler);
|
m_pUCode = UCodeFactory(_crc, m_MailHandler);
|
||||||
|
@ -33,22 +33,18 @@ class CDSPHandler
|
|||||||
IUCode* GetUCode();
|
IUCode* GetUCode();
|
||||||
void SetUCode(u32 _crc);
|
void SetUCode(u32 _crc);
|
||||||
|
|
||||||
|
|
||||||
CMailHandler& AccessMailHandler() {return(m_MailHandler);}
|
CMailHandler& AccessMailHandler() {return(m_MailHandler);}
|
||||||
|
|
||||||
|
|
||||||
static CDSPHandler& GetInstance()
|
static CDSPHandler& GetInstance()
|
||||||
{
|
{
|
||||||
return(*m_pInstance);
|
return(*m_pInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void Destroy()
|
static void Destroy()
|
||||||
{
|
{
|
||||||
SAFE_DELETE(m_pInstance);
|
delete m_pInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static CDSPHandler& CreateInstance()
|
static CDSPHandler& CreateInstance()
|
||||||
{
|
{
|
||||||
if (m_pInstance == NULL)
|
if (m_pInstance == NULL)
|
||||||
@ -59,7 +55,6 @@ class CDSPHandler
|
|||||||
return(*m_pInstance);
|
return(*m_pInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
CDSPHandler();
|
CDSPHandler();
|
||||||
|
@ -1565,14 +1565,6 @@
|
|||||||
RelativePath=".\Src\Vec3.h"
|
RelativePath=".\Src\Vec3.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\Src\XFB.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Src\XFB.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
</Globals>
|
</Globals>
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
#include "XFB.h"
|
|
||||||
#include "Common.h"
|
|
||||||
|
|
||||||
// __________________________________________________________________________________________________
|
|
||||||
// Video_UpdateXFB
|
|
||||||
//
|
|
||||||
|
|
||||||
// TODO(ector): Write protect XFB. As soon as something pokes there,
|
|
||||||
// switch to a mode where we actually display the XFB on top of the 3D.
|
|
||||||
// If no writes have happened within 5 frames, revert to normal mode.
|
|
||||||
|
|
||||||
int bound(int i)
|
|
||||||
{
|
|
||||||
return (i>255)?255:((i<0)?0:i);
|
|
||||||
}
|
|
||||||
void yuv2rgb(int y, int u, int v, int &r, int &g, int &b)
|
|
||||||
{
|
|
||||||
b = bound((76283*(y - 16) + 132252*(u - 128))>>16);
|
|
||||||
g = bound((76283*(y - 16) - 53281 *(v - 128) - 25624*(u - 128))>>16); //last one u?
|
|
||||||
r = bound((76283*(y - 16) + 104595*(v - 128))>>16);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConvertXFB(int *dst, const u8* _pXFB, int width, int height)
|
|
||||||
{
|
|
||||||
const unsigned char *src = _pXFB;
|
|
||||||
for (int y=0; y < height; y++)
|
|
||||||
{
|
|
||||||
for (int x = 0; x < width; x++)
|
|
||||||
{
|
|
||||||
int Y1 = *src++;
|
|
||||||
int U = *src++;
|
|
||||||
int Y2 = *src++;
|
|
||||||
int V = *src++;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
|||||||
#ifndef _XFB_H
|
|
||||||
#define _XFB_H
|
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
void ConvertXFB(int *dst, const u8* _pXFB, int width, int height);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="Windows-1252"?>
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
<VisualStudioProject
|
<VisualStudioProject
|
||||||
ProjectType="Visual C++"
|
ProjectType="Visual C++"
|
||||||
Version="8,00"
|
Version="8.00"
|
||||||
Name="Plugin_VideoOGL"
|
Name="Plugin_VideoOGL"
|
||||||
ProjectGUID="{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}"
|
ProjectGUID="{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}"
|
||||||
RootNamespace="Plugin_VideoOGL"
|
RootNamespace="Plugin_VideoOGL"
|
||||||
@ -821,6 +821,14 @@
|
|||||||
RelativePath=".\Src\rasterfont.h"
|
RelativePath=".\Src\rasterfont.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\TextureMngr.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\Src\TextureMngr.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\VertexShader.cpp"
|
RelativePath=".\Src\VertexShader.cpp"
|
||||||
>
|
>
|
||||||
@ -1040,14 +1048,6 @@
|
|||||||
RelativePath=".\Src\Render.h"
|
RelativePath=".\Src\Render.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\Src\TextureMngr.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Src\TextureMngr.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\XFB.cpp"
|
RelativePath=".\Src\XFB.cpp"
|
||||||
>
|
>
|
||||||
|
@ -100,13 +100,7 @@ struct RECT
|
|||||||
|
|
||||||
// several macros
|
// several macros
|
||||||
// PLEASE DO NOT USE THE FOLLOWING SAFE*
|
// PLEASE DO NOT USE THE FOLLOWING SAFE*
|
||||||
// They only encourage sloppy coding, and hides bugs.
|
// They only encourage sloppy coding, and hide bugs.
|
||||||
#ifndef SAFE_DELETE_ARRAY
|
|
||||||
#define SAFE_DELETE_ARRAY(x) if( (x) != NULL ) { delete[] (x); (x) = NULL; }
|
|
||||||
#endif
|
|
||||||
#ifndef SAFE_RELEASE
|
|
||||||
#define SAFE_RELEASE(x) if( (x) != NULL ) { (x)->Release(); (x) = NULL; }
|
|
||||||
#endif
|
|
||||||
#define SAFE_RELEASE_CGPROG(x) { if( (x) != NULL ) { cgDestroyProgram(x); x = NULL; } }
|
#define SAFE_RELEASE_CGPROG(x) { if( (x) != NULL ) { cgDestroyProgram(x); x = NULL; } }
|
||||||
#define SAFE_RELEASE_PROG(x) { if( (x) != 0 ) { glDeleteProgramsARB(1, &(x)); x = 0; } }
|
#define SAFE_RELEASE_PROG(x) { if( (x) != 0 ) { glDeleteProgramsARB(1, &(x)); x = 0; } }
|
||||||
#define SAFE_RELEASE_TEX(x) { if( (x) != 0 ) { glDeleteTextures(1, &(x)); x = 0; } }
|
#define SAFE_RELEASE_TEX(x) { if( (x) != 0 ) { glDeleteTextures(1, &(x)); x = 0; } }
|
||||||
@ -269,8 +263,6 @@ unsigned char memcmp_mmx(const void* src1, const void* src2, int cmpsize);
|
|||||||
#define memcmp_gc memcmp
|
#define memcmp_gc memcmp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define RAM_MASK 0x1FFFFFF
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
inline u8 *Memory_GetPtr(u32 _uAddress)
|
inline u8 *Memory_GetPtr(u32 _uAddress)
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "VertexShader.h"
|
#include "VertexShader.h"
|
||||||
#include "PixelShaderManager.h"
|
#include "PixelShaderManager.h"
|
||||||
#include "VertexLoader.h"
|
#include "VertexLoader.h"
|
||||||
|
#include "XFB.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "OS\Win32.h"
|
#include "OS\Win32.h"
|
||||||
@ -52,6 +53,7 @@ static bool s_bOutputCgErrors = true;
|
|||||||
static int nZBufferRender = 0; // if > 0, then using zbuffer render
|
static int nZBufferRender = 0; // if > 0, then using zbuffer render
|
||||||
static u32 s_uFramebuffer = 0;
|
static u32 s_uFramebuffer = 0;
|
||||||
static u32 s_RenderTargets[1] = {0}, s_DepthTarget = 0, s_ZBufferTarget = 0;
|
static u32 s_RenderTargets[1] = {0}, s_DepthTarget = 0, s_ZBufferTarget = 0;
|
||||||
|
|
||||||
static bool s_bATIDrawBuffers = false, s_bHaveStencilBuffer = false;
|
static bool s_bATIDrawBuffers = false, s_bHaveStencilBuffer = false;
|
||||||
static Renderer::RenderMode s_RenderMode = Renderer::RM_Normal;
|
static Renderer::RenderMode s_RenderMode = Renderer::RM_Normal;
|
||||||
static int s_nCurTarget = 0;
|
static int s_nCurTarget = 0;
|
||||||
@ -273,26 +275,29 @@ bool Renderer::Create2()
|
|||||||
if (!Initialize())
|
if (!Initialize())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
XFB_Init();
|
||||||
return glGetError() == GL_NO_ERROR && bSuccess;
|
return glGetError() == GL_NO_ERROR && bSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Shutdown(void)
|
void Renderer::Shutdown(void)
|
||||||
{
|
{
|
||||||
SAFE_DELETE(s_pfont);
|
delete s_pfont;
|
||||||
|
s_pfont = 0;
|
||||||
|
|
||||||
if( g_cgcontext != 0 ) {
|
XFB_Shutdown();
|
||||||
|
|
||||||
|
if (g_cgcontext != 0) {
|
||||||
cgDestroyContext(g_cgcontext);
|
cgDestroyContext(g_cgcontext);
|
||||||
g_cgcontext = 0;
|
g_cgcontext = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( s_RenderTargets[0] ) {
|
if (s_RenderTargets[0]) {
|
||||||
glDeleteTextures(ARRAYSIZE(s_RenderTargets), (GLuint *)s_RenderTargets);
|
glDeleteTextures(ARRAYSIZE(s_RenderTargets), (GLuint *)s_RenderTargets);
|
||||||
memset(s_RenderTargets, 0, sizeof(s_RenderTargets));
|
memset(s_RenderTargets, 0, sizeof(s_RenderTargets));
|
||||||
}
|
}
|
||||||
if( s_DepthTarget ) {
|
if (s_DepthTarget) {
|
||||||
glDeleteRenderbuffersEXT(1, (GLuint *)&s_DepthTarget); s_DepthTarget = 0;
|
glDeleteRenderbuffersEXT(1, (GLuint *)&s_DepthTarget); s_DepthTarget = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_uFramebuffer != 0) {
|
if (s_uFramebuffer != 0) {
|
||||||
glDeleteFramebuffersEXT( 1, (GLuint *)&s_uFramebuffer);
|
glDeleteFramebuffersEXT( 1, (GLuint *)&s_uFramebuffer);
|
||||||
s_uFramebuffer = 0;
|
s_uFramebuffer = 0;
|
||||||
@ -550,7 +555,7 @@ void Renderer::FlushZBufferAlphaToTarget()
|
|||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glTexCoord2f(0, 0); glVertex2f(-1,-1);
|
glTexCoord2f(0, 0); glVertex2f(-1,-1);
|
||||||
glTexCoord2f(0, (float)(GetTargetHeight()<<g_AAy)); glVertex2f(-1,1);
|
glTexCoord2f(0, (float)(GetTargetHeight()<<g_AAy)); glVertex2f(-1,1);
|
||||||
glTexCoord2f((float)(GetTargetWidth()<<g_AAx), (float)(GetTargetWidth()<<g_AAy)); glVertex2f(1,1);
|
glTexCoord2f((float)(GetTargetWidth()<<g_AAx), (float)(GetTargetHeight()<<g_AAy)); glVertex2f(1,1);
|
||||||
glTexCoord2f((float)(GetTargetWidth()<<g_AAx), 0); glVertex2f(1,-1);
|
glTexCoord2f((float)(GetTargetWidth()<<g_AAx), 0); glVertex2f(1,-1);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
@ -15,48 +15,56 @@
|
|||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
|
|
||||||
|
// Preliminary non-working code.
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Globals.h"
|
#include "Globals.h"
|
||||||
|
#include "Render.h"
|
||||||
|
#include "TextureMngr.h"
|
||||||
|
#include "XFBConvert.h"
|
||||||
|
|
||||||
// __________________________________________________________________________________________________
|
enum {
|
||||||
// Video_UpdateXFB
|
XFB_WIDTH = 640,
|
||||||
//
|
XFB_HEIGHT = 480,
|
||||||
|
};
|
||||||
|
|
||||||
// TODO(ector): Write protect XFB. As soon as something pokes there,
|
static GLuint xfb_texture;
|
||||||
// switch to a mode where we actually display the XFB on top of the 3D.
|
static u8 *xfb_buffer;
|
||||||
// If no writes have happened within 5 frames, revert to normal mode.
|
|
||||||
|
|
||||||
// Also, write a crazy SSE2 optimized version of this :P
|
void XFB_Init()
|
||||||
|
|
||||||
int bound(int i)
|
|
||||||
{
|
{
|
||||||
return (i>255)?255:((i<0)?0:i);
|
xfb_buffer = new u8[XFB_WIDTH * XFB_HEIGHT * 4];
|
||||||
|
memset(xfb_buffer, 0, XFB_WIDTH * XFB_HEIGHT * 4);
|
||||||
|
glGenTextures(1, &xfb_texture);
|
||||||
|
glBindTexture(GL_TEXTURE_RECTANGLE_NV, xfb_texture);
|
||||||
|
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 4, XFB_WIDTH, XFB_HEIGHT, 0, GL_BGRA, GL_UNSIGNED_BYTE, xfb_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void yuv2rgb(int y, int u, int v, int &r, int &g, int &b)
|
void XFB_Draw(u8 *xfb_in_ram)
|
||||||
{
|
{
|
||||||
b = bound((76283*(y - 16) + 132252*(u - 128))>>16);
|
Renderer::ResetGLState();
|
||||||
g = bound((76283*(y - 16) - 53281 *(v - 128) - 25624*(u - 128))>>16); //last one u?
|
ConvertXFB((u32 *)xfb_buffer, xfb_in_ram, XFB_WIDTH, XFB_HEIGHT);
|
||||||
r = bound((76283*(y - 16) + 104595*(v - 128))>>16);
|
glBindTexture(GL_TEXTURE_RECTANGLE_NV, xfb_texture);
|
||||||
|
glTexImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 4, XFB_WIDTH, XFB_HEIGHT, 0, GL_BGRA, GL_UNSIGNED_BYTE, xfb_buffer);
|
||||||
|
TextureMngr::EnableTexRECT(0);
|
||||||
|
for (int i = 1; i < 8; ++i)
|
||||||
|
TextureMngr::DisableStage(i);
|
||||||
|
|
||||||
|
glBegin(GL_QUADS);
|
||||||
|
glTexCoord2f(0, 0); glVertex2f(-1,-1);
|
||||||
|
glTexCoord2f(0, XFB_WIDTH); glVertex2f(-1,1);
|
||||||
|
glTexCoord2f(XFB_WIDTH, XFB_HEIGHT); glVertex2f(1,1);
|
||||||
|
glTexCoord2f(XFB_WIDTH, 0); glVertex2f(1,-1);
|
||||||
|
glEnd();
|
||||||
|
|
||||||
|
Renderer::RestoreGLState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConvertXFB(int *dst, const u8* _pXFB, int width, int height)
|
void XFB_Shutdown()
|
||||||
{
|
{
|
||||||
const unsigned char *src = _pXFB;
|
glDeleteTextures(1, &xfb_texture);
|
||||||
for (int y = 0; y < height; y++)
|
xfb_texture = 0;
|
||||||
{
|
delete [] xfb_buffer;
|
||||||
for (int x = 0; x < width; x++)
|
xfb_buffer = 0;
|
||||||
{
|
|
||||||
int Y1 = *src++;
|
|
||||||
int U = *src++;
|
|
||||||
int Y2 = *src++;
|
|
||||||
int V = *src++;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,8 @@
|
|||||||
#ifndef _XFB_H
|
#ifndef _XFB_H
|
||||||
#define _XFB_H
|
#define _XFB_H
|
||||||
|
|
||||||
|
void XFB_Init();
|
||||||
|
void XFB_Draw(u8 *xfb_in_ram);
|
||||||
|
void XFB_Shutdown();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user