diff --git a/hw/xbox/nv2a/nv2a.c b/hw/xbox/nv2a/nv2a.c index 5aebb1190a3..e09fc8f8900 100644 --- a/hw/xbox/nv2a/nv2a.c +++ b/hw/xbox/nv2a/nv2a.c @@ -517,7 +517,6 @@ static const VMStateDescription vmstate_nv2a = { VMSTATE_INT32_ARRAY(pgraph.gl_draw_arrays_start, NV2AState, 1250), VMSTATE_INT32_ARRAY(pgraph.gl_draw_arrays_count, NV2AState, 1250), VMSTATE_UINT32_ARRAY(pgraph.regs, NV2AState, 0x2000), - VMSTATE_BOOL(pgraph.smoothing_enabled, NV2AState), VMSTATE_UINT32(pmc.pending_interrupts, NV2AState), VMSTATE_UINT32(pmc.enabled_interrupts, NV2AState), VMSTATE_UINT32(pfifo.pending_interrupts, NV2AState), diff --git a/hw/xbox/nv2a/nv2a_int.h b/hw/xbox/nv2a/nv2a_int.h index 11e00e71c38..65233ff265b 100644 --- a/hw/xbox/nv2a/nv2a_int.h +++ b/hw/xbox/nv2a/nv2a_int.h @@ -360,8 +360,6 @@ typedef struct PGRAPHState { bool ltc1_dirty[NV2A_LTC1_COUNT]; float material_alpha; - // FIXME: Find the correct register for this. - bool smoothing_enabled; // should figure out where these are in lighting context float light_infinite_half_vector[NV2A_MAX_LIGHTS][3]; diff --git a/hw/xbox/nv2a/nv2a_regs.h b/hw/xbox/nv2a/nv2a_regs.h index ba498279837..108db8f716d 100644 --- a/hw/xbox/nv2a/nv2a_regs.h +++ b/hw/xbox/nv2a/nv2a_regs.h @@ -335,6 +335,8 @@ # define NV_PGRAPH_CHEOPS_OFFSET_PROG_LD_PTR 0x000000FF # define NV_PGRAPH_CHEOPS_OFFSET_CONST_LD_PTR 0x0000FF00 #define NV_PGRAPH_DMA_STATE 0x00001034 +#define NV_PGRAPH_ANTIALIASING 0x00001800 +# define NV_PGRAPH_ANTIALIASING_ENABLE (1 << 0) #define NV_PGRAPH_BLEND 0x00001804 # define NV_PGRAPH_BLEND_EQN 0x00000007 # define NV_PGRAPH_BLEND_EN (1 << 3) @@ -1220,8 +1222,8 @@ # define NV097_SET_ZMIN_MAX_CONTROL_ZCLAMP_EN 0x000000F0 # define NV097_SET_ZMIN_MAX_CONTROL_ZCLAMP_EN_CULL 0 # define NV097_SET_ZMIN_MAX_CONTROL_ZCLAMP_EN_CLAMP 1 -# define NV097_SET_SMOOTHING_CONTROL 0x00001D7C -# define NV097_SET_SMOOTHING_CONTROL_DISABLE 0x00000001 +# define NV097_SET_ANTI_ALIASING_CONTROL 0x00001D7C +# define NV097_SET_ANTI_ALIASING_CONTROL_ENABLE (1 << 0) # define NV097_SET_ZSTENCIL_CLEAR_VALUE 0x00001D8C # define NV097_SET_COLOR_CLEAR_VALUE 0x00001D90 # define NV097_CLEAR_SURFACE 0x00001D94 diff --git a/hw/xbox/nv2a/pgraph.c b/hw/xbox/nv2a/pgraph.c index c6fdb15b144..a9bdb1ab671 100644 --- a/hw/xbox/nv2a/pgraph.c +++ b/hw/xbox/nv2a/pgraph.c @@ -3048,17 +3048,17 @@ DEF_METHOD(NV097, SET_BEGIN_END) glEnable(GL_PROGRAM_POINT_SIZE); + bool anti_aliasing = GET_MASK(pg->regs[NV_PGRAPH_ANTIALIASING], NV_PGRAPH_ANTIALIASING_ENABLE); + /* Edge Antialiasing */ - if (pg->smoothing_enabled - && pg->regs[NV_PGRAPH_SETUPRASTER] & - NV_PGRAPH_SETUPRASTER_LINESMOOTHENABLE) { + if (!anti_aliasing && pg->regs[NV_PGRAPH_SETUPRASTER] & + NV_PGRAPH_SETUPRASTER_LINESMOOTHENABLE) { glEnable(GL_LINE_SMOOTH); } else { glDisable(GL_LINE_SMOOTH); } - if (pg->smoothing_enabled - && pg->regs[NV_PGRAPH_SETUPRASTER] & - NV_PGRAPH_SETUPRASTER_POLYSMOOTHENABLE) { + if (!anti_aliasing && pg->regs[NV_PGRAPH_SETUPRASTER] & + NV_PGRAPH_SETUPRASTER_POLYSMOOTHENABLE) { glEnable(GL_POLYGON_SMOOTH); } else { glDisable(GL_POLYGON_SMOOTH); @@ -3459,11 +3459,10 @@ DEF_METHOD(NV097, SET_ZMIN_MAX_CONTROL) } } -DEF_METHOD(NV097, SET_SMOOTHING_CONTROL) +DEF_METHOD(NV097, SET_ANTI_ALIASING_CONTROL) { - // FIXME: Find the correct register for this. - pg->smoothing_enabled = !GET_MASK(parameter, - NV097_SET_SMOOTHING_CONTROL_DISABLE); + SET_MASK(pg->regs[NV_PGRAPH_ANTIALIASING], NV_PGRAPH_ANTIALIASING_ENABLE, + GET_MASK(parameter, NV097_SET_ANTI_ALIASING_CONTROL_ENABLE)); // FIXME: Handle the remaining bits (observed values 0xFFFF0000, 0xFFFF0001) } @@ -4037,7 +4036,6 @@ void pgraph_init(NV2AState *d) shader_cache_init(pg); pg->material_alpha = 0.0f; - pg->smoothing_enabled = false; SET_MASK(pg->regs[NV_PGRAPH_CONTROL_3], NV_PGRAPH_CONTROL_3_SHADEMODE, NV_PGRAPH_CONTROL_3_SHADEMODE_SMOOTH); pg->primitive_mode = PRIM_TYPE_INVALID; diff --git a/hw/xbox/nv2a/pgraph_methods.h b/hw/xbox/nv2a/pgraph_methods.h index ab47f9966eb..380df07ea5c 100644 --- a/hw/xbox/nv2a/pgraph_methods.h +++ b/hw/xbox/nv2a/pgraph_methods.h @@ -169,7 +169,7 @@ DEF_METHOD_RANGE(NV097, SET_VERTEX_DATA4S_M, 32) DEF_METHOD(NV097, SET_SEMAPHORE_OFFSET) DEF_METHOD(NV097, BACK_END_WRITE_SEMAPHORE_RELEASE) DEF_METHOD(NV097, SET_ZMIN_MAX_CONTROL) -DEF_METHOD(NV097, SET_SMOOTHING_CONTROL) +DEF_METHOD(NV097, SET_ANTI_ALIASING_CONTROL) DEF_METHOD(NV097, SET_ZSTENCIL_CLEAR_VALUE) DEF_METHOD(NV097, SET_COLOR_CLEAR_VALUE) DEF_METHOD(NV097, CLEAR_SURFACE)