mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
nv2a: Move point params to uniforms
Co-authored-by: Matt Borgerson <contact@mborgerson.com>
This commit is contained in:
co-authored by
Matt Borgerson
parent
6e513ed948
commit
d593869429
@@ -126,6 +126,7 @@ typedef struct ShaderBinding {
|
||||
|
||||
GLint clip_region_loc[8];
|
||||
|
||||
GLint point_params_loc[8];
|
||||
GLint material_alpha_loc;
|
||||
} ShaderBinding;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user