Code cleanup. Juggling rectangles. I'm about to investigate the problems with Real XFB's in PAL games, so I wanted to make sure all our rectangles were cleaned up and organized.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3794 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Nolan Check
2009-07-15 00:51:24 +00:00
parent 7a82ae0943
commit f338d5c44c
20 changed files with 297 additions and 307 deletions

View File

@ -45,11 +45,9 @@ void SetBlendMode(const Bypass &bp);
void SetDitherMode(const Bypass &bp);
void SetLogicOpMode(const Bypass &bp);
void SetColorMask(const Bypass &bp);
float GetRendererTargetScaleX();
float GetRendererTargetScaleY();
void CopyEFB(const Bypass &bp, const TRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 &copyfmt, const bool &scaleByHalf);
void RenderToXFB(const Bypass &bp, const TRectangle &multirc, const float &yScale, const float &xfbLines, u32 xfbAddr, const u32 &dstWidth, const u32 &dstHeight);
void ClearScreen(const Bypass &bp, const TRectangle &multirc);
void CopyEFB(const Bypass &bp, const EFBRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 &copyfmt, const bool &scaleByHalf);
void RenderToXFB(const Bypass &bp, const EFBRectangle &rc, const float &yScale, const float &xfbLines, u32 xfbAddr, const u32 &dstWidth, const u32 &dstHeight);
void ClearScreen(const Bypass &bp, const EFBRectangle &rc);
void RestoreRenderState(const Bypass &bp);
u8 *GetPointer(const u32 &address);
bool GetConfig(const int &type);

View File

@ -176,24 +176,13 @@ void BPWritten(const Bypass& bp)
DVSTARTSUBPROFILE("LoadBPReg:swap");
// The bottom right is within the rectangle
// The values in bpmem.copyTexSrcXY and bpmem.copyTexSrcWH are updated in case 0x49 and 0x4a in this function
TRectangle rc = {
(int)(bpmem.copyTexSrcXY.x),
(int)(bpmem.copyTexSrcXY.y),
(int)((bpmem.copyTexSrcXY.x + bpmem.copyTexSrcWH.x + 1)),
(int)((bpmem.copyTexSrcXY.y + bpmem.copyTexSrcWH.y + 1))
};
float MValueX = GetRendererTargetScaleX();
float MValueY = GetRendererTargetScaleY();
EFBRectangle rc;
rc.left = (int)bpmem.copyTexSrcXY.x;
rc.top = (int)bpmem.copyTexSrcXY.y;
rc.right = (int)(bpmem.copyTexSrcXY.x + bpmem.copyTexSrcWH.x + 1);
rc.bottom = (int)(bpmem.copyTexSrcXY.y + bpmem.copyTexSrcWH.y + 1);
// Need another rc here to get it to scale.
// Here the bottom right is the out of the rectangle.
TRectangle multirc = {
(int)(bpmem.copyTexSrcXY.x * MValueX),
(int)(bpmem.copyTexSrcXY.y * MValueY),
(int)((bpmem.copyTexSrcXY.x * MValueX + (bpmem.copyTexSrcWH.x + 1) * MValueX)),
(int)((bpmem.copyTexSrcXY.y * MValueY + (bpmem.copyTexSrcWH.y + 1) * MValueY))
};
UPE_Copy PE_copy;
PE_copy.Hex = bpmem.triggerEFBCopy;
@ -219,7 +208,7 @@ void BPWritten(const Bypass& bp)
#endif
const float yScale = bpmem.dispcopyyscale / 256.0f;
const float xfbLines = ((bpmem.copyTexSrcWH.y + 1.0f) * yScale);
RenderToXFB(bp, multirc, yScale, xfbLines,
RenderToXFB(bp, rc, yScale, xfbLines,
bpmem.copyTexDest << 5,
bpmem.copyMipMapStrideChannels << 4,
(u32)ceil(xfbLines));
@ -227,7 +216,7 @@ void BPWritten(const Bypass& bp)
// Clear the picture after it's done and submitted, to prepare for the next picture
if (PE_copy.clear)
ClearScreen(bp, multirc);
ClearScreen(bp, rc);
RestoreRenderState(bp);

View File

@ -48,7 +48,7 @@ struct Statistics
float g2proj_0, g2proj_1, g2proj_2, g2proj_3, g2proj_4, g2proj_5;
float g2proj_6, g2proj_7, g2proj_8, g2proj_9, g2proj_10, g2proj_11, g2proj_12, g2proj_13, g2proj_14, g2proj_15;
std::vector<TRectangle> efb_regions;
std::vector<EFBRectangle> efb_regions;
struct ThisFrame
{

View File

@ -19,6 +19,7 @@
#define _VIDEOCOMMON_H
#include "Common.h"
#include "MathUtil.h"
#include "pluginspecs_video.h"
#if defined(_MSC_VER) && !defined(__x86_64__) && !defined(_M_X64)
@ -40,9 +41,14 @@ enum
enum
{
XFB_WIDTH = 640,
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
// XFB width is decided by EFB copy operation. The VI can do horizontal
// scaling (TODO: emulate).
MAX_XFB_WIDTH = EFB_WIDTH,
// Although EFB height is 528, 574-line XFB's can be created either with
// vertical scaling by the EFB copy operation or copying to multiple XFB's
// that are next to each other in memory (TODO: handle that situation).
MAX_XFB_HEIGHT = 574
};
// If this is enabled, bounding boxes will be computed for everything drawn.
@ -54,11 +60,6 @@ enum
extern SVideoInitialize g_VideoInitialize;
// (mb2) for XFB update hack. TODO: find a static better place
extern volatile u32 g_XFBUpdateRequested;
extern volatile bool g_EFBAccessRequested;
//////////////////////////////////////////////////////////////////////////
inline u8 *Memory_GetPtr(u32 _uAddress)
{
@ -103,48 +104,11 @@ inline float Memory_Read_Float(u32 _uAddress)
return temp.f;
}
struct TRectangle
{
int left;
int top;
int right;
int bottom;
int GetWidth() const { return right - left; }
int GetHeight() const { return bottom - top; }
void FlipYPosition(int y_height, TRectangle *dest) const
{
int offset = y_height - (bottom - top);
dest->left = left;
dest->top = top + offset;
dest->right = right;
dest->bottom = bottom + offset;
}
void FlipY(int y_height, TRectangle *dest) const {
dest->left = left;
dest->right = right;
dest->bottom = y_height - bottom;
dest->top = y_height - top;
}
void Scale(float factor_x, float factor_y, TRectangle *dest) const
{
dest->left = (int)(factor_x * left);
dest->right = (int)(factor_x * right);
dest->top = (int)(factor_y * top);
dest->bottom = (int)(factor_y * bottom);
}
void Clamp(int x1, int y1, int x2, int y2)
{
if (left < x1) left = x1;
if (right > x2) right = x2;
if (top < y1) top = y1;
if (bottom > y2) bottom = y2;
}
};
// This structure should only be used to represent a rectangle in EFB
// coordinates, where the origin is at the upper left and the frame dimensions
// are 640 x 528.
struct EFBRectangle : public MathUtil::Rectangle<int>
{};
// Logging
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>