Skip to content

Commit dd2917e

Browse files
committed
nv2a: Move point params to uniforms
1 parent 89185e6 commit dd2917e

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

hw/xbox/nv2a/pgraph/gl/renderer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ typedef struct ShaderBinding {
126126

127127
GLint clip_region_loc[8];
128128

129+
GLint point_params_loc[8];
129130
GLint material_alpha_loc;
130131
} ShaderBinding;
131132

hw/xbox/nv2a/pgraph/gl/shaders.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ static void update_shader_constant_locations(ShaderBinding *binding)
190190
binding->clip_region_loc[i] = glGetUniformLocation(binding->gl_program, tmp);
191191
}
192192

193+
for (int i = 0; i < 8; i++) {
194+
snprintf(tmp, sizeof(tmp), "pointParams[%d]", i);
195+
binding->point_params_loc[i] = glGetUniformLocation(binding->gl_program, tmp);
196+
}
197+
193198
if (binding->state.fixed_function) {
194199
binding->material_alpha_loc =
195200
glGetUniformLocation(binding->gl_program, "material_alpha");
@@ -950,6 +955,13 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
950955
x_min, y_min_xlat, x_max, y_max_xlat);
951956
}
952957

958+
for (i = 0; i < 8; i++) {
959+
GLint loc = binding->point_params_loc[i];
960+
if (loc != -1) {
961+
glUniform1f(loc, pg->point_params[i]);
962+
}
963+
}
964+
953965
if (binding->material_alpha_loc != -1) {
954966
glUniform1f(binding->material_alpha_loc, pg->material_alpha);
955967
}

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -482,14 +482,12 @@ GLSL_DEFINE(materialEmissionColor, GLSL_LTCTXA(NV_IGRAPH_XF_LTCTXA_CM_COL) ".xyz
482482

483483
/* FIXME: Testing */
484484
if (state->point_params_enable) {
485-
mstring_append_fmt(
485+
mstring_append_fmt(uniforms, "%sfloat pointParams[8];\n", u);
486+
mstring_append(
486487
body,
487488
" float d_e = length(position * modelViewMat0);\n"
488-
" oPts.x = 1/sqrt(%f + %f*d_e + %f*d_e*d_e) + %f;\n",
489-
state->point_params[0], state->point_params[1], state->point_params[2],
490-
state->point_params[6]);
491-
mstring_append_fmt(body, " oPts.x = min(oPts.x*%f + %f, 64.0) * %d;\n",
492-
state->point_params[3], state->point_params[7],
489+
" oPts.x = 1/sqrt(pointParams[0] + pointParams[1] * d_e + pointParams[2] * d_e * d_e) + pointParams[6];\n");
490+
mstring_append_fmt(body, " oPts.x = min(oPts.x * pointParams[3] + pointParams[7], 64.0) * %d;\n",
493491
state->surface_scale_factor);
494492
} else {
495493
mstring_append_fmt(body, " oPts.x = %f * %d;\n", state->point_size,

hw/xbox/nv2a/pgraph/vk/renderer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ typedef struct ShaderBinding {
194194

195195
int clip_region_loc;
196196

197+
int point_params_loc[8];
197198
int material_alpha_loc;
198199

199200
int uniform_attrs_loc;

0 commit comments

Comments
 (0)