GPU/SW: Fix performance regression on 32-bit ARM

This commit is contained in:
Connor McLaughlin 2021-07-17 14:02:54 +10:00
parent 75b69a6f7e
commit e9374646e9
3 changed files with 148 additions and 1301 deletions

View file

@ -1,73 +1,46 @@
texmode = [
"GPUTextureMode::Palette4Bit",
"GPUTextureMode::Palette8Bit",
"GPUTextureMode::Direct16Bit",
"GPUTextureMode::Direct16Bit",
"GPUTextureMode::RawPalette4Bit",
"GPUTextureMode::RawPalette8Bit",
"GPUTextureMode::RawDirect16Bit",
"GPUTextureMode::RawDirect16Bit",
"GPUTextureMode::Disabled"
]
transparentmode = [
"GPUTransparencyMode::HalfBackgroundPlusHalfForeground",
"GPUTransparencyMode::BackgroundPlusForeground",
"GPUTransparencyMode::BackgroundMinusForeground",
"GPUTransparencyMode::BackgroundPlusQuarterForeground",
"GPUTransparencyMode::Disabled"
]
bools = ["false", "true"] bools = ["false", "true"]
""" print("static constexpr DrawRectangleFunction funcs[2][2][2] = {")
print("const GPU_SW_Backend::DrawRectangleFunction GPU_SW_Backend::s_rectangle_draw_functions[%d][%d][2] = {" % (len(texmode), len(transparentmode))) for texture in range(2):
for texture in range(len(texmode)): print(" {")
print(" { // %s" % texmode[texture]) for raw_texture in range(2):
for transparency in range(len(transparentmode)): print(" {")
print(" { // %s" % transparentmode[transparency]) for transparency in range(2):
for check_mask in range(2): line = "&GPU_SW_Backend::DrawRectangle<%s, %s, %s>" % (bools[texture], bools[0 if texture == 0 else raw_texture], bools[transparency])
line = "&GPU_SW_Backend::DrawRectangle<%s, %s, %s>" % (texmode[texture], transparentmode[transparency], bools[check_mask]) print(" %s%s" % (line, "," if transparency == 0 else ""))
print(" %s%s" % (line, "," if check_mask == 0 else "")) print(" }%s" % ("," if raw_texture == 0 else ""))
print(" }%s" % ("," if transparency < (len(transparentmode) - 1) else "")) print(" }%s" % ("," if texture == 0 else ""))
print(" }%s" % ("," if texture < (len(texmode) - 1) else ""))
print("};") print("};")
"""
"""
print("const GPU_SW_Backend::DrawTriangleFunction GPU_SW_Backend::s_triangle_draw_functions[2][%d][%d][2][2] = {" % (len(texmode), len(transparentmode))) print("static constexpr DrawTriangleFunction funcs[2][2][2][2][2] = {")
for shading in range(2): for shading in range(2):
print(" { // shading %s" % bools[shading]) print(" {")
for texture in range(len(texmode)): for texture in range(2):
print(" { // %s" % texmode[texture]) print(" {")
for transparency in range(len(transparentmode)): for raw_texture in range(2):
print(" { // %s" % transparentmode[transparency]) print(" {")
for dither in range(2): for transparency in range(2):
print(" { // dither %s" % bools[dither]) print(" {")
for check_mask in range(2): for dither in range(2):
line = "&GPU_SW_Backend::DrawTriangle<%s, %s, %s, %s, %s>" % (bools[shading], texmode[texture], transparentmode[transparency], bools[dither], bools[check_mask]) line = "&GPU_SW_Backend::DrawTriangle<%s, %s, %s, %s, %s>" % (bools[shading], bools[texture], bools[0 if texture == 0 else raw_texture], bools[transparency], bools[0 if raw_texture != 0 else dither])
print(" %s%s" % (line, "," if check_mask == 0 else "")) print(" %s%s" % (line, "," if dither == 0 else ""))
print(" }%s" % ("," if dither == 0 else "")) print(" }%s" % ("," if transparency == 0 else ""))
print(" }%s" % ("," if transparency < (len(transparentmode) - 1) else "")) print(" }%s" % ("," if raw_texture == 0 else ""))
print(" }%s" % ("," if texture < (len(texmode) - 1) else "")) print(" }%s" % ("," if texture == 0 else ""))
print(" }%s" % ("," if shading == 0 else "")) print(" }%s" % ("," if shading == 0 else ""))
print("};") print("};")
"""
print("const GPU_SW_Backend::DrawLineFunction GPU_SW_Backend::s_line_draw_functions[2][%d][2][2] = {" % (len(transparentmode)))
print("static constexpr DrawLineFunction funcs[2][2][2] = {")
for shading in range(2): for shading in range(2):
print(" { // shading %s" % bools[shading]) print(" {")
for transparency in range(len(transparentmode)): for transparency in range(2):
print(" { // %s" % transparentmode[transparency]) print(" {")
for dither in range(2): for dither in range(2):
print(" { // dither %s" % bools[dither]) line = "&GPU_SW_Backend::DrawLine<%s, %s, %s>" % (bools[shading], bools[transparency], bools[dither])
for check_mask in range(2): print(" %s%s" % (line, "," if dither == 0 else ""))
line = "&GPU_SW_Backend::DrawLine<%s, %s, %s, %s>" % (bools[shading], transparentmode[transparency], bools[dither], bools[check_mask]) print(" }%s" % ("," if transparency == 0 else ""))
print(" %s%s" % (line, "," if check_mask == 0 else ""))
print(" }%s" % ("," if dither == 0 else ""))
print(" }%s" % ("," if transparency < (len(transparentmode) - 1) else ""))
print(" }%s" % ("," if shading == 0 else "")) print(" }%s" % ("," if shading == 0 else ""))
print("};") print("};")

