From a34cab69dd648e7a386cd1a55c1a90f6c0e5f467 Mon Sep 17 00:00:00 2001 From: Matt Borgerson Date: Tue, 1 Dec 2020 20:47:18 -0700 Subject: [PATCH] nv2a: Support line and poly anti-aliasing --- hw/xbox/nv2a/nv2a_regs.h | 4 ++++ hw/xbox/nv2a/pgraph.c | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/hw/xbox/nv2a/nv2a_regs.h b/hw/xbox/nv2a/nv2a_regs.h index b0e31585a9..3cce60e542 100644 --- a/hw/xbox/nv2a/nv2a_regs.h +++ b/hw/xbox/nv2a/nv2a_regs.h @@ -467,6 +467,8 @@ # define NV_PGRAPH_SETUPRASTER_POFFSETPOINTENABLE (1 << 6) # define NV_PGRAPH_SETUPRASTER_POFFSETLINEENABLE (1 << 7) # define NV_PGRAPH_SETUPRASTER_POFFSETFILLENABLE (1 << 8) +# define NV_PGRAPH_SETUPRASTER_LINESMOOTHENABLE (1 << 10) +# define NV_PGRAPH_SETUPRASTER_POLYSMOOTHENABLE (1 << 11) # define NV_PGRAPH_SETUPRASTER_CULLCTRL 0x00600000 # define NV_PGRAPH_SETUPRASTER_CULLCTRL_FRONT 1 # define NV_PGRAPH_SETUPRASTER_CULLCTRL_BACK 2 @@ -852,6 +854,8 @@ # define NV097_SET_DEPTH_TEST_ENABLE 0x0000030C # define NV097_SET_DITHER_ENABLE 0x00000310 # define NV097_SET_LIGHTING_ENABLE 0x00000314 +# define NV097_SET_LINE_SMOOTH_ENABLE 0x00000320 +# define NV097_SET_POLY_SMOOTH_ENABLE 0x00000324 # define NV097_SET_SKIN_MODE 0x00000328 # define NV097_SET_SKIN_MODE_OFF 0 # define NV097_SET_SKIN_MODE_2G 1 diff --git a/hw/xbox/nv2a/pgraph.c b/hw/xbox/nv2a/pgraph.c index 803c24b51a..157d1ebef7 100644 --- a/hw/xbox/nv2a/pgraph.c +++ b/hw/xbox/nv2a/pgraph.c @@ -1087,6 +1087,14 @@ void pgraph_method(NV2AState *d, SET_MASK(pg->regs[NV_PGRAPH_CSV0_C], NV_PGRAPH_CSV0_C_LIGHTING, parameter); break; + case NV097_SET_LINE_SMOOTH_ENABLE: + SET_MASK(pg->regs[NV_PGRAPH_SETUPRASTER], + NV_PGRAPH_SETUPRASTER_LINESMOOTHENABLE, parameter); + break; + case NV097_SET_POLY_SMOOTH_ENABLE: + SET_MASK(pg->regs[NV_PGRAPH_SETUPRASTER], + NV_PGRAPH_SETUPRASTER_POLYSMOOTHENABLE, parameter); + break; case NV097_SET_SKIN_MODE: SET_MASK(pg->regs[NV_PGRAPH_CSV0_D], NV_PGRAPH_CSV0_D_SKIN, parameter); @@ -2149,6 +2157,20 @@ void pgraph_method(NV2AState *d, glDisable(GL_DITHER); } + /* Edge Antialiasing */ + if (pg->regs[NV_PGRAPH_SETUPRASTER] & + NV_PGRAPH_SETUPRASTER_LINESMOOTHENABLE) { + glEnable(GL_LINE_SMOOTH); + } else { + glDisable(GL_LINE_SMOOTH); + } + if (pg->regs[NV_PGRAPH_SETUPRASTER] & + NV_PGRAPH_SETUPRASTER_POLYSMOOTHENABLE) { + glEnable(GL_POLYGON_SMOOTH); + } else { + glDisable(GL_POLYGON_SMOOTH); + } + //glDisableVertexAttribArray(NV2A_VERTEX_ATTR_DIFFUSE); //glVertexAttrib4f(NV2A_VERTEX_ATTR_DIFFUSE, 1.0, 1.0, 1.0, 1.0);