mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
BPMemory: Expose the pixel_format and zformat fields in PE_CONTROL as enumerations.
This commit is contained in:
@ -79,10 +79,10 @@ void SetColorMask()
|
||||
g_renderer->SetColorMask();
|
||||
}
|
||||
|
||||
void CopyEFB(u32 dstAddr, unsigned int dstFormat, unsigned int srcFormat,
|
||||
void CopyEFB(u32 dstAddr, unsigned int dstFormat, PEControl::PixelFormat srcFormat,
|
||||
const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf)
|
||||
{
|
||||
// bpmem.zcontrol.pixel_format to PIXELFMT_Z24 is when the game wants to copy from ZBuffer (Zbuffer uses 24-bit Format)
|
||||
// bpmem.zcontrol.pixel_format to PEControl::Z24 is when the game wants to copy from ZBuffer (Zbuffer uses 24-bit Format)
|
||||
if (g_ActiveConfig.bEFBCopyEnable)
|
||||
{
|
||||
TextureCache::CopyRenderTargetToTexture(dstAddr, dstFormat, srcFormat,
|
||||
@ -111,11 +111,12 @@ void ClearScreen(const EFBRectangle &rc)
|
||||
bool colorEnable = bpmem.blendmode.colorupdate;
|
||||
bool alphaEnable = bpmem.blendmode.alphaupdate;
|
||||
bool zEnable = bpmem.zmode.updateenable;
|
||||
auto pixel_format = bpmem.zcontrol.pixel_format;
|
||||
|
||||
// (1): Disable unused color channels
|
||||
if (bpmem.zcontrol.pixel_format == PIXELFMT_RGB8_Z24 ||
|
||||
bpmem.zcontrol.pixel_format == PIXELFMT_RGB565_Z16 ||
|
||||
bpmem.zcontrol.pixel_format == PIXELFMT_Z24)
|
||||
if (pixel_format == PEControl::RGB8_Z24 ||
|
||||
pixel_format == PEControl::RGB565_Z16 ||
|
||||
pixel_format == PEControl::Z24)
|
||||
{
|
||||
alphaEnable = false;
|
||||
}
|
||||
@ -126,11 +127,11 @@ void ClearScreen(const EFBRectangle &rc)
|
||||
u32 z = bpmem.clearZValue;
|
||||
|
||||
// (2) drop additional accuracy
|
||||
if (bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24)
|
||||
if (pixel_format == PEControl::RGBA6_Z24)
|
||||
{
|
||||
color = RGBA8ToRGBA6ToRGBA8(color);
|
||||
}
|
||||
else if (bpmem.zcontrol.pixel_format == PIXELFMT_RGB565_Z16)
|
||||
else if (pixel_format == PEControl::RGB565_Z16)
|
||||
{
|
||||
color = RGBA8ToRGB565ToRGBA8(color);
|
||||
z = Z24ToZ16ToZ24(z);
|
||||
@ -156,8 +157,8 @@ void OnPixelFormatChange()
|
||||
!g_ActiveConfig.backend_info.bSupportsFormatReinterpretation)
|
||||
return;
|
||||
|
||||
u32 old_format = Renderer::GetPrevPixelFormat();
|
||||
u32 new_format = bpmem.zcontrol.pixel_format;
|
||||
auto old_format = Renderer::GetPrevPixelFormat();
|
||||
auto new_format = bpmem.zcontrol.pixel_format;
|
||||
|
||||
// no need to reinterpret pixel data in these cases
|
||||
if (new_format == old_format || old_format == (unsigned int)-1)
|
||||
@ -166,31 +167,31 @@ void OnPixelFormatChange()
|
||||
// Check for pixel format changes
|
||||
switch (old_format)
|
||||
{
|
||||
case PIXELFMT_RGB8_Z24:
|
||||
case PIXELFMT_Z24:
|
||||
case PEControl::RGB8_Z24:
|
||||
case PEControl::Z24:
|
||||
// Z24 and RGB8_Z24 are treated equal, so just return in this case
|
||||
if (new_format == PIXELFMT_RGB8_Z24 || new_format == PIXELFMT_Z24)
|
||||
if (new_format == PEControl::RGB8_Z24 || new_format == PEControl::Z24)
|
||||
goto skip;
|
||||
|
||||
if (new_format == PIXELFMT_RGBA6_Z24)
|
||||
if (new_format == PEControl::RGBA6_Z24)
|
||||
convtype = 0;
|
||||
else if (new_format == PIXELFMT_RGB565_Z16)
|
||||
else if (new_format == PEControl::RGB565_Z16)
|
||||
convtype = 1;
|
||||
break;
|
||||
|
||||
case PIXELFMT_RGBA6_Z24:
|
||||
if (new_format == PIXELFMT_RGB8_Z24 ||
|
||||
new_format == PIXELFMT_Z24)
|
||||
case PEControl::RGBA6_Z24:
|
||||
if (new_format == PEControl::RGB8_Z24 ||
|
||||
new_format == PEControl::Z24)
|
||||
convtype = 2;
|
||||
else if (new_format == PIXELFMT_RGB565_Z16)
|
||||
else if (new_format == PEControl::RGB565_Z16)
|
||||
convtype = 3;
|
||||
break;
|
||||
|
||||
case PIXELFMT_RGB565_Z16:
|
||||
if (new_format == PIXELFMT_RGB8_Z24 ||
|
||||
new_format == PIXELFMT_Z24)
|
||||
case PEControl::RGB565_Z16:
|
||||
if (new_format == PEControl::RGB8_Z24 ||
|
||||
new_format == PEControl::Z24)
|
||||
convtype = 4;
|
||||
else if (new_format == PIXELFMT_RGBA6_Z24)
|
||||
else if (new_format == PEControl::RGBA6_Z24)
|
||||
convtype = 5;
|
||||
break;
|
||||
|
||||
@ -200,14 +201,14 @@ void OnPixelFormatChange()
|
||||
|
||||
if (convtype == -1)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "Unhandled EFB format change: %d to %d\n", old_format, new_format);
|
||||
ERROR_LOG(VIDEO, "Unhandled EFB format change: %d to %d\n", static_cast<int>(old_format), static_cast<int>(new_format));
|
||||
goto skip;
|
||||
}
|
||||
|
||||
g_renderer->ReinterpretPixelData(convtype);
|
||||
|
||||
skip:
|
||||
DEBUG_LOG(VIDEO, "pixelfmt: pixel=%d, zc=%d", new_format, bpmem.zcontrol.zformat);
|
||||
DEBUG_LOG(VIDEO, "pixelfmt: pixel=%d, zc=%d", static_cast<int>(new_format), static_cast<int>(bpmem.zcontrol.zformat));
|
||||
|
||||
Renderer::StorePixelFormat(new_format);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ void SetBlendMode();
|
||||
void SetDitherMode();
|
||||
void SetLogicOpMode();
|
||||
void SetColorMask();
|
||||
void CopyEFB(u32 dstAddr, unsigned int dstFormat, unsigned int srcFormat,
|
||||
void CopyEFB(u32 dstAddr, unsigned int dstFormat, PEControl::PixelFormat srcFormat,
|
||||
const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf);
|
||||
void ClearScreen(const EFBRectangle &rc);
|
||||
void OnPixelFormatChange();
|
||||
|
@ -92,7 +92,7 @@ void GetBPRegInfo(const u8* data, char* name, size_t name_size, char* desc, size
|
||||
case BPMEM_ZCOMPARE:
|
||||
{
|
||||
SetRegName(BPMEM_ZCOMPARE);
|
||||
PE_CONTROL config; config.hex = cmddata;
|
||||
PEControl config; config.hex = cmddata;
|
||||
const char* pixel_formats[] = { "RGB8_Z24", "RGBA6_Z24", "RGB565_Z16", "Z24", "Y8", "U8", "V8", "YUV420" };
|
||||
const char* zformats[] = { "linear", "compressed (near)", "compressed (mid)", "compressed (far)", "inv linear", "compressed (inv near)", "compressed (inv mid)", "compressed (inv far)" };
|
||||
snprintf(desc, desc_size, "EFB pixel format: %s\n"
|
||||
|
@ -773,36 +773,38 @@ union FieldMask
|
||||
u32 hex;
|
||||
};
|
||||
|
||||
#define PIXELFMT_RGB8_Z24 0
|
||||
#define PIXELFMT_RGBA6_Z24 1
|
||||
#define PIXELFMT_RGB565_Z16 2
|
||||
#define PIXELFMT_Z24 3
|
||||
#define PIXELFMT_Y8 4
|
||||
#define PIXELFMT_U8 5
|
||||
#define PIXELFMT_V8 6
|
||||
#define PIXELFMT_YUV420 7
|
||||
|
||||
#define ZC_LINEAR 0
|
||||
#define ZC_NEAR 1
|
||||
#define ZC_MID 2
|
||||
#define ZC_FAR 3
|
||||
// It seems these Z formats aren't supported/were removed ?
|
||||
#define ZC_INV_LINEAR 4
|
||||
#define ZC_INV_NEAR 5
|
||||
#define ZC_INV_MID 6
|
||||
#define ZC_INV_FAR 7
|
||||
|
||||
union PE_CONTROL
|
||||
union PEControl
|
||||
{
|
||||
struct
|
||||
enum PixelFormat : u32
|
||||
{
|
||||
u32 pixel_format : 3; // PIXELFMT_X
|
||||
u32 zformat : 3; // Z Compression for 16bit Z format
|
||||
u32 early_ztest : 1; // 1: before tex stage
|
||||
u32 unused : 17;
|
||||
u32 rid : 8;
|
||||
RGB8_Z24 = 0,
|
||||
RGBA6_Z24 = 1,
|
||||
RGB565_Z16 = 2,
|
||||
Z24 = 3,
|
||||
Y8 = 4,
|
||||
U8 = 5,
|
||||
V8 = 6,
|
||||
YUV420 = 7
|
||||
};
|
||||
|
||||
enum DepthFormat : u32
|
||||
{
|
||||
ZLINEAR = 0,
|
||||
ZNEAR = 1,
|
||||
ZMID = 2,
|
||||
ZFAR = 3,
|
||||
|
||||
// It seems these Z formats aren't supported/were removed ?
|
||||
ZINV_LINEAR = 4,
|
||||
ZINV_NEAR = 5,
|
||||
ZINV_MID = 6,
|
||||
ZINV_FAR = 7
|
||||
};
|
||||
|
||||
BitField< 0,3,PixelFormat> pixel_format;
|
||||
BitField< 3,3,DepthFormat> zformat;
|
||||
BitField< 6,1,u32> early_ztest;
|
||||
|
||||
u32 hex;
|
||||
};
|
||||
|
||||
@ -999,7 +1001,7 @@ struct BPMemory
|
||||
ZMode zmode; //40
|
||||
BlendMode blendmode; //41
|
||||
ConstantAlpha dstalpha; //42
|
||||
PE_CONTROL zcontrol; //43 GXSetZCompLoc, GXPixModeSync
|
||||
PEControl zcontrol; //43 GXSetZCompLoc, GXPixModeSync
|
||||
FieldMask fieldmask; //44
|
||||
u32 drawdone; //45, bit1=1 if end of list
|
||||
u32 unknown5; //46 clock?
|
||||
|
@ -86,7 +86,7 @@ void GFXDebuggerBase::DumpPixelShader(const std::string& path)
|
||||
const std::string filename = StringFromFormat("%sdump_ps.txt", path.c_str());
|
||||
|
||||
std::string output;
|
||||
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
|
||||
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate && bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24;
|
||||
if (!useDstAlpha)
|
||||
{
|
||||
output = "Destination alpha disabled:\n";
|
||||
|
@ -64,7 +64,7 @@ int Renderer::s_LastEFBScale;
|
||||
bool Renderer::s_skipSwap;
|
||||
bool Renderer::XFBWrited;
|
||||
|
||||
unsigned int Renderer::prev_efb_format = (unsigned int)-1;
|
||||
PEControl::PixelFormat Renderer::prev_efb_format = (PEControl::PixelFormat)-1;
|
||||
unsigned int Renderer::efb_scale_numeratorX = 1;
|
||||
unsigned int Renderer::efb_scale_numeratorY = 1;
|
||||
unsigned int Renderer::efb_scale_denominatorX = 1;
|
||||
@ -89,7 +89,7 @@ Renderer::Renderer()
|
||||
Renderer::~Renderer()
|
||||
{
|
||||
// invalidate previous efb format
|
||||
prev_efb_format = (unsigned int)-1;
|
||||
prev_efb_format = (PEControl::PixelFormat)-1;
|
||||
|
||||
efb_scale_numeratorX = efb_scale_numeratorY = efb_scale_denominatorX = efb_scale_denominatorY = 1;
|
||||
|
||||
|
@ -111,8 +111,8 @@ public:
|
||||
|
||||
virtual bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc) = 0;
|
||||
|
||||
static unsigned int GetPrevPixelFormat() { return prev_efb_format; }
|
||||
static void StorePixelFormat(unsigned int new_format) { prev_efb_format = new_format; }
|
||||
static PEControl::PixelFormat GetPrevPixelFormat() { return prev_efb_format; }
|
||||
static void StorePixelFormat(PEControl::PixelFormat new_format) { prev_efb_format = new_format; }
|
||||
|
||||
protected:
|
||||
|
||||
@ -151,7 +151,7 @@ protected:
|
||||
static bool XFBWrited;
|
||||
|
||||
private:
|
||||
static unsigned int prev_efb_format;
|
||||
static PEControl::PixelFormat prev_efb_format;
|
||||
static unsigned int efb_scale_numeratorX;
|
||||
static unsigned int efb_scale_numeratorY;
|
||||
static unsigned int efb_scale_denominatorX;
|
||||
|
@ -572,7 +572,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int const stage,
|
||||
return ReturnEntry(stage, entry);
|
||||
}
|
||||
|
||||
void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, unsigned int srcFormat,
|
||||
void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, PEControl::PixelFormat srcFormat,
|
||||
const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf)
|
||||
{
|
||||
// Emulation methods:
|
||||
@ -623,9 +623,9 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat
|
||||
ColorMask[0] = ColorMask[1] = ColorMask[2] = ColorMask[3] = 255.0f;
|
||||
ColorMask[4] = ColorMask[5] = ColorMask[6] = ColorMask[7] = 1.0f / 255.0f;
|
||||
unsigned int cbufid = -1;
|
||||
bool efbHasAlpha = bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
|
||||
bool efbHasAlpha = bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24;
|
||||
|
||||
if (srcFormat == PIXELFMT_Z24)
|
||||
if (srcFormat == PEControl::Z24)
|
||||
{
|
||||
switch (dstFormat)
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
virtual void Load(unsigned int width, unsigned int height,
|
||||
unsigned int expanded_width, unsigned int level) = 0;
|
||||
virtual void FromRenderTarget(u32 dstAddr, unsigned int dstFormat,
|
||||
unsigned int srcFormat, const EFBRectangle& srcRect,
|
||||
PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect,
|
||||
bool isIntensity, bool scaleByHalf, unsigned int cbufid,
|
||||
const float *colmat) = 0;
|
||||
|
||||
@ -103,7 +103,7 @@ public:
|
||||
|
||||
static TCacheEntryBase* Load(unsigned int stage, u32 address, unsigned int width, unsigned int height,
|
||||
int format, unsigned int tlutaddr, int tlutfmt, bool use_mipmaps, unsigned int maxlevel, bool from_tmem);
|
||||
static void CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, unsigned int srcFormat,
|
||||
static void CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat, PEControl::PixelFormat srcFormat,
|
||||
const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf);
|
||||
|
||||
static void RequestInvalidateTextureCache();
|
||||
|
@ -219,7 +219,7 @@ void VertexManager::Flush()
|
||||
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass &&
|
||||
bpmem.dstalpha.enable &&
|
||||
bpmem.blendmode.alphaupdate &&
|
||||
bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
|
||||
bpmem.zcontrol.pixel_format == PEControl::RGBA6_Z24;
|
||||
|
||||
if (PerfQueryBase::ShouldEmulate())
|
||||
g_perf_query->EnableQuery(bpmem.zcontrol.early_ztest ? PQG_ZCOMP_ZCOMPLOC : PQG_ZCOMP);
|
||||
|
Reference in New Issue
Block a user