v3d: don't emit point coordinates varyings if the FS doesn't read them
We still need to emit them in V3D 3.x since there there is no mechanism to disable them. Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
@@ -1462,6 +1462,17 @@ var_needs_point_coord(struct v3d_compile *c, nir_variable *var)
|
||||
(1 << (var->data.location - VARYING_SLOT_VAR0)))));
|
||||
}
|
||||
|
||||
static bool
|
||||
program_reads_point_coord(struct v3d_compile *c)
|
||||
{
|
||||
nir_foreach_variable(var, &c->s->inputs) {
|
||||
if (var_needs_point_coord(c, var))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
ntq_setup_fs_inputs(struct v3d_compile *c)
|
||||
{
|
||||
@@ -2300,15 +2311,17 @@ nir_to_vir(struct v3d_compile *c)
|
||||
c->payload_w_centroid = vir_MOV(c, vir_reg(QFILE_REG, 1));
|
||||
c->payload_z = vir_MOV(c, vir_reg(QFILE_REG, 2));
|
||||
|
||||
/* XXX perf: We could set the "disable implicit point/line
|
||||
* varyings" field in the shader record and not emit these, if
|
||||
* they're not going to be used.
|
||||
/* V3D 4.x can disable implicit point coordinate varyings if
|
||||
* they are not used.
|
||||
*/
|
||||
if (c->fs_key->is_points) {
|
||||
if (c->fs_key->is_points &&
|
||||
(c->devinfo->ver < 40 || program_reads_point_coord(c))) {
|
||||
c->point_x = emit_fragment_varying(c, NULL, 0, 0);
|
||||
c->point_y = emit_fragment_varying(c, NULL, 0, 0);
|
||||
} else if (c->fs_key->is_lines) {
|
||||
c->uses_implicit_point_line_varyings = true;
|
||||
} else if (c->fs_key->is_lines && c->devinfo->ver < 40) {
|
||||
c->line_x = emit_fragment_varying(c, NULL, 0, 0);
|
||||
c->uses_implicit_point_line_varyings = true;
|
||||
}
|
||||
break;
|
||||
case MESA_SHADER_COMPUTE:
|
||||
|
@@ -513,6 +513,7 @@ struct v3d_compile {
|
||||
|
||||
bool uses_center_w;
|
||||
bool writes_z;
|
||||
bool uses_implicit_point_line_varyings;
|
||||
|
||||
/* State for whether we're executing on each channel currently. 0 if
|
||||
* yes, otherwise a block number + 1 that the channel jumped to.
|
||||
@@ -689,6 +690,7 @@ struct v3d_fs_prog_data {
|
||||
bool writes_z;
|
||||
bool disable_ez;
|
||||
bool uses_center_w;
|
||||
bool uses_implicit_point_line_varyings;
|
||||
};
|
||||
|
||||
struct v3d_compute_prog_data {
|
||||
|
@@ -688,6 +688,8 @@ v3d_fs_set_prog_data(struct v3d_compile *c,
|
||||
prog_data->writes_z = c->writes_z;
|
||||
prog_data->disable_ez = !c->s->info.fs.early_fragment_tests;
|
||||
prog_data->uses_center_w = c->uses_center_w;
|
||||
prog_data->uses_implicit_point_line_varyings =
|
||||
c->uses_implicit_point_line_varyings;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -236,6 +236,11 @@ v3d_emit_gl_shader_state(struct v3d_context *v3d,
|
||||
shader.fragment_shader_uses_real_pixel_centre_w_in_addition_to_centroid_w2 =
|
||||
v3d->prog.fs->prog_data.fs->uses_center_w;
|
||||
|
||||
#if V3D_VERSION >= 40
|
||||
shader.disable_implicit_point_line_varyings =
|
||||
!v3d->prog.fs->prog_data.fs->uses_implicit_point_line_varyings;
|
||||
#endif
|
||||
|
||||
shader.number_of_varyings_in_fragment_shader =
|
||||
v3d->prog.fs->prog_data.fs->num_inputs;
|
||||
|
||||
|
Reference in New Issue
Block a user