GPU/SW: Specialize rasterizing functions further

This commit is contained in:
Connor McLaughlin 2021-07-10 14:28:27 +10:00
parent 79dccc9d05
commit 0537370fb5
2 changed files with 1244 additions and 111 deletions

File diff suppressed because it is too large Load Diff

View File

@ -98,17 +98,13 @@ protected:
//////////////////////////////////////////////////////////////////////////
// Rasterization
//////////////////////////////////////////////////////////////////////////
template<bool texture_enable, bool raw_texture_enable, bool transparency_enable, bool dithering_enable>
template<GPUTextureMode texture_mode, GPUTransparencyMode transparency_mode, bool dithering_enable, bool check_mask>
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<bool texture_enable, bool raw_texture_enable, bool transparency_enable>
template<GPUTextureMode texture_mode, GPUTransparencyMode transparency_mode, bool check_mask>
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
//////////////////////////////////////////////////////////////////////////
@ -137,31 +133,36 @@ 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, bool texture_enable, bool raw_texture_enable, bool transparency_enable,
bool dithering_enable>
template<bool shading_enable, GPUTextureMode texture_mode, GPUTransparencyMode transparency_mode,
bool dithering_enable, bool check_mask>
void DrawSpan(const GPUBackendDrawPolygonCommand* cmd, s32 y, s32 x_start, s32 x_bound, i_group ig,
const i_deltas& idl);
template<bool shading_enable, bool texture_enable, bool raw_texture_enable, bool transparency_enable,
bool dithering_enable>
template<bool shading_enable, GPUTextureMode texture_mode, GPUTransparencyMode transparency_mode,
bool dithering_enable, bool check_mask>
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);
std::array<u16, VRAM_WIDTH * VRAM_HEIGHT> m_vram;
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];
};