sofjit: Move common types to reg cache header.

This makes it easier to use vectors elsewhere.
This commit is contained in:
Unknown W. Brackets 2021-11-27 17:12:48 -08:00
parent 3d5bced296
commit 96a7554053
6 changed files with 60 additions and 65 deletions

View File

@ -378,8 +378,14 @@ static inline u32 ApplyLogicOp(GELogicOp op, u32 old_color, u32 new_color) {
}
template <bool clearMode, GEBufferFormat fbFormat>
void SOFTPIXEL_CALL DrawSinglePixel(int x, int y, int z, int fog, SOFTPIXEL_VEC4I color_in, const PixelFuncID &pixelID) {
void SOFTRAST_CALL DrawSinglePixel(int x, int y, int z, int fog, Vec4IntArg color_in, const PixelFuncID &pixelID) {
#if PPSSPP_ARCH(ARM64)
Vec4<int> prim_color;
vst1q_s32(prim_color.AsArray(), color_in);
prim_color = prim_color.Clamp(0, 255);
#else
Vec4<int> prim_color = Vec4<int>(color_in).Clamp(0, 255);
#endif
// Depth range test - applied in clear mode, if not through mode.
if (pixelID.applyDepthRange)
if (z < gstate.getDepthRangeMin() || z > gstate.getDepthRangeMax())

View File

@ -22,38 +22,13 @@
#include <string>
#include <vector>
#include <unordered_map>
#if PPSSPP_ARCH(ARM)
#include "Common/ArmEmitter.h"
#elif PPSSPP_ARCH(ARM64)
#include "Common/Arm64Emitter.h"
#elif PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
#include "Common/x64Emitter.h"
#elif PPSSPP_ARCH(MIPS)
#include "Common/MipsEmitter.h"
#else
#include "Common/FakeEmitter.h"
#endif
#include "GPU/Math3D.h"
#include "GPU/Software/FuncId.h"
#include "GPU/Software/RasterizerRegCache.h"
namespace Rasterizer {
#if PPSSPP_ARCH(AMD64) && PPSSPP_PLATFORM(WINDOWS) && (defined(_MSC_VER) || defined(__clang__))
#define SOFTPIXEL_CALL __vectorcall
#define SOFTPIXEL_VEC4I __m128i
#define SOFTPIXEL_TO_VEC4I(x) (x).ivec
#elif PPSSPP_ARCH(AMD64)
#define SOFTPIXEL_CALL
#define SOFTPIXEL_VEC4I __m128i
#define SOFTPIXEL_TO_VEC4I(x) (x).ivec
#else
#define SOFTPIXEL_CALL
#define SOFTPIXEL_VEC4I const Math3D::Vec4<int> &
#define SOFTPIXEL_TO_VEC4I(x) (x)
#endif
typedef void (SOFTPIXEL_CALL *SingleFunc)(int x, int y, int z, int fog, SOFTPIXEL_VEC4I color_in, const PixelFuncID &pixelID);
typedef void (SOFTRAST_CALL *SingleFunc)(int x, int y, int z, int fog, Vec4IntArg color_in, const PixelFuncID &pixelID);
SingleFunc GetSingleFunc(const PixelFuncID &id);
void Init();
@ -68,17 +43,7 @@ struct PixelBlendState {
};
void ComputePixelBlendState(PixelBlendState &state, const PixelFuncID &id);
#if PPSSPP_ARCH(ARM)
class PixelJitCache : public ArmGen::ARMXCodeBlock {
#elif PPSSPP_ARCH(ARM64)
class PixelJitCache : public Arm64Gen::ARM64CodeBlock {
#elif PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
class PixelJitCache : public Gen::XCodeBlock {
#elif PPSSPP_ARCH(MIPS)
class PixelJitCache : public MIPSGen::MIPSCodeBlock {
#else
class PixelJitCache : public FakeGen::FakeXCodeBlock {
#endif
class PixelJitCache : public Rasterizer::CodeBlock {
public:
PixelJitCache();

View File

@ -906,7 +906,7 @@ void DrawTriangleSlice(
subp.x = p.x + (i & 1);
subp.y = p.y + (i / 2);
drawPixel(subp.x, subp.y, z[i], fog[i], SOFTPIXEL_TO_VEC4I(prim_color[i]), pixelID);
drawPixel(subp.x, subp.y, z[i], fog[i], ToVec4IntArg(prim_color[i]), pixelID);
}
}
}
@ -1054,7 +1054,7 @@ void DrawPoint(const VertexData &v0)
fog = ClampFogDepth(v0.fogdepth);
}
drawPixel(p.x, p.y, z, fog, SOFTPIXEL_TO_VEC4I(prim_color), pixelID);
drawPixel(p.x, p.y, z, fog, ToVec4IntArg(prim_color), pixelID);
}
void ClearRectangle(const VertexData &v0, const VertexData &v1)
@ -1344,7 +1344,7 @@ void DrawLine(const VertexData &v0, const VertexData &v1)
ScreenCoords pprime = ScreenCoords((int)x, (int)y, (int)z);
DrawingCoords p = TransformUnit::ScreenToDrawing(pprime);
drawPixel(p.x, p.y, z, fog, SOFTPIXEL_TO_VEC4I(prim_color), pixelID);
drawPixel(p.x, p.y, z, fog, ToVec4IntArg(prim_color), pixelID);
}
x += xinc;

View File

@ -193,7 +193,7 @@ void DrawSprite(const VertexData& v0, const VertexData& v1) {
Vec4<int> prim_color = v1.color0;
Vec4<int> tex_color = Vec4<int>::FromRGBA(nearestFunc(s, t, texptr, texbufw, 0));
prim_color = GetTextureFunctionOutput(prim_color, tex_color);
drawPixel(x, y, z, 255, SOFTPIXEL_TO_VEC4I(prim_color), pixelID);
drawPixel(x, y, z, 255, ToVec4IntArg(prim_color), pixelID);
s += ds;
}
t += dt;
@ -237,7 +237,7 @@ void DrawSprite(const VertexData& v0, const VertexData& v1) {
for (int y = y1; y < y2; y++) {
for (int x = pos0.x; x < pos1.x; x++) {
Vec4<int> prim_color = v1.color0;
drawPixel(x, y, z, fog, SOFTPIXEL_TO_VEC4I(prim_color), pixelID);
drawPixel(x, y, z, fog, ToVec4IntArg(prim_color), pixelID);
}
}
}, pos0.y, pos1.y, MIN_LINES_PER_THREAD);

View File

@ -21,6 +21,18 @@
#include <cstdint>
#include <vector>
#if defined(_M_SSE)
#include <emmintrin.h>
#endif
#if PPSSPP_ARCH(ARM_NEON) && PPSSPP_ARCH(ARM64)
#if defined(_MSC_VER) && PPSSPP_ARCH(ARM64)
#include <arm64_neon.h>
#else
#include <arm_neon.h>
#endif
#endif
#if PPSSPP_ARCH(ARM)
#include "Common/ArmEmitter.h"
#elif PPSSPP_ARCH(ARM64)
@ -32,9 +44,41 @@
#else
#include "Common/FakeEmitter.h"
#endif
#include "GPU/Math3D.h"
namespace Rasterizer {
// While not part of the reg cache proper, this is the type it is built for.
#if PPSSPP_ARCH(ARM)
typedef ArmGen::ARMXCodeBlock CodeBlock;
#elif PPSSPP_ARCH(ARM64)
typedef Arm64Gen::ARM64CodeBlock CodeBlock;
#elif PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
typedef Gen::XCodeBlock CodeBlock;
#elif PPSSPP_ARCH(MIPS)
typedef MIPSGen::MIPSCodeBlock CodeBlock;
#else
typedef FakeGen::FakeXCodeBlock CodeBlock;
#endif
// We also have the types of things that end up in regs.
#if PPSSPP_ARCH(ARM64)
typedef int32x4_t Vec4IntArg;
static inline Vec4IntArg ToVec4IntArg(const Math3D::Vec4<int> &a) { return vld1q_s32(a.AsArray()); }
#elif PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
typedef __m128i Vec4IntArg;
static inline Vec4IntArg ToVec4IntArg(const Math3D::Vec4<int> &a) { return a.ivec; }
#else
typedef const Math3D::Vec4<int> &Vec4IntArg;
static inline Vec4IntArg ToVec4IntArg(const Math3D::Vec4<int> &a) { return a; }
#endif
#if PPSSPP_ARCH(AMD64) && PPSSPP_PLATFORM(WINDOWS) && (defined(_MSC_VER) || defined(__clang__) || defined(__INTEL_COMPILER))
#define SOFTRAST_CALL __vectorcall
#else
#define SOFTRAST_CALL
#endif
struct RegCache {
enum Purpose {
FLAG_GEN = 0x0100,

View File

@ -20,19 +20,9 @@
#include "ppsspp_config.h"
#include <unordered_map>
#if PPSSPP_ARCH(ARM)
#include "Common/ArmEmitter.h"
#elif PPSSPP_ARCH(ARM64)
#include "Common/Arm64Emitter.h"
#elif PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
#include "Common/x64Emitter.h"
#elif PPSSPP_ARCH(MIPS)
#include "Common/MipsEmitter.h"
#else
#include "Common/FakeEmitter.h"
#endif
#include "GPU/Math3D.h"
#include "GPU/Software/FuncId.h"
#include "GPU/Software/RasterizerRegCache.h"
namespace Sampler {
@ -58,17 +48,7 @@ void Shutdown();
bool DescribeCodePtr(const u8 *ptr, std::string &name);
#if PPSSPP_ARCH(ARM)
class SamplerJitCache : public ArmGen::ARMXCodeBlock {
#elif PPSSPP_ARCH(ARM64)
class SamplerJitCache : public Arm64Gen::ARM64CodeBlock {
#elif PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
class SamplerJitCache : public Gen::XCodeBlock {
#elif PPSSPP_ARCH(MIPS)
class SamplerJitCache : public MIPSGen::MIPSCodeBlock {
#else
class SamplerJitCache : public FakeGen::FakeXCodeBlock {
#endif
class SamplerJitCache : public Rasterizer::CodeBlock {
public:
SamplerJitCache();