File diff suppressed because it is too large Load diff

View file

@ -98,13 +98,17 @@ protected:
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Rasterization // Rasterization
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
template<GPUTextureMode texture_mode, GPUTransparencyMode transparency_mode, bool dithering_enable, bool check_mask> template<bool texture_enable, bool raw_texture_enable, bool transparency_enable, bool dithering_enable>
void ShadePixel(const GPUBackendDrawCommand* cmd, u32 x, u32 y, u8 color_r, u8 color_g, u8 color_b, u8 texcoord_x, void ShadePixel(const GPUBackendDrawCommand* cmd, u32 x, u32 y, u8 color_r, u8 color_g, u8 color_b, u8 texcoord_x,
u8 texcoord_y); u8 texcoord_y);
template<GPUTextureMode texture_mode, GPUTransparencyMode transparency_mode, bool check_mask> template<bool texture_enable, bool raw_texture_enable, bool transparency_enable>
void DrawRectangle(const GPUBackendDrawRectangleCommand* cmd); void DrawRectangle(const GPUBackendDrawRectangleCommand* cmd);
using DrawRectangleFunction = void (GPU_SW_Backend::*)(const GPUBackendDrawRectangleCommand* cmd);
DrawRectangleFunction GetDrawRectangleFunction(bool texture_enable, bool raw_texture_enable,
bool transparency_enable);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Polygon and line rasterization ported from Mednafen // Polygon and line rasterization ported from Mednafen
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -133,36 +137,31 @@ protected:
template<bool shading_enable, bool texture_enable> template<bool shading_enable, bool texture_enable>
void AddIDeltas_DY(i_group& ig, const i_deltas& idl, u32 count = 1); void AddIDeltas_DY(i_group& ig, const i_deltas& idl, u32 count = 1);
template<bool shading_enable, GPUTextureMode texture_mode, GPUTransparencyMode transparency_mode, template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable,
bool dithering_enable, bool check_mask> bool dithering_enable>
void DrawSpan(const GPUBackendDrawPolygonCommand* cmd, s32 y, s32 x_start, s32 x_bound, i_group ig, void DrawSpan(const GPUBackendDrawPolygonCommand* cmd, s32 y, s32 x_start, s32 x_bound, i_group ig,
const i_deltas& idl); const i_deltas& idl);
template<bool shading_enable, GPUTextureMode texture_mode, GPUTransparencyMode transparency_mode, template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable,
bool dithering_enable, bool check_mask> bool dithering_enable>
void DrawTriangle(const GPUBackendDrawPolygonCommand* cmd, const GPUBackendDrawPolygonCommand::Vertex* v0, void DrawTriangle(const GPUBackendDrawPolygonCommand* cmd, const GPUBackendDrawPolygonCommand::Vertex* v0,
const GPUBackendDrawPolygonCommand::Vertex* v1, const GPUBackendDrawPolygonCommand::Vertex* v2); const GPUBackendDrawPolygonCommand::Vertex* v1, const GPUBackendDrawPolygonCommand::Vertex* v2);
template<bool shading_enable, GPUTransparencyMode transparency_mode, bool dithering_enable, bool check_mask>
void DrawLine(const GPUBackendDrawLineCommand* cmd, const GPUBackendDrawLineCommand::Vertex* p0,
const GPUBackendDrawLineCommand::Vertex* p1);
#if 0
std::array<u16, VRAM_WIDTH * VRAM_HEIGHT> m_vram;
#else
u16 m_vram[VRAM_WIDTH * VRAM_HEIGHT];
#endif
using DrawRectangleFunction = void (GPU_SW_Backend::*)(const GPUBackendDrawRectangleCommand* cmd);
using DrawTriangleFunction = void (GPU_SW_Backend::*)(const GPUBackendDrawPolygonCommand* cmd, using DrawTriangleFunction = void (GPU_SW_Backend::*)(const GPUBackendDrawPolygonCommand* cmd,
const GPUBackendDrawPolygonCommand::Vertex* v0, const GPUBackendDrawPolygonCommand::Vertex* v0,
const GPUBackendDrawPolygonCommand::Vertex* v1, const GPUBackendDrawPolygonCommand::Vertex* v1,
const GPUBackendDrawPolygonCommand::Vertex* v2); const GPUBackendDrawPolygonCommand::Vertex* v2);
DrawTriangleFunction GetDrawTriangleFunction(bool shading_enable, bool texture_enable, bool raw_texture_enable,
bool transparency_enable, bool dithering_enable);
template<bool shading_enable, bool transparency_enable, bool dithering_enable>
void DrawLine(const GPUBackendDrawLineCommand* cmd, const GPUBackendDrawLineCommand::Vertex* p0,
const GPUBackendDrawLineCommand::Vertex* p1);
using DrawLineFunction = void (GPU_SW_Backend::*)(const GPUBackendDrawLineCommand* cmd, using DrawLineFunction = void (GPU_SW_Backend::*)(const GPUBackendDrawLineCommand* cmd,
const GPUBackendDrawLineCommand::Vertex* p0, const GPUBackendDrawLineCommand::Vertex* p0,
const GPUBackendDrawLineCommand::Vertex* p1); const GPUBackendDrawLineCommand::Vertex* p1);
DrawLineFunction GetDrawLineFunction(bool shading_enable, bool transparency_enable, bool dithering_enable);
static const DrawRectangleFunction s_rectangle_draw_functions[9][5][2]; std::array<u16, VRAM_WIDTH * VRAM_HEIGHT> m_vram;
static const DrawTriangleFunction s_triangle_draw_functions[2][9][5][2][2];
static const DrawLineFunction s_line_draw_functions[2][5][2][2];
}; };