Skip to content

Commit 66b5884

Browse files
abairejyetcv
authored andcommitted
nv2a: Improve handling of SET_POINT_SIZE
1 parent 2143899 commit 66b5884

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

hw/xbox/nv2a/nv2a_regs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@
10491049
# define NV097_SET_TEXGEN_Q 0x000003CC
10501050
# define NV097_SET_TEXTURE_MATRIX_ENABLE 0x00000420
10511051
# define NV097_SET_POINT_SIZE 0x0000043C
1052-
# define NV097_SET_POINT_SIZE_V 0x000001FF
1052+
# define NV097_SET_POINT_SIZE_V_MAX 0x1FF
10531053
# define NV097_SET_PROJECTION_MATRIX 0x00000440
10541054
# define NV097_SET_MODEL_VIEW_MATRIX 0x00000480
10551055
# define NV097_SET_INVERSE_MODEL_VIEW_MATRIX 0x00000580

hw/xbox/nv2a/pgraph/glsl/vsh-ff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ GLSL_DEFINE(materialEmissionColor, GLSL_LTCTXA(NV_IGRAPH_XF_LTCTXA_CM_COL) ".xyz
500500
" oPts.x = clamp(oPts.x * pointParams[3] + pointParams[7], ptMinSize, ptMaxSize) * %d;\n",
501501
state->surface_scale_factor);
502502
} else {
503-
mstring_append_fmt(body, " oPts.x = %f * %d;\n", state->point_size,
503+
mstring_append_fmt(body, " oPts.x = %f * %d;\n",
504+
MAX(1.f, state->point_size),
504505
state->surface_scale_factor);
505506
}
506507
}

hw/xbox/nv2a/pgraph/glsl/vsh.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ void pgraph_glsl_set_vsh_state(PGRAPHState *pg, VshState *vsh)
130130

131131
vsh->point_params_enable = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_CSV0_D),
132132
NV_PGRAPH_CSV0_D_POINTPARAMSENABLE);
133-
vsh->point_size = GET_MASK(pgraph_reg_r(pg, NV_PGRAPH_POINTSIZE),
134-
NV097_SET_POINT_SIZE_V) /
135-
8.0f;
133+
vsh->point_size = pgraph_reg_r(pg, NV_PGRAPH_POINTSIZE) / 8.0f;
136134
if (vsh->point_params_enable) {
137135
for (int i = 0; i < 8; i++) {
138136
vsh->point_params[i] = pg->point_params[i];
@@ -306,6 +304,12 @@ MString *pgraph_glsl_gen_vsh(const VshState *state, GenVshGlslOptions opts)
306304
pgraph_glsl_gen_vsh_prog(
307305
VSH_VERSION_XVS, (uint32_t *)state->programmable.program_data,
308306
state->programmable.program_length, header, body);
307+
if (!state->point_params_enable) {
308+
mstring_append_fmt(body, " oPts.x = %f * %d;\n",
309+
state->point_size <= 0.f ? 1.f :
310+
state->point_size,
311+
state->surface_scale_factor);
312+
}
309313
}
310314

311315
if (!state->fog_enable) {

hw/xbox/nv2a/pgraph/pgraph.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1729,7 +1729,11 @@ DEF_METHOD_INC(NV097, SET_TEXTURE_MATRIX_ENABLE)
17291729

17301730
DEF_METHOD(NV097, SET_POINT_SIZE)
17311731
{
1732-
PG_SET_MASK(NV_PGRAPH_POINTSIZE, NV097_SET_POINT_SIZE_V, parameter);
1732+
if (parameter > NV097_SET_POINT_SIZE_V_MAX) {
1733+
return;
1734+
}
1735+
1736+
pgraph_reg_w(pg, NV_PGRAPH_POINTSIZE, parameter);
17331737
}
17341738

17351739
DEF_METHOD_INC(NV097, SET_PROJECTION_MATRIX)

0 commit comments

Comments
 (0)