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