From aa496f863f174fa1bd488dabf7f4f0f2c3646a30 Mon Sep 17 00:00:00 2001 From: Erik Abair Date: Fri, 28 Nov 2025 14:17:11 -0800 Subject: [PATCH] nv2a: Improve handling of SET_POINT_SIZE --- hw/xbox/nv2a/nv2a_regs.h | 2 +- hw/xbox/nv2a/pgraph/glsl/vsh-ff.c | 3 ++- hw/xbox/nv2a/pgraph/glsl/vsh.c | 10 +++++++--- hw/xbox/nv2a/pgraph/pgraph.c | 6 +++++- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/hw/xbox/nv2a/nv2a_regs.h b/hw/xbox/nv2a/nv2a_regs.h index e6543ae8d0..65f4e9d11a 100644 --- a/hw/xbox/nv2a/nv2a_regs.h +++ b/hw/xbox/nv2a/nv2a_regs.h @@ -1049,7 +1049,7 @@ # define NV097_SET_TEXGEN_Q 0x000003CC # define NV097_SET_TEXTURE_MATRIX_ENABLE 0x00000420 # define NV097_SET_POINT_SIZE 0x0000043C -# define NV097_SET_POINT_SIZE_V 0x000001FF +# define NV097_SET_POINT_SIZE_V_MAX 0x1FF # define NV097_SET_PROJECTION_MATRIX 0x00000440 # define NV097_SET_MODEL_VIEW_MATRIX 0x00000480 # define NV097_SET_INVERSE_MODEL_VIEW_MATRIX 0x00000580 diff --git a/hw/xbox/nv2a/pgraph/glsl/vsh-ff.c b/hw/xbox/nv2a/pgraph/glsl/vsh-ff.c index 0e35f2f2c5..2930e92d80 100644 --- a/hw/xbox/nv2a/pgraph/glsl/vsh-ff.c +++ b/hw/xbox/nv2a/pgraph/glsl/vsh-ff.c @@ -500,7 +500,8 @@ GLSL_DEFINE(materialEmissionColor, GLSL_LTCTXA(NV_IGRAPH_XF_LTCTXA_CM_COL) ".xyz " oPts.x = clamp(oPts.x * pointParams[3] + pointParams[7], ptMinSize, ptMaxSize) * %d;\n", state->surface_scale_factor); } else { - mstring_append_fmt(body, " oPts.x = %f * %d;\n", state->point_size, + mstring_append_fmt(body, " oPts.x = %f * %d;\n", + MAX(1.f, state->point_size), state->surface_scale_factor); } } diff --git a/hw/xbox/nv2a/pgraph/glsl/vsh.c b/hw/xbox/nv2a/pgraph/glsl/vsh.c index de4ab56216..0413489131 100644 --- a/hw/xbox/nv2a/pgraph/glsl/vsh.c +++ b/hw/xbox/nv2a/pgraph/glsl/vsh.c @@ -130,9 +130,7 @@ void pgraph_glsl_set_vsh_state(PGRAPHState *pg, VshState *vsh) vsh->point_params_enable = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_CSV0_D), NV_PGRAPH_CSV0_D_POINTPARAMSENABLE); - vsh->point_size = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_POINTSIZE), - NV097_SET_POINT_SIZE_V) / - 8.0f; + vsh->point_size = pgraph_reg_r(pg, NV_PGRAPH_POINTSIZE) / 8.0f; if (vsh->point_params_enable) { for (int i = 0; i < 8; i++) { vsh->point_params[i] = pg->point_params[i]; @@ -306,6 +304,12 @@ MString *pgraph_glsl_gen_vsh(const VshState *state, GenVshGlslOptions opts) pgraph_glsl_gen_vsh_prog( VSH_VERSION_XVS, (uint32_t *)state->programmable.program_data, state->programmable.program_length, header, body); + if (!state->point_params_enable) { + mstring_append_fmt(body, " oPts.x = %f * %d;\n", + state->point_size <= 0.f ? 1.f : + state->point_size, + state->surface_scale_factor); + } } if (!state->fog_enable) { diff --git a/hw/xbox/nv2a/pgraph/pgraph.c b/hw/xbox/nv2a/pgraph/pgraph.c index 1e75cb810d..b34685866c 100644 --- a/hw/xbox/nv2a/pgraph/pgraph.c +++ b/hw/xbox/nv2a/pgraph/pgraph.c @@ -1729,7 +1729,11 @@ DEF_METHOD_INC(NV097, SET_TEXTURE_MATRIX_ENABLE) DEF_METHOD(NV097, SET_POINT_SIZE) { - PG_SET_MASK(NV_PGRAPH_POINTSIZE, NV097_SET_POINT_SIZE_V, parameter); + if (parameter > NV097_SET_POINT_SIZE_V_MAX) { + return; + } + + pgraph_reg_w(pg, NV_PGRAPH_POINTSIZE, parameter); } DEF_METHOD_INC(NV097, SET_PROJECTION_MATRIX)