bool txf = (instr->op == nir_texop_txf || instr->op == nir_texop_txf_ms);
+ /* txf loads a texture without an associated sampler, but in the hardware
+ * there is an associated load of a sampler. This requires that the driver
+ * upload a dummy sampler.
+ */
+ b->shader->out->needs_dummy_sampler |= txf;
+
for (unsigned i = 0; i < instr->num_srcs; ++i) {
agx_index index = agx_src_index(&instr->src[i].src);
unsigned nr_textures = ctx->stage[stage].texture_count;
unsigned nr_samplers = ctx->stage[stage].sampler_count;
bool custom_borders = ctx->stage[stage].custom_borders;
+ bool dummy_sampler = cs->info.needs_dummy_sampler && (nr_samplers == 0);
+
+ if (dummy_sampler)
+ nr_samplers = 1;
struct agx_ptr T_tex = agx_pool_alloc_aligned(
&batch->pool, AGX_TEXTURE_LENGTH * nr_textures, 64);
/* TODO: Dirty track me to save some CPU cycles and maybe improve caching */
uint8_t *out_sampler = T_samp.cpu;
- for (unsigned i = 0; i < nr_samplers; ++i) {
- struct agx_sampler_state *sampler = ctx->stage[stage].samplers[i];
- struct agx_sampler_packed *out = (struct agx_sampler_packed *)out_sampler;
-
- if (sampler) {
- *out = sampler->desc;
-
- if (custom_borders) {
- memcpy(out_sampler + AGX_SAMPLER_LENGTH, &sampler->border,
- AGX_BORDER_LENGTH);
+ if (dummy_sampler) {
+ /* Configuration is irrelevant for the dummy sampler */
+ agx_pack(out_sampler, SAMPLER, cfg)
+ ;
+ } else {
+ for (unsigned i = 0; i < nr_samplers; ++i) {
+ struct agx_sampler_state *sampler = ctx->stage[stage].samplers[i];
+ struct agx_sampler_packed *out =
+ (struct agx_sampler_packed *)out_sampler;
+
+ if (sampler) {
+ *out = sampler->desc;
+
+ if (custom_borders) {
+ memcpy(out_sampler + AGX_SAMPLER_LENGTH, &sampler->border,
+ AGX_BORDER_LENGTH);
+ } else {
+ assert(!sampler->uses_custom_border && "invalid combination");
+ }
} else {
- assert(!sampler->uses_custom_border && "invalid combination");
+ memset(out, 0, sampler_length);
}
- } else {
- memset(out, 0, sampler_length);
- }
- out_sampler += sampler_length;
+ out_sampler += sampler_length;
+ }
}
struct agx_usc_builder b =