Merge pull request #1206 from comex/amperspocalypse

Change a bunch of reference function arguments to pointers.
This commit is contained in:
skidau 2014-10-05 12:14:04 +11:00
commit 871d308b88
15 changed files with 333 additions and 330 deletions

View File

@ -168,15 +168,15 @@ KeyboardMouse::KeyboardMouse(Window window, int opcode, int pointer, int keyboar
// Mouse Buttons // Mouse Buttons
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
AddInput(new Button(i, m_state.buttons)); AddInput(new Button(i, &m_state.buttons));
// Mouse Cursor, X-/+ and Y-/+ // Mouse Cursor, X-/+ and Y-/+
for (int i = 0; i != 4; ++i) for (int i = 0; i != 4; ++i)
AddInput(new Cursor(!!(i & 2), !!(i & 1), (&m_state.cursor.x)[!!(i & 2)])); AddInput(new Cursor(!!(i & 2), !!(i & 1), (i & 2) ? &m_state.cursor.y : &m_state.cursor.x));
// Mouse Axis, X-/+ and Y-/+ // Mouse Axis, X-/+ and Y-/+
for (int i = 0; i != 4; ++i) for (int i = 0; i != 4; ++i)
AddInput(new Axis(!!(i & 2), !!(i & 1), (&m_state.axis.x)[!!(i & 2)])); AddInput(new Axis(!!(i & 2), !!(i & 1), (i & 2) ? &m_state.axis.y : &m_state.axis.x));
} }
KeyboardMouse::~KeyboardMouse() KeyboardMouse::~KeyboardMouse()
@ -338,7 +338,7 @@ ControlState KeyboardMouse::Key::GetState() const
return (m_keyboard[m_keycode / 8] & (1 << (m_keycode % 8))) != 0; return (m_keyboard[m_keycode / 8] & (1 << (m_keycode % 8))) != 0;
} }
KeyboardMouse::Button::Button(unsigned int index, unsigned int& buttons) KeyboardMouse::Button::Button(unsigned int index, unsigned int* buttons)
: m_buttons(buttons), m_index(index) : m_buttons(buttons), m_index(index)
{ {
// this will be a problem if we remove the hardcoded five-button limit // this will be a problem if we remove the hardcoded five-button limit
@ -347,10 +347,10 @@ KeyboardMouse::Button::Button(unsigned int index, unsigned int& buttons)
ControlState KeyboardMouse::Button::GetState() const ControlState KeyboardMouse::Button::GetState() const
{ {
return ((m_buttons & (1 << m_index)) != 0); return ((*m_buttons & (1 << m_index)) != 0);
} }
KeyboardMouse::Cursor::Cursor(u8 index, bool positive, const float& cursor) KeyboardMouse::Cursor::Cursor(u8 index, bool positive, const float* cursor)
: m_cursor(cursor), m_index(index), m_positive(positive) : m_cursor(cursor), m_index(index), m_positive(positive)
{ {
name = std::string("Cursor ") + (char)('X' + m_index) + (m_positive ? '+' : '-'); name = std::string("Cursor ") + (char)('X' + m_index) + (m_positive ? '+' : '-');
@ -358,10 +358,10 @@ KeyboardMouse::Cursor::Cursor(u8 index, bool positive, const float& cursor)
ControlState KeyboardMouse::Cursor::GetState() const ControlState KeyboardMouse::Cursor::GetState() const
{ {
return std::max(0.0f, m_cursor / (m_positive ? 1.0f : -1.0f)); return std::max(0.0f, *m_cursor / (m_positive ? 1.0f : -1.0f));
} }
KeyboardMouse::Axis::Axis(u8 index, bool positive, const float& axis) KeyboardMouse::Axis::Axis(u8 index, bool positive, const float* axis)
: m_axis(axis), m_index(index), m_positive(positive) : m_axis(axis), m_index(index), m_positive(positive)
{ {
name = std::string("Axis ") + (char)('X' + m_index) + (m_positive ? '+' : '-'); name = std::string("Axis ") + (char)('X' + m_index) + (m_positive ? '+' : '-');
@ -369,7 +369,7 @@ KeyboardMouse::Axis::Axis(u8 index, bool positive, const float& axis)
ControlState KeyboardMouse::Axis::GetState() const ControlState KeyboardMouse::Axis::GetState() const
{ {
return std::max(0.0f, m_axis / (m_positive ? MOUSE_AXIS_SENSITIVITY : -MOUSE_AXIS_SENSITIVITY)); return std::max(0.0f, *m_axis / (m_positive ? MOUSE_AXIS_SENSITIVITY : -MOUSE_AXIS_SENSITIVITY));
} }
} }

View File

@ -54,11 +54,11 @@ private:
{ {
public: public:
std::string GetName() const override { return name; } std::string GetName() const override { return name; }
Button(unsigned int index, unsigned int& buttons); Button(unsigned int index, unsigned int* buttons);
ControlState GetState() const override; ControlState GetState() const override;
private: private:
const unsigned int& m_buttons; const unsigned int* m_buttons;
const unsigned int m_index; const unsigned int m_index;
std::string name; std::string name;
}; };
@ -68,11 +68,11 @@ private:
public: public:
std::string GetName() const override { return name; } std::string GetName() const override { return name; }
bool IsDetectable() override { return false; } bool IsDetectable() override { return false; }
Cursor(u8 index, bool positive, const float& cursor); Cursor(u8 index, bool positive, const float* cursor);
ControlState GetState() const override; ControlState GetState() const override;
private: private:
const float& m_cursor; const float* m_cursor;
const u8 m_index; const u8 m_index;
const bool m_positive; const bool m_positive;
std::string name; std::string name;
@ -83,11 +83,11 @@ private:
public: public:
std::string GetName() const override { return name; } std::string GetName() const override { return name; }
bool IsDetectable() override { return false; } bool IsDetectable() override { return false; }
Axis(u8 index, bool positive, const float& axis); Axis(u8 index, bool positive, const float* axis);
ControlState GetState() const override; ControlState GetState() const override;
private: private:
const float& m_axis; const float* m_axis;
const u8 m_index; const u8 m_index;
const bool m_positive; const bool m_positive;
std::string name; std::string name;

View File

@ -721,7 +721,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
} }
u32 xfbCount = 0; u32 xfbCount = 0;
const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount); const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbWidth, fbHeight, &xfbCount);
if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB) if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
{ {
if (g_ActiveConfig.bDumpFrames && !frame_data.empty()) if (g_ActiveConfig.bDumpFrames && !frame_data.empty())

View File

@ -1385,7 +1385,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
} }
u32 xfbCount = 0; u32 xfbCount = 0;
const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbStride, fbHeight, xfbCount); const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbStride, fbHeight, &xfbCount);
if (g_ActiveConfig.VirtualXFBEnabled() && (!xfbSourceList || xfbCount == 0)) if (g_ActiveConfig.VirtualXFBEnabled() && (!xfbSourceList || xfbCount == 0))
{ {
DumpFrame(frame_data, w, h); DumpFrame(frame_data, w, h);

View File

@ -113,10 +113,9 @@ namespace Clipper
return cmask; return cmask;
} }
static inline void AddInterpolatedVertex(float t, int out, int in, int& numVertices) static inline void AddInterpolatedVertex(float t, int out, int in, int* numVertices)
{ {
Vertices[numVertices]->Lerp(t, Vertices[out], Vertices[in]); Vertices[(*numVertices)++]->Lerp(t, Vertices[out], Vertices[in]);
numVertices++;
} }
#define DIFFERENT_SIGNS(x,y) ((x <= 0 && y > 0) || (x > 0 && y <= 0)) #define DIFFERENT_SIGNS(x,y) ((x <= 0 && y > 0) || (x > 0 && y <= 0))
@ -142,10 +141,10 @@ namespace Clipper
if (DIFFERENT_SIGNS(dp, dpPrev)) { \ if (DIFFERENT_SIGNS(dp, dpPrev)) { \
if (dp < 0) { \ if (dp < 0) { \
float t = dp / (dp - dpPrev); \ float t = dp / (dp - dpPrev); \
AddInterpolatedVertex(t, idx, idxPrev, numVertices); \ AddInterpolatedVertex(t, idx, idxPrev, &numVertices); \
} else { \ } else { \
float t = dpPrev / (dpPrev - dp); \ float t = dpPrev / (dpPrev - dp); \
AddInterpolatedVertex(t, idxPrev, idx, numVertices); \ AddInterpolatedVertex(t, idxPrev, idx, &numVertices); \
} \ } \
outlist[outcount++] = numVertices - 1; \ outlist[outcount++] = numVertices - 1; \
} \ } \
@ -187,7 +186,7 @@ namespace Clipper
} \ } \
} }
static void ClipTriangle(int *indices, int &numIndices) static void ClipTriangle(int *indices, int* numIndices)
{ {
int mask = 0; int mask = 0;
@ -229,9 +228,9 @@ namespace Clipper
indices[2] = inlist[2]; indices[2] = inlist[2];
for (int j = 3; j < n; ++j) for (int j = 3; j < n; ++j)
{ {
indices[numIndices++] = inlist[0]; indices[(*numIndices)++] = inlist[0];
indices[numIndices++] = inlist[j - 1]; indices[(*numIndices)++] = inlist[j - 1];
indices[numIndices++] = inlist[j]; indices[(*numIndices)++] = inlist[j];
} }
} }
} }
@ -276,13 +275,13 @@ namespace Clipper
if (clip_mask[0]) if (clip_mask[0])
{ {
indices[0] = numVertices; indices[0] = numVertices;
AddInterpolatedVertex(t0, 0, 1, numVertices); AddInterpolatedVertex(t0, 0, 1, &numVertices);
} }
if (clip_mask[1]) if (clip_mask[1])
{ {
indices[1] = numVertices; indices[1] = numVertices;
AddInterpolatedVertex(t1, 1, 0, numVertices); AddInterpolatedVertex(t1, 1, 0, &numVertices);
} }
} }
@ -315,7 +314,7 @@ namespace Clipper
Vertices[2] = v2; Vertices[2] = v2;
} }
ClipTriangle(indices, numIndices); ClipTriangle(indices, &numIndices);
for (int i = 0; i+3 <= numIndices; i+=3) for (int i = 0; i+3 <= numIndices; i+=3)
{ {

View File

@ -334,57 +334,57 @@ namespace EfbInterface
} }
} }
static void LogicBlend(u32 srcClr, u32 &dstClr, BlendMode::LogicOp op) static void LogicBlend(u32 srcClr, u32* dstClr, BlendMode::LogicOp op)
{ {
switch (op) switch (op)
{ {
case BlendMode::CLEAR: case BlendMode::CLEAR:
dstClr = 0; *dstClr = 0;
break; break;
case BlendMode::AND: case BlendMode::AND:
dstClr = srcClr & dstClr; *dstClr = srcClr & *dstClr;
break; break;
case BlendMode::AND_REVERSE: case BlendMode::AND_REVERSE:
dstClr = srcClr & (~dstClr); *dstClr = srcClr & (~*dstClr);
break; break;
case BlendMode::COPY: case BlendMode::COPY:
dstClr = srcClr; *dstClr = srcClr;
break; break;
case BlendMode::AND_INVERTED: case BlendMode::AND_INVERTED:
dstClr = (~srcClr) & dstClr; *dstClr = (~srcClr) & *dstClr;
break; break;
case BlendMode::NOOP: case BlendMode::NOOP:
// Do nothing // Do nothing
break; break;
case BlendMode::XOR: case BlendMode::XOR:
dstClr = srcClr ^ dstClr; *dstClr = srcClr ^ *dstClr;
break; break;
case BlendMode::OR: case BlendMode::OR:
dstClr = srcClr | dstClr; *dstClr = srcClr | *dstClr;
break; break;
case BlendMode::NOR: case BlendMode::NOR:
dstClr = ~(srcClr | dstClr); *dstClr = ~(srcClr | *dstClr);
break; break;
case BlendMode::EQUIV: case BlendMode::EQUIV:
dstClr = ~(srcClr ^ dstClr); *dstClr = ~(srcClr ^ *dstClr);
break; break;
case BlendMode::INVERT: case BlendMode::INVERT:
dstClr = ~dstClr; *dstClr = ~*dstClr;
break; break;
case BlendMode::OR_REVERSE: case BlendMode::OR_REVERSE:
dstClr = srcClr | (~dstClr); *dstClr = srcClr | (~*dstClr);
break; break;
case BlendMode::COPY_INVERTED: case BlendMode::COPY_INVERTED:
dstClr = ~srcClr; *dstClr = ~srcClr;
break; break;
case BlendMode::OR_INVERTED: case BlendMode::OR_INVERTED:
dstClr = (~srcClr) | dstClr; *dstClr = (~srcClr) | *dstClr;
break; break;
case BlendMode::NAND: case BlendMode::NAND:
dstClr = ~(srcClr & dstClr); *dstClr = ~(srcClr & *dstClr);
break; break;
case BlendMode::SET: case BlendMode::SET:
dstClr = 0xffffffff; *dstClr = 0xffffffff;
break; break;
} }
} }
@ -416,7 +416,7 @@ namespace EfbInterface
} }
else if (bpmem.blendmode.logicopenable) else if (bpmem.blendmode.logicopenable)
{ {
LogicBlend(*((u32*)color), dstClr, bpmem.blendmode.logicmode); LogicBlend(*((u32*)color), &dstClr, bpmem.blendmode.logicmode);
} }
else else
{ {

View File

@ -210,7 +210,7 @@ static void InitSlope(Slope *slope, float f1, float f2, float f3, float DX31, fl
slope->f0 = f1; slope->f0 = f1;
} }
static inline void CalculateLOD(s32 &lod, bool &linear, u32 texmap, u32 texcoord) static inline void CalculateLOD(s32* lodp, bool* linear, u32 texmap, u32 texcoord)
{ {
FourTexUnits& texUnit = bpmem.tex[(texmap >> 2) & 1]; FourTexUnits& texUnit = bpmem.tex[(texmap >> 2) & 1];
u8 subTexmap = texmap & 3; u8 subTexmap = texmap & 3;
@ -240,20 +240,21 @@ static inline void CalculateLOD(s32 &lod, bool &linear, u32 texmap, u32 texcoord
} }
// get LOD in s28.4 // get LOD in s28.4
lod = FixedLog2(std::max(sDelta, tDelta)); s32 lod = FixedLog2(std::max(sDelta, tDelta));
// bias is s2.5 // bias is s2.5
int bias = tm0.lod_bias; int bias = tm0.lod_bias;
bias >>= 1; bias >>= 1;
lod += bias; lod += bias;
linear = ((lod > 0 && (tm0.min_filter & 4)) || (lod <= 0 && tm0.mag_filter)); *linear = ((lod > 0 && (tm0.min_filter & 4)) || (lod <= 0 && tm0.mag_filter));
// order of checks matters // order of checks matters
// should be: // should be:
// if lod > max then max // if lod > max then max
// else if lod < min then min // else if lod < min then min
lod = CLAMP(lod, (s32)tm1.min_lod, (s32)tm1.max_lod); lod = CLAMP(lod, (s32)tm1.min_lod, (s32)tm1.max_lod);
*lodp = lod;
} }
static void BuildBlock(s32 blockX, s32 blockY) static void BuildBlock(s32 blockX, s32 blockY)
@ -295,7 +296,7 @@ static void BuildBlock(s32 blockX, s32 blockY)
u32 texcoord = indref & 3; u32 texcoord = indref & 3;
indref >>= 3; indref >>= 3;
CalculateLOD(rasterBlock.IndirectLod[i], rasterBlock.IndirectLinear[i], texmap, texcoord); CalculateLOD(&rasterBlock.IndirectLod[i], &rasterBlock.IndirectLinear[i], texmap, texcoord);
} }
for (unsigned int i = 0; i <= bpmem.genMode.numtevstages; i++) for (unsigned int i = 0; i <= bpmem.genMode.numtevstages; i++)
@ -307,7 +308,7 @@ static void BuildBlock(s32 blockX, s32 blockY)
u32 texmap = order.getTexMap(stageOdd); u32 texmap = order.getTexMap(stageOdd);
u32 texcoord = order.getTexCoord(stageOdd); u32 texcoord = order.getTexCoord(stageOdd);
CalculateLOD(rasterBlock.TextureLod[i], rasterBlock.TextureLinear[i], texmap, texcoord); CalculateLOD(&rasterBlock.TextureLod[i], &rasterBlock.TextureLinear[i], texmap, texcoord);
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -16,8 +16,9 @@
namespace TextureSampler namespace TextureSampler
{ {
static inline void WrapCoord(int &coord, int wrapMode, int imageSize) static inline void WrapCoord(int* coordp, int wrapMode, int imageSize)
{ {
int coord = *coordp;
switch (wrapMode) switch (wrapMode)
{ {
case 0: // clamp case 0: // clamp
@ -37,6 +38,7 @@ static inline void WrapCoord(int &coord, int wrapMode, int imageSize)
} }
break; break;
} }
*coordp = coord;
} }
static inline void SetTexel(u8 *inTexel, u32 *outTexel, u32 fract) static inline void SetTexel(u8 *inTexel, u32 *outTexel, u32 fract)
@ -177,10 +179,10 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8 *sample)
u8 sampledTex[4]; u8 sampledTex[4];
u32 texel[4]; u32 texel[4];
WrapCoord(imageS, tm0.wrap_s, imageWidth); WrapCoord(&imageS, tm0.wrap_s, imageWidth);
WrapCoord(imageT, tm0.wrap_t, imageHeight); WrapCoord(&imageT, tm0.wrap_t, imageHeight);
WrapCoord(imageSPlus1, tm0.wrap_s, imageWidth); WrapCoord(&imageSPlus1, tm0.wrap_s, imageWidth);
WrapCoord(imageTPlus1, tm0.wrap_t, imageHeight); WrapCoord(&imageTPlus1, tm0.wrap_t, imageHeight);
if (!(ti0.format == GX_TF_RGBA8 && texUnit.texImage1[subTexmap].image_type)) if (!(ti0.format == GX_TF_RGBA8 && texUnit.texImage1[subTexmap].image_type))
{ {
@ -223,8 +225,8 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8 *sample)
int imageT = t >> 7; int imageT = t >> 7;
// nearest neighbor sampling // nearest neighbor sampling
WrapCoord(imageS, tm0.wrap_s, imageWidth); WrapCoord(&imageS, tm0.wrap_s, imageWidth);
WrapCoord(imageT, tm0.wrap_t, imageHeight); WrapCoord(&imageT, tm0.wrap_t, imageHeight);
if (!(ti0.format == GX_TF_RGBA8 && texUnit.texImage1[subTexmap].image_type)) if (!(ti0.format == GX_TF_RGBA8 && texUnit.texImage1[subTexmap].image_type))
TexDecoder_DecodeTexel(sample, imageSrc, imageS, imageT, imageWidth, ti0.format, tlut, tlutfmt); TexDecoder_DecodeTexel(sample, imageSrc, imageS, imageT, imageWidth, ti0.format, tlut, tlutfmt);

View File

@ -31,20 +31,20 @@ FramebufferManagerBase::~FramebufferManagerBase()
delete m_realXFBSource; delete m_realXFBSource;
} }
const XFBSourceBase* const* FramebufferManagerBase::GetXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount) const XFBSourceBase* const* FramebufferManagerBase::GetXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32* xfbCountP)
{ {
if (!g_ActiveConfig.bUseXFB) if (!g_ActiveConfig.bUseXFB)
return nullptr; return nullptr;
if (g_ActiveConfig.bUseRealXFB) if (g_ActiveConfig.bUseRealXFB)
return GetRealXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount); return GetRealXFBSource(xfbAddr, fbWidth, fbHeight, xfbCountP);
else else
return GetVirtualXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount); return GetVirtualXFBSource(xfbAddr, fbWidth, fbHeight, xfbCountP);
} }
const XFBSourceBase* const* FramebufferManagerBase::GetRealXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount) const XFBSourceBase* const* FramebufferManagerBase::GetRealXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32* xfbCountP)
{ {
xfbCount = 1; *xfbCountP = 1;
// recreate if needed // recreate if needed
if (m_realXFBSource && (m_realXFBSource->texWidth != fbWidth || m_realXFBSource->texHeight != fbHeight)) if (m_realXFBSource && (m_realXFBSource->texWidth != fbWidth || m_realXFBSource->texHeight != fbHeight))
@ -79,9 +79,9 @@ const XFBSourceBase* const* FramebufferManagerBase::GetRealXFBSource(u32 xfbAddr
return &m_overlappingXFBArray[0]; return &m_overlappingXFBArray[0];
} }
const XFBSourceBase* const* FramebufferManagerBase::GetVirtualXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount) const XFBSourceBase* const* FramebufferManagerBase::GetVirtualXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32* xfbCountP)
{ {
xfbCount = 0; u32 xfbCount = 0;
if (m_virtualXFBList.empty()) // no Virtual XFBs available if (m_virtualXFBList.empty()) // no Virtual XFBs available
return nullptr; return nullptr;
@ -106,6 +106,7 @@ const XFBSourceBase* const* FramebufferManagerBase::GetVirtualXFBSource(u32 xfbA
} }
} }
*xfbCountP = xfbCount;
return &m_overlappingXFBArray[0]; return &m_overlappingXFBArray[0];
} }

