EfbInterface: Change out parameters on getters to return by value
This commit is contained in:
parent
023eb34247
commit
33288c4569
|
@ -2,13 +2,17 @@
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "VideoBackends/Software/DebugUtil.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "Common/CommonFuncs.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
#include "Core/ConfigManager.h"
|
#include "Core/ConfigManager.h"
|
||||||
|
|
||||||
#include "VideoBackends/Software/DebugUtil.h"
|
|
||||||
#include "VideoBackends/Software/EfbInterface.h"
|
#include "VideoBackends/Software/EfbInterface.h"
|
||||||
#include "VideoBackends/Software/SWRenderer.h"
|
#include "VideoBackends/Software/SWRenderer.h"
|
||||||
#include "VideoBackends/Software/TextureSampler.h"
|
#include "VideoBackends/Software/TextureSampler.h"
|
||||||
|
@ -133,18 +137,16 @@ static void DumpEfb(const std::string& filename)
|
||||||
{
|
{
|
||||||
u8* data = new u8[EFB_WIDTH * EFB_HEIGHT * 4];
|
u8* data = new u8[EFB_WIDTH * EFB_HEIGHT * 4];
|
||||||
u8* writePtr = data;
|
u8* writePtr = data;
|
||||||
u8 sample[4];
|
|
||||||
|
|
||||||
for (int y = 0; y < EFB_HEIGHT; y++)
|
for (int y = 0; y < EFB_HEIGHT; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < EFB_WIDTH; x++)
|
for (int x = 0; x < EFB_WIDTH; x++)
|
||||||
{
|
{
|
||||||
EfbInterface::GetColor(x, y, sample);
|
|
||||||
// ABGR to RGBA
|
// ABGR to RGBA
|
||||||
*(writePtr++) = sample[3];
|
const u32 sample = Common::swap32(EfbInterface::GetColor(x, y));
|
||||||
*(writePtr++) = sample[2];
|
|
||||||
*(writePtr++) = sample[1];
|
std::memcpy(writePtr, &sample, sizeof(u32));
|
||||||
*(writePtr++) = sample[0];
|
writePtr += sizeof(u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,15 @@
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "VideoBackends/Software/EfbInterface.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include "Common/CommonFuncs.h"
|
#include "Common/CommonFuncs.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "VideoBackends/Software/EfbInterface.h"
|
|
||||||
#include "VideoCommon/BPMemory.h"
|
#include "VideoCommon/BPMemory.h"
|
||||||
#include "VideoCommon/LookUpTables.h"
|
#include "VideoCommon/LookUpTables.h"
|
||||||
#include "VideoCommon/PerfQueryBase.h"
|
#include "VideoCommon/PerfQueryBase.h"
|
||||||
|
@ -132,39 +135,30 @@ static void SetPixelAlphaColor(u32 offset, u8* color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GetPixelColor(u32 offset, u8* color)
|
static u32 GetPixelColor(u32 offset)
|
||||||
{
|
{
|
||||||
|
u32 src;
|
||||||
|
std::memcpy(&src, &efb[offset], sizeof(u32));
|
||||||
|
|
||||||
switch (bpmem.zcontrol.pixel_format)
|
switch (bpmem.zcontrol.pixel_format)
|
||||||
{
|
{
|
||||||
case PEControl::RGB8_Z24:
|
case PEControl::RGB8_Z24:
|
||||||
case PEControl::Z24:
|
case PEControl::Z24:
|
||||||
{
|
return 0xff | ((src & 0x00ffffff) << 8);
|
||||||
u32 src = *(u32*)&efb[offset];
|
|
||||||
u32* dst = (u32*)color;
|
|
||||||
u32 val = 0xff | ((src & 0x00ffffff) << 8);
|
|
||||||
*dst = val;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PEControl::RGBA6_Z24:
|
case PEControl::RGBA6_Z24:
|
||||||
{
|
return Convert6To8(src & 0x3f) | // Alpha
|
||||||
u32 src = *(u32*)&efb[offset];
|
Convert6To8((src >> 6) & 0x3f) << 8 | // Blue
|
||||||
color[ALP_C] = Convert6To8(src & 0x3f);
|
Convert6To8((src >> 12) & 0x3f) << 16 | // Green
|
||||||
color[BLU_C] = Convert6To8((src >> 6) & 0x3f);
|
Convert6To8((src >> 18) & 0x3f) << 24; // Red
|
||||||
color[GRN_C] = Convert6To8((src >> 12) & 0x3f);
|
|
||||||
color[RED_C] = Convert6To8((src >> 18) & 0x3f);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PEControl::RGB565_Z16:
|
case PEControl::RGB565_Z16:
|
||||||
{
|
|
||||||
INFO_LOG(VIDEO, "RGB565_Z16 is not supported correctly yet");
|
INFO_LOG(VIDEO, "RGB565_Z16 is not supported correctly yet");
|
||||||
u32 src = *(u32*)&efb[offset];
|
return 0xff | ((src & 0x00ffffff) << 8);
|
||||||
u32* dst = (u32*)color;
|
|
||||||
u32 val = 0xff | ((src & 0x00ffffff) << 8);
|
|
||||||
*dst = val;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
ERROR_LOG(VIDEO, "Unsupported pixel format: %i", static_cast<int>(bpmem.zcontrol.pixel_format));
|
ERROR_LOG(VIDEO, "Unsupported pixel format: %i", static_cast<int>(bpmem.zcontrol.pixel_format));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,13 +400,11 @@ static void Dither(u16 x, u16 y, u8* color)
|
||||||
|
|
||||||
void BlendTev(u16 x, u16 y, u8* color)
|
void BlendTev(u16 x, u16 y, u8* color)
|
||||||
{
|
{
|
||||||
u32 dstClr;
|
const u32 offset = GetColorOffset(x, y);
|
||||||
u32 offset = GetColorOffset(x, y);
|
u32 dstClr = GetPixelColor(offset);
|
||||||
|
|
||||||
u8* dstClrPtr = (u8*)&dstClr;
|
u8* dstClrPtr = (u8*)&dstClr;
|
||||||
|
|
||||||
GetPixelColor(offset, dstClrPtr);
|
|
||||||
|
|
||||||
if (bpmem.blendmode.blendenable)
|
if (bpmem.blendmode.blendenable)
|
||||||
{
|
{
|
||||||
if (bpmem.blendmode.subtract)
|
if (bpmem.blendmode.subtract)
|
||||||
|
@ -468,23 +460,25 @@ void SetDepth(u16 x, u16 y, u32 depth)
|
||||||
SetPixelDepth(GetDepthOffset(x, y), depth);
|
SetPixelDepth(GetDepthOffset(x, y), depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetColor(u16 x, u16 y, u8* color)
|
u32 GetColor(u16 x, u16 y)
|
||||||
{
|
{
|
||||||
u32 offset = GetColorOffset(x, y);
|
u32 offset = GetColorOffset(x, y);
|
||||||
GetPixelColor(offset, color);
|
return GetPixelColor(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For internal used only, return a non-normalized value, which saves work later.
|
// For internal used only, return a non-normalized value, which saves work later.
|
||||||
void GetColorYUV(u16 x, u16 y, yuv444* out)
|
yuv444 GetColorYUV(u16 x, u16 y)
|
||||||
{
|
{
|
||||||
u8 color[4];
|
const u32 color = GetColor(x, y);
|
||||||
GetColor(x, y, color);
|
const u8 red = static_cast<u8>(color >> 24);
|
||||||
|
const u8 green = static_cast<u8>(color >> 16);
|
||||||
|
const u8 blue = static_cast<u8>(color >> 8);
|
||||||
|
|
||||||
// GameCube/Wii uses the BT.601 standard algorithm for converting to YCbCr; see
|
// GameCube/Wii uses the BT.601 standard algorithm for converting to YCbCr; see
|
||||||
// http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion
|
// http://www.equasys.de/colorconversion.html#YCbCr-RGBColorFormatConversion
|
||||||
out->Y = (u8)(0.257f * color[RED_C] + 0.504f * color[GRN_C] + 0.098f * color[BLU_C]);
|
return {static_cast<u8>(0.257f * red + 0.504f * green + 0.098f * blue),
|
||||||
out->U = (u8)(-0.148f * color[RED_C] + -0.291f * color[GRN_C] + 0.439f * color[BLU_C]);
|
static_cast<s8>(-0.148f * red + -0.291f * green + 0.439f * blue),
|
||||||
out->V = (u8)(0.439f * color[RED_C] + -0.368f * color[GRN_C] + -0.071f * color[BLU_C]);
|
static_cast<s8>(0.439f * red + -0.368f * green + -0.071f * blue)};
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GetDepth(u16 x, u16 y)
|
u32 GetDepth(u16 x, u16 y)
|
||||||
|
@ -540,7 +534,7 @@ void CopyToXFB(yuv422_packed* xfb_in_ram, u32 fbWidth, u32 fbHeight, const EFBRe
|
||||||
|
|
||||||
for (int i = 1, x = left; x < right; i++, x++)
|
for (int i = 1, x = left; x < right; i++, x++)
|
||||||
{
|
{
|
||||||
GetColorYUV(x, y, &scanline[i]);
|
scanline[i] = GetColorYUV(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// And Downsample them to 4:2:2
|
// And Downsample them to 4:2:2
|
||||||
|
@ -573,20 +567,18 @@ void BypassXFB(u8* texture, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourc
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 color;
|
size_t textureAddress = 0;
|
||||||
u8* colorPtr = (u8*)&color;
|
const int left = sourceRc.left;
|
||||||
u32* texturePtr = (u32*)texture;
|
const int right = sourceRc.right;
|
||||||
u32 textureAddress = 0;
|
|
||||||
|
|
||||||
int left = sourceRc.left;
|
|
||||||
int right = sourceRc.right;
|
|
||||||
|
|
||||||
for (u16 y = sourceRc.top; y < sourceRc.bottom; y++)
|
for (u16 y = sourceRc.top; y < sourceRc.bottom; y++)
|
||||||
{
|
{
|
||||||
for (u16 x = left; x < right; x++)
|
for (u16 x = left; x < right; x++)
|
||||||
{
|
{
|
||||||
GetColor(x, y, colorPtr);
|
const u32 color = Common::swap32(GetColor(x, y) | 0xFF);
|
||||||
texturePtr[textureAddress++] = Common::swap32(color | 0xFF);
|
|
||||||
|
std::memcpy(&texture[textureAddress], &color, sizeof(u32));
|
||||||
|
textureAddress += sizeof(u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,8 @@ bool ZCompare(u16 x, u16 y, u32 z);
|
||||||
void SetColor(u16 x, u16 y, u8* color);
|
void SetColor(u16 x, u16 y, u8* color);
|
||||||
void SetDepth(u16 x, u16 y, u32 depth);
|
void SetDepth(u16 x, u16 y, u32 depth);
|
||||||
|
|
||||||
void GetColor(u16 x, u16 y, u8* color);
|
u32 GetColor(u16 x, u16 y);
|
||||||
void GetColorYUV(u16 x, u16 y, yuv444* color);
|
yuv444 GetColorYUV(u16 x, u16 y);
|
||||||
u32 GetDepth(u16 x, u16 y);
|
u32 GetDepth(u16 x, u16 y);
|
||||||
|
|
||||||
u8* GetPixelPointer(u16 x, u16 y, bool depth);
|
u8* GetPixelPointer(u16 x, u16 y, bool depth);
|
||||||
|
|
|
@ -176,8 +176,7 @@ u32 SWRenderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
|
||||||
}
|
}
|
||||||
case PEEK_COLOR:
|
case PEEK_COLOR:
|
||||||
{
|
{
|
||||||
u32 color = 0;
|
const u32 color = EfbInterface::GetColor(x, y);
|
||||||
EfbInterface::GetColor(x, y, (u8*)&color);
|
|
||||||
|
|
||||||
// rgba to argb
|
// rgba to argb
|
||||||
value = (color >> 8) | (color & 0xff) << 24;
|
value = (color >> 8) | (color & 0xff) << 24;
|
||||||
|
|
Loading…
Reference in New Issue