Skip to content

Commit d593869

Browse files
abairemborgerson
andauthored
nv2a: Move point params to uniforms
Co-authored-by: Matt Borgerson <[email protected]>
1 parent 6e513ed commit d593869

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

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

+1
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

+12
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

+4-6
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ typedef struct ShaderBinding {
191191
int light_local_position_loc[NV2A_MAX_LIGHTS];
192192
int light_local_attenuation_loc[NV2A_MAX_LIGHTS];
193193
int specular_power_loc;
194+
int point_params_loc;
194195

195196
int clip_region_loc;
196-
197197
int material_alpha_loc;
198198

199199
int uniform_attrs_loc;

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

+8
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ static void update_shader_constant_locations(ShaderBinding *binding)
308308
binding->clip_region_loc =
309309
uniform_index(&binding->fragment->uniforms, "clipRegion");
310310

311+
binding->point_params_loc =
312+
uniform_index(&binding->vertex->uniforms, "pointParams");
313+
311314
binding->material_alpha_loc =
312315
uniform_index(&binding->vertex->uniforms, "material_alpha");
313316

@@ -720,6 +723,11 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
720723
uniform1iv(&binding->fragment->uniforms, binding->clip_region_loc,
721724
8 * 4, (void *)clip_regions);
722725

726+
if (binding->point_params_loc != -1) {
727+
uniform1iv(&binding->vertex->uniforms, binding->point_params_loc,
728+
ARRAY_SIZE(pg->point_params), (void *)pg->point_params);
729+
}
730+
723731
if (binding->material_alpha_loc != -1) {
724732
uniform1f(&binding->vertex->uniforms, binding->material_alpha_loc,
725733
pg->material_alpha);

0 commit comments

Comments
 (0)