View File

@ -45,7 +45,7 @@ public:
virtual ~FramebufferManagerBase(); virtual ~FramebufferManagerBase();
static void CopyToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma); static void CopyToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma);
static const XFBSourceBase* const* GetXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount); static const XFBSourceBase* const* GetXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32* xfbCount);
static void SetLastXfbWidth(unsigned int width) { s_last_xfb_width = width; } static void SetLastXfbWidth(unsigned int width) { s_last_xfb_width = width; }
static void SetLastXfbHeight(unsigned int height) { s_last_xfb_height = height; } static void SetLastXfbHeight(unsigned int height) { s_last_xfb_height = height; }
@ -83,8 +83,8 @@ private:
virtual void CopyToRealXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma = 1.0f) = 0; virtual void CopyToRealXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma = 1.0f) = 0;
static void CopyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma = 1.0f); static void CopyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma = 1.0f);
static const XFBSourceBase* const* GetRealXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount); static const XFBSourceBase* const* GetRealXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32* xfbCount);
static const XFBSourceBase* const* GetVirtualXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount); static const XFBSourceBase* const* GetVirtualXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32* xfbCount);
static XFBSourceBase *m_realXFBSource; // Only used in Real XFB mode static XFBSourceBase *m_realXFBSource; // Only used in Real XFB mode
static VirtualXFBListType m_virtualXFBList; // Only used in Virtual XFB mode static VirtualXFBListType m_virtualXFBList; // Only used in Virtual XFB mode

