nv2a: Move point params to uniforms

Co-authored-by: Matt Borgerson <contact@mborgerson.com>
This commit is contained in:
Erik Abair
2025-04-30 23:43:38 -07:00
committed by GitHub
co-authored by Matt Borgerson
parent 6e513ed948
commit d593869429
5 changed files with 26 additions and 7 deletions
+1
View File
@@ -126,6 +126,7 @@ typedef struct ShaderBinding {
GLint clip_region_loc[8];
GLint point_params_loc[8];
GLint material_alpha_loc;
} ShaderBinding;
+12
View File
@@ -190,6 +190,11 @@ static void update_shader_constant_locations(ShaderBinding *binding)
binding->clip_region_loc[i] = glGetUniformLocation(binding->gl_program, tmp);
}
for (int i = 0; i < 8; ++i) {
snprintf(tmp, sizeof(tmp), "pointParams[%d]", i);
binding->point_params_loc[i] = glGetUniformLocation(binding->gl_program, tmp);
}
if (binding->state.fixed_function) {
binding->material_alpha_loc =
glGetUniformLocation(binding->gl_program, "material_alpha");
@@ -950,6 +955,13 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
x_min, y_min_xlat, x_max, y_max_xlat);
}
for (i = 0; i < 8; ++i) {
GLint loc = binding->point_params_loc[i];
if (loc != -1) {
glUniform1f(loc, pg->point_params[i]);
}
}
if (binding->material_alpha_loc != -1) {
glUniform1f(binding->material_alpha_loc, pg->material_alpha);
}
+4 -6
View File
@@ -482,14 +482,12 @@ GLSL_DEFINE(materialEmissionColor, GLSL_LTCTXA(NV_IGRAPH_XF_LTCTXA_CM_COL) ".xyz
/* FIXME: Testing */
if (state->point_params_enable) {
mstring_append_fmt(
mstring_append_fmt(uniforms, "%sfloat pointParams[8];\n", u);
mstring_append(
body,
" float d_e = length(position * modelViewMat0);\n"
" oPts.x = 1/sqrt(%f + %f*d_e + %f*d_e*d_e) + %f;\n",
state->point_params[0], state->point_params[1], state->point_params[2],
state->point_params[6]);
mstring_append_fmt(body, " oPts.x = min(oPts.x*%f + %f, 64.0) * %d;\n",
state->point_params[3], state->point_params[7],
" oPts.x = 1/sqrt(pointParams[0] + pointParams[1] * d_e + pointParams[2] * d_e * d_e) + pointParams[6];\n");
mstring_append_fmt(body, " oPts.x = min(oPts.x * pointParams[3] + pointParams[7], 64.0) * %d;\n",
state->surface_scale_factor);
} else {
mstring_append_fmt(body, " oPts.x = %f * %d;\n", state->point_size,
+1 -1
View File
@@ -191,9 +191,9 @@ typedef struct ShaderBinding {
int light_local_position_loc[NV2A_MAX_LIGHTS];
int light_local_attenuation_loc[NV2A_MAX_LIGHTS];
int specular_power_loc;
int point_params_loc;
int clip_region_loc;
int material_alpha_loc;
int uniform_attrs_loc;
+8
View File
@@ -308,6 +308,9 @@ static void update_shader_constant_locations(ShaderBinding *binding)
binding->clip_region_loc =
uniform_index(&binding->fragment->uniforms, "clipRegion");
binding->point_params_loc =
uniform_index(&binding->vertex->uniforms, "pointParams");
binding->material_alpha_loc =
uniform_index(&binding->vertex->uniforms, "material_alpha");
@@ -720,6 +723,11 @@ static void shader_update_constants(PGRAPHState *pg, ShaderBinding *binding,
uniform1iv(&binding->fragment->uniforms, binding->clip_region_loc,
8 * 4, (void *)clip_regions);
if (binding->point_params_loc != -1) {
uniform1iv(&binding->vertex->uniforms, binding->point_params_loc,
ARRAY_SIZE(pg->point_params), (void *)pg->point_params);
}
if (binding->material_alpha_loc != -1) {
uniform1f(&binding->vertex->uniforms, binding->material_alpha_loc,
pg->material_alpha);