summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2019-03-19 12:51:39 -0400
committerRob Clark <[email protected]>2019-03-21 09:13:05 -0400
commit1088b788d8616f4cb835ceeeea969b9adcc02487 (patch)
treedfed096e6d31a00f29b316bd0d7c77c11c839348
parentd4cbc946859f56f0a2a50cd8931a6fd29ab22db9 (diff)
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 <[email protected]>
-rw-r--r--src/freedreno/ir3/ir3.h2
-rw-r--r--src/freedreno/ir3/ir3_compiler_nir.c12
-rw-r--r--src/freedreno/ir3/ir3_legalize.c12
3 files changed, 13 insertions, 13 deletions
diff --git a/src/freedreno/ir3/ir3.h b/src/freedreno/ir3/ir3.h
index b42524d22ae..8fde504196a 100644
--- a/src/freedreno/ir3/ir3.h
+++ b/src/freedreno/ir3/ir3.h
@@ -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 */
diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c
index 72549fef70d..750b90030d0 100644
--- a/src/freedreno/ir3/ir3_compiler_nir.c
+++ b/src/freedreno/ir3/ir3_compiler_nir.c
@@ -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");
diff --git a/src/freedreno/ir3/ir3_legalize.c b/src/freedreno/ir3/ir3_legalize.c
index b14a789efb2..f015c6fede8 100644
--- a/src/freedreno/ir3/ir3_legalize.c
+++ b/src/freedreno/ir3/ir3_legalize.c
@@ -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;