Increased render target size to the true EFB height of 528.

This changes fixes the bloom effect in Beyond Good and Evil.
It also makes the AutoScale feature almost mandatory since it looks silly without :)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2475 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-02-28 19:02:37 +00:00
parent 8eb4aeafb4
commit 1a2a320652
7 changed files with 59 additions and 57 deletions

View File

@ -31,14 +31,17 @@ unsigned char memcmp_mmx(const void* src1, const void* src2, int cmpsize);
#define memcmp_gc memcmp
#endif
enum {
// These are accurate (disregarding AA modes).
enum
{
EFB_WIDTH = 640,
EFB_HEIGHT = 528,
};
enum {
enum
{
XFB_WIDTH = 640,
XFB_HEIGHT = 480, // 528 is max height ... ? or 538?
XFB_HEIGHT = 480, // 574 can be used with tricks (multi pass render and dual xfb copies, etc).
// TODO: figure out what to do with PAL
};
@ -51,12 +54,12 @@ void DebugLog(const char* _fmt, ...);
//////////////////////////////////////////////////////////////////////////
inline u8 *Memory_GetPtr(u32 _uAddress)
{
return g_VideoInitialize.pGetMemoryPointer(_uAddress);//&g_pMemory[_uAddress & RAM_MASK];
return g_VideoInitialize.pGetMemoryPointer(_uAddress);
}
inline u8 Memory_Read_U8(u32 _uAddress)
{
return *(u8*)g_VideoInitialize.pGetMemoryPointer(_uAddress);//g_pMemory[_uAddress & RAM_MASK];
return *(u8*)g_VideoInitialize.pGetMemoryPointer(_uAddress);
}
inline u16 Memory_Read_U16(u32 _uAddress)
@ -71,7 +74,7 @@ inline u32 Memory_Read_U32(u32 _uAddress)
//////////////////////////////////////////////////////////////////////////
inline u8* Memory_Read_U8_Ptr(u32 _uAddress)
{
return (u8*)g_VideoInitialize.pGetMemoryPointer(_uAddress);//g_pMemory[_uAddress & RAM_MASK];
return (u8*)g_VideoInitialize.pGetMemoryPointer(_uAddress);
}
inline u16* Memory_Read_U16_Unswapped_Ptr(u32 _uAddress)
@ -84,10 +87,6 @@ inline u32* Memory_Read_U32_Unswapped_Ptr(u32 _uAddress)
return (u32*)g_VideoInitialize.pGetMemoryPointer(_uAddress);
}
//////////////////////////////////////////////////////////////////////////
inline u32 Memory_Read_U32_Unswapped(u32 _uAddress)
{
return *(u32*)g_VideoInitialize.pGetMemoryPointer(_uAddress);
}
inline float Memory_Read_Float(u32 _uAddress)
{
@ -101,26 +100,17 @@ struct TRectangle
int left, top, right, bottom;
};
// Logging
// ¯¯¯¯¯¯¯¯¯¯
void DebugLog(const char* _fmt, ...); // This one goes to the main program
void DebugLog(const char *_fmt, ...); // This one goes to the main program
void HandleGLError();
#ifdef _WIN32
//#define ERROR_LOG(...) {LOG(VIDEO, __VA_ARGS__)}
//#define INFO_LOG(...) {LOG(VIDEO, __VA_ARGS__)}
#define PRIM_LOG(...) {LOG(VIDEO, __VA_ARGS__)}
//#define DEBUG_LOG(...) {LOG(VIDEO, __VA_ARGS__)}
#else
//#define ERROR_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)}
//#define INFO_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)}
#define PRIM_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)}
//#define DEBUG_LOG(...) {LOG(VIDEO, ##__VA_ARGS__)}
#endif
#ifdef LOGGING

View File

@ -417,8 +417,15 @@ void BPWritten(int addr, int changes, int newval)
}
else if (g_Config.bCopyEFBToRAM)
{
TRectangle scaled_rc;
float xScale = Renderer::GetTargetScaleX();
float yScale = Renderer::GetTargetScaleY();
scaled_rc.left = rc.left * xScale;
scaled_rc.right = rc.right * xScale;
scaled_rc.top = rc.top * xScale;
scaled_rc.bottom = rc.bottom * xScale;
TextureConverter::EncodeToRam(bpmem.copyTexDest<<5, bpmem.zcontrol.pixel_format==PIXELFMT_Z24, PE_copy.intensity_fmt>0,
(PE_copy.target_pixel_format/2)+((PE_copy.target_pixel_format&1)*8), PE_copy.half_scale>0, rc);
(PE_copy.target_pixel_format/2)+((PE_copy.target_pixel_format&1)*8), PE_copy.half_scale>0, scaled_rc);
}
else
{

View File

@ -26,6 +26,7 @@
#include "ConsoleWindow.h"
// Compile without WxWidgets in Windows to, for debugging purposes
//#define HAVE_WX 0

View File

@ -217,6 +217,16 @@ bool Renderer::Init()
// This should really be grabbed from config rather than from OpenGL.
s_targetwidth = (int)OpenGL_GetBackbufferWidth();
s_targetheight = (int)OpenGL_GetBackbufferHeight();
// Compensate height of render target for scaling, so that we get something close to the correct number of
// vertical pixels.
s_targetheight *= 528.0 / 480.0;
// Ensure a minimum target size so that the native res target always fits.
if (s_targetwidth < EFB_WIDTH)
s_targetwidth = EFB_WIDTH;
if (s_targetheight < EFB_HEIGHT)
s_targetheight = EFB_HEIGHT;
// Create the framebuffer target texture
glGenTextures(1, (GLuint *)&s_RenderTarget);
@ -427,22 +437,22 @@ bool Renderer::InitializeGL()
// ------------------------
int Renderer::GetTargetWidth()
{
return (g_Config.bNativeResolution ? 640 : s_targetwidth);
return (g_Config.bNativeResolution ? EFB_WIDTH : s_targetwidth);
}
int Renderer::GetTargetHeight()
{
return (g_Config.bNativeResolution ? 480 : s_targetheight);
return (g_Config.bNativeResolution ? EFB_HEIGHT : s_targetheight);
}
float Renderer::GetTargetScaleX()
{
return (float)GetTargetWidth() / 640.0f;
return (float)GetTargetWidth() / (float)EFB_WIDTH;
}
float Renderer::GetTargetScaleY()
{
return (float)GetTargetHeight() / 480.0f;
return (float)GetTargetHeight() / (float)EFB_HEIGHT;
}
/////////////////////////////
@ -476,6 +486,8 @@ GLuint Renderer::GetZBufferTarget()
void Renderer::ResetGLState()
{
// Gets us to a reasonably sane state where it's possible to do things like
// image copies with textured quads, etc.
glDisable(GL_SCISSOR_TEST);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
@ -489,6 +501,7 @@ void Renderer::ResetGLState()
void Renderer::RestoreGLState()
{
// Gets us back into a more game-like state.
glEnable(GL_SCISSOR_TEST);
if (bpmem.genMode.cullmode > 0) glEnable(GL_CULL_FACE);
@ -504,11 +517,13 @@ void Renderer::RestoreGLState()
void Renderer::SetColorMask()
{
if (bpmem.blendmode.alphaupdate && bpmem.blendmode.colorupdate)
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
else if (bpmem.blendmode.alphaupdate)
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_TRUE);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
else if (bpmem.blendmode.colorupdate)
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_FALSE);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
else
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
}
void Renderer::SetBlendMode(bool forceUpdate)
@ -601,11 +616,11 @@ bool Renderer::SetScissorRect()
float rc_right = (float)bpmem.scissorBR.x - xoff - 341; // right = 640
rc_right *= MValueX;
if (rc_right > 640 * MValueX) rc_right = 640 * MValueX;
if (rc_right > EFB_WIDTH * MValueX) rc_right = EFB_WIDTH * MValueX;
float rc_bottom = (float)bpmem.scissorBR.y - yoff - 341; // bottom = 480
rc_bottom *= MValueY;
if (rc_bottom > 480 * MValueY) rc_bottom = 480 * MValueY;
if (rc_bottom > EFB_HEIGHT * MValueY) rc_bottom = EFB_HEIGHT * MValueY;
/*LOG(VIDEO, "Scissor: lt=(%d,%d), rb=(%d,%d,%i), off=(%d,%d)\n",
rc_left, rc_top,
@ -751,7 +766,7 @@ void Renderer::SetRenderMode(RenderMode mode)
if (mode == RM_ZBufferOnly) {
// flush and remove stencil
_assert_(s_RenderMode==RM_ZBufferAlpha);
_assert_(s_RenderMode == RM_ZBufferAlpha);
FlushZBufferAlphaToTarget();
glDisable(GL_STENCIL_TEST);
@ -880,6 +895,9 @@ void Renderer::Swap(const TRectangle& rc)
// Texture map s_RenderTargets[s_curtarget] onto the main buffer
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, s_RenderTarget);
// Use linear filtering.
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
TextureMngr::EnableTexRECT(0);
// Disable all other stages
@ -890,12 +908,8 @@ void Renderer::Swap(const TRectangle& rc)
ComputeBackbufferRectangle(&back_rc);
// Update GLViewPort
glViewport(
back_rc.left,
back_rc.top,
back_rc.right - back_rc.left,
back_rc.bottom - back_rc.top
);
glViewport(back_rc.left, back_rc.top,
back_rc.right - back_rc.left, back_rc.bottom - back_rc.top);
GL_REPORT_ERRORD();
@ -921,6 +935,10 @@ void Renderer::Swap(const TRectangle& rc)
glTexCoord2f(u_max, v_min); glVertex2f( 1, -1);
glEnd();
// Restore filtering.
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
// Wireframe
if (g_Config.bWireFrame)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

View File

@ -250,9 +250,11 @@ void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyf
u32 target = bFromZBuffer ? Renderer::GetZBufferTarget() : Renderer::GetRenderTarget();
s32 width = source.right - source.left;
s32 height = source.bottom - source.top;
s32 height = source.bottom - source.top;
if (bScaleByHalf)
{
// Hm. Shouldn't this only scale destination, not source?
width /= 2;
height /= 2;
}
@ -289,6 +291,7 @@ void EncodeToRamYUYV(GLuint srcTexture, const TRectangle& sourceRc,
}
// Should be scale free.
void DecodeToTexture(u8* srcAddr, int srcWidth, int srcHeight, GLuint destTexture)
{
Renderer::SetRenderMode(Renderer::RM_Normal);
@ -318,7 +321,7 @@ void DecodeToTexture(u8* srcAddr, int srcWidth, int srcHeight, GLuint destTextur
glViewport(0, 0, srcWidth, srcHeight);
glEnable(GL_FRAGMENT_PROGRAM_ARB);
glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, s_yuyvToRgbProgram.glprogid);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, s_yuyvToRgbProgram.glprogid);
GL_REPORT_ERRORD();

View File

@ -403,23 +403,6 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
INCSTAT(stats.numTexturesCreated);
SETSTAT(stats.numTexturesAlive, textures.size());
//glEnable(entry.isNonPow2?GL_TEXTURE_RECTANGLE_ARB:GL_TEXTURE_2D);
/*
if ( 1
//&& (entry.w != 640 && entry.h != 480)
//&& (entry.w != 320 && entry.h != 240)
&& (entry.w ==512 && entry.h == 512)
//&& (entry.w > 200 && entry.h > 200)
//&& (format!=1)
)
{
char fn[256];
sprintf(fn, "z_%i_%i_%ix%i_%08x.tga", dbgTexIdx, format, entry.w, entry.h, entry.addr);
SaveTexture(fn, target, entry.texture, entry.w, entry.h);
dbgTexIdx++;
}
*/
return &entry;
}

View File

@ -40,7 +40,7 @@ them.
#define XFB_USE_SHADERS 1
enum {
XFB_BUF_HEIGHT = 538, //480,
XFB_BUF_HEIGHT = 574, //480,
// TODO: figure out what to do with PAL
};