2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2009 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2010-06-09 01:37:08 +00:00
|
|
|
|
2017-01-23 16:20:20 +00:00
|
|
|
#include "VideoBackends/Software/SWRenderer.h"
|
|
|
|
|
2014-06-03 05:08:54 +00:00
|
|
|
#include <string>
|
2014-05-03 02:47:04 +00:00
|
|
|
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2023-01-29 16:06:25 +00:00
|
|
|
#include "Common/MsgHandler.h"
|
2015-09-18 16:40:00 +00:00
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
#include "Core/HW/Memmap.h"
|
2022-12-10 15:35:07 +00:00
|
|
|
#include "Core/System.h"
|
2015-09-18 16:40:00 +00:00
|
|
|
|
2017-11-19 05:16:22 +00:00
|
|
|
#include "VideoBackends/Software/EfbInterface.h"
|
2015-09-18 16:40:00 +00:00
|
|
|
|
2022-01-29 21:53:54 +00:00
|
|
|
#include "VideoCommon/PixelEngine.h"
|
2017-01-23 16:20:20 +00:00
|
|
|
#include "VideoCommon/VideoBackendBase.h"
|
2013-04-13 05:48:53 +00:00
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
namespace SW
|
|
|
|
{
|
2015-10-09 18:50:36 +00:00
|
|
|
u32 SWRenderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
|
|
|
|
{
|
|
|
|
u32 value = 0;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
2017-01-23 07:51:46 +00:00
|
|
|
case EFBAccessType::PeekZ:
|
2015-10-09 18:50:36 +00:00
|
|
|
{
|
|
|
|
value = EfbInterface::GetDepth(x, y);
|
|
|
|
break;
|
|
|
|
}
|
2017-01-23 07:51:46 +00:00
|
|
|
case EFBAccessType::PeekColor:
|
2015-10-09 18:50:36 +00:00
|
|
|
{
|
2016-09-21 22:53:13 +00:00
|
|
|
const u32 color = EfbInterface::GetColor(x, y);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
// rgba to argb
|
|
|
|
value = (color >> 8) | (color & 0xff) << 24;
|
2022-01-29 21:53:54 +00:00
|
|
|
|
|
|
|
// check what to do with the alpha channel (GX_PokeAlphaRead)
|
2022-12-10 15:35:07 +00:00
|
|
|
PixelEngine::AlphaReadMode alpha_read_mode =
|
|
|
|
Core::System::GetInstance().GetPixelEngine().GetAlphaReadMode();
|
2022-01-29 21:53:54 +00:00
|
|
|
|
|
|
|
if (alpha_read_mode == PixelEngine::AlphaReadMode::ReadNone)
|
|
|
|
{
|
|
|
|
// value is OK as it is
|
|
|
|
}
|
|
|
|
else if (alpha_read_mode == PixelEngine::AlphaReadMode::ReadFF)
|
|
|
|
{
|
|
|
|
value |= 0xFF000000;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (alpha_read_mode != PixelEngine::AlphaReadMode::Read00)
|
|
|
|
{
|
|
|
|
PanicAlertFmt("Invalid PE alpha read mode: {}", static_cast<u16>(alpha_read_mode));
|
|
|
|
}
|
|
|
|
value &= 0x00FFFFFF;
|
|
|
|
}
|
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2015-10-09 18:50:36 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
} // namespace SW
|