From f3a8874214b61f33332b826a37ac9ca25dee1477 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 18 May 2018 15:09:37 -0400 Subject: EfbInterface: Move efb array into the EfbInterface namespace --- Source/Core/VideoBackends/Software/EfbInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Core/VideoBackends/Software/EfbInterface.cpp') diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp index a13feb6c50..cf30c35a48 100644 --- a/Source/Core/VideoBackends/Software/EfbInterface.cpp +++ b/Source/Core/VideoBackends/Software/EfbInterface.cpp @@ -18,10 +18,10 @@ #include "VideoCommon/LookUpTables.h" #include "VideoCommon/PerfQueryBase.h" -static u8 efb[EFB_WIDTH * EFB_HEIGHT * 6]; - namespace EfbInterface { +static u8 efb[EFB_WIDTH * EFB_HEIGHT * 6]; + u32 perf_values[PQ_NUM_MEMBERS]; static inline u32 GetColorOffset(u16 x, u16 y) -- cgit v1.2.3 From c58b5e9b9bccf9baac5d5fb5aa6e254528f19782 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 18 May 2018 15:13:03 -0400 Subject: EfbInterface: Make perf_values internally linked Instead, expose functions to operate with it. This way we keep the internal representation concealed. --- .../Core/VideoBackends/Software/EfbInterface.cpp | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'Source/Core/VideoBackends/Software/EfbInterface.cpp') diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp index cf30c35a48..1d5dab1f49 100644 --- a/Source/Core/VideoBackends/Software/EfbInterface.cpp +++ b/Source/Core/VideoBackends/Software/EfbInterface.cpp @@ -22,7 +22,7 @@ namespace EfbInterface { static u8 efb[EFB_WIDTH * EFB_HEIGHT * 6]; -u32 perf_values[PQ_NUM_MEMBERS]; +static u32 perf_values[PQ_NUM_MEMBERS]; static inline u32 GetColorOffset(u16 x, u16 y) { @@ -682,4 +682,27 @@ bool ZCompare(u16 x, u16 y, u32 z) return pass; } + +u32 GetPerfQueryResult(PerfQueryType type) +{ + return perf_values[type]; +} + +void ResetPerfQuery() +{ + std::memset(perf_values, 0, sizeof(perf_values)); +} + +void IncPerfCounterQuadCount(PerfQueryType type) +{ + // NOTE: hardware doesn't process individual pixels but quads instead. + // Current software renderer architecture works on pixels though, so + // we have this "quad" hack here to only increment the registers on + // every fourth rendered pixel + static u32 quad[PQ_NUM_MEMBERS]; + if (++quad[type] != 3) + return; + quad[type] = 0; + ++perf_values[type]; +} } -- cgit v1.2.3 From 5eef8ba9844806a795a635c6e364e3b9edc9a6c8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 18 May 2018 15:36:37 -0400 Subject: EfbInterface: Make efb and perf_values std::arrays --- Source/Core/VideoBackends/Software/EfbInterface.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoBackends/Software/EfbInterface.cpp') diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp index 1d5dab1f49..a133d63c2f 100644 --- a/Source/Core/VideoBackends/Software/EfbInterface.cpp +++ b/Source/Core/VideoBackends/Software/EfbInterface.cpp @@ -5,6 +5,7 @@ #include "VideoBackends/Software/EfbInterface.h" #include +#include #include #include #include @@ -20,9 +21,9 @@ namespace EfbInterface { -static u8 efb[EFB_WIDTH * EFB_HEIGHT * 6]; +static std::array efb; -static u32 perf_values[PQ_NUM_MEMBERS]; +static std::array perf_values; static inline u32 GetColorOffset(u16 x, u16 y) { @@ -690,7 +691,7 @@ u32 GetPerfQueryResult(PerfQueryType type) void ResetPerfQuery() { - std::memset(perf_values, 0, sizeof(perf_values)); + perf_values = {}; } void IncPerfCounterQuadCount(PerfQueryType type) -- cgit v1.2.3 From 505d45a2331e5587ca0b564ec616fc5855c33fd7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 18 May 2018 15:43:26 -0400 Subject: EfbInterface: Move buffer constant from the header to the cpp file This is only ever used internally, so we can limit its scope to the only usage point. --- Source/Core/VideoBackends/Software/EfbInterface.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Source/Core/VideoBackends/Software/EfbInterface.cpp') diff --git a/Source/Core/VideoBackends/Software/EfbInterface.cpp b/Source/Core/VideoBackends/Software/EfbInterface.cpp index a133d63c2f..bb3cfeda90 100644 --- a/Source/Core/VideoBackends/Software/EfbInterface.cpp +++ b/Source/Core/VideoBackends/Software/EfbInterface.cpp @@ -32,7 +32,9 @@ static inline u32 GetColorOffset(u16 x, u16 y) static inline u32 GetDepthOffset(u16 x, u16 y) { - return (x + y * EFB_WIDTH) * 3 + DEPTH_BUFFER_START; + constexpr u32 depth_buffer_start = EFB_WIDTH * EFB_HEIGHT * 3; + + return (x + y * EFB_WIDTH) * 3 + depth_buffer_start; } static void SetPixelAlphaOnly(u32 offset, u8 a) -- cgit v1.2.3