mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-12-16 04:09:39 +00:00
VideoCommon: move global variables out of BPFunctions
This commit is contained in:
parent
b920182c97
commit
ee7c476e24
@ -18,6 +18,7 @@
|
|||||||
#include "VideoCommon/PerfQueryBase.h"
|
#include "VideoCommon/PerfQueryBase.h"
|
||||||
#include "VideoCommon/Statistics.h"
|
#include "VideoCommon/Statistics.h"
|
||||||
#include "VideoCommon/VideoCommon.h"
|
#include "VideoCommon/VideoCommon.h"
|
||||||
|
#include "VideoCommon/XFMemory.h"
|
||||||
|
|
||||||
namespace Rasterizer
|
namespace Rasterizer
|
||||||
{
|
{
|
||||||
@ -113,7 +114,9 @@ void Init()
|
|||||||
|
|
||||||
void ScissorChanged()
|
void ScissorChanged()
|
||||||
{
|
{
|
||||||
scissors = std::move(BPFunctions::ComputeScissorRects().m_result);
|
auto scissor_result = BPFunctions::ComputeScissorRects(bpmem.scissorTL, bpmem.scissorBR,
|
||||||
|
bpmem.scissorOffset, xfmem.viewport);
|
||||||
|
scissors = std::move(scissor_result.m_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns approximation of log2(f) in s28.4
|
// Returns approximation of log2(f) in s28.4
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
#include "VideoCommon/ShaderCache.h"
|
#include "VideoCommon/ShaderCache.h"
|
||||||
#include "VideoCommon/VertexManagerBase.h"
|
#include "VideoCommon/VertexManagerBase.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
#include "VideoCommon/XFMemory.h"
|
||||||
|
|
||||||
std::unique_ptr<AbstractGfx> g_gfx;
|
std::unique_ptr<AbstractGfx> g_gfx;
|
||||||
|
|
||||||
@ -35,7 +36,8 @@ void AbstractGfx::EndUtilityDrawing()
|
|||||||
{
|
{
|
||||||
// Reset framebuffer/scissor/viewport. Pipeline will be reset at next draw.
|
// Reset framebuffer/scissor/viewport. Pipeline will be reset at next draw.
|
||||||
g_framebuffer_manager->BindEFBFramebuffer();
|
g_framebuffer_manager->BindEFBFramebuffer();
|
||||||
BPFunctions::SetScissorAndViewport();
|
BPFunctions::SetScissorAndViewport(g_framebuffer_manager.get(), bpmem.scissorTL, bpmem.scissorBR,
|
||||||
|
bpmem.scissorOffset, xfmem.viewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractGfx::SetFramebuffer(AbstractFramebuffer* framebuffer)
|
void AbstractGfx::SetFramebuffer(AbstractFramebuffer* framebuffer)
|
||||||
|
|||||||
@ -11,13 +11,12 @@
|
|||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/SmallVector.h"
|
#include "Common/SmallVector.h"
|
||||||
|
#include "Core/System.h"
|
||||||
|
|
||||||
#include "VideoCommon/AbstractFramebuffer.h"
|
|
||||||
#include "VideoCommon/AbstractGfx.h"
|
#include "VideoCommon/AbstractGfx.h"
|
||||||
#include "VideoCommon/BPMemory.h"
|
#include "VideoCommon/BPMemory.h"
|
||||||
#include "VideoCommon/EFBInterface.h"
|
#include "VideoCommon/EFBInterface.h"
|
||||||
#include "VideoCommon/FramebufferManager.h"
|
#include "VideoCommon/FramebufferManager.h"
|
||||||
#include "VideoCommon/RenderState.h"
|
|
||||||
#include "VideoCommon/VertexManagerBase.h"
|
#include "VideoCommon/VertexManagerBase.h"
|
||||||
#include "VideoCommon/VertexShaderManager.h"
|
#include "VideoCommon/VertexShaderManager.h"
|
||||||
#include "VideoCommon/VideoCommon.h"
|
#include "VideoCommon/VideoCommon.h"
|
||||||
@ -98,18 +97,18 @@ static RangeList ComputeScissorRanges(int start, int end, int offset, int efb_di
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
ScissorResult::ScissorResult(const BPMemory& bpmemory, const XFMemory& xfmemory)
|
ScissorResult::ScissorResult(ScissorPos scissor_top_left, ScissorPos scissor_bottom_right,
|
||||||
: ScissorResult(bpmemory,
|
ScissorOffset scissor_offset, const Viewport& viewport)
|
||||||
std::minmax(xfmemory.viewport.xOrig - xfmemory.viewport.wd,
|
: ScissorResult(scissor_top_left, scissor_bottom_right, scissor_offset,
|
||||||
xfmemory.viewport.xOrig + xfmemory.viewport.wd),
|
std::minmax(viewport.xOrig - viewport.wd, viewport.xOrig + viewport.wd),
|
||||||
std::minmax(xfmemory.viewport.yOrig - xfmemory.viewport.ht,
|
std::minmax(viewport.yOrig - viewport.ht, viewport.yOrig + viewport.ht))
|
||||||
xfmemory.viewport.yOrig + xfmemory.viewport.ht))
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
ScissorResult::ScissorResult(const BPMemory& bpmemory, std::pair<float, float> viewport_x,
|
ScissorResult::ScissorResult(ScissorPos scissor_top_left, ScissorPos scissor_bottom_right,
|
||||||
|
ScissorOffset scissor_offset, std::pair<float, float> viewport_x,
|
||||||
std::pair<float, float> viewport_y)
|
std::pair<float, float> viewport_y)
|
||||||
: scissor_tl{.hex = bpmemory.scissorTL.hex}, scissor_br{.hex = bpmemory.scissorBR.hex},
|
: scissor_tl{.hex = scissor_top_left.hex}, scissor_br{.hex = scissor_bottom_right.hex},
|
||||||
scissor_off{.hex = bpmemory.scissorOffset.hex}, viewport_left(viewport_x.first),
|
scissor_off{.hex = scissor_offset.hex}, viewport_left(viewport_x.first),
|
||||||
viewport_right(viewport_x.second), viewport_top(viewport_y.first),
|
viewport_right(viewport_x.second), viewport_top(viewport_y.first),
|
||||||
viewport_bottom(viewport_y.second)
|
viewport_bottom(viewport_y.second)
|
||||||
{
|
{
|
||||||
@ -172,23 +171,28 @@ ScissorRect ScissorResult::Best() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScissorResult ComputeScissorRects()
|
ScissorResult ComputeScissorRects(ScissorPos scissor_top_left, ScissorPos scissor_bottom_right,
|
||||||
|
ScissorOffset scissor_offset, const Viewport& viewport)
|
||||||
{
|
{
|
||||||
return ScissorResult{bpmem, xfmem};
|
return ScissorResult{scissor_top_left, scissor_bottom_right, scissor_offset, viewport};
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetScissorAndViewport()
|
void SetScissorAndViewport(FramebufferManager* frame_buffer_manager, ScissorPos scissor_top_left,
|
||||||
|
ScissorPos scissor_bottom_right, ScissorOffset scissor_offset,
|
||||||
|
Viewport viewport)
|
||||||
{
|
{
|
||||||
auto native_rc = ComputeScissorRects().Best();
|
const auto result = BPFunctions::ComputeScissorRects(scissor_top_left, scissor_bottom_right,
|
||||||
|
scissor_offset, viewport);
|
||||||
|
auto native_rc = result.Best();
|
||||||
|
|
||||||
auto target_rc = g_framebuffer_manager->ConvertEFBRectangle(native_rc.rect);
|
auto target_rc = frame_buffer_manager->ConvertEFBRectangle(native_rc.rect);
|
||||||
auto converted_rc = g_gfx->ConvertFramebufferRectangle(target_rc, g_gfx->GetCurrentFramebuffer());
|
auto converted_rc = g_gfx->ConvertFramebufferRectangle(target_rc, g_gfx->GetCurrentFramebuffer());
|
||||||
g_gfx->SetScissorRect(converted_rc);
|
g_gfx->SetScissorRect(converted_rc);
|
||||||
|
|
||||||
float raw_x = (xfmem.viewport.xOrig - native_rc.x_off) - xfmem.viewport.wd;
|
float raw_x = (viewport.xOrig - native_rc.x_off) - viewport.wd;
|
||||||
float raw_y = (xfmem.viewport.yOrig - native_rc.y_off) + xfmem.viewport.ht;
|
float raw_y = (viewport.yOrig - native_rc.y_off) + viewport.ht;
|
||||||
float raw_width = 2.0f * xfmem.viewport.wd;
|
float raw_width = 2.0f * viewport.wd;
|
||||||
float raw_height = -2.0f * xfmem.viewport.ht;
|
float raw_height = -2.0f * viewport.ht;
|
||||||
if (g_ActiveConfig.UseVertexRounding())
|
if (g_ActiveConfig.UseVertexRounding())
|
||||||
{
|
{
|
||||||
// Round the viewport to match full 1x IR pixels as well.
|
// Round the viewport to match full 1x IR pixels as well.
|
||||||
@ -199,12 +203,12 @@ void SetScissorAndViewport()
|
|||||||
raw_height = std::round(raw_height);
|
raw_height = std::round(raw_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
float x = g_framebuffer_manager->EFBToScaledXf(raw_x);
|
float x = frame_buffer_manager->EFBToScaledXf(raw_x);
|
||||||
float y = g_framebuffer_manager->EFBToScaledYf(raw_y);
|
float y = frame_buffer_manager->EFBToScaledYf(raw_y);
|
||||||
float width = g_framebuffer_manager->EFBToScaledXf(raw_width);
|
float width = frame_buffer_manager->EFBToScaledXf(raw_width);
|
||||||
float height = g_framebuffer_manager->EFBToScaledYf(raw_height);
|
float height = frame_buffer_manager->EFBToScaledYf(raw_height);
|
||||||
float min_depth = (xfmem.viewport.farZ - xfmem.viewport.zRange) / 16777216.0f;
|
float min_depth = (viewport.farZ - viewport.zRange) / 16777216.0f;
|
||||||
float max_depth = xfmem.viewport.farZ / 16777216.0f;
|
float max_depth = viewport.farZ / 16777216.0f;
|
||||||
if (width < 0.f)
|
if (width < 0.f)
|
||||||
{
|
{
|
||||||
x += width;
|
x += width;
|
||||||
@ -228,7 +232,7 @@ void SetScissorAndViewport()
|
|||||||
{
|
{
|
||||||
// We need to ensure depth values are clamped the maximum value supported by the console GPU.
|
// We need to ensure depth values are clamped the maximum value supported by the console GPU.
|
||||||
// Taking into account whether the depth range is inverted or not.
|
// Taking into account whether the depth range is inverted or not.
|
||||||
if (xfmem.viewport.zRange < 0.0f && g_backend_info.bSupportsReversedDepthRange)
|
if (viewport.zRange < 0.0f && g_backend_info.bSupportsReversedDepthRange)
|
||||||
{
|
{
|
||||||
min_depth = MAX_EFB_DEPTH;
|
min_depth = MAX_EFB_DEPTH;
|
||||||
max_depth = 0.0f;
|
max_depth = 0.0f;
|
||||||
@ -291,24 +295,21 @@ void SetBlendMode()
|
|||||||
- convert the RGBA8 color to RGBA6/RGB8/RGB565 and convert it to RGBA8 again
|
- convert the RGBA8 color to RGBA6/RGB8/RGB565 and convert it to RGBA8 again
|
||||||
- convert the Z24 depth value to Z16 and back to Z24
|
- convert the Z24 depth value to Z16 and back to Z24
|
||||||
*/
|
*/
|
||||||
void ClearScreen(const MathUtil::Rectangle<int>& rc)
|
bool ClearScreen(FramebufferManager* frame_buffer_manager, const MathUtil::Rectangle<int>& rc,
|
||||||
|
bool color_enable, bool alpha_enable, bool z_enable, PixelFormat pixel_format,
|
||||||
|
u32 clear_color_ar, u32 clear_color_gb, u32 clear_z_value)
|
||||||
{
|
{
|
||||||
bool colorEnable = (bpmem.blendmode.color_update != 0);
|
|
||||||
bool alphaEnable = (bpmem.blendmode.alpha_update != 0);
|
|
||||||
bool zEnable = (bpmem.zmode.update_enable != 0);
|
|
||||||
auto pixel_format = bpmem.zcontrol.pixel_format;
|
|
||||||
|
|
||||||
// (1): Disable unused color channels
|
// (1): Disable unused color channels
|
||||||
if (pixel_format == PixelFormat::RGB8_Z24 || pixel_format == PixelFormat::RGB565_Z16 ||
|
if (pixel_format == PixelFormat::RGB8_Z24 || pixel_format == PixelFormat::RGB565_Z16 ||
|
||||||
pixel_format == PixelFormat::Z24)
|
pixel_format == PixelFormat::Z24)
|
||||||
{
|
{
|
||||||
alphaEnable = false;
|
alpha_enable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colorEnable || alphaEnable || zEnable)
|
if (color_enable || alpha_enable || z_enable)
|
||||||
{
|
{
|
||||||
u32 color = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
|
u32 color = (clear_color_ar << 16) | clear_color_gb;
|
||||||
u32 z = bpmem.clearZValue;
|
u32 z = clear_z_value;
|
||||||
|
|
||||||
// (2) drop additional accuracy
|
// (2) drop additional accuracy
|
||||||
if (pixel_format == PixelFormat::RGBA6_Z24)
|
if (pixel_format == PixelFormat::RGBA6_Z24)
|
||||||
@ -320,11 +321,16 @@ void ClearScreen(const MathUtil::Rectangle<int>& rc)
|
|||||||
color = RGBA8ToRGB565ToRGBA8(color);
|
color = RGBA8ToRGB565ToRGBA8(color);
|
||||||
z = Z24ToZ16ToZ24(z);
|
z = Z24ToZ16ToZ24(z);
|
||||||
}
|
}
|
||||||
g_framebuffer_manager->ClearEFB(rc, colorEnable, alphaEnable, zEnable, color, z);
|
frame_buffer_manager->ClearEFB(rc, color_enable, alpha_enable, z_enable, color, z,
|
||||||
}
|
pixel_format);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnPixelFormatChange()
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnPixelFormatChange(FramebufferManager* frame_buffer_manager, PixelFormat pixel_format,
|
||||||
|
DepthFormat z_format)
|
||||||
{
|
{
|
||||||
// TODO : Check for Z compression format change
|
// TODO : Check for Z compression format change
|
||||||
// When using 16bit Z, the game may enable a special compression format which we might need to
|
// When using 16bit Z, the game may enable a special compression format which we might need to
|
||||||
@ -342,11 +348,11 @@ void OnPixelFormatChange()
|
|||||||
if (!g_ActiveConfig.bEFBEmulateFormatChanges)
|
if (!g_ActiveConfig.bEFBEmulateFormatChanges)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto old_format = g_framebuffer_manager->GetPrevPixelFormat();
|
const auto old_format = frame_buffer_manager->GetPrevPixelFormat();
|
||||||
const auto new_format = bpmem.zcontrol.pixel_format;
|
const auto new_format = pixel_format;
|
||||||
g_framebuffer_manager->StorePixelFormat(new_format);
|
frame_buffer_manager->StorePixelFormat(new_format);
|
||||||
|
|
||||||
DEBUG_LOG_FMT(VIDEO, "pixelfmt: pixel={}, zc={}", new_format, bpmem.zcontrol.zformat);
|
DEBUG_LOG_FMT(VIDEO, "pixelfmt: pixel={}, zc={}", new_format, z_format);
|
||||||
|
|
||||||
// no need to reinterpret pixel data in these cases
|
// no need to reinterpret pixel data in these cases
|
||||||
if (new_format == old_format || old_format == PixelFormat::INVALID_FMT)
|
if (new_format == old_format || old_format == PixelFormat::INVALID_FMT)
|
||||||
|
|||||||
@ -12,7 +12,9 @@
|
|||||||
|
|
||||||
#include "Common/MathUtil.h"
|
#include "Common/MathUtil.h"
|
||||||
#include "VideoCommon/BPMemory.h"
|
#include "VideoCommon/BPMemory.h"
|
||||||
struct XFMemory;
|
|
||||||
|
class FramebufferManager;
|
||||||
|
struct Viewport;
|
||||||
|
|
||||||
namespace BPFunctions
|
namespace BPFunctions
|
||||||
{
|
{
|
||||||
@ -67,7 +69,8 @@ struct ScissorRect
|
|||||||
// under [Settings] to True in GFX.ini.
|
// under [Settings] to True in GFX.ini.
|
||||||
struct ScissorResult
|
struct ScissorResult
|
||||||
{
|
{
|
||||||
ScissorResult(const BPMemory& bpmem, const XFMemory& xfmem);
|
ScissorResult(ScissorPos scissor_top_left, ScissorPos scissor_bottom_right,
|
||||||
|
ScissorOffset scissor_offset, const Viewport& viewport);
|
||||||
~ScissorResult() = default;
|
~ScissorResult() = default;
|
||||||
ScissorResult(const ScissorResult& other)
|
ScissorResult(const ScissorResult& other)
|
||||||
: scissor_tl{.hex = other.scissor_tl.hex}, scissor_br{.hex = other.scissor_br.hex},
|
: scissor_tl{.hex = other.scissor_tl.hex}, scissor_br{.hex = other.scissor_br.hex},
|
||||||
@ -146,21 +149,31 @@ struct ScissorResult
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ScissorResult(const BPMemory& bpmem, std::pair<float, float> viewport_x,
|
ScissorResult(ScissorPos scissor_top_left, ScissorPos scissor_bottom_right,
|
||||||
|
ScissorOffset scissor_offset, std::pair<float, float> viewport_x,
|
||||||
std::pair<float, float> viewport_y);
|
std::pair<float, float> viewport_y);
|
||||||
|
|
||||||
int GetViewportArea(const ScissorRect& rect) const;
|
int GetViewportArea(const ScissorRect& rect) const;
|
||||||
bool IsWorse(const ScissorRect& lhs, const ScissorRect& rhs) const;
|
bool IsWorse(const ScissorRect& lhs, const ScissorRect& rhs) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
ScissorResult ComputeScissorRects();
|
ScissorResult ComputeScissorRects(ScissorPos scissor_top_left, ScissorPos scissor_bottom_right,
|
||||||
|
ScissorOffset scissor_offset, const Viewport& viewport);
|
||||||
|
|
||||||
void FlushPipeline();
|
void FlushPipeline();
|
||||||
void SetGenerationMode();
|
void SetGenerationMode();
|
||||||
void SetScissorAndViewport();
|
void SetScissorAndViewport(FramebufferManager* frame_buffer_manager, ScissorPos scissor_top_left,
|
||||||
|
ScissorPos scissor_bottom_right, ScissorOffset scissor_offset,
|
||||||
|
Viewport viewport);
|
||||||
void SetDepthMode();
|
void SetDepthMode();
|
||||||
void SetBlendMode();
|
void SetBlendMode();
|
||||||
void ClearScreen(const MathUtil::Rectangle<int>& rc);
|
|
||||||
void OnPixelFormatChange();
|
// Returns true if the EFB was triggered to clear
|
||||||
|
bool ClearScreen(FramebufferManager* frame_buffer_manager, const MathUtil::Rectangle<int>& rc,
|
||||||
|
bool color_enable, bool alpha_enable, bool z_enable, PixelFormat pixel_format,
|
||||||
|
u32 clear_color_ar, u32 clear_color_gb, u32 clear_z_value);
|
||||||
|
|
||||||
|
void OnPixelFormatChange(FramebufferManager* frame_buffer_manager, PixelFormat pixel_format,
|
||||||
|
DepthFormat z_format);
|
||||||
void SetInterlacingMode(const BPCmd& bp);
|
void SetInterlacingMode(const BPCmd& bp);
|
||||||
} // namespace BPFunctions
|
} // namespace BPFunctions
|
||||||
|
|||||||
@ -381,7 +381,19 @@ static void BPWritten(PixelShaderManager& pixel_shader_manager, XFStateManager&
|
|||||||
// Clear the rectangular region after copying it.
|
// Clear the rectangular region after copying it.
|
||||||
if (PE_copy.clear)
|
if (PE_copy.clear)
|
||||||
{
|
{
|
||||||
ClearScreen(srcRect);
|
const bool color_enable = bpmem.blendmode.color_update != 0;
|
||||||
|
const bool alpha_enable = bpmem.blendmode.alpha_update != 0;
|
||||||
|
const bool z_enable = bpmem.zmode.update_enable != 0;
|
||||||
|
const auto pixel_format = bpmem.zcontrol.pixel_format;
|
||||||
|
const auto color_ar = bpmem.clearcolorAR;
|
||||||
|
const auto color_gb = bpmem.clearcolorGB;
|
||||||
|
const auto z_value = bpmem.clearZValue;
|
||||||
|
ClearScreen(g_framebuffer_manager.get(), srcRect, color_enable, alpha_enable, z_enable,
|
||||||
|
pixel_format, color_ar, color_gb, z_value);
|
||||||
|
|
||||||
|
// Scissor rect must be restored.
|
||||||
|
BPFunctions::SetScissorAndViewport(g_framebuffer_manager.get(), bpmem.scissorTL,
|
||||||
|
bpmem.scissorBR, bpmem.scissorOffset, xfmem.viewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -523,7 +535,8 @@ static void BPWritten(PixelShaderManager& pixel_shader_manager, XFStateManager&
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format
|
case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format
|
||||||
OnPixelFormatChange();
|
OnPixelFormatChange(g_framebuffer_manager.get(), bpmem.zcontrol.pixel_format,
|
||||||
|
bpmem.zcontrol.zformat);
|
||||||
if (bp.changes & 7)
|
if (bp.changes & 7)
|
||||||
SetBlendMode(); // dual source could be activated by changing to PIXELFMT_RGBA6_Z24
|
SetBlendMode(); // dual source could be activated by changing to PIXELFMT_RGBA6_Z24
|
||||||
pixel_shader_manager.SetZModeControl();
|
pixel_shader_manager.SetZModeControl();
|
||||||
@ -1355,8 +1368,10 @@ void BPReload()
|
|||||||
// let's not risk actually replaying any writes.
|
// let's not risk actually replaying any writes.
|
||||||
// note that PixelShaderManager is already covered since it has its own DoState.
|
// note that PixelShaderManager is already covered since it has its own DoState.
|
||||||
SetGenerationMode();
|
SetGenerationMode();
|
||||||
SetScissorAndViewport();
|
BPFunctions::SetScissorAndViewport(g_framebuffer_manager.get(), bpmem.scissorTL, bpmem.scissorBR,
|
||||||
|
bpmem.scissorOffset, xfmem.viewport);
|
||||||
SetDepthMode();
|
SetDepthMode();
|
||||||
SetBlendMode();
|
SetBlendMode();
|
||||||
OnPixelFormatChange();
|
OnPixelFormatChange(g_framebuffer_manager.get(), bpmem.zcontrol.pixel_format,
|
||||||
|
bpmem.zcontrol.zformat);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -856,7 +856,8 @@ void FramebufferManager::PopulateEFBCache(bool depth, u32 tile_index, bool async
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FramebufferManager::ClearEFB(const MathUtil::Rectangle<int>& rc, bool color_enable,
|
void FramebufferManager::ClearEFB(const MathUtil::Rectangle<int>& rc, bool color_enable,
|
||||||
bool alpha_enable, bool z_enable, u32 color, u32 z)
|
bool alpha_enable, bool z_enable, u32 color, u32 z,
|
||||||
|
PixelFormat pixel_format)
|
||||||
{
|
{
|
||||||
FlushEFBPokes();
|
FlushEFBPokes();
|
||||||
FlagPeekCacheAsOutOfDate();
|
FlagPeekCacheAsOutOfDate();
|
||||||
@ -870,9 +871,8 @@ void FramebufferManager::ClearEFB(const MathUtil::Rectangle<int>& rc, bool color
|
|||||||
// channel to 0xFF.
|
// channel to 0xFF.
|
||||||
// On backends that don't allow masking Alpha clears, this allows us to use the fast path
|
// On backends that don't allow masking Alpha clears, this allows us to use the fast path
|
||||||
// almost all the time
|
// almost all the time
|
||||||
if (bpmem.zcontrol.pixel_format == PixelFormat::RGB565_Z16 ||
|
if (pixel_format == PixelFormat::RGB565_Z16 || pixel_format == PixelFormat::RGB8_Z24 ||
|
||||||
bpmem.zcontrol.pixel_format == PixelFormat::RGB8_Z24 ||
|
pixel_format == PixelFormat::Z24)
|
||||||
bpmem.zcontrol.pixel_format == PixelFormat::Z24)
|
|
||||||
{
|
{
|
||||||
// Force alpha writes, and clear the alpha channel.
|
// Force alpha writes, and clear the alpha channel.
|
||||||
alpha_enable = true;
|
alpha_enable = true;
|
||||||
@ -880,9 +880,6 @@ void FramebufferManager::ClearEFB(const MathUtil::Rectangle<int>& rc, bool color
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_gfx->ClearRegion(target_rc, color_enable, alpha_enable, z_enable, color, z);
|
g_gfx->ClearRegion(target_rc, color_enable, alpha_enable, z_enable, color, z);
|
||||||
|
|
||||||
// Scissor rect must be restored.
|
|
||||||
BPFunctions::SetScissorAndViewport();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramebufferManager::CompileClearPipelines()
|
bool FramebufferManager::CompileClearPipelines()
|
||||||
|
|||||||
@ -110,7 +110,7 @@ public:
|
|||||||
|
|
||||||
// Clears the EFB using shaders.
|
// Clears the EFB using shaders.
|
||||||
void ClearEFB(const MathUtil::Rectangle<int>& rc, bool clear_color, bool clear_alpha,
|
void ClearEFB(const MathUtil::Rectangle<int>& rc, bool clear_color, bool clear_alpha,
|
||||||
bool clear_z, u32 color, u32 z);
|
bool clear_z, u32 color, u32 z, PixelFormat pixel_format);
|
||||||
|
|
||||||
AbstractPipeline* GetClearPipeline(bool clear_color, bool clear_alpha, bool clear_z) const;
|
AbstractPipeline* GetClearPipeline(bool clear_color, bool clear_alpha, bool clear_z) const;
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
#include "VideoCommon/VideoCommon.h"
|
#include "VideoCommon/VideoCommon.h"
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
#include "VideoCommon/VideoEvents.h"
|
#include "VideoCommon/VideoEvents.h"
|
||||||
|
#include "VideoCommon/XFMemory.h"
|
||||||
|
|
||||||
Statistics g_stats;
|
Statistics g_stats;
|
||||||
|
|
||||||
@ -161,7 +162,8 @@ void Statistics::AddScissorRect()
|
|||||||
clear_scissors = false;
|
clear_scissors = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BPFunctions::ScissorResult scissor = BPFunctions::ComputeScissorRects();
|
BPFunctions::ScissorResult scissor = BPFunctions::ComputeScissorRects(
|
||||||
|
bpmem.scissorTL, bpmem.scissorBR, bpmem.scissorOffset, xfmem.viewport);
|
||||||
bool add;
|
bool add;
|
||||||
if (scissors.empty())
|
if (scissors.empty())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -388,7 +388,8 @@ void VertexShaderManager::SetConstants(const std::vector<std::string>& textures,
|
|||||||
}
|
}
|
||||||
|
|
||||||
dirty = true;
|
dirty = true;
|
||||||
BPFunctions::SetScissorAndViewport();
|
BPFunctions::SetScissorAndViewport(g_framebuffer_manager.get(), bpmem.scissorTL,
|
||||||
|
bpmem.scissorBR, bpmem.scissorOffset, xfmem.viewport);
|
||||||
g_stats.AddScissorRect();
|
g_stats.AddScissorRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "VideoCommon/AbstractGfx.h"
|
#include "VideoCommon/AbstractGfx.h"
|
||||||
#include "VideoCommon/BPFunctions.h"
|
#include "VideoCommon/BPFunctions.h"
|
||||||
|
#include "VideoCommon/BPMemory.h"
|
||||||
#include "VideoCommon/DriverDetails.h"
|
#include "VideoCommon/DriverDetails.h"
|
||||||
#include "VideoCommon/Fifo.h"
|
#include "VideoCommon/Fifo.h"
|
||||||
#include "VideoCommon/FramebufferManager.h"
|
#include "VideoCommon/FramebufferManager.h"
|
||||||
@ -30,6 +31,7 @@
|
|||||||
#include "VideoCommon/ShaderGenCommon.h"
|
#include "VideoCommon/ShaderGenCommon.h"
|
||||||
#include "VideoCommon/TextureCacheBase.h"
|
#include "VideoCommon/TextureCacheBase.h"
|
||||||
#include "VideoCommon/VertexManagerBase.h"
|
#include "VideoCommon/VertexManagerBase.h"
|
||||||
|
#include "VideoCommon/XFMemory.h"
|
||||||
|
|
||||||
VideoConfig g_Config;
|
VideoConfig g_Config;
|
||||||
VideoConfig g_ActiveConfig;
|
VideoConfig g_ActiveConfig;
|
||||||
@ -383,7 +385,8 @@ void CheckForConfigChanges()
|
|||||||
// Viewport and scissor rect have to be reset since they will be scaled differently.
|
// Viewport and scissor rect have to be reset since they will be scaled differently.
|
||||||
if (changed_bits & CONFIG_CHANGE_BIT_TARGET_SIZE)
|
if (changed_bits & CONFIG_CHANGE_BIT_TARGET_SIZE)
|
||||||
{
|
{
|
||||||
BPFunctions::SetScissorAndViewport();
|
BPFunctions::SetScissorAndViewport(g_framebuffer_manager.get(), bpmem.scissorTL,
|
||||||
|
bpmem.scissorBR, bpmem.scissorOffset, xfmem.viewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify all listeners
|
// Notify all listeners
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user