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"]
"""
print("const GPU_SW_Backend::DrawRectangleFunction GPU_SW_Backend::s_rectangle_draw_functions[%d][%d][2] = {" % (len(texmode), len(transparentmode)))
for texture in range(len(texmode)):
print(" { // %s" % texmode[texture])
for transparency in range(len(transparentmode)):
print(" { // %s" % transparentmode[transparency])
for check_mask in range(2):
line = "&GPU_SW_Backend::DrawRectangle<%s, %s, %s>" % (texmode[texture], transparentmode[transparency], bools[check_mask])
print(" %s%s" % (line, "," if check_mask == 0 else ""))
print(" }%s" % ("," if transparency < (len(transparentmode) - 1) else ""))
print(" }%s" % ("," if texture < (len(texmode) - 1) else ""))
print("static constexpr DrawRectangleFunction funcs[2][2][2] = {")
for texture in range(2):
print(" {")
for raw_texture in range(2):
print(" {")
for transparency in range(2):
line = "&GPU_SW_Backend::DrawRectangle<%s, %s, %s>" % (bools[texture], bools[0 if texture == 0 else raw_texture], bools[transparency])
print(" %s%s" % (line, "," if transparency == 0 else ""))
print(" }%s" % ("," if raw_texture == 0 else ""))
print(" }%s" % ("," if texture == 0 else ""))
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):
print(" { // shading %s" % bools[shading])
for texture in range(len(texmode)):
print(" { // %s" % texmode[texture])
for transparency in range(len(transparentmode)):
print(" { // %s" % transparentmode[transparency])
print(" {")
for texture in range(2):
print(" {")
for raw_texture in range(2):
print(" {")
for transparency in range(2):
print(" {")
for dither in range(2):
print(" { // dither %s" % bools[dither])
for check_mask in range(2):
line = "&GPU_SW_Backend::DrawTriangle<%s, %s, %s, %s, %s>" % (bools[shading], texmode[texture], transparentmode[transparency], bools[dither], bools[check_mask])
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 texture < (len(texmode) - 1) else ""))
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 dither == 0 else ""))
print(" }%s" % ("," if transparency == 0 else ""))
print(" }%s" % ("," if raw_texture == 0 else ""))
print(" }%s" % ("," if texture == 0 else ""))
print(" }%s" % ("," if shading == 0 else ""))
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):
print(" { // shading %s" % bools[shading])
for transparency in range(len(transparentmode)):
print(" { // %s" % transparentmode[transparency])
print(" {")
for transparency in range(2):
print(" {")
for dither in range(2):
print(" { // dither %s" % bools[dither])
for check_mask in range(2):
line = "&GPU_SW_Backend::DrawLine<%s, %s, %s, %s>" % (bools[shading], transparentmode[transparency], bools[dither], bools[check_mask])
print(" %s%s" % (line, "," if check_mask == 0 else ""))
print(" }%s" % ("," if dither == 0 else ""))
print(" }%s" % ("," if transparency < (len(transparentmode) - 1) else ""))
line = "&GPU_SW_Backend::DrawLine<%s, %s, %s>" % (bools[shading], bools[transparency], bools[dither])
print(" %s%s" % (line, "," if dither == 0 else ""))
print(" }%s" % ("," if transparency == 0 else ""))
print(" }%s" % ("," if shading == 0 else ""))
print("};")

File diff suppressed because it is too large Load Diff

View File

@ -98,13 +98,17 @@ protected:
//////////////////////////////////////////////////////////////////////////
// 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,
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);
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
//////////////////////////////////////////////////////////////////////////
@ -133,36 +137,31 @@ protected:
template<bool shading_enable, bool texture_enable>
void AddIDeltas_DY(i_group& ig, const i_deltas& idl, u32 count = 1);
template<bool shading_enable, GPUTextureMode texture_mode, GPUTransparencyMode transparency_mode,
bool dithering_enable, bool check_mask>
template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable,
bool dithering_enable>
void DrawSpan(const GPUBackendDrawPolygonCommand* cmd, s32 y, s32 x_start, s32 x_bound, i_group ig,
const i_deltas& idl);
template<bool shading_enable, GPUTextureMode texture_mode, GPUTransparencyMode transparency_mode,
bool dithering_enable, bool check_mask>
template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable,
bool dithering_enable>
void DrawTriangle(const GPUBackendDrawPolygonCommand* cmd, const GPUBackendDrawPolygonCommand::Vertex* v0,
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,
const GPUBackendDrawPolygonCommand::Vertex* v0,
const GPUBackendDrawPolygonCommand::Vertex* v1,
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,
const GPUBackendDrawLineCommand::Vertex* p0,
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];
static const DrawTriangleFunction s_triangle_draw_functions[2][9][5][2][2];
static const DrawLineFunction s_line_draw_functions[2][5][2][2];
std::array<u16, VRAM_WIDTH * VRAM_HEIGHT> m_vram;
};