diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 3550933a44a..01cd8c99587 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -3246,6 +3246,14 @@ panfrost_emit_primitive(struct panfrost_context *ctx, } #if PAN_ARCH >= 9 +static mali_ptr +panfrost_upload_wa_sampler(struct panfrost_batch *batch) +{ + struct panfrost_ptr T = pan_pool_alloc_desc(&batch->pool.base, SAMPLER); + pan_pack(T.cpu, SAMPLER, cfg); + return T.gpu; +} + static mali_ptr panfrost_emit_resources(struct panfrost_batch *batch, enum pipe_shader_type stage, @@ -3267,9 +3275,17 @@ panfrost_emit_resources(struct panfrost_batch *batch, batch->textures[stage], ctx->sampler_view_count[stage]); - panfrost_make_resource_table(T, PAN_TABLE_SAMPLER, - batch->samplers[stage], - ctx->sampler_count[stage]); + + if (ctx->sampler_count[stage]) { + panfrost_make_resource_table(T, PAN_TABLE_SAMPLER, + batch->samplers[stage], + ctx->sampler_count[stage]); + } else { + /* We always need at least 1 sampler for txf to work */ + panfrost_make_resource_table(T, PAN_TABLE_SAMPLER, + panfrost_upload_wa_sampler(batch), + 1); + } panfrost_make_resource_table(T, PAN_TABLE_IMAGE, batch->images[stage], diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 5b3b7f10c5e..f96ae460f97 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -3666,7 +3666,9 @@ bi_emit_tex_valhall(bi_builder *b, nir_tex_instr *instr) /* 32-bit indices to be allocated as consecutive staging registers */ bi_index sregs[VALHALL_TEX_SREG_COUNT] = { }; - bi_index sampler = bi_imm_u32(instr->sampler_index); + + bool has_sampler = nir_tex_instr_need_sampler(instr); + bi_index sampler = bi_imm_u32(has_sampler ? instr->sampler_index : 0); bi_index texture = bi_imm_u32(instr->texture_index); uint32_t tables = (PAN_TABLE_SAMPLER << 11) | (PAN_TABLE_TEXTURE << 27);