freedreno/ir3: find # of samplers from uniform vars

When we have indirect samplers, we cannot tell the max sampler
referenced.  Instead just refer to the number of sampler uniforms.

Signed-off-by: Rob Clark <robdclark@gmail.com>
This commit is contained in:
Rob Clark 2019-03-19 12:51:39 -04:00
parent d4cbc94685
commit 1088b788d8
3 changed files with 13 additions and 13 deletions

View file

@ -1028,7 +1028,7 @@ int ir3_ra(struct ir3 *ir3, gl_shader_stage type,
bool frag_coord, bool frag_face);
/* legalize: */
void ir3_legalize(struct ir3 *ir, int *num_samp, bool *has_ssbo, int *max_bary);
void ir3_legalize(struct ir3 *ir, bool *has_ssbo, int *max_bary);
/* ************************************************************************* */
/* instruction helpers */

View file

@ -2395,6 +2395,16 @@ emit_instructions(struct ir3_context *ctx)
setup_output(ctx, var);
}
/* Find # of samplers: */
nir_foreach_variable(var, &ctx->s->uniforms) {
ctx->so->num_samp += glsl_type_get_sampler_count(var->type);
/* just assume that we'll be reading from images.. if it
* is write-only we don't have to count it, but not sure
* if there is a good way to know?
*/
ctx->so->num_samp += glsl_type_get_image_count(var->type);
}
/* Setup registers (which should only be arrays): */
nir_foreach_register(reg, &ctx->s->registers) {
ir3_declare_array(ctx, reg);
@ -2700,7 +2710,7 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
/* We need to do legalize after (for frag shader's) the "bary.f"
* offsets (inloc) have been assigned.
*/
ir3_legalize(ir, &so->num_samp, &so->has_ssbo, &max_bary);
ir3_legalize(ir, &so->has_ssbo, &max_bary);
if (ir3_shader_debug & IR3_DBG_OPTMSGS) {
printf("AFTER LEGALIZE:\n");

View file

@ -41,7 +41,6 @@
struct ir3_legalize_ctx {
struct ir3_compiler *compiler;
int num_samp;
bool has_ssbo;
int max_bary;
};
@ -218,14 +217,6 @@ legalize_block(struct ir3_legalize_ctx *ctx, struct ir3_block *block)
regmask_set(&state->needs_ss, n->regs[0]);
if (is_tex(n)) {
/* this ends up being the # of samp instructions.. but that
* is ok, everything else only cares whether it is zero or
* not. We do this here, rather than when we encounter a
* SAMP decl, because (especially in binning pass shader)
* the samp instruction(s) could get eliminated if the
* result is not used.
*/
ctx->num_samp = MAX2(ctx->num_samp, n->cat5.samp + 1);
regmask_set(&state->needs_sy, n->regs[0]);
} else if (n->opc == OPC_RESINFO) {
regmask_set(&state->needs_ss, n->regs[0]);
@ -480,7 +471,7 @@ mark_convergence_points(struct ir3 *ir)
}
void
ir3_legalize(struct ir3 *ir, int *num_samp, bool *has_ssbo, int *max_bary)
ir3_legalize(struct ir3 *ir, bool *has_ssbo, int *max_bary)
{
struct ir3_legalize_ctx *ctx = rzalloc(ir, struct ir3_legalize_ctx);
bool progress;
@ -501,7 +492,6 @@ ir3_legalize(struct ir3 *ir, int *num_samp, bool *has_ssbo, int *max_bary)
}
} while (progress);
*num_samp = ctx->num_samp;
*has_ssbo = ctx->has_ssbo;
*max_bary = ctx->max_bary;