Skip to content

Commit

Permalink
nv2a: Fix SET_ANTI_ALIASING_CONTROL
Browse files Browse the repository at this point in the history
- Rename from SET_SMOOTHING_CONTROL
- Use correct register
  • Loading branch information
mborgerson committed Jun 12, 2023
1 parent 5cd1e3c commit bb05a4f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
1 change: 0 additions & 1 deletion hw/xbox/nv2a/nv2a.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 0 additions & 2 deletions hw/xbox/nv2a/nv2a_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
6 changes: 4 additions & 2 deletions hw/xbox/nv2a/nv2a_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
20 changes: 9 additions & 11 deletions hw/xbox/nv2a/pgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion hw/xbox/nv2a/pgraph_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bb05a4f

Please sign in to comment.