View File

@ -151,17 +151,17 @@ int Renderer::EFBToScaledY(int y)
}; };
} }
void Renderer::CalculateTargetScale(int x, int y, int &scaledX, int &scaledY) void Renderer::CalculateTargetScale(int x, int y, int* scaledX, int* scaledY)
{ {
if (g_ActiveConfig.iEFBScale == SCALE_AUTO || g_ActiveConfig.iEFBScale == SCALE_AUTO_INTEGRAL) if (g_ActiveConfig.iEFBScale == SCALE_AUTO || g_ActiveConfig.iEFBScale == SCALE_AUTO_INTEGRAL)
{ {
scaledX = x; *scaledX = x;
scaledY = y; *scaledY = y;
} }
else else
{ {
scaledX = x * (int)efb_scale_numeratorX / (int)efb_scale_denominatorX; *scaledX = x * (int)efb_scale_numeratorX / (int)efb_scale_denominatorX;
scaledY = y * (int)efb_scale_numeratorY / (int)efb_scale_denominatorY; *scaledY = y * (int)efb_scale_numeratorY / (int)efb_scale_denominatorY;
} }
} }
@ -228,7 +228,7 @@ bool Renderer::CalculateTargetSize(unsigned int framebuffer_width, unsigned int
break; break;
} }
if (s_LastEFBScale > SCALE_AUTO_INTEGRAL) if (s_LastEFBScale > SCALE_AUTO_INTEGRAL)
CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT, newEFBWidth, newEFBHeight); CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT, &newEFBWidth, &newEFBHeight);
if (newEFBWidth != s_target_width || newEFBHeight != s_target_height) if (newEFBWidth != s_target_width || newEFBHeight != s_target_height)
{ {
@ -477,7 +477,7 @@ void Renderer::SetWindowSize(int width, int height)
height = 1; height = 1;
// Scale the window size by the EFB scale. // Scale the window size by the EFB scale.
CalculateTargetScale(width, height, width, height); CalculateTargetScale(width, height, &width, &height);
Host_RequestRenderWindowSize(width, height); Host_RequestRenderWindowSize(width, height);
} }

View File

@ -123,7 +123,7 @@ public:
protected: protected:
static void CalculateTargetScale(int x, int y, int &scaledX, int &scaledY); static void CalculateTargetScale(int x, int y, int* scaledX, int* scaledY);
bool CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height); bool CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height);
static void CheckFifoRecording(); static void CheckFifoRecording();

View File

@ -267,7 +267,7 @@ bool TextureCache::CheckForCustomTextureLODs(u64 tex_hash, int texformat, unsign
return true; return true;
} }
PC_TexFormat TextureCache::LoadCustomTexture(u64 tex_hash, int texformat, unsigned int level, unsigned int& width, unsigned int& height) PC_TexFormat TextureCache::LoadCustomTexture(u64 tex_hash, int texformat, unsigned int level, unsigned int* widthp, unsigned int* heightp)
{ {
std::string texPathTemp; std::string texPathTemp;
unsigned int newWidth = 0; unsigned int newWidth = 0;
@ -293,6 +293,7 @@ PC_TexFormat TextureCache::LoadCustomTexture(u64 tex_hash, int texformat, unsign
if (ret != PC_TEX_FMT_NONE) if (ret != PC_TEX_FMT_NONE)
{ {
unsigned int width = *widthp, height = *heightp;
if (level > 0 && (newWidth != width || newHeight != height)) if (level > 0 && (newWidth != width || newHeight != height))
ERROR_LOG(VIDEO, "Invalid custom texture size %dx%d for texture %s. This mipmap layer _must_ be %dx%d.", newWidth, newHeight, texPathTemp.c_str(), width, height); ERROR_LOG(VIDEO, "Invalid custom texture size %dx%d for texture %s. This mipmap layer _must_ be %dx%d.", newWidth, newHeight, texPathTemp.c_str(), width, height);
if (newWidth * height != newHeight * width) if (newWidth * height != newHeight * width)
@ -300,8 +301,8 @@ PC_TexFormat TextureCache::LoadCustomTexture(u64 tex_hash, int texformat, unsign
if (newWidth % width || newHeight % height) if (newWidth % width || newHeight % height)
WARN_LOG(VIDEO, "Invalid custom texture size %dx%d for texture %s. Please use an integer upscaling factor based on the native size %dx%d.", newWidth, newHeight, texPathTemp.c_str(), width, height); WARN_LOG(VIDEO, "Invalid custom texture size %dx%d for texture %s. Please use an integer upscaling factor based on the native size %dx%d.", newWidth, newHeight, texPathTemp.c_str(), width, height);
width = newWidth; *widthp = newWidth;
height = newHeight; *heightp = newHeight;
} }
return ret; return ret;
} }
@ -466,8 +467,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage,
if (g_ActiveConfig.bHiresTextures) if (g_ActiveConfig.bHiresTextures)
{ {
// This function may modify width/height. pcfmt = LoadCustomTexture(tex_hash, texformat, 0, &width, &height);
pcfmt = LoadCustomTexture(tex_hash, texformat, 0, width, height);
if (pcfmt != PC_TEX_FMT_NONE) if (pcfmt != PC_TEX_FMT_NONE)
{ {
if (expandedWidth != width || expandedHeight != height) if (expandedWidth != width || expandedHeight != height)
@ -584,7 +584,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage,
unsigned int mip_width = CalculateLevelSize(width, level); unsigned int mip_width = CalculateLevelSize(width, level);
unsigned int mip_height = CalculateLevelSize(height, level); unsigned int mip_height = CalculateLevelSize(height, level);
LoadCustomTexture(tex_hash, texformat, level, mip_width, mip_height); LoadCustomTexture(tex_hash, texformat, level, &mip_width, &mip_height);
entry->Load(mip_width, mip_height, mip_width, level); entry->Load(mip_width, mip_height, mip_width, level);
} }
} }

View File

@ -116,7 +116,7 @@ protected:
private: private:
static bool CheckForCustomTextureLODs(u64 tex_hash, int texformat, unsigned int levels); static bool CheckForCustomTextureLODs(u64 tex_hash, int texformat, unsigned int levels);
static PC_TexFormat LoadCustomTexture(u64 tex_hash, int texformat, unsigned int level, unsigned int& width, unsigned int& height); static PC_TexFormat LoadCustomTexture(u64 tex_hash, int texformat, unsigned int level, unsigned int* width, unsigned int* height);
static void DumpTexture(TCacheEntryBase* entry, unsigned int level); static void DumpTexture(TCacheEntryBase* entry, unsigned int level);
static TCacheEntryBase* AllocateRenderTarget(unsigned int width, unsigned int height); static TCacheEntryBase* AllocateRenderTarget(unsigned int width, unsigned